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 09:01:53 +0000 (09:01 +0000)
committerrnv <rnv@opencascade.com>
Mon, 28 Feb 2011 09:01:53 +0000 (09:01 +0000)
13 files changed:
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_Displayer.cxx
src/VISUGUI/VisuGUI_Displayer.h
src/VISUGUI/VisuGUI_Prs3dTools.h
src/VISUGUI/VisuGUI_Tools.cxx
src/VISUGUI/VisuGUI_ViewTools.cxx
src/VISU_I/VISU_Mesh_i.cc
src/VISU_I/VISU_Table_i.cc
src/VISU_I/VISU_Table_i.hh
src/VISU_I/VISU_Tools.cxx
src/VISU_I/VISU_Tools.h
src/VISU_I/VISU_ViewManager_i.cc
src/VISU_I/VISU_View_i.cc

index c564c948ef1aa7d43c910482773be697f750ec1c..b09336a6b18503221f65d80e54a1816fcc737b60 100644 (file)
@@ -929,6 +929,7 @@ VisuGUI
     case VISU::TCURVE:
     case VISU::TCONTAINER:
     case VISU::TTABLE:
+      getViewManager(SPlot2d_Viewer::Type(), true);
       displayer()->Display(anIO->getEntry());
       break;
     default: {
@@ -1933,6 +1934,7 @@ VisuGUI
     if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase)){
       if(aContainer && aContainer->GetNbCurves() > 0){
         aContainer->Clear();
+       VISU::updateContainerVisibility(aContainer);
         UpdateObjBrowser(this);
       }
     }
@@ -1962,8 +1964,9 @@ VisuGUI
   if (aDlg->exec()) {
     aDlg->storeToPrsObject(aContainer);
     UpdateObjBrowser(this, true);
+    delete aDlg;
+    VISU::updateContainerVisibility(aContainer);
   }
-  delete aDlg;
 }
 
 //----------------------------------------------------------------------------
@@ -3231,13 +3234,13 @@ VisuGUI
   QString aPrsInvisible = "(($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "})" + andInvisible + " and (not isPlot2dViewer))";
   QString aComponent = "( selcount=1 and canBeDisplayed and isVisuComponent )";
 
-  QString anEraseRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsVisible +
+  QString anEraseRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (" + aPrsVisible +
     " or (   (" + aTableOrContHide + orCurveVisible + "))) ) or " + aComponent;
 
-  QString aDisplayRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsInvisible +
+  QString aDisplayRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (" + aPrsInvisible +
     " or (   (" + aTableOrContShow + orCurveInvisible + "))) ) or " + aComponent;
 
-  QString aDOnlyRule = "( selcount>0 and ({true} in $canBeDisplayed) and (($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "})"
+  QString aDOnlyRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "})"
     " or (   ((type='VISU::TTABLE' and nbChildren>0) or (type='VISU::TCONTAINER' and hasCurves) or"
     " (type='VISU::TCURVE')))) ) or" + aComponent;
 
index bfa420adcd4ee184f3bf624b24037605672ae59a..cad7276a118514bb3f35a5adaca3c7ed3e012028 100644 (file)
@@ -34,6 +34,8 @@
 #include "VISU_ViewManager_i.hh"
 #include "VISU_Actor.h"
 
+#include <VISU_Table_i.hh>
+
 //#include "VVTK_ViewModel.h"
 
 #include <SVTK_ViewModel.h>
 #include <SUIT_MessageBox.h>
 #include <SUIT_Desktop.h>
 
+
+
+void changeVisibility(int theDisplaying, QString entry, SalomeApp_Study* study) {
+  
+  _PTR(SObject) obj = study->studyDS()->FindObjectID( (const char*)entry.toLatin1() );
+  CORBA::Object_var anObj = VISU::ClientSObjectToObject( obj );
+  if( CORBA::is_nil( anObj ) )
+    return;
+
+  if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( anObj ).in()) ) {
+    VISU::CurveVisibilityChanged(aCurve,theDisplaying, false, true, true);
+  }
+
+  if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( anObj ).in()) ) {
+    int nbCurves = aContainer->GetNbCurves();
+    for( int k=1; k<=nbCurves; k++ ) {
+      VISU::Curve_i* aCurve = aContainer->GetCurve( k );
+      if(aCurve)
+       VISU::CurveVisibilityChanged(aCurve,theDisplaying, true, true, true);
+    }
+  }
+
+  if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant( anObj ).in()) ) {
+    _PTR(SObject) TableSO = study->studyDS()->FindObjectID( aTable->GetEntry() );
+    if ( TableSO ) {
+      _PTR(ChildIterator) Iter = study->studyDS()->NewChildIterator( TableSO );
+      
+      for ( ; Iter->More(); Iter->Next() ) {
+       CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
+       if( !CORBA::is_nil( childObject ) ) {
+         CORBA::Object_ptr aCurve_ptr = VISU::Curve::_narrow( childObject );
+         if( !CORBA::is_nil( aCurve_ptr ) ) {
+           VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve_ptr).in());
+           if(aCurve)
+             VISU::CurveVisibilityChanged(aCurve,theDisplaying, true, false, true);
+         }
+       }
+      }
+    }
+  }
+}
+
+
 VisuGUI_Displayer::VisuGUI_Displayer( SalomeApp_Application* app )
 : LightApp_Displayer(),
   myApp( app )
