Salome HOME
Copyright update 2020
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_ExportFeature.h
1 // Copyright (C) 2014-2020  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 email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef EXCHANGEPLUGIN_EXPORTFEATURE_H_
21 #define EXCHANGEPLUGIN_EXPORTFEATURE_H_
22
23 #include <ExchangePlugin.h>
24 #include <ModelAPI_Feature.h>
25 #include <ModelAPI_Result.h>
26
27 #include <map>
28
29 /**
30  * \class ExchangePlugin_ExportFeature
31  * \ingroup Plugins
32  * \brief Feature for export shapes to the external files in CAD formats.
33  *
34  * The list of supported formats is defined in the configuration file.
35  */
36 class ExchangePlugin_ExportFeature : public ModelAPI_Feature
37 {
38 public:
39   /// Feature kind
40   inline static const std::string& ID()
41   {
42     static const std::string MY_EXPORT_ID("Export");
43     return MY_EXPORT_ID;
44   }
45   /// attribute name for file format
46   inline static const std::string& EXPORT_TYPE_ID()
47   {
48     static const std::string MY_EXPORT_TYPE_ID("ExportType");
49     return MY_EXPORT_TYPE_ID;
50   }
51   /// attribute name of file path
52   inline static const std::string& FILE_PATH_ID()
53   {
54     static const std::string MY_FILE_PATH_ID("file_path");
55     return MY_FILE_PATH_ID;
56   }
57   /// attribute name of xao file path
58   inline static const std::string& XAO_FILE_PATH_ID()
59   {
60     static const std::string MY_XAO_FILE_PATH_ID("xao_file_path");
61     return MY_XAO_FILE_PATH_ID;
62   }
63   /// attribute name of file format
64   inline static const std::string& FILE_FORMAT_ID()
65   {
66     static const std::string MY_FILE_FORMAT_ID("file_format");
67     return MY_FILE_FORMAT_ID;
68   }
69   /// attribute name of selection list
70   inline static const std::string& SELECTION_LIST_ID()
71   {
72     static const std::string MY_SELECTION_LIST_ID("selection_list");
73     return MY_SELECTION_LIST_ID;
74   }
75   /// attribute name of xao selection list
76   inline static const std::string& XAO_SELECTION_LIST_ID()
77   {
78     static const std::string MY_SELECTION_LIST_ID("xao_selection_list");
79     return MY_SELECTION_LIST_ID;
80   }
81   /// attribute name of author for XAO format
82   inline static const std::string& XAO_AUTHOR_ID()
83   {
84     static const std::string MY_XAO_AUTHOR_ID("xao_author");
85     return MY_XAO_AUTHOR_ID;
86   }
87   /// attribute name of geometry name for XAO format
88   inline static const std::string& XAO_GEOMETRY_NAME_ID()
89   {
90     static const std::string MY_XAO_GEOMETRY_NAME_ID("xao_geometry_name");
91     return MY_XAO_GEOMETRY_NAME_ID;
92   }
93   /// Default constructor
94   EXCHANGEPLUGIN_EXPORT ExchangePlugin_ExportFeature();
95   /// Default destructor
96   EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ExportFeature();
97
98   /// Returns the unique kind of a feature
99   EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind()
100   {
101     return ExchangePlugin_ExportFeature::ID();
102   }
103
104   /// Request for initialization of data model of the feature: adding all attributes
105   EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
106
107   /// Reimplemented from ModelAPI_Feature::attributeChanged()
108   EXCHANGEPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
109
110   /// Computes or recomputes the results
111   EXCHANGEPLUGIN_EXPORT virtual void execute();
112
113   /// Reimplemented from ModelAPI_Feature::isMacro(). Returns false.
114   // It is macro for not-XAO export. For XAO the feature is kept invisible in the tree
115   // for the export to GEOM functionality correct working.
116   EXCHANGEPLUGIN_EXPORT virtual bool isMacro() const;
117
118   /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
119   EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
120
121   /// Do not put in history.
122   /// Since it is not a macro, it is not deleted, but we don't want to see it.
123   bool isInHistory()  { return false; }
124
125 protected:
126   /// Performs export of the file
127   EXCHANGEPLUGIN_EXPORT void exportFile(const std::string& theFileName,
128                                         const std::string& theFormat);
129
130   /// Performs export to XAO file
131   EXCHANGEPLUGIN_EXPORT void exportXAO(const std::string& theFileName);
132 };
133
134 #endif /* EXPORT_EXPORTFEATURE_H_ */