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 // If the next macro is defined, autocolor feature works for all sub-shapes;
113 // if it is undefined, autocolor feature works for groups only
114 //#define GENERAL_AUTOCOLOR
115 // Below macro, when uncommented, switches on simplified (more performant) algorithm
116 // of auto-color picking up
117 //#define SIMPLE_AUTOCOLOR
119 void GEOMToolsGUI::OnCheckGeometry()
121 SalomeApp_Application* app =
122 dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication());
123 PyConsole_Console* pyConsole = app->pythonConsole();
126 pyConsole->exec("from GEOM_usinggeom import *");
129 void GEOMToolsGUI::OnAutoColor()
131 SALOME_ListIO selected;
132 SalomeApp_Application* app =
133 dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication());
137 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
138 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
139 if (!aSelMgr || !appStudy)
142 aSelMgr->selectedObjects(selected);
143 if (selected.IsEmpty())
146 Handle(SALOME_InteractiveObject) anIObject = selected.First();
148 _PTR(Study) aStudy = appStudy->studyDS();
149 _PTR(SObject) aMainSObject(aStudy->FindObjectID(anIObject->getEntry()));
150 GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
151 if (CORBA::is_nil(aMainObject))
154 aMainObject->SetAutoColor( true );
156 QList<SALOMEDS::Color> aReservedColors;
158 GEOM_Displayer aDisp (appStudy);
160 SALOME_View* vf = aDisp.GetActiveView();
162 SUIT_ViewWindow* window = app->desktop()->activeWindow();
163 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
164 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
166 for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); it->More(); it->Next() )
168 _PTR(SObject) aChildSObject( it->Value() );
169 GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
170 if( CORBA::is_nil( aChildObject ) )
173 #ifndef GENERAL_AUTOCOLOR // auto-color for groups only
174 if( aChildObject->GetType() != GEOM_GROUP )
176 #endif // GENERAL_AUTOCOLOR
178 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
179 SALOMEDS::Color aColor = GEOM_Displayer::getPredefinedUniqueColor();
180 #else // old algorithm for auto-colors
181 SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
182 aReservedColors.append( aColor );
183 #endif // SIMPLE_AUTOCOLOR
184 aChildObject->SetColor( aColor );
186 QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
188 SALOME_Prs* aPrs = vf->CreatePrs( aChildSObject->GetID().c_str() );
192 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
195 SVTK_View* aView = vtkVW->getView();
196 SUIT_OverrideCursor();
197 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
198 aView->SetColor( It.Value(), c );
202 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
203 Handle(AIS_InteractiveContext) ic = vm->getAISContext();
205 SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
209 AIS_ListOfInteractive aList;
210 anOCCPrs->GetObjects( aList );
211 if( !aList.Extent() )
214 Handle(AIS_InteractiveObject) io = aList.First();
218 Quantity_Color aQuanColor( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
220 // Set color for a point
221 Handle(AIS_Drawer) aCurDrawer = io->Attributes();
222 Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
223 Quantity_Color aCurColor;
224 Standard_Real aCurScale;
225 Aspect_TypeOfMarker aCurTypeOfMarker;
226 aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
227 if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
228 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aQuanColor, aCurScale) );
231 Standard_Integer aWidth, aHeight;
232 aCurPointAspect->GetTextureSize( aWidth, aHeight );
234 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
235 Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture();
237 Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
240 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aQuanColor, 1, aWidth, aHeight, aTexture ) );
242 ic->SetLocalAttributes( io, aCurDrawer );
244 io->SetColor( aQuanColor );
245 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
246 Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
247 aGAISShape->SetShadingColor( aQuanColor );
248 aGAISShape->storeBoundaryColors();
251 io->Redisplay( Standard_True );
255 app->updateActions(); //SRN: To update a Save button in the toolbar
258 void GEOMToolsGUI::OnDisableAutoColor()
260 SALOME_ListIO selected;
261 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
265 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
266 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
267 if( !aSelMgr || !appStudy )
270 aSelMgr->selectedObjects( selected );
271 if( selected.IsEmpty() )
274 Handle(SALOME_InteractiveObject) anIObject = selected.First();
276 _PTR(Study) aStudy = appStudy->studyDS();
277 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
278 GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
279 if( CORBA::is_nil( aMainObject ) )
282 aMainObject->SetAutoColor( false );
285 void GEOMToolsGUI::SetColor( const QString& entry, const QColor& color, bool updateViewer )
287 if ( entry.isEmpty() || !color.isValid() ) return;
289 // get active application
290 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
294 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
295 if ( !appStudy ) return;
298 SUIT_ViewWindow* window = app->desktop()->activeWindow();
299 if ( !window ) return;
301 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
302 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
305 int mgrId = window->getViewManager()->getGlobalId();
307 Handle(SALOME_InteractiveObject) IO =
308 new SALOME_InteractiveObject( entry.toLatin1().data(), "GEOM", "");
311 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
312 if ( !vtkVW ) return;
313 SVTK_View* aView = vtkVW->getView();
315 GEOMToolsGUI::setVtkColor( appStudy, mgrId, aView, IO, color );
316 if ( updateViewer ) aView->Repaint();
319 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
320 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
321 GEOMToolsGUI::setOccColor( appStudy, mgrId, ic, IO, color );
322 if ( updateViewer ) ic->UpdateCurrentViewer();
325 // mark study as modified
326 GeometryGUI::Modified();
329 app->updateActions(); //SRN: To update a Save button in the toolbar
332 void GEOMToolsGUI::OnColor()
334 // get active application
335 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
339 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
340 if ( !appStudy ) return;
342 // get selection manager
343 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
344 if ( !aSelMgr ) return;
347 SALOME_ListIO selected;
348 aSelMgr->selectedObjects( selected );
349 if ( selected.IsEmpty() ) return;
352 SUIT_ViewWindow* window = app->desktop()->activeWindow();
353 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
354 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
357 int mgrId = window->getViewManager()->getGlobalId();
360 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
361 if ( !vtkVW ) return;
363 // get initial color (use first object from selection)
364 SVTK_View* aView = vtkVW->getView();
365 QColor color = aView->GetColor( selected.First() );
366 QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), COLOR_PROP, color );
368 // show Choose Color dialog box
369 color = QColorDialog::getColor( v.value<QColor>(), app->desktop() );
370 if ( !color.isValid() ) return;
372 // iterate through list of objects and assign new color
373 SUIT_OverrideCursor();
374 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
375 GEOMToolsGUI::setVtkColor( appStudy, mgrId, aView, It.Value(), color );
380 // find AIS interactive object (for first item in selection)
381 Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
382 if ( io.IsNull() ) return;
384 // get initial color (use first object from selection)
385 Quantity_Color aColor;
387 QColor color = QColor((int)( aColor.Red() * 255.0 ),
388 (int)( aColor.Green() * 255.0 ),
389 (int)( aColor.Blue() * 255.0 ));
390 QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), COLOR_PROP, color );
392 // show Choose Color dialog box
393 color = QColorDialog::getColor( v.value<QColor>(), app->desktop() );
394 if ( !color.isValid() ) return;
396 // iterate through list of objects and assign new color
397 SUIT_OverrideCursor();
398 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
399 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
400 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
401 GEOMToolsGUI::setOccColor( appStudy, mgrId, ic, It.Value(), color );
403 ic->UpdateCurrentViewer();
406 // mark study as modified
407 GeometryGUI::Modified();
410 app->updateActions(); //SRN: To update a Save button in the toolbar
414 void GEOMToolsGUI::setVtkColor( SalomeApp_Study* study, // study
415 int mgrId, // view window id
416 SVTK_View* view, // VTK view
417 const Handle(SALOME_InteractiveObject)& IO, // interactive object
418 const QColor& color ) // color
420 // get material property
422 matProp = study->getObjectProperty( mgrId, IO->getEntry(), MATERIAL_PROP, matProp ).toString();
423 Material_Model material;
424 material.fromProperties( matProp );
426 // change color only for shapes with not physical type of material
427 if ( !material.isPhysical() ) {
428 view->SetColor( IO, color );
429 study->setObjectProperty( mgrId, IO->getEntry(), COLOR_PROP, color );
432 // store color to GEOM_Object
433 _PTR(Study) aStudy = study->studyDS();
434 _PTR(SObject) aSObject( aStudy->FindObjectID( IO->getEntry() ) );
435 if ( !aSObject ) return;
437 GEOM::GEOM_Object_var anObject =
438 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
440 if ( CORBA::is_nil( anObject ) ) return;
442 SALOMEDS::Color aSColor;
443 aSColor.R = (double)color.red() / 255.0;
444 aSColor.G = (double)color.green() / 255.0;
445 aSColor.B = (double)color.blue() / 255.0;
446 anObject->SetColor( aSColor );
447 anObject->SetAutoColor( false );
450 void GEOMToolsGUI::setOccColor( SalomeApp_Study* study, // study
451 int mgrId, // view window id
452 const Handle(AIS_InteractiveContext)& ic, // OCC interactive context
453 const Handle(SALOME_InteractiveObject)& IO, // interactive object
454 const QColor& color ) // color
457 Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( IO, true );
458 if ( io.IsNull() ) return;
460 // get material property
462 matProp = study->getObjectProperty( mgrId, IO->getEntry(), MATERIAL_PROP, matProp ).toString();
463 Material_Model material;
464 material.fromProperties( matProp );
466 Quantity_Color aColor = Quantity_Color( color.red() / 255., color.green() / 255., color.blue() / 255., Quantity_TOC_RGB );
468 // change color only for shapes with not physical type of material
469 if ( !material.isPhysical() ) {
470 if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) {
471 TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
472 bool onlyVertex = (theShape.ShapeType() == TopAbs_VERTEX || GEOM_Displayer::isCompoundOfVertices( theShape ));
474 // set color for a point
475 Handle(AIS_Drawer) aCurDrawer = io->Attributes();
476 Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
477 Quantity_Color aCurColor;
478 Standard_Real aCurScale;
479 Aspect_TypeOfMarker aCurTypeOfMarker;
480 aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
481 if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
482 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aColor, aCurScale ) );
485 Standard_Integer aWidth, aHeight;
486 aCurPointAspect->GetTextureSize( aWidth, aHeight );
487 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
488 Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture();
490 Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
492 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aColor, 1, aWidth, aHeight, aTexture ) );
494 ic->SetLocalAttributes( io, aCurDrawer, Standard_False );
498 io->SetColor( aColor );
499 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
500 Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
501 aGAISShape->SetShadingColor( aColor );
502 aGAISShape->storeBoundaryColors();
505 io->Redisplay( Standard_True );
507 study->setObjectProperty( mgrId, IO->getEntry(), COLOR_PROP, color );
510 // store color to GEOM_Object
511 _PTR(Study) aStudy = study->studyDS();
512 _PTR(SObject) aSObject( aStudy->FindObjectID( IO->getEntry() ) );
513 GEOM::GEOM_Object_var anObject =
514 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
515 SALOMEDS::Color aSColor;
516 aSColor.R = (double)color.red() / 255.0;
517 aSColor.G = (double)color.green() / 255.0;
518 aSColor.B = (double)color.blue() / 255.0;
519 anObject->SetColor( aSColor );
520 anObject->SetAutoColor( false );
523 void GEOMToolsGUI::OnTexture()
525 SALOME_ListIO selected;
526 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
527 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
528 if ( app && appStudy ) {
529 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
531 aSelMgr->selectedObjects( selected );
532 if ( !selected.IsEmpty() ) {
533 SUIT_ViewWindow* window = app->desktop()->activeWindow();
534 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
536 QString aTexture = QFileDialog::getOpenFileName(window,tr( "GEOM_SELECT_IMAGE"),QString(), tr("OCC_TEXTURE_FILES"));
537 if( !aTexture.isEmpty() )
539 SUIT_OverrideCursor();
540 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
541 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
542 Handle(AIS_InteractiveObject) io ;
543 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
544 io = GEOMBase::GetAIS( It.Value(), true );
545 if ( !io.IsNull() ) {
546 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
547 Handle(GEOM_AISShape)::DownCast( io )->SetTextureFileName(TCollection_AsciiString(aTexture.toStdString().c_str()));
548 io->Redisplay( Standard_True );
549 } // if ( !io.IsNull() )
551 ic->UpdateCurrentViewer();
552 GeometryGUI::Modified();
553 GeometryGUI* myGeomGUI = getGeometryGUI();
554 myGeomGUI->OnGUIEvent(GEOMOp::OpTexture);
555 } // if ( !selFile.isEmpty() )
557 } // if ( selection not empty )
561 app->updateActions(); //SRN: To update a Save button in the toolbar
564 void GEOMToolsGUI::OnTransparency()
566 GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
570 void GEOMToolsGUI::OnChangeTransparency( bool increase )
572 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
575 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
578 SALOME_ListIO selected;
579 aSelMgr->selectedObjects( selected );
580 if ( selected.IsEmpty() )
583 Handle(SALOME_InteractiveObject) FirstIOS = selected.First();
584 if ( FirstIOS.IsNull() )
588 float delta = 0.1; // VSR: 23/11/2010 (transparency value <= 0.05 is ignored)
592 SUIT_ViewWindow* window = app->desktop()->activeWindow();
593 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
594 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
597 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
600 SVTK_View* aView = vtkVW->getView();
602 float transp = aView->GetTransparency(FirstIOS);
604 // Compute new transparency value
605 transp = transp + delta;
608 else if ( transp > 1 )
611 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
612 aView->SetTransparency( It.Value(), transp );
615 GeometryGUI::Modified();
619 GEOMBase* gb = new GEOMBase();
620 Handle(GEOM_AISShape) aisShape;
622 aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS, true );
623 if( aisShape.IsNull() )
625 float transp = aisShape->Transparency();
627 // Compute new transparency value
628 transp = transp + delta;
631 else if ( transp > 1 )
634 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
637 Handle(AIS_InteractiveContext) ic = vm->getAISContext();
638 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
639 aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
640 if ( !aisShape.IsNull() ) {
641 ic->SetTransparency( aisShape, transp, false );
642 ic->Redisplay( aisShape, Standard_False, Standard_True );
645 ic->UpdateCurrentViewer();
646 GeometryGUI::Modified();
650 void GEOMToolsGUI::OnNbIsos( ActionType actionType )
652 SalomeApp_Application* app =
653 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
654 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
655 SUIT_ViewWindow* window = app->desktop()->activeWindow();
657 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
658 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
660 if(isOCC){ // if is OCCViewer
662 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
663 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
666 if ( ic->MoreCurrent() ) {
667 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
668 CurObject->restoreIsoNumbers();
669 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
671 int UIso = CurDrawer->UIsoAspect()->Number();
672 int VIso = CurDrawer->VIsoAspect()->Number();
677 if ( actionType == SHOWDLG ) {
678 GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
679 new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
681 NbIsosDlg->setU( UIso );
682 NbIsosDlg->setV( VIso );
684 if ( NbIsosDlg->exec() ) {
685 SUIT_OverrideCursor();
687 newNbUIso = NbIsosDlg->getU();
688 newNbVIso = NbIsosDlg->getV();
692 else if ( actionType == INCR || actionType == DECR ) {
694 if (actionType == DECR)
697 newNbUIso = UIso + delta;
698 newNbVIso = VIso + delta;
700 if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
704 for(; ic->MoreCurrent(); ic->NextCurrent()) {
705 int aMgrId = window->getViewManager()->getGlobalId();
706 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
708 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
710 QVariant v = aStudy->getObjectProperty( aMgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP , QVariant() );
712 int width = v.isValid() ? v.toInt() : 1;
714 CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width , newNbUIso) );
715 CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width , newNbVIso) );
717 CurObject->storeIsoNumbers();
719 ic->SetLocalAttributes(CurObject, CurDrawer);
720 ic->Redisplay(CurObject);
722 QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
723 aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_PROP, anIsos);
726 GeometryGUI::Modified();
728 else if(isVTK){ // if is VTKViewer
730 // Warning. It's works incorrect. must be recheked.
732 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >
733 ( SUIT_Session::session()->activeApplication() );
736 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
739 SALOME_ListIO selected;
740 aSelMgr->selectedObjects( selected );
741 if ( selected.IsEmpty() )
744 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
748 SALOME_View* view = GEOM_Displayer::GetActiveView();
750 vtkActorCollection* aCollection = vtkActorCollection::New();
752 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
753 Handle(SALOME_InteractiveObject) anIObject = It.Value();
754 SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() );
755 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
757 vtkActorCollection* anActors = vtkPrs->GetObjects();
758 anActors->InitTraversal();
759 vtkActor* anAct = anActors->GetNextActor();
760 aCollection->AddItem(anAct);
765 aCollection->InitTraversal();
772 vtkActor* anAct = aCollection->GetNextActor();
773 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
774 anActor->RestoreIsoNumbers();
775 anActor->GetNbIsos(UIso,VIso);
783 if ( actionType == SHOWDLG ) {
784 GEOMToolsGUI_NbIsosDlg* NbIsosDlg =
785 new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
787 NbIsosDlg->setU( UIso );
788 NbIsosDlg->setV( VIso );
790 if ( NbIsosDlg->exec() ) {
791 SUIT_OverrideCursor();
793 newNbUIso = NbIsosDlg->getU();
794 newNbVIso = NbIsosDlg->getV();
796 return; //Cancel case
798 else if ( actionType == INCR || actionType == DECR ) {
800 if (actionType == DECR)
803 newNbUIso = UIso + delta;
804 newNbVIso = VIso + delta;
806 if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
810 while( anAct!=NULL ) {
811 if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){
812 // There are no casting to needed actor.
813 int aIsos[2]={newNbUIso,newNbVIso};
814 anActor->SetNbIsos(aIsos);
815 anActor->StoreIsoNumbers();
817 QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
818 int aMgrId = window->getViewManager()->getGlobalId();
819 aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_PROP, anIsos);
821 anAct = aCollection->GetNextActor();
824 GeometryGUI::Modified();
828 void GEOMToolsGUI::OnDeflection()
830 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
831 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
834 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
835 bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
836 int mgrId = window->getViewManager()->getGlobalId();
838 if (isOCC) { // if is OCCViewer
839 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
840 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
843 if (ic->MoreCurrent()) {
844 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
846 Standard_Real aDC, aPrevDC;
847 Standard_Boolean isOwnDC = CurObject->OwnDeviationCoefficient(aDC, aPrevDC);
849 aDC = ic->DeviationCoefficient();
851 GEOMToolsGUI_DeflectionDlg * DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
852 (SUIT_Session::session()->activeApplication()->desktop());
853 DeflectionDlg->setTheDC(aDC);
857 if (DeflectionDlg->exec()) {
858 SUIT_OverrideCursor();
859 aNewDC = DeflectionDlg->getTheDC();
860 ok = (1e-07 <= aNewDC && aNewDC <= 1.0); // spinbox can return zero
862 for (; ic->MoreCurrent(); ic->NextCurrent()) {
863 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
864 ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True);
865 ic->Redisplay(CurObject);
866 appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aNewDC);
875 GeometryGUI::Modified();
877 else if (isVTK) { // if is VTKViewer
878 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
879 (SUIT_Session::session()->activeApplication());
883 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
887 SALOME_ListIO selected;
888 aSelMgr->selectedObjects(selected);
889 if (selected.IsEmpty())
892 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
896 SALOME_View* view = GEOM_Displayer::GetActiveView();
898 vtkActorCollection* aCollection = vtkActorCollection::New();
900 for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
901 Handle(SALOME_InteractiveObject) anIObject = It.Value();
902 SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
903 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
905 vtkActorCollection* anActors = vtkPrs->GetObjects();
906 anActors->InitTraversal();
907 vtkActor* anAct = anActors->GetNextActor();
908 aCollection->AddItem(anAct);
913 aCollection->InitTraversal();
919 vtkActor* anAct = aCollection->GetNextActor();
920 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
921 aDC = anActor->GetDeflection();
925 GEOMToolsGUI_DeflectionDlg* DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
926 (SUIT_Session::session()->activeApplication()->desktop());
927 DeflectionDlg->setTheDC(aDC);
928 if (DeflectionDlg->exec()) {
929 SUIT_OverrideCursor();
930 aDC = DeflectionDlg->getTheDC();
931 while (anAct != NULL) {
932 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
933 // There are no casting to needed actor.
934 anActor->SetDeflection(aDC);
935 appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
937 anAct = aCollection->GetNextActor();
940 GeometryGUI::Modified();
944 void GEOMToolsGUI::OnSelectOnly(int mode)
946 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
948 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
949 GEOM_Displayer aDisp (appStudy);
950 aDisp.GlobalSelection(mode);
951 getGeometryGUI()->setLocalSelectionMode(mode);
955 void GEOMToolsGUI::OnDiscloseConcealChildren( bool show )
957 SALOME_ListIO selected;
958 SalomeApp_Application* app =
959 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
961 SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
963 GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
966 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
967 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
968 if ( aSelMgr && appStudy ) {
969 aSelMgr->selectedObjects( selected );
970 if ( !selected.IsEmpty() ) {
971 _PTR(Study) aStudy = appStudy->studyDS();
972 _PTR(StudyBuilder) B = aStudy->NewBuilder();
974 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
976 SUIT_MessageBox::warning( app->desktop(),
977 QObject::tr( "WRN_WARNING" ),
978 QObject::tr( "WRN_STUDY_LOCKED" ) );
982 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
983 Handle(SALOME_InteractiveObject) IObject = It.Value();
985 _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
986 _PTR(GenericAttribute) anAttr;
988 _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
989 aExp->SetExpandable( show );
991 disp->EraseWithChildren(IObject,true);
996 app->updateObjectBrowser( false );
997 app->updateActions();
1001 void GEOMToolsGUI::OnPointMarker()
1003 GEOMToolsGUI_MarkerDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
1007 void GEOMToolsGUI::OnMaterialProperties()
1009 GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
1013 void GEOMToolsGUI::OnUnpublishObject() {
1014 SALOME_ListIO selected;
1015 SalomeApp_Application* app =
1016 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1018 SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
1020 GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
1022 if ( app && disp ) {
1023 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
1024 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1025 if ( aSelMgr && appStudy ) {
1026 aSelMgr->selectedObjects( selected );
1027 if ( !selected.IsEmpty() ) {
1028 _PTR(Study) aStudy = appStudy->studyDS();
1029 _PTR(StudyBuilder) B = aStudy->NewBuilder();
1031 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
1033 SUIT_MessageBox::warning( app->desktop(),
1034 QObject::tr( "WRN_WARNING" ),
1035 QObject::tr( "WRN_STUDY_LOCKED" ) );
1039 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
1040 Handle(SALOME_InteractiveObject) IObject = It.Value();
1042 _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
1043 _PTR(GenericAttribute) anAttr;
1045 _PTR(AttributeDrawable) aDrw = B->FindOrCreateAttribute( obj, "AttributeDrawable" );
1046 aDrw->SetDrawable( false );
1047 disp->EraseWithChildren(IObject);
1050 aSelMgr->clearSelected();
1053 app->updateObjectBrowser( false );
1054 app->updateActions();
1059 void GEOMToolsGUI::OnPublishObject() {
1060 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1064 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1068 _PTR(Study) aStudy = appStudy->studyDS();
1073 //Check lock of the study
1074 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
1076 SUIT_MessageBox::warning( app->desktop(),
1077 QObject::tr( "WRN_WARNING" ),
1078 QObject::tr( "WRN_STUDY_LOCKED" ) );
1082 GEOMToolsGUI_PublishDlg * publishDlg =
1083 new GEOMToolsGUI_PublishDlg( SUIT_Session::session()->activeApplication()->desktop() );
1088 void GEOMToolsGUI::OnEdgeWidth()
1090 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
1091 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
1094 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
1095 bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
1096 int mgrId = window->getViewManager()->getGlobalId();
1098 if (isOCC) { // if is OCCViewer
1099 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
1100 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
1101 SALOME_View* view = GEOM_Displayer::GetActiveView();
1103 if (ic->MoreCurrent()) {
1104 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
1106 int aWidth = (int)CurObject->Width();
1108 GEOMToolsGUI_LineWidthDlg * Dlg = new GEOMToolsGUI_LineWidthDlg
1109 (SUIT_Session::session()->activeApplication()->desktop(),"EDGE_WIDTH_TLT");
1110 Dlg->setTheLW(aWidth);
1113 aNewWidth = Dlg->getTheLW();
1114 bool ok = (aNewWidth != aWidth && aNewWidth != 0 );
1116 for(; ic->MoreCurrent(); ic->NextCurrent()) {
1117 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
1118 SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>(view->CreatePrs(CurObject->getIO()->getEntry()));
1119 AIS_ListOfInteractive anAISObjects;
1120 aPrs->GetObjects( anAISObjects );
1121 AIS_ListIteratorOfListOfInteractive aIter( anAISObjects );
1122 for ( ; aIter.More(); aIter.Next() ) {
1123 Handle(SALOME_AISShape) cur = Handle(SALOME_AISShape)::DownCast(aIter.Value());
1124 if ( !cur.IsNull() ) {
1125 cur->SetWidth(aNewWidth);
1129 appStudy->setObjectProperty(mgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP, aNewWidth);
1137 GeometryGUI::Modified();
1139 else if (isVTK) { // if is VTKViewer
1140 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
1141 (SUIT_Session::session()->activeApplication());
1145 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
1149 SALOME_ListIO selected;
1150 aSelMgr->selectedObjects(selected);
1151 if (selected.IsEmpty())
1154 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
1158 SALOME_View* view = GEOM_Displayer::GetActiveView();
1160 vtkActorCollection* aCollection = vtkActorCollection::New();
1162 for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
1163 Handle(SALOME_InteractiveObject) anIObject = It.Value();
1164 SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
1165 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
1167 vtkActorCollection* anActors = vtkPrs->GetObjects();
1168 anActors->InitTraversal();
1169 vtkActor* anAct = anActors->GetNextActor();
1170 aCollection->AddItem(anAct);
1175 aCollection->InitTraversal();
1181 vtkActor* anAct = aCollection->GetNextActor();
1182 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
1183 aWidth = anActor->GetWidth();
1187 GEOMToolsGUI_LineWidthDlg * Dlg = new GEOMToolsGUI_LineWidthDlg
1188 (SUIT_Session::session()->activeApplication()->desktop(),"EDGE_WIDTH_TLT");
1190 Dlg->setTheLW(aWidth);
1192 SUIT_OverrideCursor();
1193 aWidth = Dlg->getTheLW();
1194 while (anAct != NULL) {
1195 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
1196 // There are no casting to needed actor.
1197 anActor->SetWidth(aWidth);
1198 appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), EDGE_WIDTH_PROP, aWidth);
1200 anAct = aCollection->GetNextActor();
1203 GeometryGUI::Modified();
1208 void GEOMToolsGUI::OnIsosWidth() {
1209 SalomeApp_Application* app =
1210 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1211 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1212 SUIT_ViewWindow* window = app->desktop()->activeWindow();
1214 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1215 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
1217 if(isOCC){ // if is OCCViewer
1219 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
1220 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
1223 if ( ic->MoreCurrent() ) {
1224 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
1225 CurObject->restoreIsoNumbers();
1226 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
1228 Handle(Graphic3d_AspectLine3d) asp = CurDrawer->UIsoAspect()->Aspect();
1231 Aspect_TypeOfLine T;
1235 int aWidth = (int)W;
1237 GEOMToolsGUI_LineWidthDlg * Dlg =
1238 new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(),"ISOS_WIDTH_TLT" );
1240 Dlg->setTheLW( aWidth );
1242 if ( Dlg->exec() ) {
1243 SUIT_OverrideCursor();
1244 aWidth = Dlg->getTheLW();
1245 } else //Cancel case
1248 for(; ic->MoreCurrent(); ic->NextCurrent()) {
1249 int aMgrId = window->getViewManager()->getGlobalId();
1250 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
1252 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
1254 CurObject->Attributes()->UIsoAspect()->SetWidth(aWidth);
1255 CurObject->Attributes()->VIsoAspect()->SetWidth(aWidth);
1257 ic->Redisplay(CurObject);
1259 aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth);
1261 GeometryGUI::Modified();
1264 else if(isVTK){ // if is VTKViewer
1266 // Warning. It's works incorrect. must be recheked.
1268 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >
1269 ( SUIT_Session::session()->activeApplication() );
1272 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
1275 SALOME_ListIO selected;
1276 aSelMgr->selectedObjects( selected );
1277 if ( selected.IsEmpty() )
1280 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
1284 SALOME_View* view = GEOM_Displayer::GetActiveView();
1286 vtkActorCollection* aCollection = vtkActorCollection::New();
1288 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
1289 Handle(SALOME_InteractiveObject) anIObject = It.Value();
1290 SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() );
1291 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
1293 vtkActorCollection* anActors = vtkPrs->GetObjects();
1294 anActors->InitTraversal();
1295 vtkActor* anAct = anActors->GetNextActor();
1296 aCollection->AddItem(anAct);
1301 aCollection->InitTraversal();
1307 vtkActor* anAct = aCollection->GetNextActor();
1308 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
1309 aWidth = anActor->GetIsosWidth();
1314 GEOMToolsGUI_LineWidthDlg* Dlg =
1315 new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), "ISOS_WIDTH_TLT" );
1317 Dlg->setTheLW( aWidth );
1319 SUIT_OverrideCursor();
1320 aWidth = Dlg->getTheLW();
1322 return; //Cancel case
1324 while( anAct!= NULL ) {
1325 if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
1326 // There are no casting to needed actor.
1327 anActor->SetIsosWidth(aWidth);
1328 int aMgrId = window->getViewManager()->getGlobalId();
1329 aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth);
1331 anAct = aCollection->GetNextActor();
1335 GeometryGUI::Modified();
1339 void GEOMToolsGUI::OnBringToFront() {
1340 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1344 SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
1348 GEOM_Displayer* disp = dynamic_cast<GEOM_Displayer*>(mod->displayer());
1353 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
1357 SALOME_ListIO selected;
1358 aSelMgr->selectedObjects( selected );
1359 if ( selected.IsEmpty() )
1362 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
1366 SUIT_ViewWindow* window = app->desktop()->activeWindow();
1368 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
1372 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1374 QAction* a = getGeometryGUI()->getAction( GEOMOp::OpBringToFront );
1375 bool checked = a->isChecked();
1378 GEOMBase* gb = new GEOMBase();
1379 Handle(GEOM_AISShape) aisShape;
1381 Handle(AIS_InteractiveContext) ic = vm->getAISContext();
1382 SALOME_ListIO anIOlst;
1383 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
1384 aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
1385 if ( !aisShape.IsNull() ) {
1386 aisShape->setTopLevel(checked);
1387 int aMgrId = window->getViewManager()->getGlobalId();
1388 appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), TOP_LEVEL_PROP, checked );
1389 anIOlst.Append(aisShape->getIO());
1392 disp->Redisplay(anIOlst);
1393 GeometryGUI::Modified();
1397 void GEOMToolsGUI::OnClsBringToFront() {
1398 SalomeApp_Application* app =
1399 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1403 SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
1407 GEOM_Displayer* disp = dynamic_cast<GEOM_Displayer*>(mod->displayer());
1413 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
1417 SUIT_ViewWindow* window = app->desktop()->activeWindow();
1419 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1421 if(isOCC){ // if is OCCViewer
1423 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
1424 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
1426 SALOME_ListIO anIOlst;
1427 AIS_ListOfInteractive aList;
1428 ic->DisplayedObjects( aList );
1429 for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() ) {
1431 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(it.Value());
1433 if(CurObject.IsNull())
1436 CurObject->setTopLevel(Standard_False);
1438 int aMgrId = window->getViewManager()->getGlobalId();
1439 appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), TOP_LEVEL_PROP, Standard_False );
1440 anIOlst.Append(CurObject->getIO());
1442 disp->Redisplay(anIOlst);
1443 GeometryGUI::Modified();