From: rnv Date: Mon, 28 Feb 2011 08:59:44 +0000 (+0000) Subject: Implementation of the issue "20830: EDF 1357 GUI : Hide/Show Icon" for Post-Pro module. X-Git-Tag: V6_3_0a1~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dc1b7aa1c099124e4703c0cd1aa8252021838e4f;p=modules%2Fgui.git Implementation of the issue "20830: EDF 1357 GUI : Hide/Show Icon" for Post-Pro module. --- diff --git a/src/LightApp/LightApp_Displayer.cxx b/src/LightApp/LightApp_Displayer.cxx index a04cb8017..35e75fcac 100644 --- a/src/LightApp/LightApp_Displayer.cxx +++ b/src/LightApp/LightApp_Displayer.cxx @@ -86,6 +86,7 @@ void LightApp_Displayer::Display( const QStringList& list, const bool updateView if ( vf ) { + myLastEntry = *it; vf->BeforeDisplay( this ); vf->Display( prs ); vf->AfterDisplay( this ); @@ -171,7 +172,10 @@ void LightApp_Displayer::Erase( const QStringList& list, const bool forced, { SALOME_Prs* prs = vf->CreatePrs( (*it).toLatin1().data() ); if ( prs ) { + myLastEntry = *it; + vf->BeforeErase(this); vf->Erase( prs, forced ); + vf->AfterErase(this); if ( updateViewer ) vf->Repaint(); delete prs; // delete presentation because displayer is its owner diff --git a/src/LightApp/LightApp_Displayer.h b/src/LightApp/LightApp_Displayer.h index 762f87ccf..2e8c44a22 100644 --- a/src/LightApp/LightApp_Displayer.h +++ b/src/LightApp/LightApp_Displayer.h @@ -53,7 +53,7 @@ public: void Erase( const QString&, const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 ); void EraseAll( const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 ) const; - bool IsDisplayed( const QString&, SALOME_View* = 0 ) const; + virtual bool IsDisplayed( const QString&, SALOME_View* = 0 ) const; void UpdateViewer() const; static SALOME_View* GetActiveView(); @@ -66,6 +66,8 @@ public: protected: virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 ); +protected: + QString myLastEntry; }; #endif diff --git a/src/Prs/SALOME_Prs.h b/src/Prs/SALOME_Prs.h index 22eb63d24..4f1d2e328 100755 --- a/src/Prs/SALOME_Prs.h +++ b/src/Prs/SALOME_Prs.h @@ -196,6 +196,11 @@ public: virtual void BeforeDisplay( SALOME_Displayer* ) {} //!< Null body here virtual void AfterDisplay ( SALOME_Displayer* ) {} //!< Null body here + // Axiluary methods called before and after erasing of objects + virtual void BeforeErase( SALOME_Displayer* ) {} //!< Null body here + virtual void AfterErase ( SALOME_Displayer* ) {} //!< Null body here + + // New methods (asv) //! \retval Return false. virtual bool isVisible( const Handle_SALOME_InteractiveObject& ){ return false; } @@ -241,6 +246,15 @@ public: virtual void AfterDisplay ( SALOME_View*, const SALOME_VTKViewType& ){/*! Null body here*/}; virtual void BeforeDisplay( SALOME_View*, const SALOME_Plot2dViewType& ){/*! Null body here*/}; virtual void AfterDisplay ( SALOME_View*, const SALOME_Plot2dViewType& ){/*! Null body here*/}; + + // Axiluary methods called before and after erasing of objects + virtual void BeforeErase( SALOME_View*, const SALOME_OCCViewType& ){/*! Null body here*/}; + virtual void AfterErase ( SALOME_View*, const SALOME_OCCViewType& ){/*! Null body here*/}; + virtual void BeforeErase( SALOME_View*, const SALOME_VTKViewType& ){/*! Null body here*/}; + virtual void AfterErase ( SALOME_View*, const SALOME_VTKViewType& ){/*! Null body here*/}; + virtual void BeforeErase( SALOME_View*, const SALOME_Plot2dViewType& ){/*! Null body here*/}; + virtual void AfterErase ( SALOME_View*, const SALOME_Plot2dViewType& ){/*! Null body here*/}; + }; #endif diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index 99247e5bc..65bd597ff 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -635,6 +635,23 @@ void SOCC_Viewer::AfterDisplay( SALOME_Displayer* d ) d->AfterDisplay( this, SALOME_OCCViewType() ); } + +/*! + Auxiliary method called before erasing of objects +*/ +void SOCC_Viewer::BeforeErase( SALOME_Displayer* d ) +{ + d->BeforeErase( this, SALOME_OCCViewType() ); +} + +/*! + Auxiliary method called after erase of objects +*/ +void SOCC_Viewer::AfterErase( SALOME_Displayer* d ) +{ + d->AfterErase( this, SALOME_OCCViewType() ); +} + /*! Get new and current trihedron size corresponding to the current model size */ diff --git a/src/SOCC/SOCC_ViewModel.h b/src/SOCC/SOCC_ViewModel.h index 5f96cbe56..1c4feb978 100755 --- a/src/SOCC/SOCC_ViewModel.h +++ b/src/SOCC/SOCC_ViewModel.h @@ -62,6 +62,10 @@ public: virtual SALOME_Prs* CreatePrs( const char* entry = 0 ); virtual void BeforeDisplay( SALOME_Displayer* d ); virtual void AfterDisplay ( SALOME_Displayer* d ); + + virtual void BeforeErase( SALOME_Displayer* d ); + virtual void AfterErase ( SALOME_Displayer* d ); + virtual void LocalSelection( const SALOME_OCCPrs*, const int ); virtual void GlobalSelection( const bool = false ) const; virtual bool isVisible( const Handle(SALOME_InteractiveObject)& ); diff --git a/src/SPlot2d/SPlot2d_Curve.cxx b/src/SPlot2d/SPlot2d_Curve.cxx index ebc35f408..6db40795c 100644 --- a/src/SPlot2d/SPlot2d_Curve.cxx +++ b/src/SPlot2d/SPlot2d_Curve.cxx @@ -120,3 +120,37 @@ QString SPlot2d_Curve::getTableTitle() const title = getTableIO()->getName(); return title; } + +/*! + Add owner of the curve. + \param owner - owner of the curve +*/ +void SPlot2d_Curve::addOwner(const QString& owner) { + myOwners.insert(owner); +} + +/*! + Remove owner of the curve. + \param owner - owner of the curve +*/ +void SPlot2d_Curve::removeOwner(const QString& owner) { + myOwners.insert(owner); +} + +/*! + Get all owners of the curve. + \return owners of the curve. +*/ +OwnerSet SPlot2d_Curve::getOwners() const { + return myOwners; +} + + +/*! + Add owners of the curve. + \param owners - owners of the curve +*/ +void SPlot2d_Curve::addOwners(OwnerSet& owners) { + myOwners = myOwners|=owners; +} + diff --git a/src/SPlot2d/SPlot2d_Curve.h b/src/SPlot2d/SPlot2d_Curve.h index 7ef107a3a..089bdda1d 100644 --- a/src/SPlot2d/SPlot2d_Curve.h +++ b/src/SPlot2d/SPlot2d_Curve.h @@ -28,11 +28,16 @@ #include "SPlot2d.h" #include "Plot2d_Curve.h" + +#include + #ifndef _Handle_SALOME_InteractiveObject_HeaderFile #include #endif #include "SALOME_InteractiveObject.hxx" +typedef QSet OwnerSet; + class SPLOT2D_EXPORT SPlot2d_Curve : public Plot2d_Curve { public: @@ -52,9 +57,15 @@ public: virtual Handle(SALOME_InteractiveObject) getTableIO() const; virtual void setTableIO( const Handle(SALOME_InteractiveObject)& ); + virtual void addOwner(const QString& owner); + virtual void removeOwner(const QString& owner); + virtual OwnerSet getOwners() const; + virtual void addOwners (OwnerSet& owners); + private: Handle(SALOME_InteractiveObject) myIO; Handle(SALOME_InteractiveObject) myTableIO; + OwnerSet myOwners; }; #endif // SPlot2d_Curve_h diff --git a/src/SPlot2d/SPlot2d_ViewModel.cxx b/src/SPlot2d/SPlot2d_ViewModel.cxx index c118be8a5..587395da4 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.cxx +++ b/src/SPlot2d/SPlot2d_ViewModel.cxx @@ -278,12 +278,18 @@ SALOME_Prs* SPlot2d_Viewer::CreatePrs( const char* entry ) CurveDict aCurves = aViewFrame->getCurves(); CurveDict::Iterator it = aCurves.begin(); for( ; it != aCurves.end(); ++it ) { - SPlot2d_Curve* aCurve = dynamic_cast(it.value()); - if ( aCurve && aCurve->hasIO() && !strcmp( aCurve->getIO()->getEntry(), entry ) ) { - prs->AddObject(aCurve); - break; - } - } + SPlot2d_Curve* aCurve = dynamic_cast(it.value()); + OwnerSet owners = aCurve->getOwners(); + if(aCurve) { + if ( + (aCurve->hasIO() && !strcmp( aCurve->getIO()->getEntry(), entry )) || + (aCurve->hasTableIO() && !strcmp( aCurve->getTableIO()->getEntry(), entry )) || + owners.contains(entry) + ) { + prs->AddObject(aCurve); + } + } + } } return prs; } @@ -304,6 +310,22 @@ void SPlot2d_Viewer::AfterDisplay( SALOME_Displayer* d ) d->AfterDisplay( this, SALOME_Plot2dViewType() ); } +/*! + Axiluary method called before erasing of objects +*/ +void SPlot2d_Viewer::BeforeErase( SALOME_Displayer* d ) +{ + d->BeforeErase( this, SALOME_Plot2dViewType() ); +} + +/*! + Axiluary method called after erasing of objects +*/ +void SPlot2d_Viewer::AfterErase( SALOME_Displayer* d ) +{ + d->AfterErase( this, SALOME_Plot2dViewType() ); +} + /*! Returns true if interactive object is presented in the viewer and displayed */ diff --git a/src/SPlot2d/SPlot2d_ViewModel.h b/src/SPlot2d/SPlot2d_ViewModel.h index 05f1f834d..73e6b48e8 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.h +++ b/src/SPlot2d/SPlot2d_ViewModel.h @@ -73,6 +73,10 @@ public: virtual SALOME_Prs* CreatePrs( const char* entry = 0 ); virtual void BeforeDisplay( SALOME_Displayer* d ); virtual void AfterDisplay ( SALOME_Displayer* d ); + + virtual void BeforeErase( SALOME_Displayer* d ); + virtual void AfterErase ( SALOME_Displayer* d ); + virtual bool isVisible( const Handle(SALOME_InteractiveObject)& IObject ); virtual void GetVisible( SALOME_ListIO& theList ); diff --git a/src/SUIT/SUIT_TreeModel.cxx b/src/SUIT/SUIT_TreeModel.cxx index ed11fbad8..c79713e2d 100755 --- a/src/SUIT/SUIT_TreeModel.cxx +++ b/src/SUIT/SUIT_TreeModel.cxx @@ -665,6 +665,9 @@ Qtx::HeaderViewFlags SUIT_TreeModel::headerFlags( const QString& name ) const { \param state - visible state */ void SUIT_TreeModel::setVisibilityState(const QString& id, Qtx::VisibilityState state) { + if(myVisibilityMap.contains(id) && myVisibilityMap.value(id) == state) + return; + bool needSignal = false; if(state != Qtx::UnpresentableState) { myVisibilityMap.insert(id, state); diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 6b5d0cfa6..d3f12d5b9 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -636,6 +636,24 @@ void SVTK_Viewer::AfterDisplay( SALOME_Displayer* d ) d->AfterDisplay( this, SALOME_VTKViewType() ); } + +/*! + Auxiliary method called before erasing of objects +*/ +void SVTK_Viewer::BeforeErase( SALOME_Displayer* d ) +{ + d->BeforeErase( this, SALOME_VTKViewType() ); +} + +/*! + Auxiliary method called after displaying of objects +*/ +void SVTK_Viewer::AfterErase( SALOME_Displayer* d ) +{ + d->AfterErase( this, SALOME_VTKViewType() ); +} + + /*! \return true if object is displayed in viewer \param obj - object to be checked diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index 4cc7aaa17..93bf7c40a 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -150,6 +150,12 @@ public: //! See #SALOME_View::AfterDisplay( SALOME_Displayer* d ) virtual void AfterDisplay( SALOME_Displayer* d ); + //! See #SALOME_View::BeforeDisplay( SALOME_Displayer* d ) + virtual void BeforeErase( SALOME_Displayer* d ); + + //! See #SALOME_View::AfterDisplay( SALOME_Displayer* d ) + virtual void AfterErase( SALOME_Displayer* d ); + //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& ) virtual bool isVisible( const Handle(SALOME_InteractiveObject)& ); diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 1d8ea36a9..bd87ccaa6 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -1756,50 +1756,34 @@ void SalomeApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow ) Update visibility state of given objects */ void SalomeApp_Application::updateVisibilityState( DataObjectList& theList, - SUIT_ViewModel* theViewModel ) -{ + SUIT_ViewModel* theViewModel ) { LightApp_Study* aStudy = dynamic_cast(activeStudy()); if(!theViewModel) return; SALOME_View* aView = dynamic_cast( theViewModel ); - + if (theList.isEmpty() || !aView || !aStudy) return; - - // take visibale objects from current view - QStringList aVisibleList; - SALOME_ListIO aListOfIO; - aView->GetVisible( aListOfIO ); - SALOME_ListIteratorOfListIO anIter(aListOfIO); - for(; anIter.More(); anIter.Next()) { - Handle_SALOME_InteractiveObject& anObj = anIter.Value(); - if (!anObj.IsNull() && anObj->hasEntry()) - aVisibleList.append(anObj->getEntry()); - } - - for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) - { + + for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) { LightApp_DataObject* obj = dynamic_cast(*itr); - if (!obj ) continue; - - //if object is visible in aView => set Qtx::ShownState status - if ( aVisibleList.contains( obj->entry() ) ) - aStudy->setVisibilityState( obj->entry(), Qtx::ShownState ); - else { - //check that object can be displayed in the aView - //and set Qtx::HiddenState - Qtx::VisibilityState anObjState = Qtx::UnpresentableState; - LightApp_Module* anObjModule = dynamic_cast(obj->module()); - - if(anObjModule) { - LightApp_Displayer* aDisplayer = anObjModule->displayer(); - - if(aDisplayer && !aStudy->isComponent(obj->entry())) { - if(aDisplayer->canBeDisplayed(obj->entry(), theViewModel->getType())) { + + if (aStudy->isComponent(obj->entry()) || !obj) + continue; + + LightApp_Module* anObjModule = dynamic_cast(obj->module()); + Qtx::VisibilityState anObjState = Qtx::UnpresentableState; + + if(anObjModule) { + LightApp_Displayer* aDisplayer = anObjModule->displayer(); + if(aDisplayer) { + if( aDisplayer->canBeDisplayed(obj->entry(), theViewModel->getType()) ) { + if(aDisplayer->IsDisplayed(obj->entry(),aView)) + anObjState = Qtx::ShownState; + else anObjState = Qtx::HiddenState; - } } } aStudy->setVisibilityState( obj->entry(), anObjState );