From 0e87458642fce7974b7d344bef1ba3783c1eb36c 2017-06-09 08:45:38 From: leroux Date: 2017-06-09 08:45:38 Subject: [PATCH] Merge pull request #142 from SCIQLOP-Initialisation develop Develop --- diff --git a/app/include/MainWindow.h b/app/include/MainWindow.h index 4a6256e..77c6b09 100644 --- a/app/include/MainWindow.h +++ b/app/include/MainWindow.h @@ -23,17 +23,20 @@ #define SCIQLOP_MAINWINDOW_H #include +#include #include #include #include #include #include #include -//#include "../Core/qlopservice.h" -//#include "../Core/qlopgui.h" + +#include #include +Q_DECLARE_LOGGING_CATEGORY(LOG_MainWindow) + namespace Ui { class MainWindow; } // namespace Ui @@ -55,6 +58,8 @@ private: // QWidget *m_progressWidget; // QVBoxLayout *m_progressLayout; // QList m_qlopServices; + class MainWindowPrivate; + spimpl::unique_impl_ptr impl; }; #endif // SCIQLOP_MAINWINDOW_H diff --git a/app/src/MainWindow.cpp b/app/src/MainWindow.cpp index a8a7605..e9ecc3b 100644 --- a/app/src/MainWindow.cpp +++ b/app/src/MainWindow.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -31,6 +32,9 @@ #include #include #include +#include +#include + //#include //#include //#include @@ -42,26 +46,118 @@ //#include "cdfcodec.h" //#include "amdatxtcodec.h" //#include -#include -#include -#include -MainWindow::MainWindow(QWidget *parent) : QMainWindow{parent}, m_Ui{new Ui::MainWindow} + +#include "iostream" + +Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") + +namespace { +const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; +const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; +const auto VIEWPLITTERINDEX = 2; +const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; +const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; +} + +class MainWindow::MainWindowPrivate { +public: + QSize m_LastOpenLeftInspectorSize; + QSize m_LastOpenRightInspectorSize; +}; + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow{parent}, + m_Ui{new Ui::MainWindow}, + impl{spimpl::make_unique_impl()} { m_Ui->setupUi(this); - auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); - leftSidePane->addAction("ACTION L1"); - leftSidePane->addAction("ACTION L2"); - leftSidePane->addAction("ACTION L3"); + m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); + m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); + + // NOTE: These lambda could be factorized. Be careful of theirs parameters + // Lambda that defines what's happened when clicking on the leftSidePaneInspector open button + auto openLeftInspector = [this](bool checked) { + + // Update of the last opened geometry + if (checked) { + impl->m_LastOpenLeftInspectorSize = m_Ui->leftMainInspectorWidget->size(); + } + + auto startSize = impl->m_LastOpenLeftInspectorSize; + auto endSize = startSize; + endSize.setWidth(0); + + auto currentSizes = m_Ui->splitter->sizes(); + if (checked) { + // adjust sizes individually here, e.g. + currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX] + -= impl->m_LastOpenLeftInspectorSize.width(); + currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenLeftInspectorSize.width(); + m_Ui->splitter->setSizes(currentSizes); + } + else { + // adjust sizes individually here, e.g. + currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX] + += impl->m_LastOpenLeftInspectorSize.width(); + currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenLeftInspectorSize.width(); + m_Ui->splitter->setSizes(currentSizes); + } + + }; + + // Lambda that defines what's happened when clicking on the SidePaneInspector open button + auto openRightInspector = [this](bool checked) { + + // Update of the last opened geometry + if (checked) { + impl->m_LastOpenRightInspectorSize = m_Ui->rightMainInspectorWidget->size(); + } + + auto startSize = impl->m_LastOpenRightInspectorSize; + auto endSize = startSize; + endSize.setWidth(0); + + auto currentSizes = m_Ui->splitter->sizes(); + if (checked) { + // adjust sizes individually here, e.g. + currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX] + -= impl->m_LastOpenRightInspectorSize.width(); + currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenRightInspectorSize.width(); + m_Ui->splitter->setSizes(currentSizes); + } + else { + // adjust sizes individually here, e.g. + currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX] + += impl->m_LastOpenRightInspectorSize.width(); + currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenRightInspectorSize.width(); + m_Ui->splitter->setSizes(currentSizes); + } + + }; + + + QToolBar *leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); + auto openLeftInspectorAction = leftSidePane->addAction( + QIcon{ + ":/icones/openInspector.png", + }, + tr("Show/hide the left inspector"), openLeftInspector); + + openLeftInspectorAction->setCheckable(true); auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); - rightSidePane->addAction("ACTION R1"); - rightSidePane->addAction("ACTION R2"); - rightSidePane->addAction("ACTION R3"); + auto openRightInspectorAction = rightSidePane->addAction( + QIcon{ + ":/icones/openInspector.png", + }, + tr("Show/hide the right inspector"), openRightInspector); + + openRightInspectorAction->setCheckable(true); - this->menuBar()->addAction("File"); - auto mainToolBar = this->addToolBar("MainToolBar"); - mainToolBar->addAction("A1"); + this->menuBar()->addAction(tr("File")); + auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar")); + mainToolBar->addAction(QStringLiteral("A1")); // Widgets / controllers connections connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)), diff --git a/app/ui/MainWindow.ui b/app/ui/MainWindow.ui index 9fef44e..1b9b0ff 100644 --- a/app/ui/MainWindow.ui +++ b/app/ui/MainWindow.ui @@ -34,7 +34,7 @@ - 3 + 0 0 @@ -49,129 +49,73 @@ 0 - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - - - - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 + + + Qt::Horizontal + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + + + 0 + 0 + - - - - - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + @@ -182,7 +126,7 @@ 0 0 800 - 26 + 28 diff --git a/cmake/sciqlop_applications.cmake b/cmake/sciqlop_applications.cmake index b36eb27..1c47446 100644 --- a/cmake/sciqlop_applications.cmake +++ b/cmake/sciqlop_applications.cmake @@ -35,6 +35,13 @@ ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/gui") ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/app") +OPTION (BUILD_PLUGINS "Build the plugins" OFF) +IF(BUILD_PLUGINS) + set(sciqlop-mockplugin_DIR "${CMAKE_SOURCE_DIR}/plugins/mockplugin/cmake") + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-mockplugin_DIR}") + ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugins/mockplugin") +ENDIF(BUILD_PLUGINS) + # LOGGER set(QTLOGGING_INI_FILE "${CMAKE_SOURCE_DIR}/config/QtProject/qtlogging.ini") FILE(COPY ${QTLOGGING_INI_FILE} DESTINATION ${CONFIG_OUTPUT_PATH}) diff --git a/gui/resources/icones/openInspector.png b/gui/resources/icones/openInspector.png new file mode 100755 index 0000000000000000000000000000000000000000..ca13c20f8ed91585f2519264cfde1aae04bdb0aa GIT binary patch literal 1450 zc$@*M1y%ZqP)tsMO3T`))!G*L?Ojuu|9|og8JYe(5DJDq68Fwr1qf_!AiC9 zM-@u^QK1PWCfiogn)opHfIgrH*a9ps^3ET?55O=m1RMp%4P^|DCSVuv zF*1^~6<#yIhrmM-?Vt#00c(M$qpKz5`4}()d=HEQ(}>xFOovrK9_RvYLaZl=N#J$h zji_A{SO)AvI+Gl|A>c{i21-+Q1JI2q^V1Z%)4+4U(hwb}1lxh{hzmCX90WE7wt%f&IWg#7CtcF=s0@1J5J7hU0rF;+r$%8^cQA1L7lb7}?sg!g}CH zLWV*7wrYlTzzM~)06b{T^ndUOa6!rQInZjwY#ne~G5Zl&v8#<6firlyzQsTZ&BRCk z3q&Ecf_C5}UcO-h`V5W4=llsoA+?4U;!1dzKnvr3;$~kM(G-0sW15A7K&+wib*R@!IPTE?RatfbYk?g}&5;4>~5W_3f?E z0!$%&8K-zM29RWi)7n8Z(cn(RpFaZJVaVrYe1Gm+$O|8-7ea=#Nmws}4x1F8!D4@I z!>6%^426R16aa7>?-#_fRY_NI2R?H%U@TOYcsu%S1n$xgk_zZk?N2Nv${5<3bsztu z0OvN2A<4^n!PodCYRu=zCE8n}_6Ra(>IE~vH&MF_m7vuM*nruK~IT%VeOYurt( z0PXIMW*|`37**{K*U$>k9^bUJG*y7^(_CM*0(3^TK>eYp0xnBv1)Nvy#T)?52c5^9 zv+!KnO-hWN7YT|g;5XIITT4>~bgK4Q*U$?11u0H|#gY6h6|PTHz&UqQD_{nx%m6u` z&$@iZ5;I+)(?^j&{5OfmJ(%*d86E<0*>O%<6cXN zGR8g8?phUrDz~4=Tk<)Wr02TAn#S+&xO9Y8i}4}kr-ip zaMA27pc8TI+yPIjCC?WPP9kM#AXDPC(9#*B0kL9d@-I+Ej$4q2Iie>? zFNUr*Rs*N-at;tMpj&|yA!;SGhaw&T9mG3-9Jo3(lUAe%QBQ~N&`ip}HsB|`T&EBR z$ONrOIO&*OL<*9sfd=4l{DS93-mLQuO~8AK=`2!^biFlWg?x$(0~nb7e8?e1h;EB? z+vEXk7sxe8{gSH#bX(nCs+7U%LF(}INK7GRDVqZF*$ljbch9wxQ}I4uDV883@H=tg z+?;#{xP{UVVRFE&h?RYoLU#iB6sK$t&mpAQtOA}uI-FLnK8d*2`lBi5pEpNWCz8G0 zO8Qh9N20nnso~?h-!P`knJYOlS7mgMrwbqAJW^_?J!7_!Uu7{BX z<}ng!tdPihj{2%jxq_O;zdMYR6%EGQng9R*07*qoM6N<$ Eg3E%EY5)KL literal 0 Hc$@ + + icones/openInspector.png + + diff --git a/gui/src/SidePane/SqpSidePane.cpp b/gui/src/SidePane/SqpSidePane.cpp index da69e6c..72e6ea9 100644 --- a/gui/src/SidePane/SqpSidePane.cpp +++ b/gui/src/SidePane/SqpSidePane.cpp @@ -24,16 +24,23 @@ static const QString SQPSIDEPANESTYLESHEET SqpSidePane::SqpSidePane(QWidget *parent) : QWidget{parent}, ui{new Ui::SqpSidePane} { - QVBoxLayout *sidePaneLayout = new QVBoxLayout(this); - sidePaneLayout->setContentsMargins(0, 0, 0, 0); - this->setLayout(sidePaneLayout); + // QVBoxLayout *sidePaneLayout = new QVBoxLayout(this); + // sidePaneLayout->setContentsMargins(0, 0, 0, 0); + // this->setLayout(sidePaneLayout); ui->setupUi(this); - m_SidePaneToolbar = new QToolBar(this); + m_SidePaneToolbar = new QToolBar(); m_SidePaneToolbar->setOrientation(Qt::Vertical); - sidePaneLayout->addWidget(m_SidePaneToolbar); + this->layout()->addWidget(m_SidePaneToolbar); m_SidePaneToolbar->setStyleSheet(SQPSIDEPANESTYLESHEET); + + this->setStyleSheet( + " QWidget {" + "background: red;" + + "border: 1px;" + " }"); } SqpSidePane::~SqpSidePane() diff --git a/gui/src/Visualization/VisualizationWidget.cpp b/gui/src/Visualization/VisualizationWidget.cpp index 14b8f90..91c1f61 100644 --- a/gui/src/Visualization/VisualizationWidget.cpp +++ b/gui/src/Visualization/VisualizationWidget.cpp @@ -20,7 +20,7 @@ VisualizationWidget::VisualizationWidget(QWidget *parent) addTabViewButton->setAutoRaise(true); ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); - auto addTabView = [&](bool checked) { + auto addTabView = [&]() { auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget), QString("View %1").arg(ui->tabWidget->count() + 1)); qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); diff --git a/gui/ui/DataSource/DataSourceWidget.ui b/gui/ui/DataSource/DataSourceWidget.ui index a7cf875..473ed3b 100644 --- a/gui/ui/DataSource/DataSourceWidget.ui +++ b/gui/ui/DataSource/DataSourceWidget.ui @@ -14,8 +14,26 @@ Data sources + + 0 + + + 0 + + + 0 + + + 0 + - + + + + 1 + + + diff --git a/gui/ui/sidepane/SqpSidePane.ui b/gui/ui/sidepane/SqpSidePane.ui index 1213ccc..2b99c76 100644 --- a/gui/ui/sidepane/SqpSidePane.ui +++ b/gui/ui/sidepane/SqpSidePane.ui @@ -1,21 +1,42 @@ + - - - SqpSidePane - + 0 0 - 400 - 300 + 12 + 12 + + + 45 + 16777215 + + Form + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + - + diff --git a/plugins/mockplugin/CMakeLists.txt b/plugins/mockplugin/CMakeLists.txt new file mode 100644 index 0000000..fed127f --- /dev/null +++ b/plugins/mockplugin/CMakeLists.txt @@ -0,0 +1,145 @@ +## mockplugin - CMakeLists.txt +STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) +SET(SQPMOCKPLUGIN_LIBRARY_NAME "${LIBRARY_PREFFIX}_mockplugin${DEBUG_SUFFIX}") +SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") +SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include") +SET(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources") + +# Include mockplugin directory +INCLUDE_DIRECTORIES(${INCLUDES_DIR}) +INCLUDE_DIRECTORIES(${RESOURCES_DIR}) + +# +# Find Qt modules +# +SCIQLOP_FIND_QT(Core Widgets) + +# +# Find dependent libraries +# ======================== + +# sciqlop plugin +find_package(sciqlop-plugin) +INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR}) + +# sciqlop core +find_package(sciqlop-core) +INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR}) +list(APPEND LIBRARIES ${SCIQLOP-CORE_LIBRARIES}) + +# sciqlop gui +find_package(sciqlop-gui) +INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR}) +list(APPEND LIBRARIES ${SCIQLOP-GUI_LIBRARIES}) + +# Resources files +FILE (GLOB_RECURSE PROJECT_RESOURCES ${RESOURCES_DIR}/*.json) + +# +# Compile the library +# +FILE (GLOB_RECURSE MODULE_SOURCES + ${INCLUDES_DIR}/*.h + ${SOURCES_DIR}/*.c + ${SOURCES_DIR}/*.cpp + ${SOURCES_DIR}/*.h + ${PROJECT_RESOURCES}) + +ADD_LIBRARY(${SQPMOCKPLUGIN_LIBRARY_NAME} ${MODULE_SOURCES}) +set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD 14) +set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) + +TARGET_LINK_LIBRARIES(${SQPMOCKPLUGIN_LIBRARY_NAME} ${LIBRARIES}) +qt5_use_modules(${SQPMOCKPLUGIN_LIBRARY_NAME} Core Widgets) + +# From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html +# Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order. +# The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets +IF(BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES(${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT") +ELSE() + TARGET_COMPILE_DEFINITIONS(${SQPMOCKPLUGIN_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES") +ENDIF() + +# Set the variable to parent scope so that the other projects can copy the +# dependent shared libraries +SCIQLOP_SET_TO_PARENT_SCOPE(SQPMOCKPLUGIN_LIBRARY_NAME) + +# Copy extern shared libraries to the lib folder +SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPMOCKPLUGIN_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES}) + +# Add the files to the list of files to be analyzed +LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) +# Vera++ exclusion files +#LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) + +# +# Compile the tests +# +IF(BUILD_TESTS) + INCLUDE_DIRECTORIES(${SOURCES_DIR}) + FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp) + FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h) + SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME}) + + FOREACH( testFile ${TESTS_SOURCES} ) + GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) + GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) + + # Add to the list of sources files all the sources in the same + # directory that aren't another test + FILE (GLOB currentTestSources + ${testDirectory}/*.c + ${testDirectory}/*.cpp + ${testDirectory}/*.h) + LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) + # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) + + ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) + set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14) + set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON) + TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} ) + qt5_use_modules(${testName} Test) + + ADD_TEST( NAME ${testName} COMMAND ${testName} ) + + SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) + ENDFOREACH( testFile ) + + LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) + LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) + LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) + SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) +ENDIF(BUILD_TESTS) + +# +# Set the files that must be formatted by clang-format. +# +LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) + +# +# Set the directories that doxygen must browse to generate the +# documentation. +# +# Source directories: +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) +# Source directories to exclude from the documentation generation +#LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) + +# +# Set the directories with the sources to analyze and propagate the +# modification to the parent scope +# +# Source directories to analyze: +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) +# Source directories to exclude from the analysis +#LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) diff --git a/plugins/mockplugin/cmake/Findsciqlop-mockplugin.cmake b/plugins/mockplugin/cmake/Findsciqlop-mockplugin.cmake new file mode 100644 index 0000000..0c0d764 --- /dev/null +++ b/plugins/mockplugin/cmake/Findsciqlop-mockplugin.cmake @@ -0,0 +1,21 @@ +# - Try to find sciqlop-mockplugin +# Once done this will define +# SCIQLOP-MOCKPLUGIN_FOUND - System has sciqlop-mockplugin +# SCIQLOP-MOCKPLUGIN_INCLUDE_DIR - The sciqlop-mockplugin include directories +# SCIQLOP-MOCKPLUGIN_LIBRARIES - The libraries needed to use sciqlop-mockplugin + +if(SCIQLOP-MOCKPLUGIN_FOUND) + return() +endif(SCIQLOP-MOCKPLUGIN_FOUND) + +set(SCIQLOP-MOCKPLUGIN_INCLUDE_DIR ${sciqlop-mockplugin_DIR}/../include) + +set (OS_LIB_EXTENSION "so") + +if(WIN32) + set (OS_LIB_EXTENSION "dll") +endif(WIN32) +# TODO: Add Mac Support +set(SCIQLOP-MOCKPLUGIN_LIBRARIES ${LIBRARY_OUTPUT_PATH}/libsciqlop_mockplugin${DEBUG_SUFFIX}.${OS_LIB_EXTENSION}) + +set(SCIQLOP-MOCKPLUGIN_FOUND TRUE) diff --git a/plugins/mockplugin/include/MockPlugin.h b/plugins/mockplugin/include/MockPlugin.h new file mode 100644 index 0000000..7d18987 --- /dev/null +++ b/plugins/mockplugin/include/MockPlugin.h @@ -0,0 +1,27 @@ +#ifndef SCIQLOP_MOCKPLUGIN_H +#define SCIQLOP_MOCKPLUGIN_H + +#include + +#include + +#include + +Q_DECLARE_LOGGING_CATEGORY(LOG_MockPlugin) + +class DataSourceItem; + +class MockPlugin : public QObject, public IPlugin { + Q_OBJECT + Q_INTERFACES(IPlugin) + Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE "mockplugin.json") +public: + /// @sa IPlugin::initialize() + void initialize() override; + +private: + /// Creates the data source item relative to the plugin + std::unique_ptr createDataSourceItem() const noexcept; +}; + +#endif // SCIQLOP_MOCKPLUGIN_H diff --git a/plugins/mockplugin/resources/mockplugin.json b/plugins/mockplugin/resources/mockplugin.json new file mode 100644 index 0000000..09ac778 --- /dev/null +++ b/plugins/mockplugin/resources/mockplugin.json @@ -0,0 +1,3 @@ +{ + "name" : "MockPlugin" +} diff --git a/plugins/mockplugin/src/MockPlugin.cpp b/plugins/mockplugin/src/MockPlugin.cpp new file mode 100644 index 0000000..599ad04 --- /dev/null +++ b/plugins/mockplugin/src/MockPlugin.cpp @@ -0,0 +1,55 @@ +#include + +#include +#include + +#include + +Q_LOGGING_CATEGORY(LOG_MockPlugin, "MockPlugin") + +namespace { + +/// Name of the data source +const auto DATA_SOURCE_NAME = QStringLiteral("MMS"); + +} // namespace + +void MockPlugin::initialize() +{ + if (auto app = sqpApp) { + // Registers to the data source controller + auto &dataSourceController = app->dataSourceController(); + auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME); + + dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem()); + } + else { + qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application"); + } +} + +std::unique_ptr MockPlugin::createDataSourceItem() const noexcept +{ + // Magnetic field products + auto fgmProduct = std::make_unique(DataSourceItemType::PRODUCT, + QVector{QStringLiteral("FGM")}); + auto scProduct = std::make_unique(DataSourceItemType::PRODUCT, + QVector{QStringLiteral("SC")}); + + auto magneticFieldFolder = std::make_unique( + DataSourceItemType::NODE, QVector{QStringLiteral("Magnetic field")}); + magneticFieldFolder->appendChild(std::move(fgmProduct)); + magneticFieldFolder->appendChild(std::move(scProduct)); + + // Electric field products + auto electricFieldFolder = std::make_unique( + DataSourceItemType::NODE, QVector{QStringLiteral("Electric field")}); + + // Root + auto root = std::make_unique(DataSourceItemType::NODE, + QVector{DATA_SOURCE_NAME}); + root->appendChild(std::move(magneticFieldFolder)); + root->appendChild(std::move(electricFieldFolder)); + + return std::move(root); +}