ActiViz实战:鼠标交互和vtkCommand的问题

news2024/11/25 7:43:59

文章目录

  • 前言
  • 一、消失的vtkCallbackCommand
  • 二、自定义命令vtkCommand
    • 1、自定义一个左键双击事件的命令
    • 2、使用观察者/命令模式
    • 3、结果
  • 三、vtkObject类中的事件
    • 1、vtkCommand中所有的事件
    • 2、鼠标事件测试
    • 3、如何添加左键的双击事件
  • 四、总结


前言

在C++的VTK中,我们常用vtkCallbackCommand来触发回调,利用观察者/命令模式,实现vtkCommand中的事件。


一、消失的vtkCallbackCommand

1、在ActiViz 9.3版本中,vtkCallbackCommand类已经消失了。在源码和官方示例中,到处都找不到vtkCallbackCommand的身影。
2、在ActiViz 9.3版本中,与vtkCallbackCommand一起消失的还有vtkOldStyleCallbackCommand,以及观察者/命令模式的使用。

二、自定义命令vtkCommand

1、自定义一个左键双击事件的命令

示例代码

 public class LeftButtonDoubleClickCommand : vtkCommand
 {
     public LeftButtonDoubleClickCommand() : base(IntPtr.Zero, false, false)
     {
     }

     public override void Execute(vtkObject caller, uint eventId, IntPtr callData)
     {
         base.Execute(caller, eventId, callData);
         MessageBox.Show("鼠标双击了!");
     }
 }

2、使用观察者/命令模式

 _renderWindow.AddObserver((uint)vtkCommand.EventIds.LeftButtonDoubleClickEvent, new LeftButtonDoubleClickCommand(), 1f);
 _renderWindow.Render();
  

3、结果

按照上述自定义命令,使用观察者/命令模式,大概率会得到以下结果:
在这里插入图片描述

三、vtkObject类中的事件

1、vtkCommand中所有的事件

