[vtkusers] VtkTkRenderWidget and Python....
Ailton Santa Barbara
amati at cenpra.gov.br
Wed Apr 10 13:31:24 EDT 2002
Hi all,
We are using the vtkTkRenderWidget class to prevent the main program
crash and It works. The problem is that the "a" key
doesn't work in the interaction with mouse and keyboard - this key
allows to move a plane.
In this mail you can see a part of the vtkTkRenderWidget class. We put
a new bind (for "a"-key) and we create the def "Animation".
We believed that this def would do the same stuffs that the key-a
implementation in the vtkInteractorStyle, whose code is here too,
but only the entire cube is moved (we can't select the plane).
Could anyone help me with this or with other solution???
Thank you.
Marcelo
-----------------------------------------------------------------------------------------------------
---------------------------------
A part of vtkTkRenderWidget file
---------------------------------
def BindTkRenderWidget(self):
"""
Bind some default actions.
"""
self.bind("<KeyPress-e>",
lambda e,s=self: s.Exit())
self.bind("<KeyPress-a>",
lambda e,s=self: s.Animation())
self.bind("<ButtonPress>",
lambda e,s=self: s.StartMotion(e.x,e.y))
self.bind("<ButtonRelease>",
lambda e,s=self: s.EndMotion(e.x,e.y))
self.bind("<B1-Motion>",
lambda e,s=self: s.Rotate(e.x,e.y))
self.bind("<B2-Motion>",
lambda e,s=self: s.Pan(e.x,e.y))
self.bind("<B3-Motion>",
lambda e,s=self: s.Zoom(e.x,e.y))
self.bind("<Shift-B1-Motion>",
lambda e,s=self: s.Pan(e.x,e.y))
self.bind("<KeyPress-r>",
lambda e,s=self: s.Reset(e.x,e.y))
self.bind("<KeyPress-u>",
lambda e,s=self: s.deiconify())
self.bind("<KeyPress-w>",
lambda e,s=self: s.Wireframe())
self.bind("<KeyPress-s>",
lambda e,s=self: s.Surface())
self.bind("<KeyPress-p>",
lambda e,s=self: s.PickActor(e.x,e.y))
self.bind("<Enter>",
lambda e,s=self: s.Enter(e.x,e.y))
self.bind("<Leave>",
lambda e,s=self: s.Leave(e.x,e.y))
self.bind("<Expose>",
lambda e,s=self: s.Expose())
def Animation(self):
self._RenderWindow.SetDesiredUpdateRate(self._RenderWindow.GetDesiredUpdateRate())
self._RenderWindow.Render()
---------------------------------------------------------------------------------------------------------
--------------------------------------
A part of vtkInteractorStyle.cxx code.
--------------------------------------
void vtkInteractorStyle::OnChar(int ctrl, int shift,
char keycode, int
vtkNotUsed(repeatcount))
{
this->CtrlKey = ctrl;
this->ShiftKey = shift;
vtkRenderWindowInteractor *rwi = this->Interactor;
switch (keycode)
{
// JCP Animation control
case 'a' :
case 'A' :
if (this->AnimState == VTKIS_ANIM_OFF)
{
this->StartAnimate();
}
else
{
this->StopAnimate();
}
break;
// JCP Animation control
//-----
.
.
.
.
void vtkInteractorStyle::StartAnimate()
{
vtkRenderWindowInteractor *rwi = this->Interactor;
vtkErrorMacro(<< "starting animation");
this->AnimState = VTKIS_ANIM_ON;
if (this->State == VTKIS_START)
{
vtkErrorMacro(<< "Start state found");
rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetDesiredUpdateRate());
if ( !rwi->CreateTimer(VTKI_TIMER_FIRST) )
{
vtkErrorMacro(<< "Timer start failed");
}
}
rwi->Render();
}
More information about the vtkusers
mailing list