wxWindows render window for win32
Brian Alexander Todd
bat5 at po.cwru.edu
Mon Sep 27 10:05:20 EDT 1999
Igor,
I am at the early stages of developing a vtk/wxWindows
app. It is fairly easy to get vtk to render into a
wxWindow, but you must use platform specific vtkRenderWindow
objects for whatever platform you are using. To implement
this on MSW essentially works the way it does if you were
just using VC++.
I am using the document/view framework. The basic structure
has "documents" presenting vtkActor/vtkLODActors and vtkRenderWindow
as the "view". The view is of course where wx and vtk get linked Here's,
the basic strucuture of the class. It has a wxWindow, a vtkRenderer
and a vtkWin32OpenGLRenderWindow.
class wxVtkRenderWindowView : public wxView
{
DECLARE_DYNAMIC_CLASS(wxVtkRenderWindowView)
private:
wxWindow * canvas;
vtkWin32OpenGLRenderWindow * renWindow;
vtkRenderer * ren;
public:
wxVtkRenderWindowView();
~wxVtkRenderWindowView();
bool OnCreate(wxDocument *doc, long flags);
void OnDraw(wxDC *dc);
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
DECLARE_EVENT_TABLE()
};
The vtkRenderWindow gets linked to the wxWindow (canvas) in the OnCreate
method that is called automatically when the object is created. Here's
what it looked like. I don't really understand all of the window handle
semantics but it was pretty easy to basically copy the ugview2 example
as wxWindows mimics VC++ quite a bit.
bool wxVtkRenderWindowView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
{
ren = vtkRenderer::New();
renWindow = vtkWin32OpenGLRenderWindow::New();
HDC hdc;
HWND hwnd;
hwnd = (HWND) canvas->GetHWND();
hdc = ::GetDC( hwnd );
renWindow->SetWindowId( hwnd );
renWindow->SwapBuffersOn();
renWindow->AddRenderer(ren);
return( TRUE );
}
That's pretty much all it takes to get the vtkRenderWindow
to work its magic in a wxWindow. You'll also need to tell
the window to reRender when it is exposed and resized. This
is easy to do in the document/view framework since all of these
things are funneled through the OnDraw method. You simply
call renWindow->Render() in like,
void wxVtkRenderWindowView::OnDraw(wxDC *dc)
{
if ( GetDocument()->IsModified() )
{
this->OnUpdate( NULL,NULL );
}
renWindow->Render();
}
If you want any code or so forth I would be glad to
make it available although it would only be a starting
place, as I am very much in development. Also I would
appreciate a look at your work in the future, if you are
open to that kind of thing.
Thanks,
Brian
At 06:27 PM 9/26/99 -0700, you wrote:
>Hello, I'd like to know if anyone has been sucessful
>at developing a widget that derives from one of the
>wxWindows version 2 classes that displays a render
>window. There is currently a class that will work
>only for wxWin version 1 and unix.
>
>If no one has developed the render widget, I'd
>appreciate any help you can give me before I myself
>undertake this project.
>
>Thank you
>
>=====
>==================================================
>Igor Fridman
>
>Naval Research Laboratory
>Vacuum Electronics Branch Code 6841
>4555 Overlook Ave. S.W., Washington, DC 20375, USA
>==================================================
>__________________________________________________
>Do You Yahoo!?
>Bid and sell for free at http://auctions.yahoo.com
>
>
>-----------------------------------------------------------------------------
>This is the private VTK discussion list. Please keep messages on-topic.
>Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
>To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
><majordomo at gsao.med.ge.com>. For help, send message body containing
>"info vtkusers" to the same address. Live long and prosper.
>-----------------------------------------------------------------------------
>
>
>
_____________________________________________________
________| |________
\ | Brian Todd email: bat5 at po.cwru.edu | /
\ | N.O.B.L. home: (216) 791-2407 | /
\ | C.W.R.U. office: (216) 368-4209 | /
/ | Cleveland, OH 44106 fax: (216) 368-4969 | \
/ |_____________________________________________________| \
/___________) (__________\
-----------------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>. For help, send message body containing
"info vtkusers" to the same address. Live long and prosper.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list