@@ -60,6 +105,54 @@ VisuGUI_Displayer::~VisuGUI_Displayer()
 {
 }
 
+
+bool VisuGUI_Displayer::IsDisplayed( const QString& id, SALOME_View* vf ) const {
+
+  bool displayed = false;
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
+  if(!aStudy)
+    return displayed;
+  
+  _PTR(SObject) aSObject = aStudy->studyDS()->FindObjectID( (const char*)id.toLatin1() );
+  CORBA::Object_var anObj = VISU::ClientSObjectToObject( aSObject );
+  if( CORBA::is_nil( anObj ) )
+    return LightApp_Displayer::IsDisplayed(id, vf);
+  
+  if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( anObj ).in())) {
+    int nbCurves = aContainer->GetNbCurves();
+    for( int k=1; k<=nbCurves; k++ ) {
+      VISU::Curve_i* aCurve = aContainer->GetCurve( k );
+      if(aCurve && LightApp_Displayer::IsDisplayed(aCurve->GetEntry().c_str(), vf)) {
+       displayed = true;
+       break;
+      }
+    }
+    return displayed;
+  } else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant( anObj ).in())) {
+
+    _PTR(SObject) TableSO = aStudy->studyDS()->FindObjectID( (const char*)id.toLatin1() );
+    if( TableSO ) {
+      _PTR(ChildIterator) Iter = aStudy->studyDS()->NewChildIterator( TableSO );
+      for( ; Iter->More(); Iter->Next() ) {
+       CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
+       if( !CORBA::is_nil( childObject ) ) {
+         CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
+         if( !CORBA::is_nil( aCurve ) ) {
+           VISU::Curve_i* aCurve_i = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
+           if(aCurve && LightApp_Displayer::IsDisplayed(aCurve_i->GetEntry().c_str(), vf)) {
+             displayed = true;
+             break;
+           }       
+         }
+       }
+      }      
+    }
+    return displayed;
+  } else {
+    return LightApp_Displayer::IsDisplayed(id, vf);
+  }
+}
+
 SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& theEntry, SALOME_View* theView )
 {
   SALOME_Prs* aPrs = 0;
@@ -109,6 +202,7 @@ SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& theEntry, SALOM
                 aViewWindow->Repaint();
               }
             }
+           VISU::SetVisibilityState(qPrintable(theEntry),Qtx::ShownState);
           }
           else
             aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aBaseServant);
