Skip to content

Commit

Permalink
Re #29: Added relevant shortcut key for all collection modes currentl…
Browse files Browse the repository at this point in the history
…y available.
  • Loading branch information
matthewsholden committed May 15, 2014
1 parent a03d32e commit 89844b0
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 7 deletions.
11 changes: 11 additions & 0 deletions Widgets/qSlicerLORCollectControlsWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ ::widgetDeactivated()
}


void qSlicerLORCollectControlsWidget
::installShortcuts()
{
}


void qSlicerLORCollectControlsWidget
::uninstallShortcuts()
{
}


void qSlicerLORCollectControlsWidget
::SetLORNode( vtkMRMLNode* newNode )
Expand Down
3 changes: 3 additions & 0 deletions Widgets/qSlicerLORCollectControlsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ protected slots:

vtkMRMLNode* CollectNode;

virtual void installShortcuts();
virtual void uninstallShortcuts();

private:
Q_DECLARE_PRIVATE(qSlicerLORCollectControlsWidget);
Q_DISABLE_COPY(qSlicerLORCollectControlsWidget);
Expand Down
28 changes: 28 additions & 0 deletions Widgets/qSlicerLORFiducialWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ ::setup()

this->ConnectAllButtons();

this->ConvertShortcutC = NULL;

this->updateWidget();
}

Expand Down Expand Up @@ -146,12 +148,38 @@ ::enter()
void qSlicerLORFiducialWidget
::widgetActivated()
{
this->installShortcuts();
this->updateWidget();
}


void qSlicerLORFiducialWidget
::widgetDeactivated()
{
this->uninstallShortcuts();
this->updateWidget();
}


void qSlicerLORFiducialWidget
::installShortcuts()
{
Q_D(qSlicerLORFiducialWidget);

if ( this->ConvertShortcutC == NULL )
{
this->ConvertShortcutC = new QShortcut( QKeySequence( QString( "c" ) ), this );
}
connect( this->ConvertShortcutC, SIGNAL( activated() ), d->ConvertFiducialsButton, SLOT( click() ) );
}


void qSlicerLORFiducialWidget
::uninstallShortcuts()
{
Q_D(qSlicerLORFiducialWidget);

disconnect( this->ConvertShortcutC, SIGNAL( activated() ), d->ConvertFiducialsButton, SLOT( click() ) );
}


Expand Down
5 changes: 5 additions & 0 deletions Widgets/qSlicerLORFiducialWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ protected slots:
virtual void setup();
virtual void enter();

virtual void installShortcuts();
virtual void uninstallShortcuts();

QShortcut* ConvertShortcutC;

private:
Q_DECLARE_PRIVATE(qSlicerLORFiducialWidget);
Q_DISABLE_COPY(qSlicerLORFiducialWidget);
Expand Down
65 changes: 61 additions & 4 deletions Widgets/qSlicerLORManualDOFWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ ::setup()

this->ConnectAllButtons();

this->ReferenceShortcutR = NULL;
this->PointShortcutP = NULL;
this->LineShortcutL = NULL;
this->PlaneShortcutA = NULL;

this->updateWidget();
}

Expand Down Expand Up @@ -153,6 +158,10 @@ void qSlicerLORManualDOFWidget
::widgetActivated()
{
Q_D(qSlicerLORManualDOFWidget);

this->installShortcuts();

this->updateWidget();
}


Expand All @@ -165,9 +174,53 @@ ::widgetDeactivated()
{
this->LORNode->StopCollecting();
}

this->uninstallShortcuts();

this->updateWidget();
}


void qSlicerLORManualDOFWidget
::installShortcuts()
{
Q_D(qSlicerLORManualDOFWidget);

if ( this->ReferenceShortcutR == NULL )
{
this->ReferenceShortcutR = new QShortcut( QKeySequence( QString( "r" ) ), this );
}
if ( this->PointShortcutP == NULL )
{
this->PointShortcutP = new QShortcut( QKeySequence( QString( "p" ) ), this );
}
if ( this->LineShortcutL == NULL )
{
this->LineShortcutL = new QShortcut( QKeySequence( QString( "l" ) ), this );
}
if ( this->PlaneShortcutA == NULL )
{
this->PlaneShortcutA = new QShortcut( QKeySequence( QString( "a" ) ), this );
}

connect( this->ReferenceShortcutR, SIGNAL( activated() ), d->ReferenceButton, SLOT( toggle() ) );
connect( this->PointShortcutP, SIGNAL( activated() ), d->PointButton, SLOT( toggle() ) );
connect( this->LineShortcutL, SIGNAL( activated() ), d->LineButton, SLOT( toggle() ) );
connect( this->PlaneShortcutA, SIGNAL( activated() ), d->PlaneButton, SLOT( toggle() ) );
}


void qSlicerLORManualDOFWidget
::uninstallShortcuts()
{
Q_D(qSlicerLORManualDOFWidget);

disconnect( this->ReferenceShortcutR, SIGNAL( activated() ), d->ReferenceButton, SLOT( toggle() ) );
disconnect( this->PointShortcutP, SIGNAL( activated() ), d->PointButton, SLOT( toggle() ) );
disconnect( this->LineShortcutL, SIGNAL( activated() ), d->LineButton, SLOT( toggle() ) );
disconnect( this->PlaneShortcutA, SIGNAL( activated() ), d->PlaneButton, SLOT( toggle() ) );
}


