[vtkusers] vtkOrientationMarkerWidget does not rotate in QVTKWidget

Jothy jothybasu at gmail.com
Wed Jun 23 11:54:57 EDT 2010


Example added

http://www.cmake.org/Wiki/VTK/Examples/Python/GeometricObjects/Display/AnnotatedCube

Thanks,

Jothy


On Wed, Jun 23, 2010 at 4:15 PM, Eric E. Monson <emonson at cs.duke.edu> wrote:

> Well, I was able to transplant your code into a PyQt4 app. (Since you're
> using Python, I'm assuming that's what you're using...?) Here's the code
> that works on my system and a screenshot.
>
> -Eric
>
>
>
> from PyQt4 import QtCore, QtGui
> from PyQt4.QtGui import QApplication
> import vtk
> from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
> import sys
>
> class Ui_MainWindow(object):
> def setupUi(self, MainWindow):
> MainWindow.setObjectName("MainWindow")
> MainWindow.resize(603, 553)
> self.centralWidget = QtGui.QWidget(MainWindow)
> self.gridlayout = QtGui.QGridLayout(self.centralWidget)
> self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget)
> self.gridlayout.addWidget(self.vtkWidget, 0, 0, 1, 1)
> MainWindow.setCentralWidget(self.centralWidget)
>
> class SimpleView(QtGui.QMainWindow):
>
> def __init__(self, parent = None):
>  QtGui.QMainWindow.__init__(self, parent)
> self.ui = Ui_MainWindow()
> self.ui.setupUi(self)
>  self.ren = vtk.vtkRenderer()
> self.ui.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
> iren = self.ui.vtkWidget.GetRenderWindow().GetInteractor()
>  cube = vtk.vtkCubeSource()
> cube.SetXLength(200)
> cube.SetYLength(200)
> cube.SetZLength(200)
> cube.Update()
> cm = vtk.vtkPolyDataMapper()
> cm.SetInputConnection(cube.GetOutputPort())
> ca = vtk.vtkActor()
> ca.SetMapper(cm)
>  self.ren.AddActor(ca)
>
> self.axesActor = vtk.vtkAnnotatedCubeActor();
> self.axesActor.SetXPlusFaceText('R')
> self.axesActor.SetXMinusFaceText('L')
> self.axesActor.SetYMinusFaceText('H')
> self.axesActor.SetYPlusFaceText('F')
> self.axesActor.SetZMinusFaceText('P')
> self.axesActor.SetZPlusFaceText('A')
> self.axesActor.GetTextEdgesProperty().SetColor(1,1,0)
> self.axesActor.GetTextEdgesProperty().SetLineWidth(2)
> self.axesActor.GetCubeProperty().SetColor(0,0,1)
> self.axes = vtk.vtkOrientationMarkerWidget()
> self.axes.SetOrientationMarker(self.axesActor)
> self.axes.SetInteractor(iren)
> self.axes.EnabledOn()
> self.axes.InteractiveOn()
>  self.ren.ResetCamera()
>  iren.Start()
>
> if __name__ == "__main__":
>
>     app = QApplication(sys.argv)
>     window = SimpleView()
>     window.show()
>     sys.exit(app.exec_())
>
>
>
> On Jun 23, 2010, at 10:24 AM, Jothy wrote:
>
> Why my orientationWidget is show like the one shown in the attached
> picture?
>
> Its a vtkAxesActor+vtkOrientationWidget with a cube rendered in QVTKWidget.
>
>
> Thanks,
>
> Jothy
>
>
> On Wed, Jun 23, 2010 at 3:07 PM, Jothy <jothybasu at gmail.com> wrote:
>
>> And it also appears cropped, I mean only the centre portion is visible.
>>
>> How to get the camera of the orientation widget renderer? So that I can
>> reset it.
>>
>> Thanks,
>>
>> Jothy
>>
>>
>> On Wed, Jun 23, 2010 at 2:23 PM, Jothy <jothybasu at gmail.com> wrote:
>>
>>> No Eric,
>>>
>>> The problem is not with this code, with this script I can rotate without
>>> calling start().But, when I embed it into a QVTKWidget, it doesn't work as
>>> expected. Did you tried with QVTKWidget?
>>>
>>> Thanks,
>>>
>>> Jothy
>>>
>>>
>>> On Wed, Jun 23, 2010 at 2:18 PM, Eric E. Monson <emonson at cs.duke.edu>wrote:
>>>
>>>> Hey Jothy,
>>>>
>>>> If I add iren.Start() at the end of this code it works for me. The blue
>>>> cube in the corner spins with the big white cube.
>>>>
>>>> -Eric
>>>>
>>>> ------------------------------------------------------
>>>> Eric E Monson
>>>> Duke Visualization Technology Group
>>>>
>>>>
>>>> On Jun 23, 2010, at 7:29 AM, Jothy wrote:
>>>>
>>>> > Hi all,
>>>> >
>>>> > I am trying to add a vtkOrientationMarkerWidget to a QVTKWidget. The
>>>> annotatedCube is displayed in the corner but it doesn't rotate along with
>>>> the other actors.
>>>> >
>>>> > I checkd the code with vtkRenderWindow, it works well. What is the
>>>> problem??
>>>> >
>>>> > Below is the code
>>>> >
>>>> >
>>>> >
>>>> > from vtk import*
>>>> > cube=vtkCubeSource()
>>>> > cube.SetXLength(200)
>>>> > cube.SetYLength(200)
>>>> > cube.SetZLength(200)
>>>> > cube.Update()
>>>> > cm=vtkPolyDataMapper()
>>>> > cm.SetInputConnection(cube.GetOutputPort())
>>>> > ca=vtkActor()
>>>> > ca.SetMapper(cm)
>>>> >
>>>> > renWin = vtkRenderWindow()
>>>> > ren=vtkRenderer()
>>>> > ren.AddActor(ca)
>>>> > renWin.AddRenderer(ren)
>>>> > iren = vtkRenderWindowInteractor()
>>>> > iren.SetRenderWindow(renWin)
>>>> > ren.SetBackground(0,0,0)
>>>> > renWin.Render()
>>>> >
>>>> > axesActor = vtkAnnotatedCubeActor();
>>>> > axesActor.SetXPlusFaceText('R')
>>>> > axesActor.SetXMinusFaceText('L')
>>>> > axesActor.SetYMinusFaceText('H')
>>>> > axesActor.SetYPlusFaceText('F')
>>>> > axesActor.SetZMinusFaceText('P')
>>>> > axesActor.SetZPlusFaceText('A')
>>>> > axesActor.GetTextEdgesProperty().SetColor(1,1,0)
>>>> > axesActor.GetTextEdgesProperty().SetLineWidth(2)
>>>> > axesActor.GetCubeProperty().SetColor(0,0,1)
>>>> > axes = vtkOrientationMarkerWidget();
>>>> > axes.SetOrientationMarker(axesActor);
>>>> > axes.SetInteractor(iren);
>>>> > axes.EnabledOn();
>>>> > axes.InteractiveOn();
>>>> >
>>>> >
>>>> > Thanks,
>>>> >
>>>> > Jothy
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> > _______________________________________________
>>>> > 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
>>>> >
>>>> > Follow this link to subscribe/unsubscribe:
>>>> > http://www.vtk.org/mailman/listinfo/vtkusers
>>>>
>>>>
>>>
>>
> <untitled.TIF>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100623/60a5b7c3/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 3034 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100623/60a5b7c3/attachment.png>


More information about the vtkusers mailing list