<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
  <title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
<br>
You may ignore the caching stuff in there.&nbsp; Its off by default, and is
only useful to prevent updates when there are no changes.<br>
<br>
Whenever you make changes to VTK's data objects it's your job to call
qvtkWidget-&gt;update() or viewer-&gt;Render() afterward so the new
changes get put onto the screen.<br>
<br>
Clint<br>
<br>
On 11/23/2009 07:27 AM, Garrett Larson wrote:
<blockquote
 cite="mid:c78467350911230627v64259513y1dfca16eb8689d91@mail.gmail.com"
 type="cite">Thanks for the quick response! I've tried that and
unfortunately it isn't working for me. I think the issue has to do with
the fact that I'm changing the pixel values manually, and the widgets
don't realize the image has changed. <br>
  <br>
I thought it might have to do with the cachedImageDirty() signal, but I
don't understand when to call markCachedImageDirty() (before
qvtkWidget-&gt;update() ? after?) or how to check if the flag is being
set appropriately as the value is a protected member of QVTKWidget.<br>
  <br>
-Garrett Larson<br>
  <br>
  <br>
  <div class="gmail_quote">On Mon, Nov 23, 2009 at 8:53 AM, Andr&eacute; Prins
  <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:a.h.prins@gmail.com">a.h.prins@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;">You
could try calling QVTKWidget::update(), which is Qt's method of<br>
repainting the widget.<br>
See for example: <a moz-do-not-send="true"
 href="http://doc.trolltech.com/4.5/qwidget.html#update" target="_blank">http://doc.trolltech.com/4.5/qwidget.html#update</a>.<br>
    <br>
Regards,<br>
Andr&eacute;<br>
    <div>
    <div class="h5"><br>
On Mon, Nov 23, 2009 at 2:04 PM, Garrett Larson &lt;<a
 moz-do-not-send="true" href="mailto:garrett@unc.edu">garrett@unc.edu</a>&gt;
wrote:<br>
&gt; I've created an application that contains a QVTKWidget linked to a<br>
&gt; vtkImageViewer2. Alterations to the vtkImageData before
initializing the<br>
&gt; vtkImageViewer2 are visible as soon as I call viewer-&gt;Render(),
but any<br>
&gt; changes I make later do not appear until I click inside the
widget. In fact,<br>
&gt; this happens even if I run the exact same sequence of methods to
make a new<br>
&gt; vtkImageViewer2 (as below). Is this a result of the QVTKWidget
caching the<br>
&gt; image data, and if so, how can I make it update? Thanks!<br>
&gt;<br>
&gt; ==================<br>
&gt;<br>
&gt; &nbsp; gridData = vtkImageData::New();<br>
&gt;<br>
&gt; // etc.<br>
&gt;<br>
&gt; &nbsp; gridData-&gt;<br>
&gt; SetScalarTypeToFloat();<br>
&gt; &nbsp; gridData-&gt;AllocateScalars();<br>
&gt; &nbsp;
gridData-&gt;GetPointData()-&gt;GetScalars()-&gt;FillComponent(0,0);<br>
&gt;<br>
&gt;<br>
&gt; // The vtkImageData *gridData is modified via calls to
SetScalarComponent...<br>
&gt;<br>
&gt;<br>
&gt;
gridData-&gt;SetScalarComponentFromDouble((int)pos[0],(int)pos[1],0,0,intensity);<br>
&gt;<br>
&gt; &nbsp; viewer = vtkImageViewer2::New();<br>
&gt; &nbsp; viewer-&gt;SetInput(gridData);<br>
&gt; &nbsp;
viewer-&gt;SetupInteractor(this-&gt;ui-&gt;qvtkWidget-&gt;GetInteractor());<br>
&gt; &nbsp;
viewer-&gt;SetRenderWindow(this-&gt;ui-&gt;qvtkWidget-&gt;GetRenderWindow());<br>
&gt; &nbsp; viewer-&gt;Render();<br>
&gt;<br>
&gt; // ... and the modified image is displayed correctly.<br>
&gt;<br>
&gt; // But if the vtkImageData *gridData is further modified via calls
to<br>
&gt; SetScalarComponent...<br>
&gt;<br>
&gt;<br>
&gt;
gridData-&gt;SetScalarComponentFromDouble((int)pos[0],(int)pos[1],0,0,intensity);<br>
&gt;<br>
&gt; &nbsp; viewer = vtkImageViewer2::New();<br>
&gt; &nbsp; viewer-&gt;SetInput(gridData);<br>
&gt; &nbsp;
viewer-&gt;SetupInteractor(this-&gt;ui-&gt;qvtkWidget-&gt;GetInteractor());<br>
&gt; &nbsp;
viewer-&gt;SetRenderWindow(this-&gt;ui-&gt;qvtkWidget-&gt;GetRenderWindow());<br>
&gt; &nbsp; viewer-&gt;Render();<br>
&gt;<br>
&gt; // ...the new changes are still not visible until I click the
image.<br>
&gt;<br>
&gt; ===================<br>
&gt;<br>
&gt; -Garrett Larson<br>
    </div>
    </div>
&gt; _______________________________________________<br>
&gt; Powered by <a moz-do-not-send="true" href="http://www.kitware.com"
 target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at<br>
&gt; <a moz-do-not-send="true"
 href="http://www.kitware.com/opensource/opensource.html"
 target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the VTK FAQ at:<br>
&gt; <a moz-do-not-send="true" href="http://www.vtk.org/Wiki/VTK_FAQ"
 target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a moz-do-not-send="true"
 href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt;<br>
&gt;<br>
  </blockquote>
  </div>
  <br>
  <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>

Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>

Please keep messages on-topic and check the VTK FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>

Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
  </pre>
</blockquote>
<br>
</body>
</html>