Salome HOME
Merge from V6_main (04/10/2012)
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewPort3d.h
1 // Copyright (C) 2007-2012  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.
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 #ifndef OCCVIEWER_VIEWPORT3D_H
24 #define OCCVIEWER_VIEWPORT3D_H
25
26 #include "OCCViewer_ViewPort.h"
27 #include "Qtx.h"
28
29 #include <V3d_View.hxx>
30
31 class QColor;
32 class QString;
33 class QRect;
34
35 class Handle(V3d_Viewer);
36
37 #ifdef WIN32
38 #pragma warning ( disable:4251 )
39 #endif
40
41 class OCCVIEWER_EXPORT OCCViewer_ViewPort3d: public OCCViewer_ViewPort
42 {
43   Q_OBJECT
44
45   friend class OCCViewer_ViewTransformer;
46
47 public:
48   OCCViewer_ViewPort3d( QWidget*, const Handle(V3d_Viewer)&, V3d_TypeOfView = V3d_ORTHOGRAPHIC );
49   virtual ~OCCViewer_ViewPort3d();
50
51 public:
52   Handle(V3d_View)      getView() const;
53   Handle(V3d_View)      setView( const Handle(V3d_View)& );
54   Handle(V3d_Viewer)    getViewer() const;
55
56   void                  setAnimationMode(bool theDegenerated);
57
58   virtual void          setBackgroundColor( const QColor& color);    // obsolete
59   virtual QColor        backgroundColor() const;                     // obsolete
60   void                  setBackground( const Qtx::BackgroundData& color);
61   Qtx::BackgroundData   background() const;
62
63   virtual int           getBgImgHeight(){return myBgImgHeight; };
64   virtual int           getBgImgWidth() {return myBgImgWidth;  };
65
66   virtual void          updateStaticTriedronVisibility();
67
68 //   void         setActive( V3d_TypeOfView );
69   virtual bool          syncronize( const OCCViewer_ViewPort3d* );
70
71   double                getZSize() const;
72   void                  setZSize( double );
73
74   void                  getAxialScale( double&, double&, double& );
75
76   virtual void          onUpdate();
77
78   // TRANSFORMATIONS
79   virtual void          reset();
80   virtual void          pan( int , int );
81   virtual void          setCenter( int , int );
82   virtual void          fitRect( const QRect& );
83   virtual void          startZoomAtPoint( int, int );
84   virtual void          zoom( int, int, int, int );
85   virtual void          fitAll( bool keepScale = false, bool withZ = true, bool upd = true );
86   virtual void          rotateXY( double );
87   virtual void          setAxialScale( double, double, double );
88
89   virtual void          startRotation( int, int, int, const gp_Pnt& );
90   virtual void          rotate( int, int, int, const gp_Pnt& );
91   virtual void          endRotation();
92   bool                  isBusy() {return myBusy;} // check that View Port is fully initialized
93
94   void                  setAdvancedZoomingEnabled( const bool theState ) { myIsAdvancedZoomingEnabled = theState; }
95   bool                  isAdvancedZoomingEnabled() const { return myIsAdvancedZoomingEnabled; }
96
97 signals:
98   void                  vpChangeBackground( const Qtx::BackgroundData& );
99   void                  vpClosed();
100
101 public slots:
102   virtual bool          synchronize( OCCViewer_ViewPort* );
103
104 protected:
105     // EVENTS
106   virtual void          paintEvent( QPaintEvent* );
107   virtual void          resizeEvent( QResizeEvent* );
108
109   // initialization
110   virtual void          attachWindow( const Handle(V3d_View)&, const Handle(Aspect_Window)& );
111
112 private:
113   Handle(V3d_View)      activeView() const;
114   Handle(V3d_View)      inactiveView() const;
115   bool                  mapView( const Handle(V3d_View)& );
116   bool                  setWindow( const Handle(V3d_View)& );
117   bool                  mapped( const Handle(V3d_View)& ) const;
118   void                  updateBackground();
119   
120 private:
121   Handle(V3d_View)      myOrthoView;
122   Handle(V3d_View)      myPerspView;
123   Handle(V3d_View)      myActiveView;
124   bool                  myDegenerated;
125   bool                  myAnimate;
126   bool                  myBusy;
127   double                myScale;
128   bool                  myIsAdvancedZoomingEnabled;
129   Qtx::BackgroundData   myBackground;
130   int                   myBgImgHeight;
131   int                   myBgImgWidth;
132 };
133
134 #ifdef WIN32
135 #pragma warning ( default:4251 )
136 #endif
137
138 #endif