MeasureDistance.cpp
Go to the documentation of this file.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
00026 #ifndef _PreComp_
00027 #endif
00028
00029 #include "MeasureDistance.h"
00030
00031 using namespace App;
00032
00033 PROPERTY_SOURCE(App::MeasureDistance, App::DocumentObject)
00034
00035
00036 MeasureDistance::MeasureDistance()
00037 {
00038 ADD_PROPERTY_TYPE(P1,(Base::Vector3f()),"Measurement",Prop_None,"First point of measurement");
00039 ADD_PROPERTY_TYPE(P2,(Base::Vector3f()),"Measurement",Prop_None,"Second point of measurement");
00040 ADD_PROPERTY_TYPE(Distance,(0.0f) ,"Measurement",App::PropertyType(Prop_ReadOnly|Prop_Output),
00041 "Distance between the points");
00042
00043 }
00044
00045 MeasureDistance::~MeasureDistance()
00046 {
00047 }
00048
00049 DocumentObjectExecReturn *MeasureDistance::execute(void)
00050 {
00051 Distance.setValue(Base::Distance(P1.getValue(), P2.getValue()));
00052 return DocumentObject::StdReturn;
00053 }
00054
00055 void MeasureDistance::onChanged(const App::Property* prop)
00056 {
00057 if (prop == &P1 || prop == &P2) {
00058 if (!isRestoring()) {
00059 App::DocumentObjectExecReturn *ret = recompute();
00060 delete ret;
00061 }
00062 }
00063 DocumentObject::onChanged(prop);
00064 }