代码:
1.实现代码

#include "MyTrackballActor.h"
vtkStandardNewMacro(StyleTrackballActor);int MyTrackballActor()
{//// Next we create an instance of vtkConeSource and set some of its// properties. The instance of vtkConeSource "cone" is part of a// visualization pipeline (it is a source process object); it produces data// (output type is vtkPolyData) which other filters may process.//vtkConeSource *cone = vtkConeSource::New();cone->SetHeight(3.0);cone->SetRadius(1.0);cone->SetResolution(10);//// In this example we terminate the pipeline with a mapper process object.// (Intermediate filters such as vtkShrinkPolyData could be inserted in// between the source and the mapper.)  We create an instance of// vtkPolyDataMapper to map the polygonal data into graphics primitives. We// connect the output of the cone souece to the input of this mapper.//vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();coneMapper->SetInputConnection(cone->GetOutputPort());//// Create an actor to represent the first cone. The actor's properties are// modified to give it different surface properties. By default, an actor// is create with a property so the GetProperty() method can be used.//vtkActor *coneActor = vtkActor::New();coneActor->SetMapper(coneMapper);coneActor->GetProperty()->SetColor(0.2, 0.63, 0.79);coneActor->GetProperty()->SetDiffuse(0.7);coneActor->GetProperty()->SetSpecular(0.4);coneActor->GetProperty()->SetSpecularPower(20);double *origin = coneActor->GetOrigin();//// Create a property and directly manipulate it. Assign it to the// second actor.//vtkProperty *property = vtkProperty::New();property->SetColor(1.0, 0.3882, 0.2784);property->SetDiffuse(0.7);property->SetSpecular(0.4);property->SetSpecularPower(20);//// Create a second actor and a property. The property is directly// manipulated and then assigned to the actor. In this way, a single// property can be shared among many actors. Note also that we use the// same mapper as the first actor did. This way we avoid duplicating// geometry, which may save lots of memory if the geoemtry is large.vtkActor *coneActor2 = vtkActor::New();coneActor2->SetMapper(coneMapper);coneActor2->GetProperty()->SetColor(0.2, 0.1, 0.1);coneActor2->SetProperty(property);coneActor2->SetPosition(0, 2, 0);coneActor2->SetOrigin(origin);//// Create the Renderer and assign actors to it. A renderer is like a// viewport. It is part or all of a window on the screen and it is// responsible for drawing the actors it has.  We also set the background// color here.//vtkRenderer *ren1 = vtkRenderer::New();ren1->SetBackground(0.1, 0.2, 0.4);// Finally we create the render window which will show up on the screen.// We put our renderer into the render window using AddRenderer. We also// set the size to be 300 pixels by 300.//vtkRenderWindow *renWin = vtkRenderWindow::New();renWin->AddRenderer(ren1);renWin->SetSize(300, 300);vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();iren->SetRenderWindow(renWin);//// By default the vtkRenderWindowInteractor instantiates an instance// of vtkInteractorStyle. vtkInteractorStyle translates a set of events// it observes into operations on the camera, actors, and/or properties// in the vtkRenderWindow associated with the vtkRenderWinodwInteractor.// Here we specify a particular interactor style.//vtkInteractorStyleTrackballCamera *style =// vtkInteractorStyleTrackballCamera::New();//iren->SetInteractorStyle(style);//主函数里面的重要代码:vtkSmartPointer<StyleTrackballActor> style = vtkSmartPointer <StyleTrackballActor>::New();style->SetDefaultRenderer(ren1);style->ActorA = coneActor;style->ActorB = coneActor2;iren->SetInteractorStyle(style);ren1->AddActor(coneActor);ren1->AddActor(coneActor2);//ren1->AddActor(Actor1);//ren1->AddActor(Actor2);iren->Initialize();iren->Start();//// Now we loop over 360 degreeees and render the cone each time.////int i;// for (i = 20; i >0; --i)//  {//  // render the image//coneActor2->GetProperty()->SetOpacity(0.1);//   renWin->Render();//Sleep(5000);//  // rotate the active camera by one degree//   // ren1->GetActiveCamera()->Azimuth( 1 );//  }iren->Initialize();iren->Start();//// Free up any objects we created. All instances in VTK are deleted by// using the Delete() method.//cone->Delete();coneMapper->Delete();coneActor->Delete();property->Delete();coneActor2->Delete();ren1->Delete();renWin->Delete();return 0;
} //blog.csdn.net/q610098308/article/details/108093627

2.头文件MyTrackballActor

