0030507: Visualization - introduce AIS_ViewController
[occt.git] / src / ViewerTest / ViewerTest_EventManager.hxx
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
20 #include <AIS_ViewController.hxx>
21 #include <TColgp_Array1OfPnt2d.hxx>
22 #include <TCollection_AsciiString.hxx>
23
24 class AIS_InteractiveContext;
25 class V3d_View;
26
27 DEFINE_STANDARD_HANDLE(ViewerTest_EventManager, Standard_Transient)
28
29 //! used to manage mouse event (move,select,shiftselect)
30 //! By default the events are transmitted to interactive context.
31 class ViewerTest_EventManager : public Standard_Transient, public AIS_ViewController
32 {
33   DEFINE_STANDARD_RTTIEXT(ViewerTest_EventManager, Standard_Transient)
34 public:
35
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   }
42
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   }
49
50 public:
51
52   //! Main constructor.
53   Standard_EXPORT ViewerTest_EventManager(const Handle(V3d_View)& aView, const Handle(AIS_InteractiveContext)& aCtx);
54   
55   //! Return interactive context.
56   const Handle(AIS_InteractiveContext)& Context() const { return myCtx; }
57
58   //! Returns TRUE if picking point mode has been enabled (for VPick command).
59   Standard_Boolean ToPickPoint() const { return myToPickPnt; }
60
61   //! Start picking point for VPick command.
62   void StartPickPoint (const char* theArgX,
63                        const char* theArgY,
64                        const char* theArgZ)
65   {
66     myToPickPnt = Standard_True;
67     myPickPntArgVec[0] = theArgX;
68     myPickPntArgVec[1] = theArgY;
69     myPickPntArgVec[2] = theArgZ;
70   }
71
72   //! Handle mouse button press/release event.
73   Standard_EXPORT virtual bool UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
74                                                    Aspect_VKeyMouse theButtons,
75                                                    Aspect_VKeyFlags theModifiers,
76                                                    bool theIsEmulated) Standard_OVERRIDE;
77
78   //! Release key.
79   Standard_EXPORT virtual void KeyUp (Aspect_VKey theKey,
80                                       double theTime) Standard_OVERRIDE;
81
82   //! Redraw the View on an Expose Event
83   Standard_EXPORT virtual void ProcessExpose();
84
85   //! Resize View.
86   Standard_EXPORT virtual void ProcessConfigure();
87
88   //! Handle KeyPress event.
89   Standard_EXPORT void ProcessKeyPress (Aspect_VKey theKey);
90
91 private:
92
93   Handle(AIS_InteractiveContext) myCtx;
94   Handle(V3d_View) myView;
95
96   TCollection_AsciiString myPickPntArgVec[3];
97   Standard_Boolean myToPickPnt;
98
99 };
100
101 #endif // _ViewerTest_EventManager_HeaderFile