[vtkusers] Interacting with Actor2D?

Quy Pham Sy phamsyquybk at gmail.com
Tue Oct 13 18:00:07 EDT 2009


2009/10/14 David Doria <daviddoria+vtk at gmail.com>:
> On Tue, Oct 13, 2009 at 5:06 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>
>> Hi David,
>> That example is very misleading.  The vtkCamera and the most
>> vtkInteractorStyles do nothing with 2D actors.  The vtkActor2D uses the
>> "display" coordinate system, but for displaying data, you almost always want
>> to use the "world" coordinate system that vtkActor and vtkCamera use.
>> So: even with 2D data, you should use vtkActor, not vtkActor2D.  That way
>> the vtkCamera can control the view, just set camera->ParallelProjectionOn()
>> so that it will display a "flat" projection rather than a perspective
>> projection.  Interactor styles like the vtkInteractorStyleRubberBand2D are
>> specifically designed for use with 2D data.  But you must use vtkActor for
>> your data, don't use vtkActor2D.
>>     David
>
> Haha - the "misleading-ness" is what I am trying to sort through and remove
> with these examples :)
>
> vtkActor2D has to be around for something right? What would one use it for?
>
> If you simply set the camera to parallel projection, you can still rotate
> "out of plane" which makes the whole thing not really seem like 2D any more.
> That's what I thought this Actor2D was going to - provide a more 2D "feel".
> Is there nothing that does this (excluding simply not using the rotate
> buttons in the 3d view)?
>
> Thanks,
>
> David
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>

hi,

To prevent rotating your 2D object "out of plane" u can derive
vtkInteractorStyles and
re-implement mouse or key event handle function for your purpose,

for  example:

-----------------------
void vtkYourInteractorStyle::OnLeftButtonDown()
{
	int x = this->Interactor->GetEventPosition()[0];
	int y = this->Interactor->GetEventPosition()[1];

	this->FindPokedRenderer(x, y);
	this->FindPickedActor(x, y);
	if (this->CurrentRenderer == NULL || this->InteractionProp == NULL)
	{
		return;
	}

	this->GrabFocus(this->EventCallbackCommand);

	if (this->Interactor->GetShiftKey())
	{
		this->StartPan();
	}
	else
	{
		//this->StartRotate();
                /* your custom interaction such as spin, scale, ..etc*/
	}
}
--------------------------------

it actually interact with vtkProp3D ( the one you have from
	this->FindPickedActor(x, y)  )

I never try, but it is probably possible to create "real" interactor
style which interact with actor2D.
And you also notice that when you interact with 2D actors, your actor
actually lie on "view plane"
so it will not be affected by camera transform (in camera based-
interactor style).
your interactor style should be type of actor-based interactor.

Hope it help.



More information about the vtkusers mailing list