]> Creatis software - clitk.git/commitdiff
Added next prev image keys. Temporarily in a q.
authorsrit <srit>
Fri, 2 Apr 2010 09:50:38 +0000 (09:50 +0000)
committersrit <srit>
Fri, 2 Apr 2010 09:50:38 +0000 (09:50 +0000)
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h
vv/vvSlicerManagerCommand.cxx

index c7d05c65d333f75cc61d5c0019670991fd347f84..516c736acbc5eef76cdcbb9d56848464e2125ad4 100644 (file)
@@ -881,29 +881,30 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, LoadedImageType fi
 
         linkPanel->addImage(imageManager->GetFileName(), id.toStdString());
 
-        connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)),
+        connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)),
                 this,SLOT(CurrentImageChanged(std::string)));
-        connect(mSlicerManagers.back(),SIGNAL(
-                                              UpdatePosition(int, double, double, double, double, double, double, double)),this,
-                SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
-        connect(mSlicerManagers.back(),SIGNAL(UpdateVector(int, double, double, double, double)),
+        connect(mSlicerManagers.back(), SIGNAL(UpdatePosition(int, double, double, double, double, double, double, double)),
+             this,SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
+        connect(mSlicerManagers.back(), SIGNAL(UpdateVector(int, double, double, double, double)),
                 this, SLOT(VectorChanged(int,double,double,double, double)));
-        connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)),
+        connect(mSlicerManagers.back(), SIGNAL(UpdateOverlay(int, double, double)),
                 this, SLOT(OverlayChanged(int,double,double)));
-        connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)),
+        connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
                 this, SLOT(FusionChanged(int,double)));
-        connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)),
+        connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)),
                 this,SLOT(WindowsChanged(int, int, int)));
-        connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)),
+        connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
                 this,SLOT(WindowLevelChanged(double, double, int, int)));
-        connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)),
+        connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
                 this,SLOT(UpdateSlice(int,int)));
-        connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)),
+        connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),
                 this,SLOT(UpdateTSlice(int, int)));
-        connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)),
+        connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)),
                 this,SLOT(UpdateSliceRange(int,int,int,int,int)));
-        connect(mSlicerManagers.back(),SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
+        connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
                 this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
+        connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)),
+                this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)));
         connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
         InitSlicers();
         numberofsuccesulreads++;
@@ -1306,6 +1307,18 @@ int vvMainWindow::GetSlicerIndexFromItem(QTreeWidgetItem* item) {
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+QTreeWidgetItem* vvMainWindow::GetItemFromSlicerManager(vvSlicerManager* sm) {
+    QString id = sm->GetId().c_str();
+    for (int i = 0; i < DataTree->topLevelItemCount(); i++)
+    {
+        if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id)
+            return DataTree->topLevelItem(i);
+    }
+    return NULL;
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 void vvMainWindow::DisplayChanged(QTreeWidgetItem *clicked_item, int column) {
   int index = GetSlicerIndexFromItem(clicked_item);
@@ -1313,6 +1326,9 @@ void vvMainWindow::DisplayChanged(QTreeWidgetItem *clicked_item, int column) {
     return;
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
     {
+     //Trick to avoid redoing twice the job for a key (sr)
+      mSlicerManagers[i]->GetSlicer(column-1)->GetRenderWindow()-> GetInteractor()->SetKeySym("Crap");
+      
       QTreeWidgetItem* current_row=DataTree->topLevelItem(i);
       if (DataTree->topLevelItem(index) == current_row)
         {
@@ -2328,6 +2344,21 @@ void vvMainWindow::RemoveLink(QString image1,QString image2) {
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+void vvMainWindow::ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset)
+{
+    int index = 0;
+    while(sm != mSlicerManagers[index])
+        index++;
+    index = (index+offset) % mSlicerManagers.size();
+
+    QTreeWidgetItem* item = GetItemFromSlicerManager(mSlicerManagers[index]);
+    //CurrentImageChanged(mSlicerManagers[index]->GetId()); //select new image
+    item->setData(slicer+1,Qt::CheckStateRole,2);         //change checkbox
+    DisplayChanged(item,slicer+1);
+}
+//------------------------------------------------------------------------------
+
 void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index)
 {
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
@@ -2717,18 +2748,11 @@ void vvMainWindow::SurfaceViewerLaunch()
 //------------------------------------------------------------------------------
 void vvMainWindow::AddImage(vvImage::Pointer image,std::string filename)
 {
-  vvSlicerManager* m = new vvSlicerManager(4);
-  m->SetImage(image);
-  m->SetFilename(filename);
-  AddImage(m);
-}
-
-//------------------------------------------------------------------------------
-void vvMainWindow::AddImage(vvSlicerManager * slicer_manager) {
+  vvSlicerManager* slicer_manager = new vvSlicerManager(4);
+  slicer_manager->SetImage(image);
+  slicer_manager->SetFilename(filename);
   mSlicerManagers.push_back(slicer_manager);
 
-  std::string filename = slicer_manager->GetFileName();
-
   //create an item in the tree with good settings
   QTreeWidgetItem *item = new QTreeWidgetItem();
   item->setData(0,Qt::UserRole,slicer_manager->GetFileName().c_str());//files[i].c_str());
@@ -2765,30 +2789,31 @@ void vvMainWindow::AddImage(vvSlicerManager * slicer_manager) {
 
   linkPanel->addImage(filename, id.toStdString());
 
-  connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)),
-          this,SLOT(CurrentImageChanged(std::string)));
-  connect(mSlicerManagers.back(),SIGNAL(
-                                        UpdatePosition(int, double, double, double, double, double, double, double)),this,
-          SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
-  connect(mSlicerManagers.back(),SIGNAL(UpdateVector(int, double, double, double, double)),
+  connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)),
+          this, SLOT(CurrentImageChanged(std::string)));
+  connect(mSlicerManagers.back(), SIGNAL(UpdatePosition(int, double, double, double, double, double, double, double)),
+          this, SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
+  connect(mSlicerManagers.back(), SIGNAL(UpdateVector(int, double, double, double, double)),
           this, SLOT(VectorChanged(int,double,double,double, double)));
-  connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)),
+  connect(mSlicerManagers.back(), SIGNAL(UpdateOverlay(int, double, double)),
           this, SLOT(OverlayChanged(int,double,double)));
-  connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)),
+  connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
           this, SLOT(FusionChanged(int,double)));
