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; //!< 动
参考
相关文章:

opencascade AIS_ViewController源码学习 视图控制、包含鼠标事件等
opencascade AIS_ViewController 前言 用于在GUI和渲染线程之间处理视图器事件的辅助结构。 该类实现了以下功能: 缓存存储用户输入状态(鼠标、触摸和键盘)。 将鼠标/多点触控输入映射到视图相机操作(平移、旋转、缩放࿰…...

拉削基础知识——拉床的类型及特点
拉床是所有机械加工工具中最简单的一种,由拉削工具、夹具、驱动装置和支撑架组成。拉削加工可获得较高的尺寸精度和较小的表面粗糙度,生产率较高,适用于大批量生产。拉床按其结构主要分为卧式和立式。应用领域和功能可分为液压拉床、自动拉床…...
docker-compose笔记
docker 目前docker官网已经无法登录,但是还可以从清华镜像站(https://mirrors.tuna.tsinghua.edu.cn/docker-ce/)下载。 使用方法可以参考早期文章《docker笔记》 docker-compose 可以从Github下载不同版本的二进制文件,例如do…...

C# 自定义控件无法加载
问题 在做winform开发时自己定义了一个控件,控件在工具箱中显示了,但是拖动到窗体设计器时会提示未能加载工具箱项xxx,将从工具箱中将其删除,如下图所示: 点击确定后,控件会从工具箱中移除。 解决方法 将 生成>…...

avl树自实现(带图),探讨平衡因子与旋转
引子: 在此之前,我们学过了搜索二叉树,这种树,在如果数据有序或接近有序的情况下,二叉搜索树将退化为单支树,查找元素相当于在顺序表中搜索元素,效率低下,而且普通搜索二叉树无法有…...

Elasticsearch 的DSL查询,聚合查询与多维度数据统计
文章目录 搜索聚合高阶概念 搜索 即从一个索引下按照特定的字段或关键词搜索出符合用户预期的一个或者一堆cocument,然后根据文档的相关度得分,在返回的结果集里并根据得分对这些文档进行一定的排序。 聚合 根据业务需求,对文档中的某个或…...

【如何高效处理前端常见问题:策略与实践】
在快速发展的Web开发领域,前端作为用户与应用程序直接交互的界面,其重要性不言而喻。然而,随着技术的不断演进和项目的复杂化,前端开发者在日常工作中难免会遇到各种挑战和问题。本文旨在深入探讨前端开发中常见的问题类型&#x…...

聊聊前端 JavaScript 的扩展运算符 “...“ 的使用场景
前言 在 JavaScript 中,... 被称为 “扩展运算符” 或 “剩余参数运算符”。 扩展运算符是在 ES6(ECMAScript 2015)中被引入的,目的是为了提高语言的表达能力和代码的可读性。 根据上下文不同,它主要用在数组、对象…...

华为续签了,但我准备离职了
离职华为 今天在牛客网看到一篇帖子,名为《华为续签了,但我准备离职了》。 讲得挺真诚,可能也是一类毕业进华为的同学的心声。 贴主提到,当年自己还是应届毕业的时候,手握多个 offer,最终选的华为ÿ…...
RocketMQ 的认证与授权机制
Apache RocketMQ 是一个高性能、高吞吐量、分布式的消息中间件,广泛应用于异步通信、应用解耦、流量削峰等场景。在企业级应用中,消息安全尤为重要,本文将深入探讨 RocketMQ 的认证与授权机制,帮助开发者和系统管理员更好地理解和…...

【设计模式】六大原则-上
首先什么是设计模式? 相信刚上大学的你和我一样,在学习这门课的时候根本不了解这些设计原则和模式有什么用处,反而不如隔壁的C更有意思,至少还能弹出一个小黑框,给我个hello world。 如何你和我一样也是这么想…...

CRC16循环冗余校验
代码: #include<stdio.h> #include <stdint.h>#define uchar unsigned char #define uint unsigned int static const uint8_t auchCRCHi[] { 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x0…...

Mysql80主从复制搭建;遇到问题 Slave_IO_Running: Connecting和Slave_SQL_Running以及解决过程
总结主要步骤 1.配置一个提供复制的账号; 创建用户 CREATE USER replication% IDENTIFIED BY your_password; GRANT REPLICATION SLAVE ON *.* TO replication%; FLUSH PRIVILEGES;2.修改配置 选择模式 主库配置; windows的得话是my.ini文件 默认这个目…...
Yarn网络代理配置指南:在受限网络环境中优化依赖管理
Yarn是一个现代的包管理器,用于JavaScript项目,它提供了快速、可靠和安全的依赖管理方式。然而,在某些受限的网络环境中,例如公司内网或某些国家地区,直接连接到公共npm仓库可能不可行或效率低下。这时,配置…...

AOE网及其求解关键路径
全称 Activity on Edge Network 边活动网 特点 仅存在 有向无环图 作用 用于记录完成整个工程至少花费的时间 > 哪条路径最耗时?也就是“ 关键路径 ” AOE网元素介绍 关键活动 关键路径上的活动称为关键活动 , 关键活动是不允许拖延的&#x…...
【FPGA】modelsim编译verilog代码产生错误集合
错误1: LHS in procedural continuous assignment may not be a net 可能是一些变量不能放在一些begin和end中,改下assign的位置 新手求助 LHS in procedural continuous assignment may not be a net - 数字IC设计讨论(IC前端|FPGA|ASIC) - EETOP 创…...

Rabbitmq的持久化机制
我们通过手动应答处理了在消费者出故障消息丢失的情况,但是如何保障当 RabbitMQ 服务停掉以后消息生产者发送过来的消息不丢失。默认情况下 RabbitMQ 退出或由于某种原因崩溃时,它会清空队列和消息,除非告知它不要这样做。确保消息不会丢失可…...

Unity UnityWebRequest封装类
简化api调用流程,非常奈斯。 RestWebClient.cs using System; using System.Collections; using UnityEngine; using UnityEngine.Networking;namespace MYTOOL.RestClient {/// <summary>/// UnityWebRequest封装类/// </summary>public class RestW…...
JVM内存划分
Java虚拟机(JVM)的内存划分是指JVM在运行时所使用的内存区域的组织和管理方式。JVM内存主要分为以下几个区域: 堆区(Heap): 用途:用于存储所有对象实例和数组,是JVM中最大的一块内存…...
c++ 全排列
在C中,全排列(permutation)可以使用递归算法或标准库函数来实现。以下是使用递归和STL库std::next_permutation来生成一个集合的全排列的两种方法。 方法一:递归算法 递归方法通过交换元素来生成所有可能的排列组合。 #include…...
设计模式和设计原则回顾
设计模式和设计原则回顾 23种设计模式是设计原则的完美体现,设计原则设计原则是设计模式的理论基石, 设计模式 在经典的设计模式分类中(如《设计模式:可复用面向对象软件的基础》一书中),总共有23种设计模式,分为三大类: 一、创建型模式(5种) 1. 单例模式(Sing…...

MFC内存泄露
1、泄露代码示例 void X::SetApplicationBtn() {CMFCRibbonApplicationButton* pBtn GetApplicationButton();// 获取 Ribbon Bar 指针// 创建自定义按钮CCustomRibbonAppButton* pCustomButton new CCustomRibbonAppButton();pCustomButton->SetImage(IDB_BITMAP_Jdp26)…...

DIY|Mac 搭建 ESP-IDF 开发环境及编译小智 AI
前一阵子在百度 AI 开发者大会上,看到基于小智 AI DIY 玩具的演示,感觉有点意思,想着自己也来试试。 如果只是想烧录现成的固件,乐鑫官方除了提供了 Windows 版本的 Flash 下载工具 之外,还提供了基于网页版的 ESP LA…...

Psychopy音频的使用
Psychopy音频的使用 本文主要解决以下问题: 指定音频引擎与设备;播放音频文件 本文所使用的环境: Python3.10 numpy2.2.6 psychopy2025.1.1 psychtoolbox3.0.19.14 一、音频配置 Psychopy文档链接为Sound - for audio playback — Psy…...
解决本地部署 SmolVLM2 大语言模型运行 flash-attn 报错
出现的问题 安装 flash-attn 会一直卡在 build 那一步或者运行报错 解决办法 是因为你安装的 flash-attn 版本没有对应上,所以报错,到 https://github.com/Dao-AILab/flash-attention/releases 下载对应版本,cu、torch、cp 的版本一定要对…...
CRMEB 框架中 PHP 上传扩展开发:涵盖本地上传及阿里云 OSS、腾讯云 COS、七牛云
目前已有本地上传、阿里云OSS上传、腾讯云COS上传、七牛云上传扩展 扩展入口文件 文件目录 crmeb\services\upload\Upload.php namespace crmeb\services\upload;use crmeb\basic\BaseManager; use think\facade\Config;/*** Class Upload* package crmeb\services\upload* …...

IoT/HCIP实验-3/LiteOS操作系统内核实验(任务、内存、信号量、CMSIS..)
文章目录 概述HelloWorld 工程C/C配置编译器主配置Makefile脚本烧录器主配置运行结果程序调用栈 任务管理实验实验结果osal 系统适配层osal_task_create 其他实验实验源码内存管理实验互斥锁实验信号量实验 CMISIS接口实验还是得JlINKCMSIS 简介LiteOS->CMSIS任务间消息交互…...
【学习笔记】深入理解Java虚拟机学习笔记——第4章 虚拟机性能监控,故障处理工具
第2章 虚拟机性能监控,故障处理工具 4.1 概述 略 4.2 基础故障处理工具 4.2.1 jps:虚拟机进程状况工具 命令:jps [options] [hostid] 功能:本地虚拟机进程显示进程ID(与ps相同),可同时显示主类&#x…...
08. C#入门系列【类的基本概念】:开启编程世界的奇妙冒险
C#入门系列【类的基本概念】:开启编程世界的奇妙冒险 嘿,各位编程小白探险家!欢迎来到 C# 的奇幻大陆!今天咱们要深入探索这片大陆上至关重要的 “建筑”—— 类!别害怕,跟着我,保准让你轻松搞…...
【Nginx】使用 Nginx+Lua 实现基于 IP 的访问频率限制
使用 NginxLua 实现基于 IP 的访问频率限制 在高并发场景下,限制某个 IP 的访问频率是非常重要的,可以有效防止恶意攻击或错误配置导致的服务宕机。以下是一个详细的实现方案,使用 Nginx 和 Lua 脚本结合 Redis 来实现基于 IP 的访问频率限制…...