[vtkusers] VTK-7.0.0-Python-PyQt4-vtkImplicitPlaneWidget2-InteractionEvent

Giorgos Ragkousis giorgosragos at gmail.com
Wed Sep 21 06:16:21 EDT 2016


Hi vtk users,

Has any of you experienced problems when trying to register the interaction
event into a vtkImplicitPlaneWidget2 observer in an application with PyQt4?

I can successfully register the event out of PyQt4 app. However, when I am
trying to get vtkImplicitPlaneWidget2 to my PyQt4 application, the
AddObserver is not registered. The widget is properly displayed but I
cannot access the interaction mode. Thus, when I am moving the object, the
widget disappears.

In particular, I am trying to clip an unstructured grid and my clip method
looks like the following:

        plane = vtkPlane()
        plane.SetOrigin(0.0, 0.0, 0.0)

        clipData = vtkClipDataSet()
        clipData.SetInputData(actUG)
        clipData.SetClipFunction(plane)
        clipData.InsideOutOn()
        clipData.Update()

        clipMapper = vtkDataSetMapper()
        clipMapper.ImmediateModeRenderingOn()
        clipMapper.SetInputData(clipData.GetOutput())

        clipActor = vtkLODActor()
        clipActor.SetMapper(clipMapper)
        clipActor.VisibilityOn()
        clipActor.SetScale(1.01, 1.01, 1.01)

        # the following is my QWidget which contains the
QVTKRenderWindowInteractor

self.formWidgetC.iren.SetRenderWindow(self.formWidgetC.vtkWidget.GetRenderWindow())
#        backFaces = vtkProperty()
#        backFaces.SetDiffuseColor(0.8, 0.8, 0.4)
#        clipActor.SetBackfaceProperty(backFaces)
        def callback(pw, event):
            print("triggered")
            pw.GetRepresentation().GetPlane(plane)
            clipActor.VisibilityOn()

        rep = vtkImplicitPlaneRepresentation()
        rep.SetPlaceFactor(1.25)
        rep.PlaceWidget(actUG.GetBounds())
        rep.SetNormal(plane.GetNormal())
        rep.VisibilityOn()
        rep.GetPlane(plane)

        planeWidget = vtkImplicitPlaneWidget2()
        planeWidget.SetInteractor(self.formWidgetC.iren)
        planeWidget.SetRepresentation(rep)
        planeWidget.SetEnabled(1)
#        planeWidget.On()
#        planeWidget.SetInputData(actUG)
#        planeWidget.Set
#        planeWidget.PlaceWidget()
        planeWidget.AddObserver("InteractionEvent", callback)
        planeWidget.On()
        self.formWidgetC.ren.AddActor(clipActor)

#        self.formWidgetC.iren.Initialize()
        self.formWidgetC.iren.Render()
#        self.formWidgetC.iren.Start()

#
self.formWidgetC.vtkWidget.GetRenderWindow().GetInteractor().Render()


Any help would be much appreciated.

Giorgos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160921/44737142/attachment.html>


More information about the vtkusers mailing list