]> SALOME platform Git repositories - modules/shaper.git/blob - src/ExchangePlugin/ExchangePlugin_ImportFeature.h
Salome HOME
Add command "Rename" to a folder context menu
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_ImportFeature.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_IMPORTFEATURE_H_
22 #define EXCHANGEPLUGIN_IMPORTFEATURE_H_
23
24 #include "ExchangePlugin.h"
25
26 #include <ModelAPI_CompositeFeature.h>
27 #include <ModelAPI_Result.h>
28
29 #include <map>
30
31 /**
32  * \class ExchangePlugin_ImportFeature
33  * \ingroup Plugins
34  * \brief Feature for import shapes from the external files in CAD formats.
35  *
36  * The list of supported formats is defined in the configuration file.
37  */
38 class ExchangePlugin_ImportFeature : public ModelAPI_CompositeFeature
39 {
40  public:
41   /// Feature kind
42   inline static const std::string& ID()
43   {
44     static const std::string MY_IMPORT_ID("Import");
45     return MY_IMPORT_ID;
46   }
47   /// attribute name of file path
48   inline static const std::string& FILE_PATH_ID()
49   {
50     static const std::string MY_FILE_PATH_ID("file_path");
51     return MY_FILE_PATH_ID;
52   }
53   /// All features (list of references)
54   inline static const std::string& FEATURES_ID()
55   {
56     static const std::string MY_FEATURES_ID("Features");
57     return MY_FEATURES_ID;
58   }
59   /// Default constructor
60   EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeature();
61   /// Default destructor
62   EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ImportFeature();
63
64   /// Returns the unique kind of a feature
65   EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind()
66   {
67     return ExchangePlugin_ImportFeature::ID();
68   }
69
70   /// Request for initialization of data model of the feature: adding all attributes
71   EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
72
73   /// Computes or recomputes the results
74   EXCHANGEPLUGIN_EXPORT virtual void execute();
75
76   /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
77   EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
78
79   /// Reimplemented from ModelAPI_CompositeFeature::addFeature()
80   virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
81
82   /// Reimplemented from ModelAPI_CompositeFeature::numberOfSubs()
83   virtual int numberOfSubs(bool forTree = false) const;
84
85   /// Reimplemented from ModelAPI_CompositeFeature::subFeature()
86   virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
87
88   /// Reimplemented from ModelAPI_CompositeFeature::subFeatureId()
89   virtual int subFeatureId(const int theIndex) const;
90
91   /// Reimplemented from ModelAPI_CompositeFeature::isSub()
92   virtual bool isSub(ObjectPtr theObject) const;
93
94   /// Reimplemented from ModelAPI_CompositeFeature::removeFeature()
95   virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
96
97  protected:
98   /// Performs the import of the file
99   EXCHANGEPLUGIN_EXPORT void importFile(const std::string& theFileName);
100
101   /// Performs the import of XAO file
102   EXCHANGEPLUGIN_EXPORT void importXAO(const std::string& theFileName);
103
104   /// Creates and prepares a result body from the shape
105   std::shared_ptr<ModelAPI_ResultBody> createResultBody(
106       std::shared_ptr<GeomAPI_Shape> aGeomShape);
107
108 private:
109   /// Loads Naming data structure to the document
110   void loadNamingDS(std::shared_ptr<GeomAPI_Shape> theGeomShape,
111                     std::shared_ptr<ModelAPI_ResultBody> theResultBody);
112 };
113
114 #endif /* IMPORT_IMPORTFEATURE_H_ */