[vtkusers] Re: WarningDisplay

Goodwin Lawlor goodwin.lawlor at ucd.ie
Mon Mar 3 15:14:42 EST 2008


Mark Wyszomierski wrote:
> I haven't looked at it in awhile, but I think you can create an
> error/warning observer on the class you're using that generates the
> messages. When an error or warning occurs, your observer has a chance
> to intercept it and you can do whatever you want with it (ie. write it
> to disk in a log file). There may be other examples on how to use this
> out there, in general you do something like:
> 
>     pTheVtkInstance->AddObserver(vtkCommand::ErrorEvent,   yourObserver);
> 
> There may be a global method for doing this, but I don't know another
> way to do it.
> 
> If it helps, I put an example of how to do this observer method here:
> 
> http://devsample.org/index.php?option=com_content&task=view&id=49&Itemid=27
> 
> though as mentioned before, perhaps there is a better way.

Actually, I've a class the acts a little like you describe, except is 
catches all warning messages.

http://vtkbioeng.cvs.sourceforge.net/vtkbioeng/vtkbioeng/vtkBufferOutputWindow.cxx?view=markup
http://vtkbioeng.cvs.sourceforge.net/vtkbioeng/vtkbioeng/vtkBufferOutputWindow.h?view=markup

Its handy with wrapper language like Tcl (eg)

vtkBufferOutputWindow buffer
buffer SetInstance buffer
buffer GlobalWarningDisplayOn
buffer AddObserver ErrorEvent {cbError [buffer GetLastOutputText]}
buffer AddObserver WarningEvent {cbWarn [buffer GetLastOutputText]}

proc cbError {txt} {
# do something with the text
}

proc cbWarn {txt} {
# do something with the text
}


Goodwin




More information about the vtkusers mailing list