[vtkusers] KeyPress Events / Callbacks / User Interaction

Sebastian Gatzka sebastian.gatzka at stud.tu-darmstadt.de
Mon Mar 15 09:18:53 EDT 2010


Check. Everything is allready there.

In main:

KeyPressInteractorStyle *kpis = KeyPressInteractorStyle::New();
kpis->planeWidget = iPlane;

while iPlane is the interactivePlaneWidget2.

And the class looks like the one below, but still the line

vtkImplicitPlaneRepresentation* rep = *planeWidget*->GetRepresentation();

can't be interpreted:

error C2440: 'initializing' : cannot convert from 
'vtkWidgetRepresentation *' to 'vtkImplicitPlaneRepresentation *'

Am 15.03.2010 14:03, schrieb David Doria:
> On Mon, Mar 15, 2010 at 8:57 AM, Sebastian Gatzka 
> <sebastian.gatzka at stud.tu-darmstadt.de 
> <mailto:sebastian.gatzka at stud.tu-darmstadt.de>> wrote:
>
>     Somthing like this? I'm not getting it ...
>
>     class KeyPressInteractorStyle : public
>     vtkInteractorStyleTrackballCamera
>     {
>       public:
>         static KeyPressInteractorStyle* New();
>
>     vtkImplicitPlaneWidget2 *planeWidget;
>
>
>         virtual void OnKeyPress()
>         {
>           //get the keypress
>           vtkRenderWindowInteractor *rwi = this->Interactor;
>           std::string key = rwi->GetKeySym();
>
>           if (key.compare("p") == 0)
>           {
>               vtkImplicitPlaneRepresentation* rep =
>     *planeWidget*->GetRepresentation();
>
>
>               rep->SetNormal(1,0,0);
>               planeWidget->SetRepresentation(rep);
>
>           }
>
>           //handle an arrow key
>           if(key.compare("Up") == 0)
>             {
>             cout << "The up arrow was pressed." << endl;
>             }
>
>           // forward events
>           vtkInteractorStyleTrackballCamera::OnKeyPress();
>         }
>
>
>     };
>
>     *This leads to problems: The planeWidget inside the {}-brackets is
>     unknown.*
>     *
>     *
>
>
>
> class KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera
> {
>   ...
> vtkImplicitPlaneWidget2 *planeWidget;
>
>
>     virtual void OnKeyPress()
>     {
>       //get the keypress
>       vtkRenderWindowInteractor *rwi = this->Interactor;
>       std::string key = rwi->GetKeySym();
>
>       if (key.compare("p") == 0)
>       {
>           vtkImplicitPlaneRepresentation* rep = 
> *planeWidget*->GetRepresentation();
>
>
>           rep->SetNormal(1,0,0);
>           //planeWidget->SetRepresentation(rep); you don't need this, 
> it is already set (since you just Got it)
>
>       }
> ...
>
>
> };
>
>
> int main(int argc, char *argv[])
> {
> vtkSmartPointer<KeyPressInteractorStyle> style =
> vtkSmartPointer<KeyPressInteractorStyle>::New();
>  ...
>   vtkSmartPointer<vtkImplicitPlaneWidget2> planeWidget =
>       vtkSmartPointer<vtkImplicitPlaneWidget2>::New();
>   planeWidget->SetInteractor(renderWindowInteractor);
>
> style.planeWidget = planeWidget;
> ...
>
>
> You're definitely right that we need a tutorial on callback and 
> widgets and interactor subclasses - I'll get to it soon.
>
> Thanks,
>
> David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100315/9d719d1d/attachment.htm>


More information about the vtkusers mailing list