Salome HOME
Unicode support: correct handling of unicode on GUI level
[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().toUtf8().constData(), Aspect_FM_CENTERED );
362         break;
363       case Qtx::TileTexture:
364         activeView()->SetBackgroundImage( fi.absoluteFilePath().toUtf8().constData(), Aspect_FM_TILED );
365         break;
366       case Qtx::StretchTexture:
367         activeView()->SetBackgroundImage( fi.absoluteFilePath().toUtf8().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 }
576
577 /*!
578   Moved the viewport
579 */
580 void OCCViewer_ViewPort3d::repaintViewAfterMove( )
581 {
582   if ( !activeView().IsNull() ){
583     activeView()->MustBeResized();
584   }
585 }
586
587 /*!
588   Fits all objects in view. [ virtual protected ]
589 */
590 void OCCViewer_ViewPort3d::fitAll( bool keepScale, bool withZ, bool upd )
591 {
592   if ( activeView().IsNull() )
593     return;
594
595   if ( keepScale )
596     myScale = activeView()->Scale();
597
598   Standard_Real margin = 0.01;
599   
600   activeView()->FitAll( margin, upd );
601
602   emit vpTransformed( this );
603 }
604
605 /*!
606   Resets the view. [ virtual protected ]
607 */
608 void OCCViewer_ViewPort3d::reset()
609 {
610   //  double zsize = getZSize();
611   if ( !activeView().IsNull() ) {
612     activeView()->Reset();
613     emit vpTransformed( this );
614   //    setZSize( zsize );
615   }
616 }
617
618 /*!
619   Rotate the view in the view plane (orthogonal to the view vector)
620 */
621 void OCCViewer_ViewPort3d::rotateXY( double degrees )
622 {
623   if ( activeView().IsNull() )
624     return;
625
626   int x = width()/2, y = height()/2;
627   double X, Y, Z;
628   activeView()->Convert( x, y, X, Y, Z );
629   activeView()->Rotate( 0, 0, degrees * M_PI / 180., X, Y, Z );
630   emit vpTransformed( this );
631 }
632
633 /*!
634   Set axial scale to the view
635 */
636 void OCCViewer_ViewPort3d::setAxialScale( double xScale, double yScale, double zScale )
637 {
638   if ( activeView().IsNull() )
639     return;
640
641   activeView()->SetAxialScale( xScale, yScale, zScale );
642   emit vpTransformed( this );
643 }
644
645 /*!
646   Passed the handle of native window of the component to CASCADE view. [ private ]
647 */
648 bool OCCViewer_ViewPort3d::setWindow( const Handle(V3d_View)& view )
649 {
650   if ( !myWindow.IsNull() )
651     return true;
652
653   if ( view.IsNull() )
654     return false;
655
656   attachWindow( view, OCCViewer_VService::CreateWindow( view, winId() ) );
657
658   myWindow = view->Window();
659   return !myWindow.IsNull();
660 }
661
662 void OCCViewer_ViewPort3d::attachWindow( const Handle(V3d_View)& view,
663                                          const Handle(Aspect_Window)& window)
664 {
665   if (!view.IsNull()) {
666     view->SetWindow( window );
667     updateBackground();
668   }
669 }
670
671 /*!
672   Returns the current active view. [ private ]
673 */
674 Handle(V3d_View) OCCViewer_ViewPort3d::activeView() const
675 {
676   return myActiveView;
677 }
678
679 /*!
680   Returns the current inactive view [ private ]
681 */
682 /*Handle(V3d_View) OCCViewer_ViewPort3d::inactiveView() const
683   {
684   return ( activeView() == myOrthoView ? myPerspView : myOrthoView );
685   }*/
686
687 /*!
688   Returns 'true' if the given view is mapped to window. [ private ]
689 */
690 bool OCCViewer_ViewPort3d::mapped( const Handle(V3d_View)& view ) const
691 {
692   return ( !view.IsNull() && view->View()->IsDefined() );
693 }
694
695 /*!
696   Performs synchronization of view parameters with the specified view.
697   Returns \c true if synchronization is done successfully or \c false otherwise.
698   Default implementation does nothing (return \c false)
699 */
700 bool OCCViewer_ViewPort3d::synchronize( OCCViewer_ViewPort* view )
701 {
702   bool ok = false;
703   OCCViewer_ViewPort3d* vp3d = qobject_cast<OCCViewer_ViewPort3d*>( view );
704   if ( vp3d ) {
705     bool blocked = blockSignals( false );
706     Handle(V3d_View) aView3d = getView();
707     Handle(V3d_View) aRefView3d = vp3d->getView();
708     aView3d->SetImmediateUpdate( Standard_False );
709     aView3d->Camera()->Copy( aRefView3d->Camera() );
710     aView3d->SetImmediateUpdate( Standard_True );
711     aView3d->Update();
712     blockSignals( blocked );
713     ok = true;
714   }
715   return ok;
716 }
717
718 /*
719  * Show/Hide static triedron
720  */
721 void OCCViewer_ViewPort3d::showStaticTrihedron( bool on )
722 {
723   Handle(V3d_View) aView = activeView();
724   if ( !aView ) return;
725   
726   if ( on ) {
727     aView->ZBufferTriedronSetup();
728     aView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
729   } else {
730     aView->TriedronErase();
731   }
732   aView->Update();
733 }
734
735 /*
736  * Create default cursor with a specific shape
737  */
738 void OCCViewer_ViewPort3d::setDefaultCursor( Qt::CursorShape theCursorShape )
739 {
740   if ( !myCursor )
741     myCursor = new QCursor();
742
743   myCursor->setShape( theCursorShape );
744 }
745
746 /*
747  * Get default cursor with a specific shape
748  */
749 QCursor* OCCViewer_ViewPort3d::getDefaultCursor() const
750 {
751   return myCursor;
752 }
753
754 /*
755  * Set default parameters from preferences
756  */
757 void OCCViewer_ViewPort3d::setDefaultParams()
758 {
759   setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
760
761   // get ray tracing parameters from preferences
762   int aDepth = SUIT_Session::session()->resourceMgr()->integerValue( "OCCViewer", "rt_depth", 3 );
763   bool aReflection = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_reflection", true );
764   bool anAntialiasing = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_antialiasing", false );
765   bool aShadow = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_shadow", true );
766   bool aTransparentShadow = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_trans_shadow", true );
767
768   Graphic3d_RenderingParams& aParams = myActiveView->ChangeRenderingParams();
769   aParams.RaytracingDepth = aDepth;
770   aParams.IsReflectionEnabled = aReflection;
771   aParams.IsAntialiasingEnabled = anAntialiasing;
772   aParams.IsShadowEnabled = aShadow;
773   aParams.IsTransparentShadowEnabled = aTransparentShadow;
774   myActiveView->Redraw();
775 }