]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Implementation of the issue "20830: EDF 1357 GUI : Hide/Show Icon" for Post-Pro module.
authorrnv <rnv@opencascade.com>
Mon, 28 Feb 2011 08:59:44 +0000 (08:59 +0000)
committerrnv <rnv@opencascade.com>
Mon, 28 Feb 2011 08:59:44 +0000 (08:59 +0000)
13 files changed:
src/LightApp/LightApp_Displayer.cxx
src/LightApp/LightApp_Displayer.h
src/Prs/SALOME_Prs.h
src/SOCC/SOCC_ViewModel.cxx
src/SOCC/SOCC_ViewModel.h
src/SPlot2d/SPlot2d_Curve.cxx
src/SPlot2d/SPlot2d_Curve.h
src/SPlot2d/SPlot2d_ViewModel.cxx
src/SPlot2d/SPlot2d_ViewModel.h
src/SUIT/SUIT_TreeModel.cxx
src/SVTK/SVTK_ViewModel.cxx
src/SVTK/SVTK_ViewModel.h
src/SalomeApp/SalomeApp_Application.cxx

index a04cb80179e34b55f6f3e5d5c0fc2ec2276f8499..35e75fcacf2aff662011ba6e6833a154c7663c4b 100644 (file)
@@ -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
index 762f87ccfe6bd0a7c840c48567833f41aa778c6d..2e8c44a2215fd1df16ec39d4fd81a858184f8c82 100644 (file)
@@ -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
index 22eb63d24c7eb2c8a34f4f0b6ea45a580c4ef9bb..4f1d2e328910b362483a31b6869fe45212b979ff 100755 (executable)
@@ -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
index 99247e5bc62e6bed597821f58ebc0a84f6616a67..65bd597ffcc8f3b4b5fca5adb618d34bf44396c3 100755 (executable)
@@ -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
 */
index 5f96cbe564512e8ce1c938269c5faaaff3e88ec3..1c4feb978337b8a66c470763b02e5f87b6d2d007 100755 (executable)
@@ -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)& );
index ebc35f40896df692b3fd81244e9fb5e08a888851..6db40795c17884b7227bec963aa3bf29f6c6eda6 100644 (file)
@@ -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;
+}
+
index 7ef107a3ad5508e21b4a62b6f61262f754b1963c..089bdda1dddeef7efc801c9c22924b3fc627023f 100644 (file)
 #include "SPlot2d.h"  
 #include "Plot2d_Curve.h"
 
+
+#include <QSet>
+
 #ifndef _Handle_SALOME_InteractiveObject_HeaderFile
 #include <Handle_SALOME_InteractiveObject.hxx>
 #endif
 #include "SALOME_InteractiveObject.hxx"
 
+typedef QSet<QString> 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
index c118be8a525a2c69c43ff9ed2055cad46d8d124e..587395da48f37c4414dc4cf1b18c95e8ea5613bf 100644 (file)
@@ -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<SPlot2d_Curve*>(it.value()); 
-      if ( aCurve && aCurve->hasIO() && !strcmp( aCurve->getIO()->getEntry(), entry ) ) {
-       prs->AddObject(aCurve);
-       break;
-      }
-    }  
+      SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>(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
 */
index 05f1f834d2d70af25dfaac3035f05d927c31165b..73e6b48e81608bebb3a6ce5102328be874df7558 100644 (file)
@@ -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 );
 
index ed11fbad8b92b93117249d767555a74bc59d4560..c79713e2d01483879308dc8d561b9533cb828f38 100755 (executable)
@@ -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);
index 6b5d0cfa6e0f53b257792779d54eedf331936804..d3f12d5b9b860db81b27e98e043326e147a13f4c 100644 (file)
@@ -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
index 4cc7aaa17eaed5221ad4ff7660287c82397424dc..93bf7c40a0e7c10322bd7ba8da8682e7c2f5beac 100644 (file)
@@ -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)& );
 
index 1d8ea36a9e977a9ca9a1577c10d0e97f3f57f644..bd87ccaa6da6fad74f6e5af71da3bc0718627bab 100644 (file)
@@ -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<LightApp_Study*>(activeStudy());
 
   if(!theViewModel)
     return;
   
   SALOME_View* aView = dynamic_cast<SALOME_View*>( 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<LightApp_DataObject*>(*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<LightApp_Module*>(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<LightApp_Module*>(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 );