@@ -294,9 +388,10 @@ bool VisuGUI_Displayer::canBeDisplayed( const QString& entry, const QString& vie
   if( study->isComponent( entry ) )
     return true;
 
-  if( dynamic_cast<VISU::Curve_i*>( VISU::GetServant( anObj ).in() )
-      ||
-      dynamic_cast<VISU::Container_i*>( VISU::GetServant( anObj ).in() ) )
+  if( (dynamic_cast<VISU::Curve_i*>( VISU::GetServant( anObj ).in() )
+       ||
+       dynamic_cast<VISU::Container_i*>( VISU::GetServant( anObj ).in() ))
+      && viewer_type==SPlot2d_Viewer::Type())
     return true;
 
   if( viewer_type==SVTK_Viewer::Type() /*|| viewer_type==VVTK_Viewer::Type()*/)
@@ -322,3 +417,11 @@ bool VisuGUI_Displayer::canBeDisplayed( const QString& entry, const QString& vie
   else 
     return false;
 }
+
+void VisuGUI_Displayer::AfterDisplay( SALOME_View* vf, const SALOME_Plot2dViewType& ) {
+  changeVisibility(VISU::eDisplay, myLastEntry,dynamic_cast<SalomeApp_Study*>( myApp->activeStudy()));
+}
+
+void VisuGUI_Displayer::AfterErase( SALOME_View* vf, const SALOME_Plot2dViewType& ) {
+  changeVisibility(VISU::eErase, myLastEntry,dynamic_cast<SalomeApp_Study*>( myApp->activeStudy()));
+}
index 8111373abb82a7b33137fbf4657da8f39e9964a9..14a1a4a8773d830a80d7bf26e80f7a561c5f8da8 100644 (file)
@@ -47,6 +47,11 @@ public:
 
   virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
   virtual bool        canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const;
+  virtual bool IsDisplayed( const QString&, SALOME_View* = 0 ) const;
+  
+  virtual void AfterDisplay ( SALOME_View*, const SALOME_Plot2dViewType& );
+  virtual void AfterErase ( SALOME_View*, const SALOME_Plot2dViewType& );
+
 
 protected:
           bool         addCurve      ( SPlot2d_Prs*, Plot2d_ViewWindow*, VISU::Curve_i* ) const;
index bd7f27e29acb579e5bcf941f2df1c322770b2574..bedc52e04399c429c0ce6b2e6acebb249c098a49 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "VISUConfig.hh"
 #include "VisuGUI_Tools.h"
+#include "VISU_Tools.h"
 #include "VisuGUI_ViewTools.h"
 #include "VISU_ColoredPrs3dFactory.hh"
 #include "VISU_PipeLine.hxx"
@@ -233,8 +234,9 @@ namespace VISU
       SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
       int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0);
       if(aResourceMgr->booleanValue("VISU","display_only",false)){
-          theModule->OnEraseAll();
-        }
+       theModule->OnEraseAll();
+       SetVisibilityState(aPrs3d->GetEntry(),Qtx::ShownState);
+      }
       
       if (!aValue) {
         if (TDlg* aDlg = new TDlg(theModule)) { // dialog box in creation mode
index 91b9e9081f32e207af1db5821c4e1e4dc07980d3..343da087b4f874b3187b127b7af9b40b1d045d34 100644 (file)
@@ -778,14 +778,28 @@ namespace VISU
                     VISU::Prs3d_i* thePrs,
                     SVTK_ViewWindow* theViewWindow)
   {
-    VISU_Actor* aActor = NULL;
+    VISU_Actor* anActor = NULL;
     if (!thePrs || !theViewWindow)
-      return aActor;
+      return anActor;
+
+    SalomeApp_Application *anApp = dynamic_cast<SalomeApp_Application*>(theModule->application());
+    if(!anApp)
+      return anActor;
+    
+    SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
+
+    if(!aStudy)
+      return anActor;
+    
 
     QApplication::setOverrideCursor( Qt::WaitCursor );
     try {
-      if ((aActor = thePrs->CreateActor()))
-        theViewWindow->AddActor(aActor);
+      if ((anActor = thePrs->CreateActor())) {
+        theViewWindow->AddActor(anActor);
+
+       if(anActor->hasIO() && anActor->getIO()->hasEntry())
+         aStudy->setVisibilityState(anActor->getIO()->getEntry(), Qtx::ShownState);
+      }
     } catch(std::exception& exc) {
       SUIT_MessageBox::warning
         (GetDesktop(theModule), QObject::tr("WRN_VISU"),
@@ -793,7 +807,7 @@ namespace VISU
     }
     QApplication::restoreOverrideCursor();
 
-    return aActor;
+    return anActor;
   }
 
   //------------------------------------------------------------
index 7e455698a1b4fc65bc60da56170ee2b1a6ed1e2d..62ee8b6a04e3edbf9b7ad2708bc8db77e8285b52 100644 (file)
 #include "SVTK_ViewModel.h"
 #include "SVTK_ViewWindow.h"
 
+#include <VISU_Tools.h>
+
 #include <SUIT_Desktop.h>
 
+#include <SalomeApp_Study.h>
+
 namespace VISU 
 {
   //----------------------------------------------------------------------------
@@ -53,6 +57,15 @@ namespace VISU
           theViewWindow->getRenderer()->ResetCameraClippingRange();
           theViewWindow->Repaint();
           QApplication::restoreOverrideCursor();
+         
+         if(!thePrs->GetEntry().empty())
+           VISU::SetVisibilityState(thePrs->GetEntry(), Qtx::ShownState);
+         else {
+           VISU::ColoredPrs3d_i* prs = dynamic_cast<VISU::ColoredPrs3d_i*>(thePrs);
+           if(prs && !prs->GetHolderEntry().empty()) {
+             VISU::SetVisibilityState(prs->GetHolderEntry(), Qtx::ShownState);
+           }
+         }
           return anActor;
         }
       } catch(std::exception& exc) {
@@ -141,24 +154,32 @@ namespace VISU
   ErasePrs(VisuGUI* theModule,
            Base_i* theBase, 
            bool theDoRepaint)
-  {
+  {    
     if(!theBase)
       return;
 
+    bool updateState = true;
+
     switch (theBase->GetType()) {
     case VISU::TCURVE: {
-      if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(theBase))
+      if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(theBase)) {
         PlotCurve(theModule, aCurve, VISU::eErase );
+       updateState = false;
+      }
       break;
     }
     case VISU::TCONTAINER: {
-      if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(theBase))
+      if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(theBase)) {
         PlotContainer(theModule, aContainer, VISU::eErase );
+       updateState = false;
+      }
       break;
     }
     case VISU::TTABLE: {
-      if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(theBase))
+      if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(theBase)) {
         PlotTable(theModule, aTable, VISU::eErase );
+       updateState = false;
+      }
       break;
     }
     case VISU::TPOINTMAP3D: {
@@ -170,8 +191,10 @@ namespace VISU
             aViewWindow->Repaint();
           }
         } else {
-          if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(theBase))
+          if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(theBase)) {
             PlotTable(theModule, aTable, VISU::eErase );
+           updateState = false;
+         }
         }
       }
       break;
