##// END OF EJS Templates
Merge pull request 390 from SciQLop-fork develop...
Merge pull request 390 from SciQLop-fork develop Develop

File last commit:

r1043:a94048bf05e3
r1157:3d2098c90692 merge
Show More
MockPlugin.cpp
118 lines | 4.8 KiB | text/x-c | CppLexer
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r129 #include "MockPlugin.h"
#include "CosinusProvider.h"
Alexandre Leroux
Handles parametric frequency
r782 #include "MockDefs.h"
Alexandre Leroux
Create mock plugin
r99
#include <DataSource/DataSourceController.h>
#include <DataSource/DataSourceItem.h>
Alexandre Leroux
Adds action in the mock plugin to load products
r146 #include <DataSource/DataSourceItemAction.h>
Alexandre Leroux
Create mock plugin
r99
#include <SqpApplication.h>
Q_LOGGING_CATEGORY(LOG_MockPlugin, "MockPlugin")
namespace {
/// Name of the data source
const auto DATA_SOURCE_NAME = QStringLiteral("MMS");
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r129 /// Creates the data provider relative to the plugin
std::unique_ptr<IDataProvider> createDataProvider() noexcept
Alexandre Leroux
Create mock plugin
r99 {
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r129 return std::make_unique<CosinusProvider>();
Alexandre Leroux
Create mock plugin
r99 }
Alexandre Leroux
Handles parametric frequency
r782 std::unique_ptr<DataSourceItem> createProductItem(const QVariantHash &data,
Alexandre Leroux
Updates DataSourceController::loadProductItem() method...
r167 const QUuid &dataSourceUid)
Alexandre Leroux
Adds action in the mock plugin to load products
r146 {
Alexandre Leroux
Handles parametric frequency
r782 auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, data);
Alexandre Leroux
Sets the name of the plugin for products and components...
r1036
// Adds plugin name to product metadata
result->setData(DataSourceItem::PLUGIN_DATA_KEY, DATA_SOURCE_NAME);
Alexandre Leroux
Handles parametric frequency
r782 auto productName = data.value(DataSourceItem::NAME_DATA_KEY).toString();
Alexandre Leroux
Adds action in the mock plugin to load products
r146
// Add action to load product from DataSourceController
result->addAction(std::make_unique<DataSourceItemAction>(
Alexandre Leroux
Updates DataSourceController::loadProductItem() method...
r167 QObject::tr("Load %1 product").arg(productName),
[productName, dataSourceUid](DataSourceItem &item) {
Alexandre Leroux
Adds action in the mock plugin to load products
r146 if (auto app = sqpApp) {
Alexandre Leroux
Updates DataSourceController::loadProductItem() method...
r167 app->dataSourceController().loadProductItem(dataSourceUid, item);
Alexandre Leroux
Adds action in the mock plugin to load products
r146 }
}));
return result;
}
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r129 /// Creates the data source item relative to the plugin
Alexandre Leroux
Updates DataSourceController::loadProductItem() method...
r167 std::unique_ptr<DataSourceItem> createDataSourceItem(const QUuid &dataSourceUid) noexcept
Alexandre Leroux
Create mock plugin
r99 {
// Magnetic field products
Alexandre Leroux
Updates references to DataSourceItem after changes
r343 auto magneticFieldFolder = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
Alexandre Leroux
Changes the name of the mokc plugin nodes to facilitate their access in the merged tree
r1043 QStringLiteral("_Magnetic field"));
Alexandre Leroux
Changes plugin products to integrate parametric frequencies
r783 magneticFieldFolder->appendChild(
createProductItem({{DataSourceItem::NAME_DATA_KEY, QStringLiteral("Scalar 10 Hz")},
Alexandre Leroux
Generates vectors (5)...
r788 {COSINUS_TYPE_KEY, "scalar"},
Alexandre Leroux
Changes plugin products to integrate parametric frequencies
r783 {COSINUS_FREQUENCY_KEY, 10.}},
dataSourceUid));
magneticFieldFolder->appendChild(
createProductItem({{DataSourceItem::NAME_DATA_KEY, QStringLiteral("Scalar 60 Hz")},
Alexandre Leroux
Generates vectors (5)...
r788 {COSINUS_TYPE_KEY, "scalar"},
Alexandre Leroux
Changes plugin products to integrate parametric frequencies
r783 {COSINUS_FREQUENCY_KEY, 60.}},
dataSourceUid));
magneticFieldFolder->appendChild(
createProductItem({{DataSourceItem::NAME_DATA_KEY, QStringLiteral("Scalar 100 Hz")},
Alexandre Leroux
Generates vectors (5)...
r788 {COSINUS_TYPE_KEY, "scalar"},
{COSINUS_FREQUENCY_KEY, 100.}},
dataSourceUid));
magneticFieldFolder->appendChild(
createProductItem({{DataSourceItem::NAME_DATA_KEY, QStringLiteral("Vector 10 Hz")},
{COSINUS_TYPE_KEY, "vector"},
{COSINUS_FREQUENCY_KEY, 10.}},
dataSourceUid));
magneticFieldFolder->appendChild(
createProductItem({{DataSourceItem::NAME_DATA_KEY, QStringLiteral("Vector 60 Hz")},
{COSINUS_TYPE_KEY, "vector"},
{COSINUS_FREQUENCY_KEY, 60.}},
dataSourceUid));
magneticFieldFolder->appendChild(
createProductItem({{DataSourceItem::NAME_DATA_KEY, QStringLiteral("Vector 100 Hz")},
{COSINUS_TYPE_KEY, "vector"},
Alexandre Leroux
Changes plugin products to integrate parametric frequencies
r783 {COSINUS_FREQUENCY_KEY, 100.}},
dataSourceUid));
Alexandre Leroux
Adds a spectrogram product in the plugin tree (which can't be displayed for now)
r897 magneticFieldFolder->appendChild(
createProductItem({{DataSourceItem::NAME_DATA_KEY, QStringLiteral("Spectrogram 1 Hz")},
{COSINUS_TYPE_KEY, "spectrogram"},
{COSINUS_FREQUENCY_KEY, 1.}},
dataSourceUid));
Alexandre Leroux
Create mock plugin
r99
// Electric field products
Alexandre Leroux
Updates references to DataSourceItem after changes
r343 auto electricFieldFolder = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
Alexandre Leroux
Changes the name of the mokc plugin nodes to facilitate their access in the merged tree
r1043 QStringLiteral("_Electric field"));
Alexandre Leroux
Create mock plugin
r99
// Root
Alexandre Leroux
Updates references to DataSourceItem after changes
r343 auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE, DATA_SOURCE_NAME);
Alexandre Leroux
Create mock plugin
r99 root->appendChild(std::move(magneticFieldFolder));
root->appendChild(std::move(electricFieldFolder));
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r129 return root;
}
} // 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);
// Sets data source tree
Alexandre Leroux
Updates DataSourceController::loadProductItem() method...
r167 dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem(dataSourceUid));
Alexandre Leroux
Updates the MockPlugin::initialize() to create a cosinus provider and register it to the data source controller
r129
// Sets data provider
dataSourceController.setDataProvider(dataSourceUid, createDataProvider());
}
else {
qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application");
}
Alexandre Leroux
Create mock plugin
r99 }