1 // Copyright (C) 2007-2010 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"
35 #include <GeometryGUI.h>
36 #include <GEOM_Displayer.h>
39 #include <GEOM_Actor.h>
41 #include <SALOME_ListIO.hxx>
42 #include <SALOME_ListIteratorOfListIO.hxx>
47 #include <SVTK_ViewModel.h>
48 #include <SVTK_ViewWindow.h>
49 #include <SVTK_View.h>
51 #include <OCCViewer_ViewModel.h>
53 #include <SUIT_ViewManager.h>
54 #include <SUIT_Desktop.h>
55 #include <SUIT_ResourceMgr.h>
56 #include <SUIT_Session.h>
57 #include <SUIT_OverrideCursor.h>
58 #include <SUIT_MessageBox.h>
59 #include <SUIT_Tools.h>
61 #include <SalomeApp_Application.h>
62 #include <SalomeApp_Study.h>
63 #include <SalomeApp_Module.h>
65 #include <LightApp_SelectionMgr.h>
66 #include <LightApp_NameDlg.h>
68 #include <GEOMImpl_Types.hxx>
70 #include "utilities.h"
73 #include <AIS_Drawer.hxx>
74 #include <Prs3d_IsoAspect.hxx>
75 #include <Prs3d_PointAspect.hxx>
76 #include <Graphic3d_AspectMarker3d.hxx>
77 #include <Graphic3d_HArray1OfBytes.hxx>
80 #include <QColorDialog>
81 #include <QInputDialog>
84 #include <QGridLayout>
87 #include <QPushButton>
91 #include <vtkRenderer.h>
93 void GEOMToolsGUI::OnRename()
95 SALOME_ListIO selected;
96 SalomeApp_Application* app =
97 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
99 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
100 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
101 if ( aSelMgr && appStudy ) {
102 aSelMgr->selectedObjects( selected );
103 if ( !selected.IsEmpty() ) {
104 _PTR(Study) aStudy = appStudy->studyDS();
106 bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
108 SUIT_MessageBox::warning ( app->desktop(),
109 QObject::tr("WRN_WARNING"),
110 QObject::tr("WRN_STUDY_LOCKED") );
114 bool isAny = false; // is there any appropriate object selected
115 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
116 Handle(SALOME_InteractiveObject) IObject = It.Value();
118 _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
119 _PTR(GenericAttribute) anAttr;
121 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
122 _PTR(AttributeName) aName (anAttr);
124 GEOM::GEOM_Object_var anObj =
125 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
126 if (!CORBA::is_nil(anObj)) {
128 QString newName = LightApp_NameDlg::getName( app->desktop(), aName->Value().c_str() );
129 if (!newName.isEmpty()) {
130 aName->SetValue( newName.toLatin1().data() ); // rename the SObject
131 IObject->setName( newName.toLatin1().data() );// rename the InteractiveObject
132 anObj->SetName( newName.toLatin1().data() ); // Rename the corresponding GEOM_Object
133 (dynamic_cast<SalomeApp_Module*>(app->activeModule()))->updateObjBrowser( false );
136 } // if ( name attribute )
141 SUIT_MessageBox::warning( app->desktop(),
142 QObject::tr("WRN_WARNING"),
143 QObject::tr("GEOM_WRN_NO_APPROPRIATE_SELECTION") );
150 app->updateActions(); //SRN: To update a Save button in the toolbar
153 void GEOMToolsGUI::OnCheckGeometry()
155 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
156 PyConsole_Console* pyConsole = app->pythonConsole();
159 pyConsole->exec("from GEOM_usinggeom import *");
162 void GEOMToolsGUI::OnAutoColor()
164 SALOME_ListIO selected;
165 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
169 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
170 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
171 if( !aSelMgr || !appStudy )
174 aSelMgr->selectedObjects( selected );
175 if( selected.IsEmpty() )
178 Handle(SALOME_InteractiveObject) anIObject = selected.First();
180 _PTR(Study) aStudy = appStudy->studyDS();
181 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
182 GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
183 if( CORBA::is_nil( aMainObject ) )
186 aMainObject->SetAutoColor( true );
188 QList<SALOMEDS::Color> aReservedColors;
190 GEOM_Displayer aDisp (appStudy);
192 SALOME_View* vf = aDisp.GetActiveView();
194 SUIT_ViewWindow* window = app->desktop()->activeWindow();
195 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
196 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
198 for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); it->More(); it->Next() )
200 _PTR(SObject) aChildSObject( it->Value() );
201 GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
202 if( CORBA::is_nil( aChildObject ) )
205 if( aChildObject->GetType() != GEOM_GROUP )
208 SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
209 aChildObject->SetColor( aColor );
210 aReservedColors.append( aColor );
212 QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
214 SALOME_Prs* aPrs = vf->CreatePrs( aChildSObject->GetID().c_str() );
218 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
221 SVTK_View* aView = vtkVW->getView();
222 SUIT_OverrideCursor();
223 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
224 aView->SetColor( It.Value(), c );
228 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
229 Handle(AIS_InteractiveContext) ic = vm->getAISContext();
231 SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
235 AIS_ListOfInteractive aList;
236 anOCCPrs->GetObjects( aList );
237 if( !aList.Extent() )
240 Handle(AIS_InteractiveObject) io = aList.First();
244 Quantity_Color aQuanColor( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
246 // Set color for a point
247 Handle(AIS_Drawer) aCurDrawer = io->Attributes();
248 Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
249 Quantity_Color aCurColor;
250 Standard_Real aCurScale;
251 Aspect_TypeOfMarker aCurTypeOfMarker;
252 aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
253 if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
254 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aQuanColor, aCurScale) );
257 Standard_Integer aWidth, aHeight;
258 aCurPointAspect->GetTextureSize( aWidth, aHeight );
259 Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
260 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aQuanColor, 1, aWidth, aHeight, aTexture ) );
262 ic->SetLocalAttributes( io, aCurDrawer );
264 io->SetColor( aQuanColor );
265 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
266 Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aQuanColor );
268 io->Redisplay( Standard_True );
272 app->updateActions(); //SRN: To update a Save button in the toolbar
275 void GEOMToolsGUI::OnDisableAutoColor()
277 SALOME_ListIO selected;
278 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
282 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
283 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
284 if( !aSelMgr || !appStudy )
287 aSelMgr->selectedObjects( selected );
288 if( selected.IsEmpty() )
291 Handle(SALOME_InteractiveObject) anIObject = selected.First();
293 _PTR(Study) aStudy = appStudy->studyDS();
294 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
295 GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
296 if( CORBA::is_nil( aMainObject ) )
299 aMainObject->SetAutoColor( false );
303 void GEOMToolsGUI::OnColor()
305 SALOME_ListIO selected;
306 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
307 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
308 if ( app && appStudy ) {
309 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
311 aSelMgr->selectedObjects( selected );
312 if ( !selected.IsEmpty() ) {
313 SUIT_ViewWindow* window = app->desktop()->activeWindow();
314 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
315 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
316 int mgrId = window->getViewManager()->getGlobalId();
318 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
321 SVTK_View* aView = vtkVW->getView();
322 QColor initcolor = aView->GetColor( selected.First() );
323 QColor c = QColorDialog::getColor( initcolor, app->desktop() );
325 SUIT_OverrideCursor();
326 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
327 aView->SetColor( It.Value(), c );
328 appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
330 GeometryGUI::Modified();
334 Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
335 if ( !io.IsNull() ) {
336 Quantity_Color aColor;
338 QColor initcolor ((int)( aColor.Red() * 255.0 ),
339 (int)( aColor.Green() * 255.0 ),
340 (int)( aColor.Blue() * 255.0 ));
341 QColor c = QColorDialog::getColor( initcolor, app->desktop() );
343 SUIT_OverrideCursor();
344 aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
345 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
346 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
347 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
348 io = GEOMBase::GetAIS( It.Value(), true );
349 if ( !io.IsNull() ) {
351 if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) {
352 TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
353 if (theShape.ShapeType() == TopAbs_VERTEX) {
354 // Set color for a point
356 Handle(AIS_Drawer) aCurDrawer = io->Attributes();
357 Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
358 Quantity_Color aCurColor;
359 Standard_Real aCurScale;
360 Aspect_TypeOfMarker aCurTypeOfMarker;
361 aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
362 if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
363 aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aCurTypeOfMarker, aColor, aCurScale));
366 Standard_Integer aWidth, aHeight;
367 aCurPointAspect->GetTextureSize( aWidth, aHeight );
368 Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
369 aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aColor, 1, aWidth, aHeight, aTexture));
371 ic->SetLocalAttributes(io, aCurDrawer, Standard_False);
375 io->SetColor( aColor );
376 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
377 Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor );
379 appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
381 io->Redisplay( Standard_True );
383 // store color to GEOM_Object
384 _PTR(Study) aStudy = appStudy->studyDS();
385 _PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
386 GEOM::GEOM_Object_var anObject =
387 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
390 SALOMEDS::Color aSColor;
391 aSColor.R = (double)c.red() / 255.0;
392 aSColor.G = (double)c.green() / 255.0;
393 aSColor.B = (double)c.blue() / 255.0;
394 anObject->SetColor( aSColor );
395 anObject->SetAutoColor( false );
398 ic->UpdateCurrentViewer();
399 GeometryGUI::Modified();
401 } // first IO is not null
403 } // if ( selection not empty )
407 app->updateActions(); //SRN: To update a Save button in the toolbar
410 void GEOMToolsGUI::OnTransparency()
412 GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
416 void GEOMToolsGUI::OnChangeTransparency( bool increase )
418 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
421 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
424 SALOME_ListIO selected;
425 aSelMgr->selectedObjects( selected );
426 if ( selected.IsEmpty() )
429 Handle(SALOME_InteractiveObject) FirstIOS = selected.First();
430 if ( FirstIOS.IsNull() )
434 float delta = 0.1; // VSR: 23/11/2010 (transparency value <= 0.05 is ignored)
438 SUIT_ViewWindow* window = app->desktop()->activeWindow();
439 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
440 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
443 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
446 SVTK_View* aView = vtkVW->getView();
448 float transp = aView->GetTransparency(FirstIOS);
450 // Compute new transparency value
451 transp = transp + delta;
454 else if ( transp > 1 )
457 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
458 aView->SetTransparency( It.Value(), transp );
461 GeometryGUI::Modified();
465 GEOMBase* gb = new GEOMBase();
466 Handle(GEOM_AISShape) aisShape;
468 aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS );
469 if( aisShape.IsNull() )
471 float transp = aisShape->Transparency();
473 // Compute new transparency value
474 transp = transp + delta;
477 else if ( transp > 1 )
480 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
483 Handle(AIS_InteractiveContext) ic = vm->getAISContext();
484 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
485 aisShape = gb->ConvertIOinGEOMAISShape( It.Value() );
486 if ( !aisShape.IsNull() ) {
487 ic->SetTransparency( aisShape, transp, false );
488 ic->Redisplay( aisShape, Standard_False, Standard_True );
491 ic->UpdateCurrentViewer();
492 GeometryGUI::Modified();
496 void GEOMToolsGUI::OnNbIsos( ActionType actionType )
498 SalomeApp_Application* app =
499 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
500 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
501 SUIT_ViewWindow* window = app->desktop()->activeWindow();
503 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
504 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
506 if(isOCC){ // if is OCCViewer
508 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
509 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
512 if ( ic->MoreCurrent() ) {
513 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
514 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
516 int UIso = CurDrawer->UIsoAspect()->Number();
517 int VIso = CurDrawer->VIsoAspect()->Number();
522 if ( actionType == SHOWDLG ) {
523 GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
524 new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
526 NbIsosDlg->setU( UIso );
527 NbIsosDlg->setV( VIso );
529 if ( NbIsosDlg->exec() ) {
530 SUIT_OverrideCursor();
532 newNbUIso = NbIsosDlg->getU();
533 newNbVIso = NbIsosDlg->getV();
537 else if ( actionType == INCR || actionType == DECR ) {
539 if (actionType == DECR)
542 newNbUIso = UIso + delta;
543 newNbVIso = VIso + delta;
545 if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
549 for(; ic->MoreCurrent(); ic->NextCurrent()) {
550 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
554 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
556 CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbUIso) );
557 CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbVIso) );
559 ic->SetLocalAttributes(CurObject, CurDrawer);
560 ic->Redisplay(CurObject);
562 QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
563 int aMgrId = window->getViewManager()->getGlobalId();
564 aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), "Isos", anIsos);
567 GeometryGUI::Modified();
569 else if(isVTK){ // if is VTKViewer
571 // Warning. It's works incorrect. must be recheked.
573 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >
574 ( SUIT_Session::session()->activeApplication() );
577 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
580 SALOME_ListIO selected;
581 aSelMgr->selectedObjects( selected );
582 if ( selected.IsEmpty() )
585 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
589 SALOME_View* view = GEOM_Displayer::GetActiveView();
591 vtkActorCollection* aCollection = vtkActorCollection::New();
593 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
594 Handle(SALOME_InteractiveObject) anIObject = It.Value();
595 SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() );
596 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
598 vtkActorCollection* anActors = vtkPrs->GetObjects();
599 anActors->InitTraversal();
600 vtkActor* anAct = anActors->GetNextActor();
601 aCollection->AddItem(anAct);
606 aCollection->InitTraversal();
613 vtkActor* anAct = aCollection->GetNextActor();
614 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
615 anActor->GetNbIsos(UIso,VIso);
622 if ( actionType == SHOWDLG ) {
623 GEOMToolsGUI_NbIsosDlg* NbIsosDlg =
624 new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
626 NbIsosDlg->setU( UIso );
627 NbIsosDlg->setV( VIso );
629 if ( NbIsosDlg->exec() ) {
630 SUIT_OverrideCursor();
632 newNbUIso = NbIsosDlg->getU();
633 newNbVIso = NbIsosDlg->getV();
635 return; //Cancel case
637 else if ( actionType == INCR || actionType == DECR ) {
639 if (actionType == DECR)
642 newNbUIso = UIso + delta;
643 newNbVIso = VIso + delta;
645 if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
649 while( anAct!=NULL ) {
650 if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){
651 // There are no casting to needed actor.
652 int aIsos[2]={newNbUIso,newNbVIso};
653 anActor->SetNbIsos(aIsos);
655 QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
656 int aMgrId = window->getViewManager()->getGlobalId();
657 aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_PROP, anIsos);
659 anAct = aCollection->GetNextActor();
662 GeometryGUI::Modified();
666 void GEOMToolsGUI::OnDeflection()
668 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
669 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
672 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
673 bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
674 int mgrId = window->getViewManager()->getGlobalId();
676 if (isOCC) { // if is OCCViewer
677 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
678 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
681 if (ic->MoreCurrent()) {
682 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
684 Standard_Real aDC, aPrevDC;
685 Standard_Boolean isOwnDC = CurObject->OwnDeviationCoefficient(aDC, aPrevDC);
687 aDC = ic->DeviationCoefficient();
689 GEOMToolsGUI_DeflectionDlg * DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
690 (SUIT_Session::session()->activeApplication()->desktop());
691 DeflectionDlg->setTheDC(aDC);
695 if (DeflectionDlg->exec()) {
696 SUIT_OverrideCursor();
697 aNewDC = DeflectionDlg->getTheDC();
698 ok = (1e-07 <= aNewDC && aNewDC <= 1.0); // spinbox can return zero
700 for (; ic->MoreCurrent(); ic->NextCurrent()) {
701 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
702 ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True);
703 ic->Redisplay(CurObject);
704 appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aNewDC);
713 GeometryGUI::Modified();
715 else if (isVTK) { // if is VTKViewer
716 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
717 (SUIT_Session::session()->activeApplication());
721 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
725 SALOME_ListIO selected;
726 aSelMgr->selectedObjects(selected);
727 if (selected.IsEmpty())
730 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
734 SALOME_View* view = GEOM_Displayer::GetActiveView();
736 vtkActorCollection* aCollection = vtkActorCollection::New();
738 for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
739 Handle(SALOME_InteractiveObject) anIObject = It.Value();
740 SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
741 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
743 vtkActorCollection* anActors = vtkPrs->GetObjects();
744 anActors->InitTraversal();
745 vtkActor* anAct = anActors->GetNextActor();
746 aCollection->AddItem(anAct);
751 aCollection->InitTraversal();
757 vtkActor* anAct = aCollection->GetNextActor();
758 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
759 aDC = anActor->GetDeflection();
763 GEOMToolsGUI_DeflectionDlg* DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
764 (SUIT_Session::session()->activeApplication()->desktop());
765 DeflectionDlg->setTheDC(aDC);
766 if (DeflectionDlg->exec()) {
767 SUIT_OverrideCursor();
768 aDC = DeflectionDlg->getTheDC();
769 while (anAct != NULL) {
770 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
771 // There are no casting to needed actor.
772 anActor->SetDeflection(aDC);
773 appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
775 anAct = aCollection->GetNextActor();
778 GeometryGUI::Modified();
782 void GEOMToolsGUI::OnSelectOnly(int mode)
784 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
786 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
787 GEOM_Displayer aDisp (appStudy);
788 aDisp.GlobalSelection(mode);
789 getGeometryGUI()->setLocalSelectionMode(mode);
793 void GEOMToolsGUI::OnShowHideChildren( bool show )
795 SALOME_ListIO selected;
796 SalomeApp_Application* app =
797 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
799 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
800 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
801 if ( aSelMgr && appStudy ) {
802 aSelMgr->selectedObjects( selected );
803 if ( !selected.IsEmpty() ) {
804 _PTR(Study) aStudy = appStudy->studyDS();
805 _PTR(StudyBuilder) B = aStudy->NewBuilder();
807 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
809 SUIT_MessageBox::warning( app->desktop(),
810 QObject::tr( "WRN_WARNING" ),
811 QObject::tr( "WRN_STUDY_LOCKED" ) );
815 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
816 Handle(SALOME_InteractiveObject) IObject = It.Value();
818 _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
819 _PTR(GenericAttribute) anAttr;
821 _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
822 aExp->SetExpandable( show );
827 app->updateObjectBrowser( false );
828 app->updateActions();
832 void GEOMToolsGUI::OnPointMarker()
834 GEOMToolsGUI_MarkerDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );