Loading files
// Created on: 2004-11-23
// Created by: Pavel TELKOV
// Copyright (c) 2004-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// The original implementation Copyright: (C) RINA S.p.A
#include <TObj_TObject.hxx>
#include <Standard_GUID.hxx>
#include <TDF_AttributeDelta.hxx>
#include <TDF_ChildIterator.hxx>
IMPLEMENT_STANDARD_RTTIEXT(TObj_TObject, TDF_Attribute)
//=================================================================================================
TObj_TObject::TObj_TObject() = default;
//=================================================================================================
const Standard_GUID& TObj_TObject::GetID()
{
static Standard_GUID GInterfaceID("bbdab6a7-dca9-11d4-ba37-0060b0ee18ea");
return GInterfaceID;
}
//=================================================================================================
const Standard_GUID& TObj_TObject::ID() const
{
return GetID();
}
//=================================================================================================
void TObj_TObject::Set(const occ::handle<TObj_Object>& theElem)
{
Backup();
myElem = theElem;
}
//=================================================================================================
occ::handle<TObj_TObject> TObj_TObject::Set(const TDF_Label& theLabel,
const occ::handle<TObj_Object>& theElem)
{
occ::handle<TObj_TObject> A;
if (!theLabel.FindAttribute(TObj_TObject::GetID(), A))
{
A = new TObj_TObject;
theLabel.AddAttribute(A);
}
A->Set(theElem);
return A;
}
//=================================================================================================
occ::handle<TObj_Object> TObj_TObject::Get() const
{
return myElem;
}
//=================================================================================================
occ::handle<TDF_Attribute> TObj_TObject::NewEmpty() const
{
return new TObj_TObject();
}
//=================================================================================================
void TObj_TObject::Restore(const occ::handle<TDF_Attribute>& theWith)
{
occ::handle<TObj_TObject> R = occ::down_cast<TObj_TObject>(theWith);
myElem = R->Get();
}
//=================================================================================================
void TObj_TObject::Paste(const occ::handle<TDF_Attribute>& theInto,
const occ::handle<TDF_RelocationTable>& /* RT */) const
{
occ::handle<TObj_TObject> R = occ::down_cast<TObj_TObject>(theInto);
R->Set(myElem);
}
//=======================================================================
// function : BeforeForget
// purpose : Tell TObj_Object to die,
// i.e. (myElem->IsAlive() == false) after that
//=======================================================================
void TObj_TObject::BeforeForget()
{
if (!myElem.IsNull())
{
// attempt to delete all data from sublabels of object to remove dependences
TDF_Label aObjLabel = myElem->myLabel;
if (!aObjLabel.IsNull())
{
TDF_ChildIterator aLI(aObjLabel);
TDF_Label aSubLabel;
for (; aLI.More(); aLI.Next())
{
aSubLabel = aLI.Value();
if (!aSubLabel.IsNull())
{
aSubLabel.ForgetAllAttributes(true);
}
}
}
// remove back references before document die
myElem->RemoveBackReferences(TObj_Forced);
TDF_Label aNullLabel;
myElem->myLabel = aNullLabel;
}
}
//=======================================================================
// function : AfterUndo
// purpose : Tell TObj_Object to rise from the dead,
// i.e. (myElem->IsAlive() == true) after that
//=======================================================================
bool TObj_TObject::AfterUndo(const occ::handle<TDF_AttributeDelta>& anAttDelta,
const bool /*forceIt*/)
{
if (!myElem.IsNull())
{
TDF_Label aLabel = anAttDelta->Label();
occ::handle<TDF_Attribute> anAttr;
occ::handle<TObj_TObject> aTObject;
occ::handle<TDF_Attribute> me;
me = this;
if (!aLabel.IsNull() && aLabel.FindAttribute(GetID(), anAttr))
{
aTObject = occ::down_cast<TObj_TObject>(anAttr);
}
if (!aTObject.IsNull() && aTObject->Get() == myElem)
{
myElem->myLabel = aLabel;
}
else
{
TDF_Label aNullLabel;
myElem->myLabel = aNullLabel;
}
}
return true;
}
3d097a032This file is pinned to the selected release. Download the original to open it in your design tool.