[vtkusers] VTK CVS + wxPython...

Andrea Gavana andrea.gavana at polymtl.ca
Wed Jul 21 11:58:28 EDT 2004


Hello NG,

      thank you A LOT Charl for your work on it. I've done exactly as you said,
and now it works. Anyway, for some reason the interaction is far slower than
before (rotation/pan/zooming), but this should not be a problem (for the
moment, at least...). Secondly, sometimes I get this kind of message from
wxWindows:

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

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:

frame = wxFrame(None, -1, "VTK Reservoir Surface", wxPoint(100,10),
wxSize(1000,900),
			style=wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxNO_FULL_REPAINT_ON_RESIZE)

widget = wxVTKRenderWindowInteractor(frame,-1)
widget.Enable(1)
hiren = vtkpython.vtkRenderer()

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)

hiren.GetActiveCamera().Zoom(1.5)
hiren.GetActiveCamera().Elevation(135.0)
hiren.GetActiveCamera().Roll(180.0)
widget.SetSize((1000,900))

widget.GetRenderWindow().AddRenderer(hiren)

axes = vtkpython.vtkAxesActor()

wid = vtkpython.vtkOrientationMarkerWidget()
wid.SetViewport(-0.1, 0, 0.15, 0.25)
wid.SetOrientationMarker(axes)
wid.SetInteractor(widget)
wid.On()
wid.InteractiveOff()

frame.Show(1)


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."

I've tried a SetSize() on the frame but I get a runtime error with Python...
Charl, you found this little "bug" on XP, but I think that it is the same on
Win2000, because I am on a Win2000 machine... Probably I am doing (again)
something wrong...

Anyway, thank you so much for your help.

Andrea.


Selon "Charl P. Botha" <c.p.botha at ewi.tudelft.nl>:

> Charl P. Botha wrote:
> > Andrea Gavana wrote:
> >
> >> The funny thing is that wxVTKRenderWindow works great... I can't see a
> >> lot of
> >> differences between the behavior of wxVTKrenderWindow and
> >> wxVTKRenderWindowInteractor (as Python code, I don't know anything
> >> about the
> >> C/C++ bases of them). I would like to use wxVTKRenderWindowInteractor
> >> because
> >> is more flexible and nice (in my opinion). But it still don't work. I've
> >> debugged the example in wxVTKRenderWindowInteractor and I saw that the
> >> second
> >> window (the one with title "Visualization Toolkit - Win32OpenGL #1",
> >> with a
> >> cone inside but not interactive) appears when
> >> wxVTKRenderWindowInteractor calls
> >> widget.Initialize() and widget.Start(), but commenting them out does
> >> not help
> >> me a lot... just eliminate the window with the cone and leaving me with a
> >> completely grey window called "wxRenderWindow"...
> >
> >
> > This is extremely strange... the wxVTKRenderWindowInteractor is working
> > (and has been working for years) here with VTK CVS and wxPython 2.4.2.4
> > in a rather extensive visualisation and image processing application on
> > both Debian stable and Windows XP and 2000, but I see (just now) that
> > I'm getting the same behaviour as you report on XP, but not on Debian.
> >
> > I'm on it...
>
> Okay, it seems that on Windows XP the OnPaint handler doesn't get called
> at window creation, which means that the rendering-to-wx-context logic
> doesn't get invoked until you force a redraw.  This is very strange.
>
> In anycase, I've checked in some changes to
> wxVTKRenderWindowInteractor.py (primarily to the example part, with lots
> of documentation).  The widget.Initialize() and widget.Start() calls
> should be removed (they cause trouble) and replaced by widget.Enable().
>   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'm going to spend more time on this later, but these changes should
> solve your problems.
>
> Good luck,
> Charl
>
> --
> charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/
>






More information about the vtkusers mailing list