+
+ HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
+ if ( hydroObject )
+ {
+ SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
+ QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
+ Qtx::VisibilityState visState = treeModel->visibilityState( id );
+ if ( visState != Qtx::UnpresentableState )
+ treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
+ }
+ }
+}
+
+void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
+ const bool theState )
+{
+ if( !theObject.IsNull() )
+ {
+ // Process OCC shapes
+ ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
+ while( aShapesMapIter != myShapesMap.end() )
+ {
+ const ListOfShapes& aShapesList = aShapesMapIter.value();
+ foreach ( HYDROGUI_Shape* aShape, aShapesList )
+ {
+ if ( aShape && IsEqual( aShape->getObject(), theObject ) )
+ {
+ aShape->setIsToUpdate( theState );
+ }
+ }
+ aShapesMapIter++;
+ }
+ // Process VTK shapes
+ ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
+ while( aVTKPrsMapIter != myVTKPrsMap.end() )
+ {
+ const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
+ foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
+ {
+ if ( aShape && IsEqual( aShape->getObject(), theObject ) )
+ {
+ aShape->setIsToUpdate( theState );
+ }
+ }
+ aVTKPrsMapIter++;
+ }
+ }
+}
+
+/////////////////// OCC SHAPES PROCESSING
+QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int theViewId,
+ ObjectKind theKind ) const
+{
+ QList<HYDROGUI_Shape*> aResult;
+
+ if ( myShapesMap.contains( theViewId ) )
+ {
+ const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
+ foreach ( HYDROGUI_Shape* aShape, aViewShapes )
+ {
+ if( aShape && aShape->getObject()->GetKind()==theKind )
+ aResult.append( aShape );
+ }
+ }
+ return aResult;
+}
+
+HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
+ const Handle(HYDROData_Entity)& theObject ) const
+{
+ HYDROGUI_Shape* aResShape = NULL;
+ if( theObject.IsNull() )
+ return aResShape;
+
+ if ( myShapesMap.contains( theViewId ) )
+ {
+ const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
+ foreach ( HYDROGUI_Shape* aShape, aViewShapes )
+ {
+ if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
+ continue;
+
+ aResShape = aShape;
+ break;
+ }
+ }
+
+ return aResShape;
+}
+
+void HYDROGUI_Module::setObjectShape( const int theViewId,
+ const Handle(HYDROData_Entity)& theObject,
+ HYDROGUI_Shape* theShape )
+{
+ if( theObject.IsNull() )
+ return;
+
+ ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
+ aViewShapes.append( theShape );
+}
+
+void HYDROGUI_Module::removeObjectShape( const int theViewId,
+ const Handle(HYDROData_Entity)& theObject )
+{
+ if ( !myShapesMap.contains( theViewId ) )
+ return;
+
+ ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
+ Handle(HYDROData_Entity) anObject;
+ for ( int i = 0; i < aViewShapes.length(); )
+ {
+ HYDROGUI_Shape* aShape = aViewShapes.at( i );
+ anObject = aShape->getObject();
+ if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
+ {
+ delete aShape;
+ aViewShapes.removeAt( i );
+ continue;
+ }
+
+ ++i;
+ }
+}
+
+void HYDROGUI_Module::removeViewShapes( const int theViewId )
+{
+ if ( !myShapesMap.contains( theViewId ) )
+ return;
+
+ const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
+ for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
+ {
+ HYDROGUI_Shape* aShape = aViewShapes.at( i );
+ if ( aShape )
+ delete aShape;
+ }
+
+ myShapesMap.remove( theViewId );
+}
+/////////////////// END OF OCC SHAPES PROCESSING
+
+/////////////////// VTKPrs PROCESSING
+HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
+ const Handle(HYDROData_Entity)& theObject ) const
+{
+ HYDROGUI_VTKPrs* aResShape = NULL;
+ if( theObject.IsNull() )
+ return aResShape;
+
+ if ( myVTKPrsMap.contains( theViewId ) )
+ {
+ const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
+ foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
+ {
+ if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
+ continue;
+
+ aResShape = aShape;
+ break;
+ }
+ }
+
+ return aResShape;
+}
+
+void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
+ const Handle(HYDROData_Entity)& theObject,
+ HYDROGUI_VTKPrs* theShape )
+{
+ if( theObject.IsNull() )
+ return;
+
+ if( theShape && theShape->needScalarBar() )
+ {
+ // Compute the new global Z range from the added presentation and the old global Z range.
+ double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
+ double* aRange = theShape->getInternalZRange();
+ bool anIsUpdate = false;
+ if ( aRange[0] < aGlobalRange[0] )
+ {
+ aGlobalRange[0] = aRange[0];
+ anIsUpdate = true;
+ }
+ if ( aRange[1] > aGlobalRange[1] )
+ {
+ aGlobalRange[1] = aRange[1];
+ anIsUpdate = true;
+ }
+
+ //if ( anIsUpdate )
+ //{
+ updateVTKZRange( theViewId, aGlobalRange );
+ //}
+ }
+
+ ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
+ aViewShapes.append( theShape );
+}
+
+void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
+ const QString& theEntry )
+{
+ if ( !myVTKPrsMap.contains( theViewId ) )
+ return;
+
+ ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
+ Handle(HYDROData_Entity) anObject;
+ QString anEntryRef;
+ for ( int i = 0; i < aViewShapes.length(); )
+ {
+ HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
+ anObject = aShape->getObject();
+ anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
+ if ( aShape && (!anObject.IsNull()) && ( anEntryRef == theEntry ) )
+ {
+ delete aShape;
+ aViewShapes.removeAt( i );
+ continue;
+ }
+
+ ++i;