[vtkusers] VTK and GUI - vtkRenderWindow - Virtual or Physical?

Andrew J. Dolgert ajd27 at cornell.edu
Mon Mar 20 13:06:54 EST 2006


Hi Frank,

 

I was just working on this. You have to set both the parent ID and the
window ID, as shown in the example in VTK/GUISupport/MFC directory. That
code shows all of the steps you have to do. I shouldn't really send
files on the mailing list, so I'll send them to you separately.

 

Drew

 

 

________________________________

From: Frank Gao [mailto:gao at mdimaging.com] 
Sent: Monday, March 20, 2006 12:41 PM
To: Andrew J. Dolgert; Vtkusers at Vtk.Org; Thomas Lambertz; Xiaofeng Zhao
Subject: RE: [vtkusers] VTK and GUI - vtkRenderWindow - Virtual or
Physical?

 

Hi All,

 

Thanks for the replies.

 

Both Drew and Tom said were what I was trying to do. Separating UI and
internal code is my basic intent, and also I am not trying to use the
.Net wrapper for the whole VTK.  However, I am still struggling to get
it work. The error I received is that some object is busy, which made me
think that there are conflicts somewhere.

 

To prove the concept, I am trying to have a C# application to view a
single DICOM file. The code has three layers: C# code for UI, C++
wrapper to a C++ class, and then the C++ class making VTK calls.  Please
see the code below.  

 

I would very much appreciate if you would like to help correct the
approach or provide some sample code.

 

Thanks,

 

Frank

 

C# UI layer

private void openFileDialog1_FileOk(object sender,
System.ComponentModel.CancelEventArgs e)

{

      wrapper.Open (this.openFileDialog1.FileName, this.Handle);

            

}

 

Then my C++ wrapper to VTK code

 

void Wrapper::Open (String *filename, IntPtr wnd)

{

      char __nogc* pStr =
static_cast<char*>(Marshal::StringToHGlobalAnsi(filename).ToPointer());

      m->Open (pStr, (HWND)wnd.ToPointer());

}

 

The last one is my C++ code:

      void Dicomer::Open (char *filename, HWND whnd)

      {

            pvtkDataSetReader->SetFileName(filename);

            pvtkDataSetMapper->SetInput(pvtkDataSetReader->GetOutput());

            pvtkActor->SetMapper(pvtkDataSetMapper);

      

            pvtkRenderer    = vtkRenderer::New();

            pvtkOGLWindow = vtkWin32OpenGLRenderWindow::New();

 

            pvtkOGLWindow->SetParentId((HWND)whnd);

 

            pvtkRenderer ->SetRenderWindow (pvtkOGLWindow);

            pvtkRenderer->SetBackground(0.0,0.0,0.4);

            pvtkRenderer->AddActor((pvtkActor));

            pvtkRenderer->ResetCamera();

            pvtkOGLWindow->Render();

      }

 

 

-----Original Message-----
From: Thomas Lambertz [mailto:thomas at hexerei-software.de]
Sent: Saturday, March 18, 2006 10:51 AM
To: vtkusers at vtk.org
Subject: Re: [vtkusers] VTK and GUI - vtkRenderWindow - Virtual or
Physical?

 

 


Hello Frank,

i am far away from being such an expert - but - maybe me tries are
helpful for you.

I splittet my application into two parts. GUI runs as a managed Win Form
and the numerical parts are done in a separate DLL which is native-x86.
And - to come closer to your question - yes - i have not found problems
at this time by letting VTK render into a Forms-Picturebox.

I know that VS 2003/2005 can handle managed / unmanaged Code in the same
executable but i didnt tried this way ( splitting has some advantages
for me ).

Hope this helps,
Tom




-----Original Message-----
From: Andrew J. Dolgert [mailto:ajd27 at cornell.edu]
Sent: Saturday, March 18, 2006 7:10 AM
To: gao at mdimaging.com; Vtkusers at Vtk.Org
Subject: RE: [vtkusers] VTK and GUI - vtkRenderWindow - Virtual or
Physical?

 

Your idea is interesting. It might apply to attempts to use VTK as a
server for AJAX. For Windows Forms, however, the current setup works
fine because the vtkWin32OpenGLRenderWindow will happily receive events
from and draw into the Frame of a Windows Form because Windows Forms
expose their HWND handle.

 

Drew Dolgert

 

________________________________

From: vtkusers-bounces+ajd27=cornell.edu at vtk.org
[mailto:vtkusers-bounces+ajd27=cornell.edu at vtk.org] On Behalf Of Frank
Gao
Sent: Friday, March 17, 2006 5:24 PM
To: Vtkusers at Vtk.Org
Subject: [vtkusers] VTK and GUI - vtkRenderWindow - Virtual or Physical?

 

Hi Experts,

 

I have a question about vtkRenderWindow, and vtkOpenGLRenderWindow. Are
such objects virtual, or have to be physical by setting the parent
window ID? 

 

The requirement behind this question is here. Suppose an application
must separate its window display and interaction from its internal code.
The application needs to set a virtual vtkOpenGLRenderWindow with
interactors that are also virtual, and binding them with a physical
window whenever necessary. Simply put, make vtkOpenGLRenderWindow and
the interactor purely 'server' objects to return bitmaps (or video
streams?). These server objects are fully functional and independent of
physical implementation. By doing this, the application never needs to
get into vtk code to change files such as vtkMFCWindow. 

 

A real scenario for this. If this is possible, with a .Net wrapper, one
can easily use Win Forms as render window.

 

It would be tremendously helpful if the answer is YES, or can be YES.
Your replies are highly appreciated.

 

Thanks,

 

Frank Gao

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060320/31346c48/attachment.htm>


More information about the vtkusers mailing list