diff --git a/library/tulip-core/include/tulip/Graph.h b/library/tulip-core/include/tulip/Graph.h index cf569fe64d..158e0e6705 100644 --- a/library/tulip-core/include/tulip/Graph.h +++ b/library/tulip-core/include/tulip/Graph.h @@ -257,15 +257,13 @@ class TLP_SCOPE Graph : public Observable { * If an error occurs, a message describing the error should be stored in errorMessage. * * @param algorithm The algorithm to apply. - * @param errorMessage A string that will be modified to contain an error message should an error - *occur. - * @param dataSet The parameters to the algorithm. Defaults to nullptr. - * @param progress A PluginProgress to report the progress of the operation, as well as final - *state. Defaults to nullptr. - * @return bool Whether the algorithm was successfully applied. + * @param errorMessage A string that will be modified to contain an error message if an error occurs. + * @param parameters The parameters of the algorithm. Defaults to nullptr. + * @param progress A PluginProgress to report the progress of the operation, as well as the final state. Defaults to nullptr. + * @return bool Whether the algorithm applied successfully or not. If not, check the error message. **/ bool applyAlgorithm(const std::string &algorithm, std::string &errorMessage, - DataSet *dataSet = nullptr, PluginProgress *progress = nullptr); + DataSet *parameters = nullptr, PluginProgress *progress = nullptr); //========================================================================= // Graph hierarchy access and building @@ -1426,20 +1424,27 @@ class TLP_SCOPE Graph : public Observable { * @brief Runs a plugin on the graph, whose result is a property. * * @param algorithm The name of the plugin to run. - * @param result The property in which to put the results. All previous values will be erased. + * @param result The property in which to store the computed nodes/edges associated values. All previous values will be erased. * @param errorMessage Stores the error message if the plugin fails. - * @param progress A means of feedback during the plugin execution. Some plugins support being - * stopped or cancelled through this. * @param parameters The parameters of the algorithm. Some algorithms use this DataSet to output + * @param progress A PluginProgress to report the progress of the operation, as well as the final state. Defaults to nullptr. * some additional information. - * @return Whether the plugin executed successfully or not. If not, check the error message. + * @return Whether the plugin applied successfully or not. If not, check the error message. * * @see PluginLister::getPluginParameters() to retrieve the list of default parameters for the - * pligin. + * plugin. */ bool applyPropertyAlgorithm(const std::string &algorithm, PropertyInterface *result, - std::string &errorMessage, PluginProgress *progress = nullptr, - DataSet *parameters = nullptr); + std::string &errorMessage, DataSet *parameters = nullptr, PluginProgress *progress = nullptr); + + /** + * @brief Deprecated, use applyPropertyAlgorithm(const std::string &algorithm, PropertyInterface *result, std::string &errorMessage, DataSet *parameters = nullptr, PluginProgress *progress = nullptr) instead + */ + _DEPRECATED bool applyPropertyAlgorithm(const std::string &algorithm, PropertyInterface *result, + std::string &errorMessage, PluginProgress *progress, + DataSet *parameters = nullptr) { + return applyPropertyAlgorithm(algorithm, result, errorMessage, parameters, progress); + } // updates management /** @@ -1595,8 +1600,7 @@ class TLP_SCOPE Graph : public Observable { bool delAllEdge = true); /** - * @brief deprecated, use createMetaNode(const std::vector&, bool multiEdges = true, bool - * delAllEdge = true) instead + * @brief Deprecated, use createMetaNode(const std::vector&, bool multiEdges = true, bool delAllEdge = true) instead */ _DEPRECATED node createMetaNode(const std::set &nodeSet, bool multiEdges = true, bool delAllEdge = true); diff --git a/library/tulip-core/src/Graph.cpp b/library/tulip-core/src/Graph.cpp index 8abe1fc15c..9aebc7814c 100644 --- a/library/tulip-core/src/Graph.cpp +++ b/library/tulip-core/src/Graph.cpp @@ -670,7 +670,7 @@ Iterator *tlp::getRootGraphs() { } bool Graph::applyAlgorithm(const std::string &algorithm, std::string &errorMessage, - DataSet *dataSet, PluginProgress *progress) { + DataSet *parameters, PluginProgress *progress) { if (!PluginLister::pluginExists(algorithm)) { tlp::warning() << "libtulip: " << __FUNCTION__ << ": algorithm plugin \"" << algorithm << "\" does not exist (or is not loaded)" << endl; @@ -687,7 +687,7 @@ bool Graph::applyAlgorithm(const std::string &algorithm, std::string &errorMessa } else tmpProgress = progress; - AlgorithmContext *context = new AlgorithmContext(this, dataSet, tmpProgress); + AlgorithmContext *context = new AlgorithmContext(this, parameters, tmpProgress); Algorithm *newAlgo = PluginLister::instance()->getPluginObject(algorithm, context); if ((result = newAlgo->check(errorMessage))) { @@ -707,9 +707,11 @@ bool Graph::applyAlgorithm(const std::string &algorithm, std::string &errorMessa } //========================================================= -bool tlp::Graph::applyPropertyAlgorithm(const std::string &algorithm, PropertyInterface *prop, - std::string &errorMessage, tlp::PluginProgress *progress, - tlp::DataSet *parameters) { +bool tlp::Graph::applyPropertyAlgorithm(const std::string &algorithm, + PropertyInterface *prop, + std::string &errorMessage, + tlp::DataSet *parameters, + tlp::PluginProgress *progress) { bool result; tlp::AlgorithmContext context; diff --git a/plugins/clustering/QuotientClustering.cpp b/plugins/clustering/QuotientClustering.cpp index f05693532f..335a545b15 100644 --- a/plugins/clustering/QuotientClustering.cpp +++ b/plugins/clustering/QuotientClustering.cpp @@ -168,13 +168,13 @@ class QuotientClustering : public tlp::Algorithm { layoutParams.set("Unit edge length", std::max(maxSize[0], maxSize[1]) * 5.0); cluster->applyPropertyAlgorithm(layoutName, cluster->getLocalProperty("viewLayout"), - errMsg, nullptr, &layoutParams); + errMsg, &layoutParams); double border = std::min(minSize[0], minSize[1]); layoutParams.set("x border", border); layoutParams.set("y border", border); cluster->applyPropertyAlgorithm("Fast Overlap Removal", cluster->getLocalProperty("viewLayout"), - errMsg, nullptr, &layoutParams); + errMsg, &layoutParams); } } @@ -376,13 +376,13 @@ class QuotientClustering : public tlp::Algorithm { layoutParams.set("Unit edge length", std::max(maxSize[0], maxSize[1]) * 2.0); quotientGraph->applyPropertyAlgorithm( layoutName, quotientGraph->getLocalProperty("viewLayout"), errMsg, - nullptr, &layoutParams); + &layoutParams); double border = std::min(minSize[0], minSize[1]); layoutParams.set("x border", border); layoutParams.set("y border", border); quotientGraph->applyPropertyAlgorithm( "Fast Overlap Removal", quotientGraph->getLocalProperty("viewLayout"), - errMsg, nullptr, &layoutParams); + errMsg, &layoutParams); } // recursive call if needed diff --git a/plugins/clustering/StrengthClustering.cpp b/plugins/clustering/StrengthClustering.cpp index 54aa8fda78..216b898a56 100644 --- a/plugins/clustering/StrengthClustering.cpp +++ b/plugins/clustering/StrengthClustering.cpp @@ -206,7 +206,7 @@ bool StrengthClustering::run() { string errMsg; values = new DoubleProperty(graph); - if (!graph->applyPropertyAlgorithm("Strength", values, errMsg, pluginProgress)) + if (!graph->applyPropertyAlgorithm("Strength", values, errMsg, nullptr, pluginProgress)) return false; NumericProperty *metric = nullptr; diff --git a/plugins/import/BibTeX/ImportBibTeX.cpp b/plugins/import/BibTeX/ImportBibTeX.cpp index 1d088a4b31..f69f540efc 100644 --- a/plugins/import/BibTeX/ImportBibTeX.cpp +++ b/plugins/import/BibTeX/ImportBibTeX.cpp @@ -2078,8 +2078,8 @@ class ImportBibTeX : public ImportModule { graph->delLocalProperty(fromLabriProp->getName()); string err; - return graph->applyPropertyAlgorithm( - "FM^3 (OGDF)", graph->getProperty("viewLayout"), err, pluginProgress); + return graph->applyPropertyAlgorithm("FM^3 (OGDF)", graph->getProperty("viewLayout"), + err, nullptr, pluginProgress); } return true; diff --git a/plugins/import/CompleteTree.cpp b/plugins/import/CompleteTree.cpp index f3fa1a4c5e..865fa00796 100644 --- a/plugins/import/CompleteTree.cpp +++ b/plugins/import/CompleteTree.cpp @@ -89,10 +89,9 @@ class CompleteTree : public ImportModule { if (needLayout) { // apply Tree Leaf - DataSet dSet; string errMsg; LayoutProperty *layout = graph->getProperty("viewLayout"); - return graph->applyPropertyAlgorithm("Tree Leaf", layout, errMsg, pluginProgress, &dSet); + return graph->applyPropertyAlgorithm("Tree Leaf", layout, errMsg, nullptr, pluginProgress); } return true; diff --git a/plugins/import/FileSystem.cpp b/plugins/import/FileSystem.cpp index c75cb15bd9..ce8483efb1 100644 --- a/plugins/import/FileSystem.cpp +++ b/plugins/import/FileSystem.cpp @@ -244,10 +244,10 @@ class FileSystem : public tlp::ImportModule { if (_treeLayout) { const std::string algoName = "Bubble Tree"; tlp::DataSet defaultParameters = getDefaultAlgorithmParameters(algoName, graph); - tlp::LayoutProperty *viewLayout = graph->getProperty("viewLayout"); std::string errMsg; - graph->applyPropertyAlgorithm(algoName, viewLayout, errMsg, pluginProgress, - &defaultParameters); + tlp::LayoutProperty *viewLayout = graph->getProperty("viewLayout"); + graph->applyPropertyAlgorithm(algoName, viewLayout, errMsg, + &defaultParameters, pluginProgress); } return true; diff --git a/plugins/import/RandomTree.cpp b/plugins/import/RandomTree.cpp index 290b402ff6..3c1334a7f5 100644 --- a/plugins/import/RandomTree.cpp +++ b/plugins/import/RandomTree.cpp @@ -127,10 +127,9 @@ class RandomTree : public ImportModule { if (needLayout) { // apply Tree Leaf - DataSet dSet; string errMsg; LayoutProperty *layout = graph->getProperty("viewLayout"); - return graph->applyPropertyAlgorithm("Tree Leaf", layout, errMsg, pluginProgress, &dSet); + return graph->applyPropertyAlgorithm("Tree Leaf", layout, errMsg, nullptr, pluginProgress); } return true; diff --git a/plugins/import/RandomTreeGeneral.cpp b/plugins/import/RandomTreeGeneral.cpp index 42dcc045bd..021fedb22e 100644 --- a/plugins/import/RandomTreeGeneral.cpp +++ b/plugins/import/RandomTreeGeneral.cpp @@ -149,10 +149,9 @@ class RandomTreeGeneral : public ImportModule { if (needLayout) { // apply Tree Leaf - DataSet dSet; string errMsg; LayoutProperty *layout = graph->getProperty("viewLayout"); - return graph->applyPropertyAlgorithm("Tree Leaf", layout, errMsg, pluginProgress, &dSet); + return graph->applyPropertyAlgorithm("Tree Leaf", layout, errMsg, nullptr, pluginProgress); } return true; diff --git a/plugins/import/WebImport.cpp b/plugins/import/WebImport.cpp index 84c6d7cd40..744d479c3f 100644 --- a/plugins/import/WebImport.cpp +++ b/plugins/import/WebImport.cpp @@ -794,9 +794,8 @@ struct WebImport : public ImportModule { pluginProgress->setComment("Layouting extracted graph using FM³..."); string errMsg; // apply FM³ - DataSet tmp; LayoutProperty *layout = graph->getProperty("viewLayout"); - return graph->applyPropertyAlgorithm("FM^3 (OGDF)", layout, errMsg, pluginProgress, &tmp); + return graph->applyPropertyAlgorithm("FM^3 (OGDF)", layout, errMsg, nullptr, pluginProgress); } return true; diff --git a/plugins/interactor/NeighborhoodHighlighter/NodeNeighborhoodView.cpp b/plugins/interactor/NeighborhoodHighlighter/NodeNeighborhoodView.cpp index 0109ed6cec..2071aa36d7 100644 --- a/plugins/interactor/NeighborhoodHighlighter/NodeNeighborhoodView.cpp +++ b/plugins/interactor/NeighborhoodHighlighter/NodeNeighborhoodView.cpp @@ -131,7 +131,7 @@ void NodeNeighborhoodView::getNeighbors(node n, unsigned int dist, bool noRecurs BooleanProperty result(graph_component); string errorMsg; graph_component->applyPropertyAlgorithm(tlp::SelectionAlgorithm::ReachableSubGraphSelection, - &result, errorMsg, nullptr, &dataSet); + &result, errorMsg, &dataSet); graphViewNodes.clear(); graphViewEdges.clear(); diff --git a/plugins/layout/BubblePack.cpp b/plugins/layout/BubblePack.cpp index 1a2cb2da6d..c87bd53e8d 100644 --- a/plugins/layout/BubblePack.cpp +++ b/plugins/layout/BubblePack.cpp @@ -277,7 +277,7 @@ bool BubblePack::run() { for (unsigned int i = 0; i < components.size(); ++i) { Graph *tmp = graph->inducedSubGraph(components[i]); - tmp->applyPropertyAlgorithm("Bubble Pack", result, err, pluginProgress, dataSet); + tmp->applyPropertyAlgorithm("Bubble Pack", result, err, dataSet, pluginProgress); } // call connected component packing diff --git a/plugins/layout/BubbleTree.cpp b/plugins/layout/BubbleTree.cpp index 1373e3cfb7..dc0b29bc95 100644 --- a/plugins/layout/BubbleTree.cpp +++ b/plugins/layout/BubbleTree.cpp @@ -334,15 +334,15 @@ bool BubbleTree::run() { for (unsigned int i = 0; i < components.size(); ++i) { Graph *tmp = graph->inducedSubGraph(components[i]); - tmp->applyPropertyAlgorithm("Bubble Tree", result, err, pluginProgress, dataSet); + tmp->applyPropertyAlgorithm("Bubble Tree", result, err, dataSet, pluginProgress); } // call connected component packing LayoutProperty tmpLayout(graph); DataSet tmpdataSet; tmpdataSet.set("coordinates", result); - graph->applyPropertyAlgorithm("Connected Component Packing", &tmpLayout, err, pluginProgress, - &tmpdataSet); + graph->applyPropertyAlgorithm("Connected Component Packing", &tmpLayout, + err, &tmpdataSet, pluginProgress); // forget last temporary graph state graph->pop(); *result = tmpLayout; diff --git a/plugins/layout/GEMLayout.cpp b/plugins/layout/GEMLayout.cpp index 2b5b50cc0c..d67696d93f 100644 --- a/plugins/layout/GEMLayout.cpp +++ b/plugins/layout/GEMLayout.cpp @@ -359,15 +359,15 @@ bool GEMLayout::run() { for (size_t i = 0; i < components.size(); ++i) { Graph *tmp = graph->inducedSubGraph(components[i]); - tmp->applyPropertyAlgorithm("GEM (Frick)", result, err, pluginProgress, dataSet); + tmp->applyPropertyAlgorithm("GEM (Frick)", result, err, dataSet, pluginProgress); } // call connected component packing LayoutProperty tmpLayout(graph); DataSet ds; ds.set("coordinates", result); - graph->applyPropertyAlgorithm("Connected Component Packing", &tmpLayout, err, pluginProgress, - &ds); + graph->applyPropertyAlgorithm("Connected Component Packing", &tmpLayout, + err, &ds, pluginProgress); // forget last temporary graph state graph->pop(); *result = tmpLayout; diff --git a/plugins/layout/Grip/Grip.cpp b/plugins/layout/Grip/Grip.cpp index 697d8515a6..2612f10263 100644 --- a/plugins/layout/Grip/Grip.cpp +++ b/plugins/layout/Grip/Grip.cpp @@ -134,7 +134,8 @@ bool Grip::run() { DataSet tmp; tmp.set("coordinates", result); LayoutProperty layout(graph); - graph->applyPropertyAlgorithm("Connected Component Packing", &layout, err, nullptr, &tmp); + graph->applyPropertyAlgorithm("Connected Component Packing", &layout, + err, &tmp); for (const node &n : graph->nodes()) { result->setNodeValue(n, layout.getNodeValue(n)); diff --git a/plugins/layout/HierarchicalGraph.cpp b/plugins/layout/HierarchicalGraph.cpp index 307c13de57..3f6b8f068c 100644 --- a/plugins/layout/HierarchicalGraph.cpp +++ b/plugins/layout/HierarchicalGraph.cpp @@ -364,8 +364,8 @@ bool HierarchicalGraph::run() { #ifndef NDEBUG resultBool = #endif - mySGraph->applyPropertyAlgorithm("Hierarchical Tree (R-T Extended)", &tmpLayout, erreurMsg, - nullptr, &tmp); + mySGraph->applyPropertyAlgorithm("Hierarchical Tree (R-T Extended)", + &tmpLayout, erreurMsg, &tmp); if (edgeLength) delete edgeLength; diff --git a/plugins/layout/MixedModel.cpp b/plugins/layout/MixedModel.cpp index 2baca71eb7..c6a34f50e6 100644 --- a/plugins/layout/MixedModel.cpp +++ b/plugins/layout/MixedModel.cpp @@ -286,8 +286,8 @@ bool MixedModel::run() { LayoutProperty layout(graph); DataSet tmp; tmp.set("coordinates", result); - graph->applyPropertyAlgorithm(string("Connected Component Packing"), &layout, err, nullptr, - &tmp); + graph->applyPropertyAlgorithm(string("Connected Component Packing"), + &layout, err, &tmp); for (const node &n : graph->nodes()) { result->setNodeValue(n, layout.getNodeValue(n)); diff --git a/plugins/perspective/GraphPerspective/src/AlgorithmRunnerItem.cpp b/plugins/perspective/GraphPerspective/src/AlgorithmRunnerItem.cpp index 296a9a3b33..5bfde00e36 100644 --- a/plugins/perspective/GraphPerspective/src/AlgorithmRunnerItem.cpp +++ b/plugins/perspective/GraphPerspective/src/AlgorithmRunnerItem.cpp @@ -547,7 +547,7 @@ void AlgorithmRunnerItem::afterRun(Graph *g, const tlp::DataSet &dataSet) { cs = ColorScalesManager::getLatestColorScale(); data.set("color scale", cs); - g->applyPropertyAlgorithm("Color Mapping", color, errMsg, nullptr, &data); + g->applyPropertyAlgorithm("Color Mapping", color, errMsg, &data); } } else if (pluginLister->pluginExists(stdName)) { bool result = true; diff --git a/plugins/view/TableView/PropertiesEditor.cpp b/plugins/view/TableView/PropertiesEditor.cpp index 661e2fd43d..1cb808f2d2 100644 --- a/plugins/view/TableView/PropertiesEditor.cpp +++ b/plugins/view/TableView/PropertiesEditor.cpp @@ -493,7 +493,7 @@ void PropertiesEditor::toLabels(PropertyInterface *prop, bool nodes, bool edges, // _graph->push() must be done outside of this method // to allow call from TabelView.cpp StringProperty *result = _graph->getProperty("viewLabel"); - _graph->applyPropertyAlgorithm("To labels", result, msg, nullptr, &data); + _graph->applyPropertyAlgorithm("To labels", result, msg, &data); } void PropertiesEditor::checkStateChanged(QModelIndex index, Qt::CheckState state) { diff --git a/tests/plugins/BasicLayoutTest.cpp b/tests/plugins/BasicLayoutTest.cpp index 64b2eb8d19..cc5e906882 100644 --- a/tests/plugins/BasicLayoutTest.cpp +++ b/tests/plugins/BasicLayoutTest.cpp @@ -90,7 +90,7 @@ void BasicLayoutTest::testDendrogram() { ds.set("node size", &size); LayoutProperty layout(graph); string errorMsg; - bool result = graph->applyPropertyAlgorithm("Dendrogram", &layout, errorMsg, nullptr, &ds); + bool result = graph->applyPropertyAlgorithm("Dendrogram", &layout, errorMsg, &ds); CPPUNIT_ASSERT(result); } //========================================================== @@ -122,7 +122,7 @@ void BasicLayoutTest::testMixedModel() { ds.set("node size", &size); LayoutProperty layout(graph); string errorMsg; - bool result = graph->applyPropertyAlgorithm("Mixed Model", &layout, errorMsg, nullptr, &ds); + bool result = graph->applyPropertyAlgorithm("Mixed Model", &layout, errorMsg, &ds); CPPUNIT_ASSERT(result); } //========================================================== @@ -141,7 +141,7 @@ void BasicLayoutTest::testSquarifiedTreeMap() { LayoutProperty layout(graph); ds.set("metric", &metric); - result = graph->applyPropertyAlgorithm("Squarified Tree Map", &layout, errorMsg, nullptr, &ds); + result = graph->applyPropertyAlgorithm("Squarified Tree Map", &layout, errorMsg, &ds); CPPUNIT_ASSERT(result); } //========================================================== @@ -152,7 +152,7 @@ void BasicLayoutTest::testTreeLeaf() { ds.set("node size", &size); LayoutProperty layout(graph); string errorMsg; - bool result = graph->applyPropertyAlgorithm("Tree Leaf", &layout, errorMsg, nullptr, &ds); + bool result = graph->applyPropertyAlgorithm("Tree Leaf", &layout, errorMsg, &ds); CPPUNIT_ASSERT(result); } //========================================================== @@ -194,6 +194,6 @@ void BasicLayoutTest::testFastOverlapRemoval() { ds.set("layout", &layout); string errorMsg; bool result = - graph->applyPropertyAlgorithm("Fast Overlap Removal", &layout, errorMsg, nullptr, &ds); + graph->applyPropertyAlgorithm("Fast Overlap Removal", &layout, errorMsg, &ds); CPPUNIT_ASSERT(result); } diff --git a/tests/plugins/BasicPluginsTest.cpp b/tests/plugins/BasicPluginsTest.cpp index 0b92efef9a..3006d484b3 100644 --- a/tests/plugins/BasicPluginsTest.cpp +++ b/tests/plugins/BasicPluginsTest.cpp @@ -317,7 +317,7 @@ void BasicPluginsTest::testMetricColorMapping() { DataSet ds; ds.set("linear/uniform\nproperty", &metric); ColorProperty color(graph); - result = graph->applyPropertyAlgorithm("Color Mapping", &color, errorMsg, nullptr, &ds); + result = graph->applyPropertyAlgorithm("Color Mapping", &color, errorMsg, &ds, nullptr); CPPUNIT_ASSERT(result); } //========================================================== @@ -378,7 +378,7 @@ void BasicPluginsTest::testMetricSizeMapping() { SizeProperty size(graph); ds.set("property", &metric); - result = graph->applyPropertyAlgorithm("Size Mapping", &size, errorMsg, nullptr, &ds); + result = graph->applyPropertyAlgorithm("Size Mapping", &size, errorMsg, &ds, nullptr); CPPUNIT_ASSERT(result); } //========================================================== @@ -419,7 +419,7 @@ void BasicPluginsTest::testEqualValueClustering() { PluginProgress *progress = new SimplePluginProgress(); initializeGraph("Planar Graph"); - result = graph->applyPropertyAlgorithm("Degree", metric, errorMsg, progress); + result = graph->applyPropertyAlgorithm("Degree", metric, errorMsg, nullptr, progress); CPPUNIT_ASSERT_MESSAGE(errorMsg, result); result = graph->applyAlgorithm(algorithmName, errorMsg, &ds); CPPUNIT_ASSERT_MESSAGE(errorMsg, result);