@@ -184,6 +207,18 @@ namespace VISU
         }
       }
     }} // switch (aType)
+    
+    /* Update visibility state */
+    if(updateState) {
+      if( RemovableObject_i* obj = dynamic_cast<RemovableObject_i*>(theBase)) {
+       SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(theModule->application());
+       if(anApp) {
+         SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
+         std::string entry = obj->GetEntry();
+         if(aStudy && !entry.empty()) 
+           aStudy->setVisibilityState(QString(entry.c_str()), Qtx::HiddenState);
+       }
+      } 
+    }
   }
-
 }
index 0ab3f33472f6623bc40c462d29d3af2f69c23a3a..0fe836c4cbe73216cc721ded85a5502e7c85ae94 100644 (file)
@@ -27,6 +27,7 @@
 //
 #include "VISU_Mesh_i.hh"
 #include "VISU_Prs3dUtils.hh"
+#include "VISU_Tools.h"
 
 #include "VISU_Result_i.hh"
 
@@ -36,8 +37,8 @@
 #include "VISU_Convertor.hxx"
 
 #include "SALOME_Event.h"
+#include <SUIT_ResourceMgr.h>
 
-#include "SUIT_ResourceMgr.h"
 
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
@@ -327,6 +328,13 @@ VISU::Mesh_i
   SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder();
   aStudyBuilder->RemoveAttribute(GetSObject(), "AttributePixMap");
 
+  //Set visibility state to Qtx::UnpresentableState
+  VISU::SetVisibilityState(GetEntry(), Qtx::UnpresentableState);
+       
+
+
+
+
   ProcessVoidEvent(new TRemoveFromStudy(this));
 }
 
index 22166fd5a01c5a8d4e2a550495eeb0569fc643e8..9dc035e9586d8fbfb6b62401a8a085c726abe5d8 100644 (file)
@@ -27,6 +27,7 @@
 //
 #include "VISU_Table_i.hh"
 
+#include "VISU_Tools.h"
 #include "VISU_CutLinesBase_i.hh"
 #include "VISU_CutSegment_i.hh"
 #include "VISU_Result_i.hh"
@@ -929,6 +930,9 @@ SPlot2d_Curve* VISU::Curve_i::CreatePresentation()
   crv->setIO(new SALOME_InteractiveObject(aString.in(), "VISU", GetName().c_str()));
   if ( myTable )
     crv->setTableIO(new SALOME_InteractiveObject(myTable->GetObjectEntry().c_str(), "VISU", myTable->GetName().c_str()));
