Giter VIP home page Giter VIP logo

tutorial-vtk-pyqt's Introduction

tutorial-vtk-pyqt

Learn how to integrate vtk with pyqt in python

This tutorial will show

  • Integrate the VTK widget into a QT application
  • Pass signals from QT to VTK
  • Pass signals from VTK to QT

Screenshot of the application

0: Startup

This tutorial starts with a visualization of volumetric data based on glyphs. The explanation for this part can be found here

1: Make it a class

The first task is encapsulating the logic into a class. This will make it easier to include into a larger program.

2: Embed in Qt

Now the class will be transformed into a Qt-Widget and embedded inside a very simple PyQt interface. We have not connected any of the controls yet. The important changes are

  • Changing the windowInteractor to a QVTKRenderWindowInteractor
  • Getting the render window from the interactor
  • Moving the interactor.Initialize() call to the start method. This method must be called after the widget is visible.
  • Encapsulate the QVTKRenderWindowInteractor into a QFrame, which can be manipulated with more freedom.

Notice that now the main loop is handled by PyQt instead of VTK.

3: Connect Qt to VTK

This is very easy. It is only necessary to connect a Qt event to a method in the vtk class.

4: Connect VTK to QT

This is more tricky. The objective is to notify Qt after the user picks and object in the vtk widget. The default behaviour of vtk is to fire a pick event when the user presses the p key on the keypboard. This is not very intuitive, so first we need to translate standard clicks into picks. The complete chain is

  1. Create pick events from click events. See the method click_to_pick.
  2. Capture pick events and emit a QtSignal. See the method process_pick
  3. Connect the new QtSignal to a method in the main application class.

tutorial-vtk-pyqt's People

Contributors

diego0020 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.