[vtkusers] GetEventPosition() problem

hchen hjchen.work at gmail.com
Thu Feb 11 14:05:11 EST 2016


I have a vtkwidget embedded in a pyqt frame, the frame is a part of pyqt main
window. I use vtkImageViewer2 to display CT slices, here is how I set up:
        ...
        self.vtkWidgetCT = QVTKRenderWindowInteractor(self.ui.CTFrame)
        self.gridlayoutCT =  QtGui.QGridLayout(self.ui.CTFrame)
        self.gridlayoutCT.addWidget(self.vtkWidgetCT, 0, 0, 1, 1)  
        self.imageViewerCT = vtk.vtkImageViewer2()     
       
self.imageViewerCT.SetupInteractor(self.vtkWidgetCT.GetRenderWindow().GetInteractor())
       
self.imageViewerCT.SetRenderWindow(self.vtkWidgetCT.GetRenderWindow())
        self.imageViewerCT.GetRenderer().SetBackground(0.5, 0.5, 0.5) 
        self.irenCT = self.imageViewerCT.GetRenderWindow().GetInteractor()
        ...

I need to draw a line on top of the CT using mouse: first click for the
beginning of the line, second click for the end. I use
irenCT.GetEventPosition() to get mouse click positions. 

Here is my problem:
When the program starts, the main window is not maximized,
GetEventPosition() gives correct x, but wrong y. Now if I simply maximize
the main window (the qt frame where the vtkwidget is in gets larger
accordingly), then GetEventPosition() gives both x and y correctly
thereafter, even when restoring main window to its previous size.

It feels like when the program starts, there is "something" not updated/set
correctly, when maximizing the window, everything is re-drawn, this
"something" gets corrected. Can anyone please help to point out what this
"something" might be or what I forget to set in the first place? 

Thank you!

Chen




--
View this message in context: http://vtk.1045678.n5.nabble.com/GetEventPosition-problem-tp5736541.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list