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"
34 #include "GEOMToolsGUI_PublishDlg.h"
36 #include <GeometryGUI.h>
37 #include <GEOM_Displayer.h>
40 #include <GEOM_Actor.h>
42 #include <SALOME_ListIO.hxx>
43 #include <SALOME_ListIteratorOfListIO.hxx>
48 #include <SVTK_ViewModel.h>
49 #include <SVTK_ViewWindow.h>
50 #include <SVTK_View.h>
52 #include <OCCViewer_ViewModel.h>
54 #include <SUIT_ViewManager.h>
55 #include <SUIT_Desktop.h>
56 #include <SUIT_ResourceMgr.h>
57 #include <SUIT_Session.h>
58 #include <SUIT_OverrideCursor.h>
59 #include <SUIT_MessageBox.h>
60 #include <SUIT_Tools.h>
62 #include <SalomeApp_Application.h>
63 #include <SalomeApp_Study.h>
64 #include <SalomeApp_Module.h>
66 #include <LightApp_SelectionMgr.h>
67 #include <LightApp_NameDlg.h>
69 #include <GEOMImpl_Types.hxx>
71 #include "utilities.h"
74 #include <AIS_Drawer.hxx>
75 #include <Prs3d_IsoAspect.hxx>
76 #include <Prs3d_PointAspect.hxx>
77 #include <Graphic3d_AspectMarker3d.hxx>
78 #include <Graphic3d_HArray1OfBytes.hxx>
81 #include <QColorDialog>
82 #include <QInputDialog>
85 #include <QGridLayout>
88 #include <QPushButton>
92 #include <vtkRenderer.h>
95 void GEOMToolsGUI::OnCheckGeometry()
97 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
98 PyConsole_Console* pyConsole = app->pythonConsole();
101 pyConsole->exec("from GEOM_usinggeom import *");
104 void GEOMToolsGUI::OnAutoColor()
106 SALOME_ListIO selected;
107 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
111 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
112 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
113 if( !aSelMgr || !appStudy )
116 aSelMgr->selectedObjects( selected );
117 if( selected.IsEmpty() )
120 Handle(SALOME_InteractiveObject) anIObject = selected.First();
122 _PTR(Study) aStudy = appStudy->studyDS();
123 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
124 GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
125 if( CORBA::is_nil( aMainObject ) )
128 aMainObject->SetAutoColor( true );
130 QList<SALOMEDS::Color> aReservedColors;
132 GEOM_Displayer aDisp (appStudy);
134 SALOME_View* vf = aDisp.GetActiveView();
136 SUIT_ViewWindow* window = app->desktop()->activeWindow();
137 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
138 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
140 for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); it->More(); it->Next() )
142 _PTR(SObject) aChildSObject( it->Value() );
143 GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
144 if( CORBA::is_nil( aChildObject ) )
147 if( aChildObject->GetType() != GEOM_GROUP )
150 SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
151 aChildObject->SetColor( aColor );
152 aReservedColors.append( aColor );
154 QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
156 SALOME_Prs* aPrs = vf->CreatePrs( aChildSObject->GetID().c_str() );
160 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
163 SVTK_View* aView = vtkVW->getView();
164 SUIT_OverrideCursor();
165 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
166 aView->SetColor( It.Value(), c );
170 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
171 Handle(AIS_InteractiveContext) ic = vm->getAISContext();
173 SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
177 AIS_ListOfInteractive aList;
178 anOCCPrs->GetObjects( aList );
179 if( !aList.Extent() )
182 Handle(AIS_InteractiveObject) io = aList.First();
186 Quantity_Color aQuanColor( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
188 // Set color for a point
189 Handle(AIS_Drawer) aCurDrawer = io->Attributes();
190 Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
191 Quantity_Color aCurColor;
192 Standard_Real aCurScale;
193 Aspect_TypeOfMarker aCurTypeOfMarker;
194 aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
195 if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
196 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aQuanColor, aCurScale) );
199 Standard_Integer aWidth, aHeight;
200 aCurPointAspect->GetTextureSize( aWidth, aHeight );
201 Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
202 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aQuanColor, 1, aWidth, aHeight, aTexture ) );
204 ic->SetLocalAttributes( io, aCurDrawer );
206 io->SetColor( aQuanColor );
207 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
208 Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aQuanColor );
210 io->Redisplay( Standard_True );
214 app->updateActions(); //SRN: To update a Save button in the toolbar
217 void GEOMToolsGUI::OnDisableAutoColor()
219 SALOME_ListIO selected;
220 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
224 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
225 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
226 if( !aSelMgr || !appStudy )
229 aSelMgr->selectedObjects( selected );
230 if( selected.IsEmpty() )
233 Handle(SALOME_InteractiveObject) anIObject = selected.First();
235 _PTR(Study) aStudy = appStudy->studyDS();
236 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
237 GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
238 if( CORBA::is_nil( aMainObject ) )
241 aMainObject->SetAutoColor( false );
245 void GEOMToolsGUI::OnColor()
247 SALOME_ListIO selected;
248 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
249 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
250 if ( app && appStudy ) {
251 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
253 aSelMgr->selectedObjects( selected );
254 if ( !selected.IsEmpty() ) {
255 SUIT_ViewWindow* window = app->desktop()->activeWindow();
256 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
257 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
258 int mgrId = window->getViewManager()->getGlobalId();
260 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
263 SVTK_View* aView = vtkVW->getView();
264 QColor initcolor = aView->GetColor( selected.First() );
265 QColor c = QColorDialog::getColor( initcolor, app->desktop() );
267 SUIT_OverrideCursor();
268 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
269 aView->SetColor( It.Value(), c );
270 appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
272 GeometryGUI::Modified();
276 Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
277 if ( !io.IsNull() ) {
278 Quantity_Color aColor;
280 QColor initcolor ((int)( aColor.Red() * 255.0 ),
281 (int)( aColor.Green() * 255.0 ),
282 (int)( aColor.Blue() * 255.0 ));
283 QColor c = QColorDialog::getColor( initcolor, app->desktop() );
285 SUIT_OverrideCursor();
286 aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
287 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
288 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
289 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
290 io = GEOMBase::GetAIS( It.Value(), true );
291 if ( !io.IsNull() ) {
293 if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) {
294 TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
295 if (theShape.ShapeType() == TopAbs_VERTEX) {
296 // Set color for a point
298 Handle(AIS_Drawer) aCurDrawer = io->Attributes();
299 Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
300 Quantity_Color aCurColor;
301 Standard_Real aCurScale;
302 Aspect_TypeOfMarker aCurTypeOfMarker;
303 aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
304 if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
305 aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aCurTypeOfMarker, aColor, aCurScale));
308 Standard_Integer aWidth, aHeight;
309 aCurPointAspect->GetTextureSize( aWidth, aHeight );
310 Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
311 aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aColor, 1, aWidth, aHeight, aTexture));
313 ic->SetLocalAttributes(io, aCurDrawer, Standard_False);
317 io->SetColor( aColor );
318 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
319 Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor );
321 appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
323 io->Redisplay( Standard_True );
325 // store color to GEOM_Object
326 _PTR(Study) aStudy = appStudy->studyDS();
327 _PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
328 GEOM::GEOM_Object_var anObject =
329 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
332 SALOMEDS::Color aSColor;
333 aSColor.R = (double)c.red() / 255.0;
334 aSColor.G = (double)c.green() / 255.0;
335 aSColor.B = (double)c.blue() / 255.0;
336 anObject->SetColor( aSColor );
337 anObject->SetAutoColor( false );
340 ic->UpdateCurrentViewer();
341 GeometryGUI::Modified();
343 } // first IO is not null
345 } // if ( selection not empty )
349 app->updateActions(); //SRN: To update a Save button in the toolbar
352 void GEOMToolsGUI::OnTransparency()
354 GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
358 void GEOMToolsGUI::OnChangeTransparency( bool increase )
360 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
363 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
366 SALOME_ListIO selected;
367 aSelMgr->selectedObjects( selected );
368 if ( selected.IsEmpty() )
371 Handle(SALOME_InteractiveObject) FirstIOS = selected.First();
372 if ( FirstIOS.IsNull() )
376 float delta = 0.1; // VSR: 23/11/2010 (transparency value <= 0.05 is ignored)
380 SUIT_ViewWindow* window = app->desktop()->activeWindow();
381 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
382 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
385 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
388 SVTK_View* aView = vtkVW->getView();
390 float transp = aView->GetTransparency(FirstIOS);
392 // Compute new transparency value
393 transp = transp + delta;
396 else if ( transp > 1 )
399 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
400 aView->SetTransparency( It.Value(), transp );
403 GeometryGUI::Modified();
407 GEOMBase* gb = new GEOMBase();
408 Handle(GEOM_AISShape) aisShape;
410 aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS, true );
411 if( aisShape.IsNull() )
413 float transp = aisShape->Transparency();
415 // Compute new transparency value
416 transp = transp + delta;
419 else if ( transp > 1 )
422 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
425 Handle(AIS_InteractiveContext) ic = vm->getAISContext();
426 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
427 aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
428 if ( !aisShape.IsNull() ) {
429 ic->SetTransparency( aisShape, transp, false );
430 ic->Redisplay( aisShape, Standard_False, Standard_True );
433 ic->UpdateCurrentViewer();
434 GeometryGUI::Modified();
438 void GEOMToolsGUI::OnNbIsos( ActionType actionType )
440 SalomeApp_Application* app =
441 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
442 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
443 SUIT_ViewWindow* window = app->desktop()->activeWindow();
445 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
446 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
448 if(isOCC){ // if is OCCViewer
450 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
451 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
454 if ( ic->MoreCurrent() ) {
455 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
456 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
458 int UIso = CurDrawer->UIsoAspect()->Number();
459 int VIso = CurDrawer->VIsoAspect()->Number();
464 if ( actionType == SHOWDLG ) {
465 GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
466 new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
468 NbIsosDlg->setU( UIso );
469 NbIsosDlg->setV( VIso );
471 if ( NbIsosDlg->exec() ) {
472 SUIT_OverrideCursor();
474 newNbUIso = NbIsosDlg->getU();
475 newNbVIso = NbIsosDlg->getV();
479 else if ( actionType == INCR || actionType == DECR ) {
481 if (actionType == DECR)
484 newNbUIso = UIso + delta;
485 newNbVIso = VIso + delta;
487 if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
491 for(; ic->MoreCurrent(); ic->NextCurrent()) {
492 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
496 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
498 CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbUIso) );
499 CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbVIso) );
501 ic->SetLocalAttributes(CurObject, CurDrawer);
502 ic->Redisplay(CurObject);
504 QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
505 int aMgrId = window->getViewManager()->getGlobalId();
506 aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), "Isos", anIsos);
509 GeometryGUI::Modified();
511 else if(isVTK){ // if is VTKViewer
513 // Warning. It's works incorrect. must be recheked.
515 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >
516 ( SUIT_Session::session()->activeApplication() );
519 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
522 SALOME_ListIO selected;
523 aSelMgr->selectedObjects( selected );
524 if ( selected.IsEmpty() )
527 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
531 SALOME_View* view = GEOM_Displayer::GetActiveView();
533 vtkActorCollection* aCollection = vtkActorCollection::New();
535 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
536 Handle(SALOME_InteractiveObject) anIObject = It.Value();
537 SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() );
538 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
540 vtkActorCollection* anActors = vtkPrs->GetObjects();
541 anActors->InitTraversal();
542 vtkActor* anAct = anActors->GetNextActor();
543 aCollection->AddItem(anAct);
548 aCollection->InitTraversal();
555 vtkActor* anAct = aCollection->GetNextActor();
556 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
557 anActor->GetNbIsos(UIso,VIso);
564 if ( actionType == SHOWDLG ) {
565 GEOMToolsGUI_NbIsosDlg* NbIsosDlg =
566 new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
568 NbIsosDlg->setU( UIso );
569 NbIsosDlg->setV( VIso );
571 if ( NbIsosDlg->exec() ) {
572 SUIT_OverrideCursor();
574 newNbUIso = NbIsosDlg->getU();
575 newNbVIso = NbIsosDlg->getV();
577 return; //Cancel case
579 else if ( actionType == INCR || actionType == DECR ) {
581 if (actionType == DECR)
584 newNbUIso = UIso + delta;
585 newNbVIso = VIso + delta;
587 if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
591 while( anAct!=NULL ) {
592 if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){
593 // There are no casting to needed actor.
594 int aIsos[2]={newNbUIso,newNbVIso};
595 anActor->SetNbIsos(aIsos);
597 QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
598 int aMgrId = window->getViewManager()->getGlobalId();
599 aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_PROP, anIsos);
601 anAct = aCollection->GetNextActor();
604 GeometryGUI::Modified();
608 void GEOMToolsGUI::OnDeflection()
610 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
611 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
614 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
615 bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
616 int mgrId = window->getViewManager()->getGlobalId();
618 if (isOCC) { // if is OCCViewer
619 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
620 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
623 if (ic->MoreCurrent()) {
624 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
626 Standard_Real aDC, aPrevDC;
627 Standard_Boolean isOwnDC = CurObject->OwnDeviationCoefficient(aDC, aPrevDC);
629 aDC = ic->DeviationCoefficient();
631 GEOMToolsGUI_DeflectionDlg * DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
632 (SUIT_Session::session()->activeApplication()->desktop());
633 DeflectionDlg->setTheDC(aDC);
637 if (DeflectionDlg->exec()) {
638 SUIT_OverrideCursor();
639 aNewDC = DeflectionDlg->getTheDC();
640 ok = (1e-07 <= aNewDC && aNewDC <= 1.0); // spinbox can return zero
642 for (; ic->MoreCurrent(); ic->NextCurrent()) {
643 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
644 ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True);
645 ic->Redisplay(CurObject);
646 appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aNewDC);
655 GeometryGUI::Modified();
657 else if (isVTK) { // if is VTKViewer
658 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
659 (SUIT_Session::session()->activeApplication());
663 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
667 SALOME_ListIO selected;
668 aSelMgr->selectedObjects(selected);
669 if (selected.IsEmpty())
672 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
676 SALOME_View* view = GEOM_Displayer::GetActiveView();
678 vtkActorCollection* aCollection = vtkActorCollection::New();
680 for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
681 Handle(SALOME_InteractiveObject) anIObject = It.Value();
682 SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
683 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
685 vtkActorCollection* anActors = vtkPrs->GetObjects();
686 anActors->InitTraversal();
687 vtkActor* anAct = anActors->GetNextActor();
688 aCollection->AddItem(anAct);
693 aCollection->InitTraversal();
699 vtkActor* anAct = aCollection->GetNextActor();
700 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
701 aDC = anActor->GetDeflection();
705 GEOMToolsGUI_DeflectionDlg* DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
706 (SUIT_Session::session()->activeApplication()->desktop());
707 DeflectionDlg->setTheDC(aDC);
708 if (DeflectionDlg->exec()) {
709 SUIT_OverrideCursor();
710 aDC = DeflectionDlg->getTheDC();
711 while (anAct != NULL) {
712 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
713 // There are no casting to needed actor.
714 anActor->SetDeflection(aDC);
715 appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
717 anAct = aCollection->GetNextActor();
720 GeometryGUI::Modified();
724 void GEOMToolsGUI::OnSelectOnly(int mode)
726 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
728 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
729 GEOM_Displayer aDisp (appStudy);
730 aDisp.GlobalSelection(mode);
731 getGeometryGUI()->setLocalSelectionMode(mode);
735 void GEOMToolsGUI::OnShowHideChildren( bool show )
737 SALOME_ListIO selected;
738 SalomeApp_Application* app =
739 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
741 SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
743 GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
746 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
747 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
748 if ( aSelMgr && appStudy ) {
749 aSelMgr->selectedObjects( selected );
750 if ( !selected.IsEmpty() ) {
751 _PTR(Study) aStudy = appStudy->studyDS();
752 _PTR(StudyBuilder) B = aStudy->NewBuilder();
754 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
756 SUIT_MessageBox::warning( app->desktop(),
757 QObject::tr( "WRN_WARNING" ),
758 QObject::tr( "WRN_STUDY_LOCKED" ) );
762 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
763 Handle(SALOME_InteractiveObject) IObject = It.Value();
765 _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
766 _PTR(GenericAttribute) anAttr;
768 _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
769 aExp->SetExpandable( show );
771 disp->EraseWithChildren(IObject,true);
776 app->updateObjectBrowser( false );
777 app->updateActions();
781 void GEOMToolsGUI::OnPointMarker()
783 GEOMToolsGUI_MarkerDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
788 void GEOMToolsGUI::OnUnpublishObject() {
789 SALOME_ListIO selected;
790 SalomeApp_Application* app =
791 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
793 SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
795 GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
798 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
799 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
800 if ( aSelMgr && appStudy ) {
801 aSelMgr->selectedObjects( selected );
802 if ( !selected.IsEmpty() ) {
803 _PTR(Study) aStudy = appStudy->studyDS();
804 _PTR(StudyBuilder) B = aStudy->NewBuilder();
806 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
808 SUIT_MessageBox::warning( app->desktop(),
809 QObject::tr( "WRN_WARNING" ),
810 QObject::tr( "WRN_STUDY_LOCKED" ) );
814 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
815 Handle(SALOME_InteractiveObject) IObject = It.Value();
817 _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
818 _PTR(GenericAttribute) anAttr;
820 _PTR(AttributeDrawable) aDrw = B->FindOrCreateAttribute( obj, "AttributeDrawable" );
821 aDrw->SetDrawable( false );
822 disp->EraseWithChildren(IObject);
825 aSelMgr->clearSelected();
828 app->updateObjectBrowser( false );
829 app->updateActions();
834 void GEOMToolsGUI::OnPublishObject() {
835 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
839 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
843 _PTR(Study) aStudy = appStudy->studyDS();
848 //Check lock of the study
849 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
851 SUIT_MessageBox::warning( app->desktop(),
852 QObject::tr( "WRN_WARNING" ),
853 QObject::tr( "WRN_STUDY_LOCKED" ) );
857 GEOMToolsGUI_PublishDlg * publishDlg =
858 new GEOMToolsGUI_PublishDlg( SUIT_Session::session()->activeApplication()->desktop() );