File indexing completed on 2025-01-18 10:05:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _ViewerTest_EventManager_HeaderFile
0018 #define _ViewerTest_EventManager_HeaderFile
0019
0020 #include <AIS_ViewController.hxx>
0021 #include <TCollection_AsciiString.hxx>
0022
0023 class AIS_InteractiveContext;
0024 class Aspect_Window;
0025 class V3d_View;
0026
0027 DEFINE_STANDARD_HANDLE(ViewerTest_EventManager, Standard_Transient)
0028
0029
0030
0031 class ViewerTest_EventManager : public Standard_Transient, public AIS_ViewController
0032 {
0033 DEFINE_STANDARD_RTTIEXT(ViewerTest_EventManager, Standard_Transient)
0034 public:
0035
0036
0037 static Standard_Boolean& ToCloseViewOnEscape()
0038 {
0039 static Standard_Boolean Draw_ToCloseViewOnEsc = Standard_False;
0040 return Draw_ToCloseViewOnEsc;
0041 }
0042
0043
0044 static Standard_Boolean& ToExitOnCloseView()
0045 {
0046 static Standard_Boolean Draw_ToExitOnCloseView = Standard_False;
0047 return Draw_ToExitOnCloseView;
0048 }
0049
0050
0051 Standard_EXPORT static const Handle(AIS_AnimationCamera)& GlobalViewAnimation();
0052
0053 public:
0054
0055
0056 Standard_EXPORT ViewerTest_EventManager(const Handle(V3d_View)& aView, const Handle(AIS_InteractiveContext)& aCtx);
0057
0058
0059 Standard_EXPORT virtual ~ViewerTest_EventManager();
0060
0061
0062 Standard_EXPORT static void SetupWindowCallbacks (const Handle(Aspect_Window)& theWin);
0063
0064
0065 const Handle(AIS_InteractiveContext)& Context() const { return myCtx; }
0066
0067
0068 Standard_Boolean ToPickPoint() const { return myToPickPnt; }
0069
0070
0071 void StartPickPoint (const char* theArgX,
0072 const char* theArgY,
0073 const char* theArgZ)
0074 {
0075 myToPickPnt = Standard_True;
0076 myPickPntArgVec[0] = theArgX;
0077 myPickPntArgVec[1] = theArgY;
0078 myPickPntArgVec[2] = theArgZ;
0079 }
0080
0081
0082 Standard_EXPORT virtual bool UpdateMouseScroll (const Aspect_ScrollDelta& theDelta) Standard_OVERRIDE;
0083
0084
0085 Standard_EXPORT virtual bool UpdateMouseClick (const Graphic3d_Vec2i& thePoint,
0086 Aspect_VKeyMouse theButton,
0087 Aspect_VKeyFlags theModifiers,
0088 bool theIsDoubleClick) Standard_OVERRIDE;
0089
0090
0091 Standard_EXPORT virtual bool UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
0092 Aspect_VKeyMouse theButtons,
0093 Aspect_VKeyFlags theModifiers,
0094 bool theIsEmulated) Standard_OVERRIDE;
0095
0096
0097 Standard_EXPORT virtual void KeyDown (Aspect_VKey theKey,
0098 double theTime,
0099 double thePressure = 1.0) Standard_OVERRIDE;
0100
0101
0102 Standard_EXPORT virtual void KeyUp (Aspect_VKey theKey,
0103 double theTime) Standard_OVERRIDE;
0104
0105
0106 Standard_EXPORT virtual void ProcessExpose() Standard_OVERRIDE;
0107
0108
0109 Standard_EXPORT virtual void handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
0110 const Handle(V3d_View)& theView) Standard_OVERRIDE;
0111
0112
0113 Standard_EXPORT virtual void ProcessConfigure (bool theIsResized = true) Standard_OVERRIDE;
0114
0115
0116 Standard_EXPORT virtual void ProcessInput() Standard_OVERRIDE;
0117
0118
0119 Standard_EXPORT void ProcessKeyPress (Aspect_VKey theKey);
0120
0121
0122
0123 Standard_EXPORT virtual void OnSubviewChanged (const Handle(AIS_InteractiveContext)& theCtx,
0124 const Handle(V3d_View)& theOldView,
0125 const Handle(V3d_View)& theNewView) Standard_OVERRIDE;
0126
0127 protected:
0128
0129
0130 void addActionHotKeys (Aspect_VKey theAction,
0131 unsigned int theHotKey1 = 0,
0132 unsigned int theHotKey2 = 0,
0133 unsigned int theHotKey3 = 0,
0134 unsigned int theHotKey4 = 0,
0135 unsigned int theHotKey5 = 0)
0136 {
0137 if (theHotKey1 != 0) { myNavKeyMap.Bind (theHotKey1, theAction); }
0138 if (theHotKey2 != 0) { myNavKeyMap.Bind (theHotKey2, theAction); }
0139 if (theHotKey3 != 0) { myNavKeyMap.Bind (theHotKey3, theAction); }
0140 if (theHotKey4 != 0) { myNavKeyMap.Bind (theHotKey4, theAction); }
0141 if (theHotKey5 != 0) { myNavKeyMap.Bind (theHotKey5, theAction); }
0142 }
0143
0144
0145 Standard_EXPORT bool navigationKeyModifierSwitch (unsigned int theModifOld,
0146 unsigned int theModifNew,
0147 double theTimeStamp);
0148
0149 private:
0150
0151 #if defined(__EMSCRIPTEN__)
0152
0153 static void onWasmRedrawView (void* );
0154 #endif
0155
0156 private:
0157
0158 Handle(AIS_InteractiveContext) myCtx;
0159 Handle(V3d_View) myView;
0160 NCollection_DataMap<unsigned int, Aspect_VKey> myNavKeyMap;
0161
0162 TCollection_AsciiString myPickPntArgVec[3];
0163 Standard_Boolean myToPickPnt;
0164 Standard_Boolean myIsTmpContRedraw;
0165
0166 unsigned int myNbUpdateRequests;
0167
0168 };
0169
0170 #endif