70 #include "vtkAbstractPropPicker.h"
71 #include "vtkAssemblyPath.h"
73 #include "vtkObjectFactory.h"
74 #include "vtkRenderWindowInteractor.h"
75 #include <vtkImageData.h>
76 #include <vtkRenderWindow.h>
77 #include <vtkCamera.h>
78 #include <vtkRenderer.h>
79 #include "vtkProperty.h"
118 switch ( this->State )
130 case VTKIS_FORWARDFLY:
131 case VTKIS_REVERSEFLY:
138 this->Superclass::OnMouseMove();
143 this->InvokeEvent(vtkViewImage2DCommand::InteractionEvent,
this);
150 int x = this->Interactor->GetEventPosition()[0];
151 int y = this->Interactor->GetEventPosition()[1];
155 this->FindPokedRenderer(x, y);
157 if ( this->Interactor->GetRepeatCount() )
169 this->Superclass::OnRightButtonDown();
173 this->Superclass::OnMiddleButtonDown();
183 this->Superclass::OnLeftButtonDown();
195 this->Superclass::OnRightButtonDown();
198 this->Superclass::OnMiddleButtonDown();
205 this->Superclass::OnLeftButtonUp();
212 int x = this->Interactor->GetEventPosition()[0];
213 int y = this->Interactor->GetEventPosition()[1];
215 this->FindPokedRenderer(x, y);
220 this->Superclass::OnLeftButtonDown();
224 this->Superclass::OnRightButtonDown();
227 this->State = VTKIS_NONE;
234 this->Superclass::OnMiddleButtonDown();
244 this->Superclass::OnRightButtonUp();
247 this->State = VTKIS_NONE;
248 this->Superclass::StartPick();
255 this->Superclass::OnMiddleButtonUp();
267 this->Superclass::OnMiddleButtonDown();
270 this->Superclass::OnLeftButtonDown();
273 this->State = VTKIS_NONE;
280 this->Superclass::OnRightButtonDown();
290 this->Superclass::OnMiddleButtonUp();
293 this->Superclass::OnLeftButtonUp();
296 this->State = VTKIS_NONE;
297 this->Superclass::StartPick();
304 this->Superclass::OnRightButtonUp();
311 int x = this->Interactor->GetEventPosition()[0];
312 int y = this->Interactor->GetEventPosition()[1];
314 this->FindPokedRenderer(x, y);
315 if ( !this->CurrentRenderer )
324 this->
SliceStep =
static_cast< int >( this->MouseWheelMotionFactor );
330 this->
SliceStep =
static_cast< int >( this->MouseWheelMotionFactor );
343 int x = this->Interactor->GetEventPosition()[0];
344 int y = this->Interactor->GetEventPosition()[1];
346 this->FindPokedRenderer(x, y);
347 if ( !this->CurrentRenderer )
356 this->
SliceStep =
static_cast< int >( -this->MouseWheelMotionFactor );
362 this->
SliceStep =
static_cast< int >( -this->MouseWheelMotionFactor );
375 vtkRenderWindowInteractor *rwi = this->Interactor;
377 if ( !strcmp (rwi->GetKeySym(),
"Up") )
381 this->
SliceStep =
static_cast< int >( -this->MouseWheelMotionFactor );
385 else if ( !strcmp (rwi->GetKeySym(),
"Down") )
392 else if ( ( rwi->GetKeyCode() ==
'r' ) || ( rwi->GetKeyCode() ==
'R' ) )
394 this->InvokeEvent (vtkViewImage2DCommand::ResetWindowLevelEvent,
this);
396 else if ( ( rwi->GetKeyCode() ==
'o' ) || ( rwi->GetKeyCode() ==
'O' ) )
400 else if ( ( rwi->GetKeyCode() ==
'w' ) || ( rwi->GetKeyCode() ==
'W' ) )
402 vtkActorCollection *ac;
403 vtkActor *anActor, *aPart;
404 vtkAssemblyPath *path;
405 this->FindPokedRenderer(rwi->GetEventPosition()[0],
406 rwi->GetEventPosition()[1]);
407 if(this->CurrentRenderer!=0)
409 ac = this->CurrentRenderer->GetActors();
410 vtkCollectionSimpleIterator ait;
411 for (ac->InitTraversal(ait); (anActor = ac->GetNextActor(ait)); )
413 for (anActor->InitPathTraversal(); (path=anActor->GetNextPath()); )
419 std::vector< vtkProp3D * >::iterator it2 =
m_PlanesActors.begin();
422 if(path && dynamic_cast<vtkProp*>(*it2) == path->GetLastNode()->GetViewProp())
433 aPart=
static_cast<vtkActor *
>(path->GetLastNode()->GetViewProp());
434 aPart->GetProperty()->SetRepresentationToWireframe();
441 vtkWarningMacro(<<
"no current renderer on the interactor style.");
446 else if ( ( rwi->GetKeyCode() ==
's' ) || ( rwi->GetKeyCode() ==
'S' ) )
448 vtkActorCollection *ac;
449 vtkActor *anActor, *aPart;
450 vtkAssemblyPath *path;
451 this->FindPokedRenderer(rwi->GetEventPosition()[0],
452 rwi->GetEventPosition()[1]);
453 if(this->CurrentRenderer!=0)
455 ac = this->CurrentRenderer->GetActors();
456 vtkCollectionSimpleIterator ait;
457 for (ac->InitTraversal(ait); (anActor = ac->GetNextActor(ait)); )
459 for (anActor->InitPathTraversal(); (path=anActor->GetNextPath()); )
465 std::vector< vtkProp3D * >::iterator it2 =
m_PlanesActors.begin();
468 if(path && dynamic_cast<vtkProp*>(*it2) == path->GetLastNode()->GetViewProp())
479 aPart=
static_cast<vtkActor *
>(path->GetLastNode()->GetViewProp());
480 aPart->GetProperty()->SetRepresentationToSurface();
487 vtkWarningMacro(<<
"no current renderer on the interactor style.");
493 this->Superclass::OnChar();
500 vtkRenderWindowInteractor *rwi = this->Interactor;
502 if ( !strcmp (rwi->GetKeySym(),
"Up") )
509 else if ( !strcmp (rwi->GetKeySym(),
"Down") )
516 else if ( !strcmp (rwi->GetKeySym(),
"o") )
520 else if ( !strcmp (rwi->GetKeySym(),
"r") )
522 this->InvokeEvent (vtkViewImage2DCommand::ResetWindowLevelEvent,
this);
525 this->Superclass::OnKeyUp();
532 this->Superclass::OnKeyPress();
539 this->Superclass::OnKeyRelease();
546 if ( ( this->State != VTKIS_NONE ) && ( this->State != VTKIS_PICK ) )
596 this->Superclass::OnKeyDown();
610 return this->CurrentProp;
617 vtkRenderWindowInteractor *rwi = this->Interactor;
619 if ( this->CurrentRenderer != 0 )
621 vtkAssemblyPath *path = NULL;
622 int * eventPos = rwi->GetEventPosition();
623 this->FindPokedRenderer(eventPos[0], eventPos[1]);
624 rwi->StartPickCallback();
625 vtkAbstractPropPicker *picker =
626 vtkAbstractPropPicker::SafeDownCast( rwi->GetPicker() );
627 if ( picker != NULL )
629 picker->Pick(eventPos[0], eventPos[1],
630 0.0, this->CurrentRenderer);
631 path = picker->GetPath();
637 std::vector< vtkProp3D * >::iterator it2 =
m_PlanesActors.begin();
640 if(path && dynamic_cast<vtkProp*>(*it2) == path->GetFirstNode()->GetViewProp())
650 this->HighlightProp(NULL);
651 this->PropPicked = 0;
655 this->HighlightProp( path->GetFirstNode()->GetViewProp() );
656 this->PropPicked = 1;
658 rwi->EndPickCallback();
666 this->State = VTKIS_NONE;
674 this->State = VTKIS_NONE;
682 this->State = VTKIS_NONE;
690 this->State = VTKIS_NONE;
692 this->Superclass::StartPick();
void HighlightCurrentActor()
Draw a bounding box around the actor which is pointed by the cursor.
virtual void OnLeftButtonUp()
~vtkInteractorStyleImage2D()
void SynchronizeViews(bool iSynchronize)
virtual void OnMiddleButtonUp()
void SetPlanesActors(std::vector< vtkProp3D * > iBounds)
vtkCxxRevisionMacro(vtkFillImageWithPolyData,"$Revision: 490 $")
vtkProp * GetCurrentProp()
Return the actor which is pointed by the cursor.
virtual void OnMiddleButtonDown()
virtual void OnRightButtonUp()
vtkInteractorStyleImage2D()
Define the interactor behavior withing a vtkImage2D. 4 modes (Default, Zoom, Pan and Pick) ...
std::vector< vtkProp3D * > m_PlanesActors
virtual void OnKeyPress()
virtual void OnKeyRelease()
virtual void EndSliceMove()
virtual void DefaultMoveAction()
void SetPanMode()
Start the Pan Mode.
virtual void OnRightButtonDown()
virtual void StartSliceMove()
void SetZoomMode()
Start the Zoom Mode.
virtual void OnLeftButtonDown()
virtual void OnMouseWheelBackward()
virtual void OnMouseMove()
virtual void OnMouseWheelForward()
void SetPickMode()
Start the Pick Mode.
vtkStandardNewMacro(vtkFillImageWithPolyData)
void SetDefaultMode()
Start the Default Mode.