OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ViewerInteractor.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// Created on: 24 August 2017
3//-----------------------------------------------------------------------------
4// Copyright (c) 2017, Sergey Slyadnev (sergey.slyadnev@gmail.com)
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions are met:
9//
10// * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12// * Redistributions in binary form must reproduce the above copyright
13// notice, this list of conditions and the following disclaimer in the
14// documentation and/or other materials provided with the distribution.
15// * Neither the name of the copyright holder(s) nor the
16// names of all contributors may be used to endorse or promote products
17// derived from this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22// DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
23// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//-----------------------------------------------------------------------------
30
31#pragma once
32
33// OpenCascade includes
34#include <AIS_ViewController.hxx>
35#include <TColgp_Array1OfPnt2d.hxx>
36#include <TCollection_AsciiString.hxx>
37
38class AIS_InteractiveContext;
39class V3d_View;
40
42class ViewerInteractor : public Standard_Transient, public AIS_ViewController
43{
44public:
45
46 // OCCT RTTI
47 DEFINE_STANDARD_RTTI_INLINE(ViewerInteractor, Standard_Transient)
48
49public:
50
54 ViewerInteractor(const Handle(V3d_View)& view,
55 const Handle(AIS_InteractiveContext)& ctx);
56
58 virtual ~ViewerInteractor();
59
60public:
61
63 const Handle(AIS_InteractiveContext)&
64 GetContext() const { return m_ctx; }
65
67 virtual bool UpdateMouseButtons(const Graphic3d_Vec2i& thePoint,
68 Aspect_VKeyMouse theButtons,
69 Aspect_VKeyFlags theModifiers,
70 bool theIsEmulated) Standard_OVERRIDE;
71
73 virtual void KeyDown(Aspect_VKey theKey,
74 double theTime,
75 double thePressure = 1.0) Standard_OVERRIDE;
76
78 virtual void KeyUp(Aspect_VKey theKey,
79 double theTime) Standard_OVERRIDE;
80
82 virtual void ProcessExpose();
83
85 virtual void handleViewRedraw(const Handle(AIS_InteractiveContext)& theCtx,
86 const Handle(V3d_View)& theView) Standard_OVERRIDE;
87
89 virtual void ProcessConfigure();
90
92 void ProcessKeyPress(Aspect_VKey theKey);
93
94private:
95
96 Handle(V3d_View) m_view;
97 Handle(AIS_InteractiveContext) m_ctx;
98
99};
Manages input events.
Definition ViewerInteractor.h:43
ViewerInteractor(const Handle(V3d_View)&view, const Handle(AIS_InteractiveContext)&ctx)
Ctor.
Definition ViewerInteractor.cpp:43
virtual void KeyUp(Aspect_VKey theKey, double theTime) Standard_OVERRIDE
Release key.
Definition ViewerInteractor.cpp:105
virtual void ProcessExpose()
Redraw the View on an Expose Event.
Definition ViewerInteractor.cpp:66
const Handle(AIS_InteractiveContext) &GetContext() const
Return interactive context.
Definition ViewerInteractor.h:63
virtual bool UpdateMouseButtons(const Graphic3d_Vec2i &thePoint, Aspect_VKeyMouse theButtons, Aspect_VKeyFlags theModifiers, bool theIsEmulated) Standard_OVERRIDE
Handle mouse button press/release event.
Definition ViewerInteractor.cpp:56
virtual void ProcessConfigure()
Resize View.
Definition ViewerInteractor.cpp:85
void ProcessKeyPress(Aspect_VKey theKey)
Handle KeyPress event.
Definition ViewerInteractor.cpp:119
virtual ~ViewerInteractor()
Dtor.
Definition ViewerInteractor.cpp:51
virtual void KeyDown(Aspect_VKey theKey, double theTime, double thePressure=1.0) Standard_OVERRIDE
Release key.
Definition ViewerInteractor.cpp:96
virtual void handleViewRedraw(const Handle(AIS_InteractiveContext)&theCtx, const Handle(V3d_View)&theView) Standard_OVERRIDE
Handle redraw.
Definition ViewerInteractor.cpp:77