opencascade AIS_ViewController源码学习 视图控制、包含鼠标事件等

opencascade AIS_ViewController

前言

在这里插入图片描述

用于在GUI和渲染线程之间处理视图器事件的辅助结构。
该类实现了以下功能:
缓存存储用户输入状态(鼠标、触摸和键盘)。
将鼠标/多点触控输入映射到视图相机操作(平移、旋转、缩放)。
输入事件不会立即应用,而是排队等待两个工作线程单独处理:
UI线程接收用户输入,渲染线程用于OCCT 3D视图绘制。

方法

1

空构造函数。
AIS_ViewController();

2

返回输入缓冲区。
const AIS_ViewInputBuffer& InputBuffer(AIS_ViewInputBufferType theType) const { return theType == AIS_ViewInputBufferType_UI ? myUI : myGL; }

3

返回输入缓冲区。
AIS_ViewInputBuffer& ChangeInputBuffer(AIS_ViewInputBufferType theType) { return theType == AIS_ViewInputBufferType_UI ? myUI : myGL; }

4

//! 返回视图动画;默认情况下为空(但不是NULL)动画。
const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }

5

//! 设置视图动画以在handleViewRedraw()中处理。
void SetViewAnimation(const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; }

6

//! 中断活动的视图动画。
Standard_EXPORT void AbortViewAnimation();

7

//! 返回对象动画;默认情况下为空(但不是NULL)动画。
const Handle(AIS_Animation)& ObjectsAnimation() const { return myObjAnimation; }

8

//! 设置对象动画以在handleViewRedraw()中处理。
void SetObjectsAnimation(const Handle(AIS_Animation)& theAnimation) { myObjAnimation = theAnimation; }

9

//! 返回TRUE如果对象动画应该在鼠标点击时暂停;默认情况下为FALSE。
bool ToPauseObjectsAnimation() const { return myToPauseObjAnimation; }

10

//! 设置是否在鼠标点击时暂停对象动画。
void SetPauseObjectsAnimation(bool theToPause) { myToPauseObjAnimation = theToPause; }

11

//! 返回TRUE如果启用连续重绘;默认情况下为FALSE。
//! 此选项会要求在当前帧完成后立即完全重绘下一个视图帧。
bool IsContinuousRedraw() const { return myIsContinuousRedraw; }

12

//! 启用或禁用连续更新。
void SetContinuousRedraw(bool theToEnable) { myIsContinuousRedraw = theToEnable; }

全局参数

13

//! 返回相机旋转模式,默认为AIS_RotationMode_BndBoxActive。
AIS_RotationMode RotationMode() const { return myRotationMode; }

14

//! 设置相机旋转模式。
void SetRotationMode(AIS_RotationMode theMode) { myRotationMode = theMode; }

15

//! 返回相机导航模式;默认情况下为AIS_NavigationMode_Orbit。
AIS_NavigationMode NavigationMode() const { return myNavigationMode; }

16

//! 设置相机导航模式。
Standard_EXPORT void SetNavigationMode(AIS_NavigationMode theMode);

17

//! 返回第一人称模式下鼠标输入加速比率;默认为1.0。
float MouseAcceleration() const { return myMouseAccel; }

18

//! 设置鼠标输入加速比率。
void SetMouseAcceleration(float theRatio) { myMouseAccel = theRatio; }

19

//! 返回轨道旋转加速比率;默认为1.0。
float OrbitAcceleration() const { return myOrbitAccel; }

20

//! 设置轨道旋转加速比率。
void SetOrbitAcceleration(float theRatio) { myOrbitAccel = theRatio; }

21

//! 返回TRUE如果在透视投影中应显示平移锚点;默认为TRUE。
bool ToShowPanAnchorPoint() const { return myToShowPanAnchorPoint; }

22

//! 设置是否在透视投影中显示平移锚点。
void SetShowPanAnchorPoint(bool theToShow) { myToShowPanAnchorPoint = theToShow; }

23

//! 返回TRUE如果应在3D查看器中显示旋转中心点;默认为TRUE。
bool ToShowRotateCenter() const { return myToShowRotateCenter; }

