From a4ff6dd3c32575f669bbccf6b881d04a6b95c3da Mon Sep 17 00:00:00 2001 From: Romulo Pinho Date: Thu, 13 Dec 2012 17:16:02 +0100 Subject: [PATCH] Added GoToLandmark functionality - like GoToCursor, but when we double-click a landmark in the landmark panel's table --- vv/vvLandmarksPanel.cxx | 20 ++++++++++++++++++++ vv/vvLandmarksPanel.h | 5 +++++ vv/vvMainWindow.cxx | 18 ++++++++++++++++++ vv/vvMainWindow.h | 1 + 4 files changed, 44 insertions(+) diff --git a/vv/vvLandmarksPanel.cxx b/vv/vvLandmarksPanel.cxx index 3781cd6..2d3e1a5 100644 --- a/vv/vvLandmarksPanel.cxx +++ b/vv/vvLandmarksPanel.cxx @@ -43,6 +43,7 @@ vvLandmarksPanel::vvLandmarksPanel(QWidget * parent):QWidget(parent) connect(removeButton, SIGNAL(clicked()),this,SLOT(RemoveSelectedPoints())); connect(removeAllButton, SIGNAL(clicked()),this,SLOT(RemoveAllPoints())); connect(tableWidget,SIGNAL(cellChanged(int,int)),this,SLOT(CommentsChanged(int,int))); + connect(tableWidget,SIGNAL(doubleClicked(const QModelIndex &)),this,SLOT(SelectPoint())); } void vvLandmarksPanel::Load() @@ -78,6 +79,25 @@ void vvLandmarksPanel::Save() } } +void vvLandmarksPanel::SelectPoint() +{ + if (tableWidget->rowCount() > 0) { + QList items = tableWidget->selectedItems(); + if (!items.empty()) { + // we're using single-selection mode + int row = items[0]->row(); + mSelectedPoint[0] = mCurrentLandmarks->GetCoordinates(row)[0]; + mSelectedPoint[1] = mCurrentLandmarks->GetCoordinates(row)[1]; + mSelectedPoint[2] = mCurrentLandmarks->GetCoordinates(row)[2]; + mSelectedPoint[3] = mCurrentLandmarks->GetCoordinates(row)[3]; + + emit SelectedPointChanged(); + } + } + +} + + void vvLandmarksPanel::RemoveSelectedPoints() { if (tableWidget->rowCount() > 0) { diff --git a/vv/vvLandmarksPanel.h b/vv/vvLandmarksPanel.h index 87682d3..01f5399 100644 --- a/vv/vvLandmarksPanel.h +++ b/vv/vvLandmarksPanel.h @@ -38,6 +38,7 @@ public: mCurrentPath = path; } void SetCurrentImage(std::string filename); + double* GetSelectedPoint() { return mSelectedPoint; } public slots: void Load(); @@ -46,14 +47,18 @@ public slots: void RemoveSelectedPoints(); void RemoveAllPoints(); void AddPoint(); + void SelectPoint(); void CommentsChanged(int row, int column); signals: void UpdateRenderWindows(); + void SelectedPointChanged(); private: void AddPoint(int); + vvLandmarks* mCurrentLandmarks; std::string mCurrentPath; + double mSelectedPoint[4]; }; // end class vvLandmarksPanel //==================================================================== diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 8ca4866..a44aadf 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -324,6 +324,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,int,double,double, bool)), this,SLOT(SetFusionProperty(int,int,int,double,double, bool))); connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows())); + connect(landmarksPanel,SIGNAL(SelectedPointChanged()),this,SLOT(GoToLandmark())); playMode = 0;//pause mFrameRate = 10; @@ -2990,6 +2991,23 @@ void vvMainWindow::GoToCursor() } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvMainWindow::GoToLandmark() +{ + int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); + for (int column = 1; column < 5; column++) { + if (DataTree->selectedItems()[0]->data(column,Qt::CheckStateRole).toInt() > 1) { + double* cursorPos = landmarksPanel->GetSelectedPoint(); + mSlicerManagers[index]->GetSlicer(column-1)->SetCurrentPosition( + cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]); + mSlicerManagers[index]->UpdateViews(1,column-1); + mSlicerManagers[index]->UpdateLinked(column-1); + break; + } + } +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::PlayPause() { diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index 6e5b041..a15ff8b 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -161,6 +161,7 @@ public slots: void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level, bool showLegend); void GoToCursor(); + void GoToLandmark(); void PlayPause(); void PlayNext(); void ChangeFrameRate(int rate) { -- 2.46.1