-  connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)),
+  connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)),
           this,SLOT(WindowsChanged(int, int, int)));
-  connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)),
+  connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
           this,SLOT(WindowLevelChanged(double, double, int, int)));
-  connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)),
+  connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
           this,SLOT(UpdateSlice(int,int)));
-  connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)),
+  connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),
           this,SLOT(UpdateTSlice(int, int)));
-  connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)),
+  connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)),
           this,SLOT(UpdateSliceRange(int,int,int,int,int)));
-  connect(mSlicerManagers.back(),SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
+  connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
           this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
-  connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
+  connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)),
+          this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)));
+  connect(mSlicerManagers.back(), SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
   UpdateTree();
   qApp->processEvents();
   InitSlicers();
index adfed23c88fc31759a4e6effc955f3e8a9f1c7ee..acacde84a1c5ce4e67d5eb052ea29ee6a24f9b49 100644 (file)
@@ -46,7 +46,6 @@ class vvMainWindow: public vvMainWindowBase,
   ~vvMainWindow();
   void LoadImages(std::vector<std::string> filenames, LoadedImageType type);
   void AddImage(vvImage::Pointer image,std::string filename);
-  void AddImage(vvSlicerManager * m);
   void AddField(QString file,int index);
   void AddOverlayImage(int index, QString filename);
   ///Adds a mesh to a SlicerManager, with optional warping by vector field
@@ -105,6 +104,7 @@ public slots:
   void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
   void AddLink(QString image1,QString image2);
   void RemoveLink(QString image1,QString image2);
+  void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
 
   ///Generic method called when any one of the horizontal sliders is moved
   void HorizontalSliderMoved(int value,int column, int slicer_index);
@@ -172,6 +172,7 @@ private:
   QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
   QString GetVectorIntAsString(std::vector<int> vectorInt);
   int GetSlicerIndexFromItem(QTreeWidgetItem* item);
+  QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
   void SaveScreenshot(vtkImageData* image);
 
   QMenu contextMenu;
index 85356864018f5746f50146707a734dd7b2c3abbc..b0156adee468c769722994599cc6d494f24212e0 100644 (file)
 #include "vvMesh.h"
 #include "vvImageMapToWLColors.h"
 
-#include "vtkImageActor.h"
-#include "vtkImageData.h"
-#include "vtkRenderWindow.h"
-#include "vtkRendererCollection.h"
-#include "vtkRenderWindowInteractor.h"
-#include "vtkImageMapToWindowLevelColors.h"
-#include "vtkWindowLevelLookupTable.h"
-#include "vtkColorTransferFunction.h"
-#include "vtkImageClip.h"
+#include <vtkImageActor.h>
+#include <vtkImageData.h>
+#include <vtkRenderWindow.h>
+#include <vtkRendererCollection.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkImageMapToWindowLevelColors.h>
+#include <vtkWindowLevelLookupTable.h>
+#include <vtkColorTransferFunction.h>
+#include <vtkImageClip.h>
 #include <vtkLODActor.h>
 #include <vtkPointData.h>
 #include <vtksys/SystemTools.hxx>
@@ -1194,3 +1194,17 @@ void vvSlicerManager::AddLandmark(float x,float y,float z,float t)
   emit LandmarkAdded();
 }
 //----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+void vvSlicerManager::PrevImage(int slicer)
