<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body 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 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>
</body>
</html>