Salome HOME
Revert "Merge remote-tracking branch 'origin/cbr/export_to_geom_via_xao'"
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_ExportFeature.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef EXCHANGEPLUGIN_EXPORTFEATURE_H_
22 #define EXCHANGEPLUGIN_EXPORTFEATURE_H_
23
24 #include <ExchangePlugin.h>
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_Result.h>
27
28 #include <map>
29
30 /**
31  * \class ExchangePlugin_ExportFeature
32  * \ingroup Plugins
33  * \brief Feature for export shapes to the external files in CAD formats.
34  *
35  * The list of supported formats is defined in the configuration file.
36  */
37 class ExchangePlugin_ExportFeature : public ModelAPI_Feature
38 {
39 public:
40   /// Feature kind
41   inline static const std::string& ID()
42   {
43     static const std::string MY_EXPORT_ID("Export");
44     return MY_EXPORT_ID;
45   }
46   /// attribute name for file format
47   inline static const std::string& EXPORT_TYPE_ID()
48   {
49     static const std::string MY_EXPORT_TYPE_ID("ExportType");
50     return MY_EXPORT_TYPE_ID;
51   }
52   /// attribute name of file path
53   inline static const std::string& FILE_PATH_ID()
54   {
55     static const std::string MY_FILE_PATH_ID("file_path");
56     return MY_FILE_PATH_ID;
57   }
58   /// attribute name of xao file path
59   inline static const std::string& XAO_FILE_PATH_ID()
60   {
61     static const std::string MY_XAO_FILE_PATH_ID("xao_file_path");
62     return MY_XAO_FILE_PATH_ID;
63   }
64   /// attribute name of file format
65   inline static const std::string& FILE_FORMAT_ID()
66   {
67     static const std::string MY_FILE_FORMAT_ID("file_format");
68     return MY_FILE_FORMAT_ID;
69   }
70   /// attribute name of selection list
71   inline static const std::string& SELECTION_LIST_ID()
72   {
73     static const std::string MY_SELECTION_LIST_ID("selection_list");
74     return MY_SELECTION_LIST_ID;
75   }
76   /// attribute name of author for XAO format
77   inline static const std::string& XAO_AUTHOR_ID()
78   {
79     static const std::string MY_XAO_AUTHOR_ID("xao_author");
80     return MY_XAO_AUTHOR_ID;
81   }
82   /// attribute name of geometry name for XAO format
83   inline static const std::string& XAO_GEOMETRY_NAME_ID()
84   {
85     static const std::string MY_XAO_GEOMETRY_NAME_ID("xao_geometry_name");
86     return MY_XAO_GEOMETRY_NAME_ID;
87   }
88   /// Default constructor
89   EXCHANGEPLUGIN_EXPORT ExchangePlugin_ExportFeature();
90   /// Default destructor
91   EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ExportFeature();
92
93   /// Returns the unique kind of a feature
94   EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind()
95   {
96     return ExchangePlugin_ExportFeature::ID();
97   }
98
99   /// Request for initialization of data model of the feature: adding all attributes
100   EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
101
102   /// Reimplemented from ModelAPI_Feature::attributeChanged()
103   EXCHANGEPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
104
105   /// Computes or recomputes the results
106   EXCHANGEPLUGIN_EXPORT virtual void execute();
107
108   /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true.
109   EXCHANGEPLUGIN_EXPORT virtual bool isMacro() const { return true; }
110
111   /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
112   EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
113
114 protected:
115   /// Performs export of the file
116   EXCHANGEPLUGIN_EXPORT void exportFile(const std::string& theFileName,
117                                         const std::string& theFormat);
118
119   /// Performs export to XAO file
120   EXCHANGEPLUGIN_EXPORT void exportXAO(const std::string& theFileName);
121 };
122
123 #endif /* EXPORT_EXPORTFEATURE_H_ */