1 // Copyright (c) 2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
17 #include <OpenGl_Context.hxx>
19 #include <Standard_WarningsDisable.hxx>
20 // workaround broken definitions in Qt
21 #define GLdouble GLdouble
24 #include <QtQuick/qquickwindow.h>
25 #include <QtQuick/QQuickItem>
28 #include <Standard_WarningsRestore.hxx>
30 #include <AIS_InteractiveContext.hxx>
31 #include <V3d_View.hxx>
33 #include "AndroidQt_TouchParameters.h"
35 //! QML item with embedded OCCT viewer.
36 class AndroidQt : public QQuickItem
41 //! Default constructor.
44 //! Display shape from file.
45 Q_INVOKABLE bool ReadShapeFromFile (QString theFilePath);
47 //! Handle touch event.
48 Q_INVOKABLE void InitTouch (const double theX,
51 //! Handle touch event.
52 Q_INVOKABLE void UpdateTouch (const double theX,
57 //! Handle OpenGL context creation and window resize events.
60 //! Redraw OCCT viewer and handle pending viewer events in rendering thread.
65 //! Handle window change event.
66 void handleWindowChanged (QQuickWindow* theWin);
70 //! (Re-)initialize viewer on OpenGL context change.
71 //! \param theWin handle to GUI window
72 bool initViewer (Aspect_Drawable theWin);
79 Handle(V3d_Viewer) myViewer; //!< 3D viewer
80 Handle(V3d_View) myView; //!< 3D view
81 Handle(AIS_InteractiveContext) myContext; //!< interactive context
82 Graphic3d_Vec2i myWinTopLeft; //!< cached window position (top-left)
83 Graphic3d_Vec2i myWinSize; //!< cached window width-height
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