From: BenoƮt Presles Date: Fri, 10 Aug 2012 16:13:00 +0000 (+0200) Subject: Merge /home/srit/src/clitk/clitk X-Git-Tag: v1.4.0~281^2~15^2~4 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9c3459c14912a6e59482407d40a7b626143ebc46;hp=e4df7fea16df0710b014c7fd206086e5fdce0aa8;p=clitk.git Merge /home/srit/src/clitk/clitk --- diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 769ca63..9eb3652 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -38,7 +38,7 @@ #if defined(unix) || defined(__APPLE__) # include # include -#elif defined(WIN32) +#elif defined(_WIN32) # include #endif diff --git a/common/clitkDD.h b/common/clitkDD.h index c21bb81..97ba443 100644 --- a/common/clitkDD.h +++ b/common/clitkDD.h @@ -19,12 +19,12 @@ #define clitkDD_h #include -#ifdef WIN32 +#ifdef _WIN32 # include #endif // David's debug -#ifdef WIN32 +#ifdef _WIN32 # define DD(a) { \ std::ostringstream ossDD; \ ossDD << #a " = [ " << a << " ]" << std::endl; \ diff --git a/common/clitkPortability.h b/common/clitkPortability.h index 7fae01e..3671066 100644 --- a/common/clitkPortability.h +++ b/common/clitkPortability.h @@ -17,12 +17,12 @@ ===========================================================================**/ #ifndef CLITKPORTABILITY_H #define CLITKPORTABILITY_H -#if defined(WIN32) +#if defined(_WIN32) # define _USE_MATH_DEFINES //Before math.h include (i.e. cmath) #endif #include -#if defined(WIN32) +#if defined(_WIN32) # define rint(x) floor(x+0.5) # define lrint(x) (long)rint(x) #endif diff --git a/common/clitkTimer.cxx b/common/clitkTimer.cxx index f01d77c..cd74428 100644 --- a/common/clitkTimer.cxx +++ b/common/clitkTimer.cxx @@ -37,7 +37,7 @@ clitk::Timer::Timer() { Reset(); -#if defined(WIN32) +#if defined(_WIN32) QueryPerformanceFrequency((LARGE_INTEGER*)&mFrequency); #endif } @@ -48,7 +48,7 @@ void clitk::Timer::Start() { #if defined(unix) || defined(__APPLE__) getrusage(RUSAGE_SELF, &mBegin); -#elif defined(WIN32) +#elif defined(_WIN32) QueryPerformanceCounter((LARGE_INTEGER*)&mBegin); #endif mNumberOfCall++; @@ -64,7 +64,7 @@ void clitk::Timer::Stop(bool accumulate) mElapsed += (mEnd.ru_utime.tv_usec - mBegin.ru_utime.tv_usec)+ (mEnd.ru_utime.tv_sec - mBegin.ru_utime.tv_sec)*1000000; } -#elif defined(WIN32) +#elif defined(_WIN32) QueryPerformanceCounter((LARGE_INTEGER*)&mEnd); if (accumulate) { mElapsed += ((mEnd-mBegin)*1000000)/(long double)mFrequency; diff --git a/common/clitkTimer.h b/common/clitkTimer.h index 0021fa7..725a3b2 100644 --- a/common/clitkTimer.h +++ b/common/clitkTimer.h @@ -23,7 +23,7 @@ #if defined(unix) || defined(__APPLE__) # include # include -#elif defined(WIN32) +#elif defined(_WIN32) # include #endif #include @@ -53,7 +53,7 @@ namespace clitk { #if defined(unix) || defined(__APPLE__) rusage mBegin; rusage mEnd; -#elif defined(WIN32) +#elif defined(_WIN32) unsigned __int64 mBegin; unsigned __int64 mEnd; unsigned __int64 mFrequency; diff --git a/common/clitkXdrImageIOWriter.cxx b/common/clitkXdrImageIOWriter.cxx index af50b0e..fc75976 100644 --- a/common/clitkXdrImageIOWriter.cxx +++ b/common/clitkXdrImageIOWriter.cxx @@ -108,7 +108,7 @@ void clitk::XdrImageIO::Write(const void* buffer) #include -#ifdef WIN32 +#ifdef _WIN32 // don't use min() and max() macros indirectly defined by windows.h, // but use portable std::min() and std:max() instead #ifndef NOMINMAX @@ -256,7 +256,7 @@ static int wxdr_write(int handle, const void * buf, unsigned len) { // if (handle == 1) // stdout if (handle == fileno(stdout)) { -#ifdef WIN32 +#ifdef _WIN32 // Behave as C standard library write(): return number of bytes // written or -1 and errno set on error. fflush(stdout); @@ -837,6 +837,12 @@ void clitk::XdrImageIO::WriteImage(const char* file, char* headerinfo, char* hea char *buf2; size_t slen; +#ifdef _WIN32 + int oldFMode; + _get_fmode(&oldFMode); + _set_fmode(O_BINARY); /* default binary i/o */ +#endif + if (bLittleEndian) swap_test = 0x00000001; @@ -1203,5 +1209,10 @@ WRITE_COORDS: if (f != fileno(stdout)) close(f); if (getsize) return; + +#ifdef _WIN32 + _set_fmode(oldFMode ? oldFMode : _O_TEXT); /* restore default binary i/o */ +#endif + return AVS_OK; } diff --git a/common/vvImage.cxx b/common/vvImage.cxx index 0bddb26..31c6ef0 100644 --- a/common/vvImage.cxx +++ b/common/vvImage.cxx @@ -32,7 +32,7 @@ #include //-------------------------------------------------------------------- -vvImage::vvImage():mTransform(vtkSmartPointer::New()) +vvImage::vvImage() { Init(); } @@ -251,7 +251,7 @@ bool vvImage::IsScalarTypeInteger(int t) //-------------------------------------------------------------------- //-------------------------------------------------------------------- -vtkSmartPointer vvImage::GetTransform() +const std::vector< vtkSmartPointer >& vvImage::GetTransform() { return this->mTransform; } diff --git a/common/vvImage.h b/common/vvImage.h index ec01a1f..a120457 100644 --- a/common/vvImage.h +++ b/common/vvImage.h @@ -56,7 +56,7 @@ public : bool IsTimeSequence() const; bool IsScalarTypeInteger(); bool IsScalarTypeInteger(int t); - vtkSmartPointer GetTransform(); + const std::vector< vtkSmartPointer >& GetTransform(); void SetTimeSpacing(double s) { mTimeSpacing = s; } void SetTimeOrigin(double o) { mTimeOrigin = o; } bool HaveSameSizeAndSpacingThan(vvImage * other); @@ -66,8 +66,8 @@ private: ~vvImage(); std::vector< ConverterPointer > mItkToVtkConverters; - std::vector mVtkImages; - vtkSmartPointer mTransform; + std::vector< vtkImageData* > mVtkImages; + std::vector< vtkSmartPointer > mTransform; double mTimeOrigin; double mTimeSpacing; diff --git a/common/vvImage.txx b/common/vvImage.txx index 14da10a..55b785f 100644 --- a/common/vvImage.txx +++ b/common/vvImage.txx @@ -50,7 +50,8 @@ void vvImage::AddItkImage(TItkImageType *input) // GetDirection provides the forward transform, vtkImageReslice wants the inverse matrix->Invert(); - mTransform->SetMatrix(matrix); + mTransform.push_back(vtkSmartPointer::New()); + mTransform.back()->SetMatrix(matrix); } //-------------------------------------------------------------------- diff --git a/common/vvImageReader.cxx b/common/vvImageReader.cxx index 0205355..c795cd9 100644 --- a/common/vvImageReader.cxx +++ b/common/vvImageReader.cxx @@ -110,37 +110,37 @@ void vvImageReader::SetInputFilenames(const std::vector & filenames //------------------------------------------------------------------------------ //Read transformation in NKI format (Xdr, transposed, cm) -void vvImageReader::ReadNkiImageTransform() -{ - bool bRead=false; - std::string filename = mInputFilenames[0]+".MACHINEORIENTATION"; - if(itksys::SystemTools::FileExists(filename.c_str())){ - typedef itk::ImageFileReader< itk::Image< double, 2 > > MatrixReaderType; - MatrixReaderType::Pointer readerTransfo = MatrixReaderType::New(); - readerTransfo->SetFileName(filename); - try { - bRead = true; - readerTransfo->Update(); - } catch( itk::ExceptionObject & err ) { - bRead=false; - std::cerr << "Cannot read " << filename << std::endl - << "The error is: " << err << std::endl; - } - - if (bRead) { - //Transpose matrix (NKI format) - for(int j=0; j<4; j++) - for(int i=0; i<4; i++) - mImage->GetTransform()->GetMatrix()->SetElement(j,i,readerTransfo->GetOutput()->GetBufferPointer()[4*i+j]); - - //From cm to mm - for(int i=0; i<3; i++) - mImage->GetTransform()->GetMatrix()->SetElement(i,3,10*mImage->GetTransform()->GetMatrix()->GetElement(i,3)); - - mImage->GetTransform()->Inverse(); - } - } -} +//void vvImageReader::ReadNkiImageTransform() +//{ +// bool bRead=false; +// std::string filename = mInputFilenames[0]+".MACHINEORIENTATION"; +// if(itksys::SystemTools::FileExists(filename.c_str())){ +// typedef itk::ImageFileReader< itk::Image< double, 2 > > MatrixReaderType; +// MatrixReaderType::Pointer readerTransfo = MatrixReaderType::New(); +// readerTransfo->SetFileName(filename); +// try { +// bRead = true; +// readerTransfo->Update(); +// } catch( itk::ExceptionObject & err ) { +// bRead=false; +// std::cerr << "Cannot read " << filename << std::endl +// << "The error is: " << err << std::endl; +// } + +// if (bRead) { +// //Transpose matrix (NKI format) +// for(int j=0; j<4; j++) +// for(int i=0; i<4; i++) +// mImage->GetTransform()->GetMatrix()->SetElement(j,i,readerTransfo->GetOutput()->GetBufferPointer()[4*i+j]); + +// //From cm to mm +// for(int i=0; i<3; i++) +// mImage->GetTransform()->GetMatrix()->SetElement(i,3,10*mImage->GetTransform()->GetMatrix()->GetElement(i,3)); + +// mImage->GetTransform()->Inverse(); +// } +// } +//} //------------------------------------------------------------------------------ @@ -192,9 +192,10 @@ void vvImageReader::ReadMatImageTransform() vtkGenericWarningMacro("Matrix in " << filename.c_str() << " cannot be inverted (determinant = 0)"); } - mImage->GetTransform()->PostMultiply(); - mImage->GetTransform()->Concatenate(matrix); - mImage->GetTransform()->Update(); + // TODO SR and BP: check on the list of transforms and not the first only + mImage->GetTransform()[0]->PostMultiply(); + mImage->GetTransform()[0]->Concatenate(matrix); + mImage->GetTransform()[0]->Update(); } } //------------------------------------------------------------------------------ diff --git a/common/vvImageReader.h b/common/vvImageReader.h index dae05e4..4348e0f 100644 --- a/common/vvImageReader.h +++ b/common/vvImageReader.h @@ -92,7 +92,7 @@ protected: std::string mInputPixelType; //==================================================================== - void ReadNkiImageTransform(); +// void ReadNkiImageTransform(); void ReadMatImageTransform(); private: vvImageReader(); diff --git a/common/vvImageReader.txx b/common/vvImageReader.txx index 6a4333f..9b0e21a 100644 --- a/common/vvImageReader.txx +++ b/common/vvImageReader.txx @@ -187,12 +187,13 @@ void vvImageReader::UpdateWithDimAndInputPixelType() 0.,0.,1.,0., 0.,-1.,0.,0., 0.,0.,0.,1.}; + // TODO SR and BP: check on the list of transforms and not the first only int i; - for(i=0; i<16 && m[i]==mImage->GetTransform()->GetMatrix()->GetElement(i%4, i/4); i++); + for(i=0; i<16 && m[i]==mImage->GetTransform()[0]->GetMatrix()->GetElement(i%4, i/4); i++); if(i==16) { itkWarningMacro(<< "Analyze image file format detected with unknown orientation. " << "Forcing identity orientation, use other file format if not ok."); - mImage->GetTransform()->Identity(); + mImage->GetTransform()[0]->Identity(); } } } @@ -259,13 +260,13 @@ void vvImageReader::UpdateWithDimAndInputVectorPixelType() 0.,-1.,0.,0., 0.,0.,0.,1.}; int i; - for (i = 0; i < 16 && m[i] == mImage->GetTransform()->GetMatrix()->GetElement(i % 4, i / 4); i++) + for (i = 0; i < 16 && m[i] == mImage->GetTransform()[0]->GetMatrix()->GetElement(i % 4, i / 4); i++) ; if (i == 16) { itkWarningMacro(<< "Analyze image file format detected with unknown orientation. " << "Forcing identity orientation, use other file format if not ok."); - mImage->GetTransform()->Identity(); + mImage->GetTransform()[0]->Identity(); } } } diff --git a/common/vvImageWriter.txx b/common/vvImageWriter.txx index 0640f0c..0705197 100644 --- a/common/vvImageWriter.txx +++ b/common/vvImageWriter.txx @@ -73,7 +73,8 @@ void vvImageWriter::UpdateWithDimAndOutputPixelType() itk::Matrix trans; for(int i=0; i<4; i++) for(int j=0; j<4; j++) - trans[i][j] = mImage->GetTransform()->GetMatrix()->GetElement(i,j); + // TODO SR and BP: check on the list of transforms and not the first only + trans[i][j] = mImage->GetTransform()[0]->GetMatrix()->GetElement(i,j); trans = trans.GetInverse(); // Direction diff --git a/vv/qt_ui/vvMainWindow.ui b/vv/qt_ui/vvMainWindow.ui index 789e59f..8d3d8ff 100644 --- a/vv/qt_ui/vvMainWindow.ui +++ b/vv/qt_ui/vvMainWindow.ui @@ -67,19 +67,6 @@ 2 - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -330,7 +317,7 @@ - + @@ -356,13 +343,6 @@ - - - - Qt::Vertical - - - @@ -402,6 +382,40 @@ + + + + + World + + + + + Voxels + + + + + + + + Slice to + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -791,7 +805,7 @@ 0 0 1008 - 22 + 25 diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 9fc078c..4e70cd4 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -309,10 +309,10 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(levelSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited())); connect(colorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateColorMap())); connect(presetComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateWindowLevel())); + connect(slicingPresetComboBox, SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateSlicingPreset())); connect(inverseButton,SIGNAL(clicked()),this,SLOT(SwitchWindowLevel())); connect(applyWindowLevelToAllButton,SIGNAL(clicked()),this,SLOT(ApplyWindowLevelToAllImages())); - connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(ShowContextMenu(QPoint))); connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString))); @@ -952,6 +952,8 @@ void vvMainWindow::LoadImages(std::vector files, vvImageReader::Loa this,SLOT(UpdateSlice(int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), this,SLOT(UpdateTSlice(int, int))); + connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), + this,SLOT(ImageInfoChanged())); 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)), @@ -1139,7 +1141,7 @@ void vvMainWindow::ImageInfoChanged() infoPanel->setOrigin(GetVectorDoubleAsString(origin)); infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing)); infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")"); - transformation = imageSelected->GetTransform()->GetMatrix(); + transformation = imageSelected->GetTransform()[mSlicerManagers[index]->GetTSlice()]->GetMatrix(); infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation)); landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(), @@ -1176,6 +1178,7 @@ void vvMainWindow::ImageInfoChanged() } } WindowLevelChanged(); + slicingPresetComboBox->setCurrentIndex(mSlicerManagers[index]->GetSlicingPreset()); if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) { overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str()); @@ -1721,6 +1724,16 @@ void vvMainWindow::UpdateWindowLevel() } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvMainWindow::UpdateSlicingPreset() +{ + if (DataTree->selectedItems().size()) { + int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); + mSlicerManagers[index]->SetSlicingPreset(vvSlicerManager::SlicingPresetType(slicingPresetComboBox->currentIndex())); + } +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::UpdateColorMap() { @@ -2308,7 +2321,8 @@ void vvMainWindow::SaveAs() bool bId = true; for(int i=0; i<4; i++) for(int j=0; j<4; j++) { - double elt = mSlicerManagers[index]->GetImage()->GetTransform()->GetMatrix()->GetElement(i,j); + // TODO SR and BP: check on the list of transforms and not the first only + double elt = mSlicerManagers[index]->GetImage()->GetTransform()[0]->GetMatrix()->GetElement(i,j); if(i==j && elt!=1.) bId = false; if(i!=j && elt!=0.) @@ -3079,6 +3093,8 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen this,SLOT(UpdateSlice(int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), this,SLOT(UpdateTSlice(int, int))); + connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), + this,SLOT(ImageInfoChanged())); 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)), diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index bbdfe26..c77a59a 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -118,6 +118,7 @@ public slots: void SetWindowLevel(double w, double l); void UpdateColorMap(); void UpdateWindowLevel(); + void UpdateSlicingPreset(); void SwitchWindowLevel(); void ApplyWindowLevelToAllImages(); void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps); diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 1e133d6..2a5c924 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -145,6 +145,9 @@ vvSlicer::vvSlicer() #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10) this->GetImageActor()->GetMapper()->BorderOn(); #endif + + mSlicingTransform = vtkSmartPointer::New(); + mConcatenatedTransform = vtkSmartPointer::New(); } //------------------------------------------------------------------------------ @@ -290,13 +293,20 @@ vvSlicer::~vvSlicer() } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +double* vvSlicer::GetCurrentPosition() +{ + return mCurrentBeforeSlicingTransform; +} +//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvSlicer::SetCurrentPosition(double x, double y, double z, int t) { - mCurrent[0] = x; - mCurrent[1] = y; - mCurrent[2] = z; + mCurrentBeforeSlicingTransform[0]=x; + mCurrentBeforeSlicingTransform[1]=y; + mCurrentBeforeSlicingTransform[2]=z; + mSlicingTransform->GetInverse()->TransformPoint(mCurrentBeforeSlicingTransform,mCurrent); mCurrentTSlice = t; } //------------------------------------------------------------------------------ @@ -314,7 +324,11 @@ void vvSlicer::SetImage(vvImage::Pointer image) mImageReslice->AutoCropOutputOn(); mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1); } - mImageReslice->SetResliceTransform(mImage->GetTransform()); + + mConcatenatedTransform->Identity(); + mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]); + mConcatenatedTransform->Concatenate(mSlicingTransform); + mImageReslice->SetResliceTransform(mConcatenatedTransform); mImageReslice->SetInput(0, mImage->GetFirstVTKImageData()); mImageReslice->UpdateInformation(); @@ -355,7 +369,7 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay) mOverlayReslice->AutoCropOutputOn(); mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1); } - mOverlayReslice->SetResliceTransform(mOverlay->GetTransform()); + mOverlayReslice->SetResliceTransform(mOverlay->GetTransform()[0]); mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData()); if (!mOverlayMapper) @@ -402,7 +416,7 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion) mFusionReslice->AutoCropOutputOn(); mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1); } - mFusionReslice->SetResliceTransform(mFusion->GetTransform()); + mFusionReslice->SetResliceTransform(mFusion->GetTransform()[0]); mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData()); if (!mFusionMapper) @@ -684,6 +698,12 @@ void vvSlicer::SetTSlice(int t) else if ((unsigned int)t >= mImage->GetVTKImages().size()) t = mImage->GetVTKImages().size() -1; + // Update transform + mConcatenatedTransform->Identity(); + mConcatenatedTransform->Concatenate(mImage->GetTransform()[t]); + mConcatenatedTransform->Concatenate(mSlicingTransform); + + // Update image data mCurrentTSlice = t; mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] ); if (mVF && mVFActor->GetVisibility()) { @@ -920,9 +940,8 @@ void vvSlicer::UpdateDisplayExtent() double cpos = (double)cam->GetPosition()[this->SliceOrientation]; double range = fabs(spos - cpos); double *spacing = input->GetSpacing(); - double avg_spacing = - ((double)spacing[0] + (double)spacing[1] + (double)spacing[2]) / 3.0; - cam->SetClippingRange(range - avg_spacing * 3.0, range + avg_spacing * 3.0); + double sumSpacing = spacing[0] + spacing[1] + spacing[2]; + cam->SetClippingRange(range - sumSpacing, range + sumSpacing); } } } @@ -1272,34 +1291,29 @@ void vvSlicer::Render() if (ca->GetVisibility()) { std::stringstream worldPos; - double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0]; - double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1]; - double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2]; - -// if (X < this->GetInput()->GetWholeExtent()[0]) X = this->GetInput()->GetWholeExtent()[0]; -// else if (X > this->GetInput()->GetWholeExtent()[1]) X = this->GetInput()->GetWholeExtent()[1]; -// if (Y < this->GetInput()->GetWholeExtent()[2]) Y = this->GetInput()->GetWholeExtent()[2]; -// else if (Y > this->GetInput()->GetWholeExtent()[3]) Y = this->GetInput()->GetWholeExtent()[3]; -// if (Z < this->GetInput()->GetWholeExtent()[4]) Z = this->GetInput()->GetWholeExtent()[4]; -// else if (Z > this->GetInput()->GetWholeExtent()[5]) Z = this->GetInput()->GetWholeExtent()[5]; - - if (X >= this->GetInput()->GetWholeExtent()[0] && - X <= this->GetInput()->GetWholeExtent()[1] && - Y >= this->GetInput()->GetWholeExtent()[2] && - Y <= this->GetInput()->GetWholeExtent()[3] && - Z >= this->GetInput()->GetWholeExtent()[4] && - Z <= this->GetInput()->GetWholeExtent()[5]) { + double pt[3]; + mConcatenatedTransform->TransformPoint(mCurrent, pt); + double X = (pt[0] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[0])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[0]; + double Y = (pt[1] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[1])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[1]; + double Z = (pt[2] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[2])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[2]; + + if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[0]-0.5 && + X <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[1]+0.5 && + Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[2]-0.5 && + Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[3]+0.5 && + Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[4]-0.5 && + Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[5]+0.5) { int ix, iy, iz; - double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz); + double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz); if(ImageActor->GetVisibility()) worldPos << "data value : " << value << std::endl; - worldPos << "mm : " << lrint(mCurrent[0]) << ' ' - << lrint(mCurrent[1]) << ' ' - << lrint(mCurrent[2]) << ' ' + worldPos << "mm : " << lrint(mCurrentBeforeSlicingTransform[0]) << ' ' + << lrint(mCurrentBeforeSlicingTransform[1]) << ' ' + << lrint(mCurrentBeforeSlicingTransform[2]) << ' ' << mCurrentTSlice << std::endl; worldPos << "pixel : " << ix << ' ' diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index c09001d..44e1a2c 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -140,10 +140,11 @@ public: return mCursor; } + vtkTransform * GetSlicingTransform() { return mSlicingTransform; } + vtkTransform * GetConcatenatedTransform() { return mConcatenatedTransform; } + void SetCurrentPosition(double x, double y, double z, int t); - double* GetCurrentPosition() { - return mCurrent; - } + double* GetCurrentPosition(); void UpdateCursorPosition(); void SetCursorVisibility(bool s); @@ -207,6 +208,8 @@ protected: vvLandmarks* mLandmarks; vtkSmartPointer mImageReslice; + vtkSmartPointer mSlicingTransform; + vtkSmartPointer mConcatenatedTransform; vtkSmartPointer mOverlayReslice; vtkSmartPointer mOverlayMapper; vtkSmartPointer mOverlayActor; @@ -235,6 +238,7 @@ protected: int mCurrentTSlice; double mCurrent[3]; + double mCurrentBeforeSlicingTransform[3]; double mCursor[4]; int mSubSampling; int mScale; diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index c86928f..ee1c084 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -72,6 +72,7 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers) mPreviousSlice.resize(numberOfSlicers); mPreviousTSlice.resize(numberOfSlicers); + mSlicingPreset = WORLD_SLICING; } //---------------------------------------------------------------------------- @@ -426,6 +427,13 @@ void vvSlicerManager::SetSliceOrientation(int slicer, int orientation) } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +int vvSlicerManager::GetTSlice() +{ + return mSlicers[0]->GetTSlice(); +} +//---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- void vvSlicerManager::SetTSlice(int slice) { @@ -438,7 +446,7 @@ void vvSlicerManager::SetTSlice(int slice) for ( unsigned int i = 0; i < mSlicers.size(); i++) { if (slice != mSlicers[i]->GetTSlice()) { mSlicers[i]->SetTSlice(slice); - UpdateTSlice(i); + UpdateTSlice(i); } } } @@ -498,6 +506,13 @@ void vvSlicerManager::SetTSliceInSlicer(int tslice, int slicer) if (mSlicers[slicer]->GetTSlice() == tslice) return; + if(mSlicingPreset==VOXELS_SLICING) { + vtkMatrix4x4 *imageTransformInverse = vtkMatrix4x4::New(); + mImage->GetTransform()[tslice]->GetInverse(imageTransformInverse); + this->GetSlicer(slicer)->GetSlicingTransform()->SetMatrix(imageTransformInverse); + imageTransformInverse->Delete(); + } + mSlicers[slicer]->SetTSlice(tslice); UpdateTSlice(slicer); } @@ -570,36 +585,42 @@ void vvSlicerManager::SetOpacity(int i, double factor) //---------------------------------------------------------------------------- void vvSlicerManager::UpdateViews(int current,int slicer) { - double x = (mSlicers[slicer]->GetCurrentPosition()[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0]) + double p[3], pt[3]; + p[0] = mSlicers[slicer]->GetCurrentPosition()[0]; + p[1] = mSlicers[slicer]->GetCurrentPosition()[1]; + p[2] = mSlicers[slicer]->GetCurrentPosition()[2]; + mSlicers[slicer]->GetSlicingTransform()->GetInverse()->TransformPoint(p, pt); + + double x = (pt[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0]) /mSlicers[slicer]->GetInput()->GetSpacing()[0]; - double y = (mSlicers[slicer]->GetCurrentPosition()[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1]) + double y = (pt[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1]) /mSlicers[slicer]->GetInput()->GetSpacing()[1]; - double z = (mSlicers[slicer]->GetCurrentPosition()[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2]) + double z = (pt[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2]) /mSlicers[slicer]->GetInput()->GetSpacing()[2]; - 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]) { + 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) { mSlicers[slicer]->UpdateCursorPosition(); mSlicers[slicer]->SetCursorColor(10,212,255); switch (mSlicers[slicer]->GetSliceOrientation()) { case vtkImageViewer2::SLICE_ORIENTATION_XY: - if (mSlicers[slicer]->GetSlice() != (int)floor(z)) - mSlicers[slicer]->SetSlice((int)floor(z)); + if (mSlicers[slicer]->GetSlice() != (int)lrint(z)) + mSlicers[slicer]->SetSlice((int)lrint(z)); break; case vtkImageViewer2::SLICE_ORIENTATION_XZ: - if (mSlicers[slicer]->GetSlice() != (int)floor(y)) - mSlicers[slicer]->SetSlice((int)floor(y)); + if (mSlicers[slicer]->GetSlice() != (int)lrint(y)) + mSlicers[slicer]->SetSlice((int)lrint(y)); break; case vtkImageViewer2::SLICE_ORIENTATION_YZ: - if (mSlicers[slicer]->GetSlice() != (int)floor(x)) - mSlicers[slicer]->SetSlice((int)floor(x)); + if (mSlicers[slicer]->GetSlice() != (int)lrint(x)) + mSlicers[slicer]->SetSlice((int)lrint(x)); break; } mSlicers[slicer]->Render(); @@ -609,10 +630,7 @@ void vvSlicerManager::UpdateViews(int current,int slicer) && mSlicers[i]->GetRenderer()->GetDraw() && mSlicers[i]->GetRenderWindow()->GetSize()[0] > 2 && mSlicers[i]->GetRenderWindow()->GetSize()[1] > 2) { - mSlicers[i]->SetCurrentPosition(mSlicers[slicer]->GetCurrentPosition()[0], - mSlicers[slicer]->GetCurrentPosition()[1], - mSlicers[slicer]->GetCurrentPosition()[2], - mSlicers[slicer]->GetTSlice()); + mSlicers[i]->SetCurrentPosition(p[0], p[1], p[2], mSlicers[slicer]->GetTSlice()); 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, @@ -652,19 +670,21 @@ void vvSlicerManager::UpdateViews(int current,int slicer) //---------------------------------------------------------------------------- void vvSlicerManager::UpdateLinked(int slicer) { - double x = (mSlicers[slicer]->GetCurrentPosition()[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0]) - /mSlicers[slicer]->GetInput()->GetSpacing()[0]; - double y = (mSlicers[slicer]->GetCurrentPosition()[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1]) - /mSlicers[slicer]->GetInput()->GetSpacing()[1]; - double z = (mSlicers[slicer]->GetCurrentPosition()[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2]) - /mSlicers[slicer]->GetInput()->GetSpacing()[2]; - - 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]) { + double p[3], pt[3]; + p[0] = mSlicers[slicer]->GetCurrentPosition()[0]; + p[1] = mSlicers[slicer]->GetCurrentPosition()[1]; + p[2] = mSlicers[slicer]->GetCurrentPosition()[2]; + mSlicers[slicer]->GetSlicingTransform()->GetInverse()->TransformPoint(p, pt); + double x = (pt[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0]) / mSlicers[slicer]->GetInput()->GetSpacing()[0]; + double y = (pt[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1]) / mSlicers[slicer]->GetInput()->GetSpacing()[1]; + double z = (pt[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2]) / mSlicers[slicer]->GetInput()->GetSpacing()[2]; + + 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) { for (std::list::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) { emit UpdateLinkManager(*i, slicer,mSlicers[slicer]->GetCurrentPosition()[0], mSlicers[slicer]->GetCurrentPosition()[1], @@ -682,6 +702,11 @@ void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagat refCam->GetPosition(refPosition); refCam->GetFocalPoint(refFocal); + refSlicer->GetSlicingTransform()->TransformPoint(refPosition); + refSlicer->GetSlicingTransform()->TransformPoint(refFocal); + mSlicers[0]->GetSlicingTransform()->GetInverse()->TransformPoint(refPosition); + mSlicers[0]->GetSlicingTransform()->GetInverse()->TransformPoint(refFocal); + for ( unsigned int i = 0; i < mSlicers.size(); i++) { vtkCamera *camera = mSlicers[i]->GetRenderer()->GetActiveCamera(); camera->SetParallelScale(refCam->GetParallelScale()); @@ -729,10 +754,13 @@ void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagat focal[2] = refFocal[2]; } } - +DD(camera->GetFocalPoint()[0] << ' ' << camera->GetFocalPoint()[1] << ' ' << camera->GetFocalPoint()[2]) camera->SetFocalPoint(focal); +DD(camera->GetFocalPoint()[0] << ' ' << camera->GetFocalPoint()[1] << ' ' << camera->GetFocalPoint()[2]) +DD(camera->GetPosition()[0] << ' ' << camera->GetPosition()[1] << ' ' << camera->GetPosition()[2]) camera->SetPosition(position); - +DD(camera->GetPosition()[0] << ' ' << camera->GetPosition()[1] << ' ' << camera->GetPosition()[2]) + //Fix for bug #243 mSlicers[i]->ForceUpdateDisplayExtent(); } @@ -794,13 +822,17 @@ bool vvSlicerManager::GetLinkOverlayWindowLevel() const void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType) { if(actorType == "image") - this->GetImage()->GetTransform()->Identity(); + for(unsigned int i=0; iGetImage()->GetTransform().size(); i++) + this->GetImage()->GetTransform()[i]->Identity(); else if(actorType == "overlay") - this->GetSlicer(0)->GetOverlay()->GetTransform()->Identity(); + for(unsigned int i=0; iGetImage()->GetTransform().size(); i++) + this->GetSlicer(0)->GetOverlay()->GetTransform()[i]->Identity(); else if(actorType == "fusion") - this->GetSlicer(0)->GetFusion()->GetTransform()->Identity(); + for(unsigned int i=0; iGetImage()->GetTransform().size(); i++) + this->GetSlicer(0)->GetFusion()->GetTransform()[i]->Identity(); else if(actorType == "vf") - this->GetVF()->GetTransform()->Identity(); + for(unsigned int i=0; iGetImage()->GetTransform().size(); i++) + this->GetVF()->GetTransform()[i]->Identity(); else return; @@ -1057,6 +1089,41 @@ void vvSlicerManager::UpdateSliceRange(int slicer) } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +void vvSlicerManager::SetSlicingPreset(SlicingPresetType preset) +{ + if(mSlicingPreset==preset) + return; + + vtkMatrix4x4 *imageTransformInverse = vtkMatrix4x4::New(); + mImage->GetTransform()[this->GetTSlice()]->GetInverse(imageTransformInverse); + + for(int i=0; i< this->GetNumberOfSlicers(); i++){ + vvSlicer *s = this->GetSlicer(i); + switch(preset) + { + case WORLD_SLICING: + s->GetSlicingTransform()->Identity(); + break; + case VOXELS_SLICING: + s->GetSlicingTransform()->SetMatrix(imageTransformInverse); + break; + default: + imageTransformInverse->Delete(); + return; + } + s->ForceUpdateDisplayExtent(); + s->SetSlice((s->GetInput()->GetWholeExtent()[s->GetSliceOrientation()*2+1] + +s->GetInput()->GetWholeExtent()[s->GetSliceOrientation()*2])/2.0); + s->ResetCamera(); + s->Render(); + } + + imageTransformInverse->Delete(); + mSlicingPreset = preset; +} + +//---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void vvSlicerManager::SetPreset(int preset) @@ -1116,11 +1183,11 @@ void vvSlicerManager::SetPreset(int preset) void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlKey) { double min, max; - int t = this->mSlicers[slicer]->GetTSlice(); + int t = this->GetTSlice(); if(bCtrlKey && this->mSlicers[slicer]->GetFusion()) { this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetFusion()->GetVTKImages()[t], - this->mSlicers[slicer]->GetFusion()->GetTransform()); + this->mSlicers[slicer]->GetFusion()->GetTransform()[t]); this->SetFusionWindow(max-min); this->SetFusionLevel(0.5*(min+max)); this->SetColorMap(mColorMap); @@ -1128,7 +1195,7 @@ void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlK else if(bCtrlKey && this->mSlicers[slicer]->GetOverlay()) { this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetOverlay()->GetVTKImages()[t], - this->mSlicers[slicer]->GetOverlay()->GetTransform()); + this->mSlicers[slicer]->GetOverlay()->GetTransform()[t]); if(this->mSlicers[slicer]->GetLinkOverlayWindowLevel()){ this->SetColorWindow(max-min); this->SetColorLevel(0.5*(min+max)); @@ -1140,7 +1207,7 @@ void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlK else { this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetImage()->GetVTKImages()[t], - this->mSlicers[slicer]->GetImage()->GetTransform()); + this->mSlicers[slicer]->GetConcatenatedTransform()); this->SetColorWindow(max-min); this->SetColorLevel(0.5*(min+max)); this->SetPreset(6); @@ -1319,12 +1386,12 @@ void vvSlicerManager::AddLandmark(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 (x_index >= mSlicers[0]->GetInput()->GetWholeExtent()[0] && - x_index <= mSlicers[0]->GetInput()->GetWholeExtent()[1] && - y_index >= mSlicers[0]->GetInput()->GetWholeExtent()[2] && - y_index <= mSlicers[0]->GetInput()->GetWholeExtent()[3] && - z_index >= mSlicers[0]->GetInput()->GetWholeExtent()[4] && - z_index <= mSlicers[0]->GetInput()->GetWholeExtent()[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) { double value = this->GetScalarComponentAsDouble(mSlicers[0]->GetInput(), x_index, y_index, z_index); this->GetLandmarks()->AddLandmark(x,y,z,t,value); emit LandmarkAdded(); diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index 9858d69..50a31ba 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -52,6 +52,7 @@ class vvSlicerManager : public QObject { Q_OBJECT public: + typedef enum {WORLD_SLICING, VOXELS_SLICING} SlicingPresetType; vvSlicerManager(int numberOfSlicers); ~vvSlicerManager(); @@ -103,6 +104,7 @@ class vvSlicerManager : public QObject { void SetFilename(std::string f, int number=0); void SetSliceOrientation(int slicer, int orientation); + int GetTSlice(); void SetTSlice(int slice); void SetNextTSlice(int originating_slicer); void SetPreviousTSlice(int originating_slicer); @@ -151,6 +153,9 @@ class vvSlicerManager : public QObject { int GetPreset() { return mPreset; } + SlicingPresetType GetSlicingPreset() { + return mSlicingPreset; + } int GetOverlayColor() const { return mOverlayColor; } @@ -203,6 +208,7 @@ class vvSlicerManager : public QObject { void UpdateSlice(int slicer); void UpdateTSlice(int slicer); void UpdateSliceRange(int slicer); + void SetSlicingPreset(SlicingPresetType preset); vvLandmarks *GetLandmarks(); void AddLandmark(float x,float y,float z,float t); @@ -251,6 +257,7 @@ protected: bool mFusionShowLegend; int mPreset; + SlicingPresetType mSlicingPreset; vvImageReader::LoadedImageType mType; std::string mVFComponent; std::string mOverlayComponent; diff --git a/vv/vvSlicerManagerCommand.cxx b/vv/vvSlicerManagerCommand.cxx index 1b71033..9929e9d 100644 --- a/vv/vvSlicerManagerCommand.cxx +++ b/vv/vvSlicerManagerCommand.cxx @@ -362,7 +362,12 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, zWorld = z; break; } - this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(xWorld,yWorld,zWorld, + + double p[3]; p[0] = xWorld; p[1] = yWorld; p[2] = zWorld; + double pt[3]; + this->SM->GetSlicer(VisibleInWindow)->GetSlicingTransform()->TransformPoint(p, pt); + + this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(pt[0],pt[1],pt[2], this->SM->GetSlicer(VisibleInWindow)->GetTSlice()); if (newLandmark) { this->SM->AddLandmark(xWorld,yWorld,zWorld, diff --git a/vv/vvToolRigidReg.cxx b/vv/vvToolRigidReg.cxx index 28591ba..508551d 100644 --- a/vv/vvToolRigidReg.cxx +++ b/vv/vvToolRigidReg.cxx @@ -118,7 +118,8 @@ void vvToolRigidReg::InputIsSelected(vvSlicerManager *input) //backup original matrix for(int j=0; j<4; j++) for(int i=0; i<4; i++) - mInitialMatrix->SetElement(i,j, mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()->GetElement(i,j)); + // TODO SR and BP: check on the list of transforms and not the first only + mInitialMatrix->SetElement(i,j, mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix()->GetElement(i,j)); QString origTransformString = dynamic_cast(mMainWindow)->Get4x4MatrixDoubleAsString(mInitialMatrix); transformationLabel->setText(origTransformString); SetTransform(mInitialMatrix); @@ -242,7 +243,8 @@ void vvToolRigidReg::SpinBoxChange(double newVal) } // Compute transform and set - vtkSmartPointer transform_final=mInput->GetImage()->GetTransform(); + // TODO SR and BP: check on the list of transforms and not the first only + vtkSmartPointer transform_final=mInput->GetImage()->GetTransform()[0]; transform_final->Identity(); transform_final->PostMultiply(); @@ -294,7 +296,8 @@ void vvToolRigidReg::SaveFile() QFile file(filename); if (file.open(QFile::WriteOnly | QFile::Truncate)) { - vtkMatrix4x4* matrix = mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix(); + // TODO SR and BP: check on the list of transforms and not the first only + vtkMatrix4x4* matrix = mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix(); QString matrixStr = dynamic_cast(mMainWindow)->Get4x4MatrixDoubleAsString(matrix,16); QTextStream out(&file); out << matrixStr; @@ -332,7 +335,8 @@ void vvToolRigidReg::LoadFile() //------------------------------------------------------------------------------ void vvToolRigidReg::ChangeOfRotationCenter() { - SetTransform(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()); + // TODO SR and BP: check on the list of transforms and not the first only + SetTransform(mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix()); } //------------------------------------------------------------------------------ @@ -347,7 +351,8 @@ void vvToolRigidReg::ResetTransform() void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix) { vtkSmartPointer transform=vtkSmartPointer::New(); - mCurrentSlicerManager->GetImage()->GetTransform()->SetMatrix(matrix); + // TODO SR and BP: check on the list of transforms and not the first only + mCurrentSlicerManager->GetImage()->GetTransform()[0]->SetMatrix(matrix); transform->Update(); Render(); dynamic_cast(mMainWindow)->ImageInfoChanged();