<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hey Christian,<div><br></div><div>I played around with some of this in Python, so hopefully it will translate okay... I think you need to do two things. First, make a call to&nbsp;</div><div><br></div><div>iPlaneRepresentation-&gt;GetPlane(plane);</div><div><br></div><div>right after you set up and place the representation. This will make sure that the cut plane is the right one even before the callback is executed.&nbsp;</div><div><br></div><div>Secondly, I think you might be able to get your cut to show up right away if you start with&nbsp;cutActor-&gt;VisibilityOff();&nbsp;and then add an observer on the main interactor for a KeyPress event and then look for the "i" key press. When you see it, it should make the widget appear as usual, but in the callback for your KeyPress event, if you see an "i" then set the cutActor-&gt;VisibilityOn();</div><div><br></div><div>If this doesn't work then someone who's better with the event system had better try to help you out.</div><div><br></div><div>Talk to you later,</div><div>-Eric</div><div><br></div><div><br><div><div>On Mar 12, 2010, at 5:22 AM, Sebastian Gatzka wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Helvetica, Arial, sans-serif">Ok. Here we
go with some code.<br>
<br>
This is the callback class<br>
<font color="#ff0000"><br>
</font><font color="#ff0000" face="Courier New, Courier, monospace">//
Callback for the interaction<br>
// This does the actual work: updates the vtkPlane implicit function.<br>
// This in turn causes the pipeline to update and clip the object.<br>
class vtkIPWCallback : public vtkCommand<br>
{<br>
public:<br>
&nbsp; static vtkIPWCallback *New() <br>
&nbsp;&nbsp;&nbsp; { return new vtkIPWCallback; }<br>
&nbsp; virtual void Execute(vtkObject *caller, unsigned long, void*)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; vtkImplicitPlaneWidget2 *planeWidget = <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reinterpret_cast&lt;vtkImplicitPlaneWidget2*&gt;(caller);<br>
&nbsp;&nbsp;&nbsp; vtkImplicitPlaneRepresentation *rep = <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
reinterpret_cast&lt;vtkImplicitPlaneRepresentation*&gt;(planeWidget-&gt;GetRepresentation());<br>
&nbsp;&nbsp;&nbsp; rep-&gt;GetPlane(this-&gt;Plane);<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp; vtkIPWCallback():Plane(0),Actor(0) {}<br>
<br>
&nbsp; vtkPlane *Plane;<br>
&nbsp; vtkActor *Actor;<br>
<br>
&nbsp;};</font><br>
<br>
This is the cutting plane and its actor the callback will access:<br>
<font color="#ff0000"><br>
</font><font color="#ff0000" face="Courier New, Courier, monospace">//
Cutting-Plane<br>
vtkPlane *plane = vtkPlane::New();<br>
<br>
vtkCutter *planeCut = vtkCutter::New();<br>
planeCut-&gt;SetInput(sGrid);<br>
planeCut-&gt;SetCutFunction(plane);<br>
<br>
vtkPolyDataMapper *cutMapper = vtkPolyDataMapper::New();<br>
cutMapper-&gt;SetInputConnection(planeCut-&gt;GetOutputPort());<br>
cutMapper-&gt;SetScalarRange(
sGrid-&gt;GetCellData()-&gt;GetScalars()-&gt;GetRange() );<br>
&nbsp;&nbsp;&nbsp; <br>
vtkActor *cutActor = vtkActor::New();<br>
cutActor-&gt;SetMapper(cutMapper);</font><br>
<br>
<br>
The rest is just like in the example<br>
<br>
<font face="Courier New, Courier, monospace"><font color="#ff0000">vtkRenderWindowInteractor
*iren = vtkRenderWindowInteractor::New();<br>
iren-&gt;SetRenderWindow(renWin);<br>
<br>
<br>
// 1. implicit plane representation<br>
vtkImplicitPlaneRepresentation *iPlaneRepresentation =
vtkImplicitPlaneRepresentation::New();<br>
iPlaneRepresentation-&gt;SetPlaceFactor(1.0); // This must be set prior
to placing the widget<br>
iPlaneRepresentation-&gt;PlaceWidget(sGrid-&gt;GetBounds());<br>
iPlaneRepresentation-&gt;SetNormal(0,0,1);<br>
iPlaneRepresentation-&gt;SetOrigin(sGrid-&gt;GetCenter());<br>
iPlaneRepresentation-&gt;SetOutlineTranslation(0);<br>
iPlaneRepresentation-&gt;SetDrawPlane(0);<br>
<br>
// 2. Callback:<br>
vtkIPWCallback *myCallback = vtkIPWCallback::New();<br>
myCallback-&gt;Plane = plane;<br>
myCallback-&gt;Actor = cutActor;<br>
<br>
// 3. ImplicitPlaneWidget<br>
vtkImplicitPlaneWidget2 *iPlane = vtkImplicitPlaneWidget2::New();<br>
iPlane-&gt;SetInteractor(iren);<br>
iPlane-&gt;SetRepresentation(iPlaneRepresentation);<br>
iPlane-&gt;AddObserver(vtkCommand::InteractionEvent,myCallback);<br>
<br>
iren-&gt;Start();</font><br>
<br>
<font face="Helvetica, Arial, sans-serif">So when pressing "i" the
plane is displayed but I need to to some interaction with it before it
displays anything.</font><br>
</font><br>
</font></font>Am 10.03.2010 23:05, schrieb Eric E. Monson:
<blockquote cite="mid:6AE2EA74-F639-4C44-905E-D94A20DFAB18@cs.duke.edu" type="cite">
  <pre wrap="">Hey again,

Somehow it seems like this would have more to do with how your code is dealing with the plane and the cutting rather than an inherent property of the widget itself. This is sort of the natural VTK behavior, though, since some part of the pipeline needs to explicitly force the pipeline to Update, and it sounds like there's nothing that's forcing that to happen when the widget is made visible. Maybe if you post a piece of your code someone will have some ideas.

-Eric


On Mar 10, 2010, at 7:36 AM, Sebastian Gatzka wrote:

  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi again (sorry, this is a busy day for the list)

Is there a way of telling the vtkImplicitPlaneWidget2 to display the cutting data right from the beginning?
In my code the plane is displaying nothing after I press the key "i".
Just as I do a first manipulation, like moving, rotating or translating there is an update to the plane.

Sebastian


_______________________________________________
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>
  <pre wrap="">
  </pre>
</blockquote>
</div>

_______________________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">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">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">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br></div></body></html>