From f5e7e51223b3bb1f4faa80ef6d55a793d1416ccc Mon Sep 17 00:00:00 2001 From: jfa Date: Fri, 28 Oct 2011 12:08:38 +0000 Subject: [PATCH] Mantis issue 0020136: EDF 933 DEV : Drag&Drop in OB --- idl/SALOMEDS.idl | 9 +++ src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx | 27 +++++++- src/SALOMEDS/SALOMEDS_UseCaseBuilder.hxx | 5 +- src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx | 31 ++++++++- src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx | 7 ++- .../SALOMEDSClient_UseCaseBuilder.hxx | 5 +- .../SALOMEDSImpl_UseCaseBuilder.cxx | 63 +++++++++++++++++-- .../SALOMEDSImpl_UseCaseBuilder.hxx | 4 ++ 8 files changed, 137 insertions(+), 14 deletions(-) diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 12c595b6c..d31929817 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -329,6 +329,7 @@ during each working session. \return An object */ Object ConvertIORToObject(in string theIOR); + /*! \brief Get a new %UseCaseBuilder. */ UseCaseBuilder GetUseCaseBuilder(); @@ -1318,6 +1319,10 @@ Activates the %UseCaseIterator. Returns True if the given object theObject of the use case has child objects. */ boolean HasChildren(in SObject theObject); +/*! + Gets father object of the given object theObject in the use cases tree. +*/ + SObject GetFather(in SObject theObject); /*! Sets the name of the use case. */ @@ -1330,6 +1335,10 @@ Activates the %UseCaseIterator. Returns True if the given object theObject represents a use case. */ boolean IsUseCase(in SObject theObject); +/*! + Returns True if the given object theObject is included in the use cases tree on any level. +*/ + boolean IsUseCaseNode(in SObject theObject); /*! Gets the current object of the use case. */ diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx index 58fb28f46..cab15ad54 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File : SALOMEDS_UseCaseBuilder.cxx // Author : Sergey RUIN // Module : SALOME -// + #include "SALOMEDS_UseCaseBuilder.hxx" #include "SALOMEDS.hxx" @@ -139,6 +138,18 @@ bool SALOMEDS_UseCaseBuilder::HasChildren(const _PTR(SObject)& theObject) return ret; } +_PTR(SObject) SALOMEDS_UseCaseBuilder::GetFather(const _PTR(SObject)& theObject) +{ + SALOMEDS_SObject* father = NULL; + SALOMEDS_SObject* obj = dynamic_cast(theObject.get()); + if (_isLocal) { + SALOMEDS::Locker lock; + father = new SALOMEDS_SObject(_local_impl->GetFather(*(obj->GetLocalImpl()))); + } + else father = new SALOMEDS_SObject(_corba_impl->GetFather(obj->GetCORBAImpl())); + return _PTR(SObject)(father); +} + bool SALOMEDS_UseCaseBuilder::IsUseCase(const _PTR(SObject)& theObject) { bool ret; @@ -151,6 +162,18 @@ bool SALOMEDS_UseCaseBuilder::IsUseCase(const _PTR(SObject)& theObject) return ret; } +bool SALOMEDS_UseCaseBuilder::IsUseCaseNode(const _PTR(SObject)& theObject) +{ + bool ret; + SALOMEDS_SObject* obj = dynamic_cast(theObject.get()); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->IsUseCaseNode(*(obj->GetLocalImpl())); + } + else ret = _corba_impl->IsUseCaseNode(obj->GetCORBAImpl()); + return ret; +} + bool SALOMEDS_UseCaseBuilder::SetName(const std::string& theName) { bool ret; diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder.hxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder.hxx index 0b4db447f..35ce4c101 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder.hxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder.hxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File : SALOMEDS_UseCaseBuilder.hxx // Author : Sergey RUIN // Module : SALOME -// + #ifndef __SALOMEDS_USECaseBuilder_H__ #define __SALOMEDS_USECaseBuilder_H__ @@ -55,7 +54,9 @@ public: virtual bool SetCurrentObject(const _PTR(SObject)& theObject); virtual bool SetRootCurrent(); virtual bool HasChildren(const _PTR(SObject)& theObject); + virtual _PTR(SObject) GetFather(const _PTR(SObject)& theObject); virtual bool IsUseCase(const _PTR(SObject)& theObject); + virtual bool IsUseCaseNode(const _PTR(SObject)& theObject); virtual bool SetName(const std::string& theName); virtual _PTR(SObject) GetCurrentObject(); virtual std::string GetName(); diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx index 1b03a1bd0..513abc034 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File : SALOMEDS_UseCaseBuilder_i.cxx // Author : Sergey RUIN // Module : SALOME -// + #include "SALOMEDS_UseCaseBuilder_i.hxx" #include "SALOMEDS_UseCaseIterator_i.hxx" #include "SALOMEDS_SObject_i.hxx" @@ -141,6 +140,21 @@ CORBA::Boolean SALOMEDS_UseCaseBuilder_i::HasChildren(SALOMEDS::SObject_ptr theO return _impl->HasChildren(_impl->GetSObject(theObject->GetID())); } +//============================================================================ +/*! Function : GetFather + * Purpose : + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::GetFather(SALOMEDS::SObject_ptr theObject) +{ + SALOMEDS::Locker lock; + + if(!_impl) return NULL; + SALOMEDSImpl_SObject aSO = _impl->GetFather(_impl->GetSObject(theObject->GetID())); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); + return so._retn(); +} + //============================================================================ /*! Function : SetName * Purpose : @@ -193,6 +207,19 @@ CORBA::Boolean SALOMEDS_UseCaseBuilder_i::IsUseCase(SALOMEDS::SObject_ptr theObj return _impl->IsUseCase(_impl->GetSObject(theObject->GetID())); } +//============================================================================ +/*! Function : IsUseCaseNode + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_UseCaseBuilder_i::IsUseCaseNode(SALOMEDS::SObject_ptr theObject) +{ + SALOMEDS::Locker lock; + + if(!_impl || theObject->_is_nil()) return false; + return _impl->IsUseCaseNode(_impl->GetSObject(theObject->GetID())); +} + //============================================================================ /*! Function : NewUseCase * Purpose : diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx index c8c29215b..401dd43e6 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File : SALOMEDS_UseCaseBuilder_i.hxx // Author : Sergey RUIN // Module : SALOME -// + #ifndef __SALOMEDS_USECaseBuilder_I_H__ #define __SALOMEDS_USECaseBuilder_I_H__ @@ -73,8 +72,12 @@ public: virtual CORBA::Boolean HasChildren(SALOMEDS::SObject_ptr theObject); + virtual SALOMEDS::SObject_ptr GetFather(SALOMEDS::SObject_ptr theObject); + virtual CORBA::Boolean IsUseCase(SALOMEDS::SObject_ptr theObject); + virtual CORBA::Boolean IsUseCaseNode(SALOMEDS::SObject_ptr theObject); + virtual CORBA::Boolean SetName(const char* theName); virtual SALOMEDS::SObject_ptr GetCurrentObject(); diff --git a/src/SALOMEDSClient/SALOMEDSClient_UseCaseBuilder.hxx b/src/SALOMEDSClient/SALOMEDSClient_UseCaseBuilder.hxx index 4e503e357..22beeafe0 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_UseCaseBuilder.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_UseCaseBuilder.hxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File : SALOMEDSClient_UseCaseBuilder.hxx // Author : Sergey RUIN // Module : SALOME -// + #ifndef __SALOMEDSClient_USECaseBuilder_H__ #define __SALOMEDSClient_USECaseBuilder_H__ @@ -44,7 +43,9 @@ public: virtual bool SetCurrentObject(const _PTR(SObject)& theObject) = 0; virtual bool SetRootCurrent() = 0; virtual bool HasChildren(const _PTR(SObject)& theObject) = 0; + virtual _PTR(SObject) GetFather(const _PTR(SObject)& theObject) = 0; virtual bool IsUseCase(const _PTR(SObject)& theObject) = 0; + virtual bool IsUseCaseNode(const _PTR(SObject)& theObject) = 0; virtual bool SetName(const std::string& theName) = 0; virtual _PTR(SObject) GetCurrentObject() = 0; virtual std::string GetName() = 0; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx index a05d096d0..4278c2077 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File : SALOMEDSImpl_UseCaseBuilder.cxx // Author : Sergey RUIN // Module : SALOME -// + #include "SALOMEDSImpl_UseCaseBuilder.hxx" #include "SALOMEDSImpl_SObject.hxx" #include "SALOMEDSImpl_SComponent.hxx" @@ -99,6 +98,9 @@ bool SALOMEDSImpl_UseCaseBuilder::Append(const SALOMEDSImpl_SObject& theObject) aCurrentNode->Append(aNode); + // Mantis issue 0020136: Drag&Drop in OB + theObject.GetStudy()->addSO_Notification(theObject); + return true; } @@ -169,7 +171,12 @@ bool SALOMEDSImpl_UseCaseBuilder::AppendTo(const SALOMEDSImpl_SObject& theFather aNode->Remove(); - return aFather->Append(aNode); + bool ret = aFather->Append(aNode); + + // Mantis issue 0020136: Drag&Drop in OB + theObject.GetStudy()->addSO_Notification(theObject); + + return ret; } //============================================================================ @@ -200,7 +207,12 @@ bool SALOMEDSImpl_UseCaseBuilder::InsertBefore(const SALOMEDSImpl_SObject& theFi aFirstNode->Remove(); - return aNode->InsertBefore(aFirstNode); + bool ret = aNode->InsertBefore(aFirstNode); + + // Mantis issue 0020136: Drag&Drop in OB + theFirst.GetStudy()->addSO_Notification(theFirst); + + return ret; } @@ -266,6 +278,28 @@ bool SALOMEDSImpl_UseCaseBuilder::HasChildren(const SALOMEDSImpl_SObject& theObj return (aNode->GetFirst()); } +//============================================================================ +/*! Function : GetFather + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_SObject SALOMEDSImpl_UseCaseBuilder::GetFather(const SALOMEDSImpl_SObject& theObject) +{ + SALOMEDSImpl_SObject so; + if (!_root || !theObject) return so; + + DF_Label aLabel = theObject.GetLabel(); + if (aLabel.IsNull()) return so; + + SALOMEDSImpl_AttributeTreeNode* aNode = NULL; + if (!(aNode=(SALOMEDSImpl_AttributeTreeNode*)aLabel.FindAttribute(_root->ID()))) return so; + + SALOMEDSImpl_AttributeTreeNode* aFatherNode = aNode->GetFather(); + if (!aFatherNode) return so; + + return aFatherNode->GetSObject(); +} + //============================================================================ /*! Function : SetName * Purpose : @@ -335,6 +369,27 @@ bool SALOMEDSImpl_UseCaseBuilder::IsUseCase(const SALOMEDSImpl_SObject& theObjec return false; } +//============================================================================ +/*! Function : IsUseCaseNode + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_UseCaseBuilder::IsUseCaseNode(const SALOMEDSImpl_SObject& theObject) +{ + if(!_root) return false; + + DF_Label aLabel; + if (!theObject) aLabel = _root->Label(); + else + aLabel = theObject.GetLabel(); + if(aLabel.IsNull()) return false; + + SALOMEDSImpl_AttributeTreeNode* aNode = NULL; + if(!(aNode=(SALOMEDSImpl_AttributeTreeNode*)aLabel.FindAttribute(_root->ID()))) return false; + + return true; +} + //============================================================================ /*! Function : NewUseCase * Purpose : diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx index 5a34f2cfc..af7b14e4b 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx @@ -65,8 +65,12 @@ public: virtual bool HasChildren(const SALOMEDSImpl_SObject& theObject); + virtual SALOMEDSImpl_SObject GetFather(const SALOMEDSImpl_SObject& theObject); + virtual bool IsUseCase(const SALOMEDSImpl_SObject& theObject); + virtual bool IsUseCaseNode(const SALOMEDSImpl_SObject& theObject); + virtual bool SetName(const std::string& theName); virtual SALOMEDSImpl_SObject GetCurrentObject(); -- 2.39.2