1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : GEOMToolsGUI_1.cxx
25 // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
27 #include <PyConsole_Console.h>
29 #include "GEOMToolsGUI.h"
30 #include "GEOMToolsGUI_TransparencyDlg.h"
31 #include "GEOMToolsGUI_NbIsosDlg.h"
32 #include "GEOMToolsGUI_DeflectionDlg.h"
33 #include "GEOMToolsGUI_MarkerDlg.h"
34 #include "GEOMToolsGUI_PublishDlg.h"
35 #include "GEOMToolsGUI_MaterialPropertiesDlg.h"
36 #include "GEOMToolsGUI_LineWidthDlg.h"
37 #include "Material_Model.h"
39 #include <GeometryGUI.h>
40 #include <GeometryGUI_Operations.h>
41 #include <GEOM_Constants.h>
42 #include <GEOM_Displayer.h>
45 #include <GEOM_Actor.h>
47 #include <Basics_OCCTVersion.hxx>
49 #include <SALOME_ListIO.hxx>
50 #include <SALOME_ListIteratorOfListIO.hxx>
55 #include <SVTK_ViewModel.h>
56 #include <SVTK_ViewWindow.h>
57 #include <SVTK_View.h>
59 #include <OCCViewer_ViewModel.h>
61 #include <SUIT_ViewManager.h>
62 #include <SUIT_Desktop.h>
63 #include <SUIT_ResourceMgr.h>
64 #include <SUIT_Session.h>
65 #include <SUIT_OverrideCursor.h>
66 #include <SUIT_MessageBox.h>
67 #include <SUIT_Tools.h>
69 #include <SalomeApp_Application.h>
70 #include <SalomeApp_Study.h>
71 #include <SalomeApp_Module.h>
73 #include <LightApp_SelectionMgr.h>
74 #include <LightApp_NameDlg.h>
76 #include <GEOMImpl_Types.hxx>
78 #include "utilities.h"
81 #include <AIS_Drawer.hxx>
82 #include <Prs3d_IsoAspect.hxx>
83 #include <Prs3d_PointAspect.hxx>
84 #include <Graphic3d_AspectMarker3d.hxx>
85 #include <Graphic3d_AspectLine3d.hxx>
86 #include <AIS_ListIteratorOfListOfInteractive.hxx>
87 #include <AIS_ListOfInteractive.hxx>
90 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
91 #include <TColStd_HArray1OfByte.hxx>
93 #include <Graphic3d_HArray1OfBytes.hxx>
98 #include <QColorDialog>
99 #include <QInputDialog>
100 #include <QFileDialog>
103 #include <QGridLayout>
106 #include <QPushButton>
110 #include <vtkRenderer.h>
112 void GEOMToolsGUI::OnCheckGeometry()
114 SalomeApp_Application* app =
115 dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication());
116 PyConsole_Console* pyConsole = app->pythonConsole();
119 pyConsole->exec("from GEOM_usinggeom import *");
122 void GEOMToolsGUI::OnAutoColor()
124 SALOME_ListIO selected;
125 SalomeApp_Application* app =
126 dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication());
130 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
131 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
132 if (!aSelMgr || !appStudy)
135 aSelMgr->selectedObjects(selected);
136 if (selected.IsEmpty())
139 Handle(SALOME_InteractiveObject) anIObject = selected.First();
141 _PTR(Study) aStudy = appStudy->studyDS();
142 _PTR(SObject) aMainSObject(aStudy->FindObjectID(anIObject->getEntry()));
143 GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
144 if (CORBA::is_nil(aMainObject))
147 aMainObject->SetAutoColor( true );
149 QList<SALOMEDS::Color> aReservedColors;
151 GEOM_Displayer aDisp (appStudy);
153 SALOME_View* vf = aDisp.GetActiveView();
155 SUIT_ViewWindow* window = app->desktop()->activeWindow();
156 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
157 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
159 for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); it->More(); it->Next() )
161 _PTR(SObject) aChildSObject( it->Value() );
162 GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
163 if( CORBA::is_nil( aChildObject ) )
166 if( aChildObject->GetType() != GEOM_GROUP )
169 SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
170 aChildObject->SetColor( aColor );
171 aReservedColors.append( aColor );
173 QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
175 SALOME_Prs* aPrs = vf->CreatePrs( aChildSObject->GetID().c_str() );
179 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
182 SVTK_View* aView = vtkVW->getView();
183 SUIT_OverrideCursor();
184 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
185 aView->SetColor( It.Value(), c );
189 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
190 Handle(AIS_InteractiveContext) ic = vm->getAISContext();
192 SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
196 AIS_ListOfInteractive aList;
197 anOCCPrs->GetObjects( aList );
198 if( !aList.Extent() )
201 Handle(AIS_InteractiveObject) io = aList.First();
205 Quantity_Color aQuanColor( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
207 // Set color for a point
208 Handle(AIS_Drawer) aCurDrawer = io->Attributes();
209 Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
210 Quantity_Color aCurColor;
211 Standard_Real aCurScale;
212 Aspect_TypeOfMarker aCurTypeOfMarker;
213 aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
214 if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
215 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aQuanColor, aCurScale) );
218 Standard_Integer aWidth, aHeight;
219 aCurPointAspect->GetTextureSize( aWidth, aHeight );
221 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
222 Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture();
224 Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
227 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aQuanColor, 1, aWidth, aHeight, aTexture ) );
229 ic->SetLocalAttributes( io, aCurDrawer );
231 io->SetColor( aQuanColor );
232 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
233 Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
234 aGAISShape->SetShadingColor( aQuanColor );
235 aGAISShape->storeBoundaryColors();
238 io->Redisplay( Standard_True );
242 app->updateActions(); //SRN: To update a Save button in the toolbar
245 void GEOMToolsGUI::OnDisableAutoColor()
247 SALOME_ListIO selected;
248 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
252 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
253 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
254 if( !aSelMgr || !appStudy )
257 aSelMgr->selectedObjects( selected );
258 if( selected.IsEmpty() )
261 Handle(SALOME_InteractiveObject) anIObject = selected.First();
263 _PTR(Study) aStudy = appStudy->studyDS();
264 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
265 GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
266 if( CORBA::is_nil( aMainObject ) )
269 aMainObject->SetAutoColor( false );
273 void GEOMToolsGUI::OnColor()
275 SALOME_ListIO selected;
276 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
277 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
278 if ( app && appStudy ) {
279 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
281 aSelMgr->selectedObjects( selected );
282 if ( !selected.IsEmpty() ) {
283 SUIT_ViewWindow* window = app->desktop()->activeWindow();
284 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
285 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
286 int mgrId = window->getViewManager()->getGlobalId();
288 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
291 SVTK_View* aView = vtkVW->getView();
292 QColor initcolor = aView->GetColor( selected.First() );
293 QColor c = QColorDialog::getColor( initcolor, app->desktop() );
295 SUIT_OverrideCursor();
296 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
298 matProp = appStudy->getObjectProperty(mgrId,It.Value()->getEntry(), MATERIAL_PROP, matProp).toString();
299 Material_Model material;
300 material.fromProperties( matProp );
301 if ( !material.isPhysical() ) {
302 aView->SetColor( It.Value(), c );
303 appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
305 // store color to GEOM_Object
306 _PTR(Study) aStudy = appStudy->studyDS();
307 _PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
308 GEOM::GEOM_Object_var anObject =
309 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
310 SALOMEDS::Color aSColor;
311 aSColor.R = (double)c.red() / 255.0;
312 aSColor.G = (double)c.green() / 255.0;
313 aSColor.B = (double)c.blue() / 255.0;
314 anObject->SetColor( aSColor );
315 anObject->SetAutoColor( false );
317 GeometryGUI::Modified();
321 Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
322 if ( !io.IsNull() ) {
323 Quantity_Color aColor;
325 QColor ic = QColor((int )( aColor.Red() * 255.0 ),
326 (int)( aColor.Green() * 255.0 ),
327 (int)( aColor.Blue() * 255.0 ));
329 QVariant v = appStudy->getObjectProperty(mgrId,selected.First()->getEntry(), COLOR_PROP, ic);
331 QColor initcolor = v.value<QColor>();
332 QColor c = QColorDialog::getColor( initcolor, app->desktop() );
334 SUIT_OverrideCursor();
335 aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
336 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
337 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
338 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
340 matProp = appStudy->getObjectProperty(mgrId,It.Value()->getEntry(), MATERIAL_PROP, matProp).toString();
341 Material_Model material;
342 material.fromProperties( matProp );
343 io = GEOMBase::GetAIS( It.Value(), true );
344 if ( !io.IsNull() && !material.isPhysical() ) { // change color only for shapes with not physical type of material
346 if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) {
347 TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
348 bool onlyVertex = (theShape.ShapeType() == TopAbs_VERTEX || GEOM_Displayer::isCompoundOfVertices( theShape ));
350 // Set color for a point
352 Handle(AIS_Drawer) aCurDrawer = io->Attributes();
353 Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
354 Quantity_Color aCurColor;
355 Standard_Real aCurScale;
356 Aspect_TypeOfMarker aCurTypeOfMarker;
357 aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
358 if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
359 aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aCurTypeOfMarker, aColor, aCurScale));
362 Standard_Integer aWidth, aHeight;
363 aCurPointAspect->GetTextureSize( aWidth, aHeight );
365 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
366 Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture();
368 Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
371 aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aColor, 1, aWidth, aHeight, aTexture));
373 ic->SetLocalAttributes(io, aCurDrawer, Standard_False);
377 io->SetColor( aColor );
378 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
379 Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
380 aGAISShape->SetShadingColor( aColor );
381 aGAISShape->storeBoundaryColors();
384 appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
386 io->Redisplay( Standard_True );
388 // store color to GEOM_Object
389 _PTR(Study) aStudy = appStudy->studyDS();
390 _PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
391 GEOM::GEOM_Object_var anObject =
392 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
395 SALOMEDS::Color aSColor;
396 aSColor.R = (double)c.red() / 255.0;
397 aSColor.G = (double)c.green() / 255.0;
398 aSColor.B = (double)c.blue() / 255.0;
399 anObject->SetColor( aSColor );
400 anObject->SetAutoColor( false );
403 ic->UpdateCurrentViewer();
404 GeometryGUI::Modified();
406 } // first IO is not null
408 } // if ( selection not empty )
412 app->updateActions(); //SRN: To update a Save button in the toolbar
415 void GEOMToolsGUI::OnTexture()
417 SALOME_ListIO selected;
418 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
419 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
420 if ( app && appStudy ) {
421 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
423 aSelMgr->selectedObjects( selected );
424 if ( !selected.IsEmpty() ) {
425 SUIT_ViewWindow* window = app->desktop()->activeWindow();
426 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
428 QString aTexture = QFileDialog::getOpenFileName(window,tr( "GEOM_SELECT_IMAGE"),QString(), tr("OCC_TEXTURE_FILES"));
429 if( !aTexture.isEmpty() )
431 SUIT_OverrideCursor();
432 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
433 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
434 Handle(AIS_InteractiveObject) io ;
435 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
436 io = GEOMBase::GetAIS( It.Value(), true );
437 if ( !io.IsNull() ) {
438 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
439 Handle(GEOM_AISShape)::DownCast( io )->SetTextureFileName(TCollection_AsciiString(aTexture.toStdString().c_str()));
440 io->Redisplay( Standard_True );
441 } // if ( !io.IsNull() )
443 ic->UpdateCurrentViewer();
444 GeometryGUI::Modified();
445 GeometryGUI* myGeomGUI = getGeometryGUI();
446 myGeomGUI->OnGUIEvent(GEOMOp::OpTexture);
447 } // if ( !selFile.isEmpty() )
449 } // if ( selection not empty )
453 app->updateActions(); //SRN: To update a Save button in the toolbar
456 void GEOMToolsGUI::OnTransparency()
458 GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
462 void GEOMToolsGUI::OnChangeTransparency( bool increase )
464 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
467 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
470 SALOME_ListIO selected;
471 aSelMgr->selectedObjects( selected );
472 if ( selected.IsEmpty() )
475 Handle(SALOME_InteractiveObject) FirstIOS = selected.First();
476 if ( FirstIOS.IsNull() )
480 float delta = 0.1; // VSR: 23/11/2010 (transparency value <= 0.05 is ignored)
484 SUIT_ViewWindow* window = app->desktop()->activeWindow();
485 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
486 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
489 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
492 SVTK_View* aView = vtkVW->getView();
494 float transp = aView->GetTransparency(FirstIOS);
496 // Compute new transparency value
497 transp = transp + delta;
500 else if ( transp > 1 )
503 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
504 aView->SetTransparency( It.Value(), transp );
507 GeometryGUI::Modified();
511 GEOMBase* gb = new GEOMBase();
512 Handle(GEOM_AISShape) aisShape;
514 aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS, true );
515 if( aisShape.IsNull() )
517 float transp = aisShape->Transparency();
519 // Compute new transparency value
520 transp = transp + delta;
523 else if ( transp > 1 )
526 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
529 Handle(AIS_InteractiveContext) ic = vm->getAISContext();
530 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
531 aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
532 if ( !aisShape.IsNull() ) {
533 ic->SetTransparency( aisShape, transp, false );
534 ic->Redisplay( aisShape, Standard_False, Standard_True );
537 ic->UpdateCurrentViewer();
538 GeometryGUI::Modified();
542 void GEOMToolsGUI::OnNbIsos( ActionType actionType )
544 SalomeApp_Application* app =
545 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
546 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
547 SUIT_ViewWindow* window = app->desktop()->activeWindow();
549 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
550 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
552 if(isOCC){ // if is OCCViewer
554 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
555 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
558 if ( ic->MoreCurrent() ) {
559 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
560 CurObject->restoreIsoNumbers();
561 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
563 int UIso = CurDrawer->UIsoAspect()->Number();
564 int VIso = CurDrawer->VIsoAspect()->Number();
569 if ( actionType == SHOWDLG ) {
570 GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
571 new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
573 NbIsosDlg->setU( UIso );
574 NbIsosDlg->setV( VIso );
576 if ( NbIsosDlg->exec() ) {
577 SUIT_OverrideCursor();
579 newNbUIso = NbIsosDlg->getU();
580 newNbVIso = NbIsosDlg->getV();
584 else if ( actionType == INCR || actionType == DECR ) {
586 if (actionType == DECR)
589 newNbUIso = UIso + delta;
590 newNbVIso = VIso + delta;
592 if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
596 for(; ic->MoreCurrent(); ic->NextCurrent()) {
597 int aMgrId = window->getViewManager()->getGlobalId();
598 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
600 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
602 QVariant v = aStudy->getObjectProperty( aMgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP , QVariant() );
604 int width = v.isValid() ? v.toInt() : 1;
606 CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width , newNbUIso) );
607 CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width , newNbVIso) );
609 CurObject->storeIsoNumbers();
611 ic->SetLocalAttributes(CurObject, CurDrawer);
612 ic->Redisplay(CurObject);
614 QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
615 aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_PROP, anIsos);
618 GeometryGUI::Modified();
620 else if(isVTK){ // if is VTKViewer
622 // Warning. It's works incorrect. must be recheked.
624 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >
625 ( SUIT_Session::session()->activeApplication() );
628 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
631 SALOME_ListIO selected;
632 aSelMgr->selectedObjects( selected );
633 if ( selected.IsEmpty() )
636 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
640 SALOME_View* view = GEOM_Displayer::GetActiveView();
642 vtkActorCollection* aCollection = vtkActorCollection::New();
644 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
645 Handle(SALOME_InteractiveObject) anIObject = It.Value();
646 SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() );
647 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
649 vtkActorCollection* anActors = vtkPrs->GetObjects();
650 anActors->InitTraversal();
651 vtkActor* anAct = anActors->GetNextActor();
652 aCollection->AddItem(anAct);
657 aCollection->InitTraversal();
664 vtkActor* anAct = aCollection->GetNextActor();
665 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
666 anActor->RestoreIsoNumbers();
667 anActor->GetNbIsos(UIso,VIso);
675 if ( actionType == SHOWDLG ) {
676 GEOMToolsGUI_NbIsosDlg* NbIsosDlg =
677 new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
679 NbIsosDlg->setU( UIso );
680 NbIsosDlg->setV( VIso );
682 if ( NbIsosDlg->exec() ) {
683 SUIT_OverrideCursor();
685 newNbUIso = NbIsosDlg->getU();
686 newNbVIso = NbIsosDlg->getV();
688 return; //Cancel case
690 else if ( actionType == INCR || actionType == DECR ) {
692 if (actionType == DECR)
695 newNbUIso = UIso + delta;
696 newNbVIso = VIso + delta;
698 if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
702 while( anAct!=NULL ) {
703 if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){
704 // There are no casting to needed actor.
705 int aIsos[2]={newNbUIso,newNbVIso};
706 anActor->SetNbIsos(aIsos);
707 anActor->StoreIsoNumbers();
709 QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
710 int aMgrId = window->getViewManager()->getGlobalId();
711 aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_PROP, anIsos);
713 anAct = aCollection->GetNextActor();
716 GeometryGUI::Modified();
720 void GEOMToolsGUI::OnDeflection()
722 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
723 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
726 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
727 bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
728 int mgrId = window->getViewManager()->getGlobalId();
730 if (isOCC) { // if is OCCViewer
731 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
732 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
735 if (ic->MoreCurrent()) {
736 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
738 Standard_Real aDC, aPrevDC;
739 Standard_Boolean isOwnDC = CurObject->OwnDeviationCoefficient(aDC, aPrevDC);
741 aDC = ic->DeviationCoefficient();
743 GEOMToolsGUI_DeflectionDlg * DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
744 (SUIT_Session::session()->activeApplication()->desktop());
745 DeflectionDlg->setTheDC(aDC);
749 if (DeflectionDlg->exec()) {
750 SUIT_OverrideCursor();
751 aNewDC = DeflectionDlg->getTheDC();
752 ok = (1e-07 <= aNewDC && aNewDC <= 1.0); // spinbox can return zero
754 for (; ic->MoreCurrent(); ic->NextCurrent()) {
755 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
756 ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True);
757 ic->Redisplay(CurObject);
758 appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aNewDC);
767 GeometryGUI::Modified();
769 else if (isVTK) { // if is VTKViewer
770 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
771 (SUIT_Session::session()->activeApplication());
775 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
779 SALOME_ListIO selected;
780 aSelMgr->selectedObjects(selected);
781 if (selected.IsEmpty())
784 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
788 SALOME_View* view = GEOM_Displayer::GetActiveView();
790 vtkActorCollection* aCollection = vtkActorCollection::New();
792 for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
793 Handle(SALOME_InteractiveObject) anIObject = It.Value();
794 SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
795 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
797 vtkActorCollection* anActors = vtkPrs->GetObjects();
798 anActors->InitTraversal();
799 vtkActor* anAct = anActors->GetNextActor();
800 aCollection->AddItem(anAct);
805 aCollection->InitTraversal();
811 vtkActor* anAct = aCollection->GetNextActor();
812 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
813 aDC = anActor->GetDeflection();
817 GEOMToolsGUI_DeflectionDlg* DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
818 (SUIT_Session::session()->activeApplication()->desktop());
819 DeflectionDlg->setTheDC(aDC);
820 if (DeflectionDlg->exec()) {
821 SUIT_OverrideCursor();
822 aDC = DeflectionDlg->getTheDC();
823 while (anAct != NULL) {
824 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
825 // There are no casting to needed actor.
826 anActor->SetDeflection(aDC);
827 appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
829 anAct = aCollection->GetNextActor();
832 GeometryGUI::Modified();
836 void GEOMToolsGUI::OnSelectOnly(int mode)
838 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
840 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
841 GEOM_Displayer aDisp (appStudy);
842 aDisp.GlobalSelection(mode);
843 getGeometryGUI()->setLocalSelectionMode(mode);
847 void GEOMToolsGUI::OnShowHideChildren( bool show )
849 SALOME_ListIO selected;
850 SalomeApp_Application* app =
851 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
853 SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
855 GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
858 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
859 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
860 if ( aSelMgr && appStudy ) {
861 aSelMgr->selectedObjects( selected );
862 if ( !selected.IsEmpty() ) {
863 _PTR(Study) aStudy = appStudy->studyDS();
864 _PTR(StudyBuilder) B = aStudy->NewBuilder();
866 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
868 SUIT_MessageBox::warning( app->desktop(),
869 QObject::tr( "WRN_WARNING" ),
870 QObject::tr( "WRN_STUDY_LOCKED" ) );
874 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
875 Handle(SALOME_InteractiveObject) IObject = It.Value();
877 _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
878 _PTR(GenericAttribute) anAttr;
880 _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
881 aExp->SetExpandable( show );
883 disp->EraseWithChildren(IObject,true);
888 app->updateObjectBrowser( false );
889 app->updateActions();
893 void GEOMToolsGUI::OnPointMarker()
895 GEOMToolsGUI_MarkerDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
899 void GEOMToolsGUI::OnMaterialProperties()
901 GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
905 void GEOMToolsGUI::OnUnpublishObject() {
906 SALOME_ListIO selected;
907 SalomeApp_Application* app =
908 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
910 SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
912 GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
915 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
916 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
917 if ( aSelMgr && appStudy ) {
918 aSelMgr->selectedObjects( selected );
919 if ( !selected.IsEmpty() ) {
920 _PTR(Study) aStudy = appStudy->studyDS();
921 _PTR(StudyBuilder) B = aStudy->NewBuilder();
923 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
925 SUIT_MessageBox::warning( app->desktop(),
926 QObject::tr( "WRN_WARNING" ),
927 QObject::tr( "WRN_STUDY_LOCKED" ) );
931 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
932 Handle(SALOME_InteractiveObject) IObject = It.Value();
934 _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
935 _PTR(GenericAttribute) anAttr;
937 _PTR(AttributeDrawable) aDrw = B->FindOrCreateAttribute( obj, "AttributeDrawable" );
938 aDrw->SetDrawable( false );
939 disp->EraseWithChildren(IObject);
942 aSelMgr->clearSelected();
945 app->updateObjectBrowser( false );
946 app->updateActions();
951 void GEOMToolsGUI::OnPublishObject() {
952 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
956 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
960 _PTR(Study) aStudy = appStudy->studyDS();
965 //Check lock of the study
966 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
968 SUIT_MessageBox::warning( app->desktop(),
969 QObject::tr( "WRN_WARNING" ),
970 QObject::tr( "WRN_STUDY_LOCKED" ) );
974 GEOMToolsGUI_PublishDlg * publishDlg =
975 new GEOMToolsGUI_PublishDlg( SUIT_Session::session()->activeApplication()->desktop() );
980 void GEOMToolsGUI::OnEdgeWidth()
982 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
983 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
986 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
987 bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
988 int mgrId = window->getViewManager()->getGlobalId();
990 if (isOCC) { // if is OCCViewer
991 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
992 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
993 SALOME_View* view = GEOM_Displayer::GetActiveView();
995 if (ic->MoreCurrent()) {
996 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
998 int aWidth = (int)CurObject->Width();
1000 GEOMToolsGUI_LineWidthDlg * Dlg = new GEOMToolsGUI_LineWidthDlg
1001 (SUIT_Session::session()->activeApplication()->desktop(),"EDGE_WIDTH_TLT");
1002 Dlg->setTheLW(aWidth);
1005 aNewWidth = Dlg->getTheLW();
1006 bool ok = (aNewWidth != aWidth && aNewWidth != 0 );
1008 for(; ic->MoreCurrent(); ic->NextCurrent()) {
1009 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
1010 SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>(view->CreatePrs(CurObject->getIO()->getEntry()));
1011 AIS_ListOfInteractive anAISObjects;
1012 aPrs->GetObjects( anAISObjects );
1013 AIS_ListIteratorOfListOfInteractive aIter( anAISObjects );
1014 for ( ; aIter.More(); aIter.Next() ) {
1015 Handle(SALOME_AISShape) cur = Handle(SALOME_AISShape)::DownCast(aIter.Value());
1016 if ( !cur.IsNull() ) {
1017 cur->SetWidth(aNewWidth);
1021 appStudy->setObjectProperty(mgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP, aNewWidth);
1029 GeometryGUI::Modified();
1031 else if (isVTK) { // if is VTKViewer
1032 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
1033 (SUIT_Session::session()->activeApplication());
1037 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
1041 SALOME_ListIO selected;
1042 aSelMgr->selectedObjects(selected);
1043 if (selected.IsEmpty())
1046 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
1050 SALOME_View* view = GEOM_Displayer::GetActiveView();
1052 vtkActorCollection* aCollection = vtkActorCollection::New();
1054 for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
1055 Handle(SALOME_InteractiveObject) anIObject = It.Value();
1056 SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
1057 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
1059 vtkActorCollection* anActors = vtkPrs->GetObjects();
1060 anActors->InitTraversal();
1061 vtkActor* anAct = anActors->GetNextActor();
1062 aCollection->AddItem(anAct);
1067 aCollection->InitTraversal();
1073 vtkActor* anAct = aCollection->GetNextActor();
1074 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
1075 aWidth = anActor->GetWidth();
1079 GEOMToolsGUI_LineWidthDlg * Dlg = new GEOMToolsGUI_LineWidthDlg
1080 (SUIT_Session::session()->activeApplication()->desktop(),"EDGE_WIDTH_TLT");
1082 Dlg->setTheLW(aWidth);
1084 SUIT_OverrideCursor();
1085 aWidth = Dlg->getTheLW();
1086 while (anAct != NULL) {
1087 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
1088 // There are no casting to needed actor.
1089 anActor->SetWidth(aWidth);
1090 appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), EDGE_WIDTH_PROP, aWidth);
1092 anAct = aCollection->GetNextActor();
1095 GeometryGUI::Modified();
1100 void GEOMToolsGUI::OnIsosWidth() {
1101 SalomeApp_Application* app =
1102 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1103 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1104 SUIT_ViewWindow* window = app->desktop()->activeWindow();
1106 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1107 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
1109 if(isOCC){ // if is OCCViewer
1111 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
1112 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
1115 if ( ic->MoreCurrent() ) {
1116 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
1117 CurObject->restoreIsoNumbers();
1118 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
1120 Handle(Graphic3d_AspectLine3d) asp = CurDrawer->UIsoAspect()->Aspect();
1123 Aspect_TypeOfLine T;
1127 int aWidth = (int)W;
1129 GEOMToolsGUI_LineWidthDlg * Dlg =
1130 new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(),"ISOS_WIDTH_TLT" );
1132 Dlg->setTheLW( aWidth );
1134 if ( Dlg->exec() ) {
1135 SUIT_OverrideCursor();
1136 aWidth = Dlg->getTheLW();
1137 } else //Cancel case
1140 for(; ic->MoreCurrent(); ic->NextCurrent()) {
1141 int aMgrId = window->getViewManager()->getGlobalId();
1142 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
1144 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
1146 CurObject->Attributes()->UIsoAspect()->SetWidth(aWidth);
1147 CurObject->Attributes()->VIsoAspect()->SetWidth(aWidth);
1149 ic->Redisplay(CurObject);
1151 aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth);
1153 GeometryGUI::Modified();
1156 else if(isVTK){ // if is VTKViewer
1158 // Warning. It's works incorrect. must be recheked.
1160 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >
1161 ( SUIT_Session::session()->activeApplication() );
1164 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
1167 SALOME_ListIO selected;
1168 aSelMgr->selectedObjects( selected );
1169 if ( selected.IsEmpty() )
1172 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
1176 SALOME_View* view = GEOM_Displayer::GetActiveView();
1178 vtkActorCollection* aCollection = vtkActorCollection::New();
1180 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
1181 Handle(SALOME_InteractiveObject) anIObject = It.Value();
1182 SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() );
1183 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
1185 vtkActorCollection* anActors = vtkPrs->GetObjects();
1186 anActors->InitTraversal();
1187 vtkActor* anAct = anActors->GetNextActor();
1188 aCollection->AddItem(anAct);
1193 aCollection->InitTraversal();
1199 vtkActor* anAct = aCollection->GetNextActor();
1200 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
1201 aWidth = anActor->GetIsosWidth();
1206 GEOMToolsGUI_LineWidthDlg* Dlg =
1207 new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), "ISOS_WIDTH_TLT" );
1209 Dlg->setTheLW( aWidth );
1211 SUIT_OverrideCursor();
1212 aWidth = Dlg->getTheLW();
1214 return; //Cancel case
1216 while( anAct!= NULL ) {
1217 if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
1218 // There are no casting to needed actor.
1219 anActor->SetIsosWidth(aWidth);
1220 int aMgrId = window->getViewManager()->getGlobalId();
1221 aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth);
1223 anAct = aCollection->GetNextActor();
1227 GeometryGUI::Modified();
1231 void GEOMToolsGUI::OnBringToFront() {
1232 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1236 SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
1240 GEOM_Displayer* disp = dynamic_cast<GEOM_Displayer*>(mod->displayer());
1245 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
1249 SALOME_ListIO selected;
1250 aSelMgr->selectedObjects( selected );
1251 if ( selected.IsEmpty() )
1254 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
1258 SUIT_ViewWindow* window = app->desktop()->activeWindow();
1260 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
1264 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1266 QAction* a = getGeometryGUI()->getAction( GEOMOp::OpBringToFront );
1267 bool checked = a->isChecked();
1270 GEOMBase* gb = new GEOMBase();
1271 Handle(GEOM_AISShape) aisShape;
1273 Handle(AIS_InteractiveContext) ic = vm->getAISContext();
1274 SALOME_ListIO anIOlst;
1275 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
1276 aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
1277 if ( !aisShape.IsNull() ) {
1278 aisShape->setTopLevel(checked);
1279 int aMgrId = window->getViewManager()->getGlobalId();
1280 appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), TOP_LEVEL_PROP, checked );
1281 anIOlst.Append(aisShape->getIO());
1284 disp->Redisplay(anIOlst);
1285 GeometryGUI::Modified();
1289 void GEOMToolsGUI::OnClsBringToFront() {
1290 SalomeApp_Application* app =
1291 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1295 SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
1299 GEOM_Displayer* disp = dynamic_cast<GEOM_Displayer*>(mod->displayer());
1305 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
1309 SUIT_ViewWindow* window = app->desktop()->activeWindow();
1311 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1313 if(isOCC){ // if is OCCViewer
1315 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
1316 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
1318 SALOME_ListIO anIOlst;
1319 AIS_ListOfInteractive aList;
1320 ic->DisplayedObjects( aList );
1321 for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() ) {
1323 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(it.Value());
1325 if(CurObject.IsNull())
1328 CurObject->setTopLevel(Standard_False);
1330 int aMgrId = window->getViewManager()->getGlobalId();
1331 appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), TOP_LEVEL_PROP, Standard_False );
1332 anIOlst.Append(CurObject->getIO());
1334 disp->Redisplay(anIOlst);
1335 GeometryGUI::Modified();