From b4495f224113961c8f96e5bddb2f7206671ed1ac Mon Sep 17 00:00:00 2001 From: Thomas Kroes Date: Sun, 14 Jan 2024 13:19:43 +0100 Subject: [PATCH] Adhere to new Core API --- ExampleAnalysis/src/ExampleAnalysisPlugin.cpp | 4 +++- ExampleData/src/ExampleDataPlugin.cpp | 18 +++++++++--------- ExampleData/src/ExampleDataPlugin.h | 2 +- ExampleLoader/src/ExampleLoaderPlugin.cpp | 2 +- .../src/ExampleTransformationPlugin.cpp | 3 +-- ExampleView/src/ExampleViewPlugin.cpp | 2 +- ExampleViewJS/src/ExampleViewJSPlugin.cpp | 5 ++--- ExampleViewOpenGL/src/ExampleViewGLPlugin.cpp | 5 ++--- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/ExampleAnalysis/src/ExampleAnalysisPlugin.cpp b/ExampleAnalysis/src/ExampleAnalysisPlugin.cpp index 721642b..4caa2e8 100644 --- a/ExampleAnalysis/src/ExampleAnalysisPlugin.cpp +++ b/ExampleAnalysis/src/ExampleAnalysisPlugin.cpp @@ -2,6 +2,8 @@ #include "PointData/PointData.h" +#include + #include #include @@ -33,7 +35,7 @@ ExampleAnalysisPlugin::ExampleAnalysisPlugin(const PluginFactory* factory) : void ExampleAnalysisPlugin::init() { // Create example output dataset (a points dataset which is derived from the input points dataset) and set the output dataset - setOutputDataset(_core->createDerivedDataset("Output Data", getInputDataset(), getInputDataset())); + setOutputDataset(mv::data().createDerivedDataset("Output Data", getInputDataset(), getInputDataset())); // Retrieve the input dataset for our specific data type (in our case points) // The HDPS core sets the input dataset reference when the plugin is created diff --git a/ExampleData/src/ExampleDataPlugin.cpp b/ExampleData/src/ExampleDataPlugin.cpp index c38156f..13cb7a1 100644 --- a/ExampleData/src/ExampleDataPlugin.cpp +++ b/ExampleData/src/ExampleDataPlugin.cpp @@ -23,7 +23,7 @@ void ExampleDataPlugin::init() */ Dataset ExampleDataPlugin::createDataSet(const QString& guid /*= ""*/) const { - return new PixelSet(_core, getName(), guid); + return new PixelSet(getName(), guid); } std::vector& ExampleDataPlugin::getData() @@ -44,8 +44,8 @@ void ExampleDataPlugin::setData(QImage image) { } } -PixelSet::PixelSet(CoreInterface* core, QString dataName, const QString& guid /*= ""*/) : - DatasetImpl(core, dataName, guid) +PixelSet::PixelSet(QString dataName, const QString& guid /*= ""*/) : + DatasetImpl(dataName, true, guid) { } @@ -55,12 +55,12 @@ PixelSet::~PixelSet() Dataset PixelSet::createSubsetFromSelection(const QString& guiName, const Dataset& parentDataSet /*= Dataset()*/, const bool& visible /*= true*/) const { - return _core->createSubsetFromSelection(getSelection(), const_cast(this), guiName, parentDataSet, visible); + return mv::data().createSubsetFromSelection(getSelection(), const_cast(this), guiName, parentDataSet, visible); } Dataset PixelSet::copy() const { - auto copySet = new PixelSet(_core, getRawDataName()); + auto copySet = new PixelSet(getRawDataName()); copySet->_indices = _indices; @@ -84,12 +84,12 @@ void PixelSet::setSelectionIndices(const std::vector& indices) bool PixelSet::canSelect() const { - return getRawData().getData().size() >= 1; + return getRawData()->getData().size() >= 1; } bool PixelSet::canSelectAll() const { - return canSelect() && (getSelectionSize() < getRawData().getData().size()); + return canSelect() && (getSelectionSize() < getRawData()->getData().size()); } bool PixelSet::canSelectNone() const @@ -109,7 +109,7 @@ void PixelSet::selectAll() // Clear and resize selectionIndices.clear(); - selectionIndices.resize(getRawData().getData().size()); + selectionIndices.resize(getRawData()->getData().size()); // Generate cluster selection indices std::iota(selectionIndices.begin(), selectionIndices.end(), 0); @@ -136,7 +136,7 @@ void PixelSet::selectInvert() std::set selectionSet(selectionIndices.begin(), selectionIndices.end()); // Get number of items - const auto numberOfItems = getRawData().getData().size(); + const auto numberOfItems = getRawData()->getData().size(); // Clear and resize selectionIndices.clear(); diff --git a/ExampleData/src/ExampleDataPlugin.h b/ExampleData/src/ExampleDataPlugin.h index 72cde13..3ff0cc6 100644 --- a/ExampleData/src/ExampleDataPlugin.h +++ b/ExampleData/src/ExampleDataPlugin.h @@ -42,7 +42,7 @@ class ExampleDataPlugin : public RawData class PixelSet : public mv::DatasetImpl { public: - PixelSet(mv::CoreInterface* core, QString dataName, const QString& guid = ""); + PixelSet(QString dataName, const QString& guid = ""); ~PixelSet() override; /** diff --git a/ExampleLoader/src/ExampleLoaderPlugin.cpp b/ExampleLoader/src/ExampleLoaderPlugin.cpp index a68ba2c..d40cd4c 100644 --- a/ExampleLoader/src/ExampleLoaderPlugin.cpp +++ b/ExampleLoader/src/ExampleLoaderPlugin.cpp @@ -46,7 +46,7 @@ void ExampleLoaderPlugin::init() void ExampleLoaderPlugin::loadData() { _dataSetName = "ExampleData"; - auto points = _core->addDataset("Points", _dataSetName); + auto points = mv::data().createDataset("Points", _dataSetName); // Create 2D example data by randomly generating 1000 points std::default_random_engine generator; diff --git a/ExampleTransformation/src/ExampleTransformationPlugin.cpp b/ExampleTransformation/src/ExampleTransformationPlugin.cpp index 4c43276..e4e0c19 100644 --- a/ExampleTransformation/src/ExampleTransformationPlugin.cpp +++ b/ExampleTransformation/src/ExampleTransformationPlugin.cpp @@ -75,8 +75,7 @@ void ExampleTransformationPlugin::transform() // Create new data set case ExampleTransformationPlugin::Type::Pow2: { - auto derivedData = _core->createDerivedDataset(points->getGuiName() + "(Pow2)", points); - events().notifyDatasetAdded(derivedData); + auto derivedData = mv::data().createDerivedDataset(points->getGuiName() + "(Pow2)", points); std::vector transformedData; transformedData.resize(points->getNumPoints() * points->getNumDimensions()); diff --git a/ExampleView/src/ExampleViewPlugin.cpp b/ExampleView/src/ExampleViewPlugin.cpp index 6012cb8..45b64f1 100644 --- a/ExampleView/src/ExampleViewPlugin.cpp +++ b/ExampleView/src/ExampleViewPlugin.cpp @@ -70,7 +70,7 @@ void ExampleViewPlugin::init() else { // Get points dataset from the core - auto candidateDataset = _core->requestDataset(datasetId); + auto candidateDataset = mv::data().getDataset(datasetId); // Accept points datasets drag and drop if (dataType == PointType) { diff --git a/ExampleViewJS/src/ExampleViewJSPlugin.cpp b/ExampleViewJS/src/ExampleViewJSPlugin.cpp index 7326326..fc122b3 100644 --- a/ExampleViewJS/src/ExampleViewJSPlugin.cpp +++ b/ExampleViewJS/src/ExampleViewJSPlugin.cpp @@ -75,7 +75,7 @@ void ExampleViewJSPlugin::init() dropRegions << new DropWidget::DropRegion(this, "Warning", "Data already loaded", "exclamation-circle", false); } else { - auto candidateDataset = _core->requestDataset(datasetId); + auto candidateDataset = mv::data().getDataset(datasetId); dropRegions << new DropWidget::DropRegion(this, "Points", QString("Visualize %1 as parallel coordinates").arg(datasetGuiName), "map-marker-alt", true, [this, candidateDataset]() { loadData({ candidateDataset }); @@ -189,8 +189,7 @@ void ExampleViewJSPlugin::createData() { // Here, we create a random data set, so that we do not need // to use other plugins for loading when trying out this example - auto points = _core->addDataset("Points", "ExampleViewJSData"); - events().notifyDatasetAdded(points); + auto points = mv::data().createDataset("Points", "ExampleViewJSData"); int numPoints = 2; int numDimensions = 5; diff --git a/ExampleViewOpenGL/src/ExampleViewGLPlugin.cpp b/ExampleViewOpenGL/src/ExampleViewGLPlugin.cpp index fd59b80..059b69b 100644 --- a/ExampleViewOpenGL/src/ExampleViewGLPlugin.cpp +++ b/ExampleViewOpenGL/src/ExampleViewGLPlugin.cpp @@ -61,7 +61,7 @@ ExampleViewGLPlugin::ExampleViewGLPlugin(const PluginFactory* factory) : dropRegions << new DropWidget::DropRegion(this, "Warning", "Data already loaded", "exclamation-circle", false); } else { - auto candidateDataset = _core->requestDataset(datasetId); + auto candidateDataset = mv::data().getDataset(datasetId); dropRegions << new DropWidget::DropRegion(this, "Points", QString("Visualize %1 as parallel coordinates").arg(datasetGuiName), "map-marker-alt", true, [this, candidateDataset]() { loadData({ candidateDataset }); @@ -188,8 +188,7 @@ void ExampleViewGLPlugin::createData() { // Here, we create a random data set, so that we do not need // to use other plugins for loading when trying out this example - auto points = _core->addDataset("Points", "ExampleViewGLData"); - events().notifyDatasetAdded(points); + auto points = mv::data().createDataset("Points", "ExampleViewGLData"); int numPoints = 50; int numDimensions = 3;