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);
563 if (DeflectionDlg->exec()) {
564 SUIT_OverrideCursor();
565 aNewDC = DeflectionDlg->getDC();
566 ok = (1e-07 <= aNewDC && aNewDC <= 1.0); // spinbox can return zero
568 for (; ic->MoreCurrent(); ic->NextCurrent()) {
569 CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
570 ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True);
571 ic->Redisplay(CurObject);
581 else if (isVTK) { // if is VTKViewer
582 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
583 (SUIT_Session::session()->activeApplication());
587 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
591 SALOME_ListIO selected;
592 aSelMgr->selectedObjects(selected);
593 if (selected.IsEmpty())
596 SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
600 SALOME_View* view = GEOM_Displayer::GetActiveView();
602 vtkActorCollection* aCollection = vtkActorCollection::New();
604 for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
605 Handle(SALOME_InteractiveObject) anIObject = It.Value();
606 SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
607 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
609 vtkActorCollection* anActors = vtkPrs->GetObjects();
610 anActors->InitTraversal();
611 vtkActor* anAct = anActors->GetNextActor();
612 aCollection->AddItem(anAct);
617 aCollection->InitTraversal();
623 vtkActor* anAct = aCollection->GetNextActor();
624 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
625 aDC = anActor->GetDeflection();
629 GEOMToolsGUI_DeflectionDlg* DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
630 (SUIT_Session::session()->activeApplication()->desktop());
631 DeflectionDlg->setDC(aDC);
632 if (DeflectionDlg->exec()) {
633 SUIT_OverrideCursor();
634 aDC = DeflectionDlg->getDC();
635 while (anAct != NULL) {
636 if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
637 // There are no casting to needed actor.
638 bool isRel = anActor->GetIsRelative();
639 anActor->SetDeflection(aDC, isRel);
641 anAct = aCollection->GetNextActor();
647 void GEOMToolsGUI::OnOpen()
650 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
651 _PTR(Study) aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
653 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
654 Handle(SALOME_InteractiveObject) anIObject;
655 for(;It.More();It.Next()) {
656 anIObject = It.Value();
657 _PTR(SObject) obj ( aStudy->FindObjectID(anIObject->getEntry()) );
658 _PTR(AttributePersistentRef) aPersist;
659 _PTR(AttributeIOR) anIOR;
661 // this SObject may be GEOM module root SObject
662 _PTR(ChildIterator) anIter ( aStudy->NewChildIterator() );
663 _PTR(GenericAttribute) anAttr;
664 bool useSubItems = false;
665 while (anIter->More() && !useSubItems) {
666 _PTR(SObject) subobj ( anIter->Value() );
667 if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) {
674 obj->FindAttribute(anAttr, "AttributePersistentRef");
676 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
677 if(!obj->FindAttribute(anAttr, "AttributeIOR") &&
678 obj->FindAttribute(anAttr, "AttributePersistentRef")) {
679 _PTR(SComponent) FComp ( obj->GetFatherComponent() );
681 if (FComp->FindAttribute(anAttr, "AttributeName")) {
682 _PTR(AttributeName) aName ( anAttr );
683 QString compName = QAD_Application::getDesktop()->getComponentName(aName->Value().c_str());
684 // parent->loadComponentData(parent->getComponentName(aName->Value()));
685 Engines::Component_var comp ;
686 if ( compName.compare("SUPERV") == 0 ) {
687 comp = QAD_Application::getDesktop()->getEngine( "SuperVisionContainer", compName) ;
690 comp = QAD_Application::getDesktop()->getEngine( "FactoryServer", compName);
691 if ( comp->_is_nil() )
692 comp = QAD_Application::getDesktop()->getEngine( "FactoryServerPy", compName);
695 if (!CORBA::is_nil(comp)) {
696 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
697 if (!CORBA::is_nil(driver)) {
698 SALOMEDS::StudyBuilder_var B = dynamic_cast<SALOMEDS_Study*>(aStudy.get())->GetStudy()->NewBuilder();
699 if (!CORBA::is_nil(B)) {
700 B->LoadWith(FComp,driver);
706 MESSAGE("loadComponentData(): Driver is null");
711 MESSAGE("loadComponentData(): Engine is null");
715 // Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer","GEOM");
716 // if (!CORBA::is_nil(comp)) {
717 // SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
718 // SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
719 // SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM");
720 // if (!CORBA::is_nil(SC))
721 // aStudyBuilder->LoadWith(SC,driver);
725 MESSAGE("Component is null");
730 obj.reset( anIter->Value() );
740 void GEOMToolsGUI::OnSelectOnly(int mode)
742 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
744 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
745 GEOM_Displayer aDisp (appStudy);
746 aDisp.GlobalSelection(mode);
747 getGeometryGUI()->setLocalSelectionMode(mode);
751 void GEOMToolsGUI::OnShowHideChildren( bool show )
753 SALOME_ListIO selected;
754 SalomeApp_Application* app =
755 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
757 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
758 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
759 if ( aSelMgr && appStudy ) {
760 aSelMgr->selectedObjects( selected );
761 if ( !selected.IsEmpty() ) {
762 _PTR(Study) aStudy = appStudy->studyDS();
763 _PTR(StudyBuilder) B = aStudy->NewBuilder();
765 bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
767 SUIT_MessageBox::warning( app->desktop(),
768 QObject::tr( "WRN_WARNING" ),
769 QObject::tr( "WRN_STUDY_LOCKED" ) );
773 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
774 Handle(SALOME_InteractiveObject) IObject = It.Value();
776 _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
777 _PTR(GenericAttribute) anAttr;
779 _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
780 aExp->SetExpandable( show );
785 app->updateObjectBrowser( false );
786 app->updateActions();
790 void GEOMToolsGUI::OnPointMarker()
792 GEOMToolsGUI_MarkerDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );