[vtkusers] obtaining reference to calling class in KeyPressInteractorStyle class

Liam Kurmos quantum.leaf at googlemail.com
Fri Feb 12 09:42:21 EST 2010


Hi David,

Thanks for your reply. Your method is probably more sensible, i was
trying to get a reference to the entire class that contained the
render (and the interactor), but just getting a reference to the
filter would have been enough and would have saved me the mutal header
dependency problem i was having.

> I believe you are really never supposed to #include a cpp file.

do you say that in response to my post:
how to update pipeline after changing isovalue in vtkMarchingCubes.

what i meant to say was that to solve my problem i had include the
header file for my calling class in in KeyPressInteractorStyle.cpp and
have a forward declaration in KeyPressInteractorStyle.h
(not that i was trying to #include  a .cpp file)


in any case, i can now get to the filter, the problem is how to see
updated changes to the isovalue in the interactively rendered result?
I think i am not updating the pipeline properly, but apart from the
filter i don't know what else to call update on.

would i be better off using vtkContourFilter over vtkMarchingCubes?

thanks for your help,

Liam


> The way that you get a reference to the calling class is to add a member
> variable to the interactor style.
> class KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera
> {
>   public:
>     static KeyPressInteractorStyle* New();
>     virtual void OnKeyPress();
>   void SetContourFilter(vtkSmartPointer<vtkContourFilter> filter)
> {this->Filter = filter;}
>   private:
>     vtkSmartPointer<vtkContourFilter> Filter;
> };
> Then when you instantiate the style, you set that ivar:
> vtkSmartPointer<vtkContourFilter> filter =
> vtkSmartPointer<vtkContourFilter>::New();
> ... use the filter ...
> vtkSmartPointer<KeyPressInteractorStyle> style =
>     vtkSmartPointer<KeyPressInteractorStyle>::New();
> style->SetContourFilter(filter);
> renderWindowInteractor->SetInteractorStyle( style );
> Now you have a pointer inside the Interactor that you can use inside the
> OnKeyPress function.
> Hope that helps.
> 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
>
>



More information about the vtkusers mailing list