Salome HOME
Copyright update 2021
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_Import.h
1 // Copyright (C) 2014-2021  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_IMPORT_H_
21 #define EXCHANGEPLUGIN_IMPORT_H_
22
23 #include "ExchangePlugin.h"
24
25 #include <ModelAPI_CompositeFeature.h>
26 #include <ModelAPI_Result.h>
27 #include <ModelAPI_AttributeInteger.h>
28 #include <ModelAPI_AttributeStringArray.h>
29
30 #include <map>
31
32 /**
33  * \class ExchangePlugin_ImportFeature
34  * \ingroup Plugins
35  * \brief Feature for import shapes from the external files in CAD formats.
36  *
37  * The list of supported formats is defined in the configuration file.
38  */
39 class ExchangePlugin_Import : public ModelAPI_Feature
40 {
41  public:
42   /// Feature kind
43   inline static const std::string& ID()
44   {
45     static const std::string MY_IMPORT_ID("ImportMacro");
46     return MY_IMPORT_ID;
47   }
48   /// Feature kind
49   inline static const std::string& IMPORT_TYPE_ID()
50   {
51     static const std::string MY_IMPORT_TYPE_ID("ImportType");
52     return MY_IMPORT_TYPE_ID;
53   }
54   /// attribute name of file path
55   inline static const std::string& FILE_PATH_ID()
56   {
57     static const std::string MY_FILE_PATH_ID("file_path");
58     return MY_FILE_PATH_ID;
59   }
60   /// attribute name of target part
61   inline static const std::string& TARGET_PART_ID()
62   {
63     static const std::string MY_TARGET_PART_ID("target_part");
64     return MY_TARGET_PART_ID;
65   }
66   /// attribute name of list of target parts
67   inline static const std::string& TARGET_PARTS_LIST_ID()
68   {
69     static const std::string MY_TARGET_PARTS_LIST_ID("target_parts_list");
70     return MY_TARGET_PARTS_LIST_ID;
71   }
72   /// attribute name of step file path
73   inline static const std::string& STEP_FILE_PATH_ID()
74   {
75     static const std::string MY_STEP_FILE_PATH_ID("step_file_path");
76     return MY_STEP_FILE_PATH_ID;
77   }
78   /// attribute name of step target part
79   inline static const std::string& STEP_TARGET_PART_ID()
80   {
81     static const std::string MY_STEP_TARGET_PART_ID("step_target_part");
82     return MY_STEP_TARGET_PART_ID;
83   }
84   /// attribute name of list ofstep target parts
85   inline static const std::string& STEP_TARGET_PARTS_LIST_ID()
86   {
87     static const std::string MY_STEP_TARGET_PARTS_LIST_ID("step_target_parts_list");
88     return MY_STEP_TARGET_PARTS_LIST_ID;
89   }
90   /// attribute name of step Scale to International System Units
91   inline static const std::string& STEP_SCALE_INTER_UNITS_ID()
92   {
93     static const std::string MY_STEP_SCALE_INTER_UNITS_ID("step_scale_inter_units");
94     return MY_STEP_SCALE_INTER_UNITS_ID;
95   }
96   /// attribute name of step materiels
97   inline static const std::string& STEP_MATERIALS_ID()
98   {
99     static const std::string MY_STEP_MATERIALS_ID("step_materials");
100     return MY_STEP_MATERIALS_ID;
101   }
102   /// attribute name of step colors
103   inline static const std::string& STEP_COLORS_ID()
104   {
105     static const std::string MY_STEP_COLORS_ID("step_colors");
106     return MY_STEP_COLORS_ID;
107   }
108   /// Default constructor
109   EXCHANGEPLUGIN_EXPORT ExchangePlugin_Import();
110   /// Default destructor
111   EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_Import();
112
113   /// Returns the unique kind of a feature
114   EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind()
115   {
116     return ExchangePlugin_Import::ID();
117   }
118
119   /// Request for initialization of data model of the feature: adding all attributes
120   EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
121
122   /// Called on change of any argument-attribute of this object
123   /// \param theID identifier of changed attribute
124   EXCHANGEPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
125
126   /// Computes or recomputes the results
127   EXCHANGEPLUGIN_EXPORT virtual void execute();
128
129   /// Returns true if this feature is used as macro: creates other features and then removed.
130   EXCHANGEPLUGIN_EXPORT virtual bool isMacro() const { return true; }
131
132   /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
133   EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
134
135  private:
136   /// Called to update part
137   EXCHANGEPLUGIN_EXPORT
138   void updatePart(AttributeStringArrayPtr& thePartsAttr, AttributeIntegerPtr& theTargetAttr);
139 };
140
141 #endif /* IMPORT_IMPORTFEATURE_H_ */