From: stv Date: Fri, 15 May 2015 10:13:50 +0000 (+0300) Subject: refs #531: Show/Hide eye in HYDRO X-Git-Tag: v1.4.1~21^2~3^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=11a04ed9cc6369f95bc23df31fff226decd69d10;p=modules%2Fhydro.git refs #531: Show/Hide eye in HYDRO --- diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 159851ab..64e287db 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -288,6 +288,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN ); for( ; anIterator.More(); anIterator.Next() ) { + LightApp_DataObject* obj = 0; Handle(HYDROData_Entity) anObj = anIterator.Current(); if ( !anObj.IsNull() ) @@ -298,7 +299,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast( anObj ); if( !anImageObj.IsNull() ) { - createObject( anImageRootObj, anImageObj ); + obj = createObject( anImageRootObj, anImageObj ); } break; @@ -308,7 +309,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Bathymetry) aBathymetryObj = Handle(HYDROData_Bathymetry)::DownCast( anObj ); if( !aBathymetryObj.IsNull() ) { - createObject( aBathymetryRootObj, aBathymetryObj ); + obj = createObject( aBathymetryRootObj, aBathymetryObj ); } break; @@ -318,7 +319,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Channel) aChannelObj = Handle(HYDROData_Channel)::DownCast( anObj ); if( !aChannelObj.IsNull() ) { - createObject( anArtificialObjectsRootObj, aChannelObj ); + obj = createObject( anArtificialObjectsRootObj, aChannelObj ); } break; @@ -328,7 +329,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Digue) aDigueObj = Handle(HYDROData_Digue)::DownCast( anObj ); if( !aDigueObj.IsNull() ) { - createObject( anArtificialObjectsRootObj, aDigueObj ); + obj = createObject( anArtificialObjectsRootObj, aDigueObj ); } break; @@ -338,7 +339,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_ImmersibleZone) anImmersibleZoneObj = Handle(HYDROData_ImmersibleZone)::DownCast( anObj ); if( !anImmersibleZoneObj.IsNull() ) { - createObject( aNaturalObjectsRootObj, anImmersibleZoneObj ); + obj = createObject( aNaturalObjectsRootObj, anImmersibleZoneObj ); } break; @@ -348,7 +349,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_River) aRiverObj = Handle(HYDROData_River)::DownCast( anObj ); if( !aRiverObj.IsNull() ) { - createObject( aNaturalObjectsRootObj, aRiverObj ); + obj = createObject( aNaturalObjectsRootObj, aRiverObj ); } break; @@ -358,7 +359,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Stream) aStreamObj = Handle(HYDROData_Stream)::DownCast( anObj ); if( !aStreamObj.IsNull() ) { - createObject( aNaturalObjectsRootObj, aStreamObj ); + obj = createObject( aNaturalObjectsRootObj, aStreamObj ); } break; @@ -368,7 +369,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Obstacle) anObstacleObj = Handle(HYDROData_Obstacle)::DownCast( anObj ); if( !anObstacleObj.IsNull() ) { - createObject( anObstaclesRootObj, anObstacleObj ); + obj = createObject( anObstaclesRootObj, anObstacleObj ); } break; @@ -378,7 +379,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_CalculationCase) aCalculObj = Handle(HYDROData_CalculationCase)::DownCast( anObj ); if( !aCalculObj.IsNull() ) { - createObject( aCalculRootObj, aCalculObj ); + obj = createObject( aCalculRootObj, aCalculObj ); } break; @@ -388,7 +389,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_PolylineXY) aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anObj ); if( !aPolylineObj.IsNull() ) { - createObject( aPolylineRootObj, aPolylineObj ); + obj = createObject( aPolylineRootObj, aPolylineObj ); } break; @@ -398,7 +399,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Polyline3D) aPolylineObj = Handle(HYDROData_Polyline3D)::DownCast( anObj ); if( !aPolylineObj.IsNull() ) { - createObject( aPolyline3DRootObj, aPolylineObj ); + obj = createObject( aPolyline3DRootObj, aPolylineObj ); } break; @@ -408,7 +409,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Profile) aProfileObj = Handle(HYDROData_Profile)::DownCast( anObj ); if( !aProfileObj.IsNull() ) { - createObject( aProfileRootObj, aProfileObj ); + obj = createObject( aProfileRootObj, aProfileObj ); } break; @@ -418,7 +419,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_VisualState) aVisualStateObj = Handle(HYDROData_VisualState)::DownCast( anObj ); if( !aVisualStateObj.IsNull() ) { - createObject( aVisualStateRootObj, aVisualStateObj ); + obj = createObject( aVisualStateRootObj, aVisualStateObj ); } break; @@ -441,12 +442,12 @@ void HYDROGUI_DataModel::update( const int theStudyId ) ::synchronize < suitPtr, suitPtr, HYDROGUI_DataModelSync > ( aNewRootObj, aRoot, aSync ); + SUIT_DataBrowser* ob = anApp->objectBrowser(); - if( !myStates.isEmpty() ) + if ( !myStates.isEmpty() ) { - LightApp_Application* anApp = dynamic_cast( module()->application() ); - anApp->objectBrowser()->updateTree(); - anApp->objectBrowser()->setOpenStates( myStates, ENTRY_COLUMN ); + ob->updateTree(); + ob->setOpenStates( myStates, ENTRY_COLUMN ); myStates.clear(); } } @@ -681,7 +682,36 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* const bool theIsBuildTree ) { HYDROGUI_DataObject* aResObj = new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry ); - + + const ObjectKind aKind = theModelObject->GetKind(); + bool visibility = aKind == KIND_IMAGE || aKind == KIND_POLYLINEXY || aKind == KIND_POLYLINE || + aKind == KIND_SHAPES_GROUP || aKind == KIND_SPLITTED_GROUP || aKind == KIND_ZONE || + aKind == KIND_IMMERSIBLE_ZONE || aKind == KIND_REGION || aKind == KIND_BATHYMETRY || + aKind == KIND_OBSTACLE || aKind == KIND_STREAM || aKind == KIND_CHANNEL || + aKind == KIND_DIGUE || aKind == KIND_DUMMY_3D; + if ( !visibility ) + { + Handle(HYDROData_Profile) aProfObj = Handle(HYDROData_Profile)::DownCast( theModelObject ); + visibility = !aProfObj.IsNull() && aProfObj->IsValid(); + } + + if ( aKind == KIND_REGION ) + { + QString an = aResObj->name(); + int a = 0; + } + + if ( visibility ) + { + SUIT_AbstractModel* treeModel = 0; + LightApp_Application* app = dynamic_cast( module()->application() ); + if ( app ) + treeModel = dynamic_cast( app->objectBrowser()->model() ); + + if ( treeModel ) + treeModel->setVisibilityState( aResObj->text( aResObj->customData( Qtx::IdType ).toInt() ), Qtx::HiddenState, false ); + } + if ( theIsBuildTree ) { buildObjectTree( theParent, aResObj, theParentEntry ); @@ -1108,4 +1138,3 @@ bool HYDROGUI_DataModel::rename( Handle(HYDROData_Entity) theEntity, const QStri } return true; } - diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index a9690cdb..87014307 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -79,10 +79,11 @@ #include #include -#include -#include +#include #include #include +#include +#include #include #include @@ -236,6 +237,10 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) } } +// SUIT_DataBrowser* ob = getApp()->objectBrowser(); +// SUIT_AbstractModel* treeModel = dynamic_cast( ob->model() ); +// treeModel->setAppropriate( SUIT_DataObject::VisibilityId, Qtx::Toggled ); + return aRes; } @@ -943,6 +948,14 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId, ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ]; anObjectState.Visibility = theState; + + HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject ); + + SUIT_AbstractModel* treeModel = dynamic_cast( 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 ); } } @@ -1619,3 +1632,39 @@ HYDROGUI_Operation* HYDROGUI_Module::activeOperation() return anOp; } + +/*! + * \brief Virtual public slot + * + * This method is called after the object inserted into data view to update their visibility state + * This is default implementation + */ +void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn ) +{ + if ( !isActiveModule() ) + return; + + HYDROGUI_DataObject* hydroObject = dynamic_cast( theObject ); + + // change visibility of object + if ( !hydroObject || theColumn != SUIT_DataObject::VisibilityId ) + return; + + SUIT_AbstractModel* treeModel = dynamic_cast( getApp()->objectBrowser()->model() ); + + QString id = theObject->text( theObject->customData( Qtx::IdType ).toInt() ); + Qtx::VisibilityState visState = treeModel->visibilityState( id ); + if ( visState == Qtx::UnpresentableState ) + return; + + visState = visState == Qtx::ShownState ? Qtx::HiddenState : Qtx::ShownState; + treeModel->setVisibilityState( id, visState ); + + bool vis = visState == Qtx::ShownState; + if ( vis == isObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject() ) ) + return; + + setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis ); + + update( UF_OCCViewer | UF_FitAll ); +} diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index 6aa6f6da..4cf3a97b 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -208,6 +208,7 @@ protected: public slots: virtual bool activateModule( SUIT_Study* ); virtual bool deactivateModule( SUIT_Study* ); + virtual void onObjectClicked( SUIT_DataObject*, int ); protected: virtual LightApp_Operation* createOperation( const int ) const;