[vtkusers] Activiz / vtkOutputWindow

Jochen jochen.kling at email.de
Tue May 22 08:02:25 EDT 2012


Hi Jean, 


here is an example of redirecting the output to a file and additionally
catch the error via an event handler:



void RedirectVTKOutput() {

    
vtkFileOutputWindow _FileOutputWindow = 
vtkFileOutputWindow.New();

   
_FileOutputWindow.SetFileName(@"c:\vtkerror.txt");

    _FileOutputWindow.SetFlush(1);

    if(vtkOutputWindow.GetInstance() 
!= null) 
{

        
vtkOutputWindow.SetInstance(_FileOutputWindow);

        _FileOutputWindow.ErrorEvt +=
new
vtkObject.vtkObjectEventHandler(outputWindow_ErrorEvt);

    }

}

 

void 
outputWindow_ErrorEvt(vtkObject 
sender, vtkObjectEventArgs 
e) {

    
string s = 
"ERROR: unknown";

    try 
{

        
if(e.CallData != 
IntPtr.Zero) 
{

            s = 
System.Runtime.InteropServices.Marshal.PtrToStringAnsi(e.CallData);

        }

    }

    
catch {

        // 
handle error

    }

    System.Diagnostics.Debug.Write(System.String.Format(

    "outputWindow_ErrorEvt 
called: sender='{0}' e='{1}' s='{2}'", 
sender, e, s));

}




with best regards

Jochen

--
View this message in context: http://vtk.1045678.n5.nabble.com/Activiz-vtkOutputWindow-tp5711412p5713288.html
Sent from the VTK - Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120522/0c3a4465/attachment.htm>


More information about the vtkusers mailing list