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 | |
19 | // workaround broken definitions in Qt |
20 | #define GLdouble GLdouble |
21 | |
22 | #include <QtQuick/qquickwindow.h> |
23 | #include <QtQuick/QQuickItem> |
24 | |
25 | #undef GLdouble |
26 | |
27 | #include <AIS_InteractiveContext.hxx> |
28 | #include <V3d_View.hxx> |
29 | |
30 | #include <QMutex> |
31 | |
41ea50ac |
32 | #include "AndroidQt_TouchParameters.h" |
80eb9670 |
33 | |
34 | //! QML item with embedded OCCT viewer. |
35 | class AndroidQt : public QQuickItem |
36 | { |
37 | Q_OBJECT |
38 | |
39 | public: |
40 | //! Default constructor. |
41 | AndroidQt(); |
42 | |
43 | //! Display shape from file. |
44 | Q_INVOKABLE bool ReadShapeFromFile (QString theFilePath); |
45 | |
46 | //! Handle touch event. |
47 | Q_INVOKABLE void InitTouch (const double theX, |
48 | const double theY); |
49 | |
50 | //! Handle touch event. |
51 | Q_INVOKABLE void UpdateTouch (const double theX, |
52 | const double theY); |
53 | |
54 | public slots: |
55 | |
56 | //! Handle OpenGL context creation and window resize events. |
57 | void sync(); |
58 | |
59 | //! Redraw OCCT viewer and handle pending viewer events in rendering thread. |
60 | void paint(); |
61 | |
62 | private slots: |
63 | |
64 | //! Handle window change event. |
65 | void handleWindowChanged (QQuickWindow* theWin); |
66 | |
67 | private: |
68 | |
69 | //! (Re-)initialize viewer on OpenGL context change. |
41ea50ac |
70 | //! \param theWin handle to GUI window |
71 | bool initViewer (Aspect_Drawable theWin); |
80eb9670 |
72 | |
73 | //! Close viewer |
74 | void release(); |
75 | |
76 | private: |
77 | |
78 | Handle(V3d_Viewer) myViewer; //!< 3D viewer |
79 | Handle(V3d_View) myView; //!< 3D view |
80 | Handle(AIS_InteractiveContext) myContext; //!< interactive context |
41ea50ac |
81 | Graphic3d_Vec2i myWinTopLeft; //!< cached window position (top-left) |
82 | Graphic3d_Vec2i myWinSize; //!< cached window width-height |
80eb9670 |
83 | |
84 | QMutex myMutex; //!< mutex for interconnection with rendering thread |
85 | QSize myViewportSize; //!< QML item size |
86 | AndroidQt_TouchParameters myTouchPoint; //!< cached state of touch event |
87 | bool myFitAllAction; //!< queued viewer FitALL event |
88 | |
89 | }; |
90 | |
91 | #endif // ANDROIDQT_H |