[vtkusers] KeyPress Events / Callbacks / User Interaction
Sebastian Gatzka
sebastian.gatzka at stud.tu-darmstadt.de
Mon Mar 15 08:21:18 EDT 2010
Ok, and WHERE do I have to set this planeRepresentation member variabel
like you suggested?
Am 12.03.2010 16:04, schrieb David Doria:
> On Fri, Mar 12, 2010 at 6:58 AM, Sebastian Gatzka
> <sebastian.gatzka at stud.tu-darmstadt.de> wrote:
>
>> Ok some updates: This is what I tried to change the widgets normal:
>>
>> // Define interaction style
>> class KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera
>> {
>> public:
>> static KeyPressInteractorStyle* New();
>>
>> virtual void OnKeyPress()
>> {
>> //get the keypress
>> vtkRenderWindowInteractor *rwi = this->Interactor;
>> std::string key = rwi->GetKeySym();
>>
>> if (key.compare("p") == 0)
>> {
>> planeRepresentation->SetNormal(1,0,0);
>> planeWidget->SetRepresentation(planeRepresentation);
>> }
>>
>> //handle an arrow key
>> if(key.compare("Up") == 0)
>> {
>> cout<< "The up arrow was pressed."<< endl;
>> }
>>
>> // forward events
>> vtkInteractorStyleTrackballCamera::OnKeyPress();
>> }
>> vtkImplicitPlaneWidget2 *planeWidget;
>> vtkImplicitPlaneRepresentation *planeRepresentation;
>> };
>>
>> Results in a crash when setting the normal.
>>
>>
> You didn't show how you set the planeRepresentation member variable. I
> wouldn't do it like this, I would simply set the planeWidget member
> variable and then use:
>
> vtkImplicitPlaneRepresentation* rep = planeWidget->GetRepresentation();
>
> to do things to the representation.
>
> Thanks,
>
> David
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100315/af3238d7/attachment.htm>
More information about the vtkusers
mailing list