Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OCCViewer_ViewPort3d.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 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 #ifndef OCCVIEWER_VIEWPORT3D_H
24 #define OCCVIEWER_VIEWPORT3D_H
25 
26 #include <Basics_OCCTVersion.hxx>
27 
28 #include "OCCViewer_ViewPort.h"
29 #include "Qtx.h"
30 
31 #include <V3d_View.hxx>
32 #include <V3d_Viewer.hxx>
33 
34 class QColor;
35 class QString;
36 class QRect;
37 
38 #ifdef WIN32
39 #pragma warning ( disable:4251 )
40 #endif
41 
43 {
44  Q_OBJECT
45 
46  friend class OCCViewer_ViewTransformer;
47 
48 public:
49  OCCViewer_ViewPort3d( QWidget*, const Handle(V3d_Viewer)&, V3d_TypeOfView = V3d_ORTHOGRAPHIC );
50  virtual ~OCCViewer_ViewPort3d();
51 
52 public:
53  Handle(V3d_View) getView() const;
54  Handle(V3d_View) setView( const Handle(V3d_View)& );
55  Handle(V3d_Viewer) getViewer() const;
56 
57  virtual void setBackgroundColor( const QColor& color); // obsolete
58  virtual QColor backgroundColor() const; // obsolete
59  void setBackground( const Qtx::BackgroundData& color);
60  Qtx::BackgroundData background() const;
61 
62  virtual int getBgImgHeight(){return myBgImgHeight; };
63  virtual int getBgImgWidth() {return myBgImgWidth; };
64 
65 // void setActive( V3d_TypeOfView );
66  virtual bool syncronize( const OCCViewer_ViewPort3d* );
67 
68 #if OCC_VERSION_LARGE <= 0x07000000
69  double getZSize() const;
70  void setZSize( double );
71 #endif
72 
73  void getAxialScale( double&, double&, double& );
74 
75  virtual void onUpdate();
76 
77  // TRANSFORMATIONS
78  virtual void reset();
79  virtual void pan( int , int );
80  virtual void setCenter( int , int );
81  virtual void fitRect( const QRect& );
82  virtual void startZoomAtPoint( int, int );
83  virtual void zoom( int, int, int, int );
84  virtual void fitAll( bool keepScale = false, bool withZ = true, bool upd = true );
85  virtual void rotateXY( double );
86  virtual void setAxialScale( double, double, double );
87 
88  virtual void startRotation( int, int, int, const gp_Pnt& );
89  virtual void rotate( int, int, int, const gp_Pnt& );
90  virtual void endRotation();
91  bool isBusy() {return myBusy;} // check that View Port is fully initialized
92 
93  void setAdvancedZoomingEnabled( const bool theState ) { myIsAdvancedZoomingEnabled = theState; }
94  bool isAdvancedZoomingEnabled() const { return myIsAdvancedZoomingEnabled; }
95 
96  void showStaticTrihedron( bool );
97 
98  void setDefaultCursor( Qt::CursorShape theCursorShape );
99  QCursor* getDefaultCursor() const;
100 
101 signals:
102  void vpChangeBackground( const Qtx::BackgroundData& );
103  void vpClosed(OCCViewer_ViewPort3d*);
104  void vpMapped(OCCViewer_ViewPort3d*);
105 
106 public slots:
107  virtual bool synchronize( OCCViewer_ViewPort* );
108 
109 private slots:
110  void repaintViewAfterMove();
111 
112 protected:
113  // EVENTS
114  virtual void paintEvent( QPaintEvent* );
115  virtual void resizeEvent( QResizeEvent* );
116 
117  // initialization
118  virtual void attachWindow( const Handle(V3d_View)&, const Handle(Aspect_Window)& );
119 
120 private:
121  Handle(V3d_View) activeView() const;
122  Handle(V3d_View) inactiveView() const;
123  bool mapView( const Handle(V3d_View)& );
124  bool setWindow( const Handle(V3d_View)& );
125  bool mapped( const Handle(V3d_View)& ) const;
126  void updateBackground();
127  void setDefaultParams();
128 
129 private:
130  Handle(V3d_View) myActiveView;
131 #if OCC_VERSION_LARGE <= 0x06070100
132  Handle(V3d_View) myOrthoView;
133  Handle(V3d_View) myPerspView;
134 #endif
135  bool myBusy;
136  double myScale;
141  QCursor* myCursor;
142 };
143 
144 #ifdef WIN32
145 #pragma warning ( default:4251 )
146 #endif
147 
148 #endif