On Tue, Oct 13, 2009 at 4:00 PM, Quy Pham Sy <span dir="ltr">&lt;<a href="mailto:phamsyquybk@gmail.com">phamsyquybk@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
2009/10/14 David Doria &lt;<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; On Tue, Oct 13, 2009 at 5:06 PM, David Gobbi &lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi David,<br>
&gt;&gt; That example is very misleading.  The vtkCamera and the most<br>
&gt;&gt; vtkInteractorStyles do nothing with 2D actors.  The vtkActor2D uses the<br>
&gt;&gt; &quot;display&quot; coordinate system, but for displaying data, you almost always want<br>
&gt;&gt; to use the &quot;world&quot; coordinate system that vtkActor and vtkCamera use.<br>
&gt;&gt; So: even with 2D data, you should use vtkActor, not vtkActor2D.  That way<br>
&gt;&gt; the vtkCamera can control the view, just set camera-&gt;ParallelProjectionOn()<br>
&gt;&gt; so that it will display a &quot;flat&quot; projection rather than a perspective<br>
&gt;&gt; projection.  Interactor styles like the vtkInteractorStyleRubberBand2D are<br>
&gt;&gt; specifically designed for use with 2D data.  But you must use vtkActor for<br>
&gt;&gt; your data, don&#39;t use vtkActor2D.<br>
&gt;&gt;     David<br>
&gt;<br>
&gt; Haha - the &quot;misleading-ness&quot; is what I am trying to sort through and remove<br>
&gt; with these examples :)<br>
&gt;<br>
&gt; vtkActor2D has to be around for something right? What would one use it for?<br>
&gt;<br>
&gt; If you simply set the camera to parallel projection, you can still rotate<br>
&gt; &quot;out of plane&quot; which makes the whole thing not really seem like 2D any more.<br>
&gt; That&#39;s what I thought this Actor2D was going to - provide a more 2D &quot;feel&quot;.<br>
&gt; Is there nothing that does this (excluding simply not using the rotate<br>
&gt; buttons in the 3d view)?<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; David<br>
&gt;</div></div><div class="im">
<br>
</div>hi,<br>
<br>
To prevent rotating your 2D object &quot;out of plane&quot; u can derive<br>
vtkInteractorStyles and<br>
re-implement mouse or key event handle function for your purpose,<br>
<br>
for  example:<br>
<br>
-----------------------<br>
void vtkYourInteractorStyle::OnLeftButtonDown()<br>
{<br>
        int x = this-&gt;Interactor-&gt;GetEventPosition()[0];<br>
        int y = this-&gt;Interactor-&gt;GetEventPosition()[1];<br>
<br>
        this-&gt;FindPokedRenderer(x, y);<br>
        this-&gt;FindPickedActor(x, y);<br>
        if (this-&gt;CurrentRenderer == NULL || this-&gt;InteractionProp == NULL)<br>
        {<br>
                return;<br>
        }<br>
<br>
        this-&gt;GrabFocus(this-&gt;EventCallbackCommand);<br>
<br>
        if (this-&gt;Interactor-&gt;GetShiftKey())<br>
        {<br>
                this-&gt;StartPan();<br>
        }<br>
        else<br>
        {<br>
                //this-&gt;StartRotate();<br>
                /* your custom interaction such as spin, scale, ..etc*/<br>
        }<br>
}<br>
--------------------------------<br>
<br>
it actually interact with vtkProp3D ( the one you have from<br>
        this-&gt;FindPickedActor(x, y)  )<br>
<br>
I never try, but it is probably possible to create &quot;real&quot; interactor<br>
style which interact with actor2D.<br>
And you also notice that when you interact with 2D actors, your actor<br>
actually lie on &quot;view plane&quot;<br>
so it will not be affected by camera transform (in camera based-<br>
interactor style).<br>
your interactor style should be type of actor-based interactor.<br>
<br>
Hope it help.<br>
<div><div></div><div class="h5"><br></div></div></blockquote><div><br></div><div>Yes, I also use this trick of overriding the left mouse button so that instead of &quot;rotating&quot;, it does something more useful for 2D.</div>
<div><br></div><div>The Actor2D is mainly used for adding a 2D overlay.  For example, you can use it to add some text that will always stay at the top of the screen (or bottom, or wherever you want).  I sometimes use Actor2D to add a red border around my &quot;active&quot; renderer, if I have multiple renderers in my application.  Also, I used to use Actor2D to display images, but now I use vtkImageActor instead.</div>
<div><br></div><div>  David </div></div>