diff --git a/app/ui/MainWindow.ui b/app/ui/MainWindow.ui index 1b9b0ff..30bc87a 100644 --- a/app/ui/MainWindow.ui +++ b/app/ui/MainWindow.ui @@ -77,7 +77,7 @@ - + @@ -126,7 +126,7 @@ 0 0 800 - 28 + 26 @@ -152,6 +152,12 @@
DataSource/DataSourceWidget.h
1 + + VariableInspectorWidget + QWidget +
Variable/VariableInspectorWidget.h
+ 1 +
diff --git a/core/include/Variable/Variable.h b/core/include/Variable/Variable.h new file mode 100644 index 0000000..ff5f718 --- /dev/null +++ b/core/include/Variable/Variable.h @@ -0,0 +1,20 @@ +#ifndef SCIQLOP_VARIABLE_H +#define SCIQLOP_VARIABLE_H + +#include + +/** + * @brief The Variable struct represents a variable in SciQlop. + */ +struct Variable { + explicit Variable(const QString &name, const QString &unit, const QString &mission) + : m_Name{name}, m_Unit{unit}, m_Mission{mission} + { + } + + QString m_Name; + QString m_Unit; + QString m_Mission; +}; + +#endif // SCIQLOP_VARIABLE_H diff --git a/core/include/Variable/VariableController.h b/core/include/Variable/VariableController.h new file mode 100644 index 0000000..0ec574b --- /dev/null +++ b/core/include/Variable/VariableController.h @@ -0,0 +1,39 @@ +#ifndef SCIQLOP_VARIABLECONTROLLER_H +#define SCIQLOP_VARIABLECONTROLLER_H + +#include +#include + +#include + +class Variable; +Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController) + +/** + * @brief The VariableController class aims to handle the variables in SciQlop. + */ +class VariableController : public QObject { + Q_OBJECT +public: + explicit VariableController(QObject *parent = 0); + virtual ~VariableController(); + + /** + * Creates a new variable + * @param name the name of the new variable + * @return the variable if it was created successfully, nullptr otherwise + */ + Variable *createVariable(const QString &name) noexcept; + +public slots: + void initialize(); + void finalize(); + +private: + void waitForFinish(); + + class VariableControllerPrivate; + spimpl::unique_impl_ptr impl; +}; + +#endif // SCIQLOP_VARIABLECONTROLLER_H diff --git a/core/include/Variable/VariableModel.h b/core/include/Variable/VariableModel.h new file mode 100644 index 0000000..ad2e627 --- /dev/null +++ b/core/include/Variable/VariableModel.h @@ -0,0 +1,31 @@ +#ifndef SCIQLOP_VARIABLEMODEL_H +#define SCIQLOP_VARIABLEMODEL_H + +#include + +#include + +Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel) + +class Variable; + +/** + * @brief The VariableModel class aims to hold the variables that have been created in SciQlop + */ +class VariableModel { +public: + explicit VariableModel(); + + /** + * Creates a new variable in the model + * @param name the name of the new variable + * @return the variable if it was created successfully, nullptr otherwise + */ + Variable *createVariable(const QString &name) noexcept; + +private: + class VariableModelPrivate; + spimpl::unique_impl_ptr impl; +}; + +#endif // SCIQLOP_VARIABLEMODEL_H diff --git a/core/src/Variable/VariableController.cpp b/core/src/Variable/VariableController.cpp new file mode 100644 index 0000000..bfeefc6 --- /dev/null +++ b/core/src/Variable/VariableController.cpp @@ -0,0 +1,53 @@ +#include +#include + +#include +#include + +Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController") + +struct VariableController::VariableControllerPrivate { + explicit VariableControllerPrivate() + : m_WorkingMutex{}, m_VariableModel{std::make_unique()} + { + } + + QMutex m_WorkingMutex; + std::unique_ptr m_VariableModel; +}; + +VariableController::VariableController(QObject *parent) + : QObject{parent}, impl{spimpl::make_unique_impl()} +{ + qCDebug(LOG_VariableController()) + << tr("VariableController construction") << QThread::currentThread(); +} + +VariableController::~VariableController() +{ + qCDebug(LOG_VariableController()) + << tr("VariableController destruction") << QThread::currentThread(); + this->waitForFinish(); +} + +Variable *VariableController::createVariable(const QString &name) noexcept +{ + return impl->m_VariableModel->createVariable(name); +} + +void VariableController::initialize() +{ + qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread(); + impl->m_WorkingMutex.lock(); + qCDebug(LOG_VariableController()) << tr("VariableController init END"); +} + +void VariableController::finalize() +{ + impl->m_WorkingMutex.unlock(); +} + +void VariableController::waitForFinish() +{ + QMutexLocker locker{&impl->m_WorkingMutex}; +} diff --git a/core/src/Variable/VariableModel.cpp b/core/src/Variable/VariableModel.cpp new file mode 100644 index 0000000..7758670 --- /dev/null +++ b/core/src/Variable/VariableModel.cpp @@ -0,0 +1,24 @@ +#include + +#include + +Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel") + +struct VariableModel::VariableModelPrivate { + /// Variables created in SciQlop + std::vector > m_Variables; +}; + +VariableModel::VariableModel() : impl{spimpl::make_unique_impl()} +{ +} + +Variable *VariableModel::createVariable(const QString &name) noexcept +{ + /// @todo For the moment, the other data of the variable is initialized with default values + auto variable + = std::make_unique(name, QStringLiteral("unit"), QStringLiteral("mission")); + impl->m_Variables.push_back(std::move(variable)); + + return impl->m_Variables.back().get(); +} diff --git a/gui/include/DataSource/DataSourceWidget.h b/gui/include/DataSource/DataSourceWidget.h index 19d351f..c661fa2 100644 --- a/gui/include/DataSource/DataSourceWidget.h +++ b/gui/include/DataSource/DataSourceWidget.h @@ -1,10 +1,12 @@ #ifndef SCIQLOP_DATASOURCEWIDGET_H #define SCIQLOP_DATASOURCEWIDGET_H -#include - #include +namespace Ui { +class DataSourceWidget; +} // Ui + class DataSourceItem; /** @@ -26,8 +28,7 @@ public slots: void addDataSource(DataSourceItem *dataSource) noexcept; private: - class DataSourceWidgetPrivate; - spimpl::unique_impl_ptr impl; + Ui::DataSourceWidget *ui; }; #endif // SCIQLOP_DATASOURCEWIDGET_H diff --git a/gui/include/SqpApplication.h b/gui/include/SqpApplication.h index db80758..2d2944a 100644 --- a/gui/include/SqpApplication.h +++ b/gui/include/SqpApplication.h @@ -16,6 +16,7 @@ Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication) #define sqpApp (static_cast(QCoreApplication::instance())) class DataSourceController; +class VariableController; class VisualizationController; /** @@ -36,6 +37,7 @@ public: /// Accessors for the differents sciqlop controllers DataSourceController &dataSourceController() const noexcept; + VariableController &variableController() const noexcept; VisualizationController &visualizationController() const noexcept; private: diff --git a/gui/include/Variable/VariableInspectorWidget.h b/gui/include/Variable/VariableInspectorWidget.h new file mode 100644 index 0000000..c4d5f41 --- /dev/null +++ b/gui/include/Variable/VariableInspectorWidget.h @@ -0,0 +1,26 @@ +#ifndef SCIQLOP_VARIABLEINSPECTORWIDGET_H +#define SCIQLOP_VARIABLEINSPECTORWIDGET_H + +#include + +namespace Ui { +class VariableInspectorWidget; +} // Ui + +/** + * @brief The VariableInspectorWidget class representes represents the variable inspector, from + * which it is possible to view the loaded variables, handle them or trigger their display in + * visualization + */ +class VariableInspectorWidget : public QWidget { + Q_OBJECT + +public: + explicit VariableInspectorWidget(QWidget *parent = 0); + virtual ~VariableInspectorWidget(); + +private: + Ui::VariableInspectorWidget *ui; +}; + +#endif // SCIQLOP_VARIABLEINSPECTORWIDGET_H diff --git a/gui/src/DataSource/DataSourceWidget.cpp b/gui/src/DataSource/DataSourceWidget.cpp index 79749aa..0891a00 100644 --- a/gui/src/DataSource/DataSourceWidget.cpp +++ b/gui/src/DataSource/DataSourceWidget.cpp @@ -33,24 +33,13 @@ DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource) } // namespace -class DataSourceWidget::DataSourceWidgetPrivate { -public: - explicit DataSourceWidgetPrivate(DataSourceWidget &widget) - : m_Ui{std::make_unique()} - { - m_Ui->setupUi(&widget); - - // Set tree properties - m_Ui->treeWidget->setColumnCount(TREE_NB_COLUMNS); - m_Ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS); - } - - std::unique_ptr m_Ui; -}; - -DataSourceWidget::DataSourceWidget(QWidget *parent) - : QWidget{parent}, impl{spimpl::make_unique_impl(*this)} +DataSourceWidget::DataSourceWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::DataSourceWidget} { + ui->setupUi(this); + + // Set tree properties + ui->treeWidget->setColumnCount(TREE_NB_COLUMNS); + ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS); } void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept @@ -58,6 +47,6 @@ void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept // Creates the item associated to the source and adds it to the tree widget. The tree widget // takes the ownership of the item if (dataSource) { - impl->m_Ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource)); + ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource)); } } diff --git a/gui/src/SqpApplication.cpp b/gui/src/SqpApplication.cpp index 0a69f1f..5d6c7d8 100644 --- a/gui/src/SqpApplication.cpp +++ b/gui/src/SqpApplication.cpp @@ -2,6 +2,7 @@ #include #include +#include #include Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") @@ -10,9 +11,11 @@ class SqpApplication::SqpApplicationPrivate { public: SqpApplicationPrivate() : m_DataSourceController{std::make_unique()}, + m_VariableController{std::make_unique()}, m_VisualizationController{std::make_unique()} { m_DataSourceController->moveToThread(&m_DataSourceControllerThread); + m_VariableController->moveToThread(&m_VariableControllerThread); m_VisualizationController->moveToThread(&m_VisualizationControllerThread); } @@ -22,13 +25,18 @@ public: m_DataSourceControllerThread.quit(); m_DataSourceControllerThread.wait(); + m_VariableControllerThread.quit(); + m_VariableControllerThread.wait(); + m_VisualizationControllerThread.quit(); m_VisualizationControllerThread.wait(); } std::unique_ptr m_DataSourceController; + std::unique_ptr m_VariableController; std::unique_ptr m_VisualizationController; QThread m_DataSourceControllerThread; + QThread m_VariableControllerThread; QThread m_VisualizationControllerThread; }; @@ -43,6 +51,11 @@ SqpApplication::SqpApplication(int &argc, char **argv) connect(&impl->m_DataSourceControllerThread, &QThread::finished, impl->m_DataSourceController.get(), &DataSourceController::finalize); + connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), + &VariableController::initialize); + connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), + &VariableController::finalize); + connect(&impl->m_VisualizationControllerThread, &QThread::started, impl->m_VisualizationController.get(), &VisualizationController::initialize); connect(&impl->m_VisualizationControllerThread, &QThread::finished, @@ -50,6 +63,7 @@ SqpApplication::SqpApplication(int &argc, char **argv) impl->m_DataSourceControllerThread.start(); + impl->m_VariableControllerThread.start(); impl->m_VisualizationControllerThread.start(); } @@ -66,6 +80,11 @@ DataSourceController &SqpApplication::dataSourceController() const noexcept return *impl->m_DataSourceController; } +VariableController &SqpApplication::variableController() const noexcept +{ + return *impl->m_VariableController; +} + VisualizationController &SqpApplication::visualizationController() const noexcept { return *impl->m_VisualizationController; diff --git a/gui/src/Variable/VariableInspectorWidget.cpp b/gui/src/Variable/VariableInspectorWidget.cpp new file mode 100644 index 0000000..724016c --- /dev/null +++ b/gui/src/Variable/VariableInspectorWidget.cpp @@ -0,0 +1,14 @@ +#include + +#include + +VariableInspectorWidget::VariableInspectorWidget(QWidget *parent) + : QWidget{parent}, ui{new Ui::VariableInspectorWidget} +{ + ui->setupUi(this); +} + +VariableInspectorWidget::~VariableInspectorWidget() +{ + delete ui; +} diff --git a/gui/ui/Variable/VariableInspectorWidget.ui b/gui/ui/Variable/VariableInspectorWidget.ui new file mode 100644 index 0000000..24fdb97 --- /dev/null +++ b/gui/ui/Variable/VariableInspectorWidget.ui @@ -0,0 +1,31 @@ + + + VariableInspectorWidget + + + + 0 + 0 + 400 + 300 + + + + Variables + + + + + + true + + + true + + + + + + + +