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