+
+ //------------------------------------------------------------
+ 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);
+ }
+ }
+ }
+ }