#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
+#include <HYDROData_Bathymetry.h>
#include <HYDROData_Document.h>
#include <HYDROData_Image.h>
#include <HYDROData_Iterator.h>
#include <HYDROData_Polyline.h>
#include <HYDROData_VisualState.h>
-#include <HYDROData_Bathymetry.h>
#include <CAM_Application.h>
#include <CAM_DataObject.h>
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" );
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() )
{
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;
}
}
}
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,
* \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
#include <TDF_Tool.hxx>
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
* 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.
*/
/**
* 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.
protected:
Handle(HYDROData_Object) myData; ///< object from data model
+ QString myParentEntry;
};
/**
SUIT_DataOwnerPtrList anOwners;
aSelectionMgr->selected( anOwners );
+ QStringList aCollectedNameList; // to avoid duplication
foreach( SUIT_DataOwner* aSUITOwner, anOwners )
{
if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( 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;