1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "FeaturesAPI_BooleanCommon.h"
23 #include <ModelHighAPI_Dumper.h>
24 #include <ModelHighAPI_Selection.h>
25 #include <ModelHighAPI_Tools.h>
27 //==================================================================================================
28 FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
29 const std::shared_ptr<ModelAPI_Feature>& theFeature)
30 : ModelHighAPI_Interface(theFeature)
35 //==================================================================================================
36 FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
37 const std::shared_ptr<ModelAPI_Feature>& theFeature,
38 const std::list<ModelHighAPI_Selection>& theMainObjects)
39 : ModelHighAPI_Interface(theFeature)
42 fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), mycreationMethod);
43 fillAttribute(theMainObjects, mymainObjects);
49 //==================================================================================================
50 FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
51 const std::shared_ptr<ModelAPI_Feature>& theFeature,
52 const std::list<ModelHighAPI_Selection>& theMainObjects,
53 const std::list<ModelHighAPI_Selection>& theToolObjects)
54 : ModelHighAPI_Interface(theFeature)
57 fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod);
58 fillAttribute(theMainObjects, mymainObjects);
59 fillAttribute(theToolObjects, mytoolObjects);
65 //==================================================================================================
66 FeaturesAPI_BooleanCommon::~FeaturesAPI_BooleanCommon()
71 //==================================================================================================
72 void FeaturesAPI_BooleanCommon::setMainObjects(
73 const std::list<ModelHighAPI_Selection>& theMainObjects)
75 fillAttribute(theMainObjects, mymainObjects);
80 //==================================================================================================
81 void FeaturesAPI_BooleanCommon::setToolObjects(
82 const std::list<ModelHighAPI_Selection>& theToolObjects)
84 fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod);
85 fillAttribute(theToolObjects, mytoolObjects);
90 //==================================================================================================
91 void FeaturesAPI_BooleanCommon::setAdvancedMode(const bool theMode)
94 fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod);
96 fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), mycreationMethod);
102 //==================================================================================================
103 void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const
105 FeaturePtr aBase = feature();
107 theDumper << aBase << " = model.addCommon";
109 const std::string& aDocName = theDumper.name(aBase->document());
110 AttributeStringPtr aMode = aBase->string(FeaturesPlugin_BooleanCommon::CREATION_METHOD());
111 AttributeSelectionListPtr anObjects =
112 aBase->selectionList(FeaturesPlugin_BooleanCommon::OBJECT_LIST_ID());
113 AttributeSelectionListPtr aTools =
114 aBase->selectionList(FeaturesPlugin_BooleanCommon::TOOL_LIST_ID());
116 theDumper << "(" << aDocName << ", " << anObjects;
118 if (aMode->value() == FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED()) {
119 theDumper << ", " << aTools;
122 theDumper << ")" << std::endl;
125 //==================================================================================================
126 BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
127 const std::list<ModelHighAPI_Selection>& theMainObjects)
129 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID());
130 return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects));
133 //==================================================================================================
134 BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
135 const std::list<ModelHighAPI_Selection>& theMainObjects,
136 const std::list<ModelHighAPI_Selection>& theToolObjects)
138 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID());
139 return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature,