File indexing completed on 2026-09-20 09:19:33
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
0028
0029 class ViewerTest_EventManager : public Standard_Transient, public AIS_ViewController
0030 {
0031 DEFINE_STANDARD_RTTIEXT(ViewerTest_EventManager, Standard_Transient)
0032 public:
0033
0034 static bool& ToCloseViewOnEscape()
0035 {
0036 static bool Draw_ToCloseViewOnEsc = false;
0037 return Draw_ToCloseViewOnEsc;
0038 }
0039
0040
0041 static bool& ToExitOnCloseView()
0042 {
0043 static bool Draw_ToExitOnCloseView = false;
0044 return Draw_ToExitOnCloseView;
0045 }
0046
0047
0048 Standard_EXPORT static const occ::handle<AIS_AnimationCamera>& GlobalViewAnimation();
0049
0050 public:
0051
0052 Standard_EXPORT ViewerTest_EventManager(const occ::handle<V3d_View>& aView,
0053 const occ::handle<AIS_InteractiveContext>& aCtx);
0054
0055
0056 Standard_EXPORT ~ViewerTest_EventManager() override;
0057
0058
0059 Standard_EXPORT static void SetupWindowCallbacks(const occ::handle<Aspect_Window>& theWin);
0060
0061
0062 const occ::handle<AIS_InteractiveContext>& Context() const { return myCtx; }
0063
0064
0065 bool ToPickPoint() const { return myToPickPnt; }
0066
0067
0068 void StartPickPoint(const char* theArgX, const char* theArgY, const char* theArgZ)
0069 {
0070 myToPickPnt = true;
0071 myPickPntArgVec[0] = theArgX;
0072 myPickPntArgVec[1] = theArgY;
0073 myPickPntArgVec[2] = theArgZ;
0074 }
0075
0076
0077 Standard_EXPORT bool UpdateMouseScroll(const Aspect_ScrollDelta& theDelta) override;
0078
0079
0080 Standard_EXPORT bool UpdateMouseClick(const NCollection_Vec2<int>& thePoint,
0081 Aspect_VKeyMouse theButton,
0082 Aspect_VKeyFlags theModifiers,
0083 bool theIsDoubleClick) override;
0084
0085
0086 Standard_EXPORT bool UpdateMouseButtons(const NCollection_Vec2<int>& thePoint,
0087 Aspect_VKeyMouse theButtons,
0088 Aspect_VKeyFlags theModifiers,
0089 bool theIsEmulated) override;
0090
0091
0092 Standard_EXPORT void KeyDown(Aspect_VKey theKey,
0093 double theTime,
0094 double thePressure = 1.0) override;
0095
0096
0097 Standard_EXPORT void KeyUp(Aspect_VKey theKey, double theTime) override;
0098
0099
0100 Standard_EXPORT void ProcessExpose() override;
0101
0102
0103 Standard_EXPORT void handleViewRedraw(const occ::handle<AIS_InteractiveContext>& theCtx,
0104 const occ::handle<V3d_View>& theView) override;
0105
0106
0107 Standard_EXPORT void ProcessConfigure(bool theIsResized = true) override;
0108
0109
0110 Standard_EXPORT void ProcessInput() override;
0111
0112
0113 Standard_EXPORT void ProcessKeyPress(Aspect_VKey theKey);
0114
0115
0116
0117 Standard_EXPORT void OnSubviewChanged(const occ::handle<AIS_InteractiveContext>& theCtx,
0118 const occ::handle<V3d_View>& theOldView,
0119 const occ::handle<V3d_View>& theNewView) override;
0120
0121 protected:
0122
0123 void addActionHotKeys(Aspect_VKey theAction,
0124 unsigned int theHotKey1 = 0,
0125 unsigned int theHotKey2 = 0,
0126 unsigned int theHotKey3 = 0,
0127 unsigned int theHotKey4 = 0,
0128 unsigned int theHotKey5 = 0)
0129 {
0130 if (theHotKey1 != 0)
0131 {
0132 myNavKeyMap.Bind(theHotKey1, theAction);
0133 }
0134 if (theHotKey2 != 0)
0135 {
0136 myNavKeyMap.Bind(theHotKey2, theAction);
0137 }
0138 if (theHotKey3 != 0)
0139 {
0140 myNavKeyMap.Bind(theHotKey3, theAction);
0141 }
0142 if (theHotKey4 != 0)
0143 {
0144 myNavKeyMap.Bind(theHotKey4, theAction);
0145 }
0146 if (theHotKey5 != 0)
0147 {
0148 myNavKeyMap.Bind(theHotKey5, theAction);
0149 }
0150 }
0151
0152
0153 Standard_EXPORT bool navigationKeyModifierSwitch(unsigned int theModifOld,
0154 unsigned int theModifNew,
0155 double theTimeStamp);
0156
0157 private:
0158 #if defined(__EMSCRIPTEN__)
0159
0160 static void onWasmRedrawView(void*);
0161 #endif
0162
0163 private:
0164 occ::handle<AIS_InteractiveContext> myCtx;
0165 occ::handle<V3d_View> myView;
0166
0167 NCollection_DataMap<unsigned int, Aspect_VKey> myNavKeyMap;
0168
0169
0170 TCollection_AsciiString myPickPntArgVec[3];
0171 bool myToPickPnt;
0172 bool myIsTmpContRedraw;
0173
0174 unsigned int myNbUpdateRequests;
0175 };
0176
0177 #endif