1 // Copyright (C) 2007-2008 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
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File : GEOMToolsGUI_1.cxx
24 // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
26 #include <PyConsole_Console.h>
28 #include "GEOMToolsGUI.h"
29 #include "GEOMToolsGUI_TransparencyDlg.h"
30 #include "GEOMToolsGUI_NbIsosDlg.h"
31 #include "GEOMToolsGUI_DeflectionDlg.h"
32 #include "GEOMToolsGUI_MarkerDlg.h"
34 #include <GeometryGUI.h>
35 #include <GEOM_Displayer.h>
38 #include <GEOM_Actor.h>
40 #include <SALOME_ListIO.hxx>
41 #include <SALOME_ListIteratorOfListIO.hxx>
46 #include <SVTK_ViewModel.h>
47 #include <SVTK_ViewWindow.h>
48 #include <SVTK_View.h>
50 #include <OCCViewer_ViewModel.h>
52 #include <SUIT_ViewManager.h>
53 #include <SUIT_Desktop.h>
54 #include <SUIT_ResourceMgr.h>
55 #include <SUIT_Session.h>
56 #include <SUIT_OverrideCursor.h>
57 #include <SUIT_MessageBox.h>
58 #include <SUIT_Tools.h>
60 #include <SalomeApp_Application.h>
61 #include <SalomeApp_Study.h>
62 #include <SalomeApp_Module.h>
64 #include <LightApp_SelectionMgr.h>
65 #include <LightApp_NameDlg.h>
67 #include <GEOMImpl_Types.hxx>
69 #include "utilities.h"
72 #include <AIS_Drawer.hxx>
73 #include <Prs3d_IsoAspect.hxx>
74 #include <Prs3d_PointAspect.hxx>
75 #include <Graphic3d_AspectMarker3d.hxx>
76 #include <Graphic3d_HArray1OfBytes.hxx>
79 #include <QColorDialog>
80 #include <QInputDialog>
83 #include <QGridLayout>
86 #include <QPushButton>
90 #include <vtkRenderer.h>
92 void GEOMToolsGUI::OnSettingsColor()
94 SUIT_Session* sess = SUIT_Session::session();
95 SUIT_ResourceMgr* resMgr = sess->resourceMgr();
96 SUIT_Desktop* desk = sess->activeApplication()->desktop();
98 QColor anInitColor = resMgr->colorValue( "Geometry", "SettingsShadingColor", QColor( "yellow" ) );
100 QColor aDialogColor = QColorDialog::getColor(anInitColor, desk );
101 if( aDialogColor.isValid() )
103 QString type = desk->activeWindow()->getViewManager()->getType();
104 if( type != OCCViewer_Viewer::Type() && type != SVTK_Viewer::Type() )
105 MESSAGE("Settings Color is not supported for current Viewer");
107 resMgr->setValue( "Geometry", "SettingsShadingColor", aDialogColor );
111 void GEOMToolsGUI::OnRename()
113 SALOME_ListIO selected;
114 SalomeApp_Application* app =
115 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
117 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
118 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
119 if ( aSelMgr && appStudy ) {
120 aSelMgr->selectedObjects( selected );
121 if ( !selected.IsEmpty() ) {
122 _PTR(Study) aStudy = appStudy->studyDS();
124 bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
126 SUIT_MessageBox::warning ( app->desktop(),
127 QObject::tr("WRN_WARNING"),
128 QObject::tr("WRN_STUDY_LOCKED") );
132 bool isAny = false; // is there any appropriate object selected
133 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
134 Handle(SALOME_InteractiveObject) IObject = It.Value();
136 _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
137 _PTR(GenericAttribute) anAttr;
139 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
140 _PTR(AttributeName) aName (anAttr);
142 GEOM::GEOM_Object_var anObj =
143 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
144 if (!CORBA::is_nil(anObj)) {
146 QString newName = LightApp_NameDlg::getName( app->desktop(), aName->Value().c_str() );
147 if (!newName.isEmpty()) {
148 aName->SetValue( newName.toLatin1().data() ); // rename the SObject
149 IObject->setName( newName.toLatin1().data() );// rename the InteractiveObject
150 anObj->SetName( newName.toLatin1().data() ); // Rename the corresponding GEOM_Object
151 (dynamic_cast<SalomeApp_Module*>(app->activeModule()))->updateObjBrowser( false );
154 } // if ( name attribute )
159 SUIT_MessageBox::warning( app->desktop(),
160 QObject::tr("WRN_WARNING"),
161 QObject::tr("GEOM_WRN_NO_APPROPRIATE_SELECTION") );
168 app->updateActions(); //SRN: To update a Save button in the toolbar
171 void GEOMToolsGUI::OnCheckGeometry()
173 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
174 PyConsole_Console* pyConsole = app->pythonConsole();
177 pyConsole->exec("from GEOM_usinggeom import *");
180 void GEOMToolsGUI::OnAutoColor()
182 SALOME_ListIO selected;
183 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
187 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
188 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
189 if( !aSelMgr || !appStudy )
192 aSelMgr->selectedObjects( selected );
193 if( selected.IsEmpty() )
196 Handle(SALOME_InteractiveObject) anIObject = selected.First();
198 _PTR(Study) aStudy = appStudy->studyDS();
199 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
200 GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
201 if( CORBA::is_nil( aMainObject ) )
204 aMainObject->SetAutoColor( true );
206 QList<SALOMEDS::Color> aReservedColors;
208 GEOM_Displayer aDisp (appStudy);
210 SALOME_View* vf = aDisp.GetActiveView();
212 SUIT_ViewWindow* window = app->desktop()->activeWindow();
213 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
214 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
216 for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); it->More(); it->Next() )
218 _PTR(SObject) aChildSObject( it->Value() );
219 GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
220 if( CORBA::is_nil( aChildObject ) )
223 if( aChildObject->GetType() != GEOM_GROUP )
226 SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
227 aChildObject->SetColor( aColor );
228 aReservedColors.append( aColor );
230 QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
232 SALOME_Prs* aPrs = vf->CreatePrs( aChildSObject->GetID().c_str() );
236 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
239 SVTK_View* aView = vtkVW->getView();
240 SUIT_OverrideCursor();
241 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
242 aView->SetColor( It.Value(), c );
246 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
247 Handle(AIS_InteractiveContext) ic = vm->getAISContext();
249 SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
253 AIS_ListOfInteractive aList;
254 anOCCPrs->GetObjects( aList );
255 if( !aList.Extent() )
258 Handle(AIS_InteractiveObject) io = aList.First();
262 Quantity_Color aQuanColor( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
264 // Set color for a point
265 Handle(AIS_Drawer) aCurDrawer = io->Attributes();
266 Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
267 Quantity_Color aCurColor;
268 Standard_Real aCurScale;
269 Aspect_TypeOfMarker aCurTypeOfMarker;
270 aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
271 if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
272 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aQuanColor, aCurScale) );
275 Standard_Integer aWidth, aHeight;
276 aCurPointAspect->GetTextureSize( aWidth, aHeight );
277 Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
278 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aQuanColor, 1, aWidth, aHeight, aTexture ) );
280 ic->SetLocalAttributes( io, aCurDrawer );
282 io->SetColor( aQuanColor );
283 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
284 Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aQuanColor );
286 io->Redisplay( Standard_True );
290 app->updateActions(); //SRN: To update a Save button in the toolbar
293 void GEOMToolsGUI::OnDisableAutoColor()
295 SALOME_ListIO selected;
296 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
300 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
301 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
302 if( !aSelMgr || !appStudy )
305 aSelMgr->selectedObjects( selected );
306 if( selected.IsEmpty() )
309 Handle(SALOME_InteractiveObject) anIObject = selected.First();
311 _PTR(Study) aStudy = appStudy->studyDS();
312 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
313 GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
314 if( CORBA::is_nil( aMainObject ) )
317 aMainObject->SetAutoColor( false );
321 void GEOMToolsGUI::OnColor()
323 SALOME_ListIO selected;
324 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
325 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
326 if ( app && appStudy ) {
327 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
329 aSelMgr->selectedObjects( selected );
330 if ( !selected.IsEmpty() ) {
331 SUIT_ViewWindow* window = app->desktop()->activeWindow();
332 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
333 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
335 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
338 SVTK_View* aView = vtkVW->getView();
339 QColor initcolor = aView->GetColor( selected.First() );
340 QColor c = QColorDialog::getColor( initcolor, app->desktop() );
342 SUIT_OverrideCursor();
343 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
344 aView->SetColor( It.Value(), c );
349 Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
350 if ( !io.IsNull() ) {
351 Quantity_Color aColor;
353 QColor initcolor ((int)( aColor.Red() * 255.0 ),
354 (int)( aColor.Green() * 255.0 ),
355 (int)( aColor.Blue() * 255.0 ));
356 QColor c = QColorDialog::getColor( initcolor, app->desktop() );
358 SUIT_OverrideCursor();
359 aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
360 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
361 io = GEOMBase::GetAIS( It.Value(), true );
362 if ( !io.IsNull() ) {
363 // Set color for a point
364 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>
365 ( window->getViewManager()->getViewModel() );
366 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
367 Handle(AIS_Drawer) aCurDrawer = io->Attributes();
368 Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
369 Quantity_Color aCurColor;
370 Standard_Real aCurScale;
371 Aspect_TypeOfMarker aCurTypeOfMarker;
372 aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
373 if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
374 aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aCurTypeOfMarker, aColor, aCurScale));
377 Standard_Integer aWidth, aHeight;
378 aCurPointAspect->GetTextureSize( aWidth, aHeight );
379 Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
380 aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aColor, 1, aWidth, aHeight, aTexture));
382 ic->SetLocalAttributes(io, aCurDrawer);
384 io->SetColor( aColor );
385 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
386 Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor );
388 io->Redisplay( Standard_True );
390 // store color to GEOM_Object
391 _PTR(Study) aStudy = appStudy->studyDS();
392 _PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
393 GEOM::GEOM_Object_var anObject =
394 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
396 SALOMEDS::Color aSColor;
397 aSColor.R = (double)c.red() / 255.0;
398 aSColor.G = (double)c.green() / 255.0;
399 aSColor.B = (double)c.blue() / 255.0;
400 anObject->SetColor( aSColor );
401 anObject->SetAutoColor( false );
405 } // first IO is not null
407 } // if ( selection not empty )
411 app->updateActions(); //SRN: To update a Save button in the toolbar
414 void GEOMToolsGUI::OnTransparency()
416 GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
420 void GEOMToolsGUI::OnNbIsos()
422 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
424 bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
425 bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
427 if(isOCC){ // if is OCCViewer
429 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
430 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
433 if ( ic->MoreCurrent() ) {
434 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
435 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
437 int UIso = CurDrawer->UIsoAspect()->Number();
438 int VIso = CurDrawer->VIsoAspect()->Number();
440 GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
441 new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
443 NbIsosDlg->setU( UIso );
444 NbIsosDlg->setV( VIso );
446 if ( NbIsosDlg->exec() ) {
447 SUIT_OverrideCursor();
448 for(; ic->MoreCurrent(); ic->NextCurrent()) {
449 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
450 Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
452 int nbUIso = NbIsosDlg->getU();
453 int nbVIso = NbIsosDlg->getV();
455 CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) );
456 CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) );
458 ic->SetLocalAttributes(CurObject, CurDrawer);
459 ic->Redisplay(CurObject);
464 else if(isVTK){ // if is VTKViewer
466 // Warning. It's works incorrect. must be recheked.
468 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >
469 ( SUIT_Session::session()->activeApplication() );
472 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
475 SALOME_ListIO selected;
476 aSelMgr->selectedObjects( selected );
477 if ( selected.IsEmpty() )
480 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
484 SALOME_View* view = GEOM_Displayer::GetActiveView();
486 vtkActorCollection* aCollection = vtkActorCollection::New();
488 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
489 Handle(SALOME_InteractiveObject) anIObject = It.Value();
490 SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() );
491 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aPrs );
493 vtkActorCollection* anActors = vtkPrs->GetObjects();
494 anActors->InitTraversal();
495 vtkActor* anAct = anActors->GetNextActor();
496 aCollection->AddItem(anAct);
501 aCollection->InitTraversal();
508 vtkActor* anAct = aCollection->GetNextActor();
509 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
510 anActor->GetNbIsos(UIso,VIso);
514 GEOMToolsGUI_NbIsosDlg* NbIsosDlg =
515 new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
517 NbIsosDlg->setU( UIso );
518 NbIsosDlg->setV( VIso );
520 if ( NbIsosDlg->exec() ) {
521 SUIT_OverrideCursor();
523 while( anAct!=NULL ) {
524 if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){
525 // There are no casting to needed actor.
526 UIso = NbIsosDlg->getU();
527 VIso = NbIsosDlg->getV();
528 int aIsos[2]={UIso,VIso};
529 anActor->SetNbIsos(aIsos);
531 anAct = aCollection->GetNextActor();
537 void GEOMToolsGUI::OnDeflection()
539 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
541 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
542 bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
544 if (isOCC) { // if is OCCViewer
545 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
546 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
549 if (ic->MoreCurrent()) {
550 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
552 Standard_Real aDC, aPrevDC;
553 Standard_Boolean isOwnDC = CurObject->OwnDeviationCoefficient(aDC, aPrevDC);
555 aDC = ic->DeviationCoefficient();
557 GEOMToolsGUI_DeflectionDlg * DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
558 (SUIT_Session::session()->activeApplication()->desktop());
559 DeflectionDlg->setDC(aDC);
560 if (DeflectionDlg->exec()) {
561 SUIT_OverrideCursor();
562 double aNewDC = DeflectionDlg->getDC();
563 for (; ic->MoreCurrent(); ic->NextCurrent()) {
564 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
565 ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True);
566 ic->Redisplay(CurObject);
571 else if (isVTK) { // if is VTKViewer
572 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
573 (SUIT_Session::session()->activeApplication());
577 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
581 SALOME_ListIO selected;
582 aSelMgr->selectedObjects(selected);
583 if (selected.IsEmpty())
586 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
590 SALOME_View* view = GEOM_Displayer::GetActiveView();
592 vtkActorCollection* aCollection = vtkActorCollection::New();
594 for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
595 Handle(SALOME_InteractiveObject) anIObject = It.Value();
596 SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
597 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
599 vtkActorCollection* anActors = vtkPrs->GetObjects();
600 anActors->InitTraversal();
601 vtkActor* anAct = anActors->GetNextActor();
602 aCollection->AddItem(anAct);
607 aCollection->InitTraversal();
613 vtkActor* anAct = aCollection->GetNextActor();
614 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
615 aDC = anActor->GetDeflection();
619 GEOMToolsGUI_DeflectionDlg* DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
620 (SUIT_Session::session()->activeApplication()->desktop());
621 DeflectionDlg->setDC(aDC);
622 if (DeflectionDlg->exec()) {
623 SUIT_OverrideCursor();
624 aDC = DeflectionDlg->getDC();
625 while (anAct != NULL) {
626 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
627 // There are no casting to needed actor.
628 bool isRel = anActor->GetIsRelative();
629 anActor->SetDeflection(aDC, isRel);
631 anAct = aCollection->GetNextActor();
637 void GEOMToolsGUI::OnOpen()
640 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
641 _PTR(Study) aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
643 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
644 Handle(SALOME_InteractiveObject) anIObject;
645 for(;It.More();It.Next()) {
646 anIObject = It.Value();
647 _PTR(SObject) obj ( aStudy->FindObjectID(anIObject->getEntry()) );
648 _PTR(AttributePersistentRef) aPersist;
649 _PTR(AttributeIOR) anIOR;
651 // this SObject may be GEOM module root SObject
652 _PTR(ChildIterator) anIter ( aStudy->NewChildIterator() );
653 _PTR(GenericAttribute) anAttr;
654 bool useSubItems = false;
655 while (anIter->More() && !useSubItems) {
656 _PTR(SObject) subobj ( anIter->Value() );
657 if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) {
664 obj->FindAttribute(anAttr, "AttributePersistentRef");
666 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
667 if(!obj->FindAttribute(anAttr, "AttributeIOR") &&
668 obj->FindAttribute(anAttr, "AttributePersistentRef")) {
669 _PTR(SComponent) FComp ( obj->GetFatherComponent() );
671 if (FComp->FindAttribute(anAttr, "AttributeName")) {
672 _PTR(AttributeName) aName ( anAttr );
673 QString compName = QAD_Application::getDesktop()->getComponentName(aName->Value().c_str());
674 // parent->loadComponentData(parent->getComponentName(aName->Value()));
675 Engines::Component_var comp ;
676 if ( compName.compare("SUPERV") == 0 ) {
677 comp = QAD_Application::getDesktop()->getEngine( "SuperVisionContainer", compName) ;
680 comp = QAD_Application::getDesktop()->getEngine( "FactoryServer", compName);
681 if ( comp->_is_nil() )
682 comp = QAD_Application::getDesktop()->getEngine( "FactoryServerPy", compName);
685 if (!CORBA::is_nil(comp)) {
686 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
687 if (!CORBA::is_nil(driver)) {
688 SALOMEDS::StudyBuilder_var B = dynamic_cast<SALOMEDS_Study*>(aStudy.get())->GetStudy()->NewBuilder();
689 if (!CORBA::is_nil(B)) {
690 B->LoadWith(FComp,driver);
696 MESSAGE("loadComponentData(): Driver is null");
701 MESSAGE("loadComponentData(): Engine is null");
705 // Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer","GEOM");
706 // if (!CORBA::is_nil(comp)) {
707 // SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
708 // SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
709 // SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM");
710 // if (!CORBA::is_nil(SC))
711 // aStudyBuilder->LoadWith(SC,driver);
715 MESSAGE("Component is null");
720 obj.reset( anIter->Value() );
730 void GEOMToolsGUI::OnSelectOnly(int mode)
732 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
734 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
735 GEOM_Displayer aDisp (appStudy);
736 aDisp.GlobalSelection(mode);
737 getGeometryGUI()->setLocalSelectionMode(mode);
741 void GEOMToolsGUI::OnShowHideChildren( bool show )
743 SALOME_ListIO selected;
744 SalomeApp_Application* app =
745 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
747 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
748 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
749 if ( aSelMgr && appStudy ) {
750 aSelMgr->selectedObjects( selected );
751 if ( !selected.IsEmpty() ) {
752 _PTR(Study) aStudy = appStudy->studyDS();
753 _PTR(StudyBuilder) B = aStudy->NewBuilder();
755 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
757 SUIT_MessageBox::warning( app->desktop(),
758 QObject::tr( "WRN_WARNING" ),
759 QObject::tr( "WRN_STUDY_LOCKED" ) );
763 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
764 Handle(SALOME_InteractiveObject) IObject = It.Value();
766 _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
767 _PTR(GenericAttribute) anAttr;
769 _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
770 aExp->SetExpandable( show );
775 app->updateObjectBrowser( false );
776 app->updateActions();
780 void GEOMToolsGUI::OnPointMarker()
782 GEOMToolsGUI_MarkerDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );