Concluding a mouse-event action in VTK within a wxPanel











up vote
0
down vote

favorite












I am writing an application to render a point cloud in VTK, using a wxPython GUI. I've based the code on the excellent examples by Sukhbinder Singh here and here. I'd like now to implement a right-mouse-click option in my data panel, which allows the user to do various tasks (like reset the camera position) through a context menu. I've tried a couple of different scenarios but the behavior is slightly wrong in each one:



A) The event "RightButtonPressEvent" allows me to select the right item out of my context menu and performs the bound function, but then won't respond to the left mouse button anymore, and



B) the event "RightButtonReleaseEvent" gets to performing the bound function as well, but then any subsequent movement of the mouse acts as though I still have the right button depressed. In my current VTK render window interactor style, this means zooming in/out - until I click the left mouse button.



I've tried (B) with a subsequent PostEvent call to simulate a left-mouse-click, to no avail. Adding the event directly to the interactor rather than to its style has the same effect. Can anyone tell me what I'm missing?



Using Python 3.4/3.6 on Win7, wx 4.0.3, vtk 8.1.1.



My long-ish "minimal" example below:



import wx
import vtk
from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
import numpy as np

class VtkPointCloud:

def __init__(self, zMin=-10.0, zMax=10.0):
self.maxNumPoints = 1e6
self.vtkPolyData = vtk.vtkPolyData()
self.clearPoints()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(self.vtkPolyData)
mapper.SetColorModeToDefault()
mapper.SetScalarRange(zMin, zMax)
mapper.SetScalarVisibility(1)
self.vtkActor = vtk.vtkActor()
self.vtkActor.SetMapper(mapper)

def addPoint(self, point):
if self.vtkPoints.GetNumberOfPoints() < self.maxNumPoints:
pointId = self.vtkPoints.InsertNextPoint(point[:])
self.vtkDepth.InsertNextValue(point[2])
self.vtkCells.InsertNextCell(1)
self.vtkCells.InsertCellPoint(pointId)
self.vtkCells.Modified()
self.vtkPoints.Modified()
self.vtkDepth.Modified()

def clearPoints(self):
self.vtkPoints = vtk.vtkPoints()
self.vtkCells = vtk.vtkCellArray()
self.vtkDepth = vtk.vtkDoubleArray()
self.vtkDepth.SetName('DepthArray')
self.vtkPolyData.SetPoints(self.vtkPoints)
self.vtkPolyData.SetVerts(self.vtkCells)
self.vtkPolyData.GetPointData().SetScalars(self.vtkDepth)
self.vtkPolyData.GetPointData().SetActiveScalars('DepthArray')


class p1(wx.Panel):
# ---------------------------------------------------------------------------------------------
def __init__(self,parent):
wx.Panel.__init__(self, parent)

self.widget = wxVTKRenderWindowInteractor(self, -1)
self.widget.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
self.widget.Enable(1)
self.widget.AddObserver("ExitEvent", lambda o,e,f=self: f.Close())
i_style = self.widget.GetInteractorStyle()
#i_style.AddObserver("RightButtonPressEvent", self._context_menu) # Freezes panel!
i_style.AddObserver("RightButtonReleaseEvent", self._context_menu)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.widget, 1, wx.EXPAND)
self.SetSizer(self.sizer)
self.Layout()
self.is_plotted = False

# ---------------------------------------------------------------------------------------------
def renderthis(self):
# open a window and create a renderer
pointCloud = VtkPointCloud()
data = 20*(np.random.rand(3,1000)-0.5)
for i in range(data.shape[1]):
pointCloud.addPoint(data[:,i])

camera = vtk.vtkCamera()
midpoint_x = 0
midpoint_y = 0
camera.SetPosition(midpoint_x, midpoint_y, -np.nanmax(data[2,:])); # eye position
camera.SetFocalPoint(midpoint_x, midpoint_y, np.nanmax(data[2,:])) # perspective vanishing point

# Save the default view
self._default_cam_pos = camera.GetPosition()
self._default_cam_focal = camera.GetFocalPoint()
self._default_view_up = camera.GetViewUp()

# Renderer
self._renderer = vtk.vtkRenderer()
self._renderer.AddActor(pointCloud.vtkActor)
self._renderer.SetBackground(0.0, 0.0, 0.0)
self._renderer.SetActiveCamera(camera)

# Render Window
self.widget.GetRenderWindow().AddRenderer(self._renderer)


