[vtkusers] VTK CVS + wxPython...
Andrea Gavana
andrea.gavana at polymtl.ca
Thu Jul 22 03:48:17 EDT 2004
Hello NG,
thanks Charl for your kind help... So, this is what I've done:
> > Traceback (most recent call last):
> > File "C:\Python23\myproject\wxVTKRenderWindowInteractor.py", line 290, in
> > OnButtonUp
> > self.ReleaseMouse()
> > File "C:\Python23\Lib\site-packages\wxPython\windows.py", line 647, in
> > ReleaseMouse
> > val = windowsc.wxWindow_ReleaseMouse(self, *_args, **_kwargs)
> > wxPython.wxc.wxPyAssertionError: C++ assertion "GetCapture() == this"
> failed in
> > e:\Projects\wx2.4\src\common\wincmn.cpp(2006): attempt to release mouse,
> but
> > this window hasn't captured it
>
> Argh, this is due to the mouse capturing. I usually switch that off as
> the logic isn't failsafe yet.
I don't know how to switch it off... probably you know better than everyone else
what to do in order to avoid these messages.
> > No idea on what this means. But, fortunately, is a rarely appearing
> message.
> > Next, in my application I had defined a vtkOrientationMarkerWidget, but
> either
> > I've done something wrong or there is something wrong in the interactor
> (the
> > first is the MOST probable...), the vtkOrientationMarkerWidget does not
> follow
> > the interactor. It is frozen. I've tried some modification, but it seems to
> me
> > that the vtkOrientationMarkerWidget does not react to the mouse movements.
> > This is the last part of my code:
>
> Please send a sample that I can actually run. Your code looks alright,
> but there's nothing like being able to test it.
That is the strange thing. I can run your example in wxVTKRWI without problems,
and also adding the vtkOrientationMarkerWidget works perfectly (the
vtkOrientationMarkerWidget follows the wxVTKRWI). What I am not able to do is
run my application, that seems to me EXACTLY the same as the xample in
wxVTKRWI... The code in wxVTKRWI:
# every wx app needs an app
app = wxPySimpleApp()
# create the widget
frame = wxFrame(None, -1, "wxRenderWindow", size=wxSize(400,400))
widget = wxVTKRenderWindowInteractor(frame, -1)
# It would be more correct (API-wise) to call widget.Initialize() and
# widget.Start() here, but Initialize() calls RenderWindow.Render().
# That Render() call will get through before we can setup the
# RenderWindow() to render via the wxWidgets-created context; this
# causes flashing on some platforms and downright breaks things on
# other platforms. Instead, we call widget.Enable(). This means
# that the RWI::Initialized ivar is not set, but in THIS SPECIFIC CASE,
# that doesn't matter.
widget.Enable(1)
widget.AddObserver("ExitEvent", lambda o,e,f=frame: f.Close())
ren = vtk.vtkRenderer()
widget.GetRenderWindow().AddRenderer(ren)
cone = vtk.vtkConeSource()
cone.SetResolution(8)
coneMapper = vtk.vtkPolyDataMapper()
coneMapper.SetInput(cone.GetOutput())
coneActor = vtk.vtkActor()
coneActor.SetMapper(coneMapper)
ren.AddActor(coneActor)
# Create the Orientation marker
axes = vtk.vtkAxesActor()
wid = vtk.vtkOrientationMarkerWidget()
wid.SetViewport(-0.1, 0, 0.15, 0.25)
wid.SetOrientationMarker(axes)
wid.SetInteractor(widget)
wid.On()
wid.InteractiveOff()
# show the window
# on some platforms, this SetSize() is necessary to cause an OnPaint()
# when the event loop begins; else we get an empty window until we
# force a redraw.
frame.SetSize((640,480))
frame.Show(1)
app.MainLoop()
MY CODE:
frame = wxFrame(None, -1, "VTK Reservoir Surface", size=wxSize(400,400),
style=wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxNO_FULL_REPAINT_ON_RESIZE)
widget = wxVTKRenderWindowInteractor(frame,-1)
widget.Enable(1)
widget.AddObserver("ExitEvent", lambda o,e,f=frame: f.Close())
hiren = vtk.vtkRenderer()
widget.GetRenderWindow().AddRenderer(hiren)
# Add all the actors to the rendering scene
hiren.AddActor(actsurface)
hiren.AddActor(actedge)
for i in range(0,len(self.wellnames)):
hiren.AddActor(textActor[i])
hiren.AddActor(profileactor)
hiren.AddActor(outlineActor)
hiren.AddActor(axesActor)
hiren.AddActor(xconeActor)
hiren.AddActor(yconeActor)
hiren.AddActor(zconeActor)
# Orient correctly the grid and zoom
hiren.GetActiveCamera().Zoom(1.5)
hiren.GetActiveCamera().Elevation(135.0)
hiren.GetActiveCamera().Roll(180.0)
# Create the Orientation marker
axes = vtk.vtkAxesActor()
wid = vtk.vtkOrientationMarkerWidget()
wid.SetViewport(-0.1, 0, 0.15, 0.25)
wid.SetOrientationMarker(axes)
wid.SetInteractor(widget)
wid.On()
wid.InteractiveOff()
# show the window
frame.SetSize((1000,900))
frame.Show(1)
I can not see any difference between them... I'm crashing my head on it till
yesterday, and I don't see any changes...
Regarding:
> > As a last thing, Charl mentioned that:
> >
> > "In addition, a SetSize() call should be made on the FRAME to make sure
> that it
> > gets an OnPaint event when it's shown."
> >
> > I would say (based on the example in wxVTKRenderWindowInteractor), that:
> >
> > "In addition, a SetSize() call should be made on the WIDGET to make sure
> that it
> > gets an OnPaint event when it's shown."
>
> Strange... the sample (as it is now) was tested on XP and Debian, it
> should be fine. SetSize() on the frame leads to (eventually) an OnPaint
> being invoked on the RWI, which is what we want.
You were right Charl, it was just my stupid error...
Unfortunately, I don't know how reproduce this behavior (the OrientationMarker
frozen) without my application, and obviously I can not send all the files one
may need... it is just too big. But if someone would like to try, I can put all
the files on my website...
Thanks to everyone for all suggestions/pointers.
Andrea.
More information about the vtkusers
mailing list