[vtkusers] VTK Interactor problem

Florian Schiffers florian.schiffers at physik.uni-erlangen.de
Thu Aug 22 06:26:18 EDT 2013


Hello,

thx for the answer. It helped me alot, but I still have the problem that 
I cannot access to class member variables in a callback function or the 
vtkInteractorStyleTrackballCamera Class.

I have a structure like this:

( with pastebin: http://pastebin.com/qm42n1xh )

void ClickCallbackFunction ( vtkObject* caller, long unsigned int 
eventId, void* clientData, void* callData );
ElectrodeDetectorPlugin::ElectrodeDetectorPlugin(QVTKWidget *p): QObject(){
     m_InputData                =    vtkSmartPointer <vtkPolyData> :: New();
     m_InputDataActor        =    vtkSmartPointer <vtkActor> :: New();

     m_MaximaData           = vtkSmartPointer<vtkPolyData>::New();
     m_InputMaximaActor            = vtkSmartPointer<vtkActor>::New();

     vtkSmartPointer<MouseInteractorStyle1> style  = 
vtkSmartPointer<MouseInteractorStyle1>::New(); // Style 1 for 
manipulation Spin/Pan etc.
     vtkSmartPointer<MouseInteractorStyle2> style  = 
vtkSmartPointer<MouseInteractorStyle2>::New();
     ... ....
     renderWindow->GetInteractor()->SetInteractorStyle( style );
    vtkSmartPointer<vtkCallbackCommand> clickCallback = 
vtkSmartPointer<vtkCallbackCommand>::New(); clickCallback->SetCallback ( 
ClickCallbackFunction );   renderWindowInteractor->AddObserver ( 
vtkCommand::LeftButtonPressEvent, clickCallback );

}
void ClickCallbackFunction ( vtkObject* vtkNotUsed(caller), long 
unsigned int vtkNotUsed(eventId), void* vtkNotUsed(clientData), void* 
vtkNotUsed(callData) ) { std::cout << "Click callback" << std::endl;

   // Get the interactor like this:
   vtkRenderWindowInteractor *iren =
   static_cast<vtkRenderWindowInteractor*>(caller);

   HERE I need to operations on m_InputData, m_MaximaData using PointPicker Methods
   I also want to draw objects etc.
   
}

I tried a lot of stuff, but they all didn't work. Do you have any idea?

Thank you for your help!

best regards,
Flo

Am 21.08.2013 04:04, schrieb Alex Malyushytskyy:
> I just want to add thet currently set . vtkInteractorStyle is defining 
> which events are handled and how.
> So subclassing and overriding appropriate functionality is way to go.
> Also you can create multiple vtkInteractorStyle and set them active 
> according to your needs.
>
> Hope this helps.
>
> Alex
>
>
> On Tue, Aug 20, 2013 at 4:08 PM, Alex Malyushytskyy 
> <alexmalvtk at gmail.com <mailto:alexmalvtk at gmail.com>> wrote:
>
>     Subclass vtkInteractorStyle (or derived class ) you are using.
>
>     All the operations: rotation, calls as results on Keypressevents
>     are initiated there.
>     Depending on the actual subclass of vtkInteractorStyle things what
>     you need to do are different,
>     For example to suppress Keypressevents for
>     vtkInteractorStyleRubberBand subclass you can just override
>     void vtkInteractorStyleRubberBand::OnChar() to do nothing.
>
>     Regards,
>          Alex
>
>
>     On Tue, Aug 20, 2013 at 5:59 AM, Phys1k3r
>     <florian.schiffers at physik.uni-erlangen.de
>     <mailto:florian.schiffers at physik.uni-erlangen.de>> wrote:
>
>         Hello,
>
>         I have written a vtk-programm that allows me to display a 3D
>         data set (VTK
>         and QT). Additonally you can interact with the 3D Data with
>         'RightButtonPressEvent' and 'MiddleButtonPressEvent'. Both
>         interaction are
>         point picker interactions.
>
>         My problem is, that for example, when I press the
>         'RightButton' two things
>         happen at once:
>
>         1. Point on 3D Data get's picked
>         2. Camera is zooming in/out (only when I move mouse during
>         picking, but this
>         happens from time to time)
>
>         The same happens with 'MiddleButtonPressEvent', the objects
>         just get moved
>         instead.
>
>         So basically I want a button on my GUI, where I can choose:
>          1. Either Zoom in/out
>          2. or pick a point
>
>         As an alternative I would be satisfied with something like this:
>          1. Just OnLeftButtonDown() -> Just Zoom/Pan/Spin
>          2. OnLeftButtonDown() + KeePressEvent -> Don't zoom, pick
>         point instead
>
>         This is how I implemented the 'MiddleButtonPressEventHandling'
>         by now:
>
>
>
>         I know, this is not the best way, but it worked so far. I
>         propably will
>         implement it this way in the near future:
>         http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/MouseEventsObserver
>
>         But even when I use the MouseEventsObserver I still have no
>         Idea how
>         suppress the Zoom/Pan/Spin Events...
>
>         Than I thought of this method instead:
>         http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/MouseEvents
>
>         First of all, I don't need (and also don't want) all the
>         features of the
>         vtkInteractorStyle class like Keypressevents for p, r, s, u, v
>         e (as you can
>         find them here:
>         http://www.vtk.org/doc/nightly/html/classvtkInteractorStyle.html
>         at Detailed
>         Description)
>
>         I just need to overwrite 'OnLeftButtonDown', 'OnMiddleButtonDown',
>         'OnRightButtonDown' etc.
>
>         So basically I tried things like this, but they don't work, of
>         course:
>
>
>
>
>         Honestly I have no idea how to solve my problem... I also
>         haven't found much
>         documentary besides the examples.
>
>         Thank you for your help, I really appreciate it
>         Phys1k3r
>
>
>
>         --
>         View this message in context:
>         http://vtk.1045678.n5.nabble.com/VTK-Interactor-problem-tp5722887.html
>         Sent from the VTK - Users mailing list archive at Nabble.com.
>         _______________________________________________
>         Powered by www.kitware.com <http://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
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130822/2f568a82/attachment.htm>


More information about the vtkusers mailing list