Salome HOME
Merge modifications for HYDRO project (origin/hydro/imps_2017_salome_83 branch)
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewPort3d.cxx
1 // Copyright (C) 2007-2016  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 #include "OCCViewer_ViewPort3d.h"
24
25 #include "OCCViewer_VService.h"
26 #include "OCCViewer_ViewWindow.h"
27 #include "OCCViewer_ViewModel.h"
28
29 #include <SUIT_ViewManager.h>
30 #include <SUIT_ViewModel.h>
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
33
34 #include <QColor>
35 #include <QFileInfo>
36 #include <QString>
37 #include <QRect>
38 #include <QPaintEvent>
39 #include <QResizeEvent>
40 #include <QApplication>
41 #include <QTimer>
42
43 #include <V3d_View.hxx>
44 #include <Quantity_Ratio.hxx>
45
46 #include "utilities.h"
47
48 #if defined WIN32
49 #include <WNT_Window.hxx>
50 #else
51 //#include <Xw_Window.hxx>
52 #endif
53
54 static double rx = 0.;
55 static double ry = 0.;
56 static int sx = 0;
57 static int sy = 0;
58 static Standard_Boolean zRotation = Standard_False;
59
60 //#include <Standard_Version.hxx>
61
62 /*!
63   Constructor
64 */
65 OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_Viewer)& viewer, V3d_TypeOfView  type )
66   : OCCViewer_ViewPort( parent ),
67     myScale( 1.0 ),
68     myBusy( true ),
69     myIsAdvancedZoomingEnabled( false )
70 {
71   // VSR: 01/07/2010 commented to avoid SIGSEGV at SALOME exit
72   //selectVisualId();
73
74   myActiveView = new V3d_View( viewer, type );
75
76   setDefaultParams();
77
78   myCursor = NULL;
79 }
80
81 /*!
82   Destructor
83 */
84 OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d()
85 {
86   if ( myCursor )
87   {
88     delete myCursor;
89     myCursor = NULL;
90   }
91
92   emit vpClosed(this);
93   Handle(V3d_View) aView = activeView();
94   if (!aView.IsNull())
95     aView->Remove();
96 }
97
98 /*!
99   Activates the desired 'type' of view in the viewer
100   ( view of 'type' is created if it doesn't exist ). [ public ]
101 */
102 /*void OCCViewer_ViewPort3d::setActive( V3d_TypeOfView type )
103 {
104   if ( activeView().IsNull() )
105   return;
106
107   if ( activeView()->Type() != type )
108   {
109   if ( type == V3d_ORTHOGRAPHIC )
110   setView( myOrthoView );
111   if ( type == V3d_PERSPECTIVE )
112   setView( myPerspView );
113   }
114 }*/
115
116 /*!
117   Maps CasCade 'view' to this viewport. [ private ]
118 */
119 bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view )
120 {
121   if ( !setWindow( view ) )
122     return false;
123
124   if ( !mapped( view ) ) {
125     view->SetWindow( myWindow );
126     if ( view != activeView() )
127       view->View()->Deactivate();
128   }
129
130   emit( vpMapped(this) );
131
132   return true;
133 }
134
135
136
137 /*!
138   Sets new CASCADE view on viewport. Returns the previous active view. [ public ]
139 */
140 Handle( V3d_View ) OCCViewer_ViewPort3d::setView( const Handle( V3d_View )& view )
141 {
142   /* map the new view */
143   if ( view == activeView() || !mapView( view ) )
144     return activeView();
145
146   /* activate the new view*/
147   Handle( V3d_View ) oldView = activeView();
148   if ( !oldView.IsNull() ) {
149     if (oldView->View()->IsDefined())
150       oldView->View()->Deactivate();
151     view->SetBackgroundColor( oldView->BackgroundColor() );
152   }
153
154   view->View()->Activate();
155   activeView() = view;
156   return oldView;
157 }
158
159 /*!
160   Returns CasCade 3D view. [ public ]
161 */
162 Handle(V3d_View) OCCViewer_ViewPort3d::getView() const
163 {
164   return activeView();
165 }
166
167 /*!
168   Returns CasCade 3D viewer [ public ]
169 */
170 Handle(V3d_Viewer) OCCViewer_ViewPort3d::getViewer() const
171 {
172   Handle(V3d_Viewer) viewer;
173   if ( !activeView().IsNull() )
174     viewer = activeView()->Viewer();
175   return viewer;
176 }
177
178 /*!
179   Syncronizes visual state of this viewport with 'ref'
180   ( scale, projection, eye etc ) Returns 'true' if copied OK,
181   'false' otherwise. [ virtual public ]
182 */
183 bool OCCViewer_ViewPort3d::syncronize( const OCCViewer_ViewPort3d* ref )
184 {
185   OCCViewer_ViewPort3d* ref3d = (OCCViewer_ViewPort3d*)ref;
186   Handle(V3d_View) refView = ref3d->getView();
187   Handle(V3d_View) tgtView = getView();
188
189   /* Syncronize view types */
190   /*    if ( tgtView->Type() != refView->Type() )
191         {
192         setActive( refView->Type() );
193         tgtView = getView();
194         }*/
195
196   /*  The following params are copied:
197       - view type( ortho/persp )
198       - position of view point
199       - orientation of high point
200       - position of the eye
201       - projection vector
202       - view center ( 2D )
203       - view twist
204       - view scale
205   */
206
207   /* we'll update after setting all params */
208   tgtView->SetImmediateUpdate( Standard_False );
209
210   /* perspective */
211   if ( refView->Type() == V3d_PERSPECTIVE )
212     tgtView->SetFocale( refView->Focale() );
213
214   /* copy params */
215   Standard_Real x, y, z;
216   refView->At( x, y, z ); tgtView->SetAt( x, y, z );
217   refView->Up( x, y, z ); tgtView->SetUp( x, y, z );
218   refView->Eye( x, y, z ); tgtView->SetEye( x, y, z );
219   refView->Proj( x, y, z ); tgtView->SetProj( x, y, z );
220   tgtView->SetScale( refView->Scale() );
221   tgtView->SetTwist( refView->Twist() );
222
223   /* update */
224   tgtView->Update();
225   tgtView->SetImmediateUpdate( Standard_True );
226
227   return true;
228 }
229
230
231 /*!
232   Get axial scale to the view
233 */
234 void OCCViewer_ViewPort3d::getAxialScale( double& xScale, double& yScale, double& zScale )
235 {
236   xScale = yScale = zScale = 1.;
237
238   if ( !activeView().IsNull() )
239     activeView()->AxialScale( xScale, yScale, zScale );
240 }
241
242 /*!
243   Returns the background color [ virtual public ] [ obsolete ]
244 */
245 QColor OCCViewer_ViewPort3d::backgroundColor() const
246 {
247   return background().color();
248 }
249
250 /*!
251   Sets the background color [ virtual public ] [ obsolete ]
252 */
253 void OCCViewer_ViewPort3d::setBackgroundColor( const QColor& color )
254 {
255   Qtx::BackgroundData bg = background();
256   bg.setColor( color );
257   setBackground( bg );
258 }
259
260 /*!
261   Returns the background data
262 */
263 Qtx::BackgroundData OCCViewer_ViewPort3d::background() const
264 {
265   return myBackground;
266 }
267
268 /*!
269   Sets the background data
270 */
271 void OCCViewer_ViewPort3d::setBackground( const Qtx::BackgroundData& bgData )
272 {
273   if ( bgData.isValid() ) {
274     myBackground = bgData;
275     updateBackground();
276     emit vpChangeBackground( myBackground );
277   }
278 }
279
280 void OCCViewer_ViewPort3d::updateBackground()
281 {
282   if ( activeView().IsNull() ) return;
283   if ( !myBackground.isValid() ) return;
284
285   switch ( myBackground.mode() ) {
286   case Qtx::ColorBackground:
287     {
288       QColor c = myBackground.color();
289       if ( c.isValid() ) {
290         // Unset texture should be done here
291         // ...
292         Quantity_Color qCol( c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB );
293         activeView()->SetBgGradientStyle( Aspect_GFM_NONE ); // cancel gradient background
294         activeView()->SetBgImageStyle( Aspect_FM_NONE );     // cancel texture background
295         // then change background color
296         activeView()->SetBackgroundColor( qCol );
297         // update viewer
298         activeView()->Update();
299       }
300       break;
301     }
302   case Qtx::SimpleGradientBackground:
303     {
304       QColor c1, c2;
305       int type = myBackground.gradient( c1, c2 );
306       if ( c1.isValid() && type >= OCCViewer_Viewer::HorizontalGradient && type <= OCCViewer_Viewer::LastGradient ) {
307         // Unset texture should be done here
308         // ...
309         // Get colors and set-up gradiented background
310         if ( !c2.isValid() ) c2 = c1;
311         Quantity_Color qCol1( c1.red()/255., c1.green()/255., c1.blue()/255., Quantity_TOC_RGB );
312         Quantity_Color qCol2( c2.red()/255., c2.green()/255., c2.blue()/255., Quantity_TOC_RGB );
313         activeView()->SetBgImageStyle( Aspect_FM_NONE );    // cancel texture background
314         switch ( type ) {
315         case OCCViewer_Viewer::HorizontalGradient:
316           activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_HOR, Standard_True );
317           break;
318         case OCCViewer_Viewer::VerticalGradient:
319           activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_VER, Standard_True );
320           break;
321         case OCCViewer_Viewer::Diagonal1Gradient:
322           activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_DIAG1, Standard_True );
323           break;
324         case OCCViewer_Viewer::Diagonal2Gradient:
325           activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_DIAG2, Standard_True );
326           break;
327         case OCCViewer_Viewer::Corner1Gradient:
328           activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_CORNER1, Standard_True );
329           break;
330         case OCCViewer_Viewer::Corner2Gradient:
331           activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_CORNER2, Standard_True );
332           break;
333         case OCCViewer_Viewer::Corner3Gradient:
334           activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_CORNER3, Standard_True );
335           break;
336         case OCCViewer_Viewer::Corner4Gradient:
337           activeView()->SetBgGradientColors( qCol1, qCol2, Aspect_GFM_CORNER4, Standard_True );
338           break;
339         default:
340           break;
341         }
342       }
343       break;
344     }
345   case Qtx::CustomGradientBackground:
346     {
347       // NOT IMPLEMENTED YET
348       break;
349     }
350   default:
351     break;
352   }
353   if ( myBackground.isTextureShown() ) {
354     QString fileName;
355     int textureMode = myBackground.texture( fileName );
356     QFileInfo fi( fileName );
357     if ( !fileName.isEmpty() && fi.exists() ) {
358       // set texture image: file name and fill mode
359       switch ( textureMode ) {
360       case Qtx::CenterTexture:
361         activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_CENTERED );
362         break;
363       case Qtx::TileTexture:
364         activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_TILED );
365         break;
366       case Qtx::StretchTexture:
367         activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_STRETCH );
368         break;
369       default:
370         break;
371       }
372       activeView()->Update();
373     }
374   }
375 }
376
377 /*!
378   Updates the active viewport. [ virtual public ]
379 */
380 void OCCViewer_ViewPort3d::onUpdate()
381 {
382   if ( !activeView().IsNull() )
383     activeView()->Update();
384 }
385
386 /*!
387   Called at 'window fit' transformation. [ virtual protected ]
388 */
389 void OCCViewer_ViewPort3d::fitRect( const QRect& rect )
390 {
391   if ( !activeView().IsNull() ) {
392     activeView()->WindowFit( rect.left(), rect.top(), rect.right(), rect.bottom() );
393     emit vpTransformed( this );
394   }
395 }
396
397 /*!
398   Inits 'zoom' transformation. [ protected ]
399 */
400 void OCCViewer_ViewPort3d::startZoomAtPoint( int x, int y )
401 {
402   if ( !activeView().IsNull() && isAdvancedZoomingEnabled() )
403     activeView()->StartZoomAtPoint( x, y );
404 }
405
406 /*!
407   Called at 'zoom' transformation. [ virtual protected ]
408 */
409 void OCCViewer_ViewPort3d::zoom( int x0, int y0, int x, int y )
410 {
411   if ( !activeView().IsNull() ) {
412     // as OCCT respects a sign of only dx,
413     // but we want both signes to be taken into account
414     //activeView()->Zoom( x0, y0, x, y );
415     if ( isAdvancedZoomingEnabled() )
416       activeView()->ZoomAtPoint( x0, y0, x, y );
417     else
418       activeView()->Zoom( x0 + y0, 0, x + y, 0 );
419     emit vpTransformed( this );
420   }
421 }
422
423 /*!
424   Centers the viewport. [ virtual protected ]
425 */
426 void OCCViewer_ViewPort3d::setCenter( int x, int y )
427 {
428   if ( !activeView().IsNull() ) {
429     activeView()->Place( x, y, myScale );
430     emit vpTransformed( this );
431   }
432 }
433
434 /*!
435   Called at 'pan' transformation. [ virtual protected ]
436 */
437 void OCCViewer_ViewPort3d::pan( int dx, int dy )
438 {
439   if ( !activeView().IsNull() ) {
440     activeView()->Pan( dx, dy, 1.0 );
441     emit vpTransformed( this );
442   }
443 }
444
445 /*!
446   Inits 'rotation' transformation. [ protected ]
447 */
448 void OCCViewer_ViewPort3d::startRotation( int x, int y,
449                                           int theRotationPointType,
450                                           const gp_Pnt& theSelectedPoint )
451 {
452   if ( !activeView().IsNull() ) {
453     //double gx, gy, gz;
454     //double gx = activeView()->gx;
455     //activeView()->Gravity(gx,gy,gz);
456
457     switch ( theRotationPointType ) {
458     case OCCViewer_ViewWindow::BBCENTER:
459       activeView()->StartRotation( x, y, 0.45 );
460       break;
461     case OCCViewer_ViewWindow::SELECTED:
462       sx = x; sy = y;
463
464       double X,Y;
465       activeView()->Size(X,Y);
466       rx = Standard_Real(activeView()->Convert(X));
467       ry = Standard_Real(activeView()->Convert(Y));
468
469       activeView()->Rotate( 0., 0., 0.,
470                             theSelectedPoint.X(),theSelectedPoint.Y(), theSelectedPoint.Z(),
471                             Standard_True );
472
473       Quantity_Ratio zRotationThreshold;
474       zRotation = Standard_False;
475       zRotationThreshold = 0.45;
476       if( zRotationThreshold > 0. ) {
477         Standard_Real dx = Abs(sx - rx/2.);
478         Standard_Real dy = Abs(sy - ry/2.);
479         Standard_Real dd = zRotationThreshold * (rx + ry)/2.;
480         if( dx > dd || dy > dd ) zRotation = Standard_True;
481       }
482       break;
483     default:
484       break;
485     }
486     // VSR: 10.06.2015: next line commented out - causes ugly blinking on starting rotation with Perspective projection mode
487     //activeView()->DepthFitAll();
488   }
489 }
490
491 /*!
492   Rotates the viewport. [ protected ]
493 */
494 void OCCViewer_ViewPort3d::rotate( int x, int y,
495                                    int theRotationPointType,
496                                    const gp_Pnt& theSelectedPoint )
497 {
498   if ( !activeView().IsNull() ) {
499     switch ( theRotationPointType ) {
500     case OCCViewer_ViewWindow::BBCENTER:
501       activeView()->Rotation( x, y );
502       break;
503     case OCCViewer_ViewWindow::SELECTED:
504       double dx, dy, dz;
505       if( zRotation ) {
506         dz = atan2(Standard_Real(x)-rx/2., ry/2.-Standard_Real(y)) -
507           atan2(sx-rx/2.,ry/2.-sy);
508         dx = dy = 0.;
509       }
510       else {
511         dx = (Standard_Real(x) - sx) * M_PI/rx;
512         dy = (sy - Standard_Real(y)) * M_PI/ry;
513         dz = 0.;
514       }
515
516       activeView()->Rotate( dx, dy, dz,
517                             theSelectedPoint.X(),theSelectedPoint.Y(), theSelectedPoint.Z(),
518                             Standard_False );
519       break;
520     default:
521       break;
522     }
523     emit vpTransformed( this );
524   }
525   //  setZSize( getZSize() );
526 }
527
528 /*!
529   Resets the viewport after 'rotation'. [ protected ]
530 */
531 void OCCViewer_ViewPort3d::endRotation()
532 {
533   if ( !activeView().IsNull() ) {
534     activeView()->Update();
535     emit vpTransformed( this );
536   }
537 }
538
539 /*!
540   Repaints the viewport. [ virtual protected ]
541 */
542 void OCCViewer_ViewPort3d::paintEvent( QPaintEvent* e )
543 {
544 #ifndef WIN32
545   /* X11 : map before show doesn't work */
546   if ( !mapped( activeView() ) )
547     mapView( activeView() );
548 #endif
549   if ( !myWindow.IsNull() ) {
550 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
551     QApplication::syncX();
552 #endif
553     if ( !myPaintersRedrawing ) {
554       activeView()->Redraw();
555     }
556   }
557   OCCViewer_ViewPort::paintEvent( e );
558   myBusy = false;
559 }
560
561 /*!
562   Resizes the viewport. [ virtual protected ]
563 */
564 void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e )
565 {
566 #if defined WIN32 || QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
567   /* Win32 : map before first show to avoid flicker */
568   if ( !mapped( activeView() ) )
569     mapView( activeView() );
570 #endif
571 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
572     QApplication::syncX();
573 #endif
574   QTimer::singleShot( 0, this, SLOT( repaintViewAfterMove() ) );
575   emit vpResizeEvent( e );
576 }
577
578 /*!
579   Moved the viewport
580 */
581 void OCCViewer_ViewPort3d::repaintViewAfterMove( )
582 {
583   if ( !activeView().IsNull() ){
584     activeView()->MustBeResized();
585   }
586 }
587
588 /*!
589   Fits all objects in view. [ virtual protected ]
590 */
591 void OCCViewer_ViewPort3d::fitAll( bool keepScale, bool withZ, bool upd )
592 {
593   if ( activeView().IsNull() )
594     return;
595
596   if ( keepScale )
597     myScale = activeView()->Scale();
598
599   Standard_Real margin = 0.01;
600   
601   activeView()->FitAll( margin, upd );
602
603   emit vpTransformed( this );
604 }
605
606 /*!
607   Resets the view. [ virtual protected ]
608 */
609 void OCCViewer_ViewPort3d::reset()
610 {
611   //  double zsize = getZSize();
612   if ( !activeView().IsNull() ) {
613     activeView()->Reset();
614     emit vpTransformed( this );
615   //    setZSize( zsize );
616   }
617 }
618
619 /*!
620   Rotate the view in the view plane (orthogonal to the view vector)
621 */
622 void OCCViewer_ViewPort3d::rotateXY( double degrees )
623 {
624   if ( activeView().IsNull() )
625     return;
626
627   int x = width()/2, y = height()/2;
628   double X, Y, Z;
629   activeView()->Convert( x, y, X, Y, Z );
630   activeView()->Rotate( 0, 0, degrees * M_PI / 180., X, Y, Z );
631   emit vpTransformed( this );
632 }
633
634 /*!
635   Set axial scale to the view
636 */
637 void OCCViewer_ViewPort3d::setAxialScale( double xScale, double yScale, double zScale )
638 {
639   if ( activeView().IsNull() )
640     return;
641
642   activeView()->SetAxialScale( xScale, yScale, zScale );
643   emit vpTransformed( this );
644 }
645
646 /*!
647   Passed the handle of native window of the component to CASCADE view. [ private ]
648 */
649 bool OCCViewer_ViewPort3d::setWindow( const Handle(V3d_View)& view )
650 {
651   if ( !myWindow.IsNull() )
652     return true;
653
654   if ( view.IsNull() )
655     return false;
656
657   attachWindow( view, OCCViewer_VService::CreateWindow( view, winId() ) );
658
659   myWindow = view->Window();
660   return !myWindow.IsNull();
661 }
662
663 void OCCViewer_ViewPort3d::attachWindow( const Handle(V3d_View)& view,
664                                          const Handle(Aspect_Window)& window)
665 {
666   if (!view.IsNull()) {
667     view->SetWindow( window );
668     updateBackground();
669   }
670 }
671
672 /*!
673   Returns the current active view. [ private ]
674 */
675 Handle(V3d_View) OCCViewer_ViewPort3d::activeView() const
676 {
677   return myActiveView;
678 }
679
680 /*!
681   Returns the current inactive view [ private ]
682 */
683 /*Handle(V3d_View) OCCViewer_ViewPort3d::inactiveView() const
684   {
685   return ( activeView() == myOrthoView ? myPerspView : myOrthoView );
686   }*/
687
688 /*!
689   Returns 'true' if the given view is mapped to window. [ private ]
690 */
691 bool OCCViewer_ViewPort3d::mapped( const Handle(V3d_View)& view ) const
692 {
693   return ( !view.IsNull() && view->View()->IsDefined() );
694 }
695
696 /*!
697   Performs synchronization of view parameters with the specified view.
698   Returns \c true if synchronization is done successfully or \c false otherwise.
699   Default implementation does nothing (return \c false)
700 */
701 bool OCCViewer_ViewPort3d::synchronize( OCCViewer_ViewPort* view )
702 {
703   bool ok = false;
704   OCCViewer_ViewPort3d* vp3d = qobject_cast<OCCViewer_ViewPort3d*>( view );
705   if ( vp3d ) {
706     bool blocked = blockSignals( false );
707     Handle(V3d_View) aView3d = getView();
708     Handle(V3d_View) aRefView3d = vp3d->getView();
709     aView3d->SetImmediateUpdate( Standard_False );
710     aView3d->Camera()->Copy( aRefView3d->Camera() );
711     aView3d->SetImmediateUpdate( Standard_True );
712     aView3d->Update();
713     blockSignals( blocked );
714     ok = true;
715   }
716   return ok;
717 }
718
719 /*
720  * Show/Hide static triedron
721  */
722 void OCCViewer_ViewPort3d::showStaticTrihedron( bool on )
723 {
724   Handle(V3d_View) aView = activeView();
725   if ( !aView ) return;
726   
727   if ( on ) {
728     aView->ZBufferTriedronSetup();
729     aView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
730   } else {
731     aView->TriedronErase();
732   }
733   aView->Update();
734 }
735
736 /*
737  * Create default cursor with a specific shape
738  */
739 void OCCViewer_ViewPort3d::setDefaultCursor( Qt::CursorShape theCursorShape )
740 {
741   if ( !myCursor )
742     myCursor = new QCursor();
743
744   myCursor->setShape( theCursorShape );
745 }
746
747 /*
748  * Get default cursor with a specific shape
749  */
750 QCursor* OCCViewer_ViewPort3d::getDefaultCursor() const
751 {
752   return myCursor;
753 }
754
755 /*
756  * Set default parameters from preferences
757  */
758 void OCCViewer_ViewPort3d::setDefaultParams()
759 {
760   setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
761
762   // get ray tracing parameters from preferences
763   int aDepth = SUIT_Session::session()->resourceMgr()->integerValue( "OCCViewer", "rt_depth", 3 );
764   bool aReflection = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_reflection", true );
765   bool anAntialiasing = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_antialiasing", false );
766   bool aShadow = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_shadow", true );
767   bool aTransparentShadow = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_trans_shadow", true );
768
769   Graphic3d_RenderingParams& aParams = myActiveView->ChangeRenderingParams();
770   aParams.RaytracingDepth = aDepth;
771   aParams.IsReflectionEnabled = aReflection;
772   aParams.IsAntialiasingEnabled = anAntialiasing;
773   aParams.IsShadowEnabled = aShadow;
774   aParams.IsTransparentShadowEnabled = aTransparentShadow;
775   myActiveView->Redraw();
776 }