1 // Copyright (C) 2014-2020 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef EXCHANGEPLUGIN_IMPORT_H_
21 #define EXCHANGEPLUGIN_IMPORT_H_
23 #include "ExchangePlugin.h"
25 #include <ModelAPI_CompositeFeature.h>
26 #include <ModelAPI_Result.h>
27 #include <ModelAPI_AttributeInteger.h>
28 #include <ModelAPI_AttributeStringArray.h>
33 * \class ExchangePlugin_ImportFeature
35 * \brief Feature for import shapes from the external files in CAD formats.
37 * The list of supported formats is defined in the configuration file.
39 class ExchangePlugin_ImportBase : public ModelAPI_Feature
42 /// attribute name of file path
43 inline static const std::string& FILE_PATH_ID()
45 static const std::string MY_FILE_PATH_ID("file_path");
46 return MY_FILE_PATH_ID;
48 /// attribute name of target part
49 inline static const std::string& TARGET_PART_ID()
51 static const std::string MY_TARGET_PART_ID("target_part");
52 return MY_TARGET_PART_ID;
54 /// attribute name of list of target parts
55 inline static const std::string& TARGET_PARTS_LIST_ID()
57 static const std::string MY_TARGET_PARTS_LIST_ID("target_parts_list");
58 return MY_TARGET_PARTS_LIST_ID;
60 /// Default constructor
61 EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportBase()= default;
62 /// Default destructor
63 EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ImportBase()= default;
66 /// Request for initialization of data model of the feature: adding all attributes
67 EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
69 /// Called on change of any argument-attribute of this object
70 /// \param theID identifier of changed attribute
71 EXCHANGEPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID) = 0;
73 /// Computes or recomputes the results
74 EXCHANGEPLUGIN_EXPORT virtual void execute() = 0;
76 /// Returns true if this feature is used as macro: creates other features and then removed.
77 EXCHANGEPLUGIN_EXPORT virtual bool isMacro() const { return true; }
79 /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
80 EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
84 EXCHANGEPLUGIN_EXPORT void updatePart(AttributeStringArrayPtr& aPartsAttr,
85 AttributeIntegerPtr& aTargetAttr);
88 EXCHANGEPLUGIN_EXPORT class ExchangePlugin_Import : public ExchangePlugin_ImportBase
92 inline static const std::string& ID()
94 static const std::string MY_IMPORT_ID("ImportMacro");
98 inline static const std::string& IMPORT_TYPE_ID()
100 static const std::string MY_IMPORT_TYPE_ID("ImportType");
101 return MY_IMPORT_TYPE_ID;
103 /// attribute name of step file path
104 inline static const std::string& STEP_FILE_PATH_ID()
106 static const std::string MY_STEP_FILE_PATH_ID("step_file_path");
107 return MY_STEP_FILE_PATH_ID;
109 /// attribute name of step target part
110 inline static const std::string& STEP_TARGET_PART_ID()
112 static const std::string MY_STEP_TARGET_PART_ID("step_target_part");
113 return MY_STEP_TARGET_PART_ID;
115 /// attribute name of list ofstep target parts
116 inline static const std::string& STEP_TARGET_PARTS_LIST_ID()
118 static const std::string MY_STEP_TARGET_PARTS_LIST_ID("step_target_parts_list");
119 return MY_STEP_TARGET_PARTS_LIST_ID;
121 /// attribute name of step Scale to International System Units
122 inline static const std::string& STEP_SCALE_INTER_UNITS_ID()
124 static const std::string MY_STEP_SCALE_INTER_UNITS_ID("step_scale_inter_units");
125 return MY_STEP_SCALE_INTER_UNITS_ID;
127 /// attribute name of step materiels
128 inline static const std::string& STEP_MATERIALS_ID()
130 static const std::string MY_STEP_MATERIALS_ID("step_materials");
131 return MY_STEP_MATERIALS_ID;
133 /// attribute name of step colors
134 inline static const std::string& STEP_COLORS_ID()
136 static const std::string MY_STEP_COLORS_ID("step_colors");
137 return MY_STEP_COLORS_ID;
139 /// Default constructor
140 EXCHANGEPLUGIN_EXPORT ExchangePlugin_Import() = default;
141 /// Default destructor
142 EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_Import() = default;
144 /// Returns the unique kind of a feature
145 EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind() override
147 return ExchangePlugin_Import::ID();
149 /// Computes or recomputes the results
150 EXCHANGEPLUGIN_EXPORT virtual void execute() override;
152 /// Request for initialization of data model of the feature: adding all attributes
153 EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
155 // Called on change of any argument-attribute of this object
156 /// \param theID identifier of changed attribute
157 EXCHANGEPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID) override;
161 EXCHANGEPLUGIN_EXPORT class ExchangePlugin_Import_Image : public ExchangePlugin_ImportBase
165 inline static const std::string& ID()
167 static const std::string MY_IMPORT_ID("ImportImageMacro");
171 /// Default constructor
172 EXCHANGEPLUGIN_EXPORT ExchangePlugin_Import_Image() = default;
173 /// Default destructor
174 EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_Import_Image() = default;
176 /// Returns the unique kind of a feature
177 EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind() override
179 return ExchangePlugin_Import_Image::ID();
182 /// Computes or recomputes the results
183 EXCHANGEPLUGIN_EXPORT virtual void execute() override;
185 // Called on change of any argument-attribute of this object
186 /// \param theID identifier of changed attribute
187 EXCHANGEPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID) override;
191 #endif /* IMPORT_IMPORTFEATURE_H_ */