[vtkusers] How to draw rectangles using CDC in vtkMFCWindow

zouchao1112 zouchao1112 at hotmail.com
Wed Oct 19 11:23:23 EDT 2011


Thanks for you help.

I tried to build up a sub-class of vtkActor2D named vtkRectROI, and I
override the RenderOpaqueGeometry() and RenderOverlay()... as:

int vtkROIRect::RenderOverlay(vtkViewport *viewport)
{
	vtkRenderer *pRenderer = (vtkRenderer *)viewport; // Get Renderer
	vtkWin32OpenGLRenderWindow *pRenWindow = (vtkWin32OpenGLRenderWindow
*)pRenderer->GetRenderWindow(); //Get RenderWindow

	HWND hWnd = (HWND)pRenWindow->GetWindowId();
	ImageWindow *pWnd = (ImageWindow *)CWnd::FromHandle(hWnd); // ImageWindow
is a sub-class of vtkMFCWindow

	CDC *pDC = pWnd->GetDC(); // The DC seems different from
vtkMFCWindow::OnPaint()
	CPen WhitePen(PS_SOLID, 5, RGB(255, 255, 255));
	CPen *pOldPen = pDC->SelectObject(&WhitePen);
	pDC->Rectangle(0, 0, 300, 300);
	pDC->SelectObject(pOldPen);

	return 1;
}


However, this doesn't work since the white rectangle is not visible unless I
click mouse in the view port. How to solve this problem? 
Thanks very much!

--
View this message in context: http://vtk.1045678.n5.nabble.com/How-to-draw-rectangles-using-CDC-in-vtkMFCWindow-tp4913124p4918216.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list