24

//! 设置是否在3D查看器中显示旋转中心点。
void SetShowRotateCenter(bool theToShow) { myToShowRotateCenter = theToShow; }

25

//! 返回TRUE如果在AIS_NavigationMode_Orbit旋转模式下相机上方向应强制为Z向上;默认为FALSE。
bool ToLockOrbitZUp() const { return myToLockOrbitZUp; }

26

//! 设置在AIS_NavigationMode_Orbit旋转模式下相机上方向是否应强制为Z向上。
void SetLockOrbitZUp(bool theToForceUp) { myToLockOrbitZUp = theToForceUp; }

27

//! 返回TRUE如果启用通过双触控手势进行Z轴旋转;默认为FALSE。
bool ToAllowTouchZRotation() const { return myToAllowTouchZRotation; }

28

//! 设置是否启用通过双触控手势进行Z轴旋转。
void SetAllowTouchZRotation(bool theToEnable) { myToAllowTouchZRotation = theToEnable; }

29

//! 返回TRUE如果允许相机旋转;默认为TRUE。
bool ToAllowRotation() const { return myToAllowRotation; }

30

//! 设置是否允许相机旋转。
void SetAllowRotation(bool theToEnable) { myToAllowRotation = theToEnable; }

31

//! 返回TRUE如果允许平移;默认为TRUE。
bool ToAllowPanning() const { return myToAllowPanning; }

32

//! 设置是否允许平移。
void SetAllowPanning(bool theToEnable) { myToAllowPanning = theToEnable; }

33

//! 返回TRUE如果允许缩放;默认为TRUE。
bool ToAllowZooming() const { return myToAllowZooming; }

34

//! 设置是否允许缩放。
void SetAllowZooming(bool theToEnable) { myToAllowZooming = theToEnable; }

35

//! 返回TRUE如果允许ZFocus更改;默认为TRUE。
bool ToAllowZFocus() const { return myToAllowZFocus; }

36

//! 设置是否允许ZFocus更改。
void SetAllowZFocus(bool theToEnable) { myToAllowZFocus = theToEnable; }

37

//! 返回TRUE如果允许鼠标移动时动态高亮显示;默认为TRUE。
bool ToAllowHighlight() const { return myToAllowHighlight; }

38

//! 设置是否允许鼠标移动时动态高亮显示。
void SetAllowHighlight(bool theToEnable) { myToAllowHighlight = theToEnable; }

39

//! 返回TRUE如果允许拖拽对象;默认为TRUE。
bool ToAllowDragging() const { return myToAllowDragging; }

40

//! 设置是否允许拖拽对象。
void SetAllowDragging(bool theToEnable) { myToAllowDragging = theToEnable; }

41

//! 返回TRUE如果在缩放到点时应将选取点投影到拾取射线上;默认为TRUE。
bool ToStickToRayOnZoom() const { return myToStickToRayOnZoom; }

42

//! 设置在缩放到点时是否应将选取点投影到拾取射线上。
void SetStickToRayOnZoom(bool theToEnable) { myToStickToRayOnZoom = theToEnable; }

43

//! 返回TRUE如果在围绕点旋转时应将选取点投影到拾取射线上;默认为TRUE。
bool ToStickToRayOnRotation() const { return myToStickToRayOnRotation; }

44

//! 设置在围绕点旋转时是否应将选取点投影到拾取射线上。
void SetStickToRayOnRotation(bool theToEnable) { myToStickToRayOnRotation = theToEnable; }

45

//! 返回TRUE如果在处理Aspect_VKey_NavLookUp/Aspect_VKey_NavLookDown时应反转俯仰方向;默认为FALSE。
bool ToInvertPitch() const { return myToInvertPitch; }

46

//! 设置是否反转俯仰方向。
void SetInvertPitch(bool theToInvert) { myToInvertPitch = theToInvert; }

47

//! 返回正常步行速度,单位为米/秒;默认为1.5。
float WalkSpeedAbsolute() const { return myWalkSpeedAbsolute; }

48

