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()
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);
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
//! Removes document data
HYDRODATA_EXPORT void Close();
+public:
+
// Returns name of document instance in python dump script
HYDRODATA_EXPORT QString GetDocPyName() const;
//! 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)
//! 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
//! 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;
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() )
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
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,
{
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();
%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.