+
+  if(!myContainers.isEmpty())     
+    crv->addOwners(myContainers);
   return crv;
 }
 /*!
@@ -1024,6 +1028,32 @@ SALOMEDS::SObject_var VISU::Curve_i::GetSObject()
   return mySObj;
 }
 
+
+/*!
+  Add container.
+  id  - owner of the curve
+*/
+void VISU::Curve_i::addContainer(const QString& id) {
+  myContainers.insert(id);
+}
+
+/*!
+  Remove Container
+  id  - entry of the container
+*/
+void VISU::Curve_i::removeContainer(const QString& id) {
+  myContainers.insert(id);
+}
+
+/*!
+  Get all owners of the curve.
+  \return owners of the curve.
+*/
+VISU::ContainerSet VISU::Curve_i::getContainers() const {
+  return myContainers;
+}
+
+
 //----------------------------------------------------------------
 //                      Container Object
 //----------------------------------------------------------------
@@ -1078,6 +1108,7 @@ void VISU::Container_i::AddCurve( Curve_ptr theCurve )
       SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
       SALOMEDS::SObject_var newSO = Builder->NewObject( mySO );
       Builder->Addreference( newSO, SO );
+      pCurve->addContainer(GetEntry().c_str());
     }
   }
 }
@@ -1107,6 +1138,7 @@ void VISU::Container_i::RemoveCurve( Curve_ptr theCurve )
          Builder->RemoveObject( childSO );
        }
       }
+      pCurve->removeContainer(GetEntry().c_str());
     }
   }
 }
index 3db4f3b5d237447206f5a9c62747d54ca2a99f9a..36f4b1c80d03e1e19ee12ba6121d6787880ad8ea 100644 (file)
@@ -31,6 +31,7 @@
 #include "VISU_PrsObject_i.hh"
 
 #include <QStringList>
+#include <QSet>
 
 class SPlot2d_Curve;
 
@@ -95,6 +96,9 @@ namespace VISU{
                                      bool theFirstStrAsTitle = false);
   bool ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName);
   //==============================================================================
+
+  typedef QSet<QString> ContainerSet;
+
   class VISU_I_EXPORT Curve_i : public virtual POA_VISU::Curve,
                   public virtual PrsObject_i
   {
@@ -121,6 +125,10 @@ namespace VISU{
     virtual VISU::Curve::LineType GetLine();
     virtual CORBA::Long GetLineWidth();
 
+    virtual void addContainer(const QString& id);
+    virtual void removeContainer(const QString& id);
+    virtual ContainerSet getContainers() const;
+
     virtual void RemoveFromStudy();
 
     virtual SALOMEDS::SObject_var GetSObject();
@@ -141,9 +149,12 @@ namespace VISU{
     std::string             myTitle;
     bool                    myAuto;
     SALOMEDS::SObject_var   mySObj;
+    ContainerSet            myContainers;
 
   public:
     virtual Storable* Create();
+    
+    Table_i* getTable() const {return myTable;}
 
     int  GetHRow() const { return myHRow; }
     void SetHRow( const int theHRow ) { myHRow = theHRow; }
index 1b33516fdf04dcabaa9269f6fe72ec586d6a72b0..d17a33ec2603d06f610da029403b23513fc7ce0e 100644 (file)
 #include "VISU_Table_i.hh"
 #include "VISU_ViewManager_i.hh"
 
+#include <VISU_ActorBase.h>
+
+#include <LightApp_Displayer.h>
+
 #include <SalomeApp_Study.h>
 #include <SalomeApp_Application.h>
+#include <SalomeApp_Module.h>
 
 #include <SPlot2d_ViewModel.h>
 #include <Plot2d_ViewFrame.h>
 #include <Plot2d_ViewManager.h>
 
 #include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
 
 //=============================================================================
 namespace VISU
@@ -129,6 +135,7 @@ namespace VISU
             }
 
             UpdateCurve( theCurve, thePlot, plotCurve, theDisplaying );
+           CurveVisibilityChanged(theCurve, theDisplaying, true, false, true);
 
             if ( theDisplaying == VISU::eErase && plotCurve ) {
               clist.removeAll(plotCurve );
@@ -137,7 +144,9 @@ namespace VISU
         }
       }
       thePlot->Repaint();
+      SetVisibilityState(table->GetEntry(),GetStateByDisplaying(theDisplaying));
     }
+    
   }
 
   //------------------------------------------------------------
@@ -183,6 +192,9 @@ namespace VISU
     }
 
     thePlot->Repaint();
+
+    SetVisibilityState(theCurve->GetEntry(),GetStateByDisplaying(theDisplaying));
+    CurveVisibilityChanged(theCurve,theDisplaying,false, true, true);
   }
 
   //------------------------------------------------------------