//! 设置正常步行速度,单位为米/秒;默认为1.5。
void SetWalkSpeedAbsolute(float theSpeed) { myWalkSpeedAbsolute = theSpeed; }

49

//! 返回相对于场景包围盒的步行速度比率;默认为0.1。
float WalkSpeedRelative() const { return myWalkSpeedRelative; }

50

//! 设置相对于场景包围盒的步行速度比率。
void SetWalkSpeedRelative(float theFactor) { myWalkSpeedRelative = theFactor; }

51

//! 返回活动推力值;默认为0.0。
float ThrustSpeed() const { return myThrustSpeed; }

52

//! 设置活动推力值。
void SetThrustSpeed(float theSpeed);
//! 返回TRUE如果先前已定义MoveTo的前一个位置。
bool HasPreviousMoveTo() const { return myPrevMoveTo != Graphic3d_Vec2i(-1); }

53

//! 返回3D查看器中MoveTo事件的前一个位置。
const Graphic3d_Vec2i& PreviousMoveTo() const { return myPrevMoveTo; }

54

//! 重置MoveTo的前一个位置。
void ResetPreviousMoveTo() { myPrevMoveTo = Graphic3d_Vec2i(-1); }

55

//! 返回TRUE以显示辅助跟踪的XR设备(如跟踪站)。
bool ToDisplayXRAuxDevices() const { return myToDisplayXRAuxDevices; }

56

//! 设置是否应显示辅助跟踪的XR设备。
void SetDisplayXRAuxDevices(bool theToDisplay) { myToDisplayXRAuxDevices = theToDisplay; }

57

//! 返回TRUE以显示XR手柄。
bool ToDisplayXRHands() const { return myToDisplayXRHands; }

58

//! 设置是否应显示XR手柄。
void SetDisplayXRHands(bool theToDisplay) { myToDisplayXRHands = theToDisplay; }

键盘输入
59

using Aspect_WindowInputListener::Keys;
using Aspect_WindowInputListener::ChangeKeys;

60

//! 按下按键。
//! 默认实现更新内部缓存。
//! @param theKey 按下的按键
//! @param theTime 事件时间戳
Standard_EXPORT virtual void KeyDown (Aspect_VKey theKey,
double theTime,
double thePressure = 1.0) Standard_OVERRIDE;

61

//! 松开按键。
//! 默认实现更新内部缓存。
//! @param theKey 按下的按键
//! @param theTime 事件时间戳
Standard_EXPORT virtual void KeyUp (Aspect_VKey theKey,
double theTime) Standard_OVERRIDE;

62

//! 根据轴值模拟按键的按下/松开事件。
//! 默认实现更新内部缓存。
Standard_EXPORT virtual void KeyFromAxis (Aspect_VKey theNegative,
Aspect_VKey thePositive,
double theTime,
double thePressure) Standard_OVERRIDE;

63

//! 获取活动的导航动作。
Standard_EXPORT AIS_WalkDelta FetchNavigationKeys (Standard_Real theCrouchRatio,
Standard_Real theRunRatio);

鼠标输入
64

//! 返回定义鼠标手势的映射。
const AIS_MouseGestureMap& MouseGestureMap() const { return myMouseGestureMap; }

65

//! 返回定义鼠标手势的映射。
AIS_MouseGestureMap& ChangeMouseGestureMap() { return myMouseGestureMap; }

66

//! 返回定义鼠标选择方案的映射。
const AIS_MouseSelectionSchemeMap& MouseSelectionSchemes() const { return myMouseSelectionSchemes; }

67

//! 返回定义鼠标选择方案的映射。
AIS_MouseSelectionSchemeMap& ChangeMouseSelectionSchemes() { return myMouseSelectionSchemes; }

68

//! 返回双击间隔时间(秒),默认为0.4秒。
double MouseDoubleClickInterval() const { return myMouseDoubleClickInt; }

69

//! 设置双击间隔时间(秒)。
void SetMouseDoubleClickInterval(double theSeconds) { myMouseDoubleClickInt = theSeconds; }

70

