- 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])
- {
- std::stringstream pixel1;
- std::stringstream pixel2;
- std::stringstream pixel3;
- std::stringstream temps;
- pixel1 << (int)X;
- pixel2 << (int)Y;
- pixel3 << (int)Z;
- temps << mCurrentTSlice;
- double value = this->GetInput()->GetScalarComponentAsDouble(
- (int)X,
- (int)Y,
- (int)Z,0);
-
- 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();
- }
- ca->SetText(1,worldPos.c_str());
- }
- if (mOverlay && mOverlayActor->GetVisibility())
- {
+ std::stringstream slicePos;
+ slicePos << "Slice: " << this->GetSlice();
+ ca->SetText(2, slicePos.str().c_str());
+ }
+
+ if (pdmA->GetVisibility()) {
+ double x = mCursor[0];
+ double y = mCursor[1];
+ double z = mCursor[2];
+ double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
+ double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
+ double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
+#if VTK_MAJOR_VERSION <= 5
+ if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0]-0.5 &&
+ xCursor < this->GetImageActor()->GetDisplayExtent()[1]+0.5 &&
+ yCursor >= this->GetImageActor()->GetDisplayExtent()[2]-0.5 &&
+ yCursor < this->GetImageActor()->GetDisplayExtent()[3]+0.5 &&
+ zCursor >= this->GetImageActor()->GetDisplayExtent()[4]-0.5 &&
+ zCursor < this->GetImageActor()->GetDisplayExtent()[5]+0.5 ) {
+ vtkRenderer * renderer = this->Renderer;
+
+ renderer->WorldToView(x,y,z);
+ renderer->ViewToNormalizedViewport(x,y,z);
+ renderer->NormalizedViewportToViewport(x,y);
+ renderer->ViewportToNormalizedDisplay(x,y);
+ renderer->NormalizedDisplayToDisplay(x,y);
+ crossCursor->SetFocalPoint(x,y,z);
+ } else
+ crossCursor->SetFocalPoint(-1,-1,z);
+ crossCursor->Update();
+ }
+#else
+ vtkSmartPointer<vtkOpenGLImageSliceMapper> mapperOpenGL= vtkSmartPointer<vtkOpenGLImageSliceMapper>::New();
+ try {
+ mapperOpenGL = dynamic_cast<vtkOpenGLImageSliceMapper*>(GetImageActor()->GetMapper());
+ } catch (const std::bad_cast& e) {
+ std::cerr << e.what() << std::endl;
+ std::cerr << "Conversion error" << std::endl;
+ return;
+ }
+
+ if (xCursor >= mapperOpenGL->GetCroppingRegion()[0]-0.5 &&
+ xCursor < mapperOpenGL->GetCroppingRegion()[1]+0.5 &&
+ yCursor >= mapperOpenGL->GetCroppingRegion()[2]-0.5 &&
+ yCursor < mapperOpenGL->GetCroppingRegion()[3]+0.5 &&
+ zCursor >= mapperOpenGL->GetCroppingRegion()[4]-0.5 &&
+ zCursor < mapperOpenGL->GetCroppingRegion()[5]+0.5 ) {
+ vtkRenderer * renderer = this->Renderer;
+
+ renderer->WorldToView(x,y,z);
+ renderer->ViewToNormalizedViewport(x,y,z);
+ renderer->NormalizedViewportToViewport(x,y);
+ renderer->ViewportToNormalizedDisplay(x,y);
+ renderer->NormalizedDisplayToDisplay(x,y);
+ crossCursor->SetFocalPoint(x,y,z);
+ } else
+ crossCursor->SetFocalPoint(-1,-1,z);
+ crossCursor->Update();
+ }
+#endif
+
+ if (mOverlay && mOverlayActor->GetVisibility()) {
+ if(mLinkOverlayWindowLevel) {