Salome HOME
updated copyright message
[modules/shaper.git] / src / FiltersAPI / FiltersAPI_Argument.cpp
1 // Copyright (C) 2014-2023  CEA, EDF
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 #include "FiltersAPI_Argument.h"
21
22 FiltersAPI_Argument::FiltersAPI_Argument()
23 {
24 }
25
26 FiltersAPI_Argument::FiltersAPI_Argument(const bool theValue)
27   : myBoolean(theValue)
28 {
29 }
30
31 FiltersAPI_Argument::FiltersAPI_Argument(const ModelHighAPI_Double theValue)
32   : myDouble(theValue)
33 {
34 }
35
36 FiltersAPI_Argument::FiltersAPI_Argument(const double& theValue)
37 {
38   myDouble = theValue;
39 }
40
41 FiltersAPI_Argument::FiltersAPI_Argument(const std::string& theValue)
42   : myValue(theValue)
43 {
44 }
45
46 FiltersAPI_Argument::FiltersAPI_Argument(const ModelHighAPI_Selection& theSelection)
47   : mySelection(theSelection)
48 {
49 }
50
51 FiltersAPI_Argument::FiltersAPI_Argument(const AttributeSelectionPtr& theSelection)
52   : mySelectionAttr(theSelection)
53 {
54 }
55
56 FiltersAPI_Argument::~FiltersAPI_Argument()
57 {
58 }
59
60 void FiltersAPI_Argument::dump(ModelHighAPI_Dumper& theDumper) const
61 {
62   if (mySelectionAttr) {
63     // write empty selection attribute, because parametrization is not supported yet
64     theDumper << "model.selection()"; // mySelectionAttr;
65   }
66   else if (mySelection.variantType() == ModelHighAPI_Selection::VT_Empty) {
67     if (myDouble.value() > std::numeric_limits<double>::lowest() ) {
68       theDumper << myDouble.value();
69     }
70     else if (myValue.empty()) {
71       theDumper << myBoolean;
72     }
73     else{
74       theDumper << "\"" << myValue << "\"";
75     }
76   }
77 }