//! 在3D视图中执行选择操作。
//! 预期该方法从UI线程调用。
//! @param thePnt 拾取点
//! @param theScheme 选择方案
Standard_EXPORT virtual void SelectInViewer(const Graphic3d_Vec2i& thePnt,
const AIS_SelectionScheme theScheme = AIS_SelectionScheme_Replace);

71

//! 在3D视图中执行选择操作。
//! 预期该方法从UI线程调用。
//! @param thePnts 拾取点序列
//! @param theScheme 选择方案
Standard_EXPORT virtual void SelectInViewer(const NCollection_Sequence<Graphic3d_Vec2i>& thePnts,
const AIS_SelectionScheme theScheme = AIS_SelectionScheme_Replace);

72

//! 更新矩形选择工具。
//! 预期该方法从UI线程调用。
//! @param thePntFrom 矩形的第一个角点
//! @param thePntTo 矩形的另一个角点
Standard_EXPORT virtual void UpdateRubberBand(const Graphic3d_Vec2i& thePntFrom,
const Graphic3d_Vec2i& thePntTo);

73

//! 更新多边形选择工具。
//! 预期该方法从UI线程调用。
//! @param thePnt 新添加到多边形中的点
//! @param theToAppend 是否添加新点或更新最后一个点
Standard_EXPORT virtual void UpdatePolySelection(const Graphic3d_Vec2i& thePnt,
bool theToAppend);

//! 更新缩放事件(例如来自鼠标滚轮)。
//! 预期该方法从UI线程调用。
//! @param theDelta 鼠标光标位置和缩放增量
//! @return 如果创建了新的缩放事件则返回TRUE,如果更新了现有事件则返回FALSE
Standard_EXPORT virtual bool UpdateZoom(const Aspect_ScrollDelta& theDelta);

74

//! 更新Z轴旋转事件。
//! @param theAngle 旋转角度,以弧度为单位。
//! @return 如果创建了新的旋转事件则返回TRUE,如果更新了现有事件则返回FALSE
Standard_EXPORT virtual bool UpdateZRotation(double theAngle);

75

//! 更新鼠标滚轮事件;默认重定向到UpdateZoom。
//! 预期该方法从UI线程调用。
//! @param theDelta 鼠标光标位置和增量
//! @return 如果创建了新事件则返回TRUE,如果更新了现有事件则返回FALSE
Standard_EXPORT virtual bool UpdateMouseScroll(const Aspect_ScrollDelta& theDelta) Standard_OVERRIDE;

76

//! 处理鼠标按钮按下/释放事件。
//! 预期该方法从UI线程调用。
//! @param thePoint 鼠标光标位置
//! @param theButtons 按下的按钮
//! @param theModifiers 按键修饰符
//! @param theIsEmulated 如果为TRUE,则鼠标事件不是来自真实鼠标,而是来自触摸等非精确输入的仿真
//! @return 如果应重绘视图则返回TRUE
Standard_EXPORT virtual bool UpdateMouseButtons(const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButtons,
Aspect_VKeyFlags theModifiers,
bool theIsEmulated) Standard_OVERRIDE;

77

//! 处理鼠标移动事件。
//! 预期该方法从UI线程调用。
//! @param thePoint 鼠标光标位置
//! @param theButtons 按下的按钮
//! @param theModifiers 按键修饰符
//! @param theIsEmulated 如果为TRUE,则鼠标事件不是来自真实鼠标,而是来自触摸等非精确输入的仿真
//! @return 如果应重绘视图则返回TRUE
Standard_EXPORT virtual bool UpdateMousePosition(const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButtons,
Aspect_VKeyFlags theModifiers,
bool theIsEmulated) Standard_OVERRIDE;

78

//! 处理鼠标点击事件(由UpdateMouseButtons()仿真单击释放按钮)。
//! 注意,由于该方法由UpdateMouseButtons()调用,因此应在UI线程中执行。
//! 默认实现重定向到SelectInViewer()。
//! 预期该方法从UI线程调用。
//! @param thePoint 鼠标光标位置
//! @param theButton 点击的按钮
//! @param theModifiers 按键修饰符
//! @param theIsDoubleClick 标志指示是否双击鼠标
//! @return 如果应重绘视图则返回TRUE
Standard_EXPORT virtual bool UpdateMouseClick(const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButton,
Aspect_VKeyFlags theModifiers,
bool theIsDoubleClick);

