<div class="gmail_quote">On Wed, Oct 21, 2009 at 6:28 PM, David Gobbi <span dir="ltr">&lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;</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&#39;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 &lt;&lt; &quot;Origin: &quot; &lt;&lt; this-&gt;Origin[0] &lt;&lt; &quot; &quot; &lt;&lt; this-&gt;Origin[1] &lt;&lt; &quot; &quot;<br>
&lt;&lt; this-&gt;Origin[2] &lt;&lt; &quot;\n&quot;;<br>
<br>
These could have been simply like this:<br>
<br>
 format-&gt;PrintAttribute(os, &quot;Origin&quot;, this-&gt;Origin, 3);<br>
<br>
Or even a macro:<br>
<br>
 vtkPrintAttributeMacro(Origin,3);<br>
<br>
Unfortunately all those &quot;&lt;&lt;&quot; operators have already been typed... but<br>
it&#39;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>
&lt;<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>&gt; wrote:<br>
&gt; You don&#39;t need all these things if you&#39;re working in C++.<br>
&gt; You just have to change the flag on your ostream:<br>
&gt;<br>
&gt; Example with cout:<br>
&gt;<br>
&gt; vtkObject *a;<br>
&gt;<br>
&gt; cout.setf(ios::scientific,ios::floatfield); // ios::fixed or ios::scientific<br>
&gt; cout.precision(5);<br>
&gt;<br>
&gt; a-&gt;Print(cout);<br>
&gt;<br>
&gt; ref: <a href="http://www.cplusplus.com/reference/iostream/ostream/" target="_blank">http://www.cplusplus.com/reference/iostream/ostream/</a><br>
&gt; 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>
&gt;<br>
&gt;<br>
&gt; On Wed, Oct 21, 2009 at 7:03 PM, David Doria &lt;<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>&gt; wrote:<br>
&gt;&gt; On Wed, Oct 21, 2009 at 6:52 PM, David Gobbi &lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt; I agree with Jeff that a method for pretty-printing would be handy.  A<br>
&gt;&gt;&gt; generic way of doing this is to create a &quot;formatting&quot; object that can<br>
&gt;&gt;&gt; be sent to PrintSelf:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; void PrintSelf(ostream&amp; os, vtkIndent indent, vtkPrintFormat *format);<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The &quot;format&quot; object could provide information about precision, column<br>
&gt;&gt;&gt; widths, and &quot;level of detail&quot; i.e. whether to print all attributes or<br>
&gt;&gt;&gt; just the important ones i.e. the data values.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; This would be an optional method, i.e. if any object that didn&#39;t<br>
&gt;&gt;&gt; define the new form of PrintSelf would fall back to the old PrintSelf.<br>
&gt;&gt;&gt;  The reason to modify PrintSelf, instead of adding new methods, is<br>
&gt;&gt;&gt; because it makes it easy to convert relevant object (matrix,<br>
&gt;&gt;&gt; transform, array) over to the new system.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; There could be two ways of invoking the pretty-print methods:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; vtkPrintFormat::Print(ostream &amp;stream, vtkObject *object);<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; vtkObject::Print(ostream &amp;stream, vtkPrintFormat *format);<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Overall, this would be fairly easy to implement and would be very<br>
&gt;&gt;&gt; general-purpose.  In fact it is general enough to even encompass such<br>
&gt;&gt;&gt; things as serialization of VTK objects.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;    David<br>
&gt;&gt;&gt; ___<br>
&gt;&gt;<br>
&gt;&gt; David Gobbi,<br>
&gt;&gt;<br>
&gt;&gt; That sounds like a very reasonable idea to me. Are you or Jeff<br>
&gt;&gt; interested in setting up the framework? Once it&#39;s setup, I&#39;d be happy<br>
&gt;&gt; to try to write a few of the Print functions. We should make a list of<br>
&gt;&gt; things that could really use the new idea: vtkMatrix4x4,<br>
&gt;&gt; vtk*Transform, vtk*Array, ?<br>
&gt;&gt;<br>
&gt;&gt; This &quot;level of detail&quot; is also a nice feature, almost all the classes<br>
&gt;&gt; could eventually be updated to have a few different levels of detail.<br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt;<br>
&gt;&gt; David<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;&gt;<br>
&gt;&gt; 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>
&gt;&gt;<br>
&gt;&gt; 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>
&gt;&gt;<br>
&gt;&gt; Follow this link to subscribe/unsubscribe:<br>
&gt;&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; 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>