#pragma once
//#include "MouseInter.h"
#include "InitInclude.h"#define VTKISRBP_ORIENT 0
#define VTKISRBP_SELECT 1class StyleTrackballActor :public   vtkInteractorStyleTrackballActor
{
public:static StyleTrackballActor* New();//vtkTypeMacro(InteractorStyle, vtkInteractorStyleRubberBandPick);vtkTypeMacro(StyleTrackballActor, vtkInteractorStyleTrackballActor);virtual void OnLeftButtonDown(){// Forward eventsvtkInteractorStyleTrackballActor::OnLeftButtonDown();if (this->InteractionProp == this->ActorA){std::cout << "Picked ActorA." << std::endl;}else if (this->InteractionProp == this->ActorB){std::cout << "Picked ActorB." << std::endl;}}vtkActor* ActorA;vtkActor* ActorB;};

3.项目的公共头文件InitInclude

#pragma once
#include <vtkSphereSource.h>
#include <vtkPolyData.h>
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkAutoInit.h>
#include <string>
#include <vtkCellArray.h>
#include <vtkFloatArray.h>
#include <vtkImageData.h>
#include <vtkJPEGReader.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkPolygon.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkTexture.h>
#include <vtkQuadric.h>
#include <vtkSampleFunction.h>
#include <vtkContourFilter.h>
#include <vtkOutlineFilter.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkImageData.h>
#include <vtkSmartPointer.h>
#include<vtkConeSource.h>
#include<vtkPolyDataMapper.h>
#include<vtkActor.h>
#include<vtkRenderer.h>
#include<vtkRenderWindow.h>
#include<vtkRenderWindowInteractor.h>
#include<vtkInteractorStyleTrackballCamera.h>#include "vtkPlaneSource.h"
#include <vtkNew.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
#include <vtkPoints.h>
#include <vtkPolygon.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkTriangleFilter.h>
#include <vtkProperty.h>
#include <vtkTriangleFilter.h>
#include <vtkDataSetSurfaceFilter.h>
#include <vtkLinearExtrusionFilter.h>
#include <vtkBMPReader.h>
#include <vector>
#include "vtkhswpolygonwidget.h"
#include "vtkPlaneSource.h"
#include <vtkNew.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
#include <vtkPoints.h>
#include <vtkPolygon.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkTriangleFilter.h>
#include <vtkProperty.h>
#include <vtkTriangleFilter.h>
#include <vtkDataSetSurfaceFilter.h>
#include <vtkLinearExtrusionFilter.h>
#include <vtkBMPReader.h>
#include <vector>
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkProperty.h"#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include <windows.h>
#include <vtkObjectFactory.h>
#include <vtkInteractorStyleTrackballActor.h>
#include "vtkPropPicker.h"
#ifndef INITIAL_OPENGL2
#define INITIAL_OPENGL2
#include "vtkAutoInit.h" VTK_MODULE_INIT(vtkRenderingOpenGL2); // VTK was built with vtkRenderingOpenGL2
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingFreeType)
#endif
#include <iostream>
#include <map>
#include<vector>
using namespace std;//#pragma comment(lib,"vtkzlib-6.1.lib")
两个actor通过鼠标移动


代码可以直接运行的;
环境:win10 x64
qt5.4
vs2103专业版
vtk7.1


http://www.taodudu.cc/news/show-1639479.html

相关文章:

  • (6)通过输入参数(测量数据)构建三维体模型
  • (4)建立一个标准尺寸的平面,并对其进行着色贴图、拉伸一定的厚度
  • (5)通过输入参数(测量数据)构建二维体模型(01)
  • (3)通过输入参数(测量数据)构建三维体模型(02)
  • (8)VTK 鼠标左右键控制模型旋转
  • (2)通过输入参数(测量数据)构建三维体模型(01)
  • (01)VTK读取OBJ格式模型
  • (02)vtk 绘制模型的外轮廓线 模型轮廓线
  • (03)两个模型的交集、并集、差集
  • (04)VTK移动模型,判断是否相交
  • (05)vtk通过多边形构建矩形,并拉伸成立方体,两个立方体独立操作
  • (06)vtk修改默认鼠标操作,实现鼠标按键控制模型旋转
  • who i am !
  • (01)OpenGL es中只在指定区域渲染view
  • (01)C++之设计模式演变
  • C++设计模式(全网最通俗易懂的设计模式进阶)
  • c++工程模式+配置文件+动态调用类
  • 读书感悟之,从术到道
  • 因果否?
  • (01)数据库及相关
  • avg最多用多少列 mysql_40斤一桶水,最多用多少克磷酸二氢钾?打几次增产效果最好...
  • 用单片机测量流体流速的_旋进旋涡流量计的测量原理及优点
  • 文字加减前后缀lisp_日本搞笑艺人催泪讲授汉字课堂告诉你文字背后的意义!...
  • 幼儿园调查过程怎么写_幼儿园对孩子的重要性你真的清楚吗?
  • 三星oneui主屏幕费电_这或许是单手握持手感最佳的手机 三星Galaxy S20上手体验...
  • 麦克纳姆轮运动原理怎么安装_家用中央空调水系统原理是什么?怎么样安装比较好呢?...
  • redis 判断存在性_一口气说出四种幂等性解决方案,面试官露出了姨母笑~
  • python心跳包原理_Python 用心跳(UDP包)探测不活动主机
  • pin码计算器网页版_快对作业APP下载手机版电脑版官方正式上线
  • 进入已经打开的pyrebox_PyREBox-可用Python编写脚本的逆向工程沙盒

