From bb4ef137e6cc9e3312ab56b66c7c6c4bf42ef6ff Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 18 Jul 2007 08:26:17 +0000 Subject: [PATCH] To improve popup resolution management for partions --- src/VISUGUI/VisuGUI.cxx | 22 +++++++-- src/VISUGUI/VisuGUI_PopupTools.cxx | 77 ++++++++++++++++++++++++++++-- src/VISUGUI/VisuGUI_PopupTools.h | 9 +++- 3 files changed, 99 insertions(+), 9 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 9e75a7f6..aa9c23eb 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -2655,11 +2655,23 @@ VisuGUI //aRule = "client='ObjectBrowser' and type='MEDFIELD'"; //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true ); - aRule = "client='ObjectBrowser' and $type in {'VISU::TPART'} and selcount>=1"; - mgr->setRule( action( VISU_MULTIPR_FULL_RES ), aRule, true ); - mgr->setRule( action( VISU_MULTIPR_MED_RES ), aRule, true ); - mgr->setRule( action( VISU_MULTIPR_LOW_RES ), aRule, true ); - mgr->setRule( action( VISU_MULTIPR_HIDE), aRule, true ); + aRule = "client='ObjectBrowser' and $type in {'VISU::TPART'} and "; + { + QString aCustomRule = aRule + "fullResolution=1 and (selcount>1 or (selcount=1 and resolutionState!='F'))"; + mgr->setRule( action( VISU_MULTIPR_FULL_RES ), aCustomRule, true ); + } + { + QString aCustomRule = aRule + "mediumResolution=1 and (selcount>1 or (selcount=1 and resolutionState!='M'))"; + mgr->setRule( action( VISU_MULTIPR_MED_RES ), aCustomRule, true ); + } + { + QString aCustomRule = aRule + "lowResolution=1 and (selcount>1 or (selcount=1 and resolutionState!='L'))"; + mgr->setRule( action( VISU_MULTIPR_LOW_RES ), aCustomRule, true ); + } + { + QString aCustomRule = aRule + "(selcount>1 or (selcount=1 and resolutionState!='H'))"; + mgr->setRule( action( VISU_MULTIPR_HIDE), aCustomRule, true ); + } } //*************************************************************************** diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index c46f165d..84a63267 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -53,7 +53,6 @@ QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const if ( !val.isValid() ) { if ( p == "type" ) val = QtxValue( type( ind ) ); else if ( p == "nbComponents" ) val = QtxValue( nbComponents( ind ) ); - else if ( p == "resolution" ) val = QtxValue( resolution( ind ) ); else if ( p == "medEntity" ) val = QtxValue( medEntity( ind ) ); else if ( p == "medSource" ) val = QtxValue( medSource( ind ) ); else if ( p == "representation" ) val = QtxValue( representation( ind ) ); @@ -66,6 +65,11 @@ QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const else if ( p == "isShading" ) val = QtxValue( isShading( ind ) ); else if ( p == "isScalarMapAct" ) val = QtxValue( isScalarMapAct( ind ) ); else if ( p == "isVisuComponent") val = QtxValue( isVisuComponent( ind ) ); + + else if ( p == "fullResolution" ) val = QtxValue( fullResolution( ind ) ); + else if ( p == "mediumResolution" ) val = QtxValue( mediumResolution( ind ) ); + else if ( p == "lowResolution" ) val = QtxValue( lowResolution( ind ) ); + else if ( p == "resolutionState" ) val = QtxValue( resolutionState( ind ) ); } return val; @@ -160,7 +164,7 @@ QString VisuGUI_Selection::nbComponents( const int ind ) const //--------------------------------------------------------------- -QString VisuGUI_Selection::resolution( const int ind ) const +QString VisuGUI_Selection::resolutions( const int ind ) const { QString aResStr; SalomeApp_Study* aStudy = GetStudy(); @@ -171,7 +175,7 @@ QString VisuGUI_Selection::resolution( const int ind ) const VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); bool isExist; - QString aVal = VISU::Storable::FindValue(aMap,"myState",&isExist); + QString aVal = VISU::Storable::FindValue(aMap,"myResolutions",&isExist); if ( isExist ) aResStr = aVal; @@ -179,6 +183,73 @@ QString VisuGUI_Selection::resolution( const int ind ) const } +//--------------------------------------------------------------- +QString VisuGUI_Selection::resolution( const int ind, char theResoltuion ) const +{ + QString aResStr; + + QString aResolutions = resolutions( ind ); + if(aResolutions.isEmpty()) + return aResStr; + + if(aResolutions.find(theResoltuion) != -1) + aResStr = "1"; + else + aResStr = "0"; + + return aResStr; +} + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::fullResolution( const int ind ) const +{ + return resolution( ind, 'F'); +} + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::mediumResolution( const int ind ) const +{ + return resolution( ind, 'M'); +} + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::lowResolution( const int ind ) const +{ + return resolution( ind, 'L'); +} + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::resolutionState( const int ind ) const +{ + QString aResStr; + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind )); + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + + bool isExist; + QString aVal = VISU::Storable::FindValue(aMap,"myState",&isExist); + if ( isExist ) { + if ( aVal.toInt() == VISU::Result::FULL ) + aResStr = "F"; + if ( aVal.toInt() == VISU::Result::MEDIUM ) + aResStr = "M"; + if ( aVal.toInt() == VISU::Result::LOW ) + aResStr = "L"; + if ( aVal.toInt() == VISU::Result::HIDDEN ) + aResStr = "H"; + } + + return aResStr; +} + + //--------------------------------------------------------------- QString VisuGUI_Selection::medEntity( const int ind ) const { diff --git a/src/VISUGUI/VisuGUI_PopupTools.h b/src/VISUGUI/VisuGUI_PopupTools.h index aef18963..61a59250 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.h +++ b/src/VISUGUI/VisuGUI_PopupTools.h @@ -48,7 +48,6 @@ public: private: QString type( const int ) const; QString nbComponents( const int ) const; - QString resolution( const int ) const; QString medEntity( const int ) const; QString medSource( const int ) const; QString nbTimeStamps( const int ) const; @@ -62,10 +61,18 @@ private: QString isScalarMapAct( const int ) const; bool isVisuComponent( const int ) const; + QString fullResolution( const int ) const; + QString mediumResolution( const int ) const; + QString lowResolution( const int ) const; + QString resolutionState( const int ) const; + private: int nbChild( const int, const bool ) const; SalomeApp_Study* GetStudy() const; + QString resolutions( const int ) const; + QString resolution( const int, char theResoltuion ) const; + private: SalomeApp_Module* myModule; }; -- 2.39.2