/// <summary>enum member</summary>
AbortCheckEvent = 10,
/// <summary>enum member</summary>
ActiveCameraEvent = 29,
/// <summary>enum member</summary>
AnimationCueTickEvent = 59,
/// <summary>enum member</summary>
AnnotationChangedEvent = 78,
/// <summary>enum member</summary>
AnyEvent = 1,
/// <summary>enum member</summary>
Button3DEvent = 122,
/// <summary>enum member</summary>
CharEvent = 22,
/// <summary>enum member</summary>
Clip3DEvent = 132,
/// <summary>enum member</summary>
ComputeVisiblePropBoundsEvent = 84,
/// <summary>enum member</summary>
ConfigureEvent = 24,
/// <summary>enum member</summary>
ConnectionClosedEvent = 71,
/// <summary>enum member</summary>
ConnectionCreatedEvent = 70,
/// <summary>enum member</summary>
CreateCameraEvent = 30,
/// <summary>enum member</summary>
CreateTimerEvent = 48,
/// <summary>enum member</summary>
CurrentChangedEvent = 83,
/// <summary>enum member</summary>
CursorChangedEvent = 53,
/// <summary>enum member</summary>
DeleteEvent = 2,
/// <summary>enum member</summary>
DeletePointEvent = 51,
/// <summary>enum member</summary>
DestroyTimerEvent = 49,
/// <summary>enum member</summary>
DisableEvent = 47,
/// <summary>enum member</summary>
DomainModifiedEvent = 72,
/// <summary>enum member</summary>
DropFilesEvent = 42,
/// <summary>enum member</summary>
Elevation3DEvent = 136,
/// <summary>enum member</summary>
EnableEvent = 46,
/// <summary>enum member</summary>
EndAnimationCueEvent = 60,
/// <summary>enum member</summary>
EndEvent = 4,
/// <summary>enum member</summary>
EndInteractionEvent = 45,
/// <summary>enum member</summary>
EndPanEvent = 114,
/// <summary>enum member</summary>
EndPickEvent = 9,
/// <summary>enum member</summary>
EndPinchEvent = 108,
/// <summary>enum member</summary>
EndRotateEvent = 111,
/// <summary>enum member</summary>
EndSwipeEvent = 105,
/// <summary>enum member</summary>
EndWindowLevelEvent = 36,
/// <summary>enum member</summary>
EnterEvent = 18,
/// <summary>enum member</summary>
ErrorEvent = 39,
/// <summary>enum member</summary>
ExecuteInformationEvent = 54,
/// <summary>enum member</summary>
ExitEvent = 11,
/// <summary>enum member</summary>
ExposeEvent = 23,
/// <summary>enum member</summary>
FifthButtonPressEvent = 119,
/// <summary>enum member</summary>
FifthButtonReleaseEvent = 120,
/// <summary>enum member</summary>
FourthButtonPressEvent = 117,
/// <summary>enum member</summary>
FourthButtonReleaseEvent = 118,
/// <summary>enum member</summary>
HighlightEvent = 95,
/// <summary>enum member</summary>
HoverEvent = 88,
/// <summary>enum member</summary>
InteractionEvent = 44,
/// <summary>enum member</summary>
KeyPressEvent = 20,
/// <summary>enum member</summary>
KeyReleaseEvent = 21,
/// <summary>enum member</summary>
LeaveEvent = 19,
/// <summary>enum member</summary>
LeftButtonDoubleClickEvent = 124,
/// <summary>enum member</summary>
LeftButtonPressEvent = 12,
/// <summary>enum member</summary>
LeftButtonReleaseEvent = 13,
/// <summary>enum member</summary>
LoadStateEvent = 89,
/// <summary>enum member</summary>
LongTapEvent = 116,
/// <summary>enum member</summary>
Menu3DEvent = 130,
/// <summary>enum member</summary>
MessageEvent = 102,
/// <summary>enum member</summary>
MiddleButtonDoubleClickEvent = 125,
/// <summary>enum member</summary>
MiddleButtonPressEvent = 14,
/// <summary>enum member</summary>
MiddleButtonReleaseEvent = 15,
/// <summary>enum member</summary>
ModifiedEvent = 33,
/// <summary>enum member</summary>
MouseMoveEvent = 26,
/// <summary>enum member</summary>
MouseWheelBackwardEvent = 28,
/// <summary>enum member</summary>
MouseWheelForwardEvent = 27,
/// <summary>enum member</summary>
MouseWheelLeftEvent = 127,
/// <summary>enum member</summary>
MouseWheelRightEvent = 128,
/// <summary>enum member</summary>
Move3DEvent = 121,
/// <summary>enum member</summary>
NextPose3DEvent = 131,
/// <summary>enum member</summary>
NoEvent = 0,
/// <summary>enum member</summary>
PanEvent = 113,
/// <summary>enum member</summary>
Pick3DEvent = 134,
/// <summary>enum member</summary>
PickEvent = 7,
/// <summary>enum member</summary>
PinchEvent = 107,
/// <summary>enum member</summary>
PlacePointEvent = 50,
/// <summary>enum member</summary>
PlaceWidgetEvent = 52,
/// <summary>enum member</summary>
PositionProp3DEvent = 133,
/// <summary>enum member</summary>
ProgressEvent = 6,
/// <summary>enum member</summary>
PropertyModifiedEvent = 73,
/// <summary>enum member</summary>
RegisterEvent = 75,
/// <summary>enum member</summary>
RenderEvent = 5,
/// <summary>enum member</summary>
RenderWindowMessageEvent = 55,
/// <summary>enum member</summary>
ResetCameraClippingRangeEvent = 32,
/// <summary>enum member</summary>
ResetCameraEvent = 31,
/// <summary>enum member</summary>
ResetWindowLevelEvent = 37,
/// <summary>enum member</summary>
ResliceAxesChangedEvent = 58,
/// <summary>enum member</summary>
RightButtonDoubleClickEvent = 126,
/// <summary>enum member</summary>
RightButtonPressEvent = 16,
/// <summary>enum member</summary>
RightButtonReleaseEvent = 17,
/// <summary>enum member</summary>
RotateEvent = 110,
/// <summary>enum member</summary>
SaveStateEvent = 90,
/// <summary>enum member</summary>
Select3DEvent = 135,
/// <summary>enum member</summary>
SelectionChangedEvent = 79,
/// <summary>enum member</summary>
SetOutputEvent = 38,
/// <summary>enum member</summary>
StartAnimationCueEvent = 57,
/// <summary>enum member</summary>
StartEvent = 3,
/// <summary>enum member</summary>
StartInteractionEvent = 41,
/// <summary>enum member</summary>
StartPanEvent = 112,
/// <summary>enum member</summary>
StartPickEvent = 8,
/// <summary>enum member</summary>
StartPinchEvent = 106,
/// <summary>enum member</summary>
StartRotateEvent = 109,
/// <summary>enum member</summary>
StartSwipeEvent = 103,
/// <summary>enum member</summary>
StartWindowLevelEvent = 35,
/// <summary>enum member</summary>
StateChangedEvent = 91,
/// <summary>enum member</summary>
SwipeEvent = 104,
/// <summary>enum member</summary>
TDxButtonPressEvent = 86,
/// <summary>enum member</summary>
TDxButtonReleaseEvent = 87,
/// <summary>enum member</summary>
TDxMotionEvent = 85,
/// <summary>enum member</summary>
TapEvent = 115,
/// <summary>enum member</summary>
TextEvent = 123,
/// <summary>enum member</summary>
TimerEvent = 25,
/// <summary>enum member</summary>
UnRegisterEvent = 76,
/// <summary>enum member</summary>
UncheckedPropertyModifiedEvent = 100,
/// <summary>enum member</summary>
UpdateDataEvent = 82,
/// <summary>enum member</summary>
UpdateDropLocationEvent = 43,
/// <summary>enum member</summary>
UpdateEvent = 74,
/// <summary>enum member</summary>
UpdateInformationEvent = 77,
/// <summary>enum member</summary>
UpdatePropertyEvent = 80,
/// <summary>enum member</summary>
UpdateShaderEvent = 101,
/// <summary>enum member</summary>
UserEvent = 1000,
/// <summary>enum member</summary>
ViewProgressEvent = 81,
/// <summary>enum member</summary>
ViewerMovement3DEvent = 129,
/// <summary>enum member</summary>
VolumeMapperComputeGradientsEndEvent = 64,
/// <summary>enum member</summary>
VolumeMapperComputeGradientsProgressEvent = 65,
/// <summary>enum member</summary>
VolumeMapperComputeGradientsStartEvent = 66,
/// <summary>enum member</summary>
VolumeMapperRenderEndEvent = 61,
/// <summary>enum member</summary>
VolumeMapperRenderProgressEvent = 62,
/// <summary>enum member</summary>
VolumeMapperRenderStartEvent = 63,
/// <summary>enum member</summary>
WarningEvent = 40,
/// <summary>enum member</summary>
WidgetActivateEvent = 69,
/// <summary>enum member</summary>
WidgetModifiedEvent = 67,
/// <summary>enum member</summary>
WidgetValueChangedEvent = 68,
/// <summary>enum member</summary>
WindowFrameEvent = 94,
/// <summary>enum member</summary>
WindowIsCurrentEvent = 93,
/// <summary>enum member</summary>
WindowIsDirectEvent = 97,
/// <summary>enum member</summary>
WindowLevelEvent = 34,
/// <summary>enum member</summary>
WindowMakeCurrentEvent = 92,
/// <summary>enum member</summary>
WindowResizeEvent = 99,
/// <summary>enum member</summary>
WindowStereoTypeChangedEvent = 98,
/// <summary>enum member</summary>
WindowSupportsOpenGLEvent = 96,
/// <summary>enum member</summary>
WrongTagEvent = 56

