<div class="gmail_quote">On Wed, Oct 21, 2009 at 6:28 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Yes, that's true, I guess it really is that easy.<br>
<br>
Still, I wish that VTK did have a vtkPrintFormat object because it<br>
would make writing PrintSelf methods a lot less tedious.<br>
<br>
For example, there are tons of lines of code in VTK like this<br>
(probably many with little errors and inconsistencies here and there):<br>
<br>
os << "Origin: " << this->Origin[0] << " " << this->Origin[1] << " "<br>
<< this->Origin[2] << "\n";<br>
<br>
These could have been simply like this:<br>
<br>
format->PrintAttribute(os, "Origin", this->Origin, 3);<br>
<br>
Or even a macro:<br>
<br>
vtkPrintAttributeMacro(Origin,3);<br>
<br>
Unfortunately all those "<<" operators have already been typed... but<br>
it's not too late to switch to a better system.<br>
<font color="#888888"><br>
David<br>
</font><div><div></div><div class="h5"><br>
<br>
On Wed, Oct 21, 2009 at 5:08 PM, Francois Bertel<br>
<<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>> wrote:<br>
> You don't need all these things if you're working in C++.<br>
> You just have to change the flag on your ostream:<br>
><br>
> Example with cout:<br>
><br>
> vtkObject *a;<br>
><br>
> cout.setf(ios::scientific,ios::floatfield); // ios::fixed or ios::scientific<br>
> cout.precision(5);<br>
><br>
> a->Print(cout);<br>
><br>
> ref: <a href="http://www.cplusplus.com/reference/iostream/ostream/" target="_blank">http://www.cplusplus.com/reference/iostream/ostream/</a><br>
> ref: <a href="http://www.cplusplus.com/reference/iostream/ios_base/fmtflags/" target="_blank">http://www.cplusplus.com/reference/iostream/ios_base/fmtflags/</a><br>
><br>
><br>
> On Wed, Oct 21, 2009 at 7:03 PM, David Doria <<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>> wrote:<br>
>> On Wed, Oct 21, 2009 at 6:52 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br>
>>> I agree with Jeff that a method for pretty-printing would be handy. A<br>
>>> generic way of doing this is to create a "formatting" object that can<br>
>>> be sent to PrintSelf:<br>
>>><br>
>>> void PrintSelf(ostream& os, vtkIndent indent, vtkPrintFormat *format);<br>
>>><br>
>>> The "format" object could provide information about precision, column<br>
>>> widths, and "level of detail" i.e. whether to print all attributes or<br>
>>> just the important ones i.e. the data values.<br>
>>><br>
>>> This would be an optional method, i.e. if any object that didn't<br>
>>> define the new form of PrintSelf would fall back to the old PrintSelf.<br>
>>> The reason to modify PrintSelf, instead of adding new methods, is<br>
>>> because it makes it easy to convert relevant object (matrix,<br>
>>> transform, array) over to the new system.<br>
>>><br>
>>> There could be two ways of invoking the pretty-print methods:<br>
>>><br>
>>> vtkPrintFormat::Print(ostream &stream, vtkObject *object);<br>
>>><br>
>>> vtkObject::Print(ostream &stream, vtkPrintFormat *format);<br>
>>><br>
>>> Overall, this would be fairly easy to implement and would be very<br>
>>> general-purpose. In fact it is general enough to even encompass such<br>
>>> things as serialization of VTK objects.<br>
>>><br>
>>> David<br>
>>> ___<br>
>><br>
>> David Gobbi,<br>
>><br>
>> That sounds like a very reasonable idea to me. Are you or Jeff<br>
>> interested in setting up the framework? Once it's setup, I'd be happy<br>
>> to try to write a few of the Print functions. We should make a list of<br>
>> things that could really use the new idea: vtkMatrix4x4,<br>
>> vtk*Transform, vtk*Array, ?<br>
>><br>
>> This "level of detail" is also a nice feature, almost all the classes<br>
>> could eventually be updated to have a few different levels of detail.<br>
>><br>
>> Thanks,<br>
>><br>
>> David<br>
>> _______________________________________________<br>
>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>><br>
>> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>><br>
>> Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
>><br>
>> Follow this link to subscribe/unsubscribe:<br>
>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> François Bertel, PhD | Kitware Inc. Suite 204<br>
<br></div></div></blockquote><div><br>Was the decision to do nothing? If so, that would be unfortunate :(<br><br clear="all">Thanks,<br><br>David<br></div></div>