42cf5bc1 |
1 | // Created on: 1998-08-27 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1998-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _ViewerTest_EventManager_HeaderFile |
18 | #define _ViewerTest_EventManager_HeaderFile |
19 | |
49582f9d |
20 | #include <AIS_ViewController.hxx> |
42cf5bc1 |
21 | #include <TColgp_Array1OfPnt2d.hxx> |
49582f9d |
22 | #include <TCollection_AsciiString.hxx> |
23 | |
42cf5bc1 |
24 | class AIS_InteractiveContext; |
25 | class V3d_View; |
26 | |
25e59720 |
27 | DEFINE_STANDARD_HANDLE(ViewerTest_EventManager, Standard_Transient) |
42cf5bc1 |
28 | |
75cf8250 |
29 | //! used to manage mouse event (move,select) |
42cf5bc1 |
30 | //! By default the events are transmitted to interactive context. |
49582f9d |
31 | class ViewerTest_EventManager : public Standard_Transient, public AIS_ViewController |
42cf5bc1 |
32 | { |
49582f9d |
33 | DEFINE_STANDARD_RTTIEXT(ViewerTest_EventManager, Standard_Transient) |
42cf5bc1 |
34 | public: |
35 | |
49582f9d |
36 | //! Return TRUE if View should be closed on escape. |
37 | static Standard_Boolean& ToCloseViewOnEscape() |
38 | { |
39 | static Standard_Boolean Draw_ToCloseViewOnEsc = Standard_False; |
40 | return Draw_ToCloseViewOnEsc; |
41 | } |
42cf5bc1 |
42 | |
49582f9d |
43 | //! Return TRUE if Draw Harness should exit on closing View. |
44 | static Standard_Boolean& ToExitOnCloseView() |
45 | { |
46 | static Standard_Boolean Draw_ToExitOnCloseView = Standard_False; |
47 | return Draw_ToExitOnCloseView; |
48 | } |
42cf5bc1 |
49 | |
2108d9a2 |
50 | //! Use global camera animation object shared across all Views in ViewerTest. |
51 | Standard_EXPORT static const Handle(AIS_AnimationCamera)& GlobalViewAnimation(); |
52 | |
49582f9d |
53 | public: |
42cf5bc1 |
54 | |
49582f9d |
55 | //! Main constructor. |
56 | Standard_EXPORT ViewerTest_EventManager(const Handle(V3d_View)& aView, const Handle(AIS_InteractiveContext)& aCtx); |
2108d9a2 |
57 | |
58 | //! Destructor. |
59 | Standard_EXPORT virtual ~ViewerTest_EventManager(); |
60 | |
49582f9d |
61 | //! Return interactive context. |
62 | const Handle(AIS_InteractiveContext)& Context() const { return myCtx; } |
63 | |
64 | //! Returns TRUE if picking point mode has been enabled (for VPick command). |
65 | Standard_Boolean ToPickPoint() const { return myToPickPnt; } |
66 | |
67 | //! Start picking point for VPick command. |
68 | void StartPickPoint (const char* theArgX, |
69 | const char* theArgY, |
70 | const char* theArgZ) |
71 | { |
72 | myToPickPnt = Standard_True; |
73 | myPickPntArgVec[0] = theArgX; |
74 | myPickPntArgVec[1] = theArgY; |
75 | myPickPntArgVec[2] = theArgZ; |
76 | } |
77 | |
78 | //! Handle mouse button press/release event. |
79 | Standard_EXPORT virtual bool UpdateMouseButtons (const Graphic3d_Vec2i& thePoint, |
80 | Aspect_VKeyMouse theButtons, |
81 | Aspect_VKeyFlags theModifiers, |
82 | bool theIsEmulated) Standard_OVERRIDE; |
83 | |
d22962e4 |
84 | //! Release key. |
85 | Standard_EXPORT virtual void KeyDown (Aspect_VKey theKey, |
86 | double theTime, |
87 | double thePressure = 1.0) Standard_OVERRIDE; |
88 | |
49582f9d |
89 | //! Release key. |
90 | Standard_EXPORT virtual void KeyUp (Aspect_VKey theKey, |
91 | double theTime) Standard_OVERRIDE; |
92 | |
93 | //! Redraw the View on an Expose Event |
e8e157df |
94 | Standard_EXPORT virtual void ProcessExpose() Standard_OVERRIDE; |
49582f9d |
95 | |
08b7a39f |
96 | //! Handle redraw. |
97 | Standard_EXPORT virtual void handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx, |
98 | const Handle(V3d_View)& theView) Standard_OVERRIDE; |
99 | |
49582f9d |
100 | //! Resize View. |
e8e157df |
101 | Standard_EXPORT virtual void ProcessConfigure (bool theIsResized = true) Standard_OVERRIDE; |
102 | |
103 | //! Handle window input event immediately (flush input buffer). |
104 | Standard_EXPORT virtual void ProcessInput() Standard_OVERRIDE; |
49582f9d |
105 | |
106 | //! Handle KeyPress event. |
107 | Standard_EXPORT void ProcessKeyPress (Aspect_VKey theKey); |
42cf5bc1 |
108 | |
d22962e4 |
109 | protected: |
110 | |
111 | //! Register hot-keys for specified Action. |
112 | void addActionHotKeys (Aspect_VKey theAction, |
113 | unsigned int theHotKey1 = 0, |
114 | unsigned int theHotKey2 = 0, |
115 | unsigned int theHotKey3 = 0, |
116 | unsigned int theHotKey4 = 0, |
117 | unsigned int theHotKey5 = 0) |
118 | { |
119 | if (theHotKey1 != 0) { myNavKeyMap.Bind (theHotKey1, theAction); } |
120 | if (theHotKey2 != 0) { myNavKeyMap.Bind (theHotKey2, theAction); } |
121 | if (theHotKey3 != 0) { myNavKeyMap.Bind (theHotKey3, theAction); } |
122 | if (theHotKey4 != 0) { myNavKeyMap.Bind (theHotKey4, theAction); } |
123 | if (theHotKey5 != 0) { myNavKeyMap.Bind (theHotKey5, theAction); } |
124 | } |
125 | |
126 | //! Handle modifier key changes. |
127 | Standard_EXPORT bool navigationKeyModifierSwitch (unsigned int theModifOld, |
128 | unsigned int theModifNew, |
129 | double theTimeStamp); |
130 | |
42cf5bc1 |
131 | private: |
132 | |
42cf5bc1 |
133 | Handle(AIS_InteractiveContext) myCtx; |
134 | Handle(V3d_View) myView; |
d22962e4 |
135 | NCollection_DataMap<unsigned int, Aspect_VKey> myNavKeyMap; //!< map of Hot-Key (key+modifiers) to Action |
42cf5bc1 |
136 | |
49582f9d |
137 | TCollection_AsciiString myPickPntArgVec[3]; |
138 | Standard_Boolean myToPickPnt; |
08b7a39f |
139 | Standard_Boolean myIsTmpContRedraw; |
42cf5bc1 |
140 | |
141 | }; |
142 | |
42cf5bc1 |
143 | #endif // _ViewerTest_EventManager_HeaderFile |