mForegroundValue = 1;
mBackgroundValue = 0;
m_modeBG = true;
+ mDepth = 1.0;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::UpdateSlice(int slicer, int slice)
+void vvBinaryImageOverlayActor::UpdateSlice(int slicer, int slice, bool force)
{
if (!mSlicer) return;
- if (mPreviousSlice == mSlicer->GetSlice()) {
- if (mPreviousTSlice == mSlicer->GetTSlice()) {
- //DD("=========== NOTHING");
- return; // Nothing to do
+ if (!force) {
+ if (mPreviousSlice == mSlicer->GetSlice()) {
+ if (mPreviousTSlice == mSlicer->GetTSlice()) {
+ return; // Nothing to do
+ }
}
}
int orientation = mSlicer->GetOrientation();
int maskExtent[6];
ComputeExtent(orientation, mSlice, imageExtent, maskExtent);
- //ComputeExtent(imageExtent, maskExtent, mSlicer->GetImage()->GetFirstVTKImageData(), mImage->GetFirstVTKImageData());
ComputeExtent(maskExtent, maskExtent, mSlicer->GetImage()->GetFirstVTKImageData(), mImage->GetFirstVTKImageData());
- // std::cout << "maskExtent = " << maskExtent[0] << " " << maskExtent[1] << " " << maskExtent[2] << " "
- // << maskExtent[3] << " " << maskExtent[4] << " " << maskExtent[5] << std::endl;
mSlicer->ClipDisplayedExtent(maskExtent, mMapperList[mTSlice]->GetInput()->GetWholeExtent());
- // std::cout << "maskExtent = " << maskExtent[0] << " " << maskExtent[1] << " " << maskExtent[2] << " "
- // << maskExtent[3] << " " << maskExtent[4] << " " << maskExtent[5] << std::endl;
- SetDisplayExtentAndCameraPosition(orientation, mSlice, maskExtent, mImageActorList[mTSlice], 0.0);
+ SetDisplayExtentAndCameraPosition(orientation, mSlice, maskExtent, mImageActorList[mTSlice], mDepth);
// set previous slice
mPreviousTSlice = mSlicer->GetTSlice();
//----------------------------------------------------------------------------
void vvBinaryImageOverlayActor::ComputeExtent(int * inExtent, int * outExtent, vtkImageData * image, vtkImageData * overlay)
{
- outExtent[0] = (( image->GetOrigin()[0] + inExtent[0]*image->GetSpacing()[0] ) - overlay->GetOrigin()[0]) /
- overlay->GetSpacing()[0];
- outExtent[1] = (( image->GetOrigin()[0] + inExtent[1]*image->GetSpacing()[0] ) - overlay->GetOrigin()[0]) /
- overlay->GetSpacing()[0];
- outExtent[2] = (( image->GetOrigin()[1] + inExtent[2]*image->GetSpacing()[1] ) - overlay->GetOrigin()[1]) /
- overlay->GetSpacing()[1];
- outExtent[3] = (( image->GetOrigin()[1] + inExtent[3]*image->GetSpacing()[1] ) - overlay->GetOrigin()[1]) /
- overlay->GetSpacing()[1];
- outExtent[4] = (( image->GetOrigin()[2] + inExtent[4]*image->GetSpacing()[2] ) - overlay->GetOrigin()[2]) /
- overlay->GetSpacing()[2];
- outExtent[5] = (( image->GetOrigin()[2] + inExtent[5]*image->GetSpacing()[2] ) - overlay->GetOrigin()[2]) /
- overlay->GetSpacing()[2];
+ outExtent[0] = (int)lrint(((image->GetOrigin()[0] + inExtent[0]*image->GetSpacing()[0]) - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0]);
+ outExtent[1] = (int)lrint(((image->GetOrigin()[0] + inExtent[1]*image->GetSpacing()[0]) - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0]);
+ outExtent[2] = (int)lrint(((image->GetOrigin()[1] + inExtent[2]*image->GetSpacing()[1]) - overlay->GetOrigin()[1]) / overlay->GetSpacing()[1]);
+ outExtent[3] = (int)lrint(((image->GetOrigin()[1] + inExtent[3]*image->GetSpacing()[1]) - overlay->GetOrigin()[1]) / overlay->GetSpacing()[1]);
+ outExtent[4] = (int)lrint(((image->GetOrigin()[2] + inExtent[4]*image->GetSpacing()[2]) - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2]);
+ outExtent[5] = (int)lrint(((image->GetOrigin()[2] + inExtent[5]*image->GetSpacing()[2]) - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2]);
}
//----------------------------------------------------------------------------
vtkImageActor * actor,
double position)
{
+ /* FIXME
+ Error according to camera orientation
+ */
+
// Set position
if (orientation == vtkImageViewer2::SLICE_ORIENTATION_XY) {
- if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice)
- actor->SetPosition(0,0, position);
- else
+ //if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice)
actor->SetPosition(0,0, -position);
+ //else
+ //actor->SetPosition(0,0, position);
}
if (orientation == vtkImageViewer2::SLICE_ORIENTATION_XZ) {
- if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice)
- actor->SetPosition(0,position,0);
- else
+ //if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice)
+ // actor->SetPosition(0,position,0);
+ //else
actor->SetPosition(0,-position,0);
}
if (orientation == vtkImageViewer2::SLICE_ORIENTATION_YZ) {
- if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice)
- actor->SetPosition(position,0, 0);
- else
+ //if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice)
+ // actor->SetPosition(position,0, 0);
+ //else
actor->SetPosition(-position,0, 0);
}
actor->SetDisplayExtent(extent);
void SetColor(double r, double g, double b);
void SetOpacity(double d);
void SetImage(vvImage * image, double bg, bool modeBG=true);
+ void SetDepth(double d) { mDepth = d; }
void Initialize(bool IsVisible=true);
void UpdateColor();
- void UpdateSlice(int slicer, int slice);
+ void UpdateSlice(int slicer, int slice, bool force=false);
void HideActors();
void ShowActors();
double mForegroundValue;
bool m_modeBG;
vtkSmartPointer<vtkLookupTable> mColorLUT;
+ double mDepth;
std::vector<vtkSmartPointer<vtkImageMapToRGBA> > mMapperList;
std::vector<vtkSmartPointer<vtkImageActor> > mImageActorList;
mDisplayModeIsPreserveMemory = true;
SetPreserveMemoryModeEnabled(true);
mPreviousOrientation = -1;
+ mDepth = 1.0;
}
//------------------------------------------------------------------------------
vtkMarchingSquares * squares,
vtkImageClip * clipper,
double threshold, int orientation, int slice) {
-
- // Set parameter for the MarchigSquare
+ // Set parameter for the MarchigSquare
squares->SetValue(0, threshold);
// Get image extent
s = s-mHiddenImage->GetFirstVTKImageData()->GetOrigin()[orientation]; // from corner second image
s = s/mHiddenImage->GetFirstVTKImageData()->GetSpacing()[orientation]; // in voxel
- if (s == floor(s)) {
- extent2[orientation*2] = extent2[orientation*2+1] = (int)floor(s);
- } else {
- extent2[orientation*2] = (int)floor(s);
- extent2[orientation*2+1] = extent2[orientation*2];
- }
+ // Rint to the closest slice
+ extent2[orientation*2+1] = extent2[orientation*2] = (int)lrint(s);
// Do not display a contour if there is no contour on this slice
- if (extent2[orientation*2+1] > extent3[orientation*2+1]) {
+ // DD(extent2[orientation*2+1]);
+ // DD(extent3[orientation*2+1]);
+ // DD(extent2[orientation*2]);
+ // DD(extent3[orientation*2]);
+ if ((extent2[orientation*2+1] > extent3[orientation*2+1]) ||
+ (extent2[orientation*2] < extent3[orientation*2])) {
actor->VisibilityOff();
return;
}
// Move the actor to be visible
double position[3] = {0, 0, 0};
- position[orientation] = -1;
+ position[orientation] = -mDepth;
actor->SetPosition(position);
mapper->Update();
void SetLineWidth(double w);
void SetImage(vvImage * image);
void SetPreserveMemoryModeEnabled(bool b);
+ void SetDepth(double d) { mDepth = d; }
protected:
vvSlicer * mSlicer;
bool mHiddenImageIsUsed;
vvImage * mHiddenImage;
bool mDisplayModeIsPreserveMemory;
+ double mDepth;
// For preserveMemory mode
std::vector<vtkSmartPointer<vtkActor> > mSquaresActorList;
void vvMeshActor::SetCutSlice(double slice)
{
+ DD("SetCutSlice");
+ DD(slice);
mCutSlice=slice;
vtkImageData* mask;
if (static_cast<unsigned int>(mTimeSlice)<mMesh->GetNumberOfMasks())
mContourWidth = 1;
mContourColor.resize(3);
m_modeBG = true;
+ mDepth = 1.0;
}
//------------------------------------------------------------------------------
{
mOverlayActors.clear();
mImageContour.clear();
- Initialize(mIsVisible);
+ Initialize(mDepth, mIsVisible);
Update(); // No Render
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvROIActor::Initialize(bool IsVisible) {
+void vvROIActor::Initialize(double depth, bool IsVisible) {
if (mROI->GetImage()) {
mImageContour.clear();
mOverlayActors.clear();
+ mDepth = depth;
for(int i=0; i<mSlicerManager->GetNumberOfSlicers(); i++) {
mImageContour.push_back(vvImageContour::New());
mImageContour[i]->SetColor(mContourColor[0], mContourColor[1], mContourColor[2]);
mImageContour[i]->SetLineWidth(mContourWidth);
mImageContour[i]->SetPreserveMemoryModeEnabled(true);
+ mImageContour[i]->SetDepth(mDepth);
//mImageContour[i]->SetPreserveMemoryModeEnabled(false); // SEG FAULT !!!
mImageContour[i]->SetSlicer(mSlicerManager->GetSlicer(i));
mImageContour[i]->HideActors();
mROI->GetDisplayColor()[2]);
mOverlayActors[i]->SetOpacity(mOpacity);
mOverlayActors[i]->SetSlicer(mSlicerManager->GetSlicer(i));
- mOverlayActors[i]->Initialize(IsVisible);
+ mOverlayActors[i]->Initialize(IsVisible);
+ mOverlayActors[i]->SetDepth(mDepth);
}
connect(mSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
//------------------------------------------------------------------------------
-void vvROIActor::Update()
+void vvROIActor::SetDepth(double d)
+{
+ mDepth = d;
+ for(int i=0; i<mSlicerManager->GetNumberOfSlicers(); i++) {
+ mOverlayActors[i]->SetDepth(d);
+ mImageContour[i]->SetDepth(d);
+ }
+ Update(true);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvROIActor::Update(bool force)
{
for(int i=0; i<mSlicerManager->GetNumberOfSlicers(); i++) {
- UpdateSlice(i, mSlicerManager->GetSlicer(i)->GetSlice());
+ UpdateSlice(i, mSlicerManager->GetSlicer(i)->GetSlice(), force);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvROIActor::UpdateSlice(int slicer, int slices)
+void vvROIActor::UpdateSlice(int slicer, int slices, bool force)
{
if (!mROI->GetImage()) return;
if ((!mIsVisible) && (!mIsContourVisible)) return;
}
// Refresh overlays
- mOverlayActors[slicer]->UpdateSlice(slicer, slices);
+ mOverlayActors[slicer]->UpdateSlice(slicer, slices, force);
}
//------------------------------------------------------------------------------
void SetROI(clitk::DicomRT_ROI * r);
clitk::DicomRT_ROI * GetROI() { return mROI; }
void SetSlicerManager(vvSlicerManager * s);
- void Update();
- void Initialize(bool IsVisible=true);
+ void Update(bool force=false);
+ void Initialize(double d=1.0, bool IsVisible=true);
void SetVisible(bool b);
void SetContourVisible(bool b);
bool IsVisible();
void SetContourColor(double r, double v, double b);
std::vector<double> & GetContourColor();
void SetBGMode(bool b) { m_modeBG = b; }
+ void SetDepth(double d);
+ double GetDepth() { return mDepth; }
public slots:
- void UpdateSlice(int slicer, int slices);
+ void UpdateSlice(int slicer, int slices, bool force=false);
void UpdateColor();
void UpdateImage();
int mContourWidth;
std::vector<double> mContourColor;
bool m_modeBG;
+ double mDepth;
}; // end class vvROIActor
//------------------------------------------------------------------------------