[vtkusers] Possible Bug in vtkOrientationMarkerWidget / vtkProp
Martin Meiler
martin.meiler at simetris.de
Fri Jul 8 10:22:15 EDT 2016
Hello everybody,
I am facing a problem when using a vtkOrientationMarkerWidget in a
python/pyQt
environment.
python 2.7.3
vtk 6.1
pyQt: 4.10.1
I first define the axesActor and axesMarker and later in the code ...
> self.axesActor = vtk.vtkAxesActor()
> self.axesMarker = vtk.vtkOrientationMarkerWidget()
> self.axesMarker.SetDefaultRenderer(self.renderer)
>
> self.axesMarker.SetInteractor(self.interact)
>
> self.axesMarker.SetOrientationMarker(self.axesActor)
>
> self.axesMarker.SetOutlineColor(0.9300, 0.5700, 0.1300)
>
> self.axesMarker.SetViewport(0.8, 0.0, 1.0, 0.2)
>
> self.axesMarker.SetEnabled(0)
>
> self.renderer.AddActor(self.axesActor)
>
> self.axesActor.VisibilityOn()
>
...
change the size of the orientation markers.
> self.axesActor.SetTotalLength(delta, delta, delta)
If the parameter delta is larger equal 5e-3, than everything looks fine.
However if I
use values smaller than 5e-3 the tips of the axesActor suddenly all
point in x-Direction and
the labels are not readable.
Can someone reproduce this behavior? Is this a bug?
Please find attached a python file that allows to reproduce this
behavior (at least on my machine).
Best regards
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160708/eb5b69a6/attachment.html>
-------------- next part --------------
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 08 15:50:36 2016
@author: martin
"""
import sys
import vtk
from PyQt4 import QtGui
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent = None, radius=0.5):
super(MainWindow, self).__init__(parent)
self._sphereRad = radius
self._initUI()
self._initVtk()
def _initUI(self):
"""
This method sets up the pyqt items
"""
frame = QtGui.QFrame()
self.vtkWidget = QVTKRenderWindowInteractor(frame)
main_lhbox = QtGui.QHBoxLayout()
main_lhbox.addWidget(self.vtkWidget)
frame.setLayout(main_lhbox)
self.setCentralWidget(frame)
self.show()
def _initVtk(self):
"""
This method sets up the vtk objects
"""
self.attrib = vtk.vtkCompositeDataDisplayAttributes()
self.mapper = vtk.vtkCompositePolyDataMapper2()
self.mapper.SetCompositeDataDisplayAttributes(self.attrib)
# Create an actor
self.actor = vtk.vtkActor()
self.actor.SetMapper(self.mapper)
self.actor.GetProperty().SetInterpolationToFlat()
self.actor.GetProperty().EdgeVisibilityOff()
self.actor.GetProperty().SetOpacity(0.5)
self.renderer = vtk.vtkRenderer()
self.renderer.GradientBackgroundOn();
self.renderer.SetBackground(1,1,1);
self.renderer.SetBackground2(37./255, 127./255, 194./255);
self.renderer.AddActor(self.actor)
self.vtkWidget.GetRenderWindow().AddRenderer(self.renderer)
self.interact = self.vtkWidget.GetRenderWindow().GetInteractor()
self.interact.Initialize()
self.sphere = vtk.vtkSphereSource()
self.sphere.SetRadius(self._sphereRad)
self.sphere.Modified()
self.geoF = vtk.vtkDataSetSurfaceFilter()
self.axesActor = vtk.vtkAxesActor()
self.axesMarker = vtk.vtkOrientationMarkerWidget()
self.axesMarker.SetDefaultRenderer(self.renderer)
self.axesMarker.SetInteractor(self.interact)
self.axesMarker.SetOrientationMarker(self.axesActor)
self.axesMarker.SetOutlineColor(0.9300, 0.5700, 0.1300)
self.axesMarker.SetEnabled(0)
self.renderer.AddActor(self.axesActor)
self.axesActor.VisibilityOn()
self.axesActor.SetTotalLength(0.5*self._sphereRad,
0.5*self._sphereRad,
0.5*self._sphereRad)
self.geoF.SetInputConnection(self.sphere.GetOutputPort())
self.mapper.SetInputConnection(self.geoF.GetOutputPort())
style = vtk.vtkInteractorStyleTrackballCamera()
self.renderer.GetActiveCamera().ParallelProjectionOff()
self.interact.SetInteractorStyle(style)
style.EnabledOn()
self.renderer.ResetCamera(self.mapper.GetBounds())
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
window = MainWindow(radius=9e-3)
sys.exit(app.exec_())
More information about the vtkusers
mailing list