using Aspect_WindowInputListener::PressMouseButton;
using Aspect_WindowInputListener::ReleaseMouseButton;

using Aspect_WindowInputListener::PressedMouseButtons;
using Aspect_WindowInputListener::LastMouseFlags;
using Aspect_WindowInputListener::LastMousePosition;

多点触控输入
79

//! 返回调整多点触控手势起始容差的比例因子;默认为1.0。
//! 该比例因子预期从触摸屏分辨率计算得出。
float TouchToleranceScale() const { return myTouchToleranceScale; }

//! 设置调整多点触控手势起始容差的比例因子。
void SetTouchToleranceScale(float theTolerance) { myTouchToleranceScale = theTolerance; }

80

//! 添加具有给定ID的触摸点。
//! 预期该方法从UI线程调用。
//! @param theId 触摸唯一标识符
//! @param thePnt 触摸坐标
//! @param theClearBefore 如果为TRUE,则会清除之前注册的触摸点
Standard_EXPORT virtual void AddTouchPoint(Standard_Size theId,
const Graphic3d_Vec2d& thePnt,
Standard_Boolean theClearBefore = false) Standard_OVERRIDE;

81

//! 移除具有给定ID的触摸点。
//! 预期该方法从UI线程调用。
//! @param theId 触摸唯一标识符
//! @param theClearSelectPnts 如果为TRUE,则将启动清除选择点
//! @return 如果点已被移除则返回TRUE
Standard_EXPORT virtual bool RemoveTouchPoint(Standard_Size theId,
Standard_Boolean theClearSelectPnts = false) Standard_OVERRIDE;

82

//! 更新具有给定ID的触摸点。
//! 如果之前未注册具有指定ID的点,则会将其添加。
//! 预期该方法从UI线程调用。
//! @param theId 触摸唯一标识符
//! @param thePnt 触摸坐标
Standard_EXPORT virtual void UpdateTouchPoint(Standard_Size theId,
const Graphic3d_Vec2d& thePnt) Standard_OVERRIDE;

using Aspect_WindowInputListener::HasTouchPoints;

3D鼠标输入
83

//! 处理3D鼠标输入事件(重定向到平移、旋转和键)。
Standard_EXPORT virtual bool Update3dMouse(const WNT_HIDSpaceMouse& theEvent) Standard_OVERRIDE;

调整大小事件
84

//! 处理暴露事件(窗口内容已失效并应重绘)。
//! 默认实现不执行任何操作。
virtual void ProcessExpose() Standard_OVERRIDE {}

85

//! 处理窗口调整大小事件。
//! 默认实现不执行任何操作。
virtual void ProcessConfigure(bool theIsResized) Standard_OVERRIDE
{
(void)theIsResized;
}

86

//! 处理窗口输入事件立即。
//! 默认实现不执行任何操作 - 输入事件累积在内部缓冲区中,直到显式调用FlushViewEvents()为止。
virtual void ProcessInput() Standard_OVERRIDE {}

87

//! 处理焦点事件。
//! 默认实现重置缓存的输入状态(按下的按键)。
virtual void ProcessFocus(bool theIsActivated) Standard_OVERRIDE
{
if (!theIsActivated)
{
ResetViewInput();
}
}

88

//! 处理窗口关闭事件。
//! 默认实现不执行任何操作。
virtual void ProcessClose() Standard_OVERRIDE {}
public:

using Aspect_WindowInputListener::EventTime;

89

//! 重置输入状态(按下的按键、鼠标按钮等),例如在窗口失去焦点时调用。
//! 预期该方法从UI线程调用。
Standard_EXPORT virtual void ResetViewInput();

90

//! 重置视图方向。
//! 预期该方法从UI线程调用。
Standard_EXPORT virtual void UpdateViewOrientation(V3d_TypeOfOrientation theOrientation,
bool theToFitAll);