# ---------------------------------------------------------------------------------------------
def _context_menu(self, caller, event):
reset_cam_ID = wx.NewId()
self.Bind(wx.EVT_MENU, self._on_reset_cam, id=reset_cam_ID)
menu = wx.Menu()
menu.Append(reset_cam_ID, "Reset camera")
self.PopupMenu(menu)
menu.Destroy()


# ---------------------------------------------------------------------------------------------
def _on_reset_cam(self, event):
cam = self._renderer.GetActiveCamera()
cam.SetPosition(self._default_cam_pos)
cam.SetFocalPoint(self._default_cam_focal)
cam.SetViewUp(self._default_view_up)
self.Refresh()


class TestFrame(wx.Frame):

# ---------------------------------------------------------------------------------------------
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(650,600),
style=(wx.MINIMIZE_BOX |
wx.SYSTEM_MENU |
wx.CAPTION |
wx.CLOSE_BOX |
wx.CLIP_CHILDREN))
self.sp = wx.SplitterWindow(self)
self.p1 = p1(self.sp)
self.p2 = wx.Panel(self.sp, style=wx.SUNKEN_BORDER)

self.sp.SplitHorizontally(self.p1, self.p2, 470)

self.statusbar = self.CreateStatusBar()
self.statusbar.SetStatusText("Click on the Plot Button")

self.plotbut = wx.Button(self.p2, -1, "Plot", size=(40,20), pos=(10,10))
self.plotbut.Bind(wx.EVT_BUTTON,self.plot)

# ---------------------------------------------------------------------------------------------
def plot(self,event):
if not self.p1.is_plotted:
self.p1.renderthis()
self.statusbar.SetStatusText("Use your mouse to interact with the model")


app = wx.App(redirect=False)
frame = TestFrame(None, "Pointcloud")
frame.Show()
app.MainLoop()









