VTK鼠标键盘事件:观察者模式

VTK鼠标键盘事件会优先于QT的鼠标键盘事件,而且会吃掉这些事件,使得QT的

    //void mouseMoveEvent(QMouseEvent * event) override;
这种事件得不到执行。

这主要是通过QVTKOpenGLWidget类来实现的。

所以我们只能使用VTK的鼠标响应机制来实现鼠标键盘的控制。

VTK鼠标键盘事件的响应是用观察者模式,也就是先注册观察者。等事件发生的时候,自动回调观察者的成员函数。

第一步,创建观察者类,实现回调函数

#pragma once

#include "vtkCommand.h"
#include "SeriesPreviewWindow.h"

class SeriesPreviewWindowCallback : public vtkCommand
{
public:
	static SeriesPreviewWindowCallback* New()
	{
		return new SeriesPreviewWindowCallback;
	}
	SeriesPreviewWindowCallback();
	~SeriesPreviewWindowCallback();
	void Execute(vtkObject *caller, unsigned long eventI
VTK使用指南:介绍 本章讨论了开发大型和/或复杂软件系统的一些问题,并描述了面向对象设计如何解决其中的许多问题。本章定义了面向对象建模和设计中使用的关键术语,并通过一个真实世界的例子进行了工作。本章最后简要介绍了一些面向对象的语言以及与面向对象可视化相关的一些问题。 阅读详情

相关推荐

VTK修炼之道1_初识VTK

1.VTK是什么? Visualization ToolKit 3D计算机图形学、图象处理及可视化工具包 VTK使用C++、面向对象技术开发;基于OpenGL,封装了OpenGL中的功能,屏蔽细节、便于交互、易于使用提供多种语言接口C++ 、Java 、Tcl、 Python 等;可在Windows 98/NT, SGI, Linux,  Sun, HP等系统编译

沈春旭的博客 1万+

VTK事件回调机制详解:从观察者模式到交互式三维可视化实战

观察者模式是软件设计中实现对象间松耦合通信的核心设计模式,其原理在于定义对象间的一对多依赖关系,当一个对象状态改变时,所有依赖它的对象都会自动得到通知并更新。在计算机图形学与科学可视化领域,这一模式被具体化为事件驱动架构,成为实现用户交互、数据状态同步和异步处理的技术基石。VTK(Visualization Toolkit)作为强大的跨平台三维可视化库,其事件回调系统正是观察者模式的经典工程实践,它通过vtkCommand、AddObserver等核心组件,将硬件输入(如鼠标点击、键盘事件)或内部逻辑事件(

abc20899的专栏 318

VTK鼠标坐标获取:从屏幕像素到三维世界的完整转换指南

在科学计算可视化与三维交互开发中,坐标系统转换是基础且核心的技术环节。其原理涉及从二维屏幕空间到三维世界空间的映射,通常通过视口归一化、相机投影矩阵逆变换等步骤实现。这一技术的工程价值在于,它构成了交互式拾取、三维标注、模型测量等高级功能的基础。在医学影像分析、CAD设计、地理信息系统等应用场景中,精确的坐标拾取直接影响用户体验与功能可靠性。本文聚焦于VTK(Visualization Toolkit)这一经典可视化库,深入探讨其事件处理机制与坐标转换管线,并针对编译依赖、虚拟环境配置等常见工程实践问题,提

weixin_34414650的博客 437

VTK实战-深入解析vtkRenderWindowInteractor的交互机制与定制开发

本文深入解析VTK中vtkRenderWindowInteractor的交互机制与定制开发,涵盖从基础事件处理到高级定制技巧。通过医疗影像和工业仿真实战案例,展示如何利用交互器实现窗宽窗位调节、测量工具等专业功能,并分享跨平台适配与性能优化经验,助力开发者掌握三维可视化交互核心。

weixin_30919429的博客 508

机器人视觉仿真软件:VTK (Visualization Toolkit)_(9).VTK中的交互技术

除了使用预定义的交互风格,开发者还可以通过继承类来创建自定义的交互风格。public:// 获取当前鼠标位置// 获取上一次鼠标位置// 计算鼠标移动的增量// 获取当前的圆锥源public :// 获取当前鼠标位置 int * pos = this -> Interactor -> GetEventPosition();// 获取上一次鼠标位置 int * lastPos = this -> Interactor -> GetLastEventPosition();

kkchenjj的博客 1195

第二部分:VTK核心类详解(第23章 vtkInteractor交互器类)

VTK交互器系统(vtkInteractor)是VTK中处理用户交互的核心组件,主要包括vtkRenderWindowInteractor、vtkInteractorObserver和vtkInteractorStyle等类。该系统采用命令/观察者设计模式,将平台事件转换为VTK事件,通过交互样式类实现3D场景的旋转、平移、缩放等操作。vtkRenderWindowInteractor负责管理事件循环和窗口关联,vtkInteractorObserver提供基本观察者功能,而vtkInteractorSty

仰望星空的博客 294

H5获取手机相机或相册图片两种方式-Android通过webview传递多张照片给H5

H5调用公共获取图片文件方法,在android手机端,H5主要依赖Webview,这边在webview声明并重写该方法onShowFileChooser使用工具类打开相机或相册,可以两种方式安卓原生方式或者利用第三方组件库方式选中图片,返回uri列表给H5H5收到uri照片列表,并且使用前端方式展示创造价值,乐哉分享!

m0_74823947的博客 3096

MPU6050数据融合避坑指南:当欧拉角遇到万向节死锁,我们该如何处理?

本文深入探讨了MPU6050在姿态解算中遇到的欧拉角万向节死锁问题,提供了四元数解决方案及工程实践策略。通过分析死锁现象的本质,介绍四元数的优势与实现方法,并给出必须使用欧拉角时的三种应对方案,帮助开发者有效规避数据跳变和解算失效问题。

weixin_30415113的博客 541

微信小程序协同工作和发布

微信小程序协同工作和发布

qq_53114527的博客 1621

loadStop的原因导致的SSUSP

Total内存值是可用来调度的可用内存,当前可用内存为 0M。 loadSched和loadStop的阈值是根据 Total 内存和节点内存来做限制的。 loadStop 50G,现在有大量作业SSUSP,说明之前某个时间点该节点内存可能有低于50G的时候,导致作业SSUSP,具体是否是这个原因引起的需要用 bjobs -l JobID 看下作业的详细信息。 如果是loadStop的原因导致的 SSUSP,根据loadStop设置的阈值,Total 值高于loadStop值后,将逐步恢复挂起的作业

Blueberry521的博客 667

【UE5 C++开发指南】从零配置Visual Studio 2022开发环境

本文详细指导如何从零开始为UE5 C++开发配置Visual Studio 2022环境。文章强调了VS2022与UE5的深度兼容性,并逐步讲解了社区版下载、核心工作负载(如“使用C++的游戏开发”)与组件安装、界面优化、专属工具设置以及首个C++项目的创建与验证流程,帮助开发者高效搭建专业开发环境。

weixin_29016865的博客 395

DOSBOX 0.74模拟器安装Windows 95

DosBox本身带有5.0版的DOS系统,启动后虚拟一个Z盘存放有Dosbox特有的外部指令,如config.com、imgmount.com等,经测试,可以顺利安装各版本的windows 3.1系统,但是不能安装win95,需要用原版的dos镜像启动才能安装。1. 获取启动盘镜像文件 下载Win95启动软盘镜像文件,名为boot.img,放到DosBox 0.74的目录下。2. 制作硬盘镜像文件

xjnzhidao的博客 9310

Ardupilot姿态控制详解(完结篇)

本文主要是对过去写的一些APM中姿态控制流程及函数博文的汇总。 按照之前写的博文以及个人认为的学习顺序,给出APM姿态控制器的学习顺序如下: APM姿态旋转理论基础 Ardupilot姿态控制器 PID控制流程(整定后的P控制器) 详解APM的开方控制器sqrt_controller Ardupilot前馈及平滑函数input_euler_angle_roll_pitch_yaw解析 Ardupilot倾转分离函数thrust_heading_rotation_angles Ardupilot四元数姿态控制

moumde的博客 7024

NVIDIA Omniverse 技术浅析(二):USD

例如,一个用户可以负责场景的几何体设计,另一个用户可以负责材质和灯光的调整。USD 的开放性和可扩展性,结合 Omniverse 的 Kit 扩展框架,使得用户和开发者可以创建自定义的应用程序和工具,以满足特定的需求。USD 的材质和物理属性系统,结合 Omniverse 的 RTX 实时渲染技术,使得用户可以在虚拟环境中看到逼真的光影效果和物理模拟。USD 的时间轴和动画功能,结合 Omniverse 的物理属性系统,使得用户可以为虚拟环境中的元素创建复杂的动画和物理模拟。

m0_75253143的博客 446

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

上一篇: QGridLayout添加、删除、交换、复制、Widget
下一篇: QT拖动窗口实现
C++程序员Carea
博客等级 码龄18年 1590粉丝 878原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

C++程序员Carea

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值