mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
The visual links between functions are recovered. The demo is synchronized with a corresponding demo from Qt (qt486-vc10-32\examples\graphicsview\elasticnodes). It may be successfully compiled by any further versions of Qt including 5.10.1 Also, because Open CASCADE (and OCAF in particular) is improved for usage in multi-threading mode, usage of mutexes is added in this sample (for access to the sharing TNaming_UsedShapes attribute, for example).
61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
// PointDriver.cpp: implementation of the PointDriver class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "PointDriver.h"
|
|
|
|
#include <Standard_GUID.hxx>
|
|
#include <TDF_Reference.hxx>
|
|
#include <TNaming_Builder.hxx>
|
|
#include <TDataStd_RealArray.hxx>
|
|
|
|
#include <gp_Pnt.hxx>
|
|
#include <TopoDS_Vertex.hxx>
|
|
#include <BRepBuilderAPI_MakeVertex.hxx>
|
|
|
|
IMPLEMENT_STANDARD_HANDLE(PointDriver,BaseDriver)
|
|
IMPLEMENT_STANDARD_RTTIEXT(PointDriver,BaseDriver)
|
|
|
|
// ID of the function driver
|
|
const Standard_GUID& PointDriver::GetID()
|
|
{
|
|
static const Standard_GUID id("E9467D43-B11D-42d3-AF10-E91B74D2A3D9");
|
|
return id;
|
|
}
|
|
|
|
// Constructor
|
|
PointDriver::PointDriver()
|
|
{
|
|
|
|
}
|
|
|
|
// Execution.
|
|
Standard_Integer PointDriver::Execute(Handle(TFunction_Logbook)& log) const
|
|
{
|
|
// Usual check...
|
|
if (Label().IsNull())
|
|
return 1;
|
|
|
|
// Take the arguments (x, y, z)
|
|
Handle(TDataStd_RealArray) arr;
|
|
if (!Label().FindAttribute(TDataStd_RealArray::GetID(), arr))
|
|
return 2;
|
|
double x = arr->Value(1);
|
|
double y = arr->Value(2);
|
|
double z = arr->Value(3);
|
|
|
|
// Make the result
|
|
TopoDS_Vertex V = BRepBuilderAPI_MakeVertex(gp_Pnt(x, y, z));
|
|
|
|
if (myMutex)
|
|
myMutex->Lock();
|
|
|
|
// Set the result
|
|
TNaming_Builder B(Label());
|
|
B.Generated(V);
|
|
|
|
if (myMutex)
|
|
myMutex->Unlock();
|
|
|
|
return BaseDriver::Execute(log);
|
|
} |