On Tue, Oct 13, 2009 at 4:00 PM, Quy Pham Sy <span dir="ltr"><<a href="mailto:phamsyquybk@gmail.com">phamsyquybk@gmail.com</a>></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 <<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>>:<br>
<div><div></div><div class="h5">> On Tue, Oct 13, 2009 at 5:06 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br>
>><br>
>> Hi David,<br>
>> That example is very misleading. The vtkCamera and the most<br>
>> vtkInteractorStyles do nothing with 2D actors. The vtkActor2D uses the<br>
>> "display" coordinate system, but for displaying data, you almost always want<br>
>> to use the "world" coordinate system that vtkActor and vtkCamera use.<br>
>> So: even with 2D data, you should use vtkActor, not vtkActor2D. That way<br>
>> the vtkCamera can control the view, just set camera->ParallelProjectionOn()<br>
>> so that it will display a "flat" projection rather than a perspective<br>
>> projection. Interactor styles like the vtkInteractorStyleRubberBand2D are<br>
>> specifically designed for use with 2D data. But you must use vtkActor for<br>
>> your data, don't use vtkActor2D.<br>
>> David<br>
><br>
> Haha - the "misleading-ness" is what I am trying to sort through and remove<br>
> with these examples :)<br>
><br>
> vtkActor2D has to be around for something right? What would one use it for?<br>
><br>
> If you simply set the camera to parallel projection, you can still rotate<br>
> "out of plane" which makes the whole thing not really seem like 2D any more.<br>
> That's what I thought this Actor2D was going to - provide a more 2D "feel".<br>
> Is there nothing that does this (excluding simply not using the rotate<br>
> buttons in the 3d view)?<br>
><br>
> Thanks,<br>
><br>
> David<br>
></div></div><div class="im">
<br>
</div>hi,<br>
<br>
To prevent rotating your 2D object "out of plane" 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->Interactor->GetEventPosition()[0];<br>
int y = this->Interactor->GetEventPosition()[1];<br>
<br>
this->FindPokedRenderer(x, y);<br>
this->FindPickedActor(x, y);<br>
if (this->CurrentRenderer == NULL || this->InteractionProp == NULL)<br>
{<br>
return;<br>
}<br>
<br>
this->GrabFocus(this->EventCallbackCommand);<br>
<br>
if (this->Interactor->GetShiftKey())<br>
{<br>
this->StartPan();<br>
}<br>
else<br>
{<br>
//this->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->FindPickedActor(x, y) )<br>
<br>
I never try, but it is probably possible to create "real" 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 "view plane"<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 "rotating", 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 "active" 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>