@@ -258,13 +270,16 @@ namespace VISU
           if ( plotCurve && theDisplaying == VISU::eErase ) {
             clist.removeAll( plotCurve );
           }
+         CurveVisibilityChanged(theCurve, theDisplaying, true, true, true);
         }
       }
     }
+    
     thePlot->Repaint();
     if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
       thePlot->fitAll();
     }
+    
     qApp->processEvents();
   }
 
@@ -305,4 +320,166 @@ namespace VISU
       }
     }
   }
+
+  //------------------------------------------------------------
+  void SetVisibilityState(std::string entry, Qtx::VisibilityState state) {
+    if(entry.empty())
+      return;
+
+    if( SUIT_Session* aSession = SUIT_Session::session() )
+      if( SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSession->activeApplication()) )
+       if( SalomeApp_Study* aStudy =  dynamic_cast<SalomeApp_Study*>(anApp->activeStudy()) )
+         aStudy->setVisibilityState(entry.c_str(), state);
+
+  }
+
+  //------------------------------------------------------------
+  void SetVisibilityState(VISU_ActorBase *theActor, Qtx::VisibilityState state) {
+    if(!theActor || theActor->hasIO() || !theActor->getIO()->hasEntry())
+      return;
+    SetVisibilityState(theActor->getIO()->getEntry(), state);
+  }
+
+  void CurveVisibilityChanged(VISU::Curve_i* theCurve, 
+                             int theDisplaying,
+                             bool updateCurve,
+                             bool updateTable,
+                             bool updateContainers) {
+    
+    SUIT_Session* aSession = SUIT_Session::session();
+    if(!aSession)
+      return;
+    
+    SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSession->activeApplication());
+    if( !anApp )
+      return;
+
+    SUIT_ViewManager* aManager = anApp->activeViewManager();
+
+    if( !aManager)
+      return;
+    
+    bool is2dViewActive = aManager->getType() == SPlot2d_Viewer::Type();
+
+    Qtx::VisibilityState state = is2dViewActive ? GetStateByDisplaying(theDisplaying) : Qtx::UnpresentableState;
+    
+    if(updateCurve)
+      SetVisibilityState(theCurve->GetEntry(), state);
+    
+    if(updateTable) {
+      Table_i* aTable = theCurve->getTable();
+      if(aTable) {
+       if( SalomeApp_Study* aStudy =  dynamic_cast<SalomeApp_Study*>(anApp->activeStudy()) ) {
+         _PTR(SObject) TableSO = aStudy->studyDS()->FindObjectID( aTable->GetEntry() );
+         if ( TableSO ) {
+           _PTR(ChildIterator) Iter = aStudy->studyDS()->NewChildIterator( TableSO );
+           bool isTableVisible = false;
+           LightApp_Displayer* aDisplayer = (dynamic_cast<SalomeApp_Module*>(anApp->activeModule()))->displayer();
+           if(aDisplayer && state != Qtx::UnpresentableState ) {
+             for ( ; Iter->More(); Iter->Next() ) {
+               CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
+               if( !CORBA::is_nil( childObject ) ) {
+                 CORBA::Object_ptr aCurve_ptr = VISU::Curve::_narrow( childObject );
+                 if( !CORBA::is_nil( aCurve_ptr ) ) {
+                   VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve_ptr).in());
+                   if(aDisplayer->IsDisplayed(aCurve->GetEntry().c_str())) {
+                     isTableVisible = true;
+                     break;
+                   }
+                 } //!CORBA::is_nil( aCurve )
+               } // !CORBA::is_nil( childObject )
+             } //for
+             if(state != Qtx::UnpresentableState)
+               SetVisibilityState(aTable->GetEntry(), (isTableVisible ? Qtx::ShownState : Qtx::HiddenState));
+             else 
+               SetVisibilityState(aTable->GetEntry(), state);
+           } //aDisplayer
+         } //TableSO
+       } //aStudy
+      } //aTable
+    } //updateTable
+
+    if(updateContainers) {
+      if( SalomeApp_Study* aStudy =  dynamic_cast<SalomeApp_Study*>(anApp->activeStudy()) ) {
+       if(LightApp_Displayer* aDisplayer =  (dynamic_cast<SalomeApp_Module*>(anApp->activeModule()))->displayer()) { 
+         ContainerSet aContainers = theCurve->getContainers();
+         ContainerSet::ConstIterator it = aContainers.begin();
+         for(;it != aContainers.end();it++ ) {
+           if(state != Qtx::UnpresentableState) {
+             bool isContainerDisplayed = false;
+             _PTR(SObject) aSObject = aStudy->studyDS()->FindObjectID( (*it).toLatin1().data());
+             CORBA::Object_var anObj = VISU::ClientSObjectToObject( aSObject );
+             if( !CORBA::is_nil( anObj ) ) {
+               if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( anObj ).in())) {
+                 int nbCurves = aContainer->GetNbCurves();
+                 for( int k=1; k<=nbCurves; k++ ) {
+                   VISU::Curve_i* aCurve = aContainer->GetCurve( k );
+                   if(aCurve && aDisplayer->IsDisplayed(aCurve->GetEntry().c_str())) {
+                     isContainerDisplayed = true;
+                     break;
+                   } // aCurve && aDisplater->IsDisplayed
+                 } //for k=1 ...
+                 SetVisibilityState(aContainer->GetEntry(), (isContainerDisplayed ? Qtx::ShownState : Qtx::HiddenState));
+               } //aContainer
+             } //!CORBA::is_nil( anObj )
+           } //state != Qtx::UnpresentableState
+           else {
+             SetVisibilityState((*it).toLatin1().data(), state);
+           }
+         } // for Containers           
+       } //aDisplayer
+      } //aStudy
+    } //updateContainers    
+  } 
+
+  Qtx::VisibilityState GetStateByDisplaying(int theDisplaying) {
+    
+    Qtx::VisibilityState state = Qtx::UnpresentableState;
+    if(theDisplaying == eDisplayAll || 
+       theDisplaying == eDisplay    || 
+       theDisplaying == eDisplayOnly ) {
+      state = Qtx::ShownState;
+      
+    } else if (theDisplaying == eErase || theDisplaying == eEraseAll) {
+      state = Qtx::HiddenState;
+    }
+    return state;
+  }
+
+  void updateContainerVisibility(VISU::Container_i* theContainer) {
+    if(!theContainer)
+      return;
+    
+    if( SUIT_Session* aSession = SUIT_Session::session() ) {
+      if( SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSession->activeApplication()) ) {
+       if( SalomeApp_Study* aStudy =  dynamic_cast<SalomeApp_Study*>(anApp->activeStudy()) ) {
+         Qtx::VisibilityState state = Qtx::UnpresentableState;
+         int nbCurves = theContainer->GetNbCurves();
+         if( nbCurves > 0 ) {
+           if(LightApp_Displayer* aDisplayer =  (dynamic_cast<SalomeApp_Module*>(anApp->activeModule()))->displayer()) {
+             for( int k=1; k<=nbCurves; k++ ) {
+               VISU::Curve_i* aCurve = theContainer->GetCurve( k );
+               if(aCurve && aDisplayer->IsDisplayed(aCurve->GetEntry().c_str())) {
+                 state = Qtx::ShownState;
+                 break;
+               }             
+             }
+             if ( state  == Qtx::UnpresentableState) {
+               if( SUIT_ViewManager * vm = anApp->activeViewManager()){
+                 if(vm->getType() == SPlot2d_Viewer::Type()) {
+                   state = Qtx::HiddenState;
+                 }
+               }
+             }
+           }
+         } else if(SUIT_ViewManager * vm = anApp->activeViewManager()){
+           if(vm->getType() == SPlot2d_Viewer::Type()) {
+             state = Qtx::HiddenState;
+           }
+         }
+         aStudy->setVisibilityState(theContainer->GetEntry().c_str(),state);
+       }
+      }
+    }
+  }
 }
