From 1cdf1a9613980c36319c375f8f86b8ad103bc300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20L=C3=A9ger?= <17100565+errollgarner@users.noreply.github.com> Date: Fri, 3 May 2024 15:29:35 -0400 Subject: [PATCH] Fix picking points outside of volume * When handling LandmarkRegistrationObject points outside of the main volume, no point would get selected in the widget after a capture and a subsequent capture would crash the app. This behaviour is undesired. While it may be rare to handle LandmarkRegistrationObject points not associated with a loaded volume, the case can still arise. * Current solution: Validation that points are within the bounds of the volume aren't enforced anymore and in the event that the user tries to capture when no point is selected, we simply move on without capturing anything and display an error message. --- IbisLib/pointsobject.cpp | 12 ------------ IbisLib/pointsobject.h | 2 -- .../landmarkregistrationobject.cpp | 3 --- .../landmarkregistrationobjectsettingswidget.cpp | 5 ++++- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/IbisLib/pointsobject.cpp b/IbisLib/pointsobject.cpp index 674ead76..50b0dd62 100644 --- a/IbisLib/pointsobject.cpp +++ b/IbisLib/pointsobject.cpp @@ -393,18 +393,6 @@ void PointsObject::UnselectAllPoints() emit ObjectModified(); } -void PointsObject::ValidateSelectedPoint() -{ - if( m_selectedPointIndex == InvalidPointIndex ) return; - - vtkSmartPointer pt = m_pointList.at( m_selectedPointIndex ); - if( !pt->CheckVisibility() ) - { - m_selectedPointIndex = InvalidPointIndex; - emit ObjectModified(); - } -} - void PointsObject::MoveCursorToPoint( int index ) { Q_ASSERT( index != InvalidPointIndex && index < m_pointCoordinates->GetNumberOfPoints() ); diff --git a/IbisLib/pointsobject.h b/IbisLib/pointsobject.h index 237c1258..7c00d2e5 100644 --- a/IbisLib/pointsobject.h +++ b/IbisLib/pointsobject.h @@ -180,8 +180,6 @@ class PointsObject : public SceneObject void SetPointCoordinates( int index, double coords[3] ); /** Set point timestamp - time when point was created. */ void SetPointTimeStamp( int index, const QString & stamp ); - /** Check if the selected point is in the current planes. */ - void ValidateSelectedPoint(); signals: void PointAdded(); diff --git a/IbisPlugins/LandmarkRegistrationObject/landmarkregistrationobject.cpp b/IbisPlugins/LandmarkRegistrationObject/landmarkregistrationobject.cpp index dfd1c306..f589bfeb 100644 --- a/IbisPlugins/LandmarkRegistrationObject/landmarkregistrationobject.cpp +++ b/IbisPlugins/LandmarkRegistrationObject/landmarkregistrationobject.cpp @@ -140,7 +140,6 @@ void LandmarkRegistrationObject::CurrentObjectChanged() if( GetManager()->GetCurrentObject() == SceneObject::SafeDownCast( this ) ) { EnablePicking( true ); - m_sourcePoints->ValidateSelectedPoint(); emit UpdateSettings(); } else @@ -297,7 +296,6 @@ void LandmarkRegistrationObject::Hide() void LandmarkRegistrationObject::Show() { m_sourcePoints->SetHidden( false ); - m_sourcePoints->ValidateSelectedPoint(); m_targetPoints->SetHidden( false ); m_sourcePoints->UpdatePointsVisibility(); m_targetPoints->UpdatePointsVisibility(); @@ -307,7 +305,6 @@ void LandmarkRegistrationObject::SetHiddenChildren( SceneObject * parent, bool h { // LandmarkRegistrationObject manages two PointsObjects, we just show/hide both. m_sourcePoints->SetHidden( hide ); - if( !hide ) m_sourcePoints->ValidateSelectedPoint(); m_targetPoints->SetHidden( hide ); m_sourcePoints->UpdatePointsVisibility(); m_targetPoints->UpdatePointsVisibility(); diff --git a/IbisPlugins/LandmarkRegistrationObject/landmarkregistrationobjectsettingswidget.cpp b/IbisPlugins/LandmarkRegistrationObject/landmarkregistrationobjectsettingswidget.cpp index 7faf6f66..abd595db 100644 --- a/IbisPlugins/LandmarkRegistrationObject/landmarkregistrationobjectsettingswidget.cpp +++ b/IbisPlugins/LandmarkRegistrationObject/landmarkregistrationobjectsettingswidget.cpp @@ -91,7 +91,10 @@ void LandmarkRegistrationObjectSettingsWidget::on_capturePushButton_clicked() { Q_ASSERT( m_registrationObject ); int index = ui->pointsTreeView->currentIndex().row(); - Q_ASSERT( index >= 0 && index < m_registrationObject->GetNumberOfPoints() ); + if( ! (index >= 0 && index < m_registrationObject->GetNumberOfPoints()) ){ + std::cerr << "No point selected, nothing was captured." << std::endl; + return; + } Q_ASSERT( m_registrationObject->GetManager() ); PointerObject * pointer = m_registrationObject->GetManager()->GetNavigationPointerObject();