void qSlicerLORManualDOFWidget
::onReferenceButtonToggled()
Expand All @@ -182,6 +235,7 @@ ::onReferenceButtonToggled()
{
this->LORNode->StopCollecting();
}
this->updateWidget();
}


Expand All @@ -198,6 +252,7 @@ ::onPointButtonToggled()
{
this->LORNode->StopCollecting();
}
this->updateWidget();
}


Expand All @@ -214,6 +269,7 @@ ::onLineButtonToggled()
{
this->LORNode->StopCollecting();
}
this->updateWidget();
}


Expand All @@ -230,6 +286,7 @@ ::onPlaneButtonToggled()
{
this->LORNode->StopCollecting();
}
this->updateWidget();
}


Expand All @@ -246,7 +303,7 @@ ::updateWidget()

this->DisconnectAllButtons();

if ( this->LORNode->GetCollectState().compare( LORConstants::REFERENCE_COLLECT_STATE ) )
if ( this->LORNode->GetCollectState().compare( LORConstants::REFERENCE_COLLECT_STATE ) == 0 )
{
d->ReferenceButton->setChecked( true );
}
Expand All @@ -255,7 +312,7 @@ ::updateWidget()
d->ReferenceButton->setChecked( false );
}

if ( this->LORNode->GetCollectState().compare( LORConstants::POINT_COLLECT_STATE ) )
if ( this->LORNode->GetCollectState().compare( LORConstants::POINT_COLLECT_STATE ) == 0 )
{
d->PointButton->setChecked( true );
}
Expand All @@ -264,7 +321,7 @@ ::updateWidget()
d->PointButton->setChecked( false );
}

if ( this->LORNode->GetCollectState().compare( LORConstants::LINE_COLLECT_STATE ) )
if ( this->LORNode->GetCollectState().compare( LORConstants::LINE_COLLECT_STATE ) == 0 )
{
d->LineButton->setChecked( true );
}
Expand All @@ -273,7 +330,7 @@ ::updateWidget()
d->LineButton->setChecked( false );
}

if ( this->LORNode->GetCollectState().compare( LORConstants::PLANE_COLLECT_STATE ) )
if ( this->LORNode->GetCollectState().compare( LORConstants::PLANE_COLLECT_STATE ) == 0 )
{
d->PlaneButton->setChecked( true );
}
Expand Down
8 changes: 8 additions & 0 deletions Widgets/qSlicerLORManualDOFWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ protected slots:
virtual void setup();
virtual void enter();

virtual void installShortcuts();
virtual void uninstallShortcuts();

QShortcut* ReferenceShortcutR;
QShortcut* PointShortcutP;
QShortcut* LineShortcutL;
QShortcut* PlaneShortcutA;

private:
Q_DECLARE_PRIVATE(qSlicerLORManualDOFWidget);
Q_DISABLE_COPY(qSlicerLORManualDOFWidget);
Expand Down
30 changes: 30 additions & 0 deletions Widgets/qSlicerLORManualSegmentationWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ ::setup()
d->setupUi(this);

connect( d->CollectButton, SIGNAL( toggled( bool ) ), this, SLOT( onCollectButtonToggled() ) );

this->CollectShortcutC = NULL;

this->updateWidget();
}
Expand Down Expand Up @@ -130,6 +132,9 @@ void qSlicerLORManualSegmentationWidget
::widgetActivated()
{
Q_D(qSlicerLORManualSegmentationWidget);

this->installShortcuts();

this->updateWidget();
}

Expand All @@ -143,10 +148,35 @@ ::widgetDeactivated()
{
this->LORNode->StopCollecting();
}

this->uninstallShortcuts();

this->updateWidget();
}


void qSlicerLORManualSegmentationWidget
::installShortcuts()
{
Q_D(qSlicerLORManualSegmentationWidget);

if ( this->CollectShortcutC == NULL )
{
this->CollectShortcutC = new QShortcut( QKeySequence( QString( "c" ) ), this );
}
connect( this->CollectShortcutC, SIGNAL( activated() ), d->CollectButton, SLOT( toggle() ) );
}


void qSlicerLORManualSegmentationWidget
::uninstallShortcuts()
{
Q_D(qSlicerLORManualSegmentationWidget);

disconnect( this->CollectShortcutC, SIGNAL( activated() ), d->CollectButton, SLOT( toggle() ) );
}


void qSlicerLORManualSegmentationWidget
::SetAndObserveCollectNode( vtkMRMLNode* newCollectNode )
{
Expand Down
5 changes: 5 additions & 0 deletions Widgets/qSlicerLORManualSegmentationWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ protected slots:
virtual void setup();
virtual void enter();

virtual void installShortcuts();
virtual void uninstallShortcuts();

QShortcut* CollectShortcutC;

private:
Q_DECLARE_PRIVATE(qSlicerLORManualSegmentationWidget);
Q_DISABLE_COPY(qSlicerLORManualSegmentationWidget);
Expand Down
Loading

0 comments on commit 89844b0

Please sign in to comment.