2、鼠标事件测试

由于vtkObject是很多vtk类的基类,也就是说我们常用的vtkActor和vtkInteractorStyle,直接添加事件都是一样使用的vtkObject。
经过测试:
正常触发: LeftButtonPressEvt、RightButtonPressEvt等单击、MouseMoveEvt,正常触发。
无法触发: LeftButtonDoubleClickEvt、RightButtonDoubleClickEvt等双击,无法触发。

3、如何添加左键的双击事件

目前我所能想到的就是利用单击事件来自定义实现双击事件。原理很简单,在短时间内,单击次数是2次时,判定为双击事件,具体代码可自行实现。

四、总结

观察者/命令模式不可用,原因未知;鼠标单击事件可用,双击事件不触发。目前发现的ActiViz鼠标交互问题就以上这些,如果大家有什么新发现,可评论留言。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1893082.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

这次终于能把神经网络学习原理搞清楚了!

在本文中&#xff0c;我们将深入训练过程&#xff0c;探讨神经网络到底是如何学习的。 内容很肝&#xff0c;建议收藏反复观看学习&#xff01; 假设我们想创建一个神经网络&#xff0c;这个神经网络使用温度和星期几特征来预测每天冰淇淋的销售额。 这是我们使用的训练数据…

spring中集成mybatis,并测试是否成功

