1
/***************************************************************************
2
* Copyright (c) J�rgen Riegel (juergen.riegel@web.de) 2002 *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
24
#include "PreCompiled.h"
29
#include <Base/Console.h>
30
#include <Base/Exception.h>
31
#include "FeatureTest.h"
34
#define new DEBUG_CLIENTBLOCK
38
PROPERTY_SOURCE(App::FeatureTest, App::DocumentObject)
40
const char* enums[]= {"Zero","One","Two","Three","Four",NULL};
41
const PropertyIntegerConstraint::Constraints intPercent = {0,100,1};
42
const PropertyFloatConstraint::Constraints floatPercent = {0.0,100.0,1.0};
45
FeatureTest::FeatureTest()
47
ADD_PROPERTY(Integer,(4711) );
48
ADD_PROPERTY(Float ,(47.11f) );
49
ADD_PROPERTY(Bool ,(true) );
50
ADD_PROPERTY(String ,("4711"));
51
ADD_PROPERTY(Path ,("c:\\temp"));
52
ADD_PROPERTY(StringList ,("4711"));
54
ADD_PROPERTY(Enum ,(4));
56
ADD_PROPERTY(ConstraintInt ,(5));
57
ConstraintInt.setConstraints(&intPercent);
58
ADD_PROPERTY(ConstraintFloat ,(5.0));
59
ConstraintFloat.setConstraints(&floatPercent);
62
ADD_PROPERTY(Colour ,(c) );
63
ADD_PROPERTY(ColourList ,(c) );
65
ADD_PROPERTY(Distance,(47.11f) );
66
ADD_PROPERTY(Angle ,(3.0f) );
68
ADD_PROPERTY(IntegerList,(4711) );
69
ADD_PROPERTY(FloatList ,(47.11f) );
71
ADD_PROPERTY(Link ,(0));
72
ADD_PROPERTY(LinkList ,(0));
74
ADD_PROPERTY(Vector ,(1.0,2.0,3.0));
75
ADD_PROPERTY(VectorList,(3.0,2.0,1.0));
76
ADD_PROPERTY(Matrix ,(Base::Matrix4D(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0)));
77
ADD_PROPERTY(Placement ,(Base::Placement()));
79
// properties for recompute testing
80
static const char* group = "Feature Test";
81
ADD_PROPERTY_TYPE(Source1 ,(0),group,Prop_None,"Source for testing links");
82
ADD_PROPERTY_TYPE(Source2 ,(0),group,Prop_None,"Source for testing links");
83
ADD_PROPERTY_TYPE(SourceN ,(0),group,Prop_None,"Source for testing links");
84
ADD_PROPERTY_TYPE(ExecResult ,("empty"),group,Prop_None,"Result of the execution");
85
ADD_PROPERTY_TYPE(ExceptionType ,(0),group,Prop_None,"The type of exception the execution method throws");
86
ADD_PROPERTY_TYPE(ExecCount ,(0),group,Prop_None,"Number of executions");
88
// properties with types
89
ADD_PROPERTY_TYPE(TypeHidden ,(4711),group,Prop_Hidden,"An example property which has the type 'Hidden'" );
90
ADD_PROPERTY_TYPE(TypeReadOnly,(4711),group,Prop_ReadOnly ,"An example property which has the type 'ReadOnly'" );
91
ADD_PROPERTY_TYPE(TypeOutput ,(4711),group,Prop_Output ,"An example property which has the type 'Transient'" );
92
ADD_PROPERTY_TYPE(TypeTransient,(4711),group,Prop_Transient ,"An example property which has the type 'Transient'" );
93
ADD_PROPERTY_TYPE(TypeAll ,(4711),group,(App::PropertyType) (Prop_Output|Prop_ReadOnly |Prop_Hidden ),
94
"An example property which has the types 'Output', 'ReadOnly' and 'Hidden'");
99
DocumentObjectExecReturn *FeatureTest::execute(void)
103
switch(ExceptionType.getValue())
106
case 1: throw "Test Exeption";
107
case 2: throw Base::Exception("FeatureTestException::execute(): Testexception");
109
ExecCount.setValue(ExecCount.getValue() + 1);
111
ExecResult.setValue("Exec");
113
return DocumentObject::StdReturn;
117
PROPERTY_SOURCE(App::FeatureTestException, App::FeatureTest)
120
FeatureTestException::FeatureTestException()
122
ADD_PROPERTY(ExceptionType,(Base::Exception::getClassTypeId().getKey()) );
125
DocumentObjectExecReturn *FeatureTestException::execute(void)
129
throw Base::Exception("FeatureTestException::execute(): Testexception ;-)");