Tulip  5.1.0
Large graphs analysis and drawing
ExportModule.h
1 /*
2  *
3  * This file is part of Tulip (http://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 
22 #ifndef _EXPORTMODULE_H
23 #define _EXPORTMODULE_H
24 
25 #include <iostream>
26 #include <tulip/Plugin.h>
27 #include <tulip/Algorithm.h>
28 
29 namespace tlp {
30 
31 static const std::string EXPORT_CATEGORY = "Export";
32 
33 class Graph;
34 class DataSet;
35 class PluginProgress;
36 
37 /**
38  * @ingroup Plugins
39  * @brief The ExportModule class
40  */
41 class ExportModule: public tlp::Plugin {
42 public:
43 
44  ExportModule(const tlp::PluginContext* context) {
45  if(context != NULL) {
46  const tlp::AlgorithmContext* algoritmContext = dynamic_cast<const tlp::AlgorithmContext*>(context);
47  assert(algoritmContext != NULL);
48  graph = algoritmContext->graph;
49  pluginProgress = algoritmContext->pluginProgress;
50  dataSet = algoritmContext->dataSet;
51  }
52  }
53 
54  virtual ~ExportModule() {}
55 
56  virtual std::string category() const {
57  return EXPORT_CATEGORY;
58  }
59 
60  std::string icon() const {
61  return ":/tulip/gui/icons/64/document-export.png";
62  }
63 
64  /**
65  * @brief Gets the extension of the file format this export plugin saves to.
66  * e.g. a GML export would return 'gml'.
67  *
68  * @return :string the extension that this export module saves to.
69  **/
70  virtual std::string fileExtension() const = 0;
71 
72  /**
73  * @brief Gets a list of the extensions file format when compressed with gzip this export plugin saves to.
74  *
75  * @since Tulip 5.0
76  *
77  * @return :string the extension that this export module saves to.
78  **/
79  virtual std::list<std::string> gzipFileExtensions() const {
80  return std::list<std::string>();
81  }
82 
83  /**
84  * @brief Gets a list of all extensions file format (normal and gzipped) this export plugin saves 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 
110 
111 }
112 #endif
113 ///@endcond
PluginProgress * pluginProgress
A progress handler to notify the user about the progress state of the algorithm when run...
Definition: PluginContext.h:69
DataSet * dataSet
Input parameters set by the user when running the plugin.
Definition: PluginContext.h:63
Contains runtime parameters for a plugin.
Definition: PluginContext.h:39
Top-level interface for plug-ins.
Definition: Plugin.h:79
bool exportGraph(Graph *graph, std::ostream &outputStream, const std::string &format, DataSet &dataSet, PluginProgress *progress=NULL)
Exports a graph using the specified export plugin with parameters stored in the DataSet.
Parameters structure for a tlp::Algorithm.
Definition: PluginContext.h:51
Graph * graph
The pointer to the tlp::Graph on which the algorithm will be run.
Definition: PluginContext.h:56