Salome HOME
Update copyrights 2014.
[modules/gui.git] / src / SVTK / SVTK_Renderer.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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 //  SALOME VTKViewer : build VTK viewer into Salome desktop
24 //  File   :
25 //  Author :
26
27 #include "SVTK_Renderer.h"
28
29 #include "SVTK_Trihedron.h"
30 #include "SVTK_CubeAxesActor2D.h"
31 #include "SVTK_AreaPicker.h"
32
33 #include "SALOME_Actor.h"
34 #include "VTKViewer_Actor.h"
35 #include "VTKViewer_Algorithm.h"
36 #include "VTKViewer_Transform.h"
37 #include "VTKViewer_Utilities.h"
38 #include "VTKViewer_OpenGLRenderer.h"
39
40 #include <vtkCamera.h>
41 #include <vtkTextProperty.h>
42 #include <vtkObjectFactory.h>
43 #include <vtkCallbackCommand.h>
44
45 #include <vtkPicker.h>
46 #include <vtkPointPicker.h>
47 #include <vtkCellPicker.h>
48
49 #include <vtkProperty.h>
50 #include <vtkProp3DCollection.h>
51
52 // undefining min and max because CASCADE's defines them and
53 // it clashes with std::min(), std::max() included in utilities.h
54 #undef min
55 #undef max
56
57
58 vtkStandardNewMacro(SVTK_Renderer);
59
60 /*!
61   Constructor
62 */
63 SVTK_Renderer
64 ::SVTK_Renderer():
65   myDevice(VTKViewer_OpenGLRenderer::New()),
66   myInteractor(NULL),
67   myPriority(0.0),
68   myEventCallbackCommand(vtkCallbackCommand::New()),
69   myPointPicker(vtkPointPicker::New()),
70   myCellPicker(vtkCellPicker::New()),
71   myPointAreaPicker(SVTK_AreaPicker::New()),
72   myCellAreaPicker(SVTK_AreaPicker::New()),
73   myPreHighlightProperty(vtkProperty::New()),
74   myHighlightProperty(vtkProperty::New()),
75   myTransform(VTKViewer_Transform::New()),
76   myCubeAxes(SVTK_CubeAxesActor2D::New()),
77   myTrihedron(SVTK_Trihedron::New()),
78   myTrihedronSize(105),
79   myIsTrihedronRelative(true)
80 {
81   myDevice->Delete();
82   myTransform->Delete();
83
84   myPointPicker->Delete();
85   myCellPicker->Delete();
86
87   myPointAreaPicker->Delete();
88   myPointAreaPicker->PickFromListOn();
89
90   myCellAreaPicker->Delete();
91   myCellAreaPicker->PickFromListOn();
92   myCellAreaPicker->PickPointsOff();
93
94   //SetPreselectionProp();
95   myPreHighlightProperty->Delete();
96   myPreHighlightProperty->SetColor(0,1,1);
97   myPreHighlightProperty->SetPointSize(SALOME_POINT_SIZE+2);
98   myPreHighlightProperty->SetLineWidth(SALOME_LINE_WIDTH+2);
99   myPreHighlightProperty->SetRepresentationToPoints();
100
101   //SetSelectionProp();
102   myHighlightProperty->Delete();
103   myHighlightProperty->SetColor(1,1,0);
104   myHighlightProperty->SetPointSize(SALOME_POINT_SIZE+2);
105   myHighlightProperty->SetLineWidth(SALOME_LINE_WIDTH+2);
106   myHighlightProperty->SetRepresentationToPoints();
107
108   // Bug 0020123, note 0005217 - Problem with zoom
109   GetDevice()->SetNearClippingPlaneTolerance( 0.00001 );
110
111   myTrihedron->Delete();
112   myCubeAxes->Delete();
113   myEventCallbackCommand->Delete();
114
115   myTrihedron->AddToRender(GetDevice());
116   GetDevice()->AddViewProp(GetCubeAxes());
117
118   myBndBox[0] = myBndBox[2] = myBndBox[4] = 0;
119   myBndBox[1] = myBndBox[3] = myBndBox[5] = myTrihedron->GetSize();
120
121   myCubeAxes->SetBounds(myBndBox);
122   myCubeAxes->SetCamera(GetDevice()->GetActiveCamera());
123
124   myCubeAxes->SetLabelFormat("%6.4g");
125   myCubeAxes->SetFlyModeToOuterEdges(); // ENK remarks: it must bee
126   myCubeAxes->SetFontFactor(0.8);
127   myCubeAxes->SetCornerOffset(0);
128   myCubeAxes->SetScaling(0);
129   myCubeAxes->SetNumberOfLabels(5);
130   myCubeAxes->VisibilityOff();
131   myCubeAxes->SetTransform(GetTransform());
132
133   vtkTextProperty* aTextProp = vtkTextProperty::New();
134   aTextProp->SetColor(1, 1, 1);
135   aTextProp->ShadowOn();
136   myCubeAxes->SetAxisTitleTextProperty(aTextProp);
137   myCubeAxes->SetAxisLabelTextProperty(aTextProp);
138   aTextProp->Delete();
139
140   GetDevice()->GetActiveCamera()->ParallelProjectionOn();
141   GetDevice()->LightFollowCameraOn();
142   GetDevice()->TwoSidedLightingOn();
143
144   myEventCallbackCommand->SetClientData(this);
145   myEventCallbackCommand->SetCallback(SVTK_Renderer::ProcessEvents);
146   GetDevice()->AddObserver(vtkCommand::ConfigureEvent,
147                            myEventCallbackCommand.GetPointer(), 
148                            myPriority);
149   GetDevice()->AddObserver(vtkCommand::ResetCameraEvent,
150                            myEventCallbackCommand.GetPointer(), 
151                            myPriority);
152   GetDevice()->AddObserver(vtkCommand::ResetCameraClippingRangeEvent,
153                            myEventCallbackCommand.GetPointer(), 
154                            myPriority);
155 }
156
157 /*!
158   Destructor
159 */
160 SVTK_Renderer
161 ::~SVTK_Renderer()
162 {
163   VTK::ActorCollectionCopy aCopy(GetDevice()->GetActors());
164   vtkActorCollection* anActors = aCopy.GetActors();
165   vtkActorCollection* anActors2 = vtkActorCollection::New();
166
167   anActors->InitTraversal();
168   while(vtkActor* anAct = anActors->GetNextActor()){
169     if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct)){
170       anActors2->AddItem(anActor);
171     }
172   }
173
174   anActors2->InitTraversal();
175   while(vtkActor* anAct = anActors2->GetNextActor()){
176     if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct)){
177       RemoveActor(anActor);
178     }
179   }
180
181   anActors2->Delete();
182 }
183
184
185 /*!
186   Main process event method
187 */
188 void 
189 SVTK_Renderer
190 ::ProcessEvents(vtkObject* vtkNotUsed(theObject), 
191                 unsigned long theEvent,
192                 void* theClientData, 
193                 void* vtkNotUsed(theCallData))
194 {
195   SVTK_Renderer* self = reinterpret_cast<SVTK_Renderer*>(theClientData);
196
197   switch(theEvent){
198   case vtkCommand::ConfigureEvent:
199     self->OnResetView();
200     break;
201   case vtkCommand::ResetCameraEvent:
202     self->OnFitAll();
203     break;
204   case vtkCommand::ResetCameraClippingRangeEvent:
205     self->OnResetClippingRange();
206     break;
207   }
208 }
209
210 /*!
211   \return renderer's device
212 */
213 vtkRenderer* 
214 SVTK_Renderer
215 ::GetDevice()
216 {
217   return myDevice.GetPointer();
218 }
219
220 /*!
221   Initialize renderer
222 */
223 void 
224 SVTK_Renderer
225 ::Initialize(vtkRenderWindowInteractor* theInteractor,
226              SVTK_Selector* theSelector)
227 {
228   myInteractor = theInteractor;
229   mySelector = theSelector;
230   SetSelectionTolerance();
231 }
232
233 /*!
234   Publishes pointed actor into the renderer
235 */
236 void
237 SVTK_Renderer
238 ::AddActor(VTKViewer_Actor* theActor, bool theIsAdjustActors)
239 {
240   if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor)){
241     anActor->SetInteractor(myInteractor);
242     anActor->SetTransform(GetTransform());
243     anActor->SetSelector(mySelector.GetPointer());
244
245     anActor->SetPointPicker(myPointPicker.GetPointer());
246     anActor->SetCellPicker(myCellPicker.GetPointer());
247
248     anActor->SetPointAreaPicker(myPointAreaPicker.GetPointer());
249     anActor->SetCellAreaPicker(myCellAreaPicker.GetPointer());
250
251     anActor->SetPreHighlightProperty(myPreHighlightProperty.GetPointer());
252     anActor->SetHighlightProperty(myHighlightProperty.GetPointer());
253
254     anActor->AddToRender(GetDevice());
255     anActor->UpdateNameActors();
256
257     if(theIsAdjustActors)
258       AdjustActors();
259   }
260 }
261
262 /*!
263   Removes pointed actor from the renderer
264 */
265 void
266 SVTK_Renderer
267 ::RemoveActor(VTKViewer_Actor* theActor, bool theIsAdjustActors)
268 {
269   if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor)){
270     // Order of the calls are important because VTKViewer_Actor::RemoveFromRender
271     //   can leads do destruction of the actor
272     anActor->SetInteractor(NULL);
273     anActor->SetTransform(NULL);
274     anActor->SetSelector(NULL);
275
276     anActor->SetPointPicker(NULL);
277     anActor->SetCellPicker(NULL);
278
279     anActor->SetPointAreaPicker(NULL);
280     anActor->SetCellAreaPicker(NULL);
281
282     anActor->SetPreHighlightProperty(NULL);
283     anActor->SetHighlightProperty(NULL);
284
285     anActor->RemoveFromRender(GetDevice());
286
287     while ( int i = myPointPicker->GetProp3Ds()->IsItemPresent( theActor ))
288       myPointPicker->GetProp3Ds()->RemoveItem( i-1 );
289     while ( int i = myCellPicker->GetProp3Ds()->IsItemPresent( theActor ))
290       myCellPicker->GetProp3Ds()->RemoveItem( i-1 );
291
292     while ( int i = myPointPicker->GetActors()->IsItemPresent( theActor ))
293       myPointPicker->GetActors()->RemoveItem( i-1 );
294     while ( int i = myCellPicker->GetActors()->IsItemPresent( theActor ))
295       myCellPicker->GetActors()->RemoveItem( i-1 );
296
297     if(theIsAdjustActors)
298       AdjustActors();
299   }
300 }
301
302 /*!
303   Get special container that keeps scaling of the scene
304 */
305 VTKViewer_Transform* 
306 SVTK_Renderer
307 ::GetTransform()
308 {
309   return myTransform.GetPointer();
310 }
311
312 /*!
313   Allows to get a scale that is applied on the whole scene
314 */
315 void
316 SVTK_Renderer
317 ::GetScale( double theScale[3] ) 
318 {
319   myTransform->GetMatrixScale( theScale );
320 }
321
322 /*!
323   Allows to apply a scale on the whole scene
324 */
325 void
326 SVTK_Renderer
327 ::SetScale( double theScale[3] ) 
328 {
329   myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
330   AdjustActors();
331
332   VTK::ActorCollectionCopy aCopy(GetDevice()->GetActors());
333   vtkActorCollection* anActors = aCopy.GetActors();
334   anActors->InitTraversal();
335   while(vtkActor* anAct = anActors->GetNextActor())
336     if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct))
337       if(anActor->isHighlighted() && !anActor->IsInfinitive())
338         anActor->highlight(true);
339 }
340
341 /*!
342   Applies color and size (PointSize and LineWidth) of primitives in selection mode
343 */
344 void
345 SVTK_Renderer
346 ::SetSelectionProp(const double& theRed, 
347                    const double& theGreen, 
348                    const double& theBlue, 
349                    const int& theWidth) 
350 {
351   myHighlightProperty->SetColor( theRed, theGreen, theBlue );
352   myHighlightProperty->SetLineWidth( theWidth );
353   myHighlightProperty->SetPointSize( theWidth );
354 }
355
356 /*!
357   Applies color and size (PointSize and LineWidth) of primitives in preselection mode
358 */
359 void
360 SVTK_Renderer
361 ::SetPreselectionProp(const double& theRed, 
362                       const double& theGreen, 
363                       const double& theBlue, 
364                       const int& theWidth) 
365 {
366   myPreHighlightProperty->SetColor( theRed, theGreen, theBlue );
367   myPreHighlightProperty->SetLineWidth( theWidth );
368   myPreHighlightProperty->SetPointSize( theWidth );
369 }
370
371 /*!
372   Setup requested tolerance for the picking
373 */
374 void
375 SVTK_Renderer
376 ::SetSelectionTolerance(const double& theTolNodes, 
377                         const double& theTolCell,
378                         const double& theTolObjects)
379 {
380   myPointPicker->SetTolerance( theTolNodes );
381   myCellPicker->SetTolerance( theTolCell );
382
383   myPointAreaPicker->SetTolerance( theTolNodes );
384   myCellAreaPicker->SetTolerance( theTolCell );
385
386   mySelector->SetTolerance( theTolObjects );
387 }
388
389
390 /*! If parameter theIsForcedUpdate is true, recalculate parameters for
391  *  trihedron and cube axes, even if trihedron and cube axes is invisible.
392  */
393
394 inline
395 bool
396 CheckBndBox(const double theBounds[6])
397 {
398   if(theBounds[0] > -VTK_LARGE_FLOAT && theBounds[1] < VTK_LARGE_FLOAT &&
399      theBounds[2] > -VTK_LARGE_FLOAT && theBounds[3] < VTK_LARGE_FLOAT &&
400      theBounds[4] > -VTK_LARGE_FLOAT && theBounds[5] < VTK_LARGE_FLOAT)
401     return true;
402   return false;
403 }
404
405 /*!
406   Adjusts size of actors
407 */
408 bool
409 SVTK_Renderer
410 ::OnAdjustActors()
411 {
412   bool aTDisplayed = IsTrihedronDisplayed();
413   bool aCDisplayed = IsCubeAxesDisplayed();
414
415   double aNewBndBox[6];
416   aNewBndBox[ 0 ] = aNewBndBox[ 2 ] = aNewBndBox[ 4 ] = VTK_LARGE_FLOAT;
417   aNewBndBox[ 1 ] = aNewBndBox[ 3 ] = aNewBndBox[ 5 ] = -VTK_LARGE_FLOAT;
418
419   int aVisibleNum = myTrihedron->GetVisibleActorCount(GetDevice());
420   if(aVisibleNum){
421     if(aTDisplayed)
422       myTrihedron->VisibilityOff();
423
424     if(aCDisplayed) 
425       myCubeAxes->VisibilityOff();
426
427     // if the new trihedron size have sufficient difference, then apply the value
428     double aSize = myTrihedron->GetSize();
429     if ( IsTrihedronRelative() )
430       {
431         ComputeTrihedronSize(GetDevice(),aSize,aSize,myTrihedronSize);
432         myTrihedron->SetSize(aSize);
433       }
434     else
435       myTrihedron->SetSize( myTrihedronSize );
436
437     // iterate through displayed objects and set size if necessary
438     VTK::ActorCollectionCopy aCopy(GetDevice()->GetActors());
439     vtkActorCollection* anActors = aCopy.GetActors();
440     anActors->InitTraversal();
441     while(vtkActor* anAct = anActors->GetNextActor()){
442       if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct)){
443         if(anActor->IsResizable())
444           anActor->SetSize(0.5*aSize);
445         if(anActor->GetVisibility() && !anActor->IsInfinitive()){
446           double *aBounds = anActor->GetBounds();
447           if(CheckBndBox(aBounds))
448             for(int i = 0; i < 5; i = i + 2){
449               if(aBounds[i] < aNewBndBox[i]) 
450                 aNewBndBox[i] = aBounds[i];
451               if(aBounds[i+1] > aNewBndBox[i+1]) 
452                 aNewBndBox[i+1] = aBounds[i+1];
453             }
454         }
455       }
456     }
457
458     if(aTDisplayed) 
459       myTrihedron->VisibilityOn();
460
461     if(aCDisplayed) 
462       myCubeAxes->VisibilityOn();
463     
464   }else{
465     double aSize = myTrihedron->GetSize();
466     aNewBndBox[0] = aNewBndBox[2] = aNewBndBox[4] = 0;
467     aNewBndBox[1] = aNewBndBox[3] = aNewBndBox[5] = aSize;
468   }
469   
470   if(CheckBndBox(aNewBndBox)){
471     for(int i = 0; i < 6; i++)
472       myBndBox[i] = aNewBndBox[i];
473     myCubeAxes->SetBounds(myBndBox);
474     return true;
475   }
476
477   return false;
478 }
479
480 /*!
481   Adjusts size of actors
482 */
483 void
484 SVTK_Renderer
485 ::AdjustActors()
486 {
487   if(OnAdjustActors())
488     ::ResetCameraClippingRange(GetDevice());
489 }
490
491 /*!
492   Set size of the trihedron
493   \param theSize - new size
494   \param theRelative - if it is true, then size is mesured in percents from bounding box of the scene,
495   otherwise - in viewer units
496 */
497 void
498 SVTK_Renderer
499 ::SetTrihedronSize(double theSize, const bool theRelative)
500 {
501   if(myTrihedronSize != theSize || myIsTrihedronRelative != theRelative){
502     myTrihedronSize = theSize;
503     myIsTrihedronRelative = theRelative;
504     AdjustActors();
505   }
506 }
507
508 /*!
509   \return size of the trihedron in percents from bounding box of the scene
510 */
511 double
512 SVTK_Renderer
513 ::GetTrihedronSize() const
514 {
515   return myTrihedronSize;
516 }
517
518 /*!
519   \return true if the size of the trihedron is relative
520 */
521 bool 
522 SVTK_Renderer
523 ::IsTrihedronRelative() const
524 {
525   return myIsTrihedronRelative;
526 }
527
528 /*!
529   \return trihedron control
530 */
531 VTKViewer_Trihedron* 
532 SVTK_Renderer
533 ::GetTrihedron()
534 {
535   return myTrihedron.GetPointer();
536 }
537
538 /*!
539   \return true if trihedron is displayed
540 */
541 bool
542 SVTK_Renderer
543 ::IsTrihedronDisplayed()
544 {
545   return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
546 }
547
548 /*!
549   Toggle trihedron visibility
550 */
551 void 
552 SVTK_Renderer
553 ::OnViewTrihedron()
554 {
555   if(IsTrihedronDisplayed())
556     myTrihedron->VisibilityOff();
557   else
558     myTrihedron->VisibilityOn();
559 }
560
561 /*!
562   Adjust size of the trihedron to the bounding box of the scene
563 */
564 void
565 SVTK_Renderer
566 ::OnAdjustTrihedron()
567 {   
568   AdjustActors();
569 }
570
571 /*!
572   \return graduated rules control
573 */
574 SVTK_CubeAxesActor2D* 
575 SVTK_Renderer
576 ::GetCubeAxes()
577 {
578   return myCubeAxes.GetPointer();
579 }
580
581 /*!
582   \return true if graduated rules displayed
583 */
584 bool
585 SVTK_Renderer
586 ::IsCubeAxesDisplayed()
587 {
588   return myCubeAxes->GetVisibility() == 1;
589 }
590
591 /*!
592   Toggle graduated rules visibility
593 */
594 void
595 SVTK_Renderer
596 ::OnViewCubeAxes()
597 {
598   if(IsCubeAxesDisplayed())
599     myCubeAxes->VisibilityOff();
600   else
601     myCubeAxes->VisibilityOn();
602 }
603
604 /*!
605   Adjust size of the graduated rules to the bounding box of the scene
606 */
607 void
608 SVTK_Renderer
609 ::OnAdjustCubeAxes()
610 {   
611   AdjustActors();
612 }
613
614 /*!
615   Sets camera into predefined state
616 */
617 void
618 SVTK_Renderer
619 ::OnResetView()
620 {
621   int aTrihedronIsVisible = IsTrihedronDisplayed();
622   int aCubeAxesIsVisible = IsCubeAxesDisplayed();
623
624   myTrihedron->SetVisibility( VTKViewer_Trihedron::eOnlyLineOn );
625   myCubeAxes->SetVisibility(0);
626
627   ::ResetCamera(GetDevice(),true);  
628   vtkCamera* aCamera = GetDevice()->GetActiveCamera();
629   aCamera->SetPosition(1,-1,1);
630   aCamera->SetViewUp(0,0,1);
631   ::ResetCamera(GetDevice(),true);  
632
633   if(aTrihedronIsVisible) 
634     myTrihedron->VisibilityOn();
635   else
636     myTrihedron->VisibilityOff();
637
638   if(aCubeAxesIsVisible) 
639     myCubeAxes->VisibilityOn();
640   else
641     myCubeAxes->VisibilityOff();
642
643   static double aCoeff = 3.0;
644   aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale());
645 }
646
647 /*!
648   Fit all presentation in the scene into the window
649 */
650 void
651 SVTK_Renderer
652 ::OnFitAll()
653 {
654   int aTrihedronWasVisible = false;
655   int aCubeAxesWasVisible = false;
656
657   aTrihedronWasVisible = IsTrihedronDisplayed();
658   if(aTrihedronWasVisible)
659     myTrihedron->VisibilityOff();
660
661   aCubeAxesWasVisible = IsCubeAxesDisplayed();
662   if(aCubeAxesWasVisible)
663     myCubeAxes->VisibilityOff();
664
665   if(myTrihedron->GetVisibleActorCount(GetDevice())){
666     myTrihedron->VisibilityOff();
667     myCubeAxes->VisibilityOff();
668     ::ResetCamera(GetDevice());
669   }else{
670     myTrihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
671     myCubeAxes->SetVisibility(2);
672     ::ResetCamera(GetDevice(),true);
673   }
674
675   if(aTrihedronWasVisible)
676     myTrihedron->VisibilityOn();
677   else
678     myTrihedron->VisibilityOff();
679   
680   if(aCubeAxesWasVisible)
681     myCubeAxes->VisibilityOn();
682   else
683     myCubeAxes->VisibilityOff();
684
685   ::ResetCameraClippingRange(GetDevice());
686 }
687
688 /*!
689   Reset camera clipping range to adjust the range to the bounding box of the scene
690 */
691 void
692 SVTK_Renderer
693 ::OnResetClippingRange()
694 {
695   return;
696   ::ResetCameraClippingRange(GetDevice());
697 }
698
699 /*!
700   To reset direction of the camera to front view
701 */
702 void
703 SVTK_Renderer
704 ::OnFrontView()
705 {
706   vtkCamera* aCamera = GetDevice()->GetActiveCamera();
707   aCamera->SetPosition(1,0,0);
708   aCamera->SetViewUp(0,0,1);
709   aCamera->SetFocalPoint(0,0,0);
710   this->OnFitAll();
711 }
712
713 /*!
714   To reset direction of the camera to back view
715 */
716 void
717 SVTK_Renderer
718 ::OnBackView()
719 {
720   vtkCamera* aCamera = GetDevice()->GetActiveCamera();
721   aCamera->SetPosition(-1,0,0);
722   aCamera->SetViewUp(0,0,1);
723   aCamera->SetFocalPoint(0,0,0);
724   this->OnFitAll();
725 }
726
727 /*!
728   To reset direction of the camera to top view
729 */
730 void
731 SVTK_Renderer
732 ::OnTopView()
733 {
734   vtkCamera* aCamera = GetDevice()->GetActiveCamera();
735   aCamera->SetPosition(0,0,1);
736   aCamera->SetViewUp(0,1,0);
737   aCamera->SetFocalPoint(0,0,0);
738   this->OnFitAll();
739 }
740
741 /*!
742   To reset direction of the camera to bottom view
743 */
744 void
745 SVTK_Renderer
746 ::OnBottomView()
747 {
748   vtkCamera* aCamera = GetDevice()->GetActiveCamera();
749   aCamera->SetPosition(0,0,-1);
750   aCamera->SetViewUp(0,1,0);
751   aCamera->SetFocalPoint(0,0,0);
752   this->OnFitAll();
753 }
754
755 /*!
756   To reset direction of the camera to left view
757 */
758 void
759 SVTK_Renderer
760 ::OnLeftView()
761 {
762   vtkCamera* aCamera = GetDevice()->GetActiveCamera(); 
763   aCamera->SetPosition(0,-1,0);
764   aCamera->SetViewUp(0,0,1);
765   aCamera->SetFocalPoint(0,0,0);
766   this->OnFitAll();
767 }
768
769
770 /*!
771   To rotate view 90 degrees clockwise
772 */
773 void
774 SVTK_Renderer
775 ::onClockWiseView()
776 {
777   vtkCamera* aCamera = GetDevice()->GetActiveCamera(); 
778   aCamera->Roll(-90);
779   aCamera->OrthogonalizeViewUp();
780 }
781
782 /*!
783   To rotate view 90 degrees counterclockwise
784 */
785 void
786 SVTK_Renderer
787 ::onAntiClockWiseView()
788 {
789   vtkCamera* aCamera = GetDevice()->GetActiveCamera(); 
790   aCamera->Roll(90);
791   aCamera->OrthogonalizeViewUp();
792 }
793
794 /*!
795   To reset direction of the camera to right view
796 */
797 void
798 SVTK_Renderer
799 ::OnRightView()
800 {
801   vtkCamera* aCamera = GetDevice()->GetActiveCamera();
802   aCamera->SetPosition(0,1,0);
803   aCamera->SetViewUp(0,0,1);
804   aCamera->SetFocalPoint(0,0,0);
805   this->OnFitAll();
806 }