Salome HOME
Improve XAO import: group_list
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_ImportFeature.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    ExchangePlugin_ImportFeature.h
4 // Created: Aug 28, 2014
5 // Author:  Sergey BELASH
6
7 #ifndef EXCHANGEPLUGIN_IMPORTFEATURE_H_
8 #define EXCHANGEPLUGIN_IMPORTFEATURE_H_
9
10 #include <ExchangePlugin.h>
11 #include <ModelAPI_Feature.h>
12 #include <ModelAPI_Result.h>
13
14 #include <map>
15
16 /**
17  * \class ExchangePlugin_ImportFeature
18  * \ingroup Plugins
19  * \brief Feature for import shapes from the external files in CAD formats.
20  *
21  * The list of supported formats is defined in the configuration file.
22  */
23 class ExchangePlugin_ImportFeature : public ModelAPI_Feature
24 {
25  public:
26   /// Feature kind
27   inline static const std::string& ID()
28   {
29     static const std::string MY_IMPORT_ID("Import");
30     return MY_IMPORT_ID;
31   }
32   /// attribute name of file path
33   inline static const std::string& FILE_PATH_ID()
34   {
35     static const std::string MY_FILE_PATH_ID("file_path");
36     return MY_FILE_PATH_ID;
37   }
38   /// attribute name of group list
39   inline static const std::string& GROUP_LIST_ID()
40   {
41     static const std::string MY_GROUP_LIST_ID("group_list");
42     return MY_GROUP_LIST_ID;
43   }
44   /// Default constructor
45   EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeature();
46   /// Default destructor
47   EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ImportFeature();
48
49   /// Returns the unique kind of a feature
50   EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind()
51   {
52     return ExchangePlugin_ImportFeature::ID();
53   }
54
55   /// Request for initialization of data model of the feature: adding all attributes
56   EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
57
58   /// Computes or recomputes the results
59   EXCHANGEPLUGIN_EXPORT virtual void execute();
60
61   /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
62   EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
63
64  protected:
65   /// Performs the import of the file
66   EXCHANGEPLUGIN_EXPORT void importFile(const std::string& theFileName);
67
68   /// Performs the import of XAO file
69   EXCHANGEPLUGIN_EXPORT void importXAO(const std::string& theFileName);
70
71   /// Creates and prepares a result body from the shape
72   std::shared_ptr<ModelAPI_ResultBody> createResultBody(
73       std::shared_ptr<GeomAPI_Shape> aGeomShape);
74
75 private:
76   /// Loads Naming data structure to the document
77   void loadNamingDS(std::shared_ptr<GeomAPI_Shape> theGeomShape, 
78                     std::shared_ptr<ModelAPI_ResultBody> theResultBody);
79 };
80
81 #endif /* IMPORT_IMPORTFEATURE_H_ */