Skip to content

Commit

Permalink
Adjust controls to enable window/level and moving slice plane in eith…
Browse files Browse the repository at this point in the history
…er navigation or edit mode
  • Loading branch information
davidborland committed Nov 7, 2019
1 parent 81dec6c commit 37fa3d4
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 54 deletions.
105 changes: 66 additions & 39 deletions vtkInteractorStyleSlice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -152,39 +152,41 @@ void vtkInteractorStyleSlice::OnLeftButtonDown()
return;
}

if (this->Mode == EditMode)
// If shift is held down, do window/level in either mode
if (this->Interactor->GetShiftKey())
{
// If alt is held down, select the region label
if (this->Interactor->GetAltKey()) {
this->StartSelect();
}

// If shift is held down, do window/level
else if (this->Interactor->GetShiftKey())
{
this->WindowLevelStartPosition[0] = x;
this->WindowLevelStartPosition[1] = y;
this->StartWindowLevel();
}

// Otherwise paint
else
{
this->StartPaint();
}
this->WindowLevelStartPosition[0] = x;
this->WindowLevelStartPosition[1] = y;
this->StartWindowLevel();
}
else
else
{
// If ctrl is held down, spin
if (this->Interactor->GetControlKey())
if (this->Mode == EditMode)
{
this->StartSpin();
// If ctrl is held down, select the region label
if (this->Interactor->GetControlKey()) {
this->StartSelect();
}

// Otherwise paint
else
{
this->StartPaint();
}
}

// Otherwise rotate around focal point
else
{
this->StartRotate();
// If ctrl is held down, spin
if (this->Interactor->GetControlKey())
{
this->StartSpin();
}

// Otherwise rotate around focal point
else
{
this->StartRotate();
}
}
}
}
Expand Down Expand Up @@ -238,13 +240,39 @@ void vtkInteractorStyleSlice::OnMiddleButtonDown()
return;
}

if (this->Mode == NavigationMode)
if (this->Mode == EditMode)
{
// Select
this->StartSelect();
}
else
{
// Pan
this->StartPan();
}
}

//----------------------------------------------------------------------------
void vtkInteractorStyleSlice::OnMiddleButtonUp() {
int x = this->Interactor->GetEventPosition()[0];
int y = this->Interactor->GetEventPosition()[1];

this->FindPokedRenderer(x, y);
if (this->CurrentRenderer == nullptr)
{
return;
}

if (this->State == VTKIS_SELECT_SLICE)
{
this->EndSelect();
}

// Call parent to handle all other states and perform additional work

this->Superclass::OnMiddleButtonUp();
}

//----------------------------------------------------------------------------
void vtkInteractorStyleSlice::OnRightButtonDown()
{
Expand All @@ -259,25 +287,24 @@ void vtkInteractorStyleSlice::OnRightButtonDown()
return;
}

if (this->Mode == EditMode)
// Slice if ctrl is held down
if (this->Interactor->GetControlKey())
{
this->StartSlice();
}
else
{
// Slice if ctrl is held down
if (this->Interactor->GetControlKey())
if (this->Mode == EditMode)
{
this->StartSlice();
// Erase
this->StartErase();
}

// Otherwise erase
else
{
this->StartErase();
// Zoom
this->StartDolly();
}
}
else
{
// Zoom
this->StartDolly();
}
}

//----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions vtkInteractorStyleSlice.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class vtkInteractorStyleSlice : public vtkInteractorStyleImage {
void OnLeftButtonDown() override;
void OnLeftButtonUp() override;
void OnMiddleButtonDown() override;
void OnMiddleButtonUp() override;
void OnRightButtonDown() override;
void OnRightButtonUp() override;
void OnChar() override;
Expand Down
55 changes: 40 additions & 15 deletions vtkInteractorStyleVolume.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ void vtkInteractorStyleVolume::OnLeftButtonDown()

if (this->Mode == EditMode)
{
// If alt is held down, select the region label
if (this->Interactor->GetAltKey()) {
// If ctrl is held down, select the region label
if (this->Interactor->GetControlKey()) {
this->StartSelect();
}

Expand Down Expand Up @@ -255,13 +255,39 @@ void vtkInteractorStyleVolume::OnMiddleButtonDown()
return;
}

if (this->Mode == NavigationMode)
if (this->Mode == EditMode)
{
// Select
this->StartSelect();
}
else
{
// Pan
this->StartPan();
}
}

//----------------------------------------------------------------------------
void vtkInteractorStyleVolume::OnMiddleButtonUp() {
int x = this->Interactor->GetEventPosition()[0];
int y = this->Interactor->GetEventPosition()[1];

this->FindPokedRenderer(x, y);
if (this->CurrentRenderer == nullptr)
{
return;
}

if (this->State == VTKIS_SELECT_VOLUME)
{
this->EndSelect();
}

// Call parent to handle all other states and perform additional work

this->Superclass::OnMiddleButtonUp();
}

//----------------------------------------------------------------------------
void vtkInteractorStyleVolume::OnRightButtonDown()
{
Expand All @@ -276,25 +302,24 @@ void vtkInteractorStyleVolume::OnRightButtonDown()
return;
}

if (this->Mode == EditMode)
// Slice if ctrl is held down
if (this->Interactor->GetControlKey())
{
// Slice if ctrl is held down
if (this->Interactor->GetControlKey())
this->StartSlice();
}
else
{
if (this->Mode == EditMode)
{
this->StartSlice();
// Erase
this->StartErase();
}

// Otherwise erase
else
{
this->StartErase();
// Zoom
this->StartDolly();
}
}
else
{
// Zoom
this->StartDolly();
}
}

//----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions vtkInteractorStyleVolume.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class vtkInteractorStyleVolume : public vtkInteractorStyleTrackballCamera {
void OnLeftButtonDown() override;
void OnLeftButtonUp() override;
void OnMiddleButtonDown() override;
void OnMiddleButtonUp() override;
void OnRightButtonDown() override;
void OnRightButtonUp() override;
void OnChar() override;
Expand Down

0 comments on commit 37fa3d4

Please sign in to comment.