index a0ec2b53a511989749b3bf938bb2b9a7a614a022..b0740bd933e1ceef5f8a2a46f7e0d2d26a4a2eaf 100644 (file)
 #include "VISUConfig.hh"
 #include "VISU_I.hxx"
 
+#include <Qtx.h>
+
 #include <SALOMEDSClient_Study.hxx>
 
 class SPlot2d_Curve;
 class Plot2d_ViewFrame;
 class SalomeApp_Study;
 class SalomeApp_Application;
+class VISU_ActorBase;
 
 namespace VISU 
 {
@@ -68,6 +71,18 @@ namespace VISU
   VISU_I_EXPORT void                                 CreatePlot( VISU_Gen_i*,
                                                                  Plot2d_ViewFrame*,
                                                                  _PTR(SObject) theTableSO );
+
+  VISU_I_EXPORT void                                 SetVisibilityState(std::string entry, Qtx::VisibilityState state);
+  VISU_I_EXPORT void                                 SetVisibilityState(VISU_ActorBase *theActor, Qtx::VisibilityState state);
+
+  VISU_I_EXPORT void                                 CurveVisibilityChanged(VISU::Curve_i* theCurve, 
+                                                                           int theDisplaying,
+                                                                           bool updateCurve,
+                                                                           bool updateTable,
+                                                                           bool updateContainers);
+
+  VISU_I_EXPORT Qtx::VisibilityState                 GetStateByDisplaying(int theDisplaying);
+  VISU_I_EXPORT void                                 updateContainerVisibility(VISU::Container_i* theContainer);
 }
 
 #endif
