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 if(SUIT_ViewManager* aViewManager = anApp->activeViewManager()){
150 if(aViewManager->getType() == SVTK_Viewer::Type()){
151 if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){
152 return dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
160 SVTK_ViewWindow* FindVtkViewWindow( SUIT_ViewManager* theMgr,
161 SUIT_ViewWindow* theWindow )
166 QPtrVector<SUIT_ViewWindow> views = theMgr->getViews();
167 if( views.containsRef( theWindow ) )
168 return GetVtkViewWindow( theWindow );
174 SVTK_ViewWindow* GetVtkViewWindow(SUIT_ViewWindow* theWindow){
175 return dynamic_cast<SVTK_ViewWindow*>(theWindow);
179 /* SUIT_ViewWindow* GetActiveWindow()
181 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
184 SUIT_ViewManager* mgr = app->activeViewManager();
186 return mgr->getActiveView();
191 SVTK_ViewWindow* GetCurrentVtkView(){
192 return GetVtkViewWindow( GetActiveWindow() );
195 void RepaintViewWindow(SVTK_ViewWindow* theWindow)
197 theWindow->Repaint();
200 void RenderViewWindow(SVTK_ViewWindow* theWindow)
202 theWindow->getRenderer()->Render();
203 theWindow->Repaint();
206 SMESH_Actor* FindActorByEntry(SUIT_ViewWindow *theWindow,
207 const char* theEntry)
209 if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow)){
210 vtkRenderer *aRenderer = aViewWindow->getRenderer();
211 vtkActorCollection *aCollection = aRenderer->GetActors();
212 aCollection->InitTraversal();
213 while(vtkActor *anAct = aCollection->GetNextActor()){
214 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
215 if(anActor->hasIO()){
216 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
217 if(anIO->hasEntry() && strcmp(anIO->getEntry(),theEntry) == 0){
228 SMESH_Actor* FindActorByEntry(const char* theEntry){
229 return FindActorByEntry(GetActiveWindow(),theEntry);
233 SMESH_Actor* FindActorByObject(CORBA::Object_ptr theObject){
234 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
238 if(!CORBA::is_nil(theObject)){
239 _PTR(Study) aStudy = GetActiveStudyDocument();
240 CORBA::String_var anIOR = app->orb()->object_to_string( theObject );
241 _PTR(SObject) aSObject = aStudy->FindObjectIOR(anIOR.in());
243 CORBA::String_var anEntry = aSObject->GetID().c_str();
244 return FindActorByEntry(anEntry.in());
251 SMESH_Actor* CreateActor(_PTR(Study) theStudy,
252 const char* theEntry,
255 SMESH_Actor *anActor = NULL;
256 CORBA::Long anId = theStudy->StudyId();
257 if(TVisualObjPtr aVisualObj = GetVisualObj(anId,theEntry)){
258 _PTR(SObject) aSObj = theStudy->FindObjectID(theEntry);
260 _PTR(GenericAttribute) anAttr;
261 if(aSObj->FindAttribute(anAttr,"AttributeName")){
262 _PTR(AttributeName) aName = anAttr;
263 std::string aNameVal = aName->Value();
264 anActor = SMESH_Actor::New(aVisualObj,theEntry,aNameVal.c_str(),theIsClear);
272 void DisplayActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){
273 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){
274 vtkWnd->AddActor(theActor);
280 void RemoveActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){
281 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){
282 vtkWnd->RemoveActor(theActor);
283 if(theActor->hasIO()){
284 Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
285 if(anIO->hasEntry()){
286 std::string anEntry = anIO->getEntry();
287 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( vtkWnd->getViewManager()->study() );
288 int aStudyId = aStudy->id();
289 TVisualObjCont::key_type aKey(aStudyId,anEntry);
290 VISUAL_OBJ_CONT.erase(aKey);
300 if(SVTK_ViewWindow* wnd = GetCurrentVtkView() ){
306 vtkRenderer* GetCurrentRenderer(){
307 if(SVTK_ViewWindow* wnd = GetCurrentVtkView() )
308 return wnd->getRenderer();
312 void RepaintCurrentView(){
313 if(SVTK_ViewWindow* wnd = GetCurrentVtkView() )
314 wnd->getRenderer()->Render();
318 void UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry)
320 if(SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd)){
321 vtkRenderer *aRenderer = aViewWnd->getRenderer();
322 vtkActorCollection *aCollection = aRenderer->GetActors();
323 aCollection->InitTraversal();
326 while(vtkActor *anAct = aCollection->GetNextActor()){
327 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
328 anActor->SetVisibility(true);
335 while(vtkActor *anAct = aCollection->GetNextActor()){
336 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
337 anActor->SetVisibility(false);
342 if(SMESH_Actor *anActor = FindActorByEntry(theWnd,theEntry)){
346 anActor->SetVisibility(true);
349 anActor->SetVisibility(false);
356 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( theWnd->getViewManager()->study() );
357 _PTR(Study) aDocument = aStudy->studyDS();
358 if((anActor = CreateActor(aDocument,theEntry,true))) {
359 DisplayActor(theWnd,anActor);
372 void UpdateView(EDisplaing theAction, const char* theEntry){
373 SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( GetActiveStudy() );
374 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() );
375 SUIT_ViewWindow *aWnd = app->activeViewManager()->getActiveView();
376 UpdateView(aWnd,theAction,theEntry);
380 if(SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView()){
381 SalomeApp_SelectionMgr* mgr = SMESHGUI::selectionMgr();
382 SALOME_ListIO selected; mgr->selectedObjects( selected );
384 if( selected.Extent() == 0){
385 vtkRenderer* aRenderer = aWnd->getRenderer();
386 vtkActorCollection *aCollection = aRenderer->GetActors();
387 aCollection->InitTraversal();
388 while(vtkActor *anAct = aCollection->GetNextActor()){
389 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
391 Update(anActor->getIO(),anActor->GetVisibility());
395 SALOME_ListIteratorOfListIO anIter( selected );
396 for(; anIter.More(); anIter.Next()){
397 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
401 RepaintCurrentView();
406 void Update(const Handle(SALOME_InteractiveObject)& theIO,
409 _PTR(Study) aStudy = GetActiveStudyDocument();
410 CORBA::Long anId = aStudy->StudyId();
411 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry());
413 aVisualObj->Update();
415 UpdateView(SMESH::eDisplay,theIO->getEntry());
419 void UpdateSelectionProp() {
420 SUIT_Study* aStudy = GetActiveStudy();
421 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() );
422 SUIT_ViewManager* vm = app->activeViewManager();
423 QPtrVector<SUIT_ViewWindow> views = vm->getViews();
425 SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
427 QColor aHiColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white ),
428 aSelColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow ),
429 aPreColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan );
431 int SW = mgr->integerValue( "SMESH", "SettingsItemSelectWidth", 5 ),
432 PW = mgr->integerValue( "SMESH", "SettingsPreSelectWidth", 5 );
434 double SP1 = mgr->doubleValue( "SMESH", "SettingsNodeSelectTol", 0.025 ),
435 SP2 = mgr->doubleValue( "SMESH", "SettingsElementsSelectTol", 0.001 );
437 for ( int i=0, n=views.count(); i<n; i++ ) {
438 SVTK_ViewWindow* aVtkView = GetVtkViewWindow( views[i] );
439 if (!aVtkView) continue;
440 // update VTK viewer properties
441 SVTK_RenderWindowInteractor* anInteractor = aVtkView->getRWInteractor();
443 // mesh element selection
444 anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
445 aSelColor.blue()/255., SW );
448 anInteractor->SetSelectionTolerance(SP1, SP2);
451 SVTK_InteractorStyle* aStyle =
452 dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
454 aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
455 aPreColor.blue()/255., PW);
459 vtkRenderer* aRenderer = aVtkView->getRenderer();
460 vtkActorCollection *aCollection = aRenderer->GetActors();
461 aCollection->InitTraversal();
462 while(vtkActor *anAct = aCollection->GetNextActor()){
463 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
464 anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
465 aHiColor.blue()/255.);
466 anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
467 aPreColor.blue()/255.);
474 //----------------------------------------------------------------------------
475 SVTK_InteractorStyle* GetInteractorStyle(SUIT_ViewWindow *theWindow){
476 if(SVTK_ViewWindow* aWnd = GetVtkViewWindow(theWindow)){
477 if(SVTK_RenderWindowInteractor* anInteractor = aWnd->getRWInteractor()){
478 return dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
484 void SetFilter(const Handle(VTKViewer_Filter)& theFilter,
485 SVTK_InteractorStyle* theStyle)
487 theStyle->SetFilter(theFilter);
490 Handle(VTKViewer_Filter) GetFilter(int theId, SVTK_InteractorStyle* theStyle)
492 return theStyle->GetFilter(theId);
495 bool IsFilterPresent(int theId, SVTK_InteractorStyle* theStyle)
497 return theStyle->IsFilterPresent(theId);
500 void RemoveFilter(int theId, SVTK_InteractorStyle* theStyle)
502 theStyle->RemoveFilter(theId);
505 void RemoveFilters(SVTK_InteractorStyle* theStyle)
507 for ( int id = SMESHGUI_NodeFilter; theStyle && id < SMESHGUI_LastFilter; id++ )
508 theStyle->RemoveFilter( id );
511 bool IsValid(SALOME_Actor* theActor, int theCellId,
512 SVTK_InteractorStyle* theStyle)
514 return theStyle->IsValid(theActor,theCellId);
518 //----------------------------------------------------------------------------
519 void SetPointRepresentation(bool theIsVisible){
520 if(SVTK_ViewWindow* aViewWindow = GetCurrentVtkView()){
521 vtkRenderer *aRenderer = aViewWindow->getRenderer();
522 vtkActorCollection *aCollection = aRenderer->GetActors();
523 aCollection->InitTraversal();
524 while(vtkActor *anAct = aCollection->GetNextActor()){
525 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
526 if(anActor->GetVisibility()){
527 anActor->SetPointRepresentation(theIsVisible);
531 RepaintCurrentView();
536 void SetPickable(SMESH_Actor* theActor){
537 if(SVTK_ViewWindow* aWnd = GetCurrentVtkView()){
538 int anIsAllPickable = (theActor == NULL);
539 vtkRenderer *aRenderer = aWnd->getRenderer();
540 vtkActorCollection *aCollection = aRenderer->GetActors();
541 aCollection->InitTraversal();
542 while(vtkActor *anAct = aCollection->GetNextActor()){
543 if(SALOME_Actor *anActor = dynamic_cast<SALOME_Actor*>(anAct)){
544 if(anActor->GetVisibility()){
545 anActor->SetPickable(anIsAllPickable);
550 theActor->SetPickable(!anIsAllPickable);
551 RepaintCurrentView();
556 //----------------------------------------------------------------------------
557 int GetNameOfSelectedNodes(SVTK_Selector* theSelector,
558 const Handle(SALOME_InteractiveObject)& theIO,
562 TColStd_IndexedMapOfInteger aMapIndex;
563 theSelector->GetIndex(theIO,aMapIndex);
565 for(int i = 1; i <= aMapIndex.Extent(); i++)
566 theName += QString(" %1").arg(aMapIndex(i));
568 return aMapIndex.Extent();
571 int GetNameOfSelectedElements(SVTK_Selector* theSelector,
572 const Handle(SALOME_InteractiveObject)& theIO,
576 TColStd_IndexedMapOfInteger aMapIndex;
577 theSelector->GetIndex(theIO,aMapIndex);
579 typedef std::set<int> TIdContainer;
580 TIdContainer anIdContainer;
581 for( int i = 1; i <= aMapIndex.Extent(); i++)
582 anIdContainer.insert(aMapIndex(i));
584 TIdContainer::const_iterator anIter = anIdContainer.begin();
585 for(; anIter != anIdContainer.end(); anIter++)
586 theName += QString(" %1").arg(*anIter);
588 return aMapIndex.Extent();
592 int GetEdgeNodes(SVTK_Selector* theSelector,
593 const TVisualObjPtr& theVisualObject,
597 const SALOME_ListIO& selected = theSelector->StoredIObjects();
599 if ( selected.Extent() != 1 )
602 Handle(SALOME_InteractiveObject) anIO = selected.First();
603 if ( anIO.IsNull() || !anIO->hasEntry() )
606 TColStd_IndexedMapOfInteger aMapIndex;
607 theSelector->GetIndex( anIO, aMapIndex );
608 if ( aMapIndex.Extent() != 2 )
611 int anObjId = -1, anEdgeNum = -1;
612 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
613 int aVal = aMapIndex( i );
617 anEdgeNum = abs( aVal ) - 1;
620 if ( anObjId == -1 || anEdgeNum == -1 )
623 return theVisualObject->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
626 //----------------------------------------------------------------------------
627 int GetNameOfSelectedNodes(SalomeApp_SelectionMgr *theMgr,
628 const Handle(SALOME_InteractiveObject)& theIO,
632 if(theIO->hasEntry()){
633 if(FindActorByEntry(theIO->getEntry())){
634 TColStd_IndexedMapOfInteger aMapIndex;
635 theMgr->GetIndexes(theIO,aMapIndex);
636 for(int i = 1; i <= aMapIndex.Extent(); i++){
637 theName += QString(" %1").arg(aMapIndex(i));
639 return aMapIndex.Extent();
645 int GetNameOfSelectedNodes(SalomeApp_SelectionMgr *theMgr, QString& theName){
647 SALOME_ListIO selected; theMgr->selectedObjects( selected );
648 if(selected.Extent() == 1){
649 Handle(SALOME_InteractiveObject) anIO = selected.First();
650 return GetNameOfSelectedNodes(theMgr,anIO,theName);
656 int GetNameOfSelectedElements(SalomeApp_SelectionMgr *theMgr,
657 const Handle(SALOME_InteractiveObject)& theIO,
661 if(theIO->hasEntry()){
662 if(FindActorByEntry(theIO->getEntry())){
663 TColStd_IndexedMapOfInteger aMapIndex;
664 theMgr->GetIndexes(theIO,aMapIndex);
665 typedef set<int> TIdContainer;
666 TIdContainer anIdContainer;
667 for( int i = 1; i <= aMapIndex.Extent(); i++)
668 anIdContainer.insert(aMapIndex(i));
669 TIdContainer::const_iterator anIter = anIdContainer.begin();
670 for(; anIter != anIdContainer.end(); anIter++){
671 theName += QString(" %1").arg(*anIter);
673 return aMapIndex.Extent();
680 int GetNameOfSelectedElements(SalomeApp_SelectionMgr *theMgr, QString& theName)
683 SALOME_ListIO selected; theMgr->selectedObjects( selected );
685 if( selected.Extent() == 1){
686 Handle(SALOME_InteractiveObject) anIO = selected.First();
687 return GetNameOfSelectedElements(theMgr,anIO,theName);
692 int GetSelected(SalomeApp_SelectionMgr* theMgr,
693 TColStd_IndexedMapOfInteger& theMap,
694 const bool theIsElement)
697 SALOME_ListIO selected; theMgr->selectedObjects( selected );
699 if ( selected.Extent() == 1 )
701 Handle(SALOME_InteractiveObject) anIO = selected.First();
702 if ( anIO->hasEntry() ) {
703 theMgr->GetIndexes( anIO, theMap );
706 return theMap.Extent();
710 int GetEdgeNodes( SalomeApp_SelectionMgr* theMgr, int& theId1, int& theId2 )
712 SALOME_ListIO selected; theMgr->selectedObjects( selected );
714 if ( selected.Extent() != 1 )
717 Handle(SALOME_InteractiveObject) anIO = selected.First();
718 if ( anIO.IsNull() || !anIO->hasEntry() )
721 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry() );
725 TColStd_IndexedMapOfInteger aMapIndex;
726 theMgr->GetIndexes( anIO, aMapIndex );
727 if ( aMapIndex.Extent() != 2 )
730 int anObjId = -1, anEdgeNum = -1;
731 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
732 int aVal = aMapIndex( i );
736 anEdgeNum = abs( aVal );
739 if ( anObjId == -1 || anEdgeNum == -1 )
742 return anActor->GetObject()->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
745 void SetControlsPrecision( const long theVal )
747 if( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView() )
749 vtkRenderer *aRenderer = aWnd->getRenderer();
750 vtkActorCollection *aCollection = aRenderer->GetActors();
751 aCollection->InitTraversal();
753 while ( vtkActor *anAct = aCollection->GetNextActor())
755 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct ) )
757 anActor->SetControlsPrecision( theVal );
758 anActor->SetControlMode( anActor->GetControlMode() );