80eb9670 |
1 | // Copyright (c) 2014 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #ifndef ANDROIDQT_H |
15 | #define ANDROIDQT_H |
16 | |
17 | #include <OpenGl_Context.hxx> |
18 | |
55a40de8 |
19 | #include <Standard_WarningsDisable.hxx> |
80eb9670 |
20 | // workaround broken definitions in Qt |
21 | #define GLdouble GLdouble |
22 | |
55a40de8 |
23 | #include <QMutex> |
80eb9670 |
24 | #include <QtQuick/qquickwindow.h> |
25 | #include <QtQuick/QQuickItem> |
26 | |
27 | #undef GLdouble |
55a40de8 |
28 | #include <Standard_WarningsRestore.hxx> |
80eb9670 |
29 | |
30 | #include <AIS_InteractiveContext.hxx> |
31 | #include <V3d_View.hxx> |
32 | |
41ea50ac |
33 | #include "AndroidQt_TouchParameters.h" |
80eb9670 |
34 | |
35 | //! QML item with embedded OCCT viewer. |
36 | class AndroidQt : public QQuickItem |
37 | { |
38 | Q_OBJECT |
39 | |
40 | public: |
41 | //! Default constructor. |
42 | AndroidQt(); |
43 | |
44 | //! Display shape from file. |
45 | Q_INVOKABLE bool ReadShapeFromFile (QString theFilePath); |
46 | |
47 | //! Handle touch event. |
48 | Q_INVOKABLE void InitTouch (const double theX, |
49 | const double theY); |
50 | |
51 | //! Handle touch event. |
52 | Q_INVOKABLE void UpdateTouch (const double theX, |
53 | const double theY); |
54 | |
55 | public slots: |
56 | |
57 | //! Handle OpenGL context creation and window resize events. |
58 | void sync(); |
59 | |
60 | //! Redraw OCCT viewer and handle pending viewer events in rendering thread. |
61 | void paint(); |
62 | |
63 | private slots: |
64 | |
65 | //! Handle window change event. |
66 | void handleWindowChanged (QQuickWindow* theWin); |
67 | |
68 | private: |
69 | |
70 | //! (Re-)initialize viewer on OpenGL context change. |
41ea50ac |
71 | //! \param theWin handle to GUI window |
72 | bool initViewer (Aspect_Drawable theWin); |
80eb9670 |
73 | |
74 | //! Close viewer |
75 | void release(); |
76 | |
77 | private: |
78 | |
79 | Handle(V3d_Viewer) myViewer; //!< 3D viewer |
80 | Handle(V3d_View) myView; //!< 3D view |
81 | Handle(AIS_InteractiveContext) myContext; //!< interactive context |
41ea50ac |
82 | Graphic3d_Vec2i myWinTopLeft; //!< cached window position (top-left) |
83 | Graphic3d_Vec2i myWinSize; //!< cached window width-height |
80eb9670 |
84 | |
85 | QMutex myMutex; //!< mutex for interconnection with rendering thread |
86 | QSize myViewportSize; //!< QML item size |
87 | AndroidQt_TouchParameters myTouchPoint; //!< cached state of touch event |
88 | bool myFitAllAction; //!< queued viewer FitALL event |
89 | |
90 | }; |
91 | |
92 | #endif // ANDROIDQT_H |