Salome HOME
NRI : KERNEL is now defined in KERNELCatalog.
[modules/kernel.git] / src / OCCViewer / OCCViewer_ViewPort3d.h
1 //  File      : OCCViewer_ViewPort3d.h
2 //  Created   : Wed Mar 20 10:48:51 2002
3 //  Author    : Nicolas REJNERI
4 //  Project   : SALOME
5 //  Module    : OCCViewer
6 //  Copyright : Open CASCADE 2002
7 //  $Header$
8
9 #ifndef OCCViewer_ViewPort3d_H
10 #define OCCViewer_ViewPort3d_H
11
12 #include "OCCViewer_ViewPort.h"
13 #include "OCCViewer_VService.h"
14
15 #include "QAD.h"
16
17 // Open CASCADE Includes
18 #include <Standard.hxx>
19 #include <V3d_View.hxx>
20 #include <V3d_Viewer.hxx>
21
22 // QT Includes
23 #include <qwidget.h>
24 #include <qrect.h>
25 #include <qcolor.h>
26 #include <qpainter.h>
27 #include <qapplication.h>
28
29 class QAD_EXPORT OCCViewer_ViewPort3d: public OCCViewer_ViewPort
30 {
31   Q_OBJECT
32         
33  public:        
34   OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_Viewer)& viewer,
35                         V3d_TypeOfView  viewType = V3d_ORTHOGRAPHIC, 
36                         OCCViewer_ViewPort* prevView = 0, 
37                         const QRect* magnify = 0 );
38   ~OCCViewer_ViewPort3d();
39   
40   /* view 3D management */
41   Handle (V3d_View)       setView( const Handle( V3d_View )& );
42   Handle (V3d_View)       getView() const;
43   Handle (V3d_Viewer)     getViewer() const;
44   V3d_TypeOfView          setViewType( V3d_TypeOfView type );
45
46   /* popup management */
47   void                    onCreatePopup();
48   
49   /* view transformations */
50   void                    activateGlobalPanning();
51   void                    fitAll( bool withZ = true );
52   void                    reset();
53
54   /* background */
55   void                    setBackgroundColor( const QColor& color);     
56   QColor                  backgroundColor() const;
57
58   protected slots:
59     void                  onChangeBackgroundColor();
60
61  protected:     
62   void                    paintEvent(QPaintEvent *ev);    
63
64  private:
65   bool                  setWindow(); 
66   void                  windowResize();
67   void                  pan(int dx, int dy);
68   void                  setCenter(int x, int y);
69   void                  fitWindow( const QRect& rect);
70   void                  zoom(int x0, int y0, int x, int y);
71   void                  startRotation(int x0, int y0);
72   void                  rotate(int x, int y);
73   void                  endRotation();
74
75  private:       
76   Handle (V3d_View)             myActiveView;    
77   bool                          myDegenerated;
78   double                                myCurScale;
79 };
80
81 #endif
82