ImageVerifierCode 换一换
格式:DOCX , 页数:22 ,大小:157.75KB ,
资源ID:28153940      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/28153940.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(VTK和QT联合使用.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

VTK和QT联合使用.docx

1、VTK和QT联合使用qt和vtk共用作者:我是小李,欢迎交流来源:博客园发布时间:2009-02-10 11:00阅读:908 次原文链接 收藏 QT与VTK的结合开发2008/07/16 15:26最近,由于项目的需要,我打算使用VTK来开发程序,VTK全名是VisualizationToolKit,它是一套跨平台的C库,对 OpenGL作了较全面的封装,将各种三维模型的存储,运算,显示,交互等内容全都以类的方式封装起来了,并且提供比OpenGL强大得多的功能。可惜 VTK最大的缺点是,没有免费的教程,它只提供免费的API手册,其中只是对各个类的功能罗列而已,而参考书籍则需要花几十美元去购买

2、,所以学习VTK只 能依靠它的大量Example了。由于我的项目需要兼故未来跨平台的可能(目前只在Windows下),所以必须使用一套跨平台的开发库, 在VTKExamplesGUI的例子里,Windows平台下只有SDK,MFC,C+ Builder这几个例子,另外还有Motif,Python,Tcl,选择是不少,但是Motif听说编程比较麻烦,我也从来没有接触过,Tcl和 Python作为脚本语言,其性能和安全性则有些令人担忧,也就是说,这里面没有一个是我能使用的.。.说起跨平台,由于单位里项目的关系,我接触得比较 多的就是QT了,所以,在未选定VTK之前,其实我是打算使用QTOpenGL

3、的组合方式来开发这个软件的,其实,如果不考虑跨平台,我还是会选择 QT,因为它的事件处理方式对于用惯Delphi的我而言,更为顺手,那么现在使用了VTK,是否还能将VTK和QT组合起来使用呢。作为试验,我仿照VTKExamplesGUIWin32SampleMFC,制作了以下这个小程序,很顺利,结果证明了我的猜想,QT和VTK是可以很方便的结合起来的,下面就跟我来一步步制作这个程序吧:1)从http:/www。vtk.org/下 载VTK的最新版本,我用的是4。2。该包中只有程序文件,你还需要自己编译,为此你还需要CMake,用来生成VC的.dsw,。dsp文件。然后用 VC打开生成的工程文件

4、,并进行编译。最后将编译后生成的目录:VTKbinDebug加入到Windows系统环境的Path中。2)下载QT,我目前使用的是QT334,打开VC的Tools-OptionsDirectories,将QT的bin,include,lib路径分别加入其中。3)在VC中,建立一个新的Win32 Console Application工程,建立一个main。cpp,作为main函数的入口,代码如下:include Renderer = vtkRenderer:New();this-RendererSetBackground(0.3, 0.5, 0.1);thisRenderWindow = vt

5、kWin32OpenGLRenderWindow::New();this-RenderWindowAddRenderer(thisRenderer);thisInteractor = vtkWin32RenderWindowInteractor:New();vtkActor2D actor2d = vtkActor2D:New();vtkTextMapper txt = vtkTextMapper:New();actor2dSetMapper(txt);txtSetInput(Hello World”);txt-GetTextProperty()-SetFontSize(24);this-Re