91

//! 更新用于渲染线程的缓冲区。
//! 预期在GUI线程和渲染线程之间的同步屏障中调用(例如,应先锁定GUI线程以避免数据竞争)。
//! @param theCtx 交互上下文
//! @param theView 激活的视图
//! @param theToHandle 如果为TRUE,则调用HandleViewEvents()
Standard_EXPORT virtual void FlushViewEvents(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
Standard_Boolean theToHandle = Standard_False);

92

//! 在渲染线程内处理事件。
Standard_EXPORT virtual void HandleViewEvents(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

93

//! 3D视图中选择发生变化时handleMoveTo()回调。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void OnSelectionChanged(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

94

//! 在3D视图中拖动对象时handleMoveTo()回调。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void OnObjectDragged(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
AIS_DragAction theAction);

95

//! 在HandleViewEvents()中选择另一个(子)视图时回调。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void OnSubviewChanged(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theOldView,
const Handle(V3d_View)& theNewView);

96

//! 在鼠标光标下选择最近的点。
//! 预期从渲染线程调用。
//! @param thePnt [out] 结果点
//! @param theCtx [in] 交互上下文
//! @param theView [in] 激活视图
//! @param theCursor [in] 鼠标光标
//! @param theToStickToPickRay [in] 当为TRUE时,结果点将位于拾取射线上
//! @return 如果找到结果则返回TRUE
Standard_EXPORT virtual bool PickPoint(gp_Pnt& thePnt,
const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const Graphic3d_Vec2i& theCursor,
bool theToStickToPickRay);

97

//! 根据轴选择最近的点。
//! 预期从渲染线程调用。
//! @param theTopPnt [out] 结果点
//! @param theCtx [in] 交互上下文
//! @param theView [in] 激活视图
//! @param theAxis [in] 选择轴
//! @return 如果找到结果则返回TRUE
Standard_EXPORT virtual bool PickAxis(gp_Pnt& theTopPnt,
const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const gp_Ax1& theAxis);

98