index e591ba5a71446432c430f8e3c6c3367a4cc9e0e9..cc1df8951a20093cdae537a078efeaf5548027d3 100644 (file)
@@ -29,6 +29,7 @@
 #include "VISU_View_i.hh"
 #include "VISU_Prs3d_i.hh"
 #include "VISU_Table_i.hh"
+#include "VISU_Tools.h"
 
 #include "VISU_Actor.h"
 #include "VISU_ActorFactory.h"
@@ -301,15 +302,23 @@ namespace VISU {
         anVISUActor = VISU_Actor::SafeDownCast(anActor);
         if (thePrs == anVISUActor->GetPrs3d()) {
           aResActor = anVISUActor;
-          if(theDisplaing < eErase)
+          if(theDisplaing < eErase) {
             aResActor->VisibilityOn();
-          else
+           VISU::SetVisibilityState(aResActor, Qtx::ShownState);
+         }
+          else {
             aResActor->VisibilityOff();
+           VISU::SetVisibilityState(aResActor, Qtx::HiddenState);
+         }
         } else {
-          if(theDisplaing == eEraseAll || theDisplaing == eDisplayOnly)
+          if(theDisplaing == eEraseAll || theDisplaing == eDisplayOnly) {
             anVISUActor->VisibilityOff();
-          else if ( theDisplaing == eDisplayAll )
+           VISU::SetVisibilityState(aResActor, Qtx::HiddenState);
+         }
+          else if ( theDisplaing == eDisplayAll ) {
             anVISUActor->VisibilityOn();
+           VISU::SetVisibilityState(aResActor, Qtx::HiddenState);
+         }
         }
       }
     }
index 51aed177ea7e205fae2fcae2834bc61fcf47bc62..d80850e79a849f5cf9f1cfc9a0927115c42cbaa2 100644 (file)
@@ -26,6 +26,7 @@
 //  Module : VISU
 //
 #include "VISU_View_i.hh"
+#include "VISU_Tools.h"
 
 #include "VISU_Gen_i.hh"
 #include "VISU_Prs3d_i.hh"
@@ -1334,17 +1335,23 @@ namespace VISU {
 
     virtual void Execute()
     {
+      Qtx::VisibilityState state = (myDisplaing == eDisplay ||myDisplaing == eDisplayOnly) ?
+       Qtx::ShownState : Qtx::HiddenState;
       // is it Curve ?
       if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
        UpdatePlot2d(aCurve,myDisplaing,myView);
+       VISU::SetVisibilityState(aCurve->GetEntry(),state);
+       VISU::CurveVisibilityChanged(aCurve, myDisplaing , false, true, true);
       }
       // is it Container ?
       if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
+       VISU::SetVisibilityState(aContainer->GetEntry(),state);
        int nbCurves = aContainer->GetNbCurves();
        for ( int i = 1; i <= nbCurves; i++ ) {
          VISU::Curve_i* aCurve = aContainer->GetCurve( i );
          if ( aCurve && aCurve->IsValid() ) {
            UpdatePlot2d(aCurve,myDisplaing,myView);
+           VISU::CurveVisibilityChanged(aCurve, myDisplaing , true, true, true);
          }
        }
        myView->Repaint();
@@ -1365,12 +1372,15 @@ namespace VISU {
            CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
            if (!CORBA::is_nil(childObject)) {
              CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
-             if (!CORBA::is_nil(aCurve))
-               UpdatePlot2d(dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()),
-                             myDisplaing, myView);
+             if (!CORBA::is_nil(aCurve)) {
+               Curve_i* crv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
+               UpdatePlot2d(crv, myDisplaing, myView);
+               VISU::CurveVisibilityChanged(crv, myDisplaing , true, false, true);
+             }
            }
          }
          myView->Repaint();
+         VISU::SetVisibilityState(aTable->GetEntry(),state);
        }
       }
     }