首先你要配置pom.xml <!-- 连接 MySQL 数据库的驱动程序 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.16</version></dependency><!-- spring-jdbc -->&…

纯前端低代码开发脚手架 - daelui/molecule

daelui/molecule低代码开发脚手架&#xff1a;分子组件开发、预览、打包 页面代码示例、大屏代码示例预览 可开发页面组件 可开发大屏组件 项目git地址&#xff1a;https://gitee.com/daelui/molecule 在线预览&#xff1a;http://www.daelui.com/daelui/molecule/app/index.…

一个使用 g++ 模块化编译的 hello world 示例( Ubuntu 20.04 )

1. 确认 ubuntu 版本&#xff1a; 2. 文件夹结构&#xff1a; 3. 各个文件内容&#xff1a; 3.1. myadd.cpp&#xff1a; #include<iostream> using namespace std; int add_xxx( int a,int b ){int result a b;cout << a << " " << …

【android】【adb shell】写一个shell脚本,监听进程pid变化

前言 当前业务&#xff0c;需要写一个脚本&#xff0c;不断监视com.android.phone 进程是否异常死掉 脚本 #!/system/bin/sh last_pid"" current_pid"" while(true){current_pidps -A | grep com.android.phone | awk {print $2}if [ -n "$current…

企业必备:Airflow与TASKCTL在任务调度中的优势

在实际系统运维工作中&#xff0c;Airflow 和 TASKCTL 都是强大的任务调度工具&#xff0c;但它们在功能、安全性、技术架构和应对压力方面各有特点。以下是我对两者的对比&#xff1a; 功能对比 Airflow: ● 基于 Python&#xff0c;使用有向无环图&#xff08;DAG&#xff…

伦敦金价格走势图的资金管理怎么进行?

要成熟地交易伦敦金价格走势图&#xff0c;其实并不是一件容易的事情。其一&#xff0c;我们在很多广告或者周边朋友的宣传之下&#xff0c;觉得它能够帮助我们很快之内实现很多的财富增值&#xff0c;其二&#xff0c;很多投资者觉得伦敦金交易虽然不错&#xff0c;但是风险好…

RKNN3588——YOLOv8的PT模型转RKNN模型

一&#xff1a;PT转ONNX 1. 首先克隆rknn修改后的ultralytics版本项目到本地 https://github.com/airockchip/ultralytics_yolov8 cd ultralytics-main pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple pip install -e . 主要是修改了源码的ul…

【管理咨询宝藏140】安永大型国央企内控合规体系建设培训

本报告首发于公号“管理咨询宝藏”&#xff0c;如需阅读完整版报告内容&#xff0c;请查阅公号“管理咨询宝藏”。 【管理咨询宝藏140】安永大型国央企内控合规体系建设培训 【格式】PDF版本 【关键词】安永、内控风控、合规体系 【核心观点】 - 合规是指企业的经营活动与法律…

复合机器人:手脚眼脑的完美结合

