[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vtk-developers
Subject:    Re: [vtk-developers] QVTKRenderWindowInteractor bug?
From:       Panagiotis Mavrogiorgos <pmav99 () gmail ! com>
Date:       2011-08-15 15:38:07
Message-ID: CAAVvtwq3A2YVob=F4vwD+cELWNdtRNOT_s2ygkidB9K0sGC0Eg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Mon, Aug 15, 2011 at 4:12 PM, Jean-Christophe Fillion-Robin <
jchris.fillionr@kitware.com> wrote:

> Hi Panos,
>
> Would be great if you could submit a patch on gerrit for review.
> See http://www.vtk.org/Wiki/VTK/Git#Gerrit
>
> Thanks
> Jc
>

Hi Jean-Christophe,

I've managed to reproduce the bug. You can easily observe it when you use a
vtkScalarBarWidget and you try to move it on screen. I am attaching a
minimum "working" (reproducing would be more accurate) example. The
dependencies in order to run the file are Python2, VTK and PyQt4.

The ScalarBarWidget is moving on screen but the following traceback is
produced

Traceback (most recent call last):
  File
"/usr/lib/python2.7/site-packages/vtk/qt4/QVTKRenderWindowInteractor.py",
line 211, in ShowCursor
    self.setCursor(cursor)
NameError: global name 'cursor' is not defined

Changing the last line of the ShowCursor method (line 220 on the git repo)
of QVTKRenderWindowInteractor class ( path :
VTK/Wrapping/Python/vtk/qt4/QVTKRenderWindowInteractor.py), from

self.setCursor(cursor)

to

self.setCursor(qt_cursor)

results to no traceback.

This is the link to Gerrit (
http://review.source.kitware.com/#change,2469). Who should I add as a
reviewer?

with regards,
Panos

ps. Perhaps this is not the appropriate list, but how can you add examples
to the wiki? I have created an account but it says that I don't have the
rights to create a new page. I can edit this page though... (
http://www.vtk.org/Wiki/VTK/Examples/Python )

[Attachment #5 (text/html)]

<div class="gmail_quote"><div class="gmail_quote"><div class="im"><br>On Mon, Aug 15, \
2011 at 4:12 PM, Jean-Christophe Fillion-Robin <span dir="ltr">&lt;<a \
href="mailto:jchris.fillionr@kitware.com" \
target="_blank">jchris.fillionr@kitware.com</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> Hi Panos, <br><br>Would be great if you could submit a patch \
on gerrit for review.<br>See <a href="http://www.vtk.org/Wiki/VTK/Git#Gerrit" \
target="_blank">http://www.vtk.org/Wiki/VTK/Git#Gerrit</a><br><br>Thanks<br>Jc<br>

</blockquote></div><div><br>Hi Jean-Christophe,<br><br>I&#39;ve managed to reproduce \
the bug. You can easily observe it when you use a vtkScalarBarWidget and you try to \
move it on screen. I am attaching a minimum &quot;working&quot; (reproducing would be \
more accurate) example. The dependencies in order to run the file are Python2, VTK \
and PyQt4.<br>

<br>The ScalarBarWidget is moving on screen but the following traceback is \
produced<br><br><span style="font-family:courier new,monospace">Traceback (most \
recent call last):</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">   File \
&quot;/usr/lib/python2.7/site-packages/vtk/qt4/QVTKRenderWindowInteractor.py&quot;, \
line 211, in ShowCursor</span><br style="font-family:courier new,monospace"><span \
style="font-family:courier new,monospace">       self.setCursor(cursor)</span><br \
style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">NameError: global name \
&#39;cursor&#39; is not defined</span><br><br>Changing the last line of the \
ShowCursor method (line 220 on the git repo) of QVTKRenderWindowInteractor class ( \
path : VTK/Wrapping/Python/vtk/qt4/QVTKRenderWindowInteractor.py), from<br>

<span style="font-family:courier \
new,monospace"><br>self.setCursor(cursor)</span><br><br>to <br><br><span \
style="font-family:courier \
new,monospace">self.setCursor(qt_cursor)</span><br><br>results to no traceback. <br> \
<br>This is the link to Gerrit ( <a \
href="http://review.source.kitware.com/#change,2469" \
target="_blank">http://review.source.kitware.com/#change,2469</a> ). Who should I add \
as a reviewer?<br><br>with regards,<br>Panos<br> <br>ps. Perhaps this is not the \
appropriate list, but how can you add examples to the wiki? I have created an account \
but it says that I don&#39;t have the rights to create a new page. I can edit this \
page though... ( <a href="http://www.vtk.org/Wiki/VTK/Examples/Python" \
target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Python</a> )<br>

</div></div>
</div><br>

--20cf303a2fcbbe923e04aa8d0c39--


["bug_report.py" (text/x-python)]

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from vtk import *
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
from PyQt4 import QtGui

class VTKWindow(QVTKRenderWindowInteractor):
    def __init__(self, parent, filename):
        super(VTKWindow, self).__init__(parent)

        self.parent = parent
        self.filename = filename

        self.reader = vtkUnstructuredGridReader()
        self.reader.SetFileName(self.filename)
        self.reader.Update()
        self.output = self.reader.GetOutput()
        self.scalar_range = self.output.GetScalarRange()
        
        # Create the custom lut and add it to the mapper
        self.lut = vtkLookupTable()
        self.lut.Build()
        
        self.mapper = vtkDataSetMapper()
        self.mapper.SetInput(self.output)
        self.mapper.SetScalarRange(self.scalar_range)
        self.mapper.SetLookupTable(self.lut)

        # Create the scalar_bar (legend) and set it up.
        self.scalar_bar = vtkScalarBarActor()
        self.scalar_bar.SetLookupTable(self.lut)
        
        self.actor = vtkActor()
        self.actor.SetMapper(self.mapper)

        self.renderer = vtkRenderer()
        self.renderer.AddActor(self.actor)
        self.renderer.AddActor2D(self.scalar_bar)

        self.renderer_window = self.GetRenderWindow()
        self.renderer_window.AddRenderer(self.renderer)
        self.renderer_window.SetSize(300,500)

        # In order to be able to move the scalar_bar we must use it as an
        # actor to vtkScalarBarWidget.
        # The vtkScalarBarWidget's 'On' method must be invoked last.
        self.scalar_bar_widget = vtkScalarBarWidget()
        self.scalar_bar_widget.SetScalarBarActor(self.scalar_bar)
        self.scalar_bar_widget.SetInteractor(self)
        self.scalar_bar_widget.On()
        
class VTKFrame(QtGui.QFrame):
    """Test class"""
    def __init__(self, parent, filename):
        super(VTKFrame, self).__init__(parent)

        hbox = QtGui.QHBoxLayout()

        # create the widget
        self.vtk_window = VTKWindow(self, filename)

        hbox.addWidget(self.vtk_window)
        self.setLayout(hbox)

if __name__ == "__main__":
     app = QtGui.QApplication(sys.argv)
     main = VTKFrame(None, "simple.vtk")
     main.show()
     sys.exit(app.exec_())

["simple.vtk" (application/octet-stream)]

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtk-developers



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic