+
+void GEOMToolsGUI::OnBringToFront() {
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if ( !app )
+ return;
+
+ SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
+ if(!mod)
+ return;
+
+ GEOM_Displayer* disp = dynamic_cast<GEOM_Displayer*>(mod->displayer());
+
+ if(!disp)
+ return;
+
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ if ( !aSelMgr )
+ return;
+
+ SALOME_ListIO selected;
+ aSelMgr->selectedObjects( selected );
+ if ( selected.IsEmpty() )
+ return;
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+ if(!appStudy)
+ return;
+
+ SUIT_ViewWindow* window = app->desktop()->activeWindow();
+
+ OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+ if ( !vm )
+ return;
+
+ bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+
+ QAction* a = getGeometryGUI()->action( GEOMOp::OpBringToFront );
+ bool checked = a->isChecked();
+
+ if ( isOCC ) {
+ GEOMBase* gb = new GEOMBase();
+ Handle(GEOM_AISShape) aisShape;
+
+ Handle(AIS_InteractiveContext) ic = vm->getAISContext();
+ SALOME_ListIO anIOlst;
+ for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+ aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
+ if ( !aisShape.IsNull() ) {
+ aisShape->setTopLevel(checked);
+ int aMgrId = window->getViewManager()->getGlobalId();
+ appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), TOP_LEVEL_PROP, checked );
+ anIOlst.Append(aisShape->getIO());
+ }
+ } // for...
+ disp->Redisplay(anIOlst);
+ GeometryGUI::Modified();
+ } // if ( isOCC )
+}
+
+void GEOMToolsGUI::OnClsBringToFront() {
+ SalomeApp_Application* app =
+ dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if(!app)
+ return;
+
+ SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
+ if(!mod)
+ return;
+
+ GEOM_Displayer* disp = dynamic_cast<GEOM_Displayer*>(mod->displayer());
+
+ if(!disp)
+ return;
+
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+ if(!appStudy)
+ return;
+
+ SUIT_ViewWindow* window = app->desktop()->activeWindow();
+
+ bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+
+ if(isOCC){ // if is OCCViewer
+
+ OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+ Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+
+ SALOME_ListIO anIOlst;
+ AIS_ListOfInteractive aList;
+ ic->DisplayedObjects( aList );
+ for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() ) {
+
+ Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(it.Value());
+
+ if(CurObject.IsNull())
+ continue;
+
+ CurObject->setTopLevel(Standard_False);
+
+ int aMgrId = window->getViewManager()->getGlobalId();
+ appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), TOP_LEVEL_PROP, Standard_False );
+ anIOlst.Append(CurObject->getIO());
+ }
+ disp->Redisplay(anIOlst);
+ GeometryGUI::Modified();
+ }
+}
+