]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Find object by name were moved to the methods of document.
authoradv <adv@opencascade.com>
Fri, 24 Jan 2014 05:28:18 +0000 (05:28 +0000)
committeradv <adv@opencascade.com>
Fri, 24 Jan 2014 05:28:18 +0000 (05:28 +0000)
src/HYDROData/HYDROData_Document.cxx
src/HYDROData/HYDROData_Document.h
src/HYDROData/HYDROData_Tool.cxx
src/HYDROData/HYDROData_Tool.h
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROPy/HYDROData_Document.sip

index c237aa93ce74ee8bd42d403ae2cd96fc8abab4df..c195b9d5d7150f94c93455cd49b826cfed559c20 100644 (file)
@@ -360,9 +360,57 @@ void HYDROData_Document::Redo()
   myTransactionsAfterSave++;
 }
 
-Handle(HYDROData_Entity) HYDROData_Document::CreateObject(const ObjectKind theKind)
+Handle(HYDROData_Entity) HYDROData_Document::CreateObject( const ObjectKind theKind )
 {
-  return HYDROData_Iterator::CreateObject(this, theKind);
+  return HYDROData_Iterator::CreateObject( this, theKind );
+}
+
+Handle(HYDROData_Entity) HYDROData_Document::FindObjectByName( 
+  const QString&   theName,
+  const ObjectKind theObjectKind ) const
+{
+  Handle(HYDROData_Entity) anObject;
+  if ( theName.isEmpty() )
+    return anObject;
+
+  QStringList aNamesList;
+  aNamesList << theName;
+
+  HYDROData_SequenceOfObjects aSeqOfObjs = FindObjectsByNames( aNamesList, theObjectKind );
+  if( aSeqOfObjs.IsEmpty() )
+    return anObject;
+  
+  anObject = aSeqOfObjs.First();
+  return anObject;
+}
+
+HYDROData_SequenceOfObjects HYDROData_Document::FindObjectsByNames(
+  const QStringList& theNames, 
+  const ObjectKind   theObjectKind ) const
+{
+  HYDROData_SequenceOfObjects aResSeq;
+
+  QStringList aNamesList = theNames;
+
+  HYDROData_Iterator anIter( this, theObjectKind );
+  for( ; anIter.More(); anIter.Next() )
+  {
+    Handle(HYDROData_Entity) anObject = anIter.Current();
+    if( anObject.IsNull() )
+      continue;
+
+    QString anObjName = anObject->GetName();
+    if ( anObjName.isEmpty() || !aNamesList.contains( anObjName ) )
+      continue;
+
+    aResSeq.Append( anObject );
+
+    aNamesList.removeAll( anObjName );
+    if ( aNamesList.isEmpty() )
+      break;
+  }
+
+  return aResSeq;
 }
 
 HYDROData_Document::HYDROData_Document()
index 569a588db71fee40bad246eb2213fbc893cf26bc..1de23428a08d4be1d53b5148a2df943491a01bd7 100644 (file)
@@ -45,6 +45,8 @@ public:
   HYDRODATA_EXPORT static Handle(HYDROData_Document) Document( 
     const TDF_Label& theObjectLabel );
 
+public:
+
   //! Returns true if data model contains document for this study
   HYDRODATA_EXPORT static bool HasDocument(const int theStudyID);
 
@@ -52,6 +54,8 @@ public:
   HYDRODATA_EXPORT static bool DocumentId( const Handle(HYDROData_Document)& theDocument,
                                            int&                              theDocId );
 
+public:
+
   //! Loads the OCAF document from the file.
   //! \param theFileName full name of the file to load
   //! \param theStudyID identifier of the SALOME study to associate with loaded file
@@ -66,6 +70,8 @@ public:
   //! Removes document data
   HYDRODATA_EXPORT void Close();
 
+public:
+
   // Returns name of document instance in python dump script
   HYDRODATA_EXPORT QString GetDocPyName() const;
 
@@ -77,6 +83,8 @@ public:
   //! Dump model data to Python script representation.
   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
 
+public:
+
   //! Starts a new operation (opens a tansaction)
   HYDRODATA_EXPORT void StartOperation();
   //! Finishes the previously started operation (closes the transaction)
