Moved generic Datum class to Part module to avoid Sketcher dependency on PartDesign
This commit is contained in:
committed by
Stefan Tröger
parent
20ba1983a4
commit
5b3d5e6bd8
101
src/Mod/PartDesign/Gui/ViewProviderDatumPoint.cpp
Normal file
101
src/Mod/PartDesign/Gui/ViewProviderDatumPoint.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2013 Jan Rheinlaender <jrheinlaender@users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <Inventor/nodes/SoSeparator.h>
|
||||
# include <Inventor/nodes/SoPickStyle.h>
|
||||
# include <Inventor/nodes/SoShapeHints.h>
|
||||
# include <Inventor/nodes/SoMaterial.h>
|
||||
# include <Inventor/nodes/SoBaseColor.h>
|
||||
# include <Inventor/nodes/SoMarkerSet.h>
|
||||
# include <Inventor/nodes/SoVertexProperty.h>
|
||||
# include <Inventor/nodes/SoLineSet.h>
|
||||
# include <Inventor/nodes/SoFaceSet.h>
|
||||
# include <Inventor/details/SoLineDetail.h>
|
||||
# include <Inventor/details/SoFaceDetail.h>
|
||||
# include <Inventor/details/SoPointDetail.h>
|
||||
# include <TopoDS_Vertex.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <BRep_Tool.hxx>
|
||||
# include <gp_Pnt.hxx>
|
||||
# include <Precision.hxx>
|
||||
# include <Geom_Plane.hxx>
|
||||
# include <Geom_Line.hxx>
|
||||
# include <GeomAPI_IntCS.hxx>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderDatumPoint.h"
|
||||
#include "TaskDatumParameters.h"
|
||||
#include "Workbench.h"
|
||||
#include <Mod/PartDesign/App/DatumPoint.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderDatumPoint,PartDesignGui::ViewProviderDatum)
|
||||
|
||||
ViewProviderDatumPoint::ViewProviderDatumPoint()
|
||||
{
|
||||
SoMarkerSet* points = new SoMarkerSet();
|
||||
points->markerIndex = SoMarkerSet::DIAMOND_FILLED_9_9;
|
||||
points->numPoints = 0;
|
||||
pShapeSep->addChild(points);
|
||||
}
|
||||
|
||||
ViewProviderDatumPoint::~ViewProviderDatumPoint()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ViewProviderDatumPoint::updateData(const App::Property* prop)
|
||||
{
|
||||
// Gets called whenever a property of the attached object changes
|
||||
PartDesign::Point* pcDatum = static_cast<PartDesign::Point*>(this->getObject());
|
||||
|
||||
if (strcmp(prop->getName(),"_Point") == 0) {
|
||||
Base::Vector3d p = pcDatum->_Point.getValue();
|
||||
SoMFVec3f v;
|
||||
v.setNum(1);
|
||||
v.set1Value(0, p.x, p.y, p.z);
|
||||
SoMarkerSet* points = static_cast<SoMarkerSet*>(pShapeSep->getChild(0));
|
||||
|
||||
SoVertexProperty* vprop;
|
||||
if (points->vertexProperty.getValue() == NULL) {
|
||||
vprop = new SoVertexProperty();
|
||||
vprop->vertex = v;
|
||||
points->vertexProperty = vprop;
|
||||
} else {
|
||||
vprop = static_cast<SoVertexProperty*>(points->vertexProperty.getValue());
|
||||
vprop->vertex = v;
|
||||
}
|
||||
|
||||
points->numPoints = 1;
|
||||
}
|
||||
|
||||
ViewProviderDatum::updateData(prop);
|
||||
}
|
||||
Reference in New Issue
Block a user