Salome HOME
DCQ : Merge with Ecole_ete_a6.
[modules/kernel.git] / src / OCCViewer / OCCViewer_ViewPort3d.h
1 //  SALOME OCCViewer : build OCC Viewer into Salome desktop
2 //
3 //  Copyright (C) 2003  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. 
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : OCCViewer_ViewPort3d.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef OCCViewer_ViewPort3d_H
30 #define OCCViewer_ViewPort3d_H
31
32 #include "OCCViewer_ViewPort.h"
33 #include "OCCViewer_VService.h"
34
35 #include "QAD.h"
36
37 // Open CASCADE Includes
38 #include <Standard.hxx>
39 #include <V3d_View.hxx>
40 #include <V3d_Viewer.hxx>
41
42 // QT Includes
43 #include <qwidget.h>
44 #include <qrect.h>
45 #include <qcolor.h>
46 #include <qpainter.h>
47 #include <qapplication.h>
48
49 class QAD_EXPORT OCCViewer_ViewPort3d: public OCCViewer_ViewPort
50 {
51   Q_OBJECT
52         
53  public:        
54   OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_Viewer)& viewer,
55                         V3d_TypeOfView  viewType = V3d_ORTHOGRAPHIC, 
56                         OCCViewer_ViewPort* prevView = 0, 
57                         const QRect* magnify = 0 );
58   ~OCCViewer_ViewPort3d();
59   
60   /* view 3D management */
61   Handle (V3d_View)       setView( const Handle( V3d_View )& );
62   Handle (V3d_View)       getView() const;
63   Handle (V3d_Viewer)     getViewer() const;
64   V3d_TypeOfView          setViewType( V3d_TypeOfView type );
65
66   /* popup management */
67   void                    onCreatePopup();
68   
69   /* view transformations */
70   void                    activateGlobalPanning();
71   void                    fitAll( bool withZ = true );
72   void                    reset();
73
74   /* background */
75   void                    setBackgroundColor( const QColor& color);     
76   QColor                  backgroundColor() const;
77
78   protected slots:
79     void                  onChangeBackgroundColor();
80
81  protected:     
82   void                    paintEvent(QPaintEvent *ev);    
83
84  private:
85   bool                  setWindow(); 
86   void                  windowResize();
87   void                  pan(int dx, int dy);
88   void                  setCenter(int x, int y);
89   void                  fitWindow( const QRect& rect);
90   void                  zoom(int x0, int y0, int x, int y);
91   void                  startRotation(int x0, int y0);
92   void                  rotate(int x, int y);
93   void                  endRotation();
94
95  private:       
96   Handle (V3d_View)             myActiveView;    
97   bool                          myDegenerated;
98   double                                myCurScale;
99 };
100
101 #endif
102