Tulip  4.7.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
ExportModule.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
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  std::string icon() const {
60  return ":/tulip/gui/icons/32/plugin_import_export.png";
61  }
62 
63  /**
64  * @brief Gets the extension of the file format this export plugin saves to.
65  * e.g. a GraphML export would return 'xml'.
66  *
67  * @return :string the extension that this export module saves to.
68  **/
69  virtual std::string fileExtension() const = 0;
70 
71  /**
72  * @brief The export operations should take place here.
73  * @param the output stream
74  * @return bool Whether the export was successful or not.
75  **/
76  virtual bool exportGraph(std::ostream &os)=0;
77  /** It is the root graph*/
78  Graph *graph;
79  ///
80  PluginProgress *pluginProgress;
81  DataSet *dataSet;
82 };
83 
84 
85 }
86 #endif
87 ///@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