Skip to content

Commit

Permalink
Re #23: Corresponding linear object is highlighted in the other list.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewsholden committed May 15, 2014
1 parent ede49ce commit 6f66194
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Widgets/qSlicerLinearObjectCollectionWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,22 @@ ::setScrollLinearObject( vtkObject* caller, void* callData )
}


void qSlicerLinearObjectCollectionWidget
::highlightNthLinearObject( int index )
{
Q_D(qSlicerLinearObjectCollectionWidget);

if ( index >= 0 && index < d->CollectionTableWidget->rowCount() )
{
d->CollectionTableWidget->selectRow( index );
}
else
{
d->CollectionTableWidget->clearSelection();
}
}


void qSlicerLinearObjectCollectionWidget
::updateWidget()
{
Expand Down Expand Up @@ -670,4 +686,6 @@ ::updateWidget()
this->ScrollLinearObject = NULL;

d->CollectionTableWidget->blockSignals( false );

emit updateFinished();
}
5 changes: 5 additions & 0 deletions Widgets/qSlicerLinearObjectCollectionWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ qSlicerLinearObjectCollectionWidget : public qSlicerWidget
std::string GetQtStyleStringActive();
std::string GetQtStyleStringInactive();

public slots:

void highlightNthLinearObject( int index );

protected slots:

void onCollectionNodeChanged(); // User selects a different node using the combo box
Expand All @@ -84,6 +88,7 @@ protected slots:
void collectionNodeChanged();
void linearObjectSelected();
void collectionNodeActivated();
void updateFinished();

protected:
QScopedPointer<qSlicerLinearObjectCollectionWidgetPrivate> d_ptr;
Expand Down
35 changes: 35 additions & 0 deletions qSlicerLinearObjectRegistrationModuleWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,10 @@ ::ConnectWidgets()

connect( d->FromCollectionWidget, SIGNAL( collectionNodeChanged() ), this, SLOT( UpdateToMRMLNode() ) );
connect( d->FromCollectionWidget, SIGNAL( collectionNodeActivated() ), this, SLOT( UpdateToMRMLNode() ) );
connect( d->FromCollectionWidget, SIGNAL( updateFinished() ), this, SLOT( PostProcessCollectionWidgets() ) );
connect( d->ToCollectionWidget, SIGNAL( collectionNodeChanged() ), this, SLOT( UpdateToMRMLNode() ) );
connect( d->ToCollectionWidget, SIGNAL( collectionNodeActivated() ), this, SLOT( UpdateToMRMLNode() ) );
connect( d->ToCollectionWidget, SIGNAL( updateFinished() ), this, SLOT( PostProcessCollectionWidgets() ) );

connect( d->MergeThresholdSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( UpdateToMRMLNode() ) );
connect( d->NoiseThresholdSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( UpdateToMRMLNode() ) );
Expand Down Expand Up @@ -574,3 +576,36 @@ ::UpdateFromMRMLNode()
d->StatusLabel->setText( QString::fromStdString( statusString.str() ) ); // Also update the results
}


void qSlicerLinearObjectRegistrationModuleWidget
::PostProcessCollectionWidgets()
{
Q_D( qSlicerLinearObjectRegistrationModuleWidget );

vtkMRMLLinearObjectCollectionNode* activeCollectionNode = d->logic()->GetActiveCollectionNode();

vtkMRMLLinearObjectCollectionNode* fromCollectionNode = vtkMRMLLinearObjectCollectionNode::SafeDownCast( d->FromCollectionWidget->GetCurrentNode() );
vtkMRMLLinearObjectCollectionNode* toCollectionNode = vtkMRMLLinearObjectCollectionNode::SafeDownCast( d->ToCollectionWidget->GetCurrentNode() );

vtkMRMLLinearObjectRegistrationNode* linearObjectRegistrationNode = vtkMRMLLinearObjectRegistrationNode::SafeDownCast( d->ModuleNodeComboBox->currentNode() );

if ( fromCollectionNode == NULL || toCollectionNode == NULL || linearObjectRegistrationNode == NULL )
{
return;
}

if ( ! linearObjectRegistrationNode->GetAutomaticMatch() )
{
// Adding to "From" collection
if ( strcmp( activeCollectionNode->GetID(), fromCollectionNode->GetID() ) == 0 )
{
d->ToCollectionWidget->highlightNthLinearObject( fromCollectionNode->Size() );
}
// Adding to "To" collection
if ( strcmp( activeCollectionNode->GetID(), toCollectionNode->GetID() ) == 0 )
{
d->FromCollectionWidget->highlightNthLinearObject( toCollectionNode->Size() );
}
}

}
2 changes: 2 additions & 0 deletions qSlicerLinearObjectRegistrationModuleWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public slots:
void UpdateToMRMLNode();
void UpdateFromMRMLNode();

void PostProcessCollectionWidgets();

protected:
QScopedPointer<qSlicerLinearObjectRegistrationModuleWidgetPrivate> d_ptr;

Expand Down

0 comments on commit 6f66194

Please sign in to comment.