Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / SVTK / SALOME_Actor.cxx
1 //  SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : SALOME_Actor.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 /*!
30   \class SALOME_Actor SALOME_Actor.h
31   \brief Abstract class of SALOME Objects in VTK.
32 */
33
34
35 #include "SALOME_Actor.h"
36
37 #include "VTKViewer_Transform.h"
38 #include "VTKViewer_TransformFilter.h"
39 #include "VTKViewer_GeometryFilter.h"
40 #include "SVTK_RectPicker.h"
41
42 #include "SVTK_Actor.h"
43
44 // VTK Includes
45 #include <vtkCell.h>
46 #include <vtkLine.h>
47 #include <vtkPicker.h>
48 #include <vtkPointPicker.h>
49 #include <vtkCellPicker.h>
50 #include <vtkRenderer.h>
51 #include <vtkPolyData.h>
52 #include <vtkObjectFactory.h>
53 #include <vtkDataSetMapper.h>
54 #include <vtkPolyDataMapper.h>
55 #include <vtkProperty.h>
56 #include <vtkOutlineSource.h>
57
58 #include <vtkInteractorStyle.h>
59 #include <vtkRenderWindowInteractor.h>
60 #include <vtkPassThroughFilter.h>
61
62 #include <TColStd_MapOfInteger.hxx>
63 #include <TColStd_IndexedMapOfInteger.hxx>
64
65 using namespace std;
66
67 #if defined __GNUC__
68   #if __GNUC__ == 2
69     #define __GNUC_2__
70   #endif
71 #endif
72
73 int SALOME_POINT_SIZE = 5;
74 int SALOME_LINE_WIDTH = 3;
75
76 namespace
77 {
78   int
79   GetEdgeId(SALOME_Actor* theActor,
80             vtkPicker* thePicker, 
81             int theObjId)
82   {
83     int anEdgeId = 0;
84     if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
85       vtkFloatingPointType aPickPosition[3];
86       thePicker->GetPickPosition(aPickPosition);
87       vtkFloatingPointType aMinDist = 1000000.0, aDist = 0;
88       for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
89         if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
90           int subId;  
91           vtkFloatingPointType pcoords[3], closestPoint[3], weights[3];
92           aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
93           if (aDist < aMinDist) {
94             aMinDist = aDist;
95             anEdgeId = -1 - i;
96           }
97         }
98       }
99     }
100     return anEdgeId;
101   }
102
103   inline
104   bool
105   CheckDimensionId(Selection_Mode theMode, 
106                    SALOME_Actor *theActor, 
107                    vtkIdType theObjId)
108   {
109     switch(theMode){
110     case CellSelection:
111       return true;
112     case EdgeSelection:
113       return ( theActor->GetObjDimension( theObjId ) == 1 );
114     case FaceSelection:
115       return ( theActor->GetObjDimension( theObjId ) == 2 );
116     case VolumeSelection:
117       return ( theActor->GetObjDimension( theObjId ) == 3 );
118     };
119     return false;
120   }
121
122 }
123
124
125 vtkStandardNewMacro(SALOME_Actor);
126
127 /*!
128   Constructor
129 */
130 SALOME_Actor
131 ::SALOME_Actor():
132   myRenderer(NULL),
133   myInteractor(NULL),
134   mySelectionMode(ActorSelection),
135   myPreHighlightActor(SVTK_Actor::New()),
136   myHighlightActor(SVTK_Actor::New()),
137   myOutline(vtkOutlineSource::New()),
138   myOutlineActor(VTKViewer_Actor::New())
139 {
140   myPreHighlightActor->Delete();
141   myPreHighlightActor->Initialize();
142   myPreHighlightActor->PickableOff();
143   myPreHighlightActor->SetVisibility( false );
144
145   myHighlightActor->Delete();
146   myHighlightActor->Initialize();
147   myHighlightActor->PickableOff();
148   myHighlightActor->SetVisibility( false );
149
150   myOutline->Delete();
151
152   vtkPolyDataMapper* anOutlineMapper = vtkPolyDataMapper::New();
153   anOutlineMapper->SetInput(myOutline->GetOutput());
154
155   myOutlineActor->Delete();
156   myOutlineActor->SetMapper( anOutlineMapper );
157   anOutlineMapper->Delete();
158
159   myOutlineActor->PickableOff();
160   myOutlineActor->DragableOff();
161   myOutlineActor->GetProperty()->SetColor(1.0,0.0,0.0);
162   myOutlineActor->GetProperty()->SetAmbient(1.0);
163   myOutlineActor->GetProperty()->SetDiffuse(0.0);
164   myOutlineActor->SetVisibility( false );
165 }
166
167 /*!
168   Destructor
169 */
170 SALOME_Actor
171 ::~SALOME_Actor()
172 {}
173
174
175 /*!
176   \return true if the SALOME_Actor has a reference to SALOME_InteractiveObject
177 */
178 Standard_Boolean 
179 SALOME_Actor
180 ::hasIO() 
181
182   return !myIO.IsNull(); 
183 }
184
185 /*!
186   \return correspoinding reference to SALOME_InteractiveObject
187 */
188 const Handle(SALOME_InteractiveObject)& 
189 SALOME_Actor
190 ::getIO()
191
192   return myIO; 
193 }
194
195 /*!
196   Sets reference to SALOME_InteractiveObject
197   \param theIO - new SALOME_InteractiveObject
198 */
199 void
200 SALOME_Actor
201 ::setIO(const Handle(SALOME_InteractiveObject)& theIO) 
202
203   myIO = theIO; 
204 }
205
206 /*!
207   Sets name the SALOME_Actor
208   \param theName - new name
209 */
210 void
211 SALOME_Actor
212 ::setName(const char* theName)
213 {
214   if(hasIO())   
215     myIO->setName(theName);
216   Superclass::setName(theName);
217 }
218
219
220 /*!
221   Publishes the actor in all its internal devices
222 */
223 void
224 SALOME_Actor
225 ::AddToRender(vtkRenderer* theRenderer)
226 {
227   Superclass::AddToRender(theRenderer);
228
229   myRenderer = theRenderer;
230
231   theRenderer->AddActor( myPreHighlightActor.GetPointer() );
232   theRenderer->AddActor( myHighlightActor.GetPointer() );
233   theRenderer->AddActor( myOutlineActor.GetPointer() );
234 }
235
236 /*!
237   Removes the actor from all its internal devices
238 */
239 void 
240 SALOME_Actor
241 ::RemoveFromRender(vtkRenderer* theRenderer)
242 {
243   Superclass::RemoveFromRender(theRenderer);
244
245   theRenderer->RemoveActor( myPreHighlightActor.GetPointer() );
246   theRenderer->RemoveActor( myHighlightActor.GetPointer() );
247   theRenderer->RemoveActor( myOutlineActor.GetPointer() );
248 }
249
250 /*!
251   \return reference on renderer where it is published
252 */
253 vtkRenderer*
254 SALOME_Actor
255 ::GetRenderer()
256 {
257   return myRenderer;
258 }
259
260 /*!
261   Sets interactor in order to use vtkInteractorObserver devices
262   \param theInteractor - new interactor
263 */
264 void
265 SALOME_Actor
266 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
267 {
268   myInteractor = theInteractor;
269 }
270
271 /*!
272   Put a request to redraw the view 
273 */
274 void
275 SALOME_Actor
276 ::Update()
277 {
278   myInteractor->CreateTimer(VTKI_TIMER_UPDATE);    
279 }
280
281 /*!
282   Apply view transformation
283   \param theTransform - transformation
284 */
285 void
286 SALOME_Actor
287 ::SetTransform(VTKViewer_Transform* theTransform)
288 {
289   Superclass::SetTransform(theTransform);
290
291   myPreHighlightActor->SetTransform(theTransform);
292   myHighlightActor->SetTransform(theTransform);
293   myOutlineActor->SetTransform(theTransform);
294 }
295
296 /*!
297   Apply additional position
298 */
299 void
300 SALOME_Actor
301 ::SetPosition(vtkFloatingPointType _arg1, 
302               vtkFloatingPointType _arg2, 
303               vtkFloatingPointType _arg3)
304 {
305   Superclass::SetPosition(_arg1,_arg2,_arg3);
306
307   myPreHighlightActor->SetPosition(_arg1,_arg2,_arg3);
308   myHighlightActor->SetPosition(_arg1,_arg2,_arg3);
309   myOutlineActor->SetPosition(_arg1,_arg2,_arg3);
310 }
311
312 /*!
313   Apply additional position
314 */
315 void
316 SALOME_Actor
317 ::SetPosition(vtkFloatingPointType _arg[3])
318 {
319   SetPosition(_arg[0],_arg[1],_arg[2]);
320 }
321
322 /*!
323   Shows/hides actor
324   \param theVisibility - new visibility state
325 */
326 void
327 SALOME_Actor
328 ::SetVisibility( int theVisibility )
329 {
330   Superclass::SetVisibility( theVisibility );
331
332   myOutlineActor->SetVisibility( theVisibility && isHighlighted() && !hasHighlight() );
333
334   myPreHighlightActor->SetVisibility( theVisibility && myIsPreselected );
335
336   if(mySelector.GetPointer() && hasIO()){
337     if(mySelector->SelectionMode() != ActorSelection){
338       int aHasIndex = mySelector->HasIndex( getIO() );
339       myHighlightActor->SetVisibility( theVisibility && isHighlighted() && aHasIndex);
340     }
341   }
342 }
343
344 /*!
345   Set selector in order to the actor at any time can restore current selection
346   \param theSelector - new selector
347 */
348 void
349 SALOME_Actor
350 ::SetSelector(SVTK_Selector* theSelector)
351 {
352   mySelector = theSelector;
353 }
354
355 /*!
356   To map current selection to VTK representation
357 */
358 void
359 SALOME_Actor
360 ::Highlight(bool theIsHighlight)
361 {
362   mySelectionMode = mySelector->SelectionMode();
363   myHighlightActor->SetVisibility( false );
364   myOutlineActor->SetVisibility( false );
365
366   if(mySelector.GetPointer()){
367     if(mySelectionMode != ActorSelection){
368       TColStd_IndexedMapOfInteger aMapIndex;
369       mySelector->GetIndex( getIO(), aMapIndex );
370       switch( mySelectionMode ){
371       case NodeSelection:
372         myHighlightActor->GetProperty()->SetRepresentationToPoints();
373         myHighlightActor->MapPoints( this, aMapIndex );
374         break;
375       case EdgeOfCellSelection:
376         myHighlightActor->GetProperty()->SetRepresentationToWireframe();
377         myHighlightActor->MapEdge( this, aMapIndex );
378         break;
379       case CellSelection:
380       case EdgeSelection:
381       case FaceSelection:
382       case VolumeSelection:
383         myHighlightActor->GetProperty()->SetRepresentationToSurface();
384         myHighlightActor->MapCells( this, aMapIndex );
385         break;
386       }
387       myHighlightActor->SetVisibility( GetVisibility() && theIsHighlight );
388     }
389   }
390
391   highlight(theIsHighlight);
392 }
393
394 /*!
395   Updates visibility of the highlight devices  
396 */
397 void
398 SALOME_Actor
399 ::highlight(bool theIsHighlight)
400 {
401   vtkFloatingPointType aBounds[6];
402   GetInput()->GetBounds(aBounds);
403   myOutline->SetBounds(aBounds);
404   myOutlineActor->SetVisibility( GetVisibility() && theIsHighlight );
405
406   Superclass::highlight(theIsHighlight);
407 }
408
409
410 /*!
411   To process prehighlight (called from SVTK_InteractorStyle)
412 */
413 bool
414 SALOME_Actor
415 ::PreHighlight(vtkInteractorStyle *theInteractorStyle, 
416                SVTK_SelectionEvent* theSelectionEvent,
417                bool theIsHighlight)
418 {
419   if ( !GetPickable() )
420     return false;
421
422   vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
423   //
424   myPreHighlightActor->SetVisibility( false );
425   bool anIsPreselected = myIsPreselected;
426   
427   Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
428   bool anIsChanged = (mySelectionMode != aSelectionMode);
429
430   vtkFloatingPointType x = theSelectionEvent->myX;
431   vtkFloatingPointType y = theSelectionEvent->myY;
432   vtkFloatingPointType z = 0.0;
433
434   if( !theIsHighlight ) {
435     SetPreSelected( false );
436     vtkActorCollection* theActors = aRenderer->GetActors();
437     theActors->InitTraversal();
438     while( vtkActor *ac = theActors->GetNextActor() )
439       if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
440         if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
441           anActor->SetPreSelected( false );
442
443   }else{
444     switch(aSelectionMode){
445     case NodeSelection: 
446     {
447       myPointPicker->Pick( x, y, z, aRenderer );
448       
449       int aVtkId = myPointPicker->GetPointId();
450       if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
451         int anObjId = GetNodeObjId( aVtkId );
452         myIsPreselected = (anObjId >= 0);
453         if(myIsPreselected){
454           const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
455           int anExtent = aMapIndex.Extent();
456           anIsChanged |= (anExtent == 0 || anExtent > 0 && anObjId != aMapIndex(1));
457           if(anIsChanged){
458             TColStd_IndexedMapOfInteger aMapIndex;
459             aMapIndex.Add( anObjId );
460             
461             myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
462             myPreHighlightActor->MapPoints( this, aMapIndex );
463           }
464           myPreHighlightActor->SetVisibility( true );
465         }
466       }
467       break;
468     }
469     case CellSelection: 
470     case EdgeSelection:
471     case FaceSelection:
472     case VolumeSelection: 
473     {
474       myCellPicker->Pick( x, y, z, aRenderer );
475       
476       int aVtkId = myCellPicker->GetCellId();
477       if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO() ) {
478         int anObjId = GetElemObjId (aVtkId );
479         if ( anObjId >= 0 ) {
480           myIsPreselected = CheckDimensionId(aSelectionMode,this,anObjId);
481           if(myIsPreselected){
482             const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
483             int anExtent = aMapIndex.Extent();
484             anIsChanged |= (anExtent == 0 || anExtent > 0 && anObjId != aMapIndex(1));
485             if(anIsChanged){
486               TColStd_IndexedMapOfInteger aMapIndex;
487               aMapIndex.Add( anObjId );
488               
489               myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
490               myPreHighlightActor->MapCells( this, aMapIndex );
491             }
492             myPreHighlightActor->SetVisibility( true );
493           }
494         }
495       }
496       break;
497     }
498     case EdgeOfCellSelection:
499     {
500       myCellPicker->Pick( x, y, z, aRenderer );
501       
502       int aVtkId = myCellPicker->GetCellId();
503       if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )) {
504         int anObjId = GetElemObjId( aVtkId );
505         if ( anObjId >= 0 ) {
506           int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
507           myIsPreselected = anEdgeId < 0;
508           if(myIsPreselected){
509             const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
510             int anExtent = aMapIndex.Extent();
511             anIsChanged |= (anExtent == 0);
512             anIsChanged |= (anExtent == 2 && (anObjId != aMapIndex(1) || anEdgeId != aMapIndex(2)));
513             if(anIsChanged){
514               TColStd_IndexedMapOfInteger aMapIndex;
515               aMapIndex.Add( anObjId );
516               aMapIndex.Add( anEdgeId );
517
518               myPreHighlightActor->GetProperty()->SetRepresentationToWireframe();
519               myPreHighlightActor->MapEdge( this, aMapIndex );
520             }
521             myPreHighlightActor->SetVisibility( true );
522           }
523         }
524       }
525       break;
526     }
527     case ActorSelection : 
528     {
529       if( !mySelector->IsSelected( myIO ) ) {
530         SetPreSelected( true );
531
532         vtkActorCollection* theActors = aRenderer->GetActors();
533         theActors->InitTraversal();
534         while( vtkActor *anAct = theActors->GetNextActor() ) {
535           if( anAct != this )
536             if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( anAct ) )
537               if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
538                 anActor->SetPreSelected( true );
539         }
540       }
541     }
542     default:
543       break;
544     }
545   }
546
547   mySelectionMode = aSelectionMode;
548   anIsChanged |= (anIsPreselected != myIsPreselected);
549
550   return anIsChanged;
551 }
552
553 /*!
554   To process highlight (called from SVTK_InteractorStyle)
555 */
556 bool
557 SALOME_Actor
558 ::Highlight(vtkInteractorStyle *theInteractorStyle, 
559             SVTK_SelectionEvent* theSelectionEvent,
560             bool theIsHighlight)
561 {
562   if ( !GetPickable() )
563     return false;
564
565   myOutlineActor->SetVisibility( false );
566   myHighlightActor->SetVisibility( false );
567
568   vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
569   //
570   Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
571   bool anIsShift = theSelectionEvent->myIsShift;
572   if( !anIsShift || !theIsHighlight ) {
573     mySelector->RemoveIObject( this );
574   }
575
576   if ( !theIsHighlight )
577     return true;
578
579   vtkFloatingPointType x = theSelectionEvent->myX;
580   vtkFloatingPointType y = theSelectionEvent->myY;
581   vtkFloatingPointType z = 0.0;
582
583   if( !theSelectionEvent->myIsRectangle ) {
584     switch(aSelectionMode){
585     case NodeSelection: {
586       myPointPicker->Pick( x, y, z, aRenderer );
587
588       int aVtkId = myPointPicker->GetPointId();
589       if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
590         int anObjId = GetNodeObjId( aVtkId );
591         if( anObjId >= 0 ) {
592           mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
593           mySelector->AddIObject( this );
594         }
595       }
596       break;
597     }
598     case CellSelection: 
599     case EdgeSelection:
600     case FaceSelection:
601     case VolumeSelection: 
602     {
603       myCellPicker->Pick( x, y, z, aRenderer );
604     
605       int aVtkId = myCellPicker->GetCellId();
606       if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
607         int anObjId = GetElemObjId( aVtkId );
608         if( anObjId >= 0 ) {
609           if ( CheckDimensionId(aSelectionMode,this,anObjId) ) {
610             mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
611             mySelector->AddIObject( this );
612           }
613         }
614       }
615       break;
616     }
617     case EdgeOfCellSelection: 
618     {
619       myCellPicker->Pick( x, y, z, aRenderer );
620     
621       int aVtkId = myCellPicker->GetCellId();
622       if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
623         int anObjId = GetElemObjId( aVtkId );
624         if( anObjId >= 0 ) {
625           int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
626           if( anEdgeId < 0 ) {
627             mySelector->AddOrRemoveIndex( myIO, anObjId, false );
628             mySelector->AddOrRemoveIndex( myIO, anEdgeId, true );
629             mySelector->AddIObject( this );
630           } 
631         }
632       }
633       break;
634     }
635     case ActorSelection : 
636     {
637       if( mySelector->IsSelected( myIO ) && anIsShift )
638         mySelector->RemoveIObject( this );
639       else {
640         mySelector->AddIObject( this );
641       }
642       break;
643     }
644     default:
645       break;
646     }
647   }else{
648     vtkFloatingPointType xLast = theSelectionEvent->myLastX;
649     vtkFloatingPointType yLast = theSelectionEvent->myLastY;
650     vtkFloatingPointType zLast = 0.0;
651
652     vtkFloatingPointType x1 = x < xLast ? x : xLast;
653     vtkFloatingPointType y1 = y < yLast ? y : yLast;
654     vtkFloatingPointType z1 = z < zLast ? z : zLast;
655     vtkFloatingPointType x2 = x > xLast ? x : xLast;
656     vtkFloatingPointType y2 = y > yLast ? y : yLast;
657     vtkFloatingPointType z2 = z > zLast ? z : zLast;
658
659     switch(aSelectionMode){
660     case NodeSelection: {
661       myPointRectPicker->InitializePickList();
662       myPointRectPicker->AddPickList(this);
663       myPointRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
664
665       const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myPointRectPicker->GetPointIdsMap();
666       SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
667       TColStd_MapOfInteger anIndexes;
668       if(aMapIter != aVectorIdsMap.end()){
669         const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
670         vtkIdType anEnd = aVectorIds.size();
671         for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
672           int aPointId = aVectorIds[anId];
673           if( aPointId >= 0 && mySelector->IsValid( this, aPointId, true ) ) {
674             int anObjId = GetNodeObjId( aPointId );
675             anIndexes.Add( anObjId );
676           }
677         }
678       }
679       
680       if( !anIndexes.IsEmpty() ) {
681         mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
682         mySelector->AddIObject( this );
683         anIndexes.Clear();
684       }
685       else
686         mySelector->RemoveIObject( this );
687
688       break;
689     }
690     case ActorSelection :
691     {
692       vtkFloatingPointType aPnt[3];
693       vtkFloatingPointType* aBounds = GetBounds();
694
695       bool anIsPicked = true;
696       for( int i = 0; i <= 1; i++ ) {
697         for( int j = 2; j <= 3; j++ ) {
698           for( int k = 4; k <= 5; k++ ) {
699             aRenderer->SetWorldPoint( aBounds[ i ], aBounds[ j ], aBounds[ k ], 1.0 );
700             aRenderer->WorldToDisplay();
701             aRenderer->GetDisplayPoint( aPnt );
702
703             if( aPnt[0] < x1 || aPnt[0] > x2 || aPnt[1] < y1 || aPnt[1] > y2 ) {
704               anIsPicked = false;
705               break;
706             }
707           }
708         }
709       }
710
711       if( anIsPicked )
712         mySelector->AddIObject(this);
713
714       break;
715     }
716     case CellSelection: 
717     case EdgeSelection:
718     case FaceSelection:
719     case VolumeSelection: 
720     {
721       myCellRectPicker->InitializePickList();
722       myCellRectPicker->AddPickList(this);
723       myCellRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
724
725       const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myCellRectPicker->GetCellIdsMap();
726       SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
727       TColStd_MapOfInteger anIndexes;
728       if(aMapIter != aVectorIdsMap.end()){
729         const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
730         vtkIdType anEnd = aVectorIds.size();
731         for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
732           int aCellId = aVectorIds[anId];
733           if ( !mySelector->IsValid( this, aCellId ) )
734             continue;
735
736           int anObjId = GetElemObjId( aCellId );
737           if( anObjId != -1 )
738             if ( CheckDimensionId(aSelectionMode,this,anObjId) ) {
739               anIndexes.Add(anObjId);
740             }
741         }
742       }
743       mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
744       mySelector->AddIObject( this );
745     }
746     default:
747       break;
748     }
749   }
750
751   mySelectionMode = aSelectionMode;
752
753   return true;
754 }
755
756 /*!
757   To set up a picker for nodal selection (initialized by SVTK_Renderer::AddActor)
758   \param thePointPicker - new picker
759 */
760 void
761 SALOME_Actor
762 ::SetPointPicker(vtkPointPicker* thePointPicker) 
763 {
764   myPointPicker = thePointPicker;
765 }
766
767 /*!
768   To set up a picker for cell selection (initialized by SVTK_Renderer::AddActor)
769   \param theCellPicker - new picker
770 */
771 void
772 SALOME_Actor
773 ::SetCellPicker(vtkCellPicker* theCellPicker) 
774 {
775   myCellPicker = theCellPicker;
776 }
777
778 /*!
779   To set up a picker for point rectangle selection (initialized by SVTK_Renderer::AddActor)
780   \param theRectPicker - new picker
781 */
782 void
783 SALOME_Actor
784 ::SetPointRectPicker(SVTK_RectPicker* theRectPicker) 
785 {
786   myPointRectPicker = theRectPicker;
787 }
788
789 /*!
790   To set up a picker for cell rectangle selection (initialized by SVTK_Renderer::AddActor)
791   \param theRectPicker - new picker
792 */
793 void
794 SALOME_Actor
795 ::SetCellRectPicker(SVTK_RectPicker* theRectPicker) 
796 {
797   myCellRectPicker = theRectPicker;
798 }
799
800 /*!
801   To set up a prehighlight property (initialized by SVTK_Renderer::AddActor)
802 */
803 void
804 SALOME_Actor
805 ::SetPreHighlightProperty(vtkProperty* theProperty) 
806 {
807   myPreHighlightActor->SetProperty(theProperty);
808 }
809
810 /*!
811   To set up a highlight property (initialized by SVTK_Renderer::AddActor)
812 */
813 void
814 SALOME_Actor
815 ::SetHighlightProperty(vtkProperty* theProperty) 
816 {
817   myHighlightActor->SetProperty(theProperty);
818 }