00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025 #ifndef _PreComp_
00026 #endif
00027
00028
00029 #include <Base/Console.h>
00030 #include <Base/Exception.h>
00031 #include "FeatureTest.h"
00032 #include "Material.h"
00033
00034 #define new DEBUG_CLIENTBLOCK
00035 using namespace App;
00036
00037
00038 PROPERTY_SOURCE(App::FeatureTest, App::DocumentObject)
00039
00040 const char* enums[]= {"Zero","One","Two","Three","Four",NULL};
00041 const PropertyIntegerConstraint::Constraints intPercent = {0,100,1};
00042 const PropertyFloatConstraint::Constraints floatPercent = {0.0,100.0,1.0};
00043
00044
00045 FeatureTest::FeatureTest()
00046 {
00047 ADD_PROPERTY(Integer,(4711) );
00048 ADD_PROPERTY(Float ,(47.11f) );
00049 ADD_PROPERTY(Bool ,(true) );
00050 ADD_PROPERTY(String ,("4711"));
00051 ADD_PROPERTY(Path ,("c:\\temp"));
00052 ADD_PROPERTY(StringList ,("4711"));
00053
00054 ADD_PROPERTY(Enum ,(4));
00055 Enum.setEnums(enums);
00056 ADD_PROPERTY(ConstraintInt ,(5));
00057 ConstraintInt.setConstraints(&intPercent);
00058 ADD_PROPERTY(ConstraintFloat ,(5.0));
00059 ConstraintFloat.setConstraints(&floatPercent);
00060
00061 App::Color c;
00062 ADD_PROPERTY(Colour ,(c) );
00063 ADD_PROPERTY(ColourList ,(c) );
00064
00065 ADD_PROPERTY(Distance,(47.11f) );
00066 ADD_PROPERTY(Angle ,(3.0f) );
00067
00068 ADD_PROPERTY(IntegerList,(4711) );
00069 ADD_PROPERTY(FloatList ,(47.11f) );
00070
00071 ADD_PROPERTY(Link ,(0));
00072 ADD_PROPERTY(LinkSub, (0));
00073 ADD_PROPERTY(LinkList ,(0));
00074
00075 ADD_PROPERTY(Vector ,(1.0,2.0,3.0));
00076 ADD_PROPERTY(VectorList,(3.0,2.0,1.0));
00077 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)));
00078 ADD_PROPERTY(Placement ,(Base::Placement()));
00079
00080
00081 static const char* group = "Feature Test";
00082 ADD_PROPERTY_TYPE(Source1 ,(0),group,Prop_None,"Source for testing links");
00083 ADD_PROPERTY_TYPE(Source2 ,(0),group,Prop_None,"Source for testing links");
00084 ADD_PROPERTY_TYPE(SourceN ,(0),group,Prop_None,"Source for testing links");
00085 ADD_PROPERTY_TYPE(ExecResult ,("empty"),group,Prop_None,"Result of the execution");
00086 ADD_PROPERTY_TYPE(ExceptionType ,(0),group,Prop_None,"The type of exception the execution method throws");
00087 ADD_PROPERTY_TYPE(ExecCount ,(0),group,Prop_None,"Number of executions");
00088
00089
00090 ADD_PROPERTY_TYPE(TypeHidden ,(4711),group,Prop_Hidden,"An example property which has the type 'Hidden'" );
00091 ADD_PROPERTY_TYPE(TypeReadOnly,(4711),group,Prop_ReadOnly ,"An example property which has the type 'ReadOnly'" );
00092 ADD_PROPERTY_TYPE(TypeOutput ,(4711),group,Prop_Output ,"An example property which has the type 'Output'" );
00093 ADD_PROPERTY_TYPE(TypeTransient,(4711),group,Prop_Transient ,"An example property which has the type 'Transient'" );
00094 ADD_PROPERTY_TYPE(TypeAll ,(4711),group,(App::PropertyType) (Prop_Output|Prop_ReadOnly |Prop_Hidden ),
00095 "An example property which has the types 'Output', 'ReadOnly' and 'Hidden'");
00096
00097 }
00098
00099 FeatureTest::~FeatureTest()
00100 {
00101
00102 }
00103 DocumentObjectExecReturn *FeatureTest::execute(void)
00104 {
00105
00106
00107 switch(ExceptionType.getValue())
00108 {
00109 case 0: break;
00110 case 1: throw "Test Exeption";
00111 case 2: throw Base::Exception("FeatureTestException::execute(): Testexception");
00112 }
00113 ExecCount.setValue(ExecCount.getValue() + 1);
00114
00115 ExecResult.setValue("Exec");
00116
00117 return DocumentObject::StdReturn;
00118 }
00119
00120
00121 PROPERTY_SOURCE(App::FeatureTestException, App::FeatureTest)
00122
00123
00124 FeatureTestException::FeatureTestException()
00125 {
00126 ADD_PROPERTY(ExceptionType,(Base::Exception::getClassTypeId().getKey()) );
00127 }
00128
00129 DocumentObjectExecReturn *FeatureTestException::execute(void)
00130 {
00131
00132
00133 throw Base::Exception("FeatureTestException::execute(): Testexception ;-)");
00134
00135 return 0;
00136 }