[vtkusers] Relationship between interactor/render window and VTKRenderWindowInteractor for VTK Charting

Elvis Stansvik elvis.stansvik at orexplore.com
Sun Jun 26 08:17:33 EDT 2016


Hi Arasu,

2016-06-26 13:11 GMT+02:00 arasu via vtkusers <vtkusers at vtk.org>:

> The problem is similiar to the one reported by Elvis Stansvik earlier this
> month about creating and displaying Chart in own Window.
>
> I am using C++ on Windows and VTK7.0. I am not using QT. I have adapted
> the MFC version that comes with VTK to not be dependent on MFC. I am using
> the lines below (based on the documentation shows for QT )
>
> SetRenderWindow(vtkWin32OpenGLRenderWindow::SafeDownCast(view->GetRenderWindow()));
>         view->SetInteractor(GetInteractor());
>
> I am able to get the chart to display on the Window I create in the
> program. However the Interactor does not work - i.e. mouse actions do not
> pan/zoom the chart.
>
> I have no such problem when using VTK for other visualizations -creating
> and connecting Mapper / Actor / Renderer / Interactor etc. and connecting
> the renderwindow to the renderer.   The visualization is shown in my window
> and the display responds to mouse and keyboard actions.    What do I need
> to do in order to do the same with VTK Charting ? The interacting seems to
> have been initialized and started as I can put a break in the program and
> step through the Interactor code for mouse events.
>

I finally solved my problem. Unfortunately, I don't quite know what I did
that made it work :/ It just started working when I began using a heavily
customized QVTKRenderWindowInteractor.

I know your case is different from mine (C++, not Python and MFC, not Qt),
but I'm attaching my code anyway, and perhaps something can be of help.

The attached files are:

vtk_widget.py: Contains VTKWidget, a customized/simplified version of
QVTKRenderWindowInteractor that I'm using. It essentially just sets up the
render window, interactor and renderer to render into the QGLWidget, and
forwards Qt input events to the interactor.

transfer_functions_editor.py: This is where I make use of VTK charts. Have
a look at the constructors for CompositeTransferFunctionEditor and
ColorTransferFunctionEditor. These two widgets subclass my VTKWidget, so to
get the full picture of how I set things up, read the constructor in there
first.

If I read my own code right, what I do is:

1. Create the render window
2. Create the interactor
3. Set the render window on the interactor with SetRenderWindow(..)
4. Start the interactor with Start()
5. Create the renderer
6. Add the renderer to the render window with AddRenderer(..)

The above is done in my VTKWidget class. Then I

7. Create the plots I want to show (subclasses of vtkPlot)
8. Create the chart (vtkChartXY)
9. Add the plots to the chart with AddPlot(..)
10. Create the context view (vtkContextView)
11. Set the render window on the context view with SetRenderWindow(..)
12. Set the interactor on the context view with SetInteractor(..)
13. Add the chart to the scene backing the context view with
.GetScene().AddItem(..)

The above is done in my subclasses (CompositeTransferFunctionEditor and
ColorTransferFunctionEditor).

Hope this can help somewhat.

Elvis


>
> Thanks in advance,
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160626/ba55b6e1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: transfer_functions_editor.py
Type: text/x-python
Size: 10872 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160626/ba55b6e1/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtk_widget.py
Type: text/x-python
Size: 10665 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160626/ba55b6e1/attachment-0001.py>


More information about the vtkusers mailing list