From: rnv Date: Mon, 28 Feb 2011 09:01:53 +0000 (+0000) Subject: Implementation of the issue "20830: EDF 1357 GUI : Hide/Show Icon" for Post-Pro module. X-Git-Tag: V6_main_20110301~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b401dfdc191dcda77d46bec7030fb7b77f29a06e;p=modules%2Fvisu.git Implementation of the issue "20830: EDF 1357 GUI : Hide/Show Icon" for Post-Pro module. --- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index c564c948..b09336a6 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -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(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; diff --git a/src/VISUGUI/VisuGUI_Displayer.cxx b/src/VISUGUI/VisuGUI_Displayer.cxx index bfa420ad..cad7276a 100644 --- a/src/VISUGUI/VisuGUI_Displayer.cxx +++ b/src/VISUGUI/VisuGUI_Displayer.cxx @@ -34,6 +34,8 @@ #include "VISU_ViewManager_i.hh" #include "VISU_Actor.h" +#include + //#include "VVTK_ViewModel.h" #include @@ -50,6 +52,49 @@ #include #include + + +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::GetServant( anObj ).in()) ) { + VISU::CurveVisibilityChanged(aCurve,theDisplaying, false, true, true); + } + + if(VISU::Container_i* aContainer = dynamic_cast( 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::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::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( 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::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::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::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(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::GetServant( anObj ).in() ) - || - dynamic_cast( VISU::GetServant( anObj ).in() ) ) + if( (dynamic_cast( VISU::GetServant( anObj ).in() ) + || + dynamic_cast( 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( myApp->activeStudy())); +} + +void VisuGUI_Displayer::AfterErase( SALOME_View* vf, const SALOME_Plot2dViewType& ) { + changeVisibility(VISU::eErase, myLastEntry,dynamic_cast( myApp->activeStudy())); +} diff --git a/src/VISUGUI/VisuGUI_Displayer.h b/src/VISUGUI/VisuGUI_Displayer.h index 8111373a..14a1a4a8 100644 --- a/src/VISUGUI/VisuGUI_Displayer.h +++ b/src/VISUGUI/VisuGUI_Displayer.h @@ -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; diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index bd7f27e2..bedc52e0 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -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 diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 91b9e908..343da087 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -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(theModule->application()); + if(!anApp) + return anActor; + + SalomeApp_Study* aStudy = dynamic_cast(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; } //------------------------------------------------------------ diff --git a/src/VISUGUI/VisuGUI_ViewTools.cxx b/src/VISUGUI/VisuGUI_ViewTools.cxx index 7e455698..62ee8b6a 100644 --- a/src/VISUGUI/VisuGUI_ViewTools.cxx +++ b/src/VISUGUI/VisuGUI_ViewTools.cxx @@ -32,8 +32,12 @@ #include "SVTK_ViewModel.h" #include "SVTK_ViewWindow.h" +#include + #include +#include + 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(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(theBase)) + if (VISU::Curve_i* aCurve = dynamic_cast(theBase)) { PlotCurve(theModule, aCurve, VISU::eErase ); + updateState = false; + } break; } case VISU::TCONTAINER: { - if (VISU::Container_i* aContainer = dynamic_cast(theBase)) + if (VISU::Container_i* aContainer = dynamic_cast(theBase)) { PlotContainer(theModule, aContainer, VISU::eErase ); + updateState = false; + } break; } case VISU::TTABLE: { - if (VISU::Table_i* aTable = dynamic_cast(theBase)) + if (VISU::Table_i* aTable = dynamic_cast(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(theBase)) + if (VISU::Table_i* aTable = dynamic_cast(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(theBase)) { + SalomeApp_Application* anApp = dynamic_cast(theModule->application()); + if(anApp) { + SalomeApp_Study* aStudy = dynamic_cast(anApp->activeStudy()); + std::string entry = obj->GetEntry(); + if(aStudy && !entry.empty()) + aStudy->setVisibilityState(QString(entry.c_str()), Qtx::HiddenState); + } + } + } } - } diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index 0ab3f334..0fe836c4 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -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 -#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)); } diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 22166fd5..9dc035e9 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -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()); } } } diff --git a/src/VISU_I/VISU_Table_i.hh b/src/VISU_I/VISU_Table_i.hh index 3db4f3b5..36f4b1c8 100644 --- a/src/VISU_I/VISU_Table_i.hh +++ b/src/VISU_I/VISU_Table_i.hh @@ -31,6 +31,7 @@ #include "VISU_PrsObject_i.hh" #include +#include class SPlot2d_Curve; @@ -95,6 +96,9 @@ namespace VISU{ bool theFirstStrAsTitle = false); bool ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName); //============================================================================== + + typedef QSet 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; } diff --git a/src/VISU_I/VISU_Tools.cxx b/src/VISU_I/VISU_Tools.cxx index 1b33516f..d17a33ec 100644 --- a/src/VISU_I/VISU_Tools.cxx +++ b/src/VISU_I/VISU_Tools.cxx @@ -27,14 +27,20 @@ #include "VISU_Table_i.hh" #include "VISU_ViewManager_i.hh" +#include + +#include + #include #include +#include #include #include #include #include +#include //============================================================================= 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(aSession->activeApplication()) ) + if( SalomeApp_Study* aStudy = dynamic_cast(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(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(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(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::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(anApp->activeStudy()) ) { + if(LightApp_Displayer* aDisplayer = (dynamic_cast(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::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(aSession->activeApplication()) ) { + if( SalomeApp_Study* aStudy = dynamic_cast(anApp->activeStudy()) ) { + Qtx::VisibilityState state = Qtx::UnpresentableState; + int nbCurves = theContainer->GetNbCurves(); + if( nbCurves > 0 ) { + if(LightApp_Displayer* aDisplayer = (dynamic_cast(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); + } + } + } + } } diff --git a/src/VISU_I/VISU_Tools.h b/src/VISU_I/VISU_Tools.h index a0ec2b53..b0740bd9 100644 --- a/src/VISU_I/VISU_Tools.h +++ b/src/VISU_I/VISU_Tools.h @@ -27,12 +27,15 @@ #include "VISUConfig.hh" #include "VISU_I.hxx" +#include + #include 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 diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index e591ba5a..cc1df895 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -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); + } } } } diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index 51aed177..d80850e7 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -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(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(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::GetServant(aCurve).in()), - myDisplaing, myView); + if (!CORBA::is_nil(aCurve)) { + Curve_i* crv = dynamic_cast(VISU::GetServant(aCurve).in()); + UpdatePlot2d(crv, myDisplaing, myView); + VISU::CurveVisibilityChanged(crv, myDisplaing , true, false, true); + } } } myView->Repaint(); + VISU::SetVisibilityState(aTable->GetEntry(),state); } } }