Program: bbtk
Module: $RCSfile: bbvtkImagePlanes.cxx,v $
Language: C++
- Date: $Date: 2009/07/02 07:17:33 $
- Version: $Revision: 1.29 $
+ Date: $Date: 2010/03/07 13:18:41 $
+ Version: $Revision: 1.32 $
=========================================================================*/
/* ---------------------------------------------------------------------
};
//================================================================
- //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.29 $");
+ //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.32 $");
//================================================================
picker->SetTolerance(0.005);
// The 3 image plane widgets
- vtkImagePlaneWidget* planeWidgetX = vtkImagePlaneWidget::New();
- planeWidgetX->DisplayTextOn();
- planeWidgetX->SetPicker(picker);
- planeWidgetX->SetKeyPressActivationValue('x');
- vtkProperty* prop1 = planeWidgetX->GetPlaneProperty();
- prop1->SetColor(1, 0, 0);
-
- vtkImagePlaneWidget* planeWidgetY = vtkImagePlaneWidget::New();
- planeWidgetY->DisplayTextOn();
- planeWidgetY->SetPicker(picker);
- planeWidgetY->SetKeyPressActivationValue('y');
- vtkProperty* prop2 = planeWidgetY->GetPlaneProperty();
- prop2->SetColor(1, 1, 0);
+ vtkImagePlaneWidget* planeWidgetX = GetPlaneWidget('x', 1, 0, 0, picker);
+ vtkImagePlaneWidget* planeWidgetY = GetPlaneWidget('y', 1, 1, 0, picker);
planeWidgetY->SetLookupTable(planeWidgetX->GetLookupTable());
- vtkImagePlaneWidget* planeWidgetZ = vtkImagePlaneWidget::New();
- planeWidgetZ->DisplayTextOn();
- planeWidgetZ->SetPicker(picker);
- planeWidgetZ->SetKeyPressActivationValue('z');
- vtkProperty* prop3 = planeWidgetZ->GetPlaneProperty();
- prop3->SetColor(0, 0, 1);
+ vtkImagePlaneWidget* planeWidgetZ = GetPlaneWidget('z', 0, 0, 1, picker);
planeWidgetZ->SetLookupTable(planeWidgetX->GetLookupTable());
- vtkImagePlaneWidget* planeWidget3Pts = vtkImagePlaneWidget::New();
- //vtkPlaneWidget* planeWidget3Pts = vtkPlaneWidget::New();
- planeWidget3Pts->DisplayTextOn();
- planeWidget3Pts->SetPicker(picker);
- planeWidget3Pts->SetKeyPressActivationValue('3');
- vtkProperty* prop3Pts = planeWidget3Pts->GetPlaneProperty();
- prop3Pts->SetColor(0, 1, 1);
+ vtkImagePlaneWidget* planeWidget3Pts = GetPlaneWidget('3', 0, 1, 1, picker);
planeWidget3Pts->SetLookupTable(planeWidgetX->GetLookupTable());
bbSetOutputPlaneX(planeWidgetX);
bbSetOutputImageX(planeWidgetX->GetResliceOutput());
bbSetOutputImageY(planeWidgetY->GetResliceOutput());
bbSetOutputImageZ(planeWidgetZ->GetResliceOutput());
+ bbSetInputInteractor(0);
//bbSetOutputImage3Pts(planeWidget3Pts->GetResliceOutput());
picker->UnRegister(NULL);
0.5*(range[1]+range[0]));
}
+ updateInteractor();
+
}
// UPDATE DES SORTIES
bbGetOutputPlaneX()->GetResliceOutput()->Update();
std::vector<int> pointsy = bbGetInputPointsY();
std::vector<int> pointsz = bbGetInputPointsZ();
- std::cout<<pointsx.size()<<pointsy.size()<<pointsz.size()<<std::endl;
+ //std::cout<<pointsx.size()<<pointsy.size()<<pointsz.size()<<std::endl;
if(pointsx.size()==pointsy.size() && pointsx.size()==pointsz.size()&&pointsx.size()>=3){
+ //Get the corresponding three points out of the vectors
double origin[3];
origin[0] = pointsx[0];
origin[1] = pointsy[0];
point2[1]= pointsy[2];
point2[2]= pointsz[2];
+ //With the three points we create the corresponding X, Y and Z vectors all orthogonal to each other
double* vect1= getNormal(makeVector(origin, point1));
double* vect2= getNormal(makeVector(origin, point2));
double* crossp = getCrossProduct(vect1, vect2);
factor = ext[0]<ext[3]? ext[3] : ext[0];
factor = factor<ext[5]? ext[5] : factor;
-
+ //for the plane widgets
vtkImagePlaneWidget* plane3pts = (vtkImagePlaneWidget*)bbGetOutputPlane3Pts();
plane3pts->SetInput(bbGetInputIn());
double xSpacing, ySpacing, zSpacing;
(origin[1]+vect2[1]*factor)*ySpacing,
(origin[2]+vect2[2]*factor)*zSpacing);
plane3pts->GetResliceOutput()->Update();
-
+//To get the slice of image out of the selected volume
if (_imageReslicer==NULL){
_imageReslicer = vtkImageReslice::New();
_imageReslicer->SetOutputDimensionality(2);
}
_imageReslicer->SetInput( bbGetInputIn() );
_imageReslicer->SetInformationInput(bbGetInputIn());
- _imageReslicer->SetResliceAxesDirectionCosines(newx[0],newx[1],newx[2],
- vect2[0],vect2[1],vect2[2],
- crossp[0],crossp[1],crossp[2]);
+ //fill out the information with the created vectors and using the spacing of the image
+ _imageReslicer->SetResliceAxesDirectionCosines(newx[0]*xSpacing,newx[1]*xSpacing,newx[2]*xSpacing,
+ vect2[0]*ySpacing,vect2[1]*ySpacing,vect2[2]*ySpacing,
+ crossp[0]*zSpacing,crossp[1]*zSpacing,crossp[2]*zSpacing);
_imageReslicer->SetResliceAxesOrigin(origin[0]*xSpacing,origin[1]*ySpacing,origin[2]*zSpacing);
_imageReslicer->GetOutput()->Update();
_imageReslicer->GetOutput()->UpdateInformation();
_matrix->Identity();
- _matrix->SetElement(0,0,newx[0]);
- _matrix->SetElement(1,0,newx[1]);
- _matrix->SetElement(2,0,newx[2]);
- _matrix->SetElement(0,1,vect2[0]);
- _matrix->SetElement(1,1,vect2[1]);
- _matrix->SetElement(2,1,vect2[2]);
- _matrix->SetElement(0,2,crossp[0]);
- _matrix->SetElement(1,2,crossp[1]);
- _matrix->SetElement(2,2,crossp[2]);
- _matrix->SetElement(0,3,origin[0]);
- _matrix->SetElement(1,3,origin[1]);
- _matrix->SetElement(2,3,origin[2]);
+ _matrix->SetElement(0,0,newx[0]*xSpacing);
+ _matrix->SetElement(1,0,newx[1]*xSpacing);
+ _matrix->SetElement(2,0,newx[2]*xSpacing);
+ _matrix->SetElement(0,1,vect2[0]*ySpacing);
+ _matrix->SetElement(1,1,vect2[1]*ySpacing);
+ _matrix->SetElement(2,1,vect2[2]*ySpacing);
+ _matrix->SetElement(0,2,crossp[0]*zSpacing);
+ _matrix->SetElement(1,2,crossp[1]*zSpacing);
+ _matrix->SetElement(2,2,crossp[2]*zSpacing);
+ _matrix->SetElement(0,3,origin[0]*xSpacing);
+ _matrix->SetElement(1,3,origin[1]*ySpacing);
+ _matrix->SetElement(2,3,origin[2]*zSpacing);
_transform->SetMatrix(_matrix);
+ //set the transformation out to be used by other bbBoxes
bbSetOutputTransform3Pts((vtkLinearTransform*)_transform);
}
}
-
+void ImagePlanes::updateInteractor(){
+
+ vtkRenderWindowInteractor* interactor = bbGetInputInteractor();
+
+ if(interactor){
+ bbGetOutputPlaneX()->SetInteractor(interactor);
+ bbGetOutputPlaneX()->EnabledOn();
+ bbGetOutputPlaneY()->SetInteractor(interactor);
+ bbGetOutputPlaneY()->EnabledOn();
+ bbGetOutputPlaneZ()->SetInteractor(interactor);
+ bbGetOutputPlaneZ()->EnabledOn();
+ bbGetOutputPlane3Pts()->SetInteractor(interactor);
+ bbGetOutputPlane3Pts()->EnabledOn();
+ }
+}
//-----------------------------------------------------------------
void vtkImageDataPointerRelay::bbUserSetDefaultValues()
{
+
}
//-----------------------------------------------------------------
{
}
-
+ vtkImagePlaneWidget* ImagePlanes::GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker)
+ {
+ vtkProperty* prop1 = 0;
+ vtkImagePlaneWidget* planeWidget = 0;
+
+ planeWidget = vtkImagePlaneWidget::New();
+ planeWidget->DisplayTextOn();
+ planeWidget->SetPicker(picker);
+ planeWidget->SetKeyPressActivationValue(activationkey);
+ prop1 = planeWidget->GetPlaneProperty();
+ prop1->SetColor(r, g, b);
+
+ return planeWidget;
+ }
double* ImagePlanes::getCrossProduct(double* vect0,double* vect1){
double* vectCross;