Tulip 5.7.1
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 {
41public:
42 ExportModule(const tlp::PluginContext *context) {
43 if (context != nullptr) {
44 const tlp::AlgorithmContext *algoritmContext =
45 static_cast<const tlp::AlgorithmContext *>(context);
46 graph = algoritmContext->graph;
47 pluginProgress = algoritmContext->pluginProgress;
48 dataSet = algoritmContext->dataSet;
49 }
50 }
51
52 ~ExportModule() override {}
53
54 std::string category() const override {
55 return EXPORT_CATEGORY;
56 }
57
58 std::string icon() const override {
59 return ":/tulip/gui/icons/64/document-export.png";
60 }
61
62 /**
63 * @brief Gets the extension of the file format this export plugin saves to.
64 * e.g. a GML export would return 'gml'.
65 *
66 * @return :string the extension that this export module saves to.
67 **/
68 virtual std::string fileExtension() const = 0;
69
70 /**
71 * @brief Gets a list of the extensions file format when compressed with gzip this export plugin
72 *saves to.
73 *
74 * @since Tulip 5.0
75 *
76 * @return :string the extension that this export module saves to.
77 **/
78 virtual std::list<std::string> gzipFileExtensions() const {
79 return std::list<std::string>();
80 }
81
82 /**
83 * @brief Gets a list of all extensions file format (normal and gzipped) this export plugin saves
84 * to.
85 *
86 * @since Tulip 5.0
87 *
88 * @return the list of file extensions this export plugin saves to.
89 */
90 std::list<std::string> allFileExtensions() const {
91 std::list<std::string> ext(gzipFileExtensions());
92 ext.push_back(fileExtension());
93 return ext;
94 }
95
96 /**
97 * @brief The export operations should take place here.
98 * @param the output stream
99 * @return bool Whether the export was successful or not.
100 **/
101 virtual bool exportGraph(std::ostream &os) = 0;
102
103 /** It is the root graph*/
104 Graph *graph;
105
106 PluginProgress *pluginProgress;
107 DataSet *dataSet;
108};
109} // namespace tlp
110#endif
111///@endcond
Parameters structure for a tlp::Algorithm.
Definition: PluginContext.h:55
PluginProgress * pluginProgress
A progress handler to notify the user about the progress state of the algorithm when run.
Definition: PluginContext.h:74
DataSet * dataSet
Input parameters set by the user when running the plugin.
Definition: PluginContext.h:67
Graph * graph
The pointer to the tlp::Graph on which the algorithm will be run.
Definition: PluginContext.h:60
Contains runtime parameters for a plugin.
Definition: PluginContext.h:42
Top-level interface for plug-ins.
Definition: Plugin.h:85
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.