#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
+#include <cstdlib>
+
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
#define HISTORY_LABEL 4
#define SUBSHAPES_LABEL 5 // 0020756: GetGroups
#define NAMING_LABEL 6 // 0020750: Naming during STEP import
+#define CALLBACK_LABEL 1 // TDataStd_Comment
#ifdef KEEP_ORIENTATION_0021251
#define ORIENTATION_LABEL 7 // 0021251: TNaming_NamedShape doesn't store orientation
*/
//=============================================================================
GEOM_Function::GEOM_Function(const TDF_Label& theEntry, const Standard_GUID& theGUID, int theType)
-: _label(theEntry)
+ : _label(theEntry), _isCallBackData(false)
{
TFunction_Function::Set(theEntry, theGUID);
TDataStd_Integer::Set(theEntry, theType);
aRoot->Append(aNode);
}
+//================================================================================
+/*!
+ * \brief
+ *
+ *
+ */
+//================================================================================
+
+GEOM_Function::~GEOM_Function()
+{
+ if ( _isCallBackData ) {
+ _label.FindChild( CALLBACK_LABEL ).ForgetAttribute( TDataStd_Comment::GetID() );
+ }
+}
+
//================================================================================
/*!
* \brief Retuns true if this function is the last one in the study
return _label.FindChild(NAMING_LABEL, create);
}
+//================================================================================
+/*!
+ * Save a pointer to a data holder intended to pass temporary data Driver -> Operation.
+ * This method should be called by Operation to set the data holder.
+ * An instance of GEOM_Function that sets the data holder will remove the
+ * corresponding OCAF attribute at it's destruction
+ */
+//================================================================================
+
+void GEOM_Function::SetCallBackData( void* data )
+{
+ std::ostringstream strm;
+ strm << (long long) data;
+ TCollection_ExtendedString string( strm.str().c_str() );
+
+ TDF_Label aChild = _label.FindChild(CALLBACK_LABEL);
+ TDataStd_Comment::Set(aChild, string);
+
+ _isCallBackData = true; // I will remove TDataStd_Comment at destruction
+}
+
+//================================================================================
+/*!
+ * Returns a pointer to a data holder intended to pass data Driver -> Operation.
+ * This method should be called by Driver to get the data holder to fill it in.
+ * Returns NULL if the Operation have not set the data holder.
+ */
+//================================================================================
+
+void* GEOM_Function::GetCallBackData()
+{
+ Handle(TDataStd_Comment) aComment;
+ TDF_Label aChild = _label.FindChild( CALLBACK_LABEL );
+ if(!aChild.FindAttribute(TDataStd_Comment::GetID(), aComment)) return NULL;
+ TCollection_AsciiString string( aComment->Get() );
+
+ long long address = atoll( string.ToCString() );
+ return reinterpret_cast<void*> ( address );
+}
+
IMPLEMENT_STANDARD_HANDLE (GEOM_Function, Standard_Transient);
IMPLEMENT_STANDARD_RTTIEXT(GEOM_Function, Standard_Transient );