From 21008733922eb94509532d7728219eb4f4807c49 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 17 Jun 2013 12:51:09 +0000 Subject: [PATCH] 0021684: EDF 2221 : Display the arguments and the name of the operations -class GEOM_SubShapeDriver : public TFunction_Driver { +class GEOM_SubShapeDriver : public GEOM_BaseDriver { + bool GetCreationInformation(std::string& theOperationName, + std::vector& params); --- src/GEOM/GEOM_SubShapeDriver.cxx | 101 +++++++++++++++------------- src/GEOM/GEOM_SubShapeDriver.hxx | 109 ++----------------------------- 2 files changed, 62 insertions(+), 148 deletions(-) diff --git a/src/GEOM/GEOM_SubShapeDriver.cxx b/src/GEOM/GEOM_SubShapeDriver.cxx index af50b2340..20b619239 100644 --- a/src/GEOM/GEOM_SubShapeDriver.cxx +++ b/src/GEOM/GEOM_SubShapeDriver.cxx @@ -20,20 +20,19 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include +#include "GEOM_SubShapeDriver.hxx" -#include -#include -#include -#include +#include "GEOM_ISubShape.hxx" +#include "GEOM_Function.hxx" +#include "GEOM_Object.hxx" #include - #include -#include -#include -#include #include +#include +#include +#include +#include #include @@ -108,44 +107,54 @@ Standard_Integer GEOM_SubShapeDriver::Execute(TFunction_Logbook& log) const return 1; } -//======================================================================= -//function : GEOM_SubShapeDriver_Type_ -//purpose : -//======================================================================= -Standard_EXPORT Handle_Standard_Type& GEOM_SubShapeDriver_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); - if (aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); - static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); - if (aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); - static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); - if (aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; - static Handle_Standard_Type _aType = new Standard_Type("GEOM_SubShapeDriver", - sizeof(GEOM_SubShapeDriver), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - -//======================================================================= -//function : DownCast -//purpose : -//======================================================================= -const Handle(GEOM_SubShapeDriver) Handle(GEOM_SubShapeDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +bool GEOM_SubShapeDriver:: +GetCreationInformation(std::string& theOperationName, + std::vector& theParams) { - Handle(GEOM_SubShapeDriver) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(GEOM_SubShapeDriver))) { - _anOtherObject = Handle(GEOM_SubShapeDriver)((Handle(GEOM_SubShapeDriver)&)AnObject); - } + if (Label().IsNull()) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); + GEOM_ISubShape aCI( function ); + + enum { GEOM_SUBSHAPE = 28, GEOM_GROUP = 37 }; + + TDF_Label aLabel = function->GetOwnerEntry(); + if (aLabel.IsRoot()) return false; + Handle(GEOM_Object) obj = GEOM_Object::GetObject( aLabel ); + if ( obj.IsNull() ) return false; + + switch ( obj->GetType() ) { + case GEOM_SUBSHAPE: + theOperationName = "EXPLODE"; + AddParam( theParams, "Main Object", aCI.GetMainShape() ); + AddParam( theParams, "Index", aCI.GetIndices() ); + break; + case GEOM_GROUP: + { + theOperationName = "GROUP_CREATE"; + TopAbs_ShapeEnum type = TopAbs_SHAPE; + { + TDF_Label aFreeLabel = obj->GetFreeLabel(); + Handle(TDataStd_Integer) anAttrib; + if(aFreeLabel.FindAttribute(TDataStd_Integer::GetID(), anAttrib)) + type = (TopAbs_ShapeEnum) anAttrib->Get(); + } + AddParam( theParams, "Shape Type", type ); + AddParam( theParams, "Main Shape", aCI.GetMainShape() ); + AddParam( theParams, "Indices", aCI.GetIndices() ); + break; } - - return _anOtherObject; + default: + return false; + } + + return true; } +IMPLEMENT_STANDARD_HANDLE (GEOM_SubShapeDriver,GEOM_BaseDriver); + +IMPLEMENT_STANDARD_RTTIEXT (GEOM_SubShapeDriver,GEOM_BaseDriver); diff --git a/src/GEOM/GEOM_SubShapeDriver.hxx b/src/GEOM/GEOM_SubShapeDriver.hxx index 850b5c2d8..108d9ad02 100644 --- a/src/GEOM/GEOM_SubShapeDriver.hxx +++ b/src/GEOM/GEOM_SubShapeDriver.hxx @@ -26,119 +26,25 @@ #ifndef _GEOM_SubShapeDriver_HeaderFile #define _GEOM_SubShapeDriver_HeaderFile -#ifndef _TColStd_SequenceOfExtendedString_HeaderFile -#include -#endif -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif #ifndef _Standard_GUID_HeaderFile #include #endif -#ifndef _Handle_TFunction_Driver_HeaderFile -#include -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(TFunction_Driver); -class GEOM_SubShapeDriver; - -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_SubShapeDriver); - -class Handle(GEOM_SubShapeDriver) : public Handle(TFunction_Driver) { - public: - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - - Handle(GEOM_SubShapeDriver)():Handle(TFunction_Driver)() {} - Handle(GEOM_SubShapeDriver)(const Handle(GEOM_SubShapeDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) - { - } - - Handle(GEOM_SubShapeDriver)(const GEOM_SubShapeDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) - { - } - - Handle(GEOM_SubShapeDriver)& operator=(const Handle(GEOM_SubShapeDriver)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(GEOM_SubShapeDriver)& operator=(const GEOM_SubShapeDriver* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - GEOM_SubShapeDriver* operator->() - { - return (GEOM_SubShapeDriver *)ControlAccess(); - } - - GEOM_SubShapeDriver* operator->() const - { - return (GEOM_SubShapeDriver *)ControlAccess(); - } - - Standard_EXPORT ~Handle(GEOM_SubShapeDriver)() {}; - - Standard_EXPORT static const Handle(GEOM_SubShapeDriver) DownCast(const Handle(Standard_Transient)& AnObject); -}; - #ifndef _TFunction_Driver_HeaderFile #include #endif #ifndef _TFunction_Logbook_HeaderFile #include #endif -#ifndef _Standard_CString_HeaderFile -#include -#endif -class TColStd_SequenceOfExtendedString; +#include "GEOM_BaseDriver.hxx" +DEFINE_STANDARD_HANDLE( GEOM_SubShapeDriver, GEOM_BaseDriver ); -class GEOM_SubShapeDriver : public TFunction_Driver { +class GEOM_SubShapeDriver : public GEOM_BaseDriver { public: - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC // Standard_EXPORT GEOM_SubShapeDriver(); @@ -149,12 +55,11 @@ Standard_EXPORT static const Standard_GUID& GetID(); Standard_EXPORT ~GEOM_SubShapeDriver() {}; - // Type management - // -Standard_EXPORT friend Handle_Standard_Type& GEOM_SubShapeDriver_Type_(); -Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOM_SubShapeDriver) ; } -Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOM_SubShapeDriver) == AType || TFunction_Driver::IsKind(AType)); } + Standard_EXPORT virtual + bool GetCreationInformation(std::string& theOperationName, + std::vector& params); +DEFINE_STANDARD_RTTI( GEOM_SubShapeDriver ) }; -- 2.30.2