share|improve this question


























    up vote
    0
    down vote

    favorite












    I am writing an application to render a point cloud in VTK, using a wxPython GUI. I've based the code on the excellent examples by Sukhbinder Singh here and here. I'd like now to implement a right-mouse-click option in my data panel, which allows the user to do various tasks (like reset the camera position) through a context menu. I've tried a couple of different scenarios but the behavior is slightly wrong in each one:



    A) The event "RightButtonPressEvent" allows me to select the right item out of my context menu and performs the bound function, but then won't respond to the left mouse button anymore, and



    B) the event "RightButtonReleaseEvent" gets to performing the bound function as well, but then any subsequent movement of the mouse acts as though I still have the right button depressed. In my current VTK render window interactor style, this means zooming in/out - until I click the left mouse button.



    I've tried (B) with a subsequent PostEvent call to simulate a left-mouse-click, to no avail. Adding the event directly to the interactor rather than to its style has the same effect. Can anyone tell me what I'm missing?



    Using Python 3.4/3.6 on Win7, wx 4.0.3, vtk 8.1.1.



    My long-ish "minimal" example below:



    import wx
    import vtk
    from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
    import numpy as np

    class VtkPointCloud:

    def __init__(self, zMin=-10.0, zMax=10.0):
    self.maxNumPoints = 1e6
    self.vtkPolyData = vtk.vtkPolyData()
    self.clearPoints()
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputData(self.vtkPolyData)
    mapper.SetColorModeToDefault()
    mapper.SetScalarRange(zMin, zMax)
    mapper.SetScalarVisibility(1)
    self.vtkActor = vtk.vtkActor()
    self.vtkActor.SetMapper(mapper)

    def addPoint(self, point):
    if self.vtkPoints.GetNumberOfPoints() < self.maxNumPoints:
    pointId = self.vtkPoints.InsertNextPoint(point[:])
    self.vtkDepth.InsertNextValue(point[2])
    self.vtkCells.InsertNextCell(1)
    self.vtkCells.InsertCellPoint(pointId)
    self.vtkCells.Modified()
    self.vtkPoints.Modified()
    self.vtkDepth.Modified()

    def clearPoints(self):
    self.vtkPoints = vtk.vtkPoints()
    self.vtkCells = vtk.vtkCellArray()
    self.vtkDepth = vtk.vtkDoubleArray()
    self.vtkDepth.SetName('DepthArray')
    self.vtkPolyData.SetPoints(self.vtkPoints)
    self.vtkPolyData.SetVerts(self.vtkCells)
    self.vtkPolyData.GetPointData().SetScalars(self.vtkDepth)
    self.vtkPolyData.GetPointData().SetActiveScalars('DepthArray')


    class p1(wx.Panel):
    # ---------------------------------------------------------------------------------------------
    def __init__(self,parent):
    wx.Panel.__init__(self, parent)

    self.widget = wxVTKRenderWindowInteractor(self, -1)
    self.widget.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
    self.widget.Enable(1)
    self.widget.AddObserver("ExitEvent", lambda o,e,f=self: f.Close())
    i_style = self.widget.GetInteractorStyle()
    #i_style.AddObserver("RightButtonPressEvent", self._context_menu) # Freezes panel!
    i_style.AddObserver("RightButtonReleaseEvent", self._context_menu)
    self.sizer = wx.BoxSizer(wx.VERTICAL)
    self.sizer.Add(self.widget, 1, wx.EXPAND)
    self.SetSizer(self.sizer)
    self.Layout()
    self.is_plotted = False

    # ---------------------------------------------------------------------------------------------
    def renderthis(self):
    # open a window and create a renderer
    pointCloud = VtkPointCloud()
    data = 20*(np.random.rand(3,1000)-0.5)
    for i in range(data.shape[1]):
    pointCloud.addPoint(data[:,i])

    camera = vtk.vtkCamera()
    midpoint_x = 0
    midpoint_y = 0
    camera.SetPosition(midpoint_x, midpoint_y, -np.nanmax(data[2,:])); # eye position
    camera.SetFocalPoint(midpoint_x, midpoint_y, np.nanmax(data[2,:])) # perspective vanishing point

    # Save the default view
    self._default_cam_pos = camera.GetPosition()
    self._default_cam_focal = camera.GetFocalPoint()
    self._default_view_up = camera.GetViewUp()

    # Renderer
    self._renderer = vtk.vtkRenderer()
    self._renderer.AddActor(pointCloud.vtkActor)
    self._renderer.SetBackground(0.0, 0.0, 0.0)
    self._renderer.SetActiveCamera(camera)

    # Render Window
    self.widget.GetRenderWindow().AddRenderer(self._renderer)


    # ---------------------------------------------------------------------------------------------
    def _context_menu(self, caller, event):
    reset_cam_ID = wx.NewId()
    self.Bind(wx.EVT_MENU, self._on_reset_cam, id=reset_cam_ID)
    menu = wx.Menu()
    menu.Append(reset_cam_ID, "Reset camera")
    self.PopupMenu(menu)
    menu.Destroy()


    # ---------------------------------------------------------------------------------------------
    def _on_reset_cam(self, event):
    cam = self._renderer.GetActiveCamera()
    cam.SetPosition(self._default_cam_pos)
    cam.SetFocalPoint(self._default_cam_focal)
    cam.SetViewUp(self._default_view_up)
    self.Refresh()


    class TestFrame(wx.Frame):

    # ---------------------------------------------------------------------------------------------
    def __init__(self, parent, title):
    wx.Frame.__init__(self, parent, title=title, size=(650,600),
    style=(wx.MINIMIZE_BOX |
    wx.SYSTEM_MENU |
    wx.CAPTION |
    wx.CLOSE_BOX |
    wx.CLIP_CHILDREN))
    self.sp = wx.SplitterWindow(self)
    self.p1 = p1(self.sp)
    self.p2 = wx.Panel(self.sp, style=wx.SUNKEN_BORDER)

    self.sp.SplitHorizontally(self.p1, self.p2, 470)

    self.statusbar = self.CreateStatusBar()
    self.statusbar.SetStatusText("Click on the Plot Button")

    self.plotbut = wx.Button(self.p2, -1, "Plot", size=(40,20), pos=(10,10))
    self.plotbut.Bind(wx.EVT_BUTTON,self.plot)

    # ---------------------------------------------------------------------------------------------
    def plot(self,event):
    if not self.p1.is_plotted:
    self.p1.renderthis()
    self.statusbar.SetStatusText("Use your mouse to interact with the model")


    app = wx.App(redirect=False)
    frame = TestFrame(None, "Pointcloud")
    frame.Show()
    app.MainLoop()









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am writing an application to render a point cloud in VTK, using a wxPython GUI. I've based the code on the excellent examples by Sukhbinder Singh here and here. I'd like now to implement a right-mouse-click option in my data panel, which allows the user to do various tasks (like reset the camera position) through a context menu. I've tried a couple of different scenarios but the behavior is slightly wrong in each one:



      A) The event "RightButtonPressEvent" allows me to select the right item out of my context menu and performs the bound function, but then won't respond to the left mouse button anymore, and



      B) the event "RightButtonReleaseEvent" gets to performing the bound function as well, but then any subsequent movement of the mouse acts as though I still have the right button depressed. In my current VTK render window interactor style, this means zooming in/out - until I click the left mouse button.



      I've tried (B) with a subsequent PostEvent call to simulate a left-mouse-click, to no avail. Adding the event directly to the interactor rather than to its style has the same effect. Can anyone tell me what I'm missing?



      Using Python 3.4/3.6 on Win7, wx 4.0.3, vtk 8.1.1.



      My long-ish "minimal" example below:



      import wx
      import vtk
      from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
      import numpy as np

      class VtkPointCloud:

      def __init__(self, zMin=-10.0, zMax=10.0):
      self.maxNumPoints = 1e6
      self.vtkPolyData = vtk.vtkPolyData()
      self.clearPoints()
      mapper = vtk.vtkPolyDataMapper()
      mapper.SetInputData(self.vtkPolyData)
      mapper.SetColorModeToDefault()
      mapper.SetScalarRange(zMin, zMax)
      mapper.SetScalarVisibility(1)
      self.vtkActor = vtk.vtkActor()
      self.vtkActor.SetMapper(mapper)

      def addPoint(self, point):
      if self.vtkPoints.GetNumberOfPoints() < self.maxNumPoints:
      pointId = self.vtkPoints.InsertNextPoint(point[:])
      self.vtkDepth.InsertNextValue(point[2])
      self.vtkCells.InsertNextCell(1)
      self.vtkCells.InsertCellPoint(pointId)
      self.vtkCells.Modified()
      self.vtkPoints.Modified()
      self.vtkDepth.Modified()

      def clearPoints(self):
      self.vtkPoints = vtk.vtkPoints()
      self.vtkCells = vtk.vtkCellArray()
      self.vtkDepth = vtk.vtkDoubleArray()
      self.vtkDepth.SetName('DepthArray')
      self.vtkPolyData.SetPoints(self.vtkPoints)
      self.vtkPolyData.SetVerts(self.vtkCells)
      self.vtkPolyData.GetPointData().SetScalars(self.vtkDepth)
      self.vtkPolyData.GetPointData().SetActiveScalars('DepthArray')


      class p1(wx.Panel):
      # ---------------------------------------------------------------------------------------------
      def __init__(self,parent):
      wx.Panel.__init__(self, parent)

      self.widget = wxVTKRenderWindowInteractor(self, -1)
      self.widget.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
      self.widget.Enable(1)
      self.widget.AddObserver("ExitEvent", lambda o,e,f=self: f.Close())
      i_style = self.widget.GetInteractorStyle()
      #i_style.AddObserver("RightButtonPressEvent", self._context_menu) # Freezes panel!
      i_style.AddObserver("RightButtonReleaseEvent", self._context_menu)
      self.sizer = wx.BoxSizer(wx.VERTICAL)
      self.sizer.Add(self.widget, 1, wx.EXPAND)
      self.SetSizer(self.sizer)
      self.Layout()
      self.is_plotted = False

      # ---------------------------------------------------------------------------------------------
      def renderthis(self):
      # open a window and create a renderer
      pointCloud = VtkPointCloud()
      data = 20*(np.random.rand(3,1000)-0.5)
      for i in range(data.shape[1]):
      pointCloud.addPoint(data[:,i])

      camera = vtk.vtkCamera()
      midpoint_x = 0
      midpoint_y = 0
      camera.SetPosition(midpoint_x, midpoint_y, -np.nanmax(data[2,:])); # eye position
      camera.SetFocalPoint(midpoint_x, midpoint_y, np.nanmax(data[2,:])) # perspective vanishing point

      # Save the default view
      self._default_cam_pos = camera.GetPosition()
      self._default_cam_focal = camera.GetFocalPoint()
      self._default_view_up = camera.GetViewUp()

      # Renderer
      self._renderer = vtk.vtkRenderer()
      self._renderer.AddActor(pointCloud.vtkActor)
      self._renderer.SetBackground(0.0, 0.0, 0.0)
      self._renderer.SetActiveCamera(camera)

      # Render Window
      self.widget.GetRenderWindow().AddRenderer(self._renderer)


      # ---------------------------------------------------------------------------------------------
      def _context_menu(self, caller, event):
      reset_cam_ID = wx.NewId()
      self.Bind(wx.EVT_MENU, self._on_reset_cam, id=reset_cam_ID)
      menu = wx.Menu()
      menu.Append(reset_cam_ID, "Reset camera")
      self.PopupMenu(menu)
      menu.Destroy()


      # ---------------------------------------------------------------------------------------------
      def _on_reset_cam(self, event):
      cam = self._renderer.GetActiveCamera()
      cam.SetPosition(self._default_cam_pos)
      cam.SetFocalPoint(self._default_cam_focal)
      cam.SetViewUp(self._default_view_up)
      self.Refresh()


      class TestFrame(wx.Frame):

      # ---------------------------------------------------------------------------------------------
      def __init__(self, parent, title):
      wx.Frame.__init__(self, parent, title=title, size=(650,600),
      style=(wx.MINIMIZE_BOX |
      wx.SYSTEM_MENU |
      wx.CAPTION |
      wx.CLOSE_BOX |
      wx.CLIP_CHILDREN))
      self.sp = wx.SplitterWindow(self)
      self.p1 = p1(self.sp)
      self.p2 = wx.Panel(self.sp, style=wx.SUNKEN_BORDER)

      self.sp.SplitHorizontally(self.p1, self.p2, 470)

      self.statusbar = self.CreateStatusBar()
      self.statusbar.SetStatusText("Click on the Plot Button")

      self.plotbut = wx.Button(self.p2, -1, "Plot", size=(40,20), pos=(10,10))
      self.plotbut.Bind(wx.EVT_BUTTON,self.plot)

      # ---------------------------------------------------------------------------------------------
      def plot(self,event):
      if not self.p1.is_plotted:
      self.p1.renderthis()
      self.statusbar.SetStatusText("Use your mouse to interact with the model")


      app = wx.App(redirect=False)
      frame = TestFrame(None, "Pointcloud")
      frame.Show()
      app.MainLoop()









      share|improve this question













      I am writing an application to render a point cloud in VTK, using a wxPython GUI. I've based the code on the excellent examples by Sukhbinder Singh here and here. I'd like now to implement a right-mouse-click option in my data panel, which allows the user to do various tasks (like reset the camera position) through a context menu. I've tried a couple of different scenarios but the behavior is slightly wrong in each one:



      A) The event "RightButtonPressEvent" allows me to select the right item out of my context menu and performs the bound function, but then won't respond to the left mouse button anymore, and



      B) the event "RightButtonReleaseEvent" gets to performing the bound function as well, but then any subsequent movement of the mouse acts as though I still have the right button depressed. In my current VTK render window interactor style, this means zooming in/out - until I click the left mouse button.



      I've tried (B) with a subsequent PostEvent call to simulate a left-mouse-click, to no avail. Adding the event directly to the interactor rather than to its style has the same effect. Can anyone tell me what I'm missing?



      Using Python 3.4/3.6 on Win7, wx 4.0.3, vtk 8.1.1.



      My long-ish "minimal" example below:



      import wx
      import vtk
      from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
      import numpy as np

      class VtkPointCloud:

      def __init__(self, zMin=-10.0, zMax=10.0):
      self.maxNumPoints = 1e6
      self.vtkPolyData = vtk.vtkPolyData()
      self.clearPoints()
      mapper = vtk.vtkPolyDataMapper()
      mapper.SetInputData(self.vtkPolyData)
      mapper.SetColorModeToDefault()
      mapper.SetScalarRange(zMin, zMax)
      mapper.SetScalarVisibility(1)
      self.vtkActor = vtk.vtkActor()
      self.vtkActor.SetMapper(mapper)

      def addPoint(self, point):
      if self.vtkPoints.GetNumberOfPoints() < self.maxNumPoints:
      pointId = self.vtkPoints.InsertNextPoint(point[:])
      self.vtkDepth.InsertNextValue(point[2])
      self.vtkCells.InsertNextCell(1)
      self.vtkCells.InsertCellPoint(pointId)
      self.vtkCells.Modified()
      self.vtkPoints.Modified()
      self.vtkDepth.Modified()

      def clearPoints(self):
      self.vtkPoints = vtk.vtkPoints()
      self.vtkCells = vtk.vtkCellArray()
      self.vtkDepth = vtk.vtkDoubleArray()
      self.vtkDepth.SetName('DepthArray')
      self.vtkPolyData.SetPoints(self.vtkPoints)
      self.vtkPolyData.SetVerts(self.vtkCells)
      self.vtkPolyData.GetPointData().SetScalars(self.vtkDepth)
      self.vtkPolyData.GetPointData().SetActiveScalars('DepthArray')


      class p1(wx.Panel):
      # ---------------------------------------------------------------------------------------------
      def __init__(self,parent):
      wx.Panel.__init__(self, parent)

      self.widget = wxVTKRenderWindowInteractor(self, -1)
      self.widget.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
      self.widget.Enable(1)
      self.widget.AddObserver("ExitEvent", lambda o,e,f=self: f.Close())
      i_style = self.widget.GetInteractorStyle()
      #i_style.AddObserver("RightButtonPressEvent", self._context_menu) # Freezes panel!
      i_style.AddObserver("RightButtonReleaseEvent", self._context_menu)
      self.sizer = wx.BoxSizer(wx.VERTICAL)
      self.sizer.Add(self.widget, 1, wx.EXPAND)
      self.SetSizer(self.sizer)
      self.Layout()
      self.is_plotted = False

      # ---------------------------------------------------------------------------------------------
      def renderthis(self):
      # open a window and create a renderer
      pointCloud = VtkPointCloud()
      data = 20*(np.random.rand(3,1000)-0.5)
      for i in range(data.shape[1]):
      pointCloud.addPoint(data[:,i])

      camera = vtk.vtkCamera()
      midpoint_x = 0
      midpoint_y = 0
      camera.SetPosition(midpoint_x, midpoint_y, -np.nanmax(data[2,:])); # eye position
      camera.SetFocalPoint(midpoint_x, midpoint_y, np.nanmax(data[2,:])) # perspective vanishing point

      # Save the default view
      self._default_cam_pos = camera.GetPosition()
      self._default_cam_focal = camera.GetFocalPoint()
      self._default_view_up = camera.GetViewUp()

      # Renderer
      self._renderer = vtk.vtkRenderer()
      self._renderer.AddActor(pointCloud.vtkActor)
      self._renderer.SetBackground(0.0, 0.0, 0.0)
      self._renderer.SetActiveCamera(camera)

      # Render Window
      self.widget.GetRenderWindow().AddRenderer(self._renderer)


      # ---------------------------------------------------------------------------------------------
      def _context_menu(self, caller, event):
      reset_cam_ID = wx.NewId()
      self.Bind(wx.EVT_MENU, self._on_reset_cam, id=reset_cam_ID)
      menu = wx.Menu()
      menu.Append(reset_cam_ID, "Reset camera")
      self.PopupMenu(menu)
      menu.Destroy()


      # ---------------------------------------------------------------------------------------------
      def _on_reset_cam(self, event):
      cam = self._renderer.GetActiveCamera()
      cam.SetPosition(self._default_cam_pos)
      cam.SetFocalPoint(self._default_cam_focal)
      cam.SetViewUp(self._default_view_up)
      self.Refresh()


      class TestFrame(wx.Frame):

      # ---------------------------------------------------------------------------------------------
      def __init__(self, parent, title):
      wx.Frame.__init__(self, parent, title=title, size=(650,600),
      style=(wx.MINIMIZE_BOX |
      wx.SYSTEM_MENU |
      wx.CAPTION |
      wx.CLOSE_BOX |
      wx.CLIP_CHILDREN))
      self.sp = wx.SplitterWindow(self)
      self.p1 = p1(self.sp)
      self.p2 = wx.Panel(self.sp, style=wx.SUNKEN_BORDER)

      self.sp.SplitHorizontally(self.p1, self.p2, 470)

      self.statusbar = self.CreateStatusBar()
      self.statusbar.SetStatusText("Click on the Plot Button")

      self.plotbut = wx.Button(self.p2, -1, "Plot", size=(40,20), pos=(10,10))
      self.plotbut.Bind(wx.EVT_BUTTON,self.plot)

      # ---------------------------------------------------------------------------------------------
      def plot(self,event):
      if not self.p1.is_plotted:
      self.p1.renderthis()
      self.statusbar.SetStatusText("Use your mouse to interact with the model")


      app = wx.App(redirect=False)
      frame = TestFrame(None, "Pointcloud")
      frame.Show()
      app.MainLoop()






      wxpython vtk






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 at 21:22









      Tanaya

      34649




      34649





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270308%2fconcluding-a-mouse-event-action-in-vtk-within-a-wxpanel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270308%2fconcluding-a-mouse-event-action-in-vtk-within-a-wxpanel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?