@@ -89,6 +97,8 @@ public:
   //! Returns true if document was modified (since creation/opening)
   HYDRODATA_EXPORT bool IsModified();
 
+public:
+
   //! Returns True if there are available Undos
   HYDRODATA_EXPORT bool CanUndo();
   //! Returns a list of stored undo actions
@@ -107,11 +117,24 @@ public:
   //! Redoes last operation
   HYDRODATA_EXPORT void Redo();
 
+public:
+
   //! Creates and locates in the document a new object
   //! \param theKind kind of the created object, can not be UNKNOWN
   //! \returns the created object
   HYDRODATA_EXPORT Handle(HYDROData_Entity) CreateObject(const ObjectKind theKind);
 
+
+  //! Find the data object with the specified name.
+  HYDRODATA_EXPORT Handle(HYDROData_Entity) FindObjectByName( 
+    const QString&   theName, 
+    const ObjectKind theObjectKind = KIND_UNKNOWN ) const;
+
+  //! Find the data objects with the specified names.
+  HYDRODATA_EXPORT HYDROData_SequenceOfObjects FindObjectsByNames(
+    const QStringList& theNames, 
+    const ObjectKind   theObjectKind = KIND_UNKNOWN ) const;
+
 protected:
 
   friend class HYDROData_Iterator;
index e5b45109b0f778544d8d0866a31437d952a26530..333205a0e371be975b631e52c75e5e0991e767f0 100644 (file)
@@ -123,56 +123,6 @@ QString HYDROData_Tool::GenerateObjectName( const Handle(HYDROData_Document)& th
   return aName;
 }
 
-Handle(HYDROData_Entity) HYDROData_Tool::FindObjectByName( const Handle(HYDROData_Document)& theDoc,
-                                                           const QString&                    theName,
-                                                           const ObjectKind                  theObjectKind )
-{
-  Handle(HYDROData_Entity) anObject;
-  if ( theName.isEmpty() || theDoc.IsNull() )
-    return anObject;
-
-  QStringList aNamesList;
-  aNamesList << theName;
-
-  HYDROData_SequenceOfObjects aSeqOfObjs = FindObjectsByNames( theDoc, aNamesList, theObjectKind );
-  if( aSeqOfObjs.IsEmpty() )
-    return anObject;
-  
-  anObject = aSeqOfObjs.First();
-  return anObject;
-}
-
-HYDROData_SequenceOfObjects HYDROData_Tool::FindObjectsByNames( const Handle(HYDROData_Document)& theDoc,
-                                                                const QStringList&                theNames,
-                                                                const ObjectKind                  theObjectKind )
-{
-  HYDROData_SequenceOfObjects aResSeq;
-  if( theDoc.IsNull() )
-    return aResSeq;
-
-  QStringList aNamesList = theNames;
-
-  HYDROData_Iterator anIter( theDoc, theObjectKind );
-  for( ; anIter.More(); anIter.Next() )
-  {
-    Handle(HYDROData_Entity) anObject = anIter.Current();
-    if( anObject.IsNull() )
-      continue;
-
-    QString anObjName = anObject->GetName();
-    if ( anObjName.isEmpty() || !aNamesList.contains( anObjName ) )
-      continue;
-
-    aResSeq.Append( anObject );
-
-    aNamesList.removeAll( anObjName );
-    if ( aNamesList.isEmpty() )
-      break;
-  }
-
-  return aResSeq;
-}
-
 bool HYDROData_Tool::IsGeometryObject( const Handle(HYDROData_Entity)& theObject )
 {
   if ( theObject.IsNull() )
index d2260e781100c6601d95b13801a7f0f0a269781b..bb71d8c466912899e249743731237046487b1dc0 100644 (file)
@@ -46,28 +46,6 @@ public:
                                                             const QStringList&                theUsedNames = QStringList(),
                                                             const bool                        theIsTryToUsePurePrefix = false );
 