在现代工业制造的舞台上&#xff0c;复合机器人如同一位精密而高效的工匠&#xff0c;以其独特的手脚眼脑&#xff0c;正深刻改变着传统的生产方式。这些机器人不仅仅是机械臂的简单延伸&#xff0c;它们汇聚了先进的机械结构、智能的感知系统、精密的控制技术和灵活的思维能力…

移动端UI风格营造舒适氛围

移动端UI风格营造舒适氛围

MYSQL8.0配置

1、下载安装包 2、解压软件包 将MySQL软件包解压在没有中文和空格的目录下 3、设置配置文件my.ini my.ini中加入以下内容 [client] #客户端设置&#xff0c;即客户端默认的连接参数 # 设置mysql客户端连接服务端时默认使用的端口 port3306#默认编码 default-character-set…

Xilinx FPGA:vivado关于单端ROM的一个只读小实验

一、实验要求 将生成好的voe文件里的数据使用rom读取出来&#xff0c;采用串口工具发送给电脑&#xff08;当按键来临时&#xff09;。 二、程序设计 按键消抖模块&#xff1a; timescale 1ns / 1ps module key_debounce(input sys_clk ,input rst_n…

平安养老险安徽分公司:助力乡村振兴 保险知识进农村

为深入宣传普及保险理念&#xff0c;进一步提升服务品质&#xff0c;营造“78全国保险公众宣传日”活动氛围&#xff0c;助力保险业健康稳定发展&#xff0c;近日&#xff0c;平安养老保险股份有限公司&#xff08;以下简称“平安养老险”&#xff09;安徽分公司走进安庆市宿松…

Elasticsearch 8.x 存储有无压缩?能压缩到多少?

1、认知前提 Elasticsearch 支持压缩&#xff0c;压缩方式默认为&#xff1a;LZ4 压缩算法。 具体参见&#xff1a; The default value compresses stored data with LZ4 compression, but this can be set to best_compression which uses DEFLATE for a higher compression r…

Lesson 46 Can you ... ?

Lesson 46 Can you … ? 词汇 lift v. 拿起&#xff0c;搬起 n. 电梯&#xff08;直梯&#xff09; 用法&#xff1a;1. lift … up 拎起……    例句&#xff1a;我可以拎起那只小猫。       I can lift that cat up.    2. take a lift    例句&#xff1a…

不看后悔!国内AI大比拼的精彩看点全汇总

至2022年AI爆发后&#xff0c;在中国已催生了上千个AI产品。 这些产品涵盖了从头部大厂到高等院校&#xff0c;再到初创企业的广泛阵容。 如&#xff1a; 大厂&#xff1a;百度文心、阿里通义、腾讯元宝、字节豆包、讯飞星火等高校&#xff1a;清华大学、北京大学等初创&…

Element中的表格组件Table和分页组件Pagination

简述&#xff1a;在 Element UI 中&#xff0c;Table组件是一个功能强大的数据展示工具&#xff0c;用于呈现结构化的数据列表。它提供了丰富的特性&#xff0c;使得数据展示不仅美观而且高效。而Pagination组件是一个用于实现数据分页显示的强大工具。它允许用户在大量数据中导…

悲情短视频:成都柏煜文化传媒有限公司

悲情短视频&#xff1a;在光影交错中触动人心的温柔力量 在这个五彩斑斓的视频时代&#xff0c;悲情短视频如同一抹深秋的寒露&#xff0c;悄然落在人们的心田&#xff0c;带来一丝不易察觉却又难以抗拒的凉意。它们不以华丽的特效或激昂的音乐取胜&#xff0c;而是凭借真挚的…

“拆分盘投资:机遇与风险并存

一、引言 随着互联网技术的日新月异&#xff0c;金融投资领域迎来了前所未有的变革&#xff0c;其中拆分盘作为一种新兴的投资模式&#xff0c;正逐渐进入公众的视野。其独特的价值增长逻辑和创新的投资机制&#xff0c;为投资者开辟了新的财富增值渠道。本文旨在深入探讨拆分…