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