<!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">
Thank you, Eric.<br>
<br>
I think this is too far fetched in this case.<br>
I will life with the cut not beeing displayed at first - at least for
the time beeing.<br>
It's because I'm still not getting sense into this observer/callback
stuff.<br>
Maybe I will get back to this problem later ...<br>
<br>
See you.<br>
Sebastian<br>
<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>
</body>
</html>