+{
+  emit ChangeImageWithIndexOffset(this, slicer, -1);
+}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+void vvSlicerManager::NextImage(int slicer)
+{
+  emit ChangeImageWithIndexOffset(this, slicer,  1);
+}
+//----------------------------------------------------------------------------
index 74560789979b45c13e133359562ba6dcf36ab0f4..1608fbcec492dff52fae769cc3f957b6c3e5bb51 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef VVSLICERMANAGER_H
 #define VVSLICERMANAGER_H
 
+// std
 #include <iostream>
 #include <vector>
 #include <string>
@@ -182,6 +183,9 @@ class vvSlicerManager : public QObject {
 
   vvLandmarks *GetLandmarks();
   void AddLandmark(float x,float y,float z,float t);
+  
+  void NextImage(int slicer);
+  void PrevImage(int slicer);
 
 signals :
   void currentImageChanged(std::string id);
@@ -196,6 +200,7 @@ signals :
   void WindowLevelChanged(double window, double level, int preset, int colormap);
   void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
   void LandmarkAdded();
+  void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
 
 protected:
   std::vector<vvSlicer*> mSlicers;
index 5e3a6541cef0271524762ce82afca7c26fea1b32..0977586210ec76100435824927e7d44d1e5a772d 100644 (file)
 #include "vvSlicerManagerCommand.h"
 #include "vvSlicerManager.h"
 
-#include "vtkTextProperty.h"
-#include "vtkRenderer.h"
-#include "vtkImageActor.h"
-#include "vtkRenderWindowInteractor.h"
-#include "vtkPropPicker.h"
-#include "vtkCamera.h"
-#include "vtkImageMapToWindowLevelColors.h"
-#include "vtkLookupTable.h"
-#include "vtkMath.h"
-#include "vtkAbstractPropPicker.h"
-#include "vtkAssemblyPath.h"
-#include "vtkCornerAnnotation.h"
+#include <vtkTextProperty.h>
+#include <vtkRenderer.h>
+#include <vtkImageActor.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkPropPicker.h>
+#include <vtkCamera.h>
+#include <vtkImageMapToWindowLevelColors.h>
+#include <vtkLookupTable.h>
+#include <vtkMath.h>
+#include <vtkAbstractPropPicker.h>
+#include <vtkAssemblyPath.h>
+#include <vtkCornerAnnotation.h>
 #include <vtkRenderWindow.h>
 
 #include "vvSlicer.h"
@@ -63,8 +63,8 @@ int vvSlicerManagerCommand::FindSlicerNumber(vtkRenderWindow* renwin)
 
 //------------------------------------------------------------------------------
 void vvSlicerManagerCommand::Execute(vtkObject *caller,
-        unsigned long event,
-        void *vtkNotUsed(callData))
+                                     unsigned long event,
+                                     void *vtkNotUsed(callData))
 {
     //KeyPress event
     vvInteractorStyleNavigator *isi =
@@ -77,7 +77,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
 
         int VisibleInWindow = this->FindSlicerNumber(isi->GetInteractor()->GetRenderWindow());
         vtkRenderer* renderer=NULL;
-        if (VisibleInWindow>-1) 
+        if (VisibleInWindow>-1)
             renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
         newLandmark = false;
 
@@ -97,9 +97,20 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
             if (event == vtkCommand::KeyPressEvent)
             {
                 std::string KeyPress = isi->GetInteractor()->GetKeySym();
+              if (KeyPress == "a")
+              {
+                  this->SM->PrevImage(VisibleInWindow);
+                  return;
+              }
+              if (KeyPress == "q")
+              {
+                  this->SM->NextImage(VisibleInWindow);
+                  return;
+              }
                 if (KeyPress == "f" || KeyPress == "F")
                 {
                     FlyToPosition(isi->GetInteractor(),this->SM->GetSlicer(VisibleInWindow));
+                  return;
                 }
                if (KeyPress == "z")
                {
@@ -371,7 +382,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
             if (newLandmark)
             {
                 this->SM->AddLandmark(xWorld,yWorld,zWorld,
-                        this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
+                                      this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
                 this->SM->GetSlicer(VisibleInWindow)->UpdateLandmarks();
                 this->SM->Render();
             }
@@ -402,9 +413,9 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
 
             // Compute normalized delta
             double dx = static_cast<double>(isi->GetWindowLevelCurrentPosition()[0] -
-                    isi->GetWindowLevelStartPosition()[0]) / size[0];
+                                            isi->GetWindowLevelStartPosition()[0]) / size[0];
             double dy = static_cast<double>(isi->GetWindowLevelStartPosition()[1] -
-                    isi->GetWindowLevelCurrentPosition()[1]) / size[1];
+                                            isi->GetWindowLevelCurrentPosition()[1]) / size[1];
             //Window is exponential in nature, use exponential to avoid falling into negative numbers
             dx = std::exp(1.0 * (dx*fabs(dx) + dx)) ; //Quadratic behavior for more reactive interface
             dy = 0.15 * (dy*fabs(dy) + dy) * (range[1]-range[0]);//Quadratic behavior for more reactive interface
@@ -426,7 +437,7 @@ void vvSlicerManagerCommand::Dolly(double factor, vtkRenderWindowInteractor *int
 {
     int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
     vtkRenderer* renderer;
-    if (VisibleInWindow>-1) 
+    if (VisibleInWindow>-1)
         renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
     else
     {
@@ -476,12 +487,12 @@ void vvSlicerManagerCommand::Dolly(double factor, vtkRenderWindowInteractor *int
     camera->GetFocalPoint(viewFocus);
     camera->GetPosition(viewPoint);
     camera->SetFocalPoint(motionVector[0] + viewFocus[0],
-            motionVector[1] + viewFocus[1],
-            motionVector[2] + viewFocus[2]);
+                          motionVector[1] + viewFocus[1],
+                          motionVector[2] + viewFocus[2]);
 
     camera->SetPosition(motionVector[0] + viewPoint[0],
-            motionVector[1] + viewPoint[1],
-            motionVector[2] + viewPoint[2]);
+                        motionVector[1] + viewPoint[1],
+                        motionVector[2] + viewPoint[2]);
 
     if (camera->GetParallelProjection())
     {
@@ -507,14 +518,14 @@ void vvSlicerManagerCommand::FlyToPosition(vtkRenderWindowInteractor *interactor
     int i, j;
     int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
     vtkRenderer* renderer=NULL;
-    if (VisibleInWindow>-1) 
+    if (VisibleInWindow>-1)
         renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
     else
         return;
 
     interactor->GetPicker()->Pick(interactor->GetEventPosition()[0],
-            interactor->GetEventPosition()[1], 0.0,
-            renderer);
+                                  interactor->GetEventPosition()[1], 0.0,
+                                  renderer);
 
     vtkAssemblyPath *path=NULL;
     vtkAbstractPropPicker *picker;
@@ -532,17 +543,17 @@ void vvSlicerManagerCommand::FlyToPosition(vtkRenderWindowInteractor *interactor
 
         switch (slicer->GetSliceOrientation())
         {
-            case vtkImageViewer2::SLICE_ORIENTATION_XY:
-                flyTo[2] = flyFrom[2];
-                break;
+        case vtkImageViewer2::SLICE_ORIENTATION_XY:
+            flyTo[2] = flyFrom[2];
+            break;
 
-            case vtkImageViewer2::SLICE_ORIENTATION_XZ:
-                flyTo[1] = flyFrom[1];
-                break;
+        case vtkImageViewer2::SLICE_ORIENTATION_XZ:
+            flyTo[1] = flyFrom[1];
+            break;
 
-            case vtkImageViewer2::SLICE_ORIENTATION_YZ:
-                flyTo[0] = flyFrom[0];
-                break;
+        case vtkImageViewer2::SLICE_ORIENTATION_YZ:
+            flyTo[0] = flyFrom[0];
+            break;
         }