[vtk-developers] Re: GUISupport directory ?

Clinton Stimpson clinton at elemtech.com
Mon Feb 14 11:52:42 EST 2005


Quoting de Boer Ingo <I.deBoer at polytec.de>:

> > The source is in the current CVS (VTK/GUISupport/MFC).
> Thanks... I just took a look at it...
>
> I have a question. You wrote this:
>
>   // setup the parent window
>   this->renWin->SetWindowId(this->GetSafeHwnd());
>   this->iren->SetRenderWindow(this->renWin);
>   this->iren->Initialize();
>
> I did in my samples something like:
>
>   // setup the parent window
>   this->renWin->SetWindowId(this->GetSafeHwnd());
>   this->renWin->SetParentId(this->GetParent()->GetSafeHwnd());
>   this->iren->SetRenderWindow(this->renWin);
>   this->iren->Initialize();
>
> and set the parent ID. Isn't it necessary to set the parent ID ?

I don't think it is necessary.  The only place in the VTK code it makes a
difference is in the resizing window code, which is redundent, because MFC
is already doing that.

>
> Did you try my samples ?

I didn't.  I realize they were there in the bug tracker when I took this
code from the already existing examples and modified it.

> In my opinion, three samples would be needed, MDI,SDI and
> dialog-based. This is what people do. The only trouble
> with the dialog-based application I had, was, that I
> could not do a double click. For the MDI and SDI it worked
> fine.

We have an MDI and SDI sample already that uses this new class.  Do you want
to try it in a dialog?

>
> In WindowProc you set the focus for the button down.
> Is this necessary ? If yes, shouldn't you set the focus
> also for WM_MOUSEWHEEL and WM_KEYDOWN ?

Doing it on wheel mouse is preference, and I think most people want that.  A
window has to have input focus before it can get a key event.  So it is
redundent to set focus on key down because it already has focus.

>
> In the OnSize function, wouldn't a call like
> this->iren->UpdateSize(cx, cy);
> be enough ?

Yeah, it is.
I think it is weird that a window has already been sized and it is told to
be sized again recursively in VTK.  That is what iren->UpdateSize does.  My
code I had there prevents the recursion from happening and gets the same
work done.


The OnPaint function doesn't pass in a CDC to do printing like that.  It is
the OnDraw functions from CView that has that.  I don't think CWnd has an
OnDraw function.
Perhaps we have 4 widget classes in there, then some of them can support
printing like that.

Clint

>
> How about extending the OnPaint with printing ?
> Like this (pseudo, taken from my code)
> if ( pDC->IsPrinting() )
> {
> 	// Obtain the size of the printer page in pixels.
> 	int cxPage = pDC->GetDeviceCaps(HORZRES);
> 	int cyPage = pDC->GetDeviceCaps(VERTRES);
>
> 	// Get the size of the window in pixels.
> 	int *size = this->pvtkWin32OpenGLRW->GetSize();
> 	int cxWindow = size[0];
> 	int cyWindow = size[1];
> 	float fx = float(cxPage) / float(cxWindow);
> 	float fy = float(cyPage) / float(cyWindow);
> 	float scale = min(fx,fy);
> 	int x = int(scale * float(cxWindow));
> 	int y = int(scale * float(cyWindow));
> 	this->pvtkWin32OpenGLRW->SetupMemoryRendering(cxWindow, cyWindow,
> pDC->GetSafeHdc());
> 	this->pvtkWin32OpenGLRW->Render();
> 	HDC memDC = this->pvtkWin32OpenGLRW->GetMemoryDC();
>
	StretchBlt(pDC->GetSafeHdc(),0,0,x,y,memDC,0,0,cxWindow,cyWindow,SRCCOPY);
> 	this->pvtkWin32OpenGLRW->ResumeScreenRendering();
> }
> else
> {
> 	// TODO: add draw code for native data here
> 	if (this->pvtkWin32RenderWI->GetInitialized())
> 	{
> 		this->pvtkWin32OpenGLRW->Render();
> 	}
> }
>
> greets
>   Ingo
>





More information about the vtk-developers mailing list