]> Creatis software - clitk.git/commitdiff
Added GoToLandmark functionality
authorRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Thu, 13 Dec 2012 16:16:02 +0000 (17:16 +0100)
committerRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Thu, 13 Dec 2012 16:16:02 +0000 (17:16 +0100)
- like GoToCursor, but when we double-click a landmark in the landmark panel's table

vv/vvLandmarksPanel.cxx
vv/vvLandmarksPanel.h
vv/vvMainWindow.cxx
vv/vvMainWindow.h

index 3781cd6938cf59d7a384bace294c207770b5de0e..2d3e1a5503ca4f0702e13947935035afd690d16f 100644 (file)
@@ -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<QTableWidgetItem *> 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) {
index 87682d3d4871cf2669ead4ddb2419e8806168bbf..01f53994ce67b0c604e8325199a9fca4f21f6f5e 100644 (file)
@@ -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
 //====================================================================
 
index 8ca48660a78c786dc680f8cb430d068a54d8056b..a44aadfb956311329c5b79e17d5c0076526efe73 100644 (file)
@@ -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()
 {
index 6e5b0412d68e9ad339031d156dc4e2b48d520b62..a15ff8b1bb6e26817d2e7a1abe45704bc0299cdf 100644 (file)
@@ -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) {