[vtkusers] Rotating actors
Sebastian Klocke
klocke at rob.uni-luebeck.de
Thu Mar 17 13:35:53 EST 2005
I don't know a way to enhance control of rotating actors with the mouse,
but you could use a vtkRenderWindowInteractor and use AddObserver to
make it react to keypress events, then use a switch/case statement to
react to different keys with different rotations.
Sebastian
//in constructor of your class which handles the actors
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(imageWindow);//the window displaying the actors
OnKeyPress *myOnKeyPress = new OnKeyPress(this);//Execute method of this
is invoked when key pressed
iren -> AddObserver(vtkCommand::KeyPressEvent, myOnKeyPress);//
class OnKeyPress : public vtkCommand
{
public:
//OnKeyPress has to know your class which creates the actors
//that way, you can invoke a method of the class which knows the actors
yourClass *owner;
///constructor
OnKeyPress(yourClass *nowner);
///this method is called whenever the observer using OnKeyPress
object detects a key press event
virtual void Execute(vtkObject *caller, unsigned long eid, void*);
};//OnKeyPress
OnKeyPress::OnKeyPress(yourClass *nowner)
{
owner= nowner;
}
void OnKeyPress::OnKeyPress::Execute(vtkObject *caller, unsigned long
eid, void*)
{
//owner is the class with the actors,
//in ApplyOnKeyPress, you define the reactions to the values of (*key)
//like switch (*key) { case 'x' ... break; case 'y'.........}
owner -> ApplyOnKeyPress(owner -> iren -> GetKeySym());
}
Sean Richards schrieb:
>I render some 3D actors on the screen and then need to translate them around, but also do some rotations. When I do the rotations it is sometimes very hard to get the rotation I want.
>
>Is there a way to add little widgets like you would find in Photoshop or Corel so that you can rotate about one axis only ... with several widgets so you can pick the axis you want to rotate about?
>
>Any help or direction would be greatly appreciated!
>
>Sean
>
>------------------------------------------------------------------------
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>
More information about the vtkusers
mailing list