(1)鼠标单独移动两个actor相关推荐

  1. 模拟键盘鼠标事件有两种方法

    实现一个鼠标或者键盘模拟器,可以完成很多功能,比如做一个简单的游戏外挂^_^.通常,模拟键盘鼠标事件有两种方法: 1.keybd_event, mouse_event 2.SendMessage, P ...

  2. Windows如何区分鼠标双击和两次单击

    Windows如何区分鼠标双击和两次单击 http://lbsloveldm.blog.hexun.com/12212875_d.html 在Windows平台上,鼠标左键的按下.松开.快速的两次点击 ...

  3. 一套鼠标键盘控制两台电脑-绝!

    Oliver's R&D Lab C/C++/Linux 一套鼠标键盘控制两台电脑-绝! 这个工具是推荐给双电脑工作人员的,不是的就不用往下看了,嗯. synergy-----按照它主页( h ...

  4. [共享工具] 一套鼠标键盘控制两台不同系统的主机

    问题描述 用一组有线鼠标键盘控制两台主机(不同系统). 解决方法 Barrier,推荐. synergy.

  5. (转) Windows如何区分鼠标双击和两次单击

    Windows如何区分鼠标双击和两次单击 http://lbsloveldm.blog.hexun.com/12212875_d.html 在Windows平台上,鼠标左键的按下.松开.快速的两次点击 ...

  6. [转]C# winForm 自定义鼠标样式的两种方法

    本文转自:http://www.cnblogs.com/hzbzxm/archive/2008/09/15/1291104.html 以前试过在WinForm中自定义鼠标样式,结果显示出来的鼠标变成单 ...

  7. Windows/MFC 如何区分鼠标双击和两次单击

    在Windows平台上,鼠标左键的按下.松开.快速的两次点击会产生WM_LBUTTONDOWN.WM_LBUTTONUP和WM_LBUTTONDBLCLK消息,但是Windows根据什么来区分连续的两 ...

  8. 计算机主机如何控制所有的电脑,教你如何让一个鼠标和控制两台电脑

    1简介 synergy是个开源的软件,有三个版本 mac / linux / windows,要想实现共享鼠标键盘,必须在所有机器上都安装这个软件,并进行相应的配置,有一台唯一的主机作为服务器端,其他 ...

  9. 改变鼠标指针形状两种方法及实例

    改变鼠标指针形状的方法有两种:一种:用css样式表来改变鼠标指针形状.另一种是:利用第三方控件的方法,而我自己最常用的是第一种:用css样式表来改变鼠标指针形状 我们先来看第一种:用css样式表来改变 ...

最新文章

  1. AppStore 提供的App信息查询的WebService
  2. c# mysql fill_C#里sqlDataAdapter.fill(DataSet,String)的用法
  3. PyTorch模型的保存加载以及数据的可视化
  4. java将两个区间范围合并_Java如何将若干时间区间进行合并的方法步骤
  5. Windows Azure 真实案例:CCH 财政服务独立软件开发商(ISV)通过托管服务获得了灵活性并节省成本...
  6. centos65安装RabbitMQ3.6.5
  7. jzoj100044-abcd【多重背包,二进制压缩,dp】
  8. c#中 uint_C#中的uint关键字
  9. Maven工作笔记-jar包打入本地仓库并打包
  10. C#操作类----XmlHelper
  11. 判定2022年是否闰年c语言_闰年的来历
  12. Happy Birthday to You
  13. linux 如何起服务,如何修改Linux的服务的开启和关闭
  14. SecureCRT的Backspace显示为^H的解决办法
  15. xiao776php,《xiao 776》_xiao 776_NEWS下载网
  16. 23种设计模式(4):模板模式
  17. 06正交实验法及场景法
  18. 激活函数(Activation Function)及十大常见激活函数
  19. 如何自己开发一个Android APP(3)——XML和Android
  20. 解决idea在运行时出现Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8?

热门文章

  1. airflow+k8s 多用户-分布式-跨集群-容器化调度
  2. grafana将自己的数据库(hbase)设置为数据源
  3. 汇编重要知识点:地址编号和数据编号
  4. Vue表单输入绑定(文本框和复选框)
  5. C语言学习记录_2019.02.10
  6. printk打印机别
  7. 深入理解Java虚拟机2——内存管理机制及工具
  8. POJ 1177 Picture
  9. .net知识和学习方法系列(四)继承中方法的隐藏和重写
  10. [转载] python zip 文件解压中文乱码问题解决