Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/gui.git] / src / SVTK / SVTK_ViewWindow.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #include "SALOME_Actor.h"
20
21 #include <qapplication.h>
22 #include <qimage.h>
23
24 #include <vtkTextProperty.h>
25 #include <vtkActorCollection.h>
26 #include <vtkRenderWindow.h>
27 #include <vtkRenderer.h>
28 #include <vtkCamera.h>
29 #include <vtkPointPicker.h>
30 #include <vtkCellPicker.h>
31 #include <vtkAxisActor2D.h>
32
33 #include "QtxAction.h"
34
35 #include "SUIT_Session.h"
36 #include "SUIT_ToolButton.h"
37 #include "SUIT_MessageBox.h"
38 #include "SUIT_Accel.h"
39
40 #include "SUIT_Tools.h"
41 #include "SUIT_ResourceMgr.h"
42 #include "SUIT_Accel.h"
43
44 #include "VTKViewer_Utilities.h"
45
46 #include "SVTK_View.h"
47 #include "SVTK_MainWindow.h"
48 #include "SVTK_Selector.h"
49
50 #include "SVTK_Event.h"
51 #include "SVTK_Renderer.h"
52 #include "SVTK_ViewWindow.h"
53 #include "SVTK_ViewModelBase.h"
54 #include "SVTK_InteractorStyle.h"
55 #include "SVTK_RenderWindowInteractor.h"
56 #include "SVTK_GenericRenderWindowInteractor.h"
57 #include "SVTK_CubeAxesActor2D.h"
58
59 #include "SALOME_ListIteratorOfListIO.hxx"
60
61 #include "VTKViewer_Algorithm.h"
62 #include "SVTK_Functor.h"
63
64 /*!
65   Constructor
66 */
67 SVTK_ViewWindow
68 ::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
69   SUIT_ViewWindow(theDesktop),
70   myMainWindow(NULL),
71   myView(NULL)
72 {}
73
74 /*!
75   To initialize #SVTK_ViewWindow instance
76 */
77 void
78 SVTK_ViewWindow
79 ::Initialize(SVTK_ViewModelBase* theModel)
80 {
81   if(SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr()){
82     myMainWindow = new SVTK_MainWindow(this,"SVTK_MainWindow",aResourceMgr,this);
83
84     SVTK_RenderWindowInteractor* anIteractor = 
85       new SVTK_RenderWindowInteractor(myMainWindow,"SVTK_RenderWindowInteractor");
86
87     SVTK_Selector* aSelector = SVTK_Selector::New();
88
89     SVTK_GenericRenderWindowInteractor* aDevice = 
90       SVTK_GenericRenderWindowInteractor::New();
91     aDevice->SetRenderWidget(anIteractor);
92     aDevice->SetSelector(aSelector);
93
94     SVTK_Renderer* aRenderer = SVTK_Renderer::New();
95     aRenderer->Initialize(aDevice,aSelector);
96
97     anIteractor->Initialize(aDevice,aRenderer,aSelector);
98
99     aDevice->Delete();
100     aRenderer->Delete();
101     aSelector->Delete();
102
103     myMainWindow->Initialize(anIteractor);
104
105     SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New();
106     anIteractor->PushInteractorStyle(aStyle);
107     aStyle->Delete();
108
109     setCentralWidget(myMainWindow);
110     
111     myView = new SVTK_View(myMainWindow);
112     Initialize(myView,theModel);
113   }
114 }
115
116 /*!
117   To initialize #SVTK_ViewWindow instance
118 */
119 void
120 SVTK_ViewWindow
121 ::Initialize(SVTK_View* theView,
122              SVTK_ViewModelBase* theModel)
123 {
124   connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
125           this,SLOT(onKeyPressed(QKeyEvent*)) );
126   connect(theView,SIGNAL(KeyReleased(QKeyEvent*)),
127           this,SLOT(onKeyReleased(QKeyEvent*)));
128   connect(theView,SIGNAL(MouseButtonPressed(QMouseEvent*)),
129           this,SLOT(onMousePressed(QMouseEvent*)));
130   connect(theView,SIGNAL(MouseButtonReleased(QMouseEvent*)),
131           this,SLOT(onMouseReleased(QMouseEvent*)));
132   connect(theView,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
133           this,SLOT(onMouseDoubleClicked(QMouseEvent*)));
134   connect(theView,SIGNAL(MouseMove(QMouseEvent*)),
135           this,SLOT(onMouseMoving(QMouseEvent*)));
136   connect(theView,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
137           this,SIGNAL(contextMenuRequested(QContextMenuEvent *)));
138   connect(theView,SIGNAL(selectionChanged()),
139           theModel,SLOT(onSelectionChanged()));
140 }
141
142 /*!
143   Destructor
144 */
145 SVTK_ViewWindow
146 ::~SVTK_ViewWindow()
147 {}
148
149
150 /*!
151   \return corresponding view
152 */
153 SVTK_View* 
154 SVTK_ViewWindow
155 ::getView() 
156
157   return myView; 
158 }
159
160 /*!
161   \return corresponding vtk main window
162 */
163 SVTK_MainWindow* 
164 SVTK_ViewWindow
165 ::getMainWindow() 
166
167   return myMainWindow; 
168 }
169
170 /*!
171   \return corresponding vtk render window
172 */
173 vtkRenderWindow*
174 SVTK_ViewWindow
175 ::getRenderWindow()
176 {
177   return getMainWindow()->getRenderWindow();
178 }
179
180 /*!
181   \return corresponding vtk render window interactor
182 */
183 vtkRenderWindowInteractor*
184 SVTK_ViewWindow
185 ::getInteractor()
186 {
187   return getMainWindow()->getInteractor();
188 }
189
190 /*!
191   \return corresponding vtk renderer
192 */
193 vtkRenderer*
194 SVTK_ViewWindow
195 ::getRenderer()
196 {
197   return myMainWindow->getRenderer();
198 }
199
200 /*!
201   \return corresponding vtk selector
202 */
203 SVTK_Selector* 
204 SVTK_ViewWindow
205 ::GetSelector() 
206
207   return myMainWindow->GetSelector(); 
208 }
209
210 /*!
211   Processes transformation "front view"
212 */
213 void
214 SVTK_ViewWindow
215 ::onFrontView()
216 {
217   myMainWindow->onFrontView();
218 }
219
220 /*!
221   Processes transformation "back view"
222 */
223 void
224 SVTK_ViewWindow
225 ::onBackView()
226 {
227   myMainWindow->onBackView();
228 }
229
230 /*!
231   Processes transformation "top view"
232 */
233 void
234 SVTK_ViewWindow
235 ::onTopView()
236 {
237   myMainWindow->onTopView();
238 }
239
240 /*!
241   Processes transformation "bottom view"
242 */
243 void
244 SVTK_ViewWindow
245 ::onBottomView()
246 {
247   myMainWindow->onBottomView();
248 }
249
250 /*!
251   Processes transformation "left view"
252 */
253 void
254 SVTK_ViewWindow
255 ::onLeftView()
256 {
257   myMainWindow->onLeftView();
258 }
259
260 /*!
261   Processes transformation "right view"
262 */
263 void
264 SVTK_ViewWindow
265 ::onRightView()
266 {
267   myMainWindow->onRightView();
268 }
269
270 /*!
271   Processes transformation "reset view": sets default orientation of viewport camera
272 */
273 void
274 SVTK_ViewWindow
275 ::onResetView()
276 {
277   myMainWindow->onResetView();
278 }
279
280 /*!
281   Processes transformation "fit all"
282 */
283 void
284 SVTK_ViewWindow
285 ::onFitAll()
286 {
287   myMainWindow->onFitAll();
288 }
289
290 /*!
291   SLOT: called if selection is changed
292 */
293 void
294 SVTK_ViewWindow
295 ::onSelectionChanged()
296 {
297   myView->onSelectionChanged();
298 }
299
300 /*!
301   Change selection mode
302   \param theMode - new selection mode
303 */
304 void
305 SVTK_ViewWindow
306 ::SetSelectionMode(Selection_Mode theMode)
307 {
308   myMainWindow->SetSelectionMode( theMode );
309 }
310
311 /*!
312   \return selection mode
313 */
314 Selection_Mode
315 SVTK_ViewWindow
316 ::SelectionMode() const
317 {
318   return myMainWindow->SelectionMode();
319 }
320
321 /*!
322   Unhilights all objects in viewer
323 */
324 void 
325 SVTK_ViewWindow
326 ::unHighlightAll() 
327 {
328   myView->unHighlightAll();
329 }
330
331 /*!
332   Hilights/unhilights object in viewer
333   \param theIO - object to be updated
334   \param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted
335   \param theIsUpdate - update current viewer
336 */
337 void
338 SVTK_ViewWindow
339 ::highlight(const Handle(SALOME_InteractiveObject)& theIO, 
340             bool theIsHighlight, 
341             bool theIsUpdate ) 
342 {
343   myView->highlight( theIO, theIsHighlight, theIsUpdate );
344 }
345
346 /*!
347   \return true if object is in viewer or in collector
348   \param theIO - object to be checked
349 */
350 bool
351 SVTK_ViewWindow
352 ::isInViewer( const Handle(SALOME_InteractiveObject)& theIO ) 
353 {
354   return myView->isInViewer( theIO );
355 }
356
357 /*!
358   \return true if object is displayed in viewer
359   \param theIO - object to be checked
360 */
361 bool
362 SVTK_ViewWindow
363 ::isVisible( const Handle(SALOME_InteractiveObject)& theIO ) 
364 {
365   return myView->isVisible( theIO );
366 }
367
368 /*!
369   Display object
370   \param theEntry - entry that corresponds to intractive objects
371 */
372 Handle(SALOME_InteractiveObject)
373 SVTK_ViewWindow
374 ::FindIObject(const char* theEntry) 
375 {
376   return myView->FindIObject(theEntry);
377 }
378
379 /*!
380   Display object
381   \param theIO - object
382   \param theImmediatly - update viewer
383 */
384 void
385 SVTK_ViewWindow
386 ::Display(const Handle(SALOME_InteractiveObject)& theIO,
387           bool theImmediatly) 
388 {
389   myView->Display(theIO,theImmediatly);
390 }
391
392 /*!
393   Erase object
394   \param theIO - object
395   \param theImmediatly - update viewer
396 */
397 void
398 SVTK_ViewWindow
399 ::Erase(const Handle(SALOME_InteractiveObject)& theIO,
400           bool theImmediatly) 
401 {
402   myView->Erase(theIO,theImmediatly);
403 }
404
405 /*!
406   Display only passed object
407   \param theIO - object
408 */
409 void
410 SVTK_ViewWindow
411 ::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO) 
412 {
413   myView->DisplayOnly(theIO);
414 }
415
416 /*!
417   Display all objects in view
418 */
419 void 
420 SVTK_ViewWindow
421 ::DisplayAll() 
422 {
423   myView->DisplayAll();
424 }
425
426 /*!
427   Erase all objects in view
428 */
429 void 
430 SVTK_ViewWindow
431 ::EraseAll() 
432 {
433   myView->EraseAll();
434 }
435
436 /*!
437   Sets background color
438   \param color - new background color
439 */
440 void
441 SVTK_ViewWindow
442 ::setBackgroundColor( const QColor& color )
443 {
444   myMainWindow->SetBackgroundColor( color );
445 }
446
447 /*!
448   \return background color of viewer
449 */
450 QColor
451 SVTK_ViewWindow
452 ::backgroundColor() const
453 {
454   return myMainWindow->BackgroundColor();
455 }
456
457 /*!
458   Updates current viewer
459 */
460 void
461 SVTK_ViewWindow
462 ::Repaint(bool theUpdateTrihedron)
463 {
464   myMainWindow->Repaint( theUpdateTrihedron );
465 }
466
467 /*!
468   Redirect the request to #SVTK_Renderer::GetScale
469 */
470 void
471 SVTK_ViewWindow
472 ::GetScale( double theScale[3] ) 
473 {
474   myMainWindow->GetScale( theScale );
475 }
476
477 /*!
478   Redirect the request to #SVTK_Renderer::SetScale
479 */
480 void
481 SVTK_ViewWindow
482 ::SetScale( double theScale[3] ) 
483 {
484   myMainWindow->SetScale( theScale );
485 }
486
487 /*!
488   Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
489 */
490 bool
491 SVTK_ViewWindow
492 ::isTrihedronDisplayed()
493 {
494   return myMainWindow->IsTrihedronDisplayed();
495 }
496
497 /*!
498   Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
499 */
500 bool
501 SVTK_ViewWindow
502 ::isCubeAxesDisplayed()
503 {
504   return myMainWindow->IsCubeAxesDisplayed();
505 }
506
507 /*!
508   Redirect the request to #SVTK_Renderer::OnViewTrihedron
509 */
510 void 
511 SVTK_ViewWindow
512 ::onViewTrihedron()
513 {
514   myMainWindow->onViewTrihedron();
515 }
516
517 /*!
518   Redirect the request to #SVTK_Renderer::OnViewCubeAxes
519 */
520 void
521 SVTK_ViewWindow
522 ::onViewCubeAxes()
523 {
524   myMainWindow->onViewCubeAxes();
525 }
526
527 /*!
528   Redirect the request to #SVTK_Renderer::GetTrihedron
529 */
530 VTKViewer_Trihedron* 
531 SVTK_ViewWindow::
532 GetTrihedron()
533 {
534   return myMainWindow->GetTrihedron();
535 }
536
537 /*!
538   Redirect the request to #SVTK_Renderer::GetCubeAxes
539 */
540 SVTK_CubeAxesActor2D* 
541 SVTK_ViewWindow
542 ::GetCubeAxes()
543 {
544   return myMainWindow->GetCubeAxes();
545 }
546
547 /*!
548   \return trihedron size
549 */
550 int
551 SVTK_ViewWindow
552 ::GetTrihedronSize() const
553 {
554   return myMainWindow->GetTrihedronSize();
555 }
556
557 /*!
558   Sets trihedron size
559   \param theSize - new trihedron size
560   \param theRelative - trihedron relativeness
561 */
562 void
563 SVTK_ViewWindow
564 ::SetTrihedronSize(const int theSize, const bool theRelative)
565 {
566   myMainWindow->SetTrihedronSize(theSize, theRelative);
567 }
568
569 /*! If parameter theIsForcedUpdate is true, recalculate parameters for
570  *  trihedron and cube axes, even if trihedron and cube axes is invisible.
571  */
572 void
573 SVTK_ViewWindow
574 ::AdjustTrihedrons(const bool theIsForcedUpdate)
575 {
576   myMainWindow->AdjustActors();
577 }
578
579 /*!
580   Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
581 */
582 void
583 SVTK_ViewWindow
584 ::onAdjustTrihedron()
585 {   
586   myMainWindow->onAdjustTrihedron();
587 }
588
589 /*!
590   Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
591 */
592 void
593 SVTK_ViewWindow
594 ::onAdjustCubeAxes()
595 {   
596   myMainWindow->onAdjustCubeAxes();
597 }
598
599 /*!
600   Emits key pressed
601 */
602 void
603 SVTK_ViewWindow
604 ::onKeyPressed(QKeyEvent* event)
605 {
606   emit keyPressed( this, event );
607 }
608
609 /*!
610   Emits key released
611 */
612 void
613 SVTK_ViewWindow
614 ::onKeyReleased(QKeyEvent* event)
615 {
616   emit keyReleased( this, event );
617 }
618
619 /*!
620   Emits mouse pressed
621 */
622 void
623 SVTK_ViewWindow
624 ::onMousePressed(QMouseEvent* event)
625 {
626   emit mousePressed(this, event);
627 }
628
629 /*!
630   Emits mouse released
631 */
632 void
633 SVTK_ViewWindow
634 ::onMouseReleased(QMouseEvent* event)
635 {
636   emit mouseReleased( this, event );
637 }
638
639 /*!
640   Emits mouse moving
641 */
642 void
643 SVTK_ViewWindow
644 ::onMouseMoving(QMouseEvent* event)
645 {
646   emit mouseMoving( this, event );
647 }
648
649 /*!
650   Emits mouse double clicked
651 */
652 void
653 SVTK_ViewWindow
654 ::onMouseDoubleClicked( QMouseEvent* event )
655 {
656   emit mouseDoubleClicked( this, event );
657 }
658
659 /*!
660   Redirect the request to #SVTK_Renderer::AddActor
661 */
662 void
663 SVTK_ViewWindow
664 ::AddActor( VTKViewer_Actor* theActor, 
665             bool theUpdate )
666 {
667   myMainWindow->AddActor( theActor, theUpdate );
668 }
669
670 /*!
671   Redirect the request to #SVTK_Renderer::RemoveActor
672 */
673 void
674 SVTK_ViewWindow
675 ::RemoveActor( VTKViewer_Actor* theActor, 
676                bool theUpdate )
677 {
678   myMainWindow->RemoveActor( theActor, theUpdate );
679 }
680
681 /*!
682   \return QImage, containing all scene rendering in window
683 */
684 QImage
685 SVTK_ViewWindow
686 ::dumpView()
687 {
688   return myMainWindow->dumpView();
689 }
690
691 /*!
692   Redirect the request to #SVTK_Renderer::SetSelectionProp
693 */
694 void
695 SVTK_ViewWindow
696 ::SetSelectionProp(const double& theRed, 
697                    const double& theGreen, 
698                    const double& theBlue, 
699                    const int& theWidth) 
700 {
701   myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
702 }
703
704 /*!
705   Redirect the request to #SVTK_Renderer::SetSelectionProp
706 */
707 void
708 SVTK_ViewWindow
709 ::SetPreselectionProp(const double& theRed, 
710                       const double& theGreen, 
711                       const double& theBlue, 
712                       const int& theWidth) 
713 {
714   myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
715 }
716
717 /*!
718   Redirect the request to #SVTK_Renderer::SetSelectionTolerance
719 */
720 void
721 SVTK_ViewWindow
722 ::SetSelectionTolerance(const double& theTolNodes, 
723                         const double& theTolItems)
724 {
725   myView->SetSelectionTolerance(theTolNodes,theTolItems);
726 }
727
728 int convertAction( const int accelAction )
729 {
730   switch ( accelAction ) {
731   case SUIT_Accel::PanLeft     : return SVTK::PanLeftEvent;
732   case SUIT_Accel::PanRight    : return SVTK::PanRightEvent;
733   case SUIT_Accel::PanUp       : return SVTK::PanUpEvent;
734   case SUIT_Accel::PanDown     : return SVTK::PanDownEvent;
735   case SUIT_Accel::ZoomIn      : return SVTK::ZoomInEvent;
736   case SUIT_Accel::ZoomOut     : return SVTK::ZoomOutEvent;
737   case SUIT_Accel::RotateLeft  : return SVTK::RotateLeftEvent;
738   case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
739   case SUIT_Accel::RotateUp    : return SVTK::RotateUpEvent;
740   case SUIT_Accel::RotateDown  : return SVTK::RotateDownEvent;  
741   }
742   return accelAction;
743 }
744
745 /*!
746   Performs action
747   \param accelAction - action
748 */
749 bool 
750 SVTK_ViewWindow
751 ::action( const int accelAction  )
752 {
753   if ( !myMainWindow->hasFocus() )
754     return false;
755   if ( accelAction == SUIT_Accel::ZoomFit )
756     onFitAll();
757   else {
758     int anEvent = convertAction( accelAction );
759     myMainWindow->InvokeEvent( anEvent, 0 );
760   }
761   return true;
762 }
763
764 // old visual parameters had 13 values.  New format added additional 
765 // 76 values for graduated axes, so both numbers are processed.
766 const int nNormalParams = 13;   // number of view windows parameters excluding graduated axes params
767 const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z)
768 const int nAllParams = nNormalParams + 3*nGradAxisParams + 1; // number of all visual parameters
769
770 /*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes)
771  */
772 QString getGradAxisVisualParams( vtkAxisActor2D* actor )
773 {
774   QString params;
775   if ( !actor )
776     return params;
777
778   // Name
779   bool isVisible = actor->GetTitleVisibility();
780   QString title ( actor->GetTitle() );
781   vtkFloatingPointType color[ 3 ];
782   int font = VTK_ARIAL;
783   int bold = 0;
784   int italic = 0;
785   int shadow = 0;
786
787   vtkTextProperty* txtProp = actor->GetTitleTextProperty();
788   if ( txtProp )
789   {
790     txtProp->GetColor( color );
791     font = txtProp->GetFontFamily();
792     bold = txtProp->GetBold();
793     italic = txtProp->GetItalic();
794     shadow = txtProp->GetShadow();
795   }
796   params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, 
797                   title.latin1(), color[0], color[1], color[2], font, bold, italic, shadow );
798
799   // Labels
800   isVisible = actor->GetLabelVisibility();
801   int labels = actor->GetNumberOfLabels();
802   int offset = actor->GetTickOffset();
803   font = VTK_ARIAL;
804   bold = false;
805   italic = false;
806   shadow = false;
807
808   txtProp = actor->GetLabelTextProperty();
809   if ( txtProp )
810   {
811     txtProp->GetColor( color );
812     font = txtProp->GetFontFamily();
813     bold = txtProp->GetBold();
814     italic = txtProp->GetItalic();
815     shadow = txtProp->GetShadow();
816   }
817   params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset,  
818                                color[0], color[1], color[2], font, bold, italic, shadow );
819
820   // Tick marks
821   isVisible = actor->GetTickVisibility();
822   int length = actor->GetTickLength();
823   
824   params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length );
825   
826   return params;
827 }
828
829 /*! The method restores visual parameters of a graduated axis actor (x,y,z axis)
830  */
831 void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params )
832 {
833   if ( !actor )
834     return;
835
836   QStringList paramsLst = QStringList::split( '*', params, true );
837
838   if ( paramsLst.size() == nGradAxisParams ) { // altogether name, lable, ticks parameters make up 25 values
839
840     // retrieve and set name parameters
841     bool isVisible = paramsLst[2].toUShort();
842     QString title = paramsLst[3];
843     vtkFloatingPointType color[3];
844     color[0] = paramsLst[4].toDouble();
845     color[1] = paramsLst[5].toDouble();
846     color[2] = paramsLst[6].toDouble();
847     int font = paramsLst[7].toInt();
848     int bold = paramsLst[8].toInt();
849     int italic = paramsLst[9].toInt();
850     int shadow = paramsLst[10].toInt();
851
852     actor->SetTitleVisibility( isVisible );
853     actor->SetTitle( title.latin1() );
854     vtkTextProperty* txtProp = actor->GetTitleTextProperty();
855     if ( txtProp ) {
856       txtProp->SetColor( color );
857       txtProp->SetFontFamily( font );
858       txtProp->SetBold( bold );
859       txtProp->SetItalic( italic );
860       txtProp->SetShadow( shadow );
861     }
862
863     // retrieve and set lable parameters
864     isVisible = paramsLst[12].toUShort();
865     int labels = paramsLst[13].toInt();
866     int offset = paramsLst[14].toInt();
867     color[0] = paramsLst[15].toDouble();
868     color[1] = paramsLst[16].toDouble();
869     color[2] = paramsLst[17].toDouble();
870     font = paramsLst[18].toInt();
871     bold = paramsLst[19].toInt();
872     italic = paramsLst[20].toInt();
873     shadow = paramsLst[21].toInt();
874
875     actor->SetLabelVisibility( isVisible );
876     actor->SetNumberOfLabels( labels );
877     actor->SetTickOffset( offset );
878     txtProp = actor->GetLabelTextProperty();
879     if ( txtProp ) {
880       txtProp->SetColor( color );
881       txtProp->SetFontFamily( font );
882       txtProp->SetBold( bold );
883       txtProp->SetItalic( italic );
884       txtProp->SetShadow( shadow );
885     }
886
887     // retrieve and set tick marks properties
888     isVisible = paramsLst[23].toUShort();
889     int length = paramsLst[24].toInt();
890
891     actor->SetTickVisibility( isVisible );
892     actor->SetTickLength( length );
893   }
894 }
895
896 /*! The method returns the visual parameters of this view as a formated string
897  */
898 QString
899 SVTK_ViewWindow
900 ::getVisualParameters()
901 {
902   double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
903   
904   // save position, focal point, viewUp, scale
905   vtkCamera* camera = getRenderer()->GetActiveCamera();
906   camera->GetPosition( pos );
907   camera->GetFocalPoint( focalPnt );
908   camera->GetViewUp( viewUp );
909   parScale = camera->GetParallelScale();
910   GetScale( scale );
911
912   // Parameters are given in the following format:view position (3 digits), focal point position (3 digits)
913   // view up values (3 digits), parallel scale (1 digit), scale (3 digits, 
914   // Graduated axes parameters (X, Y, Z axes parameters)
915   QString retStr;
916   retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e", 
917                   pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2], 
918                   viewUp[0], viewUp[1], viewUp[2], parScale, scale[0], scale[1], scale[2] );
919
920   // save graduated axes parameters
921   if ( SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) {
922     retStr += QString( "*%1" ).arg( getMainWindow()->IsCubeAxesDisplayed() );
923     retStr += ::getGradAxisVisualParams( gradAxesActor->GetXAxisActor2D() );
924     retStr += ::getGradAxisVisualParams( gradAxesActor->GetYAxisActor2D() );
925     retStr += ::getGradAxisVisualParams( gradAxesActor->GetZAxisActor2D() );
926   }
927
928   return retStr;
929 }
930
931 /*!
932   The method restores visual parameters of this view or postpones it untill the view is shown
933 */
934 void
935 SVTK_ViewWindow
936 ::setVisualParameters( const QString& parameters )
937 {
938   SVTK_RenderWindowInteractor* anInteractor = getMainWindow()->GetInteractor();
939   if ( anInteractor->isVisible() ) {
940     doSetVisualParameters( parameters ); 
941   }
942   else {
943     myVisualParams = parameters;
944     anInteractor->installEventFilter(this);
945   }
946 }
947
948 /*!
949   The method restores visual parameters of this view from a formated string
950 */
951 void
952 SVTK_ViewWindow
953 ::doSetVisualParameters( const QString& parameters )
954 {
955   QStringList paramsLst = QStringList::split( '*', parameters, true );
956   if ( paramsLst.size() >= nNormalParams ) {
957     // 'reading' list of parameters
958     double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
959     pos[0] = paramsLst[0].toDouble();
960     pos[1] = paramsLst[1].toDouble();
961     pos[2] = paramsLst[2].toDouble();
962     focalPnt[0] = paramsLst[3].toDouble();
963     focalPnt[1] = paramsLst[4].toDouble();
964     focalPnt[2] = paramsLst[5].toDouble();
965     viewUp[0] = paramsLst[6].toDouble();
966     viewUp[1] = paramsLst[7].toDouble();
967     viewUp[2] = paramsLst[8].toDouble();
968     parScale = paramsLst[9].toDouble();
969     scale[0] = paramsLst[10].toDouble();
970     scale[1] = paramsLst[11].toDouble();
971     scale[2] = paramsLst[12].toDouble();
972     
973     // applying parameters
974     vtkCamera* camera = getRenderer()->GetActiveCamera();
975     camera->SetPosition( pos );
976     camera->SetFocalPoint( focalPnt );
977     camera->SetViewUp( viewUp );
978     camera->SetParallelScale( parScale );
979     SetScale( scale );
980
981     // apply graduated axes parameters
982     SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
983     if ( gradAxesActor && paramsLst.size() == nAllParams ) {
984       
985       int i = nNormalParams+1, j = i + nGradAxisParams - 1;
986       ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) ); 
987       i = j + 1; j += nGradAxisParams;
988       ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) ); 
989       i = j + 1; j += nGradAxisParams;
990       ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) ); 
991
992       if ( paramsLst[13].toUShort() )
993         gradAxesActor->VisibilityOn();
994       else
995         gradAxesActor->VisibilityOff();
996     }
997   }
998 }
999
1000
1001 /*!
1002   Delayed setVisualParameters
1003 */
1004 bool SVTK_ViewWindow::eventFilter( QObject* theWatched, QEvent* theEvent )
1005 {
1006   if ( theEvent->type() == QEvent::Show && theWatched->inherits( "SVTK_RenderWindowInteractor" ) ) {
1007     SVTK_RenderWindowInteractor* anInteractor = (SVTK_RenderWindowInteractor*)theWatched;
1008     if ( anInteractor->isVisible() ) {
1009       doSetVisualParameters( myVisualParams );
1010       anInteractor->removeEventFilter( this ); // theWatched = RenderWindowInteractor
1011     }
1012   }
1013   return SUIT_ViewWindow::eventFilter( theWatched, theEvent );
1014 }