<!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 some
updates: This is what I tried to change the widgets normal:<br>
<br>
<font face="Courier New, Courier, monospace"><font color="#ff0000">//
Define interaction style<br>
class KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera<br>
{<br>
public:<br>
static KeyPressInteractorStyle* New();<br>
<br>
virtual void OnKeyPress() <br>
{<br>
//get the keypress<br>
vtkRenderWindowInteractor *rwi = this->Interactor;<br>
std::string key = rwi->GetKeySym();<br>
<br>
if (key.compare("p") == 0)<br>
{<br>
planeRepresentation->SetNormal(1,0,0);<br>
planeWidget->SetRepresentation(planeRepresentation);<br>
}<br>
<br>
//handle an arrow key<br>
if(key.compare("Up") == 0)<br>
{<br>
cout << "The up arrow was pressed." << endl;<br>
}<br>
<br>
// forward events<br>
vtkInteractorStyleTrackballCamera::OnKeyPress();<br>
}<br>
vtkImplicitPlaneWidget2 *planeWidget;<br>
vtkImplicitPlaneRepresentation *planeRepresentation;<br>
};</font><br>
<br>
<font face="Helvetica, Arial, sans-serif">Results in a crash when
setting the normal.</font><br>
</font></font></font><br>
Am 12.03.2010 11:38, schrieb Sebastian Gatzka:
<blockquote cite="mid:4B9A198F.9030209@stud.tu-darmstadt.de" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<font size="-1"><font face="Helvetica, Arial, sans-serif">Just great
this worked!<br>
<br>
But as I want to change the normal and center of the
vtkImplicitPlaneWidget2 I need to access its representation.<br>
There I can set the things I want:<br>
<small><font face="Courier New, Courier, monospace"><br>
<big>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>
<font face="Helvetica, Arial, sans-serif">So how can I have access to
the representation itself from withing the class
KeyPressInteractorStyle?</font><br>
</big></font></small></font></font><br>
Am 10.03.2010 15:28, schrieb David Doria:
<blockquote
cite="mid:c19fcadc1003100628nfdcae18l4dbc8dba351be217@mail.gmail.com"
type="cite">
<div class="gmail_quote">On Wed, Mar 10, 2010 at 6:36 AM, Sebastian
Gatzka <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:sebastian.gatzka@stud.tu-darmstadt.de">sebastian.gatzka@stud.tu-darmstadt.de</a>></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;">
<div bgcolor="#ffffff" text="#000000"><font size="-1"><font
face="Helvetica, Arial, sans-serif">Hello world.<br>
<br>
I have found the example for the catching of keys: <a
moz-do-not-send="true"
href="http://vtk.org/Wiki/VTK/Examples/Interaction/KeypressEvents"
target="_blank">http://vtk.org/Wiki/VTK/Examples/Interaction/KeypressEvents</a><br>
This is great news to me, but I want to link different things:<br>
</font></font>
<ul>
<li><small><font face="Helvetica, Arial, sans-serif">Wait for a
key
to be pressed</font></small></li>
<li><small><font face="Helvetica, Arial, sans-serif">On one
special
key press change the normal direction of a vtkImplicitPlaneWidget2
representation</font></small></li>
<li><small><font face="Helvetica, Arial, sans-serif">On a
different
special key press change the center point of a vtkImplicitPlaneWidget2
representation</font></small></li>
<li><small><font face="Helvetica, Arial, sans-serif">Write the
new
normal direction and center point of the vtkImplicitPlaneWidget2
representation to a textActor to display the new values</font></small></li>
</ul>
<small><font face="Helvetica, Arial, sans-serif">So I think I
will
have
to link key press events and callbacks?<br>
I'm really not sure how to handle this on my own<br>
<br>
You will notice that my previous posts are somhow related to the topic.<br>
This here is the final requirement to the code and include the steps I
have asked before.<br>
<br>
Sebastian</font></small><br>
</div>
<div bgcolor="#ffffff" text="#000000"><small><font
face="Helvetica, Arial, sans-serif"><br>
</font></small></div>
</blockquote>
<div><br>
</div>
<div>You need to create a member variable of
type vtkImplicitPlaneWidget2* in the interactor style subclass:</div>
<div><br>
</div>
<div>class KeyPressInteractorStyle : public
vtkInteractorStyleTrackballCamera</div>
<div>
<div>{</div>
<div> public:</div>
<div> static KeyPressInteractorStyle* New();</div>
<div> </div>
<div> virtual void OnKeyPress() </div>
<div> {</div>
<div> //get the keypress</div>
<div> vtkRenderWindowInteractor *rwi = this->Interactor;</div>
<div> std::string key = rwi->GetKeySym();</div>
<div> </div>
<div> //handle a "normal" key</div>
<div> if(key.compare("a") == 0)</div>
<div> {</div>
<div> cout << "The a key was pressed." << endl;</div>
<div> }</div>
<div> </div>
<div> // forward events</div>
<div> vtkInteractorStyleTrackballCamera::OnKeyPress();</div>
<div> }</div>
<div> vtkImplicitPlaneWidget2* PlaneWidget;</div>
<div> </div>
<div>};</div>
<div><br>
</div>
<div><br>
</div>
<div>Then from main:</div>
<div><br>
</div>
<div>vtkImplicitPlaneWidget2* planeWidget
= vtkImplicitPlaneWidget2::New();</div>
<div>KeyPressInteractorStyle* style
= KeyPressInteractorStyle::New();</div>
<div>style.PlaneWidget = planeWidget;</div>
<div><br>
</div>
<div>Then you can do whatever you want to the PlaneWidget from
inside</div>
<div><br>
</div>
<div>
<div> if(key.compare("a") == 0)</div>
<div> {</div>
<div>//do something to the PlaneWidget when 'a' is pressed</div>
<div> }</div>
<div><br>
</div>
</div>
</div>
Thanks,<br>
<br>
<div>David </div>
</div>
</blockquote>
<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>
</body>
</html>