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