1
/***************************************************************************
2
* Copyright (c) 2013 Jan Rheinländer *
3
* <jrheinlaender[at]users.sourceforge.net> *
5
* This file is part of the FreeCAD CAx development system. *
7
* This library is free software; you can redistribute it and/or *
8
* modify it under the terms of the GNU Library General Public *
9
* License as published by the Free Software Foundation; either *
10
* version 2 of the License, or (at your option) any later version. *
12
* This library is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU Library General Public License for more details. *
17
* You should have received a copy of the GNU Library General Public *
18
* License along with this library; see the file COPYING.LIB. If not, *
19
* write to the Free Software Foundation, Inc., 59 Temple Place, *
20
* Suite 330, Boston, MA 02111-1307, USA *
22
***************************************************************************/
24
#include "PreCompiled.h"
26
#include "DatumFeature.h"
32
using namespace Attacher;
34
PROPERTY_SOURCE_ABSTRACT_WITH_EXTENSIONS(Part::Datum, Part::Feature)
38
AttachExtension::initExtension(this);
42
Datum::~Datum() = default;
44
void Datum::onDocumentRestored()
46
// This seems to be the only way to make the ViewProvider display the datum feature
47
AttachmentSupport.touch();
48
Part::Feature::onDocumentRestored();
51
TopoDS_Shape Datum::getShape() const
53
Part::TopoShape sh = Shape.getShape();
54
sh.setPlacement(Placement.getValue());
58
App::DocumentObject *Datum::getSubObject(const char *subname,
59
PyObject **pyObj, Base::Matrix4D *pmat, bool transform, int depth) const
61
// For the sake of simplicity, we don't bother to check for subname, just
62
// return the shape as it is, because a datum object only holds shape with
63
// one single geometry element.
68
*pmat *= Placement.getValue().toMatrix();
71
return const_cast<Datum*>(this);
73
Base::PyGILStateLocker lock;
75
TopoShape ts(getShape().Located(TopLoc_Location()));
76
if(pmat && !ts.isNull())
77
ts.transformShape(*pmat,false,true);
78
*pyObj = Py::new_reference_to(shape2pyshape(ts.getShape()));
79
return const_cast<Datum*>(this);
83
Base::Vector3d Datum::getBasePoint () const {
84
return Placement.getValue().getPosition();