Version: 9.15.0
OCCViewer_ViewPort3d.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2025 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 #include <gp_Ax1.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  void getAxialScale( double&, double&, double& );
69 
70  virtual void onUpdate();
71 
72  // TRANSFORMATIONS
73  virtual void reset();
74  virtual void pan( int , int );
75  virtual void setCenter( int , int );
76  virtual void fitRect( const QRect& );
77  virtual void startZoomAtPoint( int, int );
78  virtual void zoom( int, int, int, int );
79  virtual void fitAll( bool keepScale = false, bool withZ = true, bool upd = true );
80  virtual void rotateXY( double );
81  virtual void setAxialScale( double, double, double );
82 
83  virtual void startRotation( int, int, int, const gp_Pnt& );
84  virtual void rotate( int, int, int, const gp_Pnt& );
85  virtual void endRotation();
86 
87  // Set the rotation axis and start automatic rotation
88  void setRotationAxis(const gp_Vec& theAxis, double theAngle, double theZAngle);
89  // Stop the automatic rotation
90  void stopRotation();
91 
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  void showStaticTrihedron( bool );
98  void setStaticTrihedronTextFont();
99  void setStaticTrihedronTextColor();
100 
101  void setDefaultCursor( Qt::CursorShape theCursorShape );
102  QCursor* getDefaultCursor() const;
103 
104 signals:
108  void vpResizeEvent( QResizeEvent* );
109 
110 public slots:
111  virtual bool synchronize( OCCViewer_ViewPort* );
112 
113 private slots:
114  void updateRotation();
115  void repaintViewAfterMove();
116 
117 protected:
118  // EVENTS
119  virtual void paintEvent( QPaintEvent* );
120  virtual void resizeEvent( QResizeEvent* );
121 
122  // initialization
123  virtual void attachWindow( const Handle(V3d_View)&, const Handle(Aspect_Window)& );
124 
125 private:
126  Handle(V3d_View) activeView() const;
127  Handle(V3d_View) inactiveView() const;
128  bool mapView( const Handle(V3d_View)& );
129  bool setWindow( const Handle(V3d_View)& );
130  bool mapped( const Handle(V3d_View)& ) const;
131  void updateBackground();
132  void setDefaultParams();
133 
134 private:
135  Handle(V3d_View) myActiveView;
136  bool myBusy;
137  double myScale;
142  QCursor* myCursor;
143  // Fields for automatic rotation
144  gp_Ax1 myRotAxis; // The rotation axis
145  double myRotAngle; // The angular rotation speed
146  bool myIsRotating; // Whether rotation animation is active
147  qint64 myLastRender; // Timestamp of last paint event
148  QTimer* myRotTimer; // Rotation timer
149 };
150 
151 #ifdef WIN32
152 #pragma warning ( default:4251 )
153 #endif
154 
155 #endif
#define OCCVIEWER_EXPORT
Definition: OCCViewer.h:33
static void setView(int view)
Change the view of the current view window.
Definition: SALOMEGUI_Swig.cxx:799
Definition: OCCViewer_ViewPort3d.h:43
bool mapped(const Handle(V3d_View)&) const
Qtx::BackgroundData myBackground
Definition: OCCViewer_ViewPort3d.h:139
Handle(V3d_View) getView() const
double myScale
Definition: OCCViewer_ViewPort3d.h:137
bool myBusy
Definition: OCCViewer_ViewPort3d.h:136
bool myIsAdvancedZoomingEnabled
Definition: OCCViewer_ViewPort3d.h:138
int myBgImgWidth
Definition: OCCViewer_ViewPort3d.h:141
Handle(V3d_View) setView(const Handle(V3d_View) &)
int myBgImgHeight
Definition: OCCViewer_ViewPort3d.h:140
Handle(V3d_View) myActiveView
bool myIsRotating
Definition: OCCViewer_ViewPort3d.h:146
virtual int getBgImgHeight()
Definition: OCCViewer_ViewPort3d.h:62
bool isBusy()
Definition: OCCViewer_ViewPort3d.h:92
void vpResizeEvent(QResizeEvent *)
QTimer * myRotTimer
Definition: OCCViewer_ViewPort3d.h:148
gp_Ax1 myRotAxis
Definition: OCCViewer_ViewPort3d.h:144
Handle(V3d_View) inactiveView() const
qint64 myLastRender
Definition: OCCViewer_ViewPort3d.h:147
Handle(V3d_Viewer) getViewer() const
virtual bool synchronize(OCCViewer_ViewPort *)
QCursor * myCursor
Definition: OCCViewer_ViewPort3d.h:142
void vpClosed(OCCViewer_ViewPort3d *)
double myRotAngle
Definition: OCCViewer_ViewPort3d.h:145
Handle(V3d_View) activeView() const
bool isAdvancedZoomingEnabled() const
Definition: OCCViewer_ViewPort3d.h:95
virtual int getBgImgWidth()
Definition: OCCViewer_ViewPort3d.h:63
void vpChangeBackground(const Qtx::BackgroundData &)
void vpMapped(OCCViewer_ViewPort3d *)
virtual bool syncronize(const OCCViewer_ViewPort3d *)
void setAdvancedZoomingEnabled(const bool theState)
Definition: OCCViewer_ViewPort3d.h:94
Definition: OCCViewer_ViewPort.h:49
virtual void paintEvent(QPaintEvent *)
Definition: OCCViewer_ViewPort.cxx:428
Handle(Aspect_Window) myWindow
virtual void setBackgroundColor(const QColor &)
Definition: OCCViewer_ViewPort.cxx:327
virtual void setCenter(int, int)=0
virtual void onUpdate()
Definition: OCCViewer_ViewPort.cxx:450
virtual void fitRect(const QRect &)=0
virtual QColor backgroundColor() const
Definition: OCCViewer_ViewPort.cxx:339
virtual void reset()=0
virtual void fitAll(bool keepScale=false, bool withZ=true, bool upd=true)=0
virtual void pan(int, int)=0
virtual void zoom(int, int, int, int)=0
Stores background data.
Definition: Qtx.h:178
Quantity_Color color(const QColor &)
Convert QColor object to Quantity_Color object.
Definition: OCCViewer.cxx:28