-  /**
-   * \brief Find the data object with the specified name.
-   * \param theModule module
-   * \param theName name
-   * \param theObjectKind kind of object
-   * \return data object
-   */
-  static Handle(HYDROData_Entity)       FindObjectByName( const Handle(HYDROData_Document)& theDoc,
-                                                          const QString&                    theName,
-                                                          const ObjectKind                  theObjectKind = KIND_UNKNOWN );
-
-  /**
-   * \brief Find the data objects with the specified names.
-   * \param theModule module
-   * \param theNames list of names
-   * \param theObjectKind kind of object
-   * \return list of data objects
-   */
-  static HYDROData_SequenceOfObjects    FindObjectsByNames( const Handle(HYDROData_Document)& theDoc,
-                                                            const QStringList&                theNames,
-                                                            const ObjectKind                  theObjectKind = KIND_UNKNOWN );
-
   /**
    * \brief Checks the type of object.
    * \param theObject object to check
index 48bf198941b2d9b7610f211575bbc5b5376cb81e..5c45c8baa7e4d5deb346ce5dea38db58d3e887bf 100644 (file)
@@ -438,16 +438,26 @@ Handle(HYDROData_Entity) HYDROGUI_Tool::FindObjectByName( HYDROGUI_Module* theMo
                                                           const QString&   theName,
                                                           const ObjectKind theObjectKind )
 {
+  Handle(HYDROData_Entity) aResObj;
+  
   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
-  return HYDROData_Tool::FindObjectByName( aDocument, theName, theObjectKind );
+  if ( !aDocument.IsNull() )
+    aResObj = aDocument->FindObjectByName( theName, theObjectKind );
+  
+  return aResObj;
 }
 
 HYDROData_SequenceOfObjects HYDROGUI_Tool::FindObjectsByNames( HYDROGUI_Module*   theModule,
                                                                const QStringList& theNames,
                                                                const ObjectKind   theObjectKind )
 {
+  HYDROData_SequenceOfObjects aResSeq;
+
   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
-  return HYDROData_Tool::FindObjectsByNames( aDocument, theNames, theObjectKind );
+  if ( !aDocument.IsNull() )
+    aResSeq = aDocument->FindObjectsByNames( theNames, theObjectKind );
+
+  return aResSeq;
 }
 
 QString HYDROGUI_Tool::GenerateObjectName( HYDROGUI_Module*   theModule,
@@ -662,8 +672,7 @@ QColor HYDROGUI_Tool::GenerateFillingColor( const Handle(HYDROData_Document)& th
   {
     const QString& aZoneName = aZoneNameIter.next();
     Handle(HYDROData_ImmersibleZone) aRefZone = 
-      Handle(HYDROData_ImmersibleZone)::DownCast(
-        HYDROData_Tool::FindObjectByName( theDoc, aZoneName, KIND_IMMERSIBLE_ZONE ) );
+      Handle(HYDROData_ImmersibleZone)::DownCast( theDoc->FindObjectByName( aZoneName, KIND_IMMERSIBLE_ZONE ) );
     if( !aRefZone.IsNull() )
     {
       QColor aRefColor = aRefZone->GetFillingColor();
index 5b2e2e19bbee48164bed296a7f38840d6d88f159..6aeddf8904d4232e2341258c9fa69ac951452742 100644 (file)
@@ -275,6 +275,24 @@ public:
     
   %End
 
+  HYDROData_Entity FindObjectByName( const QString&   theName,
+                                     const ObjectKind theKind = KIND_UNKNOWN ) 
+  [Handle_HYDROData_Entity (const QString&, const ObjectKind)] ;
+  %MethodCode
+
+    Handle(HYDROData_Entity) anObject;
+    Py_BEGIN_ALLOW_THREADS
+    anObject =  sipSelfWasArg ? sipCpp->HYDROData_Document::FindObjectByName( *a0, a1 ) :
+                                sipCpp->FindObjectByName( *a0, a1 );
+    Py_END_ALLOW_THREADS
+
+    sipRes = createPointer( anObject );
+    
+  %End
+
+  HYDROData_SequenceOfObjects FindObjectsByNames( const QStringList& theNames,
+                                                  const ObjectKind   theKind = KIND_UNKNOWN );
+
 protected:
 
   //! Creates new document: private because "Document" method must be used instead of direct creation.