MeasureDistance.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
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 }

Generated on Wed Nov 23 19:00:22 2011 for FreeCAD by  doxygen 1.6.1