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