Tulip 6.1.0
Large graphs analysis and drawing
Loading...
Searching...
No Matches
ExportModule.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19///@cond DOXYGEN_HIDDEN
20
21#ifndef _EXPORTMODULE_H
22#define _EXPORTMODULE_H
23
24#include <iostream>
25#include <tulip/Plugin.h>
26#include <tulip/Algorithm.h>
27
28namespace tlp {
29
30static const std::string EXPORT_CATEGORY = "Export";
31
32class Graph;
33class DataSet;
34class PluginProgress;
35
36/**
37 * @ingroup Plugins
38 * @brief The ExportModule class
39 */
40class ExportModule : public tlp::Plugin {
41
42 /**
43 * @brief The supported file extensions
44 **/
45 std::list<std::string> extensions;
46
47public:
48 ExportModule(const tlp::PluginContext *context, std::list<std::string> exts = {})
49 : extensions(exts) {
50 if (context != nullptr) {
51 const tlp::AlgorithmContext *algoritmContext =
52 static_cast<const tlp::AlgorithmContext *>(context);
53 graph = algoritmContext->graph;
54 pluginProgress = algoritmContext->pluginProgress;
55 dataSet = algoritmContext->dataSet;
56 }
57 }
58
59 ~ExportModule() override {}
60
61 std::string category() const override {
62 return EXPORT_CATEGORY;
63 }
64
65 std::string icon() const override {
66 return ":/tulip/gui/icons/64/document-export.png";
67 }
68
69 /**
70 * @brief Gets the list of the extensions file formats supported.
71 * The ones after the first are supposed to be gzip compressed
72 *
73 * @return the list of file extensions this export plugin saves to.
74 */
75 std::list<std::string> fileExtensions() const {
76 return extensions;
77 }
78
79 /**
80 * @brief The export operations should take place here.
81 * @param the output stream
82 * @return bool Whether the export was successful or not.
83 **/
84 virtual bool exportGraph(std::ostream &os) = 0;
85
86 /** It is the root graph*/
87 Graph *graph;
88
89 PluginProgress *pluginProgress;
90 DataSet *dataSet;
91};
92} // namespace tlp
93#endif
94///@endcond
PluginProgress * pluginProgress
A progress handler to notify the user about the progress state of the algorithm when run.
DataSet * dataSet
Input parameters set by the user when running the plugin.
Graph * graph
The pointer to the tlp::Graph on which the algorithm will be run.
A container that can store data from any type.
Definition DataSet.h:195
PluginProcess subclasses are meant to notify about the progress state of some process (typically a pl...
bool exportGraph(Graph *graph, std::ostream &outputStream, const std::string &format, DataSet &dataSet, PluginProgress *progress=nullptr)
Exports a graph using the specified export plugin with parameters stored in the DataSet.