6、ndererAddProp(actor2d);txtDelete();actor2dDelete();vtkActor *actor = vtkActor:New();vtkDataSetReader reader = vtkDataSetReader:New();readerSetFileName(”weldedSpheres.vtk”);vtkDataSetMapper *mapper = vtkDataSetMapper::New();mapper-SetInput(readerGetOutput();actorSetMapper(mapper);thisRendererAddProp(

7、actor);mapperDelete();readerDelete();actor-Delete();TestWindow::TestWindow()if (this-Interactor) thisInteractorDelete();if (this-Renderer) this-RendererSetRenderWindow(NULL);if (thisRenderWindow) thisRenderWindow-Delete();if (thisRenderer) thisRendererDelete();void TestWindow::paintEvent(QPaintEvent

8、 e)if (! this-InteractorGetInitialized()) thisRenderWindowSetWindowId(thiswinId(); thisRenderWindow-WindowInitialize(); this-InteractorSetRenderWindow(thisRenderWindow); thisInteractor-Initialize();this-RenderWindow-Render();bool TestWindow::winEvent(MSG *msg)switch (msgmessage) case WM_LBUTTONDOWN:

9、 case WM_LBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_MOUSEMOVE: case WM_CHAR: case WM_TIMER: if (thisInteractor-GetInitialized() vtkHandleMessage2(msg-hwnd, msgmessage, msglParam, msg-wParam, this-Interactor); return false;其中用到了一个模型文件weldedSpher

10、es。vtk,可以在VTK中找到.可能你需要修改它的路径。然后,再次打开Proect Settings对话框,在C/C+页中,选择Category:Preprocessor,在Additional include directories:中加入:D:VTK,D:VTKParallel,D:VTKHybrid,D:VTKPatented,D:VTKRendering,D:VTKIO,D:VTKImaging,D:VTKGraphics,D:VTKFiltering,D:VTKCommon选择Link页,选择Category:Input,在Object/library modules:中加入:vt

11、kRendering.lib vtkGraphics.lib vtkImaging。lib vtkIO。lib vtkFiltering。lib vtkCommon。lib vtkftgl.lib glu32.lib opengl32。lib glu32。lib opengl32.lib vtkfreetype.lib vtkpng.lib vtktiff.lib vtkzlib。lib vtkjpeg。lib vtkexpat。lib 在Addtional library path中加入:D:VTKbindebug以上都假设VTK安装在D盘下,如果你安装在其它目录,请修改以上的路径。好了,重

12、新编译程序,运行,你将看到如下所示的VTK界面.Tuesday, October 17th 2006, 6:13pmTutorial for using Qt with VTKHi,I am a newbie in VTK and Qt. For some time now,I have been trying to use VTK with Qt but faced a lot of problems getting started and configuring them. In the end, it worked(thanks to Anja Ende,Clinton Stimpson

13、 and everyone who helped me get started)。 I am writing down the procedure to get VTK to work with Qt in visual studio 2005 environment。 Hopefully this document will help other newbies save a lot of time。I have tested the following procedure with MS Visual Studio 2005 Professional on Windows XP Pro X

14、64。1). Install and get Qt working as per the instructions here: http:/qtnode。net/wiki/Qt4_with_Visual_StudioThis works fine and you can start using Qt with visual studio(for those who just want to use Qt with Visual Studio, this is how we do it!)2). Install and configure VTK using Cmake with (a) VTK

15、_USE_GUISUPPORT option and (b) VTK_USE_QVTK option, set to ONIf Qt is installed after VTK, you will need to reconfigure VTK to find Qt。3)。Now its time to test the configuration with a code which uses both Qt and VTK。 You can try it with the example in VTK source( 。./Examples/GUI/Qt/Imageviewer)。 Cop

16、y this code(only the cxx file) to a new directory。4) I use qmake to generate build files。 The method to build this example using qmake is:(a) open visual studio command prompt, go to the directory containing the cxx file and type: qmake projectthis makes a 。pro file. Open this file in an editor and

17、modify it as below-# Automatically generated by qmake (2.00a) Wed Oct 11 17:14:01 2006#TEMPLATE = vcapp this was originally app modify it to vcappTARGET +=DEPENDPATH += .INCLUDEPATH += 。 # here include the path to all the directories containing the header filesLIBS += add this line and include all t

18、he libraries(Qt and VTK) needed for the application# InputSOURCES += main.cxx-(b)Save the .pro file and run qmake from the command prompt again。 This will generate a 。vcproj file. Open this file in visual studio and build it there. If you included all the libraries and include paths, this should bui

19、ld and run perfectly.I used qmake for building, because I didnt know how to do it with Cmake. But if the experts here can throw light on that it would help many. Also if someone knows of any other way(probably easier and smarter) to use Qt with VTK, please add to this document。Thanks,Ashish Go to th

20、e top of the page Quote Skip user informationalexiuk BeginnerPosts: 22 Thursday, May 10th 2007, 6:04pmRE: Tutorial for using Qt with VTKHi Ashish,Thanks for posting those details。 I am trying to follow those instructions and am running into problems building QVTK. Error messages follow。 Did you have

21、 any trouble building VTK?Thanks,Mark1- Build started: Project: QVTK, Configuration: Debug Win32 -1Generating moc_vtkEventQtSlotConnect.cxx1Generating moc_QVTKWidget.cxx1Compiling。.1moc_vtkEventQtSlotConnect。cxx1c1xx : fatal error C1083: Cannot open source file: .moc_vtkEventQtSlotConnect.cxx: No su

22、ch file or directory1moc_QVTKWidget.cxx1c1xx : fatal error C1083: Cannot open source file: .moc_QVTKWidget。cxx: No such file or directory1Generating Code。.1Build log was saved at ”file:/c:VTKvcc_buildGUISupportQtQVTK.dirDebugBuildLog。htm1QVTK - 2 error(s), 0 warning(s)VTK Build summary:= Build: 1 su

23、cceeded, 3 failed, 47 upto-date, 6 skipped Go to the top of the page Quote Skip user informationAshish BeginnerPosts: 83 Thursday, May 10th 2007, 8:30pmRE: Tutorial for using Qt with VTKHi Mark,I didnt face any problems building QVTK. Also I have stopped using qmake and use cmake these days.Can you give me more details as to what you have done so far and at what step are you getting the errors? Are you able to test run a simple Qt code?Thanks,Ashish Go to the top of the pa

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1