0028316: Coding Rules - Elimilate confusing aliases of Standard_Real type in V3d_View
[occt.git] / samples / qt / Common / src / OcctWindow.h
CommitLineData
de6273a3 1#ifndef OcctWindow_H
2#define OcctWindow_H
3
4#include <Aspect_Window.hxx>
5
6#include <QWidget>
7class OcctWindow;
8
9/*
10 OcctWindow class implements Aspect_Window interface using Qt API
11 as a platform-independent source of window geometry information.
12 A similar class should be used instead of platform-specific OCCT
13 classes (WNT_Window, Xw_Window) in any Qt 5 application using OCCT
14 3D visualization.
15
16 With Qt 5, the requirement for a Qt-based application to rely fully
17 on Qt public API and stop using platform-specific APIs looks mandatory.
18 An example of this is changed QWidget event sequence: when a widget is
19 first shown on the screen, a resize event is generated before the
20 underlying native window is resized correctly, however the QWidget instance
21 already holds correct size information at that moment. The OCCT classes
22 acting as a source of window geometry for V3d_View class (WNT_Window, Xw_Window)
23 are no longer compatible with changed Qt behavior because they rely on
24 platform-specific API that cannot return correct window geometry information
25 in some cases. A reasonable solution is to provide a Qt-based implementation
26 of Aspect_Window interface at application level.
27*/
28
29class OcctWindow : public Aspect_Window
30{
31public:
32
33 //! Constructor
34 OcctWindow( QWidget* theWidget, const Quantity_NameOfColor theBackColor = Quantity_NOC_MATRAGRAY );
35
36 virtual void Destroy();
37
38 //! Destructor
39 ~OcctWindow()
40 {
41 Destroy();
42 }
43
44 //! Returns native Window handle
45 virtual Aspect_Drawable NativeHandle() const;
46
47 //! Returns parent of native Window handle.
48 virtual Aspect_Drawable NativeParentHandle() const;
49
50 //! Applies the resizing to the window <me>
51 virtual Aspect_TypeOfResize DoResize() const;
52
53 //! Returns True if the window <me> is opened
54 //! and False if the window is closed.
55 virtual Standard_Boolean IsMapped() const;
56
57 //! Apply the mapping change to the window <me>
58 //! and returns TRUE if the window is mapped at screen.
59 virtual Standard_Boolean DoMapping() const { return Standard_True; }
60
61 //! Opens the window <me>.
62 virtual void Map() const;
63
64 //! Closes the window <me>.
65 virtual void Unmap() const;
66
67 virtual void Position( Standard_Integer& theX1, Standard_Integer& theY1,
68 Standard_Integer& theX2, Standard_Integer& theY2 ) const;
69
70 //! Returns The Window RATIO equal to the physical
71 //! WIDTH/HEIGHT dimensions.
ee2be2a8 72 virtual Standard_Real Ratio() const;
de6273a3 73
74 virtual void Size( Standard_Integer& theWidth, Standard_Integer& theHeight ) const;
75
76 virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return NULL; }
77
92efcf78 78 DEFINE_STANDARD_RTTIEXT(OcctWindow,Aspect_Window)
de6273a3 79
80protected:
81 Standard_Integer myXLeft;
82 Standard_Integer myYTop;
83 Standard_Integer myXRight;
84 Standard_Integer myYBottom;
85 QWidget* myWidget;
86};
87
88
89#endif // OcctWindow_H