From: Simon Rit Date: Tue, 26 Apr 2011 10:52:12 +0000 (+0200) Subject: Corrected GetScalarComponentAsDouble and displayed pixel coordinates in X-Git-Tag: v1.2.0~16 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9983384fdd6b9ac0a9cc8de007884826157c9d00;p=clitk.git Corrected GetScalarComponentAsDouble and displayed pixel coordinates in corner. --- diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 42f8303..371cd2d 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -1150,7 +1150,7 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max) //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- -double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, int X, double Y, double Z, int &ix, int &iy, int &iz, int component) +double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component) { ix = lrint(X); iy = lrint(Y); @@ -1178,13 +1178,7 @@ void vvSlicer::Render() } else legend->SetVisibility(0); if (ca->GetVisibility()) { - std::string worldPos = ""; - std::stringstream world1; - std::stringstream world2; - std::stringstream world3; - world1 << (int)mCurrent[0]; - world2 << (int)mCurrent[1]; - world3 << (int)mCurrent[2]; + 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]; @@ -1207,24 +1201,19 @@ void vvSlicer::Render() int ix, iy, iz; double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz); - std::stringstream pixel1; - std::stringstream pixel2; - std::stringstream pixel3; - std::stringstream temps; - pixel1 << ix; - pixel2 << iy; - pixel3 << iz; - temps << mCurrentTSlice; - - std::stringstream val; - val << value; - worldPos += "data value : " + val.str(); - worldPos += "\n mm : " + world1.str() + " " + world2.str() + " " + - world3.str() + " " + temps.str(); - worldPos += "\n pixel : " + pixel1.str() + " " + pixel2.str() + " " + - pixel3.str() + " " + temps.str(); + worldPos << "data value : " << value << std::endl; + worldPos << "mm : " << lrint(mCurrent[0]) << ' ' + << lrint(mCurrent[1]) << ' ' + << lrint(mCurrent[2]) << ' ' + << mCurrentTSlice + << std::endl; + worldPos << "pixel : " << ix << ' ' + << iy << ' ' + << iz << ' ' + << mCurrentTSlice + << std::endl; } - ca->SetText(1,worldPos.c_str()); + ca->SetText(1,worldPos.str().c_str()); } if (pdmA->GetVisibility()) { diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index 2a157d0..0246723 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -107,7 +107,7 @@ public: void SetDisplayMode(bool i); void FlipHorizontalView(); void FlipVerticalView(); - static double GetScalarComponentAsDouble(vtkImageData *image, int X, double Y, double Z, int &ix, int &iy, int &iz, int component=0); + static double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component=0); void Render(); ///Sets the camera to fit the image in the window void ResetCamera();