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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 #include "SMESHGUI_VTKUtils.h"
22 #include "SMESHGUI_Utils.h"
23 #include "SMESHGUI_Filter.h"
25 #include <vtkRenderer.h>
26 #include <vtkActorCollection.h>
28 #include <TColStd_IndexedMapOfInteger.hxx>
30 #include <SUIT_Desktop.h>
31 #include <SUIT_Session.h>
32 #include <SUIT_Study.h>
34 #include "SalomeApp_SelectionMgr.h"
36 #include "SVTK_Selector.h"
37 #include "SVTK_ViewModel.h"
38 #include "SVTK_ViewWindow.h"
39 #include "SVTK_RenderWindow.h"
40 #include "SVTK_InteractorStyle.h"
41 #include "SVTK_RenderWindowInteractor.h"
43 #include "utilities.h"
45 #include "SALOMEconfig.h"
46 #include CORBA_CLIENT_HEADER(SMESH_Gen)
47 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
48 #include CORBA_CLIENT_HEADER(SMESH_Group)
49 #include CORBA_CLIENT_HEADER(SMESH_Hypothesis)
52 #include "SMESH_Actor.h"
53 #include "SMESH_ObjectDef.h"
55 #include <SalomeApp_Application.h>
56 #include <SalomeApp_SelectionMgr.h>
57 #include <SalomeApp_Study.h>
59 #include <SALOMEDSClient_Study.hxx>
60 #include <SALOMEDSClient_SObject.hxx>
62 #include <SALOME_ListIO.hxx>
63 #include <SALOME_ListIteratorOfListIO.hxx>
70 typedef map<TKeyOfVisualObj,TVisualObjPtr> TVisualObjCont;
71 static TVisualObjCont VISUAL_OBJ_CONT;
73 TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry){
74 TVisualObjPtr aVisualObj;
76 TVisualObjCont::key_type aKey(theStudyId,theEntry);
77 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(aKey);
78 if(anIter != VISUAL_OBJ_CONT.end()){
79 aVisualObj = anIter->second;
81 SalomeApp_Application* app = 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!!!");
146 GetViewWindow(const SalomeApp_Module* theModule)
148 if (SalomeApp_Application* anApp = theModule->getApp())
149 return dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow());
153 SVTK_ViewWindow* FindVtkViewWindow( SUIT_ViewManager* theMgr,
154 SUIT_ViewWindow* theWindow )
159 QPtrVector<SUIT_ViewWindow> views = theMgr->getViews();
160 if( views.containsRef( theWindow ) )
161 return GetVtkViewWindow( theWindow );
167 SVTK_ViewWindow* GetVtkViewWindow(SUIT_ViewWindow* theWindow){
168 return dynamic_cast<SVTK_ViewWindow*>(theWindow);
172 /* SUIT_ViewWindow* GetActiveWindow()
174 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
177 SUIT_ViewManager* mgr = app->activeViewManager();
179 return mgr->getActiveView();
184 SVTK_ViewWindow* GetCurrentVtkView(){
185 return GetVtkViewWindow( GetActiveWindow() );
188 void RepaintViewWindow(SVTK_ViewWindow* theWindow)
190 theWindow->Repaint();
193 void RenderViewWindow(SVTK_ViewWindow* theWindow)
195 theWindow->getRenderer()->Render();
196 theWindow->Repaint();
199 SMESH_Actor* FindActorByEntry(SUIT_ViewWindow *theWindow,
200 const char* theEntry)
202 if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow)){
203 vtkRenderer *aRenderer = aViewWindow->getRenderer();
204 vtkActorCollection *aCollection = aRenderer->GetActors();
205 aCollection->InitTraversal();
206 while(vtkActor *anAct = aCollection->GetNextActor()){
207 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
208 if(anActor->hasIO()){
209 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
210 if(anIO->hasEntry() && strcmp(anIO->getEntry(),theEntry) == 0){
221 SMESH_Actor* FindActorByEntry(const char* theEntry){
222 return FindActorByEntry(GetActiveWindow(),theEntry);
226 SMESH_Actor* FindActorByObject(CORBA::Object_ptr theObject){
227 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
231 if(!CORBA::is_nil(theObject)){
232 _PTR(Study) aStudy = GetActiveStudyDocument();
233 CORBA::String_var anIOR = app->orb()->object_to_string( theObject );
234 _PTR(SObject) aSObject = aStudy->FindObjectIOR(anIOR.in());
236 CORBA::String_var anEntry = aSObject->GetID().c_str();
237 return FindActorByEntry(anEntry.in());
244 SMESH_Actor* CreateActor(_PTR(Study) theStudy,
245 const char* theEntry,
248 SMESH_Actor *anActor = NULL;
249 CORBA::Long anId = theStudy->StudyId();
250 if(TVisualObjPtr aVisualObj = GetVisualObj(anId,theEntry)){
251 _PTR(SObject) aSObj = theStudy->FindObjectID(theEntry);
253 _PTR(GenericAttribute) anAttr;
254 if(aSObj->FindAttribute(anAttr,"AttributeName")){
255 _PTR(AttributeName) aName = anAttr;
256 std::string aNameVal = aName->Value();
257 anActor = SMESH_Actor::New(aVisualObj,theEntry,aNameVal.c_str(),theIsClear);
265 void DisplayActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){
266 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){
267 vtkWnd->AddActor(theActor);
273 void RemoveActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){
274 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){
275 vtkWnd->RemoveActor(theActor);
276 if(theActor->hasIO()){
277 Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
278 if(anIO->hasEntry()){
279 std::string anEntry = anIO->getEntry();
280 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( vtkWnd->getViewManager()->study() );
281 int aStudyId = aStudy->id();
282 TVisualObjCont::key_type aKey(aStudyId,anEntry);
283 VISUAL_OBJ_CONT.erase(aKey);
293 if(SVTK_ViewWindow* wnd = GetCurrentVtkView() ){
299 vtkRenderer* GetCurrentRenderer(){
300 if(SVTK_ViewWindow* wnd = GetCurrentVtkView() )
301 return wnd->getRenderer();
305 void RepaintCurrentView(){
306 if(SVTK_ViewWindow* wnd = GetCurrentVtkView() )
308 wnd->getRenderer()->Render();
313 void UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry)
315 if(SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd)){
316 vtkRenderer *aRenderer = aViewWnd->getRenderer();
317 vtkActorCollection *aCollection = aRenderer->GetActors();
318 aCollection->InitTraversal();
321 while(vtkActor *anAct = aCollection->GetNextActor()){
322 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
323 anActor->SetVisibility(true);
330 while(vtkActor *anAct = aCollection->GetNextActor()){
331 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
332 anActor->SetVisibility(false);
337 if(SMESH_Actor *anActor = FindActorByEntry(theWnd,theEntry)){
341 anActor->SetVisibility(true);
344 anActor->SetVisibility(false);
351 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( theWnd->getViewManager()->study() );
352 _PTR(Study) aDocument = aStudy->studyDS();
353 if((anActor = CreateActor(aDocument,theEntry,true))) {
354 DisplayActor(theWnd,anActor);
367 void UpdateView(EDisplaing theAction, const char* theEntry){
368 SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( GetActiveStudy() );
369 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() );
370 SUIT_ViewWindow *aWnd = app->activeViewManager()->getActiveView();
371 UpdateView(aWnd,theAction,theEntry);
375 if(SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView()){
376 SalomeApp_SelectionMgr* mgr = SMESHGUI::selectionMgr();
377 SALOME_ListIO selected; mgr->selectedObjects( selected );
379 if( selected.Extent() == 0){
380 vtkRenderer* aRenderer = aWnd->getRenderer();
381 vtkActorCollection *aCollection = aRenderer->GetActors();
382 aCollection->InitTraversal();
383 while(vtkActor *anAct = aCollection->GetNextActor()){
384 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
386 Update(anActor->getIO(),anActor->GetVisibility());
390 SALOME_ListIteratorOfListIO anIter( selected );
391 for(; anIter.More(); anIter.Next()){
392 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
396 RepaintCurrentView();
401 void Update(const Handle(SALOME_InteractiveObject)& theIO,
404 _PTR(Study) aStudy = GetActiveStudyDocument();
405 CORBA::Long anId = aStudy->StudyId();
406 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry());
408 aVisualObj->Update();
410 UpdateView(SMESH::eDisplay,theIO->getEntry());
414 void UpdateSelectionProp( SMESHGUI* theModule ) {
418 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( theModule->application() );
421 MESSAGE( "UpdateSelectionProp: Application is null" );
425 SUIT_ViewManager* vm = app->activeViewManager();
428 MESSAGE( "UpdateSelectionProp: View manager is null" );
432 QPtrVector<SUIT_ViewWindow> views = vm->getViews();
434 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( theModule );
437 MESSAGE( "UpdateSelectionProp: Resource manager is null" );
441 QColor aHiColor = mgr->colorValue( "SMESH", "selection_object_color", Qt::white ),
442 aSelColor = mgr->colorValue( "SMESH", "selection_element_color", Qt::yellow ),
443 aPreColor = mgr->colorValue( "SMESH", "highlight_color", Qt::cyan );
445 int SW = mgr->integerValue( "SMESH", "selection_width", 5 ),
446 PW = mgr->integerValue( "SMESH", "highlight_width", 5 );
448 double SP1 = mgr->doubleValue( "SMESH", "selection_precision_node", 0.025 ),
449 SP2 = mgr->doubleValue( "SMESH", "selection_precision_element", 0.001 );
451 for ( int i=0, n=views.count(); i<n; i++ ) {
452 SVTK_ViewWindow* aVtkView = GetVtkViewWindow( views[i] );
453 if (!aVtkView) continue;
454 // update VTK viewer properties
455 SVTK_RenderWindowInteractor* anInteractor = aVtkView->getRWInteractor();
457 // mesh element selection
458 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
459 aSelColor.blue()/255., SW );
462 anInteractor->SetSelectionTolerance(SP1, SP2);
465 SVTK_InteractorStyle* aStyle =
466 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
468 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
469 aPreColor.blue()/255., PW);
473 vtkRenderer* aRenderer = aVtkView->getRenderer();
474 vtkActorCollection *aCollection = aRenderer->GetActors();
475 aCollection->InitTraversal();
476 while(vtkActor *anAct = aCollection->GetNextActor()){
477 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
478 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
479 aHiColor.blue()/255.);
480 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
481 aPreColor.blue()/255.);
488 //----------------------------------------------------------------------------
489 SVTK_InteractorStyle* GetInteractorStyle(SUIT_ViewWindow *theWindow){
490 if(SVTK_ViewWindow* aWnd = GetVtkViewWindow(theWindow)){
491 if(SVTK_RenderWindowInteractor* anInteractor = aWnd->getRWInteractor()){
492 return dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
498 void SetFilter(const Handle(VTKViewer_Filter)& theFilter,
499 SVTK_InteractorStyle* theStyle)
502 theStyle->SetFilter(theFilter);
505 Handle(VTKViewer_Filter) GetFilter(int theId, SVTK_InteractorStyle* theStyle)
507 return theStyle->GetFilter(theId);
510 bool IsFilterPresent(int theId, SVTK_InteractorStyle* theStyle)
512 return theStyle->IsFilterPresent(theId);
515 void RemoveFilter(int theId, SVTK_InteractorStyle* theStyle)
517 theStyle->RemoveFilter(theId);
520 void RemoveFilters(SVTK_InteractorStyle* theStyle)
522 for ( int id = SMESHGUI_NodeFilter; theStyle && id < SMESHGUI_LastFilter; id++ )
523 theStyle->RemoveFilter( id );
526 bool IsValid(SALOME_Actor* theActor, int theCellId,
527 SVTK_InteractorStyle* theStyle)
529 return theStyle->IsValid(theActor,theCellId);
533 //----------------------------------------------------------------------------
534 void SetPointRepresentation(bool theIsVisible){
535 if(SVTK_ViewWindow* aViewWindow = GetCurrentVtkView()){
536 vtkRenderer *aRenderer = aViewWindow->getRenderer();
537 vtkActorCollection *aCollection = aRenderer->GetActors();
538 aCollection->InitTraversal();
539 while(vtkActor *anAct = aCollection->GetNextActor()){
540 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
541 if(anActor->GetVisibility()){
542 anActor->SetPointRepresentation(theIsVisible);
546 RepaintCurrentView();
551 void SetPickable(SMESH_Actor* theActor){
552 if(SVTK_ViewWindow* aWnd = GetCurrentVtkView()){
553 int anIsAllPickable = (theActor == NULL);
554 vtkRenderer *aRenderer = aWnd->getRenderer();
555 vtkActorCollection *aCollection = aRenderer->GetActors();
556 aCollection->InitTraversal();
557 while(vtkActor *anAct = aCollection->GetNextActor()){
558 if(SALOME_Actor *anActor = dynamic_cast<SALOME_Actor*>(anAct)){
559 if(anActor->GetVisibility()){
560 anActor->SetPickable(anIsAllPickable);
565 theActor->SetPickable(!anIsAllPickable);
566 RepaintCurrentView();
571 //----------------------------------------------------------------------------
572 int GetNameOfSelectedNodes(SVTK_Selector* theSelector,
573 const Handle(SALOME_InteractiveObject)& theIO,
577 TColStd_IndexedMapOfInteger aMapIndex;
578 theSelector->GetIndex(theIO,aMapIndex);
580 for(int i = 1; i <= aMapIndex.Extent(); i++)
581 theName += QString(" %1").arg(aMapIndex(i));
583 return aMapIndex.Extent();
586 int GetNameOfSelectedElements(SVTK_Selector* theSelector,
587 const Handle(SALOME_InteractiveObject)& theIO,
591 TColStd_IndexedMapOfInteger aMapIndex;
592 theSelector->GetIndex(theIO,aMapIndex);
594 typedef std::set<int> TIdContainer;
595 TIdContainer anIdContainer;
596 for( int i = 1; i <= aMapIndex.Extent(); i++)
597 anIdContainer.insert(aMapIndex(i));
599 TIdContainer::const_iterator anIter = anIdContainer.begin();
600 for(; anIter != anIdContainer.end(); anIter++)
601 theName += QString(" %1").arg(*anIter);
603 return aMapIndex.Extent();
607 int GetEdgeNodes(SVTK_Selector* theSelector,
608 const TVisualObjPtr& theVisualObject,
612 const SALOME_ListIO& selected = theSelector->StoredIObjects();
614 if ( selected.Extent() != 1 )
617 Handle(SALOME_InteractiveObject) anIO = selected.First();
618 if ( anIO.IsNull() || !anIO->hasEntry() )
621 TColStd_IndexedMapOfInteger aMapIndex;
622 theSelector->GetIndex( anIO, aMapIndex );
623 if ( aMapIndex.Extent() != 2 )
626 int anObjId = -1, anEdgeNum = -1;
627 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
628 int aVal = aMapIndex( i );
632 anEdgeNum = abs( aVal ) - 1;
635 if ( anObjId == -1 || anEdgeNum == -1 )
638 return theVisualObject->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
641 //----------------------------------------------------------------------------
642 int GetNameOfSelectedNodes(SalomeApp_SelectionMgr *theMgr,
643 const Handle(SALOME_InteractiveObject)& theIO,
647 if(theIO->hasEntry()){
648 if(FindActorByEntry(theIO->getEntry())){
649 TColStd_IndexedMapOfInteger aMapIndex;
650 theMgr->GetIndexes(theIO,aMapIndex);
651 for(int i = 1; i <= aMapIndex.Extent(); i++){
652 theName += QString(" %1").arg(aMapIndex(i));
654 return aMapIndex.Extent();
660 int GetNameOfSelectedNodes(SalomeApp_SelectionMgr *theMgr, QString& theName){
662 SALOME_ListIO selected; theMgr->selectedObjects( selected );
663 if(selected.Extent() == 1){
664 Handle(SALOME_InteractiveObject) anIO = selected.First();
665 return GetNameOfSelectedNodes(theMgr,anIO,theName);
671 int GetNameOfSelectedElements(SalomeApp_SelectionMgr *theMgr,
672 const Handle(SALOME_InteractiveObject)& theIO,
676 if(theIO->hasEntry()){
677 if(FindActorByEntry(theIO->getEntry())){
678 TColStd_IndexedMapOfInteger aMapIndex;
679 theMgr->GetIndexes(theIO,aMapIndex);
680 typedef set<int> TIdContainer;
681 TIdContainer anIdContainer;
682 for( int i = 1; i <= aMapIndex.Extent(); i++)
683 anIdContainer.insert(aMapIndex(i));
684 TIdContainer::const_iterator anIter = anIdContainer.begin();
685 for(; anIter != anIdContainer.end(); anIter++){
686 theName += QString(" %1").arg(*anIter);
688 return aMapIndex.Extent();
695 int GetNameOfSelectedElements(SalomeApp_SelectionMgr *theMgr, QString& theName)
698 SALOME_ListIO selected; theMgr->selectedObjects( selected );
700 if( selected.Extent() == 1){
701 Handle(SALOME_InteractiveObject) anIO = selected.First();
702 return GetNameOfSelectedElements(theMgr,anIO,theName);
707 int GetSelected(SalomeApp_SelectionMgr* theMgr,
708 TColStd_IndexedMapOfInteger& theMap,
709 const bool theIsElement)
712 SALOME_ListIO selected; theMgr->selectedObjects( selected );
714 if ( selected.Extent() == 1 )
716 Handle(SALOME_InteractiveObject) anIO = selected.First();
717 if ( anIO->hasEntry() ) {
718 theMgr->GetIndexes( anIO, theMap );
721 return theMap.Extent();
725 int GetEdgeNodes( SalomeApp_SelectionMgr* theMgr, int& theId1, int& theId2 )
727 SALOME_ListIO selected; theMgr->selectedObjects( selected );
729 if ( selected.Extent() != 1 )
732 Handle(SALOME_InteractiveObject) anIO = selected.First();
733 if ( anIO.IsNull() || !anIO->hasEntry() )
736 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry() );
740 TColStd_IndexedMapOfInteger aMapIndex;
741 theMgr->GetIndexes( anIO, aMapIndex );
742 if ( aMapIndex.Extent() != 2 )
745 int anObjId = -1, anEdgeNum = -1;
746 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
747 int aVal = aMapIndex( i );
751 anEdgeNum = abs( aVal );
754 if ( anObjId == -1 || anEdgeNum == -1 )
757 return anActor->GetObject()->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
760 void SetControlsPrecision( const long theVal )
762 if( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView() )
764 vtkRenderer *aRenderer = aWnd->getRenderer();
765 vtkActorCollection *aCollection = aRenderer->GetActors();
766 aCollection->InitTraversal();
768 while ( vtkActor *anAct = aCollection->GetNextActor())
770 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct ) )
772 anActor->SetControlsPrecision( theVal );
773 anActor->SetControlMode( anActor->GetControlMode() );