From: srit Date: Fri, 2 Apr 2010 09:50:38 +0000 (+0000) Subject: Added next prev image keys. Temporarily in a q. X-Git-Tag: v1.2.0~735 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=78ae141332b4f8d5146952b08dced58e4d248e06;p=clitk.git Added next prev image keys. Temporarily in a q. --- diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index c7d05c6..516c736 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -881,29 +881,30 @@ void vvMainWindow::LoadImages(std::vector 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(); diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index adfed23..acacde8 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -46,7 +46,6 @@ class vvMainWindow: public vvMainWindowBase, ~vvMainWindow(); void LoadImages(std::vector 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 vectorDouble); QString GetVectorIntAsString(std::vector vectorInt); int GetSlicerIndexFromItem(QTreeWidgetItem* item); + QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm); void SaveScreenshot(vtkImageData* image); QMenu contextMenu; diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 8535686..b0156ad 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -27,15 +27,15 @@ #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 +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -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); +} +//---------------------------------------------------------------------------- diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index 7456078..1608fbc 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -19,6 +19,7 @@ #ifndef VVSLICERMANAGER_H #define VVSLICERMANAGER_H +// std #include #include #include @@ -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 mSlicers; diff --git a/vv/vvSlicerManagerCommand.cxx b/vv/vvSlicerManagerCommand.cxx index 5e3a654..0977586 100644 --- a/vv/vvSlicerManagerCommand.cxx +++ b/vv/vvSlicerManagerCommand.cxx @@ -18,18 +18,18 @@ #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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #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(isi->GetWindowLevelCurrentPosition()[0] - - isi->GetWindowLevelStartPosition()[0]) / size[0]; + isi->GetWindowLevelStartPosition()[0]) / size[0]; double dy = static_cast(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; }