1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-26 10:19:45 +03:00
occt/samples/qt/FuncDemo/src/ShapeSaverDriver.cpp
vro 894133a5ad 0029750: Samples - function arrows are not updated by moving a node in FuncDemo qt sample
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).
2020-12-25 17:08:25 +03:00

69 lines
1.6 KiB
C++

// ShapeSaverDriver.cpp: implementation of the ShapeSaverDriver class.
//
//////////////////////////////////////////////////////////////////////
#include "ShapeSaverDriver.h"
#include <Standard_GUID.hxx>
#include <TopoDS_Compound.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_Reference.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
IMPLEMENT_STANDARD_HANDLE(ShapeSaverDriver,BaseDriver)
IMPLEMENT_STANDARD_RTTIEXT(ShapeSaverDriver,BaseDriver)
// ID of the function driver
const Standard_GUID& ShapeSaverDriver::GetID()
{
static const Standard_GUID id("6B77A40E-E074-4fe1-AB9B-ECECA506717A");
return id;
}
// Constructor
ShapeSaverDriver::ShapeSaverDriver()
{
}
// Execution.
Standard_Integer ShapeSaverDriver::Execute(Handle(TFunction_Logbook)& log) const
{
// Usual check...
if (Label().IsNull())
return 1;
// A compound of results of all functions
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound(C);
// Take results of all functions
TDF_ChildIterator itr(Label().FindChild(1), false);
for (; itr.More(); itr.Next())
{
Handle(TDF_Reference) ref;
if (itr.Value().FindAttribute(TDF_Reference::GetID(), ref))
{
Handle(TNaming_NamedShape) n;
if (ref->Get().FindAttribute(TNaming_NamedShape::GetID(), n) && !n->IsEmpty())
{
B.Add(C, n->Get());
}
}
}
if (myMutex)
myMutex->Lock();
TNaming_Builder Bui(Label());
Bui.Generated(C);
if (myMutex)
myMutex->Unlock();
return BaseDriver::Execute(log);
}