X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvSlicerManager.cxx;h=1b432638e810915c48d252090aa6526823e45ce0;hb=c99295881254fc9245d4ee2a4cf940cf87ca2d7f;hp=cc99762fafc2466a2c789305953f0123392d173b;hpb=4f5c82fca3e8209bc02be1ce3e9ed55308ad5dfe;p=clitk.git diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index cc99762..1b43263 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -46,7 +46,10 @@ #include //---------------------------------------------------------------------------- vvSlicerManager::vvSlicerManager(int numberOfSlicers) -{ //out << __func__ << endl; +{ + + connect(this, SIGNAL(callAddLandmark(float,float,float,float)), this, SLOT(AddLandmark(float,float,float,float))); + mFileName = ""; mId = ""; mVFName = ""; @@ -76,8 +79,10 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers) mLandmarks = NULL; mLinkedId.resize(0); - for ( int i = 0; i < numberOfSlicers; i++) + for ( int i = 0; i < numberOfSlicers; i++) { mSlicers.push_back(vtkSmartPointer::New()); + mSlicers[i]->SetSlicerNumber(i); + } mSelectedSlicer = -1; mPreviousSlice.resize(numberOfSlicers, 0); @@ -91,7 +96,7 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers) //---------------------------------------------------------------------------- vvSlicerManager::~vvSlicerManager() -{ //out << __func__ << endl; +{ if (mLandmarks) delete mLandmarks; } @@ -100,7 +105,7 @@ vvSlicerManager::~vvSlicerManager() //------------------------------------------------------------------------------ void vvSlicerManager::SetFilename(std::string filename, int number) -{ //out << __func__ << endl; +{ mFileName = filename; mFileName = vtksys::SystemTools::GetFilenameName(mFileName); mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName)); @@ -122,7 +127,7 @@ void vvSlicerManager::SetFilename(std::string filename, int number) //---------------------------------------------------------------------------- void vvSlicerManager::AddContour(vvMesh::Pointer contour,bool propagate) -{ //out << __func__ << endl; +{ for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->AddContour(contour,propagate); } @@ -132,7 +137,7 @@ void vvSlicerManager::AddContour(vvMesh::Pointer contour,bool propagate) //---------------------------------------------------------------------------- void vvSlicerManager::ToggleContourSuperposition() -{ //out << __func__ << endl; +{ for ( unsigned int i = 0; i < mSlicers.size(); i++) mSlicers[i]->ToggleContourSuperposition(); } @@ -140,7 +145,7 @@ void vvSlicerManager::ToggleContourSuperposition() //---------------------------------------------------------------------------- std::string vvSlicerManager::GetListOfAbsoluteFilePathInOneString(const std::string &actorType) -{ //out << __func__ << endl; +{ vvImageReader *reader = NULL; if(actorType=="image") @@ -171,7 +176,7 @@ std::string vvSlicerManager::GetListOfAbsoluteFilePathInOneString(const std::str //---------------------------------------------------------------------------- bool vvSlicerManager::SetImage(std::string filename, vvImageReader::LoadedImageType type, int n, unsigned int slice) -{ //out << __func__ << endl; +{ mType = type; if (mReader.IsNull()) mReader = vvImageReader::New(); @@ -206,7 +211,7 @@ bool vvSlicerManager::SetImage(std::string filename, vvImageReader::LoadedImageT //---------------------------------------------------------------------------- void vvSlicerManager::SetImage(vvImage::Pointer image) -{ //out << __func__ << endl; +{ mImage=image; for (unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->SetImage(image); @@ -217,7 +222,7 @@ void vvSlicerManager::SetImage(vvImage::Pointer image) //---------------------------------------------------------------------------- bool vvSlicerManager::SetImages(std::vector filenames, vvImageReader::LoadedImageType type, int n) -{ //out << __func__ << endl; +{ mType = type; std::string fileWithoutExtension = vtksys::SystemTools::GetFilenameWithoutExtension(filenames[0]); if (type == vvImageReader::DICOM) @@ -257,7 +262,7 @@ bool vvSlicerManager::SetImages(std::vector filenames, vvImageReade //---------------------------------------------------------------------------- bool vvSlicerManager::SetOverlay(std::vector filenames,int dim, std::string component, vvImageReader::LoadedImageType type) -{ //out << __func__ << endl; +{ mOverlayName = filenames[0]; mOverlayComponent = component; if (dim > mImage->GetNumberOfDimensions()) { @@ -283,7 +288,7 @@ bool vvSlicerManager::SetOverlay(std::vector filenames,int dim, std //---------------------------------------------------------------------------- bool vvSlicerManager::SetFusion(std::vector filenames,int dim, std::string component, vvImageReader::LoadedImageType type) -{ //out << __func__ << endl; +{ mFusionName = filenames[0]; mFusionComponent = component; if (dim > mImage->GetNumberOfDimensions()) { @@ -313,7 +318,7 @@ bool vvSlicerManager::SetFusion(std::vector filenames,int dim, std: //---------------------------------------------------------------------------- //this function is called by vvMainWindow::AddFusionSequence for the primary sequence (CT), while the given files constitute the secondary sequence. bool vvSlicerManager::SetFusionSequence(std::vector filenames, int dim, std::string component, vvImageReader::LoadedImageType type) -{ //out << __func__ << endl; +{ mFusionSequenceInvolvementCode = 0; mFusionName = filenames[0]; @@ -362,7 +367,7 @@ bool vvSlicerManager::SetFusionSequence(std::vector filenames, int //---------------------------------------------------------------------------- bool vvSlicerManager::SetVF(std::string filename) -{ //out << __func__ << endl; +{ if (mVectorReader.IsNull()) mVectorReader = vvImageReader::New(); mVectorReader->SetInputFilename(filename); @@ -382,7 +387,7 @@ bool vvSlicerManager::SetVF(std::string filename) //---------------------------------------------------------------------------- bool vvSlicerManager::SetVF(vvImage::Pointer vf,std::string filename) -{ //out << __func__ << endl; +{ if (vf->GetNumberOfDimensions() > mImage->GetNumberOfDimensions()) { mLastError = "Sorry, vector field dimension cannot be greater then reference image."; return false; @@ -409,7 +414,7 @@ bool vvSlicerManager::SetVF(vvImage::Pointer vf,std::string filename) //---------------------------------------------------------------------------- vvSlicer* vvSlicerManager::GetSlicer(int i) -{ //out << __func__ << endl; +{ return mSlicers[i]; } //---------------------------------------------------------------------------- @@ -417,7 +422,7 @@ vvSlicer* vvSlicerManager::GetSlicer(int i) //---------------------------------------------------------------------------- void vvSlicerManager::UpdateSlicer(int num, bool state) -{ //out << __func__ << endl; +{ if (mSlicers[num]->GetImage()) { mSlicers[num]->SetDisplayMode(state); } @@ -427,7 +432,7 @@ void vvSlicerManager::UpdateSlicer(int num, bool state) //---------------------------------------------------------------------------- void vvSlicerManager::SetSlicerWindow(int i, vtkRenderWindow* RW) -{ //out << __func__ << endl; +{ mSlicers[i]->SetRenderWindow(i,RW); } //---------------------------------------------------------------------------- @@ -435,7 +440,7 @@ void vvSlicerManager::SetSlicerWindow(int i, vtkRenderWindow* RW) //---------------------------------------------------------------------------- void vvSlicerManager::SetInteractorStyleNavigator(int i, vtkInteractorStyle* style) -{ //out << __func__ << endl; +{ vvSlicerManagerCommand *smc = vvSlicerManagerCommand::New(); smc->SM = this; smc->SetSlicerNumber(i); @@ -474,7 +479,7 @@ void vvSlicerManager::SetInteractorStyleNavigator(int i, vtkInteractorStyle* sty //---------------------------------------------------------------------------- void vvSlicerManager::LeftButtonReleaseEvent(int slicer) -{ //out << __func__ << endl; +{ emit LeftButtonReleaseSignal(slicer); } //---------------------------------------------------------------------------- @@ -482,7 +487,7 @@ void vvSlicerManager::LeftButtonReleaseEvent(int slicer) //---------------------------------------------------------------------------- void vvSlicerManager::EmitMousePositionUpdated(int slicer) -{ //out << __func__ << endl; +{ emit MousePositionUpdatedSignal(slicer); } //---------------------------------------------------------------------------- @@ -490,7 +495,7 @@ void vvSlicerManager::EmitMousePositionUpdated(int slicer) //---------------------------------------------------------------------------- void vvSlicerManager::EmitKeyPressed(std::string KeyPress) -{ //out << __func__ << endl; +{ emit KeyPressedSignal(KeyPress); } //---------------------------------------------------------------------------- @@ -498,7 +503,7 @@ void vvSlicerManager::EmitKeyPressed(std::string KeyPress) //---------------------------------------------------------------------------- void vvSlicerManager::SetSliceOrientation(int slicer, int orientation) -{ //out << __func__ << endl; +{ mSlicers[slicer]->SetSliceOrientation(orientation); emit UpdateOrientation(slicer, orientation); } @@ -506,14 +511,14 @@ void vvSlicerManager::SetSliceOrientation(int slicer, int orientation) //---------------------------------------------------------------------------- int vvSlicerManager::GetTSlice() -{ //out << __func__ << endl; +{ return mSlicers[0]->GetTSlice(); } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void vvSlicerManager::SetTSlice(int slice, bool updateLinkedImages) -{ //out << __func__ << endl; +{ if (!updateLinkedImages) { //for fusionSequence, TMax / MaxCurrentTSlice are irrelevant. for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->SetTSlice(slice, updateLinkedImages); @@ -540,7 +545,7 @@ void vvSlicerManager::SetTSlice(int slice, bool updateLinkedImages) //---------------------------------------------------------------------------- void vvSlicerManager::SetFusionSequenceTSlice(int slice) -{ //out << __func__ << endl; +{ for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->SetFusionSequenceTSlice(slice); UpdateTSlice(i); @@ -551,7 +556,7 @@ void vvSlicerManager::SetFusionSequenceTSlice(int slice) //---------------------------------------------------------------------------- void vvSlicerManager::SetNextTSlice(int originating_slicer) -{ //out << __func__ << endl; +{ int t = mSlicers[0]->GetMaxCurrentTSlice(); t++; if (t > mSlicers[0]->GetTMax()) @@ -563,7 +568,7 @@ void vvSlicerManager::SetNextTSlice(int originating_slicer) //---------------------------------------------------------------------------- void vvSlicerManager::SetPreviousTSlice(int originating_slicer) -{ //out << __func__ << endl; +{ int t = mSlicers[0]->GetMaxCurrentTSlice(); t--; if (t < 0) @@ -575,7 +580,7 @@ void vvSlicerManager::SetPreviousTSlice(int originating_slicer) //---------------------------------------------------------------------------- void vvSlicerManager::ToggleInterpolation() -{ //out << __func__ << endl; +{ bool interpolate=!(mSlicers[0]->GetImageActor()->GetInterpolate()); for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->GetImageActor()->SetInterpolate(interpolate); @@ -590,7 +595,7 @@ void vvSlicerManager::ToggleInterpolation() //---------------------------------------------------------------------------- void vvSlicerManager::SetTSliceInSlicer(int tslice, int slicer) -{ //out << __func__ << endl; +{ if (tslice < 0) tslice = 0; else if (tslice > mSlicers[slicer]->GetTMax()) @@ -616,7 +621,7 @@ void vvSlicerManager::SetTSliceInSlicer(int tslice, int slicer) //---------------------------------------------------------------------------- void vvSlicerManager::SetColorWindow(double s) -{ //out << __func__ << endl; +{ for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->SetColorWindow(s); } @@ -625,7 +630,7 @@ void vvSlicerManager::SetColorWindow(double s) //---------------------------------------------------------------------------- void vvSlicerManager::SetColorLevel(double s) -{ //out << __func__ << endl; +{ for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->SetColorLevel(s); } @@ -634,7 +639,7 @@ void vvSlicerManager::SetColorLevel(double s) //---------------------------------------------------------------------------- void vvSlicerManager::SetOverlayColorWindow(double s) -{ //out << __func__ << endl; +{ for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->SetOverlayColorWindow(s); } @@ -643,7 +648,7 @@ void vvSlicerManager::SetOverlayColorWindow(double s) //---------------------------------------------------------------------------- void vvSlicerManager::SetOverlayColorLevel(double s) -{ //out << __func__ << endl; +{ for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->SetOverlayColorLevel(s); } @@ -652,7 +657,7 @@ void vvSlicerManager::SetOverlayColorLevel(double s) //---------------------------------------------------------------------------- void vvSlicerManager::SetLinkOverlayWindowLevel(bool b) -{ //out << __func__ << endl; +{ for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->SetLinkOverlayWindowLevel(b); } @@ -661,7 +666,7 @@ void vvSlicerManager::SetLinkOverlayWindowLevel(bool b) //---------------------------------------------------------------------------- void vvSlicerManager::SetCursorAndCornerAnnotationVisibility(int s) -{ //out << __func__ << endl; +{ for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->SetCursorVisibility(s); mSlicers[i]->SetCornerAnnotationVisibility(s); @@ -671,7 +676,7 @@ void vvSlicerManager::SetCursorAndCornerAnnotationVisibility(int s) //---------------------------------------------------------------------------- void vvSlicerManager::SetOpacity(int i, double factor) -{ //out << __func__ << endl; +{ mSlicers[i]->SetOpacity(1/factor); } //---------------------------------------------------------------------------- @@ -679,7 +684,7 @@ void vvSlicerManager::SetOpacity(int i, double factor) //---------------------------------------------------------------------------- void vvSlicerManager::UpdateViews(int current,int slicer) -{ //out << __func__ << endl; +{ double p[3], pt[3]; p[0] = mSlicers[slicer]->GetCurrentPosition()[0]; p[1] = mSlicers[slicer]->GetCurrentPosition()[1]; @@ -698,67 +703,7 @@ void vvSlicerManager::UpdateViews(int current,int slicer) y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2]-0.5 && y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3]+0.5 && z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4]-0.5 && - z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) { - mSlicers[slicer]->UpdateCursorPosition(); - mSlicers[slicer]->SetCursorColor(10,212,255); - mSelectedSlicer = slicer; - - switch (mSlicers[slicer]->GetSliceOrientation()) { - case vtkImageViewer2::SLICE_ORIENTATION_XY: - if (mSlicers[slicer]->GetSlice() != (int)lrint(z)) - mSlicers[slicer]->SetSlice((int)lrint(z)); - break; - - case vtkImageViewer2::SLICE_ORIENTATION_XZ: - if (mSlicers[slicer]->GetSlice() != (int)lrint(y)) - mSlicers[slicer]->SetSlice((int)lrint(y)); - break; - - case vtkImageViewer2::SLICE_ORIENTATION_YZ: - if (mSlicers[slicer]->GetSlice() != (int)lrint(x)) - mSlicers[slicer]->SetSlice((int)lrint(x)); - break; - } - mSlicers[slicer]->Render(); - - for ( unsigned int i = 0; i < mSlicers.size(); i++) { - if (i != (unsigned int)slicer - && mSlicers[i]->GetRenderer()->GetDraw() - && mSlicers[i]->GetRenderWindow()->GetSize()[0] > 2 - && mSlicers[i]->GetRenderWindow()->GetSize()[1] > 2) { - mSlicers[i]->SetCurrentPosition(p[0], p[1], p[2], mSlicers[slicer]->GetMaxCurrentTSlice()); - mSlicers[i]->UpdateCursorPosition(); - if (current) { //do not display corner annotation if image is the one picked - mSlicers[i]->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX, - -VTK_DOUBLE_MAX, mSlicers[slicer]->GetMaxCurrentTSlice()); - mSlicers[i]->SetCursorColor(255,10,212); - } else { - mSlicers[i]->SetCursorColor(150,10,282); - } - switch (mSlicers[i]->GetSliceOrientation()) { - case vtkImageViewer2::SLICE_ORIENTATION_XY: - if (mSlicers[i]->GetSlice() != (int)lrint(z)) - mSlicers[i]->SetSlice((int)lrint(z)); - break; - - case vtkImageViewer2::SLICE_ORIENTATION_XZ: - if (mSlicers[i]->GetSlice() != (int)lrint(y)) - mSlicers[i]->SetSlice((int)lrint(y)); - break; - - case vtkImageViewer2::SLICE_ORIENTATION_YZ: - if (mSlicers[i]->GetSlice() != (int)lrint(x)) - mSlicers[i]->SetSlice((int)lrint(x)); - break; - } - - mSlicers[i]->Render(); - - UpdateSlice(i); - UpdateTSlice(i); - } - } - } + z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) #else int extentImageReslice[6]; mSlicers[slicer]->GetRegisterExtent(extentImageReslice); @@ -767,7 +712,9 @@ mSlicers[slicer]->GetRegisterExtent(extentImageReslice); y >= extentImageReslice[2]-0.5 && y <= extentImageReslice[3]+0.5 && z >= extentImageReslice[4]-0.5 && - z <= extentImageReslice[5]+0.5) { + z <= extentImageReslice[5]+0.5) +#endif + { mSlicers[slicer]->UpdateCursorPosition(); mSlicers[slicer]->SetCursorColor(10,212,255); mSelectedSlicer = slicer; @@ -828,14 +775,13 @@ mSlicers[slicer]->GetRegisterExtent(extentImageReslice); } } } -#endif } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void vvSlicerManager::UpdateLinked(int slicer) -{ //out << __func__ << endl; +{ double p[3], pt[3]; p[0] = mSlicers[slicer]->GetCurrentPosition()[0]; p[1] = mSlicers[slicer]->GetCurrentPosition()[1]; @@ -850,17 +796,7 @@ void vvSlicerManager::UpdateLinked(int slicer) y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2]-0.5 && y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3]+0.5 && z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4]-0.5 && - z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) { - for (std::list::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) { - if (this->IsInvolvedInFusionSequence()) { - //this SlicerManager is involved in fusionSequence => do not synchronize the times - emit UpdateLinkManager(*i, slicer, p[0], p[1], p[2], -1); - } - else { - emit UpdateLinkManager(*i, slicer, p[0], p[1], p[2], mSlicers[slicer]->GetMaxCurrentTSlice()); - } - } - } + z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) #else int extentImageReslice[6]; mSlicers[slicer]->GetRegisterExtent(extentImageReslice); @@ -869,7 +805,9 @@ mSlicers[slicer]->GetRegisterExtent(extentImageReslice); y >= extentImageReslice[2]-0.5 && y <= extentImageReslice[3]+0.5 && z >= extentImageReslice[4]-0.5 && - z <= extentImageReslice[5]+0.5) { + z <= extentImageReslice[5]+0.5) +#endif + { for (std::list::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) { if (this->IsInvolvedInFusionSequence()) { //this SlicerManager is involved in fusionSequence => do not synchronize the times @@ -880,13 +818,12 @@ mSlicers[slicer]->GetRegisterExtent(extentImageReslice); } } } -#endif } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagate) -{ //out << __func__ << endl; +{ vtkCamera *refCam = refSlicer->GetRenderer()->GetActiveCamera(); double refPosition[3]; @@ -929,7 +866,7 @@ void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagat //---------------------------------------------------------------------------- double vvSlicerManager::GetColorWindow() const -{ //out << __func__ << endl; +{ if (mSlicers.size()) return mSlicers[0]->GetColorWindow(); return -1; @@ -939,7 +876,7 @@ double vvSlicerManager::GetColorWindow() const //---------------------------------------------------------------------------- double vvSlicerManager::GetColorLevel() const -{ //out << __func__ << endl; +{ if (mSlicers.size()) return mSlicers[0]->GetColorLevel(); return -1; @@ -948,7 +885,7 @@ double vvSlicerManager::GetColorLevel() const //---------------------------------------------------------------------------- double vvSlicerManager::GetOverlayColorWindow() const -{ //out << __func__ << endl; +{ if (mSlicers.size()) return mSlicers[0]->GetOverlayColorWindow(); return -1; @@ -957,7 +894,7 @@ double vvSlicerManager::GetOverlayColorWindow() const //---------------------------------------------------------------------------- double vvSlicerManager::GetOverlayColorLevel() const -{ //out << __func__ << endl; +{ if (mSlicers.size()) return mSlicers[0]->GetOverlayColorLevel(); return -1; @@ -966,7 +903,7 @@ double vvSlicerManager::GetOverlayColorLevel() const //---------------------------------------------------------------------------- bool vvSlicerManager::GetLinkOverlayWindowLevel() const -{ //out << __func__ << endl; +{ if (mSlicers.size()) return mSlicers[0]->GetLinkOverlayWindowLevel(); return -1; @@ -975,7 +912,7 @@ bool vvSlicerManager::GetLinkOverlayWindowLevel() const //------------------------------------------------------------------------------ void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType) -{ //out << __func__ << endl; +{ if(actorType == "image") for(unsigned int i=0; iGetImage()->GetTransform().size(); i++) this->GetImage()->GetTransform()[i]->Identity(); @@ -1004,7 +941,7 @@ void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType) //---------------------------------------------------------------------------- void vvSlicerManager::Render() -{ //out << __func__ << endl; +{ for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->Render(); } @@ -1014,7 +951,7 @@ void vvSlicerManager::Render() //---------------------------------------------------------------------------- void vvSlicerManager::GenerateDefaultLookupTable() -{ //out << __func__ << endl; +{ SetPreset(mPreset); SetColorMap(mColorMap); } @@ -1023,7 +960,7 @@ void vvSlicerManager::GenerateDefaultLookupTable() //---------------------------------------------------------------------------- void vvSlicerManager::Reload() -{ //out << __func__ << endl; +{ mReader->Update(mType); mImage=mReader->GetOutput(); for ( unsigned int i = 0; i < mSlicers.size(); i++) { @@ -1040,7 +977,7 @@ void vvSlicerManager::Reload() //---------------------------------------------------------------------------- void vvSlicerManager::ReloadFusion() -{ //out << __func__ << endl; +{ mFusionReader->Update(mImage->GetNumberOfDimensions(),mFusionComponent.c_str(),mType); for ( unsigned int i = 0; i < mSlicers.size(); i++) { @@ -1053,7 +990,7 @@ void vvSlicerManager::ReloadFusion() //---------------------------------------------------------------------------- //the secondary sequence is being reloaded. void vvSlicerManager::ReloadFusionSequence() -{ //out << __func__ << endl; +{ // this is to keep the slice thickness, which needs to be artificially increased for visualization double sp_x, sp_y, sp_z; this->GetImage()->GetVTKImages()[0]->GetSpacing(sp_x, sp_y, sp_z); @@ -1090,7 +1027,7 @@ void vvSlicerManager::ReloadFusionSequence() //---------------------------------------------------------------------------- void vvSlicerManager::ReloadOverlay() -{ //out << __func__ << endl; +{ mOverlayReader->Update(mImage->GetNumberOfDimensions(),mOverlayComponent.c_str(),mType); for ( unsigned int i = 0; i < mSlicers.size(); i++) { mSlicers[i]->SetOverlay(mOverlayReader->GetOutput()); @@ -1102,7 +1039,7 @@ void vvSlicerManager::ReloadOverlay() //---------------------------------------------------------------------------- void vvSlicerManager::ReloadVF() -{ //out << __func__ << endl; +{ mVectorReader->Update(vvImageReader::VECTORFIELD); //deletes the old images through the VF::Init() function mVF=mVectorReader->GetOutput(); for ( unsigned int i = 0; i < mSlicers.size(); i++) { @@ -1115,7 +1052,7 @@ void vvSlicerManager::ReloadVF() //---------------------------------------------------------------------------- void vvSlicerManager::RemoveActor(const std::string& actor_type, int overlay_index) -{ //out << __func__ << endl; +{ if (actor_type =="overlay") mOverlayReader = NULL; @@ -1139,7 +1076,7 @@ void vvSlicerManager::RemoveActor(const std::string& actor_type, int overlay_ind //---------------------------------------------------------------------------- void vvSlicerManager::RemoveActors() -{ //out << __func__ << endl; +{ ///This method leaks a few objects. See RemoveActor for what a ///correct implementation would look like //DS -> probably due to the reader (now released in the @@ -1154,18 +1091,20 @@ void vvSlicerManager::RemoveActors() //---------------------------------------------------------------------------- void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer) -{ //out << __func__ << endl; +{ // int view = mSlicers[slicer]->GetSliceOrientation(); // int slice = mSlicers[slicer]->GetSlice(); - double x = mSlicers[slicer]->GetCursorPosition()[0]; - double y = mSlicers[slicer]->GetCursorPosition()[1]; - double z = mSlicers[slicer]->GetCursorPosition()[2]; - double X = (x - mSlicers[slicer]->GetInput()->GetOrigin()[0])/ - mSlicers[slicer]->GetInput()->GetSpacing()[0]; - double Y = (y - mSlicers[slicer]->GetInput()->GetOrigin()[1])/ - mSlicers[slicer]->GetInput()->GetSpacing()[1]; - double Z = (z - mSlicers[slicer]->GetInput()->GetOrigin()[2])/ - mSlicers[slicer]->GetInput()->GetSpacing()[2]; + double x = mSlicers[slicer]->GetCurrentPosition()[0]; + double y = mSlicers[slicer]->GetCurrentPosition()[1]; + double z = mSlicers[slicer]->GetCurrentPosition()[2]; + double xyz[3], xyzTransform[3]; + xyz[0] = x; + xyz[1] = y; + xyz[2] = z; + mSlicers[slicer]->GetSlicingTransform()->GetInverse()->TransformPoint(xyz, xyzTransform); + double X = (xyzTransform[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0])/mSlicers[slicer]->GetInput()->GetSpacing()[0]; + double Y = (xyzTransform[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1])/mSlicers[slicer]->GetInput()->GetSpacing()[1]; + double Z = (xyzTransform[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2])/mSlicers[slicer]->GetInput()->GetSpacing()[2]; double value = -VTK_DOUBLE_MAX; int displayVec = 0; double xVec=0, yVec=0, zVec=0, valueVec=0; @@ -1173,75 +1112,23 @@ void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer) int displayFus = 0; double valueOver=0, valueFus=0; #if VTK_MAJOR_VERSION <= 5 - if (X >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0] && - X <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1] && - Y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2] && - Y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] && - Z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] && - Z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) { - - value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z); - - if (mSlicers[slicer]->GetVFActor() ) { - displayVec = 1; - unsigned int currentTime = mSlicers[slicer]->GetMaxCurrentTSlice(); - vtkImageData *vf = NULL; - - if (mSlicers[slicer]->GetVF()->GetVTKImages().size() > currentTime) - vf = mSlicers[slicer]->GetVF()->GetVTKImages()[currentTime]; - else - vf = mSlicers[slicer]->GetVF()->GetVTKImages()[0]; - - if (vf) { - double Xvf = (x - vf->GetOrigin()[0])/ vf->GetSpacing()[0]; - double Yvf = (y - vf->GetOrigin()[1])/ vf->GetSpacing()[1]; - double Zvf = (z - vf->GetOrigin()[2])/ vf->GetSpacing()[2]; - xVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 0); - yVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 1); - zVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 2); - valueVec = sqrt(xVec*xVec + yVec*yVec + zVec*zVec); - } - } - if (mSlicers[slicer]->GetOverlayActor() ) { - displayOver = 1; - vtkImageData *overlay = dynamic_cast(mSlicers[slicer]->GetOverlayMapper()->GetInput()); - double Xover = (x - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0]; - double Yover = (y - overlay->GetOrigin()[1]) / overlay->GetSpacing()[1]; - double Zover = (z - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2]; - valueOver = this->GetScalarComponentAsDouble(overlay, Xover, Yover, Zover); - } - - if ( mSlicers[slicer]->GetFusionActor() ) { - displayFus = 1; - vtkImageData *fusion = dynamic_cast(mSlicers[slicer]->GetFusionMapper()->GetInput()); - double Xover = (x - fusion->GetOrigin()[0]) / fusion->GetSpacing()[0]; - double Yover = (y - fusion->GetOrigin()[1]) / fusion->GetSpacing()[1]; - double Zover = (z - fusion->GetOrigin()[2]) / fusion->GetSpacing()[2]; - valueFus = this->GetScalarComponentAsDouble(fusion, Xover, Yover, Zover); - } - else if (this->IsInvolvedInFusionSequence()) { - //if the cursor moves over the 'independent' version of the secondary sequence - //do not update the panel, just keep it as it is. - displayFus = 1; - valueFus = std::numeric_limits::quiet_NaN(); - } - - emit UpdatePosition(mSlicers[slicer]->GetCursorVisibility(), - x,y,z,X,Y,Z,value); - emit UpdateVector(displayVec,xVec, yVec, zVec, valueVec); - emit UpdateOverlay(displayOver,valueOver,value); - emit UpdateFusion(displayFus,valueFus); - } + if (X >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0] -0.5 && + X <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1] +0.5 && + Y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2] -0.5 && + Y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] +0.5 && + Z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] -0.5 && + Z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5] +0.5) #else int extentImageReslice[6]; mSlicers[slicer]->GetRegisterExtent(extentImageReslice); - if (X >= extentImageReslice[0] && - X <= extentImageReslice[1] && - Y >= extentImageReslice[2] && - Y <= extentImageReslice[3] && - Z >= extentImageReslice[4] && - Z <= extentImageReslice[5]) { - + if (X >= extentImageReslice[0] -0.5 && + X <= extentImageReslice[1] +0.5 && + Y >= extentImageReslice[2] -0.5 && + Y <= extentImageReslice[3] +0.5 && + Z >= extentImageReslice[4] -0.5 && + Z <= extentImageReslice[5] +0.5) +#endif + { value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z); if (mSlicers[slicer]->GetVFActor() ) { @@ -1294,14 +1181,13 @@ mSlicers[slicer]->GetRegisterExtent(extentImageReslice); emit UpdateOverlay(displayOver,valueOver,value); emit UpdateFusion(displayFus,valueFus); } -#endif } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void vvSlicerManager::Activated() -{ //out << __func__ << endl; +{ emit currentImageChanged(mId); } //---------------------------------------------------------------------------- @@ -1309,7 +1195,7 @@ void vvSlicerManager::Activated() //---------------------------------------------------------------------------- void vvSlicerManager::Picked() -{ //out << __func__ << endl; +{ emit currentPickedImageChanged(mId); } //---------------------------------------------------------------------------- @@ -1317,7 +1203,7 @@ void vvSlicerManager::Picked() //---------------------------------------------------------------------------- void vvSlicerManager::UpdateWindowLevel() -{ //out << __func__ << endl; +{ emit WindowLevelChanged(); } //---------------------------------------------------------------------------- @@ -1325,7 +1211,7 @@ void vvSlicerManager::UpdateWindowLevel() //---------------------------------------------------------------------------- void vvSlicerManager::UpdateSlice(int slicer) -{ //out << __func__ << endl; +{ if (mPreviousSlice[slicer] == mSlicers[slicer]->GetSlice()) { //DD("============= NOTHING"); return; @@ -1339,7 +1225,7 @@ void vvSlicerManager::UpdateSlice(int slicer) //---------------------------------------------------------------------------- void vvSlicerManager::UpdateTSlice(int slicer) -{ //out << __func__ << endl; +{ int slice = mSlicers[slicer]->GetSlice(); int tslice = mSlicers[slicer]->GetMaxCurrentTSlice(); @@ -1361,7 +1247,7 @@ void vvSlicerManager::UpdateTSlice(int slicer) //---------------------------------------------------------------------------- void vvSlicerManager::UpdateSliceRange(int slicer) -{ //out << __func__ << endl; +{ emit UpdateSliceRange(slicer, mSlicers[slicer]->GetSliceRange()[0], mSlicers[slicer]->GetSliceRange()[1], 0,mSlicers[slicer]->GetTMax()); @@ -1370,7 +1256,7 @@ void vvSlicerManager::UpdateSliceRange(int slicer) //---------------------------------------------------------------------------- void vvSlicerManager::SetSlicingPreset(SlicingPresetType preset) -{ //out << __func__ << endl; +{ if(mSlicingPreset==preset) return; @@ -1413,7 +1299,7 @@ void vvSlicerManager::SetSlicingPreset(SlicingPresetType preset) //---------------------------------------------------------------------------- void vvSlicerManager::SetPreset(int preset) -{ //out << __func__ << endl; +{ //vtkLookupTable* LUT = static_cast(mSlicers[0]->GetWindowLevel()->GetLookupTable()); double window = mSlicers[0]->GetColorWindow(); @@ -1472,7 +1358,7 @@ void vvSlicerManager::SetPreset(int preset) //---------------------------------------------------------------------------- void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlKey) -{ //out << __func__ << endl; +{ double min, max; if(bCtrlKey && this->mSlicers[slicer]->GetFusion()) { int t = mSlicers[slicer]->GetFusionTSlice(); @@ -1513,7 +1399,7 @@ void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlK //---------------------------------------------------------------------------- void vvSlicerManager::SetColorMap(int colormap) -{ //out << __func__ << endl; +{ double range[2]; range[0] = mSlicers[0]->GetInput()->GetScalarRange()[0]; @@ -1667,7 +1553,7 @@ void vvSlicerManager::SetColorMap(int colormap) //---------------------------------------------------------------------------- vvLandmarks* vvSlicerManager::GetLandmarks() -{ //out << __func__ << endl; +{ if (mLandmarks == NULL) { mLandmarks = new vvLandmarks(mSlicers[0]->GetTMax()+1); for (unsigned int i = 0; i < mSlicers.size(); i++) @@ -1676,11 +1562,14 @@ vvLandmarks* vvSlicerManager::GetLandmarks() return mLandmarks; } //---------------------------------------------------------------------------- - +void vvSlicerManager::AddNewLandmark(float x,float y,float z,float t) +{ + emit callAddLandmark(x,y,z,t); +} //---------------------------------------------------------------------------- void vvSlicerManager::AddLandmark(float x,float y,float z,float t) -{ //out << __func__ << endl; +{ double x_index = (x - mSlicers[0]->GetInput()->GetOrigin()[0])/mSlicers[0]->GetInput()->GetSpacing()[0]; double y_index = (y - mSlicers[0]->GetInput()->GetOrigin()[1])/mSlicers[0]->GetInput()->GetSpacing()[1]; double z_index = (z - mSlicers[0]->GetInput()->GetOrigin()[2])/mSlicers[0]->GetInput()->GetSpacing()[2]; @@ -1690,11 +1579,38 @@ void vvSlicerManager::AddLandmark(float x,float y,float z,float t) y_index >= mSlicers[0]->GetInput()->GetWholeExtent()[2]-0.5 && y_index <= mSlicers[0]->GetInput()->GetWholeExtent()[3]+0.5 && z_index >= mSlicers[0]->GetInput()->GetWholeExtent()[4]-0.5 && - z_index <= mSlicers[0]->GetInput()->GetWholeExtent()[5]+0.5) { - double value = this->GetScalarComponentAsDouble(mSlicers[0]->GetInput(), x_index, y_index, z_index); + z_index <= mSlicers[0]->GetInput()->GetWholeExtent()[5]+0.5) +#else + int extentImageReslice[6]; + mSlicers[0]->GetRegisterExtent(extentImageReslice); + if (x_index >= extentImageReslice[0]-0.5 && + x_index <= extentImageReslice[1]+0.5 && + y_index >= extentImageReslice[2]-0.5 && + y_index <= extentImageReslice[3]+0.5 && + z_index >= extentImageReslice[4]-0.5 && + z_index <= extentImageReslice[5]+0.5) +#endif + { + double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetInput(), x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848 this->GetLandmarks()->AddLandmark(x,y,z,t,value); emit LandmarkAdded(); } +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +void vvSlicerManager::AddLandmarkProfile(float x,float y,float z,float t) +{ + double x_index = (x - mSlicers[0]->GetInput()->GetOrigin()[0])/mSlicers[0]->GetInput()->GetSpacing()[0]; + double y_index = (y - mSlicers[0]->GetInput()->GetOrigin()[1])/mSlicers[0]->GetInput()->GetSpacing()[1]; + double z_index = (z - mSlicers[0]->GetInput()->GetOrigin()[2])/mSlicers[0]->GetInput()->GetSpacing()[2]; +#if VTK_MAJOR_VERSION <= 5 + if (x_index >= mSlicers[0]->GetInput()->GetWholeExtent()[0]-0.5 && + x_index <= mSlicers[0]->GetInput()->GetWholeExtent()[1]+0.5 && + y_index >= mSlicers[0]->GetInput()->GetWholeExtent()[2]-0.5 && + y_index <= mSlicers[0]->GetInput()->GetWholeExtent()[3]+0.5 && + z_index >= mSlicers[0]->GetInput()->GetWholeExtent()[4]-0.5 && + z_index <= mSlicers[0]->GetInput()->GetWholeExtent()[5]+0.5) #else int extentImageReslice[6]; mSlicers[0]->GetRegisterExtent(extentImageReslice); @@ -1703,32 +1619,32 @@ void vvSlicerManager::AddLandmark(float x,float y,float z,float t) y_index >= extentImageReslice[2]-0.5 && y_index <= extentImageReslice[3]+0.5 && z_index >= extentImageReslice[4]-0.5 && - z_index <= extentImageReslice[5]+0.5) { - double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mSlicers[0]->GetTSlice()], x_index, y_index, z_index); + z_index <= extentImageReslice[5]+0.5) +#endif + { + double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetInput(), x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848 this->GetLandmarks()->AddLandmark(x,y,z,t,value); - emit LandmarkAdded(); } -#endif } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void vvSlicerManager::PrevImage(int slicer) -{ //out << __func__ << endl; +{ emit ChangeImageWithIndexOffset(this, slicer, -1); } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void vvSlicerManager::NextImage(int slicer) -{ //out << __func__ << endl; +{ emit ChangeImageWithIndexOffset(this, slicer, 1); } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void vvSlicerManager::VerticalSliderHasChanged(int slicer, int slice) -{ //out << __func__ << endl; +{ emit AVerticalSliderHasChanged(slicer, slice); } @@ -1736,7 +1652,7 @@ void vvSlicerManager::VerticalSliderHasChanged(int slicer, int slice) //---------------------------------------------------------------------------- double vvSlicerManager::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component) -{ //out << __func__ << endl; +{ int ix, iy, iz; return mSlicers[0]->GetScalarComponentAsDouble(image, X, Y, Z, ix, iy, iz, component); }