Skip to content

Commit 3e881bc

Browse files
committed
Allow placing cursor on isosurfaces
1 parent b2afea8 commit 3e881bc

File tree

3 files changed

+58
-16
lines changed

3 files changed

+58
-16
lines changed

freeview/Interactor3DPointSetEdit.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ bool Interactor3DPointSetEdit::ProcessKeyDownEvent( QKeyEvent* event, RenderView
3939
bool Interactor3DPointSetEdit::ProcessMouseUpEvent( QMouseEvent* event, RenderView* renderview )
4040
{
4141
RenderView3D* view = ( RenderView3D* )renderview;
42+
MainWindow* mwnd = MainWindow::GetMainWindow();
4243
if (m_bEditAttempted && qAbs(event->x() - this->m_nPressedPosX) < 2
4344
&& qAbs(event->y() - this->m_nPressedPosY) < 2)
4445
{
@@ -50,24 +51,40 @@ bool Interactor3DPointSetEdit::ProcessMouseUpEvent( QMouseEvent* event, RenderVi
5051
return false;
5152
}
5253

53-
if (surf && wp)
54+
if (wp)
5455
{
5556
if ( !(event->modifiers() & Qt::ShiftModifier) )
5657
{
57-
int nvo = -1;
58-
nvo = view->PickCurrentSurfaceVertex(event->x(), event->y(), surf);
59-
if (nvo >= 0)
58+
if (!mwnd->GetVisibleLayers("Surf").isEmpty())
6059
{
61-
wp->SaveForUndo();
62-
double ras[3];
63-
surf->GetTargetAtVertex(nvo, ras, surf->IsInflated()?FSSurface::SurfaceWhite:-1);
64-
int nIndex = wp->FindPoint( ras );
65-
if ( nIndex < 0 )
60+
int nvo = -1;
61+
nvo = view->PickCurrentSurfaceVertex(event->x(), event->y(), surf);
62+
if (nvo >= 0)
6663
{
67-
nIndex = wp->AddPoint( ras, 1, true );
68-
return true;
64+
wp->SaveForUndo();
65+
double ras[3];
66+
surf->GetTargetAtVertex(nvo, ras, surf->IsInflated()?FSSurface::SurfaceWhite:-1);
67+
int nIndex = wp->FindPoint( ras );
68+
if ( nIndex < 0 )
69+
{
70+
nIndex = wp->AddPoint( ras, 1, true );
71+
return true;
72+
}
6973
}
7074
}
75+
// else if (!mwnd->GetVisibleLayers("MRI").isEmpty())
76+
// {
77+
// double ras[3];
78+
// if (view->PickVolume(event->x(), event->y(), ras))
79+
// {
80+
// int nIndex = wp->FindPoint( ras );
81+
// if ( nIndex < 0 )
82+
// {
83+
// nIndex = wp->AddPoint( ras, 1, true );
84+
// return true;
85+
// }
86+
// }
87+
// }
7188
}
7289
else
7390
{

freeview/RenderView3D.cpp

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ void RenderView3D::DoUpdateRASPosition( int posX, int posY, bool bCursor, bool b
438438
// MousePositionToRAS( posX, posY, pos );
439439
// vtkPointPicker* picker = vtkPointPicker::SafeDownCast( this->GetPicker() );
440440
vtkCellPicker* picker = vtkCellPicker::SafeDownCast( this->GetRenderWindow()->GetInteractor()->GetPicker() );
441-
// vtkPropPicker* picker = vtkPropPicker::SafeDownCast( this->GetPicker() );
442441
if ( picker )
443442
{
444443
picker->InitializePickList();
@@ -553,8 +552,13 @@ void RenderView3D::DoUpdateRASPosition( int posX, int posY, bool bCursor, bool b
553552
picker->Pick( posX, posY, 0, GetRenderer() );
554553
picker->GetPickPosition( pos );
555554
prop = picker->GetViewProp();
556-
557-
if ( lc_mri->HasProp( prop ) || lc_roi->HasProp( prop ) )
555+
LayerMRI* mri_sel = (LayerMRI*)lc_mri->HasProp(prop);
556+
if (mri_sel->GetProperty()->GetShowAsContour())
557+
{
558+
lc_mri->SetCursorRASPosition( pos );
559+
MainWindow::GetMainWindow()->SetSlicePosition( pos );
560+
}
561+
else if ( lc_mri->HasProp( prop ) || lc_roi->HasProp( prop ) )
558562
{
559563
if ( bCursor )
560564
{
@@ -783,9 +787,8 @@ int RenderView3D::PickCurrentSurfaceVertex(int posX, int posY, LayerSurface* cur
783787

784788
int RenderView3D::PickCurrentPointSetPoint(int posX, int posY, LayerPointSet *curPointSet)
785789
{
786-
LayerCollection* lc_ps = MainWindow::GetMainWindow()->GetLayerCollection( "PointSet" );
787-
788790
this->setToolTip("");
791+
LayerCollection* lc_ps = MainWindow::GetMainWindow()->GetLayerCollection( "PointSet" );
789792
if ( lc_ps->IsEmpty() )
790793
{
791794
return -1;
@@ -1922,3 +1925,23 @@ void RenderView3D::SavePathAsControlPoints(SurfacePath *sp)
19221925
QMessageBox::warning(this, "Error", "Failed to save file " + fn);
19231926
}
19241927
}
1928+
1929+
bool RenderView3D::PickVolume(int posX, int posY, double *pos_out)
1930+
{
1931+
vtkProp* prop = this->PickProp( posX, posY, pos_out );
1932+
if ( !prop )
1933+
{
1934+
return false;
1935+
}
1936+
1937+
LayerCollection* lc_mri = MainWindow::GetMainWindow()->GetLayerCollection( "MRI" );
1938+
for ( int i = 0; i < lc_mri->GetNumberOfLayers(); i++ )
1939+
{
1940+
LayerMRI* mri = (LayerMRI*)lc_mri->GetLayer(i);
1941+
if (mri->GetProperty()->GetShowAsContour() && mri->HasProp(prop))
1942+
{
1943+
return true;
1944+
}
1945+
}
1946+
return false;
1947+
}

freeview/RenderView3D.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ class RenderView3D : public RenderView
115115

116116
int PickCurrentPointSetPoint(int posX, int posY, LayerPointSet* curPointSet = NULL);
117117

118+
bool PickVolume(int posX, int posY, double* pt_out);
119+
118120
void ShowSlice(int nPlane, bool bshow);
119121

120122
QVariantMap GetCameraInfo();

0 commit comments

Comments
 (0)