X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvSlicer.cxx;h=331c236977b12d00ad9785dd5492d6aa685d479a;hb=000ac5b867a708575268c7c823db4fcbe727c2d6;hp=ec225e2066be3558524d2ffc6c421b29e55c7dd5;hpb=f6bfd7ec2781c83bd818e93d3628a36d67bf5a63;p=clitk.git diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index ec225e2..331c236 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -64,6 +64,7 @@ #include #include #include +#include vtkCxxRevisionMacro(vvSlicer, "DummyRevision"); vtkStandardNewMacro(vvSlicer); @@ -87,6 +88,7 @@ vvSlicer::vvSlicer() mSubSampling = 5; mScale = 1; mVFLog = 0; + mVFWidth = 1; std::string text = "F1 = sagital; F2 = coronal; F3 = axial\n"; text += "F5 = horizontal flip; F6 = vertical flip\n\n"; @@ -140,6 +142,7 @@ vvSlicer::vvSlicer() this->WindowLevel->Delete(); this->WindowLevel = vvImageMapToWLColors::New(); this->InstallPipeline(); + } //------------------------------------------------------------------------------ @@ -279,6 +282,26 @@ void vvSlicer::SetImage(vvImage::Pointer image) { mImage = image; this->Superclass::SetInput(image->GetVTKImages()[0]); + + // Prevent crash when reload -> change slice if outside extent + int extent[6]; + this->GetInput()->GetWholeExtent(extent); + if (SliceOrientation == 0) { + if (Slice >= extent[1]) { + Slice = (extent[1]-extent[0])/2.0; + } + } + if (SliceOrientation == 1) { + if (Slice >= extent[3]) { + Slice = (extent[3]-extent[2])/2.0; + } + } + if (SliceOrientation == 2) { + if (Slice >= extent[5]) { + Slice = (extent[5]-extent[4])/2.0; + } + } + this->UpdateDisplayExtent(); mCurrentTSlice = 0; ca->SetText(0,mFileName.c_str()); @@ -421,6 +444,7 @@ void vvSlicer::SetVF(vvImage::Pointer vf) mVFActor = vtkActor::New(); mVFActor->SetMapper(mVFMapper); mVFActor->SetPickable(0); + mVFActor->GetProperty()->SetLineWidth(mVFWidth); this->UpdateDisplayExtent(); this->GetRenderer()->AddActor(mVFActor); @@ -543,6 +567,17 @@ void vvSlicer::SetVFScale(int scale) } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvSlicer::SetVFWidth(int width) +{ + mVFWidth = width; + if (mVFActor) + mVFActor->GetProperty()->SetLineWidth(mVFWidth); + UpdateDisplayExtent(); + Render(); +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvSlicer::SetVFLog(int log) @@ -1286,10 +1321,9 @@ void vvSlicer::Render() pixel2 << (int)Y; pixel3 << (int)Z; temps << mCurrentTSlice; - double value = this->GetInput()->GetScalarComponentAsDouble( - (int)X, - (int)Y, - (int)Z,0); + double value = this->GetInput()->GetScalarComponentAsDouble(lrint(X), + lrint(Y), + lrint(Z),0); std::stringstream val; val << value; @@ -1374,7 +1408,11 @@ void vvSlicer::SetSlice(int slice) SetContourSlice(); this->Modified(); this->UpdateDisplayExtent(); - this->Render(); + + // DD("SetSlice de slicer = Render"); + + // Seems to work without this line + // this->Render(); } //---------------------------------------------------------------------------- @@ -1415,3 +1453,8 @@ void vvSlicer::PrintSelf(ostream& os, vtkIndent indent) //---------------------------------------------------------------------------- + + + + +