1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "SMESHGUI_VTKUtils.h"
22 #include "SMESHGUI_Utils.h"
23 #include "SMESHGUI_Filter.h"
26 #include "SMESH_Actor.h"
27 #include "SMESH_ObjectDef.h"
29 #include <SUIT_Desktop.h>
30 #include <SUIT_Session.h>
31 #include <SUIT_Study.h>
33 #include <SALOME_ListIO.hxx>
34 #include <SALOME_ListIteratorOfListIO.hxx>
36 #include <SVTK_Selector.h>
37 #include <SVTK_ViewModel.h>
38 #include <SVTK_ViewWindow.h>
40 #include <LightApp_SelectionMgr.h>
41 #include <SalomeApp_Application.h>
42 #include <SalomeApp_Study.h>
44 #include <utilities.h>
46 #include <SALOMEconfig.h>
47 #include CORBA_CLIENT_HEADER(SMESH_Gen)
48 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
49 #include CORBA_CLIENT_HEADER(SMESH_Group)
50 #include CORBA_CLIENT_HEADER(SMESH_Hypothesis)
52 #include <SALOMEDSClient_Study.hxx>
53 #include <SALOMEDSClient_SObject.hxx>
56 #include <vtkRenderer.h>
57 #include <vtkActorCollection.h>
60 #include <TColStd_IndexedMapOfInteger.hxx>
69 typedef map<TKeyOfVisualObj,TVisualObjPtr> TVisualObjCont;
70 static TVisualObjCont VISUAL_OBJ_CONT;
72 TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry){
73 TVisualObjPtr aVisualObj;
75 TVisualObjCont::key_type aKey(theStudyId,theEntry);
76 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(aKey);
77 if(anIter != VISUAL_OBJ_CONT.end()){
78 aVisualObj = anIter->second;
80 SalomeApp_Application* app =
81 dynamic_cast<SalomeApp_Application*>( SMESHGUI::activeStudy()->application() );
82 _PTR(Study) aStudy = SMESHGUI::activeStudy()->studyDS();
83 _PTR(SObject) aSObj = aStudy->FindObjectID(theEntry);
85 _PTR(GenericAttribute) anAttr;
86 if(aSObj->FindAttribute(anAttr,"AttributeIOR")){
87 _PTR(AttributeIOR) anIOR = anAttr;
88 CORBA::String_var aVal = anIOR->Value().c_str();
89 CORBA::Object_var anObj = app->orb()->string_to_object( aVal.in() );
90 if(!CORBA::is_nil(anObj)){
91 //Try narrow to SMESH_Mesh interafce
92 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj);
93 if(!aMesh->_is_nil()){
94 aVisualObj.reset(new SMESH_MeshObj(aMesh));
96 TVisualObjCont::value_type aValue(aKey,aVisualObj);
97 VISUAL_OBJ_CONT.insert(aValue);
100 //Try narrow to SMESH_Group interafce
101 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObj);
102 if(!aGroup->_is_nil()){
103 _PTR(SObject) aFatherSObj = aSObj->GetFather();
104 if(!aFatherSObj) return aVisualObj;
105 aFatherSObj = aFatherSObj->GetFather();
106 if(!aFatherSObj) return aVisualObj;
107 CORBA::String_var anEntry = aFatherSObj->GetID().c_str();
108 TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in());
109 if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
110 aVisualObj.reset(new SMESH_GroupObj(aGroup,aMeshObj));
111 aVisualObj->Update();
112 TVisualObjCont::value_type aValue(aKey,aVisualObj);
113 VISUAL_OBJ_CONT.insert(aValue);
117 //Try narrow to SMESH_subMesh interafce
118 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj);
119 if(!aSubMesh->_is_nil()){
120 _PTR(SObject) aFatherSObj = aSObj->GetFather();
121 if(!aFatherSObj) return aVisualObj;
122 aFatherSObj = aFatherSObj->GetFather();
123 if(!aFatherSObj) return aVisualObj;
124 CORBA::String_var anEntry = aFatherSObj->GetID().c_str();
125 TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in());
126 if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
127 aVisualObj.reset(new SMESH_subMeshObj(aSubMesh,aMeshObj));
128 aVisualObj->Update();
129 TVisualObjCont::value_type aValue(aKey,aVisualObj);
130 VISUAL_OBJ_CONT.insert(aValue);
139 INFOS("GetMeshObj - There is no SMESH_Mesh object for the SALOMEDS::Strudy and Entry!!!");
145 /*! Return active view window, if it instantiates SVTK_ViewWindow class,
146 * overwise find or create corresponding view window, make it active and return it.
147 * \note Active VVTK_ViewWindow can be returned, because it inherits SVTK_ViewWindow.
149 SVTK_ViewWindow* GetViewWindow (const SalomeApp_Module* theModule,
150 bool createIfNotFound)
152 SalomeApp_Application* anApp;
154 anApp = theModule->getApp();
156 anApp = dynamic_cast<SalomeApp_Application*>
157 (SUIT_Session::session()->activeApplication());
160 if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow()))
163 SUIT_ViewManager* aViewManager =
164 anApp->getViewManager(SVTK_Viewer::Type(), createIfNotFound);
166 if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
167 if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
168 aViewWindow->raise();
169 aViewWindow->setFocus();
178 SVTK_ViewWindow* FindVtkViewWindow (SUIT_ViewManager* theMgr,
179 SUIT_ViewWindow * theWindow)
184 QPtrVector<SUIT_ViewWindow> views = theMgr->getViews();
185 if( views.containsRef( theWindow ) )
186 return GetVtkViewWindow( theWindow );
191 SVTK_ViewWindow* GetVtkViewWindow(SUIT_ViewWindow* theWindow){
192 return dynamic_cast<SVTK_ViewWindow*>(theWindow);
195 /* SUIT_ViewWindow* GetActiveWindow()
197 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
200 SUIT_ViewManager* mgr = app->activeViewManager();
202 return mgr->getActiveView();
207 SVTK_ViewWindow* GetCurrentVtkView(){
208 return GetVtkViewWindow( GetActiveWindow() );
212 void RepaintCurrentView()
214 if (SVTK_ViewWindow* wnd = GetCurrentVtkView())
216 wnd->getRenderer()->Render();
221 void RepaintViewWindow(SVTK_ViewWindow* theWindow)
223 theWindow->getRenderer()->Render();
224 theWindow->Repaint();
227 void RenderViewWindow(SVTK_ViewWindow* theWindow)
229 theWindow->getRenderer()->Render();
230 theWindow->Repaint();
234 if(SVTK_ViewWindow* wnd = GetCurrentVtkView() ){
241 SMESH_Actor* FindActorByEntry(SUIT_ViewWindow *theWindow,
242 const char* theEntry)
244 if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow)){
245 vtkRenderer *aRenderer = aViewWindow->getRenderer();
246 vtkActorCollection *aCollection = aRenderer->GetActors();
247 aCollection->InitTraversal();
248 while(vtkActor *anAct = aCollection->GetNextActor()){
249 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
250 if(anActor->hasIO()){
251 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
252 if(anIO->hasEntry() && strcmp(anIO->getEntry(),theEntry) == 0){
263 SMESH_Actor* FindActorByEntry(const char* theEntry){
264 return FindActorByEntry(GetActiveWindow(),theEntry);
268 SMESH_Actor* FindActorByObject(CORBA::Object_ptr theObject){
269 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
273 if(!CORBA::is_nil(theObject)){
274 _PTR(Study) aStudy = GetActiveStudyDocument();
275 CORBA::String_var anIOR = app->orb()->object_to_string( theObject );
276 _PTR(SObject) aSObject = aStudy->FindObjectIOR(anIOR.in());
278 CORBA::String_var anEntry = aSObject->GetID().c_str();
279 return FindActorByEntry(anEntry.in());
286 SMESH_Actor* CreateActor(_PTR(Study) theStudy,
287 const char* theEntry,
290 SMESH_Actor *anActor = NULL;
291 CORBA::Long anId = theStudy->StudyId();
292 if(TVisualObjPtr aVisualObj = GetVisualObj(anId,theEntry)){
293 _PTR(SObject) aSObj = theStudy->FindObjectID(theEntry);
295 _PTR(GenericAttribute) anAttr;
296 if(aSObj->FindAttribute(anAttr,"AttributeName")){
297 _PTR(AttributeName) aName = anAttr;
298 std::string aNameVal = aName->Value();
299 anActor = SMESH_Actor::New(aVisualObj,theEntry,aNameVal.c_str(),theIsClear);
307 void DisplayActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){
308 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){
309 vtkWnd->AddActor(theActor);
315 void RemoveActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){
316 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){
317 vtkWnd->RemoveActor(theActor);
318 if(theActor->hasIO()){
319 Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
320 if(anIO->hasEntry()){
321 std::string anEntry = anIO->getEntry();
322 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( vtkWnd->getViewManager()->study() );
323 int aStudyId = aStudy->id();
324 TVisualObjCont::key_type aKey(aStudyId,anEntry);
325 VISUAL_OBJ_CONT.erase(aKey);
334 void UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry)
336 if(SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd)){
337 vtkRenderer *aRenderer = aViewWnd->getRenderer();
338 vtkActorCollection *aCollection = aRenderer->GetActors();
339 aCollection->InitTraversal();
342 while(vtkActor *anAct = aCollection->GetNextActor()){
343 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
344 anActor->SetVisibility(true);
351 while(vtkActor *anAct = aCollection->GetNextActor()){
352 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
353 anActor->SetVisibility(false);
358 if(SMESH_Actor *anActor = FindActorByEntry(theWnd,theEntry)){
362 anActor->SetVisibility(true);
363 if (theAction == eDisplayOnly) aRenderer->ResetCameraClippingRange();
366 anActor->SetVisibility(false);
373 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( theWnd->getViewManager()->study() );
374 _PTR(Study) aDocument = aStudy->studyDS();
375 if((anActor = CreateActor(aDocument,theEntry,true))) {
376 DisplayActor(theWnd,anActor);
377 // FitAll(); - PAL16770(Display of a group performs an automatic fit all)
389 void UpdateView(EDisplaing theAction, const char* theEntry){
390 SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( GetActiveStudy() );
391 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() );
392 SUIT_ViewWindow *aWnd = app->activeViewManager()->getActiveView();
393 UpdateView(aWnd,theAction,theEntry);
397 if(SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView()){
398 LightApp_SelectionMgr* mgr = SMESHGUI::selectionMgr();
399 SALOME_ListIO selected; mgr->selectedObjects( selected );
401 if( selected.Extent() == 0){
402 vtkRenderer* aRenderer = aWnd->getRenderer();
403 vtkActorCollection *aCollection = aRenderer->GetActors();
404 aCollection->InitTraversal();
405 while(vtkActor *anAct = aCollection->GetNextActor()){
406 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
408 Update(anActor->getIO(),anActor->GetVisibility());
412 SALOME_ListIteratorOfListIO anIter( selected );
413 for(; anIter.More(); anIter.Next()){
414 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
418 RepaintCurrentView();
423 void Update(const Handle(SALOME_InteractiveObject)& theIO,
426 _PTR(Study) aStudy = GetActiveStudyDocument();
427 CORBA::Long anId = aStudy->StudyId();
428 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry());
430 aVisualObj->Update();
432 UpdateView(SMESH::eDisplay,theIO->getEntry());
436 void UpdateSelectionProp( SMESHGUI* theModule ) {
440 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( theModule->application() );
443 MESSAGE( "UpdateSelectionProp: Application is null" );
447 SUIT_ViewManager* vm = app->activeViewManager();
450 MESSAGE( "UpdateSelectionProp: View manager is null" );
454 QPtrVector<SUIT_ViewWindow> views = vm->getViews();
456 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( theModule );
459 MESSAGE( "UpdateSelectionProp: Resource manager is null" );
463 QColor aHiColor = mgr->colorValue( "SMESH", "selection_object_color", Qt::white ),
464 aSelColor = mgr->colorValue( "SMESH", "selection_element_color", Qt::yellow ),
465 aPreColor = mgr->colorValue( "SMESH", "highlight_color", Qt::cyan );
467 int SW = mgr->integerValue( "SMESH", "selection_width", 5 ),
468 PW = mgr->integerValue( "SMESH", "highlight_width", 5 );
470 double SP1 = mgr->doubleValue( "SMESH", "selection_precision_node", 0.025 ),
471 SP2 = mgr->doubleValue( "SMESH", "selection_precision_element", 0.001 );
473 for ( int i=0, n=views.count(); i<n; i++ ){
474 // update VTK viewer properties
475 if(SVTK_ViewWindow* aVtkView = GetVtkViewWindow( views[i] )){
476 // mesh element selection
477 aVtkView->SetSelectionProp(aSelColor.red()/255.,
478 aSelColor.green()/255.,
479 aSelColor.blue()/255.,
482 aVtkView->SetSelectionTolerance(SP1, SP2);
485 aVtkView->SetPreselectionProp(aPreColor.red()/255.,
486 aPreColor.green()/255.,
487 aPreColor.blue()/255.,
490 vtkRenderer* aRenderer = aVtkView->getRenderer();
491 vtkActorCollection *aCollection = aRenderer->GetActors();
492 aCollection->InitTraversal();
493 while(vtkActor *anAct = aCollection->GetNextActor()){
494 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
495 anActor->SetHighlightColor(aHiColor.red()/255.,
496 aHiColor.green()/255.,
497 aHiColor.blue()/255.);
498 anActor->SetPreHighlightColor(aPreColor.red()/255.,
499 aPreColor.green()/255.,
500 aPreColor.blue()/255.);
508 //----------------------------------------------------------------------------
510 GetSelector(SUIT_ViewWindow *theWindow)
512 if(SVTK_ViewWindow* aWnd = GetVtkViewWindow(theWindow))
513 return aWnd->GetSelector();
518 void SetFilter(const Handle(VTKViewer_Filter)& theFilter,
519 SVTK_Selector* theSelector)
522 theSelector->SetFilter(theFilter);
525 Handle(VTKViewer_Filter) GetFilter(int theId, SVTK_Selector* theSelector)
527 return theSelector->GetFilter(theId);
530 bool IsFilterPresent(int theId, SVTK_Selector* theSelector)
532 return theSelector->IsFilterPresent(theId);
535 void RemoveFilter(int theId, SVTK_Selector* theSelector)
537 theSelector->RemoveFilter(theId);
540 void RemoveFilters(SVTK_Selector* theSelector)
542 for ( int id = SMESHGUI_NodeFilter; theSelector && id < SMESHGUI_LastFilter; id++ )
543 theSelector->RemoveFilter( id );
546 bool IsValid(SALOME_Actor* theActor, int theCellId,
547 SVTK_Selector* theSelector)
549 return theSelector->IsValid(theActor,theCellId);
553 //----------------------------------------------------------------------------
554 void SetPointRepresentation(bool theIsVisible){
555 if(SVTK_ViewWindow* aViewWindow = GetCurrentVtkView()){
556 vtkRenderer *aRenderer = aViewWindow->getRenderer();
557 vtkActorCollection *aCollection = aRenderer->GetActors();
558 aCollection->InitTraversal();
559 while(vtkActor *anAct = aCollection->GetNextActor()){
560 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
561 if(anActor->GetVisibility()){
562 anActor->SetPointRepresentation(theIsVisible);
566 RepaintCurrentView();
571 void SetPickable(SMESH_Actor* theActor){
572 if(SVTK_ViewWindow* aWnd = GetCurrentVtkView()){
573 int anIsAllPickable = (theActor == NULL);
574 vtkRenderer *aRenderer = aWnd->getRenderer();
575 vtkActorCollection *aCollection = aRenderer->GetActors();
576 aCollection->InitTraversal();
577 while(vtkActor *anAct = aCollection->GetNextActor()){
578 if(SALOME_Actor *anActor = dynamic_cast<SALOME_Actor*>(anAct)){
579 if(anActor->GetVisibility()){
580 anActor->SetPickable(anIsAllPickable);
585 theActor->SetPickable(!anIsAllPickable);
586 RepaintCurrentView();
591 //----------------------------------------------------------------------------
592 int GetNameOfSelectedNodes(SVTK_Selector* theSelector,
593 const Handle(SALOME_InteractiveObject)& theIO,
597 TColStd_IndexedMapOfInteger aMapIndex;
598 theSelector->GetIndex(theIO,aMapIndex);
600 for(int i = 1; i <= aMapIndex.Extent(); i++)
601 theName += QString(" %1").arg(aMapIndex(i));
603 return aMapIndex.Extent();
606 int GetNameOfSelectedElements(SVTK_Selector* theSelector,
607 const Handle(SALOME_InteractiveObject)& theIO,
611 TColStd_IndexedMapOfInteger aMapIndex;
612 theSelector->GetIndex(theIO,aMapIndex);
614 typedef std::set<int> TIdContainer;
615 TIdContainer anIdContainer;
616 for( int i = 1; i <= aMapIndex.Extent(); i++)
617 anIdContainer.insert(aMapIndex(i));
619 TIdContainer::const_iterator anIter = anIdContainer.begin();
620 for(; anIter != anIdContainer.end(); anIter++)
621 theName += QString(" %1").arg(*anIter);
623 return aMapIndex.Extent();
627 int GetEdgeNodes(SVTK_Selector* theSelector,
628 const TVisualObjPtr& theVisualObject,
632 const SALOME_ListIO& selected = theSelector->StoredIObjects();
634 if ( selected.Extent() != 1 )
637 Handle(SALOME_InteractiveObject) anIO = selected.First();
638 if ( anIO.IsNull() || !anIO->hasEntry() )
641 TColStd_IndexedMapOfInteger aMapIndex;
642 theSelector->GetIndex( anIO, aMapIndex );
643 if ( aMapIndex.Extent() != 2 )
646 int anObjId = -1, anEdgeNum = -1;
647 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
648 int aVal = aMapIndex( i );
652 anEdgeNum = abs( aVal ) - 1;
655 if ( anObjId == -1 || anEdgeNum == -1 )
658 return theVisualObject->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
661 //----------------------------------------------------------------------------
662 int GetNameOfSelectedNodes(LightApp_SelectionMgr *theMgr,
663 const Handle(SALOME_InteractiveObject)& theIO,
667 if(theIO->hasEntry()){
668 if(FindActorByEntry(theIO->getEntry())){
669 TColStd_IndexedMapOfInteger aMapIndex;
670 theMgr->GetIndexes(theIO,aMapIndex);
671 for(int i = 1; i <= aMapIndex.Extent(); i++){
672 theName += QString(" %1").arg(aMapIndex(i));
674 return aMapIndex.Extent();
680 int GetNameOfSelectedNodes(LightApp_SelectionMgr *theMgr, QString& theName){
682 SALOME_ListIO selected; theMgr->selectedObjects( selected );
683 if(selected.Extent() == 1){
684 Handle(SALOME_InteractiveObject) anIO = selected.First();
685 return GetNameOfSelectedNodes(theMgr,anIO,theName);
691 int GetNameOfSelectedElements(LightApp_SelectionMgr *theMgr,
692 const Handle(SALOME_InteractiveObject)& theIO,
696 if(theIO->hasEntry()){
697 if(FindActorByEntry(theIO->getEntry())){
698 TColStd_IndexedMapOfInteger aMapIndex;
699 theMgr->GetIndexes(theIO,aMapIndex);
700 typedef set<int> TIdContainer;
701 TIdContainer anIdContainer;
702 for( int i = 1; i <= aMapIndex.Extent(); i++)
703 anIdContainer.insert(aMapIndex(i));
704 TIdContainer::const_iterator anIter = anIdContainer.begin();
705 for(; anIter != anIdContainer.end(); anIter++){
706 theName += QString(" %1").arg(*anIter);
708 return aMapIndex.Extent();
715 int GetNameOfSelectedElements(LightApp_SelectionMgr *theMgr, QString& theName)
718 SALOME_ListIO selected; theMgr->selectedObjects( selected );
720 if( selected.Extent() == 1){
721 Handle(SALOME_InteractiveObject) anIO = selected.First();
722 return GetNameOfSelectedElements(theMgr,anIO,theName);
727 int GetSelected(LightApp_SelectionMgr* theMgr,
728 TColStd_IndexedMapOfInteger& theMap,
729 const bool theIsElement)
732 SALOME_ListIO selected; theMgr->selectedObjects( selected );
734 if ( selected.Extent() == 1 )
736 Handle(SALOME_InteractiveObject) anIO = selected.First();
737 if ( anIO->hasEntry() ) {
738 theMgr->GetIndexes( anIO, theMap );
741 return theMap.Extent();
745 int GetEdgeNodes( LightApp_SelectionMgr* theMgr, int& theId1, int& theId2 )
747 SALOME_ListIO selected; theMgr->selectedObjects( selected );
749 if ( selected.Extent() != 1 )
752 Handle(SALOME_InteractiveObject) anIO = selected.First();
753 if ( anIO.IsNull() || !anIO->hasEntry() )
756 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry() );
760 TColStd_IndexedMapOfInteger aMapIndex;
761 theMgr->GetIndexes( anIO, aMapIndex );
762 if ( aMapIndex.Extent() != 2 )
765 int anObjId = -1, anEdgeNum = -1;
766 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
767 int aVal = aMapIndex( i );
771 anEdgeNum = abs( aVal );
774 if ( anObjId == -1 || anEdgeNum == -1 )
777 return anActor->GetObject()->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
780 void SetControlsPrecision( const long theVal )
782 if( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView() )
784 vtkRenderer *aRenderer = aWnd->getRenderer();
785 vtkActorCollection *aCollection = aRenderer->GetActors();
786 aCollection->InitTraversal();
788 while ( vtkActor *anAct = aCollection->GetNextActor())
790 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct ) )
792 anActor->SetControlsPrecision( theVal );
793 anActor->SetControlMode( anActor->GetControlMode() );