From: ouv Date: Mon, 2 Sep 2013 12:21:39 +0000 (+0000) Subject: Publishing the reference objects. X-Git-Tag: BR_hydro_v_0_1~79 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=527e097b1c23d10890ba04d9d7c4be86ac4abb96;p=modules%2Fhydro.git Publishing the reference objects. --- diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 1c8368ff..798cf88e 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -26,12 +26,12 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" +#include #include #include #include #include #include -#include #include #include @@ -194,7 +194,17 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast( anIterator.Current() ); if( !anImageObj.IsNull() ) - createObject( anImageRootObj, anImageObj ); + { + if( LightApp_DataObject* anImageDataObj = createObject( anImageRootObj, anImageObj ) ) + { + for( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ ) + { + Handle(HYDROData_Image) aRefImageObj = anImageObj->Reference( anIndex ); + if( !aRefImageObj.IsNull() && !aRefImageObj->IsRemoved() ) + createObject( anImageDataObj, aRefImageObj, anImageDataObj->entry() ); + } + } + } } LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, "BATHYMETRIES" ); @@ -279,6 +289,10 @@ void HYDROGUI_DataModel::updateModel() Handle(HYDROData_Object) HYDROGUI_DataModel::objectByEntry( const QString& theEntry, const ObjectKind theObjectKind ) { + QString anEntry = theEntry; + if( anEntry.indexOf( "_" ) != -1 ) // reference object + anEntry = anEntry.section( "_", -1 ); + Handle(HYDROData_Document) aDocument = getDocument(); if( !aDocument.IsNull() ) { @@ -288,8 +302,8 @@ Handle(HYDROData_Object) HYDROGUI_DataModel::objectByEntry( const QString& theEn Handle(HYDROData_Object) anObject = anIterator.Current(); if( !anObject.IsNull() ) { - QString anEntry = HYDROGUI_DataObject::dataObjectEntry( anObject ); - if( anEntry == theEntry ) + QString anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject ); + if( anEntryRef == anEntry ) return anObject; } } @@ -366,9 +380,10 @@ Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const } LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent, - Handle(HYDROData_Object) theModelObject ) + Handle(HYDROData_Object) theModelObject, + const QString& theParentEntry ) { - return new HYDROGUI_DataObject( theParent, theModelObject ); + return new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry ); } LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent, diff --git a/src/HYDROGUI/HYDROGUI_DataModel.h b/src/HYDROGUI/HYDROGUI_DataModel.h index eb6f374f..a0e59764 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.h +++ b/src/HYDROGUI/HYDROGUI_DataModel.h @@ -194,7 +194,8 @@ protected: * \param theObject model object */ LightApp_DataObject* createObject( SUIT_DataObject* theParent, - Handle(HYDROData_Object) theModelObject ); + Handle(HYDROData_Object) theModelObject, + const QString& theParentEntry = QString() ); /** * Creates the GUI data object without corresponding model object: just by name diff --git a/src/HYDROGUI/HYDROGUI_DataObject.cxx b/src/HYDROGUI/HYDROGUI_DataObject.cxx index fd4638a9..c760d195 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.cxx +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@ -27,16 +27,28 @@ #include HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent, - Handle(HYDROData_Object) theData ) + Handle(HYDROData_Object) theData, + const QString& theParentEntry ) : CAM_DataObject( theParent ), LightApp_DataObject( theParent ), - myData( theData ) + myData( theData ), + myParentEntry( theParentEntry ) { } QString HYDROGUI_DataObject::entry() const { - return HYDROGUI_DataObject::dataObjectEntry( modelObject() ); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( modelObject() ); + if( isReference() ) + anEntry.prepend( myParentEntry + "_" ); + return anEntry; +} + +QString HYDROGUI_DataObject::refEntry() const +{ + if( !myParentEntry.isEmpty() ) + return HYDROGUI_DataObject::dataObjectEntry( modelObject() ); + return QString(); } QString HYDROGUI_DataObject::name() const diff --git a/src/HYDROGUI/HYDROGUI_DataObject.h b/src/HYDROGUI/HYDROGUI_DataObject.h index cad33c21..33b53a36 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.h +++ b/src/HYDROGUI/HYDROGUI_DataObject.h @@ -47,15 +47,22 @@ public: * Constructor. * \param theParent parent data object * \param theData reference to the corresponding object from data structure + * \param theParentEntry entry of the parent data object (for reference objects) */ HYDROGUI_DataObject( SUIT_DataObject* theParent, - Handle(HYDROData_Object) theData ); + Handle(HYDROData_Object) theData, + const QString& theParentEntry ); /** * Returns the unique object identifier string. */ virtual QString entry() const; + /** + * Returns the entry of the referenced object. + */ + virtual QString refEntry() const; + /** * Returns the name of object. */ @@ -74,7 +81,7 @@ public: /** * Returns the entry prefix for all HYDRO data objects. */ - static QString entryPrefix() { return QString( "HYDRO_" ); } + static QString entryPrefix() { return QString( "HYDRO:" ); } /** * Returns the full entry for the specified data object. @@ -83,6 +90,7 @@ public: protected: Handle(HYDROData_Object) myData; ///< object from data model + QString myParentEntry; }; /** diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx index b30f5ec8..5aeadb61 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -236,13 +236,21 @@ HYDROData_SequenceOfObjects HYDROGUI_Tool::GetSelectedObjects( HYDROGUI_Module* SUIT_DataOwnerPtrList anOwners; aSelectionMgr->selected( anOwners ); + QStringList aCollectedNameList; // to avoid duplication foreach( SUIT_DataOwner* aSUITOwner, anOwners ) { if( LightApp_DataOwner* anOwner = dynamic_cast( aSUITOwner ) ) { - Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry(), KIND_UNKNOWN ); + Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() ); if( !anObject.IsNull() ) - aSeq.Append( anObject ); + { + QString aName = anObject->GetName(); + if( !aCollectedNameList.contains( aName ) ) + { + aSeq.Append( anObject ); + aCollectedNameList.append( aName ); + } + } } } return aSeq;