//! 根据旋转模式计算旋转重心点。
//! 预期从渲染线程调用。
Standard_EXPORT virtual gp_Pnt GravityPoint(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

99

//! 修改视图相机以适合所有对象。
//! 默认实现交替适合所有可见和所有选定的对象(每次调用都会交换)。
Standard_EXPORT virtual void FitAllAuto(const Handle(AIS_InteractiveContext)& theCtx,
//! 处理定义新相机方向的热键(例如 Aspect_VKey_ViewTop 和类似键)。
//! 默认实现在按下特定动作键时从当前相机方向开始到目标相机方向的动画事务。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void handleViewOrientationKeys(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

100

//! 执行导航操作(例如 Aspect_VKey_NavForward 和类似键)。
//! 预期从渲染线程调用。
Standard_EXPORT virtual AIS_WalkDelta handleNavigationKeys(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

101

//! 在手势进度中执行即时相机操作(旋转/缩放/平移)。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void handleCameraActions(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const AIS_WalkDelta& theWalk);

102

//! 执行moveTo/选择/拖动。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void handleMoveTo(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

103

//! 如果希望在此帧后绘制另一帧,则返回TRUE。
bool toAskNextFrame() const { return myToAskNextFrame; }

104

//! 设置是否在此帧后绘制另一帧。
void setAskNextFrame(bool theToDraw = true) { myToAskNextFrame = theToDraw; }

105

//! 如果定义了平移锚点,则返回TRUE。
bool hasPanningAnchorPoint() const { return !Precision::IsInfinite(myPanPnt3d.X()); }

107

//! 返回活动的平移锚点。
const gp_Pnt& panningAnchorPoint() const { return myPanPnt3d; }

108

//! 设置活动的平移锚点。
void setPanningAnchorPoint(const gp_Pnt& thePnt) { myPanPnt3d = thePnt; }

109

//! 处理平移事件 myGL.Panning。
Standard_EXPORT virtual void handlePanning(const Handle(V3d_View)& theView);

110

//! 处理Z轴旋转事件 myGL.ZRotate。
Standard_EXPORT virtual void handleZRotate(const Handle(V3d_View)& theView);

111

//! 返回用于缩放操作的最小相机距离。
double MinZoomDistance() const { return myMinCamDistance; }

112

//! 设置用于缩放操作的最小相机距离。
void SetMinZoomDistance(double theDist) { myMinCamDistance = theDist; }

113

//! 处理缩放事件 myGL.ZoomActions。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void handleZoom(const Handle(V3d_View)& theView,
const Aspect_ScrollDelta& theParams,
const gp_Pnt* thePnt);

114

//! 处理Z轴滚动事件 myGL.ZoomActions。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void handleZFocusScroll(const Handle(V3d_View)& theView,
const Aspect_ScrollDelta& theParams);

115

//! 处理轨道旋转事件 myGL.OrbitRotation。
//! @param theView 要修改的视图
//! @param thePnt 围绕旋转的3D点
//! @param theToLockZUp 修改相机以排除滚动角度(将相机上向量放置在包含全局Z和视图方向的平面上)
Standard_EXPORT virtual void handleOrbitRotation(const Handle(V3d_View)& theView,
const gp_Pnt& thePnt,
bool theToLockZUp);

116

//! 处理视图方向旋转事件 myGL.ViewRotation。
//! 预期从渲染线程调用。
//! @param theView 要修改的相机
//! @param theYawExtra 额外的偏航增量
//! @param thePitchExtra 额外的俯仰增量
//! @param theRoll 滚动值
//! @param theToRestartOnIncrement 表示飞行模式的标志
Standard_EXPORT virtual void handleViewRotation(const Handle(V3d_View)& theView,
double theYawExtra,
double thePitchExtra,
double theRoll,
bool theToRestartOnIncrement);

117

//! 处理视图重绘。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void handleViewRedraw(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

118

//! 执行XR输入。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void handleXRInput(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const AIS_WalkDelta& theWalk);

119

//! 处理触控板视图旋转操作。
Standard_EXPORT virtual void handleXRTurnPad(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

120

//! 处理触控板传送动作。
Standard_EXPORT virtual void handleXRTeleport(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

121

//! 处理扳机点击选取。
Standard_EXPORT virtual void handleXRPicking(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

122

//! 为活动手指执行动态高亮显示。
Standard_EXPORT virtual void handleXRHighlight(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

123

//! 显示辅助XR演示。
Standard_EXPORT virtual void handleXRPresentations(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

124

//! 使用/不使用XR姿态执行选取和动态高亮显示。
Standard_EXPORT virtual Standard_Integer handleXRMoveTo(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const gp_Trsf& thePose,
const Standard_Boolean theToHighlight);

protected

//! 刷新缓冲区。
Standard_EXPORT virtual void flushBuffers(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

//! 刷新触摸手势。
Standard_EXPORT virtual void flushGestures(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

//! 返回当前和先前获取的事件时间。
//! 此回调用于计算连续处理事件之间的时间差。
//! @param thePrevTime [out] 先前由该方法获取的事件时间
//! @param theCurrTime [out] 当前事件时间
void updateEventsTime(double& thePrevTime,
double& theCurrTime)
{
thePrevTime = myLastEventsTime;
myLastEventsTime = EventTime();
theCurrTime = myLastEventsTime;
}

//! 执行鼠标点击选择。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void handleSelectionPick(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

//! 在鼠标移动时执行动态高亮显示。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void handleDynamicHighlight(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

//! 执行橡皮筋选择。
//! 预期从渲染线程调用。
Standard_EXPORT virtual void handleSelectionPoly(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);

//! 延迟AIS_InteractiveContext::MoveTo(),检查myPrevMoveTo。
Standard_EXPORT virtual void contextLazyMoveTo(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const Graphic3d_Vec2i& thePnt);

protected:

AIS_ViewInputBuffer myUI; //!< UI线程缓冲区
AIS_ViewInputBuffer myGL; //!< 渲染线程缓冲区

Standard_Real myLastEventsTime; //!< 计算增量和进度的最后获取的事件计时器值
Standard_Boolean myToAskNextFrame; //!< 表示在此帧后应绘制另一帧的标志
Standard_Boolean myIsContinuousRedraw; //!< 连续重绘(没有立即渲染优化)

Standard_Real myMinCamDistance; //!< 缩放操作的最小相机距离
AIS_RotationMode myRotationMode; //!< 旋转模式
AIS_NavigationMode myNavigationMode; //!< 导航模式(轨道旋转 / 第一人称)
Standard_ShortReal myMouseAccel; //!< 第一人称模式下的鼠标输入加速比率
Standard_ShortReal myOrbitAccel; //!< 轨道旋转加速比率
Standard_Boolean myToShowPanAnchorPoint; //!< 显示平移锚点选项
Standard_Boolean myToShowRotateCenter; //!< 显示旋转中心点选项
Standard_Boolean myToLockOrbitZUp; //!< 在AIS_NavigationMode_Orbit旋转模式中强制相机朝上方向
Standard_Boolean myToInvertPitch; //!< 处理Aspect_VKey_NavLookUp/Aspect_VKey_NavLookDown时反转俯仰方向的标志
Standard_Boolean myToAllowTouchZRotation; //!< 启用双触摸手势的Z轴旋转;默认为FALSE
Standard_Boolean myToAllowRotation; //!< 启用旋转;默认为TRUE
Standard_Boolean myToAllowPanning; //!< 启用平移;默认为TRUE
Standard_Boolean myToAllowZooming; //!< 启用缩放;默认为TRUE
Standard_Boolean myToAllowZFocus; //!< 启用ZFocus更改;默认为TRUE
Standard_Boolean myToAllowHighlight; //!< 在鼠标移动时启用动态高亮显示;默认为TRUE
Standard_Boolean myToAllowDragging; //!< 启用拖动对象;默认为TRUE
Standard_Boolean myToStickToRayOnZoom; //!< 在缩放时将选择的点投射到射线上;默认为TRUE
Standard_Boolean myToStickToRayOnRotation; //!< 在围绕点旋转时将选择的点投射到射线上;默认为TRUE

Standard_ShortReal myWalkSpeedAbsolute; //!< 正常步行速度,单位为m/s;默认为1.5
Standard_ShortReal myWalkSpeedRelative; //!< 相对于场景包围盒的步行速度;默认为0.1
Standard_ShortReal myThrustSpeed; //!< 活动推力值
Standard_Boolean myHasThrust; //!< 指示活动推力的标志

Handle(AIS_AnimationCamera) myViewAnimation; //!< 视图动画
Handle(AIS_Animation) myObjAnimation; //!< 对象动画
Standard_Boolean myToPauseObjAnimation; //!< 暂停鼠标单击时的对象动画的标志;默认为FALSE
Handle(AIS_RubberBand) myRubberBand; //!< 橡皮筋呈现
Handle(SelectMgr_EntityOwner) myDragOwner; //!< 当前拖动对象的检测到的所有者
Handle(AIS_InteractiveObject) myDragObject; //!< 当前拖动对象
Graphic3d_Vec2i myPrevMoveTo; //!< 3D查看器中MoveTo事件的上一个位置
Standard_Boolean myHasHlrOnBeforeRotation; //!< 旋转后恢复计算模式的标志

protected: //! @name XR输入变量

NCollection_Array1<Handle(AIS_XRTrackedDevice)> myXRPrsDevices; //!< XR跟踪设备呈现数组
Quantity_Color myXRLaserTeleColor; //!< 传送激光的颜色
Quantity_Color myXRLaserPickColor; //!< 选择激光的颜色
Aspect_XRTrackedDeviceRole myXRLastTeleportHand;//!< 传送的活动手
Aspect_XRTrackedDeviceRole myXRLastPickingHand; //!< 选择对象的活动手
Aspect_XRHapticActionData myXRTeleportHaptic; //!< 选取传送目标时的震动
Aspect_XRHapticActionData myXRPickingHaptic; //!< 动
参考

  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值