<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">It really seems like your cut plane should show up right away if you set up your cutter, then set up the plane representation (VisibilityOn() for actor and rep), and then get the plane from the representation that's used in the cut, and then update the pipeline (Render() the window). That doesn't work?<div><br></div><div>I'll include a python script that shows the cutting plane and plane widget right from the beginning (the callback for InteractionEvent is just for moving the plane). I would assume the same sort of thing should work in C++. (Sorry for the bad variable names -- I was cutting and pasting from a couple pieces of code.)<br><div><br></div><div>-Eric</div><div><br></div><div># ================</div><div><div><div>#!/usr/bin/env python</div><div><br></div><div>import vtk</div><div><br></div><div># Create a mace out of filters.</div><div>rt = vtk.vtkRTAnalyticSource()</div><div>rt.SetWholeExtent(-3,3,-3,3,-3,3)</div><div>rt.Update()</div><div><br></div><div>maceMapper = vtk.vtkDataSetMapper()</div><div>maceMapper.SetInputConnection(rt.GetOutputPort())</div><div><br></div><div>maceActor = vtk.vtkActor()</div><div>maceActor.SetMapper(maceMapper)</div><div>maceActor.VisibilityOn()</div><div><br></div><div># This portion of the code clips the mace with the vtkPlanes</div><div># implicit function. The clipped region is colored green.</div><div>plane = vtk.vtkPlane()</div><div>clipper = vtk.vtkCutter()</div><div>clipper.SetInputConnection(rt.GetOutputPort())</div><div>clipper.SetCutFunction(plane)</div><div><br></div><div>selectMapper = vtk.vtkPolyDataMapper()</div><div>selectMapper.SetInputConnection(clipper.GetOutputPort())</div><div>selectMapper.SetScalarModeToUsePointFieldData()</div><div>selectMapper.SetColorModeToMapScalars()</div><div>selectMapper.ScalarVisibilityOn()</div><div>selectMapper.SetScalarRange(rt.GetOutputDataObject(0).GetPointData().GetScalars().GetRange())</div><div>selectMapper.SelectColorArray('RTData')</div><div><br></div><div>selectActor = vtk.vtkLODActor()</div><div>selectActor.SetMapper(selectMapper)</div><div>selectActor.VisibilityOn()</div><div>selectActor.SetScale(1.01, 1.01, 1.01)</div><div><br></div><div># Create the RenderWindow, Renderer and both Actors</div><div>ren = vtk.vtkRenderer()</div><div>renWin = vtk.vtkRenderWindow()</div><div>renWin.AddRenderer(ren)</div><div>iren = vtk.vtkRenderWindowInteractor()</div><div>iren.SetRenderWindow(renWin)</div><div><br></div><div># The callback function</div><div>def myCallback(obj, event):</div><div> global plane</div><div> obj.GetRepresentation().GetPlane(plane)</div><div> selectActor.VisibilityOn()</div><div><br></div><div># Create the representation and widget</div><div>planeRep = vtk.vtkImplicitPlaneRepresentation()</div><div>planeRep.SetPlaceFactor(1.25)</div><div>planeRep.PlaceWidget(rt.GetOutput().GetBounds())</div><div>planeRep.VisibilityOn()</div><div>planeRep.SetNormal(1,1,1)</div><div>planeRep.GetPlane(plane)</div><div><br></div><div>planeWidget = vtk.vtkImplicitPlaneWidget2()</div><div>planeWidget.SetInteractor(iren)</div><div>planeWidget.SetRepresentation(planeRep)</div><div>planeWidget.SetEnabled(1)</div><div>planeWidget.AddObserver("InteractionEvent", myCallback)</div><div><br></div><div># ren.AddActor(maceActor)</div><div>ren.AddActor(selectActor)</div><div><br></div><div># Add the actors to the renderer, set the background and size</div><div>renWin.SetSize(300, 300)</div><div>ren.SetBackground(0.1, 0.2, 0.4)</div><div>ren.ResetCamera()</div><div><br></div><div># Start interaction.</div><div>renWin.Render()</div><div>iren.Start()</div></div><div><br></div></div><div># ================</div><div><br></div><div><br></div><div><br><div><div>On Mar 19, 2010, at 6:27 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">So by now I
have gained some more knowledge about the callback stuff - or so I
think.<br>
<br>
I wan't to get back to this problem.<br>
I have made my code to display the widget right from the start with <br>
<br>
</font></font><big><font size="-1"><big><tt>->SetEnabled(1);</tt></big></font></big><font size="-1"><font face="Helvetica, Arial, sans-serif"><br>
<br>
to the implicit plane widget. I'm adding the observer <br>
<br>
</font></font><big><font size="-1"><big><tt>->AddObserver(vtkCommand::AnyEvent,myCallback);</tt></big></font></big><font size="-1"><font face="Helvetica, Arial, sans-serif"><br>
<br>
with <b>AnyEvent </b>and I think this is the problem.<br>
<br>
The cutting plane the implicit plane widget is representing is
displayed only if I do anything to the widget - and may it be a simple
move with the mouse.<br>
But what I want is for the implicit plane widget to display the cut
right from the beginning.<br>
<br>
Anyone know how this is done?<br>
</font></font><br>
Am 12.03.2010 17:01, schrieb Eric E. Monson:
<blockquote cite="mid:5CEBD5AC-3348-4242-8AB7-632AD5647ADD@cs.duke.edu" type="cite">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 </div>
<div><br>
</div>
<div>iPlaneRepresentation->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. </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 cutActor->VisibilityOff(); 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->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>
static vtkIPWCallback *New() <br>
{ return new vtkIPWCallback; }<br>
virtual void Execute(vtkObject *caller, unsigned long, void*)<br>
{<br>
vtkImplicitPlaneWidget2 *planeWidget = <br>
reinterpret_cast<vtkImplicitPlaneWidget2*>(caller);<br>
vtkImplicitPlaneRepresentation *rep = <br>
reinterpret_cast<vtkImplicitPlaneRepresentation*>(planeWidget->GetRepresentation());<br>
rep->GetPlane(this->Plane);<br>
}<br>
<br>
vtkIPWCallback():Plane(0),Actor(0) {}<br>
<br>
vtkPlane *Plane;<br>
vtkActor *Actor;<br>
<br>
};</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->SetInput(sGrid);<br>
planeCut->SetCutFunction(plane);<br>
<br>
vtkPolyDataMapper *cutMapper = vtkPolyDataMapper::New();<br>
cutMapper->SetInputConnection(planeCut->GetOutputPort());<br>
cutMapper->SetScalarRange(
sGrid->GetCellData()->GetScalars()->GetRange() );<br>
<br>
vtkActor *cutActor = vtkActor::New();<br>
cutActor->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->SetRenderWindow(renWin);<br>
<br>
<br>
// 1. implicit plane representation<br>
vtkImplicitPlaneRepresentation *iPlaneRepresentation =
vtkImplicitPlaneRepresentation::New();<br>
iPlaneRepresentation->SetPlaceFactor(1.0); // This must be set prior
to placing the widget<br>
iPlaneRepresentation->PlaceWidget(sGrid->GetBounds());<br>
iPlaneRepresentation->SetNormal(0,0,1);<br>
iPlaneRepresentation->SetOrigin(sGrid->GetCenter());<br>
iPlaneRepresentation->SetOutlineTranslation(0);<br>
iPlaneRepresentation->SetDrawPlane(0);<br>
<br>
// 2. Callback:<br>
vtkIPWCallback *myCallback = vtkIPWCallback::New();<br>
myCallback->Plane = plane;<br>
myCallback->Actor = cutActor;<br>
<br>
// 3. ImplicitPlaneWidget<br>
vtkImplicitPlaneWidget2 *iPlane = vtkImplicitPlaneWidget2::New();<br>
iPlane->SetInteractor(iren);<br>
iPlane->SetRepresentation(iPlaneRepresentation);<br>
iPlane->AddObserver(vtkCommand::InteractionEvent,myCallback);<br>
<br>
iren->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 moz-do-not-send="true" class="moz-txt-link-abbreviated" href="http://www.kitware.com/">www.kitware.com</a>
Visit other Kitware open-source projects at <a moz-do-not-send="true" 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 moz-do-not-send="true" 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 moz-do-not-send="true" 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 moz-do-not-send="true" href="http://www.kitware.com/">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a moz-do-not-send="true" 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 moz-do-not-send="true" 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 moz-do-not-send="true" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote>
</div>
<br>
</div>
</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></div></body></html>