X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvSlicerManager.cxx;h=9548dfded6f2944a4f61dadb3480b57ccd7747c9;hb=632adadb8b9230458aeab8ddccc736d674edc87a;hp=12928afa2d82ca079a02fa4c1d5bbf9e2eaaab42;hpb=df724140fd47a31aaa0feaba5938a1eecb263741;p=clitk.git diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 12928af..9548dfd 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -221,7 +221,7 @@ void vvSlicerManager::SetImage(vvImage::Pointer image) //---------------------------------------------------------------------------- -bool vvSlicerManager::SetImages(std::vector filenames, vvImageReader::LoadedImageType type, int n) +bool vvSlicerManager::SetImages(std::vector filenames, vvImageReader::LoadedImageType type, int n, bool patientCoordinateSystem) { mType = type; std::string fileWithoutExtension = vtksys::SystemTools::GetFilenameWithoutExtension(filenames[0]); @@ -237,6 +237,8 @@ bool vvSlicerManager::SetImages(std::vector filenames, vvImageReade if (mReader.IsNull()) mReader = vvImageReader::New(); mReader->SetInputFilenames(filenames); + if (type == vvImageReader::DICOM) + mReader->SetPatientCoordinateSystem(patientCoordinateSystem); mReader->Update(type); mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName)); @@ -583,6 +585,7 @@ void vvSlicerManager::ToggleInterpolation() { bool interpolate=!(mSlicers[0]->GetImageActor()->GetInterpolate()); for ( unsigned int i = 0; i < mSlicers.size(); i++) { + mSlicers[i]->SetInterpolationImageReslice(interpolate); mSlicers[i]->GetImageActor()->SetInterpolate(interpolate); if (mSlicers[i]->GetOverlayActor()) mSlicers[i]->GetOverlayActor()->SetInterpolate(interpolate); @@ -1391,7 +1394,6 @@ void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlK this->SetColorLevel(0.5*(min+max)); this->SetPreset(WL_USER); } - this->Render(); this->UpdateWindowLevel(); } //---------------------------------------------------------------------------- @@ -1570,28 +1572,26 @@ void vvSlicerManager::AddNewLandmark(float x,float y,float z,float t) //---------------------------------------------------------------------------- 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]; + double x_index = (x - mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetOrigin()[0])/mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetSpacing()[0]; + double y_index = (y - mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetOrigin()[1])/mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetSpacing()[1]; + double z_index = (z - mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetOrigin()[2])/mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->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) + if (x_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetWholeExtent()[0]-0.5 && + x_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetWholeExtent()[1]+0.5 && + y_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetWholeExtent()[2]-0.5 && + y_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetWholeExtent()[3]+0.5 && + z_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetWholeExtent()[4]-0.5 && + z_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->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) + if (x_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0]-0.5 && + x_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1]+0.5 && + y_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2]-0.5 && + y_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3]+0.5 && + z_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4]-0.5 && + z_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[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 + double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetImage()->GetVTKImages()[mSlicers[mSelectedSlicer]->GetTSlice()], x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848 this->GetLandmarks()->AddLandmark(x,y,z,t,value); emit LandmarkAdded(); } @@ -1601,33 +1601,38 @@ void vvSlicerManager::AddLandmark(float x,float y,float z,float t) //---------------------------------------------------------------------------- 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]; + double x_index = (x - mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetOrigin()[0])/mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetSpacing()[0]; + double y_index = (y - mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetOrigin()[1])/mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetSpacing()[1]; + double z_index = (z - mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetOrigin()[2])/mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->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) + if (x_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetWholeExtent()[0]-0.5 && + x_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetWholeExtent()[1]+0.5 && + y_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetWholeExtent()[2]-0.5 && + y_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetWholeExtent()[3]+0.5 && + z_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetWholeExtent()[4]-0.5 && + z_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->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) + if (x_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0]-0.5 && + x_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1]+0.5 && + y_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2]-0.5 && + y_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3]+0.5 && + z_index >= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4]-0.5 && + z_index <= mSlicers[0]->GetImage()->GetVTKImages()[mSlicers[0]->GetTSlice()]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[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 + double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetImage()->GetVTKImages()[mSlicers[mSelectedSlicer]->GetTSlice()], x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848 this->GetLandmarks()->AddLandmark(x,y,z,t,value); } } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +void vvSlicerManager::UpdateLandmark() +{ + this->GetLandmarks()->TransformUpdate(mSlicers[mSelectedSlicer]->GetConcatenatedTransform()->GetInverse()); +} +//---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- void vvSlicerManager::PrevImage(int slicer) {