Salome HOME
c653861f329d4aebe273a172bed57f71c0e6e6df
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_ExportFeature.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    ExchangePlugin_ExportFeature.h
4 // Created: May 14, 2015
5 // Author:  Sergey POKHODENKO
6
7 #ifndef EXCHANGEPLUGIN_EXPORTFEATURE_H_
8 #define EXCHANGEPLUGIN_EXPORTFEATURE_H_
9
10 #include <ExchangePlugin.h>
11 #include <ModelAPI_Feature.h>
12 #include <ModelAPI_Result.h>
13
14 #include <map>
15
16 /**\class ExchangePlugin_ExportFeature
17  * \ingroup Plugins
18  * \brief Feature for export shapes to the external files in CAD formats.
19  *
20  * The set of supported formats is defined in the configuration file.
21  */
22 class ExchangePlugin_ExportFeature : public ModelAPI_Feature
23 {
24 public:
25   inline static const std::string& ID()
26   {
27     static const std::string MY_EXPORT_ID("Export");
28     return MY_EXPORT_ID;
29   }
30   /// attribute name of file path
31   inline static const std::string& FILE_PATH_ID()
32   {
33     static const std::string MY_FILE_PATH_ID("file_path");
34     return MY_FILE_PATH_ID;
35   }
36   /// attribute name of file format
37   inline static const std::string& FILE_FORMAT_ID()
38   {
39     static const std::string MY_FILE_FORMAT_ID("file_format");
40     return MY_FILE_FORMAT_ID;
41   }
42   /// attribute name of selection list
43   inline static const std::string& SELECTION_LIST_ID()
44   {
45     static const std::string MY_SELECTION_LIST_ID("selection_list");
46     return MY_SELECTION_LIST_ID;
47   }
48   /// default constructor
49   EXCHANGEPLUGIN_EXPORT ExchangePlugin_ExportFeature();
50   /// default destructor
51   EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ExportFeature();
52
53   /// Request for initialization of data model of the feature: adding all attributes
54   EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
55
56   /// Returns the unique kind of a feature
57   EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind();
58
59   /// Computes or recomputes the results
60   EXCHANGEPLUGIN_EXPORT virtual void execute();
61
62   /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true.
63   EXCHANGEPLUGIN_EXPORT virtual bool isMacro() const { return true; }
64
65   /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
66   EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
67
68 protected:
69   /// Performs the export of the file
70   EXCHANGEPLUGIN_EXPORT bool exportFile(const std::string& theFileName,
71                                         const std::string& theFormat,
72                                         std::shared_ptr<GeomAPI_Shape> theShape);
73 };
74
75 #endif /* EXPORT_EXPORTFEATURE_H_ */