Commit 6001277f authored by Emmanuel Promayon's avatar Emmanuel Promayon

NEW pixel picked actor is back in arbitrary slice

+ auto-synchronization on other orientation when the arbitrary
slice is picked
parent 973b6155
......@@ -241,9 +241,6 @@ void Slice::setSlice(double x, double y, double z) {
// Set pixel position in current slice.
setPixelRealPosition(x, y, z);
// show the pixel actor
pixelActor->VisibilityOn();
}
// -------------------- getNumberOfColors --------------------
......@@ -253,7 +250,9 @@ int Slice::getNumberOfColors() const {
// -------------------- setPixelRealPosition --------------------
void Slice::setPixelRealPosition(double x, double y, double z) {
// update and force visibility of the pixel actor
updatePixelActor(x, y, z);
pixelActor->VisibilityOn();
}
// -------------------- get2DImageActor --------------------
......@@ -491,29 +490,22 @@ void Slice::updatePickPlane() {
// for arbitrary, the size does not change, but the position
// can move up and down depending on the current orientation/translation
// => invert the translation to set the plane actor at the proper place
double sliceThickness = originalSpacing[2] / 2.0;
double currentX = 0.0;
double currentY = 0.0;
if (image2DReslicer != nullptr && image2DReslicer->GetResliceAxes() != nullptr) {
currentX = - image2DReslicer->GetResliceAxes()->GetElement(0, 3);
currentY = - image2DReslicer->GetResliceAxes()->GetElement(1, 3);
}
image2DActor->GetBounds(bounds);
CAMITK_INFO_ALT(QString("extent %1, %2, %3, %4, %5, %6").arg(bounds[0]).arg(bounds[1]).arg(bounds[2]).arg(bounds[3]).arg(bounds[4]).arg(bounds[5]));
pickPlaneActorPointSet->GetPoints()->SetPoint(0, bounds[0], bounds[2], -sliceThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(1, bounds[0], bounds[2], sliceThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(2, bounds[0], bounds[3], sliceThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(3, bounds[0], bounds[3], -sliceThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(4, bounds[1], bounds[2], -sliceThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(5, bounds[1], bounds[2], sliceThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(6, bounds[1], bounds[3], sliceThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(7, bounds[1], bounds[3], -sliceThickness);
double sliceHalfThickness = originalSpacing[2] / 2.0;
image2DActor->GetBounds(bounds);
pickPlaneActorPointSet->GetPoints()->SetPoint(0, bounds[0], bounds[2], - sliceHalfThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(1, bounds[0], bounds[2], sliceHalfThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(2, bounds[0], bounds[3], sliceHalfThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(3, bounds[0], bounds[3], - sliceHalfThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(4, bounds[1], bounds[2], - sliceHalfThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(5, bounds[1], bounds[2], sliceHalfThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(6, bounds[1], bounds[3], sliceHalfThickness);
pickPlaneActorPointSet->GetPoints()->SetPoint(7, bounds[1], bounds[3], - sliceHalfThickness);
// Side note: the image2DActor bounding box can also be used the same way
// for all other orientation...
}
break;
case AXIAL_NEURO:
case AXIAL:
image2DActor->GetBounds(bounds);
CAMITK_INFO_ALT(QString("extent %1, %2, %3, %4, %5, %6").arg(bounds[0]).arg(bounds[1]).arg(bounds[2]).arg(bounds[3]).arg(bounds[4]).arg(bounds[5]));
sliceBackPlane = currentSliceIndex * originalSpacing[2] - originalSpacing[2] / 2.0;
sliceFrontPlane = currentSliceIndex * originalSpacing[2] + originalSpacing[2] / 2.0;
pickPlaneActorPointSet->GetPoints()->SetPoint(0, 0.0, 0.0, sliceBackPlane);
......@@ -616,6 +608,33 @@ void Slice::updatePixelActor(double x, double y, double z) {
pixelActorPointSet->GetPoints()->SetPoint(6, x + sliceHalfThickness, originalSize[1], z);
pixelActorPointSet->GetPoints()->SetPoint(7, x - sliceHalfThickness, originalSize[1], z);
break;
case ARBITRARY: {
vtkSmartPointer<vtkMatrix4x4> T_P2L = vtkSmartPointer<vtkMatrix4x4>::New();
if (image2DReslicer->GetResliceAxes() != nullptr) {
T_P2L->DeepCopy(image2DReslicer->GetResliceAxes());
}
T_P2L->Invert();
double pixel_P[4] = {x, y, z, 1.0};
double pixel_L[4];
T_P2L->MultiplyPoint(pixel_P, pixel_L);
sliceHalfThickness = originalSpacing[2] / 2.0;
double bounds[6];
image2DActor->GetBounds(bounds);
// vertical quad
pixelActorPointSet->GetPoints()->SetPoint(0, pixel_L[0], bounds[2], pixel_L[2] - sliceHalfThickness);
pixelActorPointSet->GetPoints()->SetPoint(1, pixel_L[0], bounds[2], pixel_L[2] + sliceHalfThickness);
pixelActorPointSet->GetPoints()->SetPoint(2, pixel_L[0], bounds[3], pixel_L[2] + sliceHalfThickness);
pixelActorPointSet->GetPoints()->SetPoint(3, pixel_L[0], bounds[3], pixel_L[2] - sliceHalfThickness);
// horizontal quad
pixelActorPointSet->GetPoints()->SetPoint(4, bounds[0], pixel_L[1], pixel_L[2] - sliceHalfThickness);
pixelActorPointSet->GetPoints()->SetPoint(5, bounds[0], pixel_L[1], pixel_L[2] + sliceHalfThickness);
pixelActorPointSet->GetPoints()->SetPoint(6, bounds[1], pixel_L[1], pixel_L[2] + sliceHalfThickness);
pixelActorPointSet->GetPoints()->SetPoint(7, bounds[1], pixel_L[1], pixel_L[2] - sliceHalfThickness);
break;
}
break;
default:
break;
}
......
......@@ -159,7 +159,9 @@ void ArbitrarySingleImageComponent::setTransformRotation(double angleX, double a
if (checkCenter(checkRotation)) {
getTransform()->GetMatrix()->DeepCopy(checkRotation);
getTransform()->Modified();
// update picking representation (update pickplane position + hide pixel actor)
updatePickPlane();
getPixelActor()->VisibilityOff();
}
}
......@@ -201,7 +203,10 @@ void ArbitrarySingleImageComponent::setTransformTranslation(double x, double y,
getTransform()->GetMatrix()->DeepCopy(T_P2L);
getTransform()->Modified();
// update picking representation (update pickplane position + hide pixel actor)
updatePickPlane();
getPixelActor()->VisibilityOff();
}
// -------------------- updateTranslationExtremity --------------------
......@@ -355,7 +360,16 @@ void ArbitrarySingleImageComponent::setSlice(int s) {
}
void ArbitrarySingleImageComponent::setSlice(double x, double y, double z) {
// do nothing!
// (x,y,z) is given in the image (parent) frame coordinate system
// This method is called either:
// - when a point is picked on the arbitrary slice
// - when a point is picked in another slice orientation (axial, sagittal, coronal)
// Update the position without changing the orientation
// 1. compute (x,y,z) in local coordinates
// Update the pick point actor
// Set pixel position in current slice
setPixelRealPosition(x, y, z);
}
// -------------------- getSlice --------------------
......@@ -368,13 +382,17 @@ int ArbitrarySingleImageComponent::getNumberOfSlices() const {
return 0;
}
// -------------------- pixelPicked --------------------
void ArbitrarySingleImageComponent::pixelPicked(double x, double y, double z) {
// transform picked from this slice to the parent frame (i.e., the image)
double picked[4] = {x, y, z, 1.0};
double picked_P[4];
getTransform()->GetMatrix()->MultiplyPoint(picked, picked_P);
// synchronize all the other slices
getTransform()->GetMatrix()->MultiplyPoint(picked, picked_P);
// synchronize all the other orientations
((ImageComponent*)getParent())->pixelPicked(picked_P[0], picked_P[1], picked_P[2], this);
}
......
......@@ -623,7 +623,7 @@ void ImageComponent::pixelPicked(double x, double y, double z, SingleImageCompon
foreach (Component* dc, getChildren()) {
SingleImageComponent* child = dynamic_cast<SingleImageComponent*>(dc);
if (child) {
if (child != nullptr) {
child->setSlice(x, y, z);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment