SHAPER  9.12.0
ExchangePlugin_ExportFeature.h
1 // Copyright (C) 2014-2023 CEA, EDF
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 
37 {
38 public:
40  inline static const std::string& ID()
41  {
42  static const std::string MY_EXPORT_ID("Export");
43  return MY_EXPORT_ID;
44  }
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  }
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  }
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  }
64  inline static const std::string& STL_FILE_PATH_ID()
65  {
66  static const std::string MY_STL_FILE_PATH_ID("stl_file_path");
67  return MY_STL_FILE_PATH_ID;
68  }
70  inline static const std::string& STL_OBJECT_SELECTED()
71  {
72  static const std::string ATTR_ID("stl_object_selected");
73  return ATTR_ID;
74  }
76  inline static const std::string& STL_DEFLECTION_TYPE()
77  {
78  static const std::string ATTR_ID("stl_deflection_type");
79  return ATTR_ID;
80  }
82  inline static const std::string& STL_DEFLECTION_TYPE_RELATIVE()
83  {
84  static const std::string ATTR_ID("stl_deflection_type_relative");
85  return ATTR_ID;
86  }
88  inline static const std::string& STL_DEFLECTION_TYPE_ABSOLUTE()
89  {
90  static const std::string ATTR_ID("stl_deflection_type_absolute");
91  return ATTR_ID;
92  }
94  inline static const std::string& STL_RELATIVE()
95  {
96  static const std::string ATTR_ID("stl_relative");
97  return ATTR_ID;
98  }
100  inline static const std::string& STL_ABSOLUTE()
101  {
102  static const std::string ATTR_ID("stl_absolute");
103  return ATTR_ID;
104  }
106  inline static const std::string& STL_FILE_TYPE()
107  {
108  static const std::string ATTR_ID("stl_file_type");
109  return ATTR_ID;
110  }
112  inline static const std::string& STL_FILE_TYPE_ASCII()
113  {
114  static const std::string ATTR_ID("stl_file_type_acii");
115  return ATTR_ID;
116  }
118  inline static const std::string& STL_FILE_TYPE_BINARY()
119  {
120  static const std::string ATTR_ID("stl_file_type_binary");
121  return ATTR_ID;
122  }
124  inline static const std::string& FILE_FORMAT_ID()
125  {
126  static const std::string MY_FILE_FORMAT_ID("file_format");
127  return MY_FILE_FORMAT_ID;
128  }
130  inline static const std::string& SELECTION_LIST_ID()
131  {
132  static const std::string MY_SELECTION_LIST_ID("selection_list");
133  return MY_SELECTION_LIST_ID;
134  }
136  inline static const std::string& XAO_SELECTION_LIST_ID()
137  {
138  static const std::string MY_SELECTION_LIST_ID("xao_selection_list");
139  return MY_SELECTION_LIST_ID;
140  }
142  inline static const std::string& XAO_AUTHOR_ID()
143  {
144  static const std::string MY_XAO_AUTHOR_ID("xao_author");
145  return MY_XAO_AUTHOR_ID;
146  }
148  inline static const std::string& XAO_GEOMETRY_NAME_ID()
149  {
150  static const std::string MY_XAO_GEOMETRY_NAME_ID("xao_geometry_name");
151  return MY_XAO_GEOMETRY_NAME_ID;
152  }
154  inline static const std::string& MEMORY_BUFFER_ID()
155  {
156  static const std::string MY_MEMORY_BUFFER_ID("memory_buffer");
157  return MY_MEMORY_BUFFER_ID;
158  }
159 
161  EXCHANGEPLUGIN_EXPORT ExchangePlugin_ExportFeature();
163  EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ExportFeature();
164 
166  EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind()
167  {
169  }
170 
172  EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
173 
175  EXCHANGEPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
176 
178  EXCHANGEPLUGIN_EXPORT virtual void execute();
179 
181  // It is macro for not-XAO export. For XAO the feature is kept invisible in the tree
182  // for the export to GEOM functionality correct working.
183  EXCHANGEPLUGIN_EXPORT virtual bool isMacro() const;
184 
186  EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
187 
190  bool isInHistory() { return false; }
191 
192 protected:
194  EXCHANGEPLUGIN_EXPORT void exportFile(const std::string& theFileName,
195  const std::string& theFormat,
196  const bool isMemoryExport);
197 
199  EXCHANGEPLUGIN_EXPORT void exportXAO(const std::string& theFileName,
200  const bool isMemoryExport);
201 
203  EXCHANGEPLUGIN_EXPORT void exportSTL(const std::string& theFileName);
204 };
205 
206 #endif /* EXPORT_EXPORTFEATURE_H_ */
Feature for export shapes to the external files in CAD formats.
Definition: ExchangePlugin_ExportFeature.h:37
static const std::string & SELECTION_LIST_ID()
attribute name of selection list
Definition: ExchangePlugin_ExportFeature.h:130
static const std::string & EXPORT_TYPE_ID()
attribute name for file format
Definition: ExchangePlugin_ExportFeature.h:46
virtual EXCHANGEPLUGIN_EXPORT ~ExchangePlugin_ExportFeature()
Default destructor.
Definition: ExchangePlugin_ExportFeature.cpp:78
static const std::string & XAO_AUTHOR_ID()
attribute name of author for XAO format
Definition: ExchangePlugin_ExportFeature.h:142
static const std::string & STL_FILE_TYPE()
Attribute name for stl file type.
Definition: ExchangePlugin_ExportFeature.h:106
EXCHANGEPLUGIN_EXPORT ExchangePlugin_ExportFeature()
Default constructor.
Definition: ExchangePlugin_ExportFeature.cpp:74
static const std::string & ID()
Feature kind.
Definition: ExchangePlugin_ExportFeature.h:40
static const std::string & MEMORY_BUFFER_ID()
attribute string memory buffer
Definition: ExchangePlugin_ExportFeature.h:154
static const std::string & STL_ABSOLUTE()
Attribute name for absolute.
Definition: ExchangePlugin_ExportFeature.h:100
static const std::string & XAO_GEOMETRY_NAME_ID()
attribute name of geometry name for XAO format
Definition: ExchangePlugin_ExportFeature.h:148
EXCHANGEPLUGIN_EXPORT void exportFile(const std::string &theFileName, const std::string &theFormat, const bool isMemoryExport)
Performs export of the file.
Definition: ExchangePlugin_ExportFeature.cpp:188
static const std::string & STL_FILE_TYPE_ASCII()
Attribute name for stl file type ascii.
Definition: ExchangePlugin_ExportFeature.h:112
virtual EXCHANGEPLUGIN_EXPORT void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: ExchangePlugin_ExportFeature.cpp:86
static const std::string & FILE_FORMAT_ID()
attribute name of file format
Definition: ExchangePlugin_ExportFeature.h:124
EXCHANGEPLUGIN_EXPORT void exportXAO(const std::string &theFileName, const bool isMemoryExport)
Performs export to XAO file.
Definition: ExchangePlugin_ExportFeature.cpp:329
bool isInHistory()
Do not put in history.
Definition: ExchangePlugin_ExportFeature.h:190
static const std::string & STL_OBJECT_SELECTED()
Attribute name for selected object to export in stl file path.
Definition: ExchangePlugin_ExportFeature.h:70
static const std::string & STL_DEFLECTION_TYPE_ABSOLUTE()
Attribute name for deflection type absolute.
Definition: ExchangePlugin_ExportFeature.h:88
static const std::string & XAO_SELECTION_LIST_ID()
attribute name of xao selection list
Definition: ExchangePlugin_ExportFeature.h:136
virtual EXCHANGEPLUGIN_EXPORT void execute()
Computes or recomputes the results.
Definition: ExchangePlugin_ExportFeature.cpp:168
static const std::string & FILE_PATH_ID()
attribute name of file path
Definition: ExchangePlugin_ExportFeature.h:52
virtual EXCHANGEPLUGIN_EXPORT void attributeChanged(const std::string &theID)
Reimplemented from ModelAPI_Feature::attributeChanged()
Definition: ExchangePlugin_ExportFeature.cpp:153
virtual EXCHANGEPLUGIN_EXPORT bool isPreviewNeeded() const
Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
Definition: ExchangePlugin_ExportFeature.h:186
virtual EXCHANGEPLUGIN_EXPORT const std::string & getKind()
Returns the unique kind of a feature.
Definition: ExchangePlugin_ExportFeature.h:166
static const std::string & STL_DEFLECTION_TYPE()
Attribute name for deflection type.
Definition: ExchangePlugin_ExportFeature.h:76
static const std::string & STL_FILE_PATH_ID()
attribute name of stl file path
Definition: ExchangePlugin_ExportFeature.h:64
static const std::string & STL_FILE_TYPE_BINARY()
Attribute name for stl file type binary.
Definition: ExchangePlugin_ExportFeature.h:118
EXCHANGEPLUGIN_EXPORT void exportSTL(const std::string &theFileName)
Performs export to STL file.
Definition: ExchangePlugin_ExportFeature.cpp:287
static const std::string & STL_DEFLECTION_TYPE_RELATIVE()
Attribute name for deflection type relative.
Definition: ExchangePlugin_ExportFeature.h:82
static const std::string & STL_RELATIVE()
Attribute name for relative.
Definition: ExchangePlugin_ExportFeature.h:94
static const std::string & XAO_FILE_PATH_ID()
attribute name of xao file path
Definition: ExchangePlugin_ExportFeature.h:58
virtual EXCHANGEPLUGIN_EXPORT bool isMacro() const
Reimplemented from ModelAPI_Feature::isMacro(). Returns false.
Definition: ExchangePlugin_ExportFeature.cpp:611
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:39