#include "vtkImageViewer2_XYZ.h"
#include "vtkRenderer.h"
#include "vtkImageActor.h"
+#include "vtkImageData.h"
//-------------------------------------------------------------------
//-------------------------------------------------------------------
//-------------------------------------------------------------------
_vtkimageviewer2= vtkImageViewer2::New();
_vtkimageviewer2->GetRenderer()->GradientBackgroundOn();
_vtkimageviewer2->GetRenderer()->SetBackground( 0.33 , 0.33 , 0.33 );
- _vtkimageviewer2->GetRenderer()->SetBackground2( 0.66 , 0.66 , 0.66 );
+ _vtkimageviewer2->GetRenderer()->SetBackground2( 0.66 , 0.66 , 0.66 );
_colortable = NULL;
}
//-------------------------------------------------------------------
void vtkImageViewer2_XYZ::setColorTransferFunction(vtkColorTransferFunction* colortable){
+
vtkImageMapToWindowLevelColors* imagemaptowindowlevel = _vtkimageviewer2->GetWindowLevel();
if(colortable!=NULL&&colortable->GetSize()>0 && _colortable != colortable){
int GetXSlice();
int GetYSlice();
int GetZSlice();
- vtkImageViewer2 *GetVtkImageViewer2();
+
void setColorTransferFunction(vtkColorTransferFunction* colortable);
+ vtkImageViewer2 *GetVtkImageViewer2();
private:
int _x1,_x2,_y1,_y2,_z1,_z2;
vtkImageViewer2 *_vtkimageviewer2;
vtkColorTransferFunction* _colortable;
+
+
protected:
+
};
//---------------------------------------------------------------------------
void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z)
{
- vtkImageViewer2 *imageViewer = ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2();
+ if(((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ){
+ vtkImageViewer2 *imageViewer = ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->_imageViewer2XYZ->GetVtkImageViewer2();
- imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
- imageViewer->GetRenderer()->DisplayToWorld();
- double fP[4];
- imageViewer->GetRenderer()->GetWorldPoint( fP );
+ imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
+ imageViewer->GetRenderer()->DisplayToWorld();
+ double fP[4];
+ imageViewer->GetRenderer()->GetWorldPoint( fP );
- if ( fP[3] ){
- fP[0] /= fP[3];
- fP[1] /= fP[3];
- fP[2] /= fP[3];
- }
+ if ( fP[3] ){
+ fP[0] /= fP[3];
+ fP[1] /= fP[3];
+ fP[2] /= fP[3];
+ }
-// EEDx5
- ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
+ // EEDx5
+ ((wxVtk2DBaseView*)GetWxVtk2DBaseView())->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
- X=fP[0];
- Y=fP[1];
- Z=fP[2];
+ X=fP[0];
+ Y=fP[1];
+ Z=fP[2];
+ }
}
//---------------------------------------------------------------------------
void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
if(_vtkmprbasedata->GetImageData()){
_vtkmprbasedata->GetImageData()->GetScalarRange(range);
max = range[1];
- }else{
- max = 1;
- }
-
-
-
-
- _ctFunVectorPoint.clear();
- _ctFunVectorPoint.push_back(max*0/4);
- _ctFunVectorPoint.push_back(max*1/4);
- _ctFunVectorPoint.push_back(max*2/4);
- _ctFunVectorPoint.push_back(max*3/4);
- _ctFunVectorPoint.push_back(max*4/4);
-
- _ctFunVectorRed.clear();
- _ctFunVectorRed.push_back(0.0);
- _ctFunVectorRed.push_back(1.0);
- _ctFunVectorRed.push_back(0.0);
- _ctFunVectorRed.push_back(0.0);
- _ctFunVectorRed.push_back(0.0);
-
- _ctFunVectorGreen.clear();
- _ctFunVectorGreen.push_back(0.0);
- _ctFunVectorGreen.push_back(0.0);
- _ctFunVectorGreen.push_back(0.0);
- _ctFunVectorGreen.push_back(1.0);
- _ctFunVectorGreen.push_back(0.2);
-
- _ctFunVectorBlue.clear();
- _ctFunVectorBlue.push_back(0.0);
- _ctFunVectorBlue.push_back(0.0);
- _ctFunVectorBlue.push_back(1.0);
- _ctFunVectorBlue.push_back(0.0);
- _ctFunVectorBlue.push_back(0.0);
-
-
- if(_ctfun==NULL){
- _ctfun = vtkColorTransferFunction::New();
- }
- _ctfun->RemoveAllPoints();
-
- int i,size=_ctFunVectorPoint.size();
- for (i=0;i<size;i++)
- {
- _ctfun->AddRGBPoint( _ctFunVectorPoint[i] , _ctFunVectorRed[i],_ctFunVectorGreen[i],_ctFunVectorBlue[i]);
- }
-/*
- _ctfun->AddRGBPoint( 100 ,0 ,0,0);
- _ctfun->AddRGBPoint( 200 ,1 ,0,0);
- _ctfun->AddRGBPoint( 300 ,0 ,1,0);
- _ctfun->AddRGBPoint( 400 ,0 ,0,1);
-*/
-// void *p=this; // JPRx
-
- // Create the first of the three planes. The filter vtkImageMapToColors
- // maps the data through the corresponding lookup table created above. The
- // vtkImageActor is a type of vtkProp and conveniently displays an image on
- // a single quadrilateral plane. It does this using texture mapping and as
- // a result is quite fast. (Note: the input image has to be unsigned char
- // values, which the vtkImageMapToColors produces.) Note also that by
- // specifying the DisplayExtent, the pipeline requests data of this extent
- // and the vtkImageMapToColors only processes a slice of data.
-
- if(_saggitalColors==NULL){
- _saggitalColors = vtkImageMapToColors::New();
- }
- _saggitalColors->RemoveAllInputs();
-
- if(_vtkmprbasedata->GetImageData()){
+
+ _ctFunVectorPoint.clear();
+ _ctFunVectorPoint.push_back(max*0/4);
+ _ctFunVectorPoint.push_back(max*1/4);
+ _ctFunVectorPoint.push_back(max*2/4);
+ _ctFunVectorPoint.push_back(max*3/4);
+ _ctFunVectorPoint.push_back(max*4/4);
+
+ _ctFunVectorRed.clear();
+ _ctFunVectorRed.push_back(0.0);
+ _ctFunVectorRed.push_back(1.0);
+ _ctFunVectorRed.push_back(0.0);
+ _ctFunVectorRed.push_back(0.0);
+ _ctFunVectorRed.push_back(0.0);
+
+ _ctFunVectorGreen.clear();
+ _ctFunVectorGreen.push_back(0.0);
+ _ctFunVectorGreen.push_back(0.0);
+ _ctFunVectorGreen.push_back(0.0);
+ _ctFunVectorGreen.push_back(1.0);
+ _ctFunVectorGreen.push_back(0.2);
+
+ _ctFunVectorBlue.clear();
+ _ctFunVectorBlue.push_back(0.0);
+ _ctFunVectorBlue.push_back(0.0);
+ _ctFunVectorBlue.push_back(1.0);
+ _ctFunVectorBlue.push_back(0.0);
+ _ctFunVectorBlue.push_back(0.0);
+
+
+ if(_ctfun==NULL){
+ _ctfun = vtkColorTransferFunction::New();
+ }
+ _ctfun->RemoveAllPoints();
+
+ int i,size=_ctFunVectorPoint.size();
+ for (i=0;i<size;i++)
+ {
+ _ctfun->AddRGBPoint( _ctFunVectorPoint[i] , _ctFunVectorRed[i],_ctFunVectorGreen[i],_ctFunVectorBlue[i]);
+
+ }
+ /*
+ _ctfun->AddRGBPoint( 100 ,0 ,0,0);
+ _ctfun->AddRGBPoint( 200 ,1 ,0,0);
+ _ctfun->AddRGBPoint( 300 ,0 ,1,0);
+ _ctfun->AddRGBPoint( 400 ,0 ,0,1);
+ */
+ // void *p=this; // JPRx
+
+ // Create the first of the three planes. The filter vtkImageMapToColors
+ // maps the data through the corresponding lookup table created above. The
+ // vtkImageActor is a type of vtkProp and conveniently displays an image on
+ // a single quadrilateral plane. It does this using texture mapping and as
+ // a result is quite fast. (Note: the input image has to be unsigned char
+ // values, which the vtkImageMapToColors produces.) Note also that by
+ // specifying the DisplayExtent, the pipeline requests data of this extent
+ // and the vtkImageMapToColors only processes a slice of data.
+
+ if(_saggitalColors==NULL){
+ _saggitalColors = vtkImageMapToColors::New();
+ }
+ _saggitalColors->RemoveAllInputs();
_saggitalColors->SetInput( _vtkmprbasedata->GetImageData() );
- }
-// _saggitalColors->SetLookupTable(_bwLut);
-
- _saggitalColors->SetLookupTable(_ctfun);
-
+
+ // _saggitalColors->SetLookupTable(_bwLut);
+
+ _saggitalColors->SetLookupTable(_ctfun);
+
- if(_saggital==NULL){
- _saggital = vtkImageActor::New();
- _saggital->SetInput(_saggitalColors->GetOutput());
- }
- //_saggitalColors->Update();
-
+ if(_saggital==NULL){
+ _saggital = vtkImageActor::New();
+ _saggital->SetInput(_saggitalColors->GetOutput());
+ }
+ //_saggitalColors->Update();
+
- // Create the second (axial) plane of the three planes. We use the
- // same approach as before except that the extent differs.
+ // Create the second (axial) plane of the three planes. We use the
+ // same approach as before except that the extent differs.
-
- if(_axialColors==NULL){
- _axialColors = vtkImageMapToColors::New();
- }
+
+ if(_axialColors==NULL){
+ _axialColors = vtkImageMapToColors::New();
+ }
- _axialColors->RemoveAllInputs();
- if(_vtkmprbasedata->GetImageData()){
+ _axialColors->RemoveAllInputs();
_axialColors->SetInput( _vtkmprbasedata->GetImageData() );
- }
-// _axialColors->SetLookupTable(_hueLut);
- _axialColors->SetLookupTable(_ctfun);
+ // _axialColors->SetLookupTable(_hueLut);
+ _axialColors->SetLookupTable(_ctfun);
- if(_axial==NULL){
- _axial = vtkImageActor::New();
- _axial->SetInput(_axialColors->GetOutput());
- }
+ if(_axial==NULL){
+ _axial = vtkImageActor::New();
+ _axial->SetInput(_axialColors->GetOutput());
+ }
+
+ //_axialColors->Update();
- //_axialColors->Update();
-
- // Create the third (coronal) plane of the three planes. We use
- // the same approach as before except that the extent differs.
- if(_coronalColors==NULL){
- _coronalColors = vtkImageMapToColors::New();
- }
- _coronalColors->RemoveAllInputs();
- if(_vtkmprbasedata->GetImageData()){
+ // Create the third (coronal) plane of the three planes. We use
+ // the same approach as before except that the extent differs.
+ if(_coronalColors==NULL){
+ _coronalColors = vtkImageMapToColors::New();
+ }
+ _coronalColors->RemoveAllInputs();
_coronalColors->SetInput( _vtkmprbasedata->GetImageData() );
- }
-// _coronalColors->SetLookupTable(_satLut);
- _coronalColors->SetLookupTable(_ctfun);
+ // _coronalColors->SetLookupTable(_satLut);
+ _coronalColors->SetLookupTable(_ctfun);
- if(_coronal==NULL){
- _coronal = vtkImageActor::New();
- _coronal->SetInput(_coronalColors->GetOutput());
- }
+ if(_coronal==NULL){
+ _coronal = vtkImageActor::New();
+ _coronal->SetInput(_coronalColors->GetOutput());
+ }
+
-
- // An outline provides context around the data.
- //
- if(_outlineData==NULL){
- _outlineData = vtkOutlineFilter::New();
- }
- _outlineData->RemoveAllInputs();
- if(_vtkmprbasedata->GetImageData()){
- _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() );
+ // An outline provides context around the data.
+ //
+ if(_outlineData==NULL){
+ _outlineData = vtkOutlineFilter::New();
+ }
+ _outlineData->RemoveAllInputs();
+ if(_vtkmprbasedata->GetImageData()){
+ _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() );
+ }
+
+ if(_mapOutline==NULL){
+ _mapOutline = vtkPolyDataMapper::New();
+ _mapOutline->SetInput(_outlineData->GetOutput());
+ }
+ _mapOutline->Update();
+ //_mapOutline->RemoveAllInputs();
+
+ if(_outline==NULL){
+ _outline = vtkActor::New();
+ _outline->SetMapper(_mapOutline);
+ _outline->GetProperty()->SetColor(0,0,0);
+ }
}
+
+
- if(_mapOutline==NULL){
- _mapOutline = vtkPolyDataMapper::New();
- _mapOutline->SetInput(_outlineData->GetOutput());
- }
- _mapOutline->Update();
- //_mapOutline->RemoveAllInputs();
-
- if(_outline==NULL){
- _outline = vtkActor::New();
- _outline->SetMapper(_mapOutline);
- _outline->GetProperty()->SetColor(0,0,0);
- }
+
void vtkMPR3DDataViewer::SetPositionX(int pos){
int x1,x2,y1,y2,z1,z2;
_vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
- _saggital->SetDisplayExtent( pos , pos , y1 ,y2 , z1 , z2 );
+ if(_saggital){
+ _saggital->SetDisplayExtent( pos , pos , y1 ,y2 , z1 , z2 );
+ }
}
//------------------------------------------------------------------------
void vtkMPR3DDataViewer::SetPositionY(int pos){
int x1,x2,y1,y2,z1,z2;
_vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
- _coronal->SetDisplayExtent(x1,x2, pos,pos, z1,z2);
+ if(_coronal){
+ _coronal->SetDisplayExtent(x1,x2, pos,pos, z1,z2);
+ }
}
//------------------------------------------------------------------------
void vtkMPR3DDataViewer::SetPositionZ(int pos){
int x1,x2,y1,y2,z1,z2;
_vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
- _axial->SetDisplayExtent(x1,x2, y1,y2, pos,pos);
+ if(_axial){
+ _axial->SetDisplayExtent(x1,x2, y1,y2, pos,pos);
+ }
}
//-------------------------------------------------------------------
void vtkMPR3DDataViewer::SetVisiblePosition(int idPosition, bool visible)
}
void vtkMPR3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
- _saggitalColors->SetLookupTable(colortable);
- _coronalColors->SetLookupTable(colortable);
- _axialColors->SetLookupTable(colortable);
+ if(_saggitalColors){
+ _saggitalColors->SetLookupTable(colortable);
+ _coronalColors->SetLookupTable(colortable);
+ _axialColors->SetLookupTable(colortable);
+ }
}
Program: wxMaracas
Module: $RCSfile: wxMaracas_N_ViewersWidget.cxx,v $
Language: C++
- Date: $Date: 2010/08/04 18:45:27 $
- Version: $Revision: 1.18 $
+ Date: $Date: 2010/08/25 17:51:12 $
+ Version: $Revision: 1.19 $
Copyright: (c) 2002, 2003
License:
extent[2] = 0;
extent[3] = 1;
extent[4] = 0;
- extent[5] = 1;
+ extent[5] = 0;
imagedata = vtkImageData::New();
imagedata->SetSpacing(spc);
imagedata->SetExtent(extent);
- imagedata->SetScalarTypeToUnsignedShort();
+ imagedata->SetScalarTypeToUnsignedChar();
imagedata->AllocateScalars();
}*/
if (wxwindow2!=NULL) { wxwindow2->SetImage(image); }
if (wxwindow3!=NULL) { wxwindow3->SetImage(image); }
if (wxwindow4!=NULL) { wxwindow4->SetImage(image); }
-
ConfigureVTK();
}
Program: wxMaracas
Module: $RCSfile: wxMaracas_ViewerWidget.cxx,v $
Language: C++
- Date: $Date: 2010/08/21 15:19:14 $
- Version: $Revision: 1.29 $
+ Date: $Date: 2010/08/25 17:51:12 $
+ Version: $Revision: 1.30 $
Copyright: (c) 2002, 2003
License:
if ( mwidgetMesure !=NULL ) { mwidgetMesure->SetActiveLink(true); }
if ( mwidgetMesure !=NULL ) { mwidgetMesure->SetMesureScale( 1 ); }
if ( mwxsphereview !=NULL ) { mwxsphereview->Configure(); }
+
if (mwxvtk3Dbaseview_Clipping3D !=NULL)
{
if (vtkmpr3Ddataviewer !=NULL)
{
vtkmpr3Ddataviewer->Configure();
+
}
+
+
if (mwxvtkmpr3Dview !=NULL)
{
+
mwxvtkmpr3Dview->Configure();
mwxvtkmpr3Dview->ResetCamera(ext,org,spc);
}
{
mwxvtkclipping3Dview->Configure();
}
+
+
+ if (mwxvtkclipping3Dview !=NULL) { mwxvtkclipping3Dview->Configure(); }
+
//if(vtkmpr3Ddataviewer!=NULL){vtkmpr3Ddataviewer->Configure();}
// RefreshView();
//-------------------------------------------------------------------------
void wxMaracas_ViewerWidget::RefreshView()
{
-
if (mvtk2Dbaseview !=NULL ){ mvtk2Dbaseview->Refresh(); }
if (mvtkmpr2Dview_X !=NULL ){ mvtkmpr2Dview_X->Refresh(); }
if (mvtkmpr2Dview_Y !=NULL ){ mvtkmpr2Dview_Y->Refresh(); }
Program: Visualization Toolkit
Module: $RCSfile: wxVTKRenderWindowInteractor.cxx,v $
Language: C++
- Date: $Date: 2009/05/14 13:54:35 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2010/08/25 17:51:12 $
+ Version: $Revision: 1.4 $
Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
//std::cout << "wxVTKRenderWindowInteractor::OnPaint"<<std::endl;
Render();
+ // this->Refresh();
#if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
// bbtkDebugMessage("Core",9,"wxVTKRenderWindowInteractor::OnPaint public wxGLCanvas, virtual public vtkRenderWindowInteractor \n");
#else
vtkImageData *imageData = GetVtkBaseData()->GetMarImageData()->GetImageData();
if (imageData!=NULL){
+
imageData->UpdateInformation();
imageData->SetUpdateExtent( imageData->GetWholeExtent());
imageData->Update();
//class vtkInteractorStyleBaseView;
#include "vtkInteractorStyleBaseView.h"
+#include "vtkInteractorStyleBaseView2D.h"
class vtkInfoTextImage;
class vtkInfoTextImageInteractor;
vtkInfoTextImage *_vtkIinfoTextImage;
vtkInfoTextImageInteractor *_vtkIinfoTextImageInteractor;
+ vtkInteractorStyleBaseView2D * _style2D;
protected:
//-------------------------------------------------------------------
void wxVtkMPR2DView::Configure(){
wxVtk2DBaseView::Configure();
-
- if(_interactorstylemprview==NULL)
- {
- _interactorstylemprview = new vtkInteractorStyleMPRView();
- ((vtkInteractorStyleBaseView*)GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _interactorstylemprview );
- }
-
int x1,x2,y1,y2,z1,z2;
double spc[3];
vtkImageData* img = GetVtkmprbasedata()->GetImageData();
+ if(_interactorstylemprview==NULL)
+ {
+ _interactorstylemprview = new vtkInteractorStyleMPRView();
+ ((vtkInteractorStyleBaseView*)GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _interactorstylemprview );
+ }
+
if(img!=NULL){
double* origin = img->GetOrigin();
img->GetExtent(x1,x2,y1,y2,z1,z2);
z2 = (int)(z2*spc[2]);
_visibleAxis = true;
+
+
+
}
// Axe A
_lineAMapper->SetInput(_pdA);
_lineAMapper->ImmediateModeRenderingOn();
_lineAActor->SetMapper(_lineAMapper);
-
- _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
}
vtkCellArray *linesA = vtkCellArray::New();
linesA->Delete(); //do not delete lines ??
// _lineAActor->GetProperty()->BackfaceCullingOn();
-
-
-
-
// Axe B
if(_lineBActor==NULL){
_ptsB->SetPoint(1, 1000 , 1000 , 1000 );
// _lineBActor->GetProperty()->BackfaceCullingOn();
-
- _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
}
vtkCellArray *linesB;
_lineBMapper->ImmediateModeRenderingOn();
- vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
-
-//EED 17Avril2009
-/*
- if (_direction==0) {
- camera->SetViewUp ( 0 , -1 , 0 );
- camera->SetPosition ( -10000,(y1+y2)/2 , (z1+z2)/2 );
- camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
- camera->SetParallelScale( (z2-z1)/3.0 );
- }
+ if(_imageViewer2XYZ){
+ _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
+ _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
+ vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
+
+ //EED 17Avril2009
+ /*
+ if (_direction==0) {
+ camera->SetViewUp ( 0 , -1 , 0 );
+ camera->SetPosition ( -10000,(y1+y2)/2 , (z1+z2)/2 );
+ camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
+ camera->SetParallelScale( (z2-z1)/3.0 );
+ }
- if (_direction==1) {
- camera->SetViewUp ( 0 , 0 , -1 );
- camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
- camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
- camera->SetParallelScale( (x2-x1)/3.0 );
- }
+ if (_direction==1) {
+ camera->SetViewUp ( 0 , 0 , -1 );
+ camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
+ camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
+ camera->SetParallelScale( (x2-x1)/3.0 );
+ }
- if (_direction==2) {
- camera->SetViewUp ( 0 , -1 , 0 );
- camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , -10000);
- camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
- camera->SetParallelScale( (x2-x1)/3.0 );
- }
-*/
+ if (_direction==2) {
+ camera->SetViewUp ( 0 , -1 , 0 );
+ camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , -10000);
+ camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
+ camera->SetParallelScale( (x2-x1)/3.0 );
+ }
+ */
- if (_direction==0) { // YZ
- camera->SetViewUp ( 0 , 1 , 0 );
- camera->SetPosition ( 10000,(y1+y2)/2 , (z1+z2)/2 );
- camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
- camera->SetParallelScale( (z2-z1)/3.0 );
- }
-
- if (_direction==1) { // XZ
- camera->SetViewUp ( 0 , 0 , -1 );
- camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
- camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
- camera->SetParallelScale( (x2-x1)/3.0 );
- }
-
- if (_direction==2) { // XY
- camera->SetViewUp ( 0 , 1 , 0 );
- camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , 10000);
- camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
- camera->SetParallelScale( (x2-x1)/3.0 );
- }
-
+ if (_direction==0) { // YZ
+ camera->SetViewUp ( 0 , 1 , 0 );
+ camera->SetPosition ( 10000,(y1+y2)/2 , (z1+z2)/2 );
+ camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
+ camera->SetParallelScale( (z2-z1)/3.0 );
+ }
+
+ if (_direction==1) { // XZ
+ camera->SetViewUp ( 0 , 0 , -1 );
+ camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
+ camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
+ camera->SetParallelScale( (x2-x1)/3.0 );
+ }
+
+ if (_direction==2) { // XY
+ camera->SetViewUp ( 0 , 1 , 0 );
+ camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , 10000);
+ camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
+ camera->SetParallelScale( (x2-x1)/3.0 );
+ }
+
-// _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160);
-// _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800);
+ // _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160);
+ // _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800);
+ }
}
if ((x!=_backX) || (y!=_backY) || (z!=_backZ)) {
if (_direction==0) { // YZ
- _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) );
+ if(_imageViewer2XYZ)
+ _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) );
_ptsA->SetPoint(0, x2, y1 , z );
_ptsA->SetPoint(1, x2, y2 , z );
_ptsB->SetPoint(0, x2, y , z1);
_ptsB->SetPoint(1, x2, y , z2);
}
if (_direction==1) { // XZ
- _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) );
+ if(_imageViewer2XYZ)
+ _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) );
_ptsA->SetPoint(0, x1 , y2 , z );
_ptsA->SetPoint(1, x2 , y2 , z );
_ptsB->SetPoint(0, x , y2 , z1);
_ptsB->SetPoint(1, x , y2 , z2);
}
if (_direction==2) { // XY
- _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
- _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
+ if(_imageViewer2XYZ)
+ _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
// _ptsA->SetPoint(0, x1 , y , -z2 );
// _ptsA->SetPoint(1, x2 , y , -z2 );
// _ptsB->SetPoint(0, x , y1, -z2 );
_probe = NULL;
_contourMapper = NULL;
-
+ _planeWidgetX = 0;
+ _planeWidgetY = 0;
+ _planeWidgetZ = 0;
//EED Fev 3 2010
//Free Planes
}
//}
vtkmyPWCallback_3DPointWidget *_myCallback = vtkmyPWCallback_3DPointWidget::New();
_myCallback->SetWxVtkMPR3DView(this);
-
- if(_pointWidget!=NULL){
- _pointWidget->Delete();
- }
- _pointWidget = vtkPointWidget::New();
- _myCallback->SetVtkPointWidget(_pointWidget);
- _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
- if(imageData){
- _pointWidget->SetInput( imageData );
- }
- _pointWidget->AllOff();
-
- _pointWidget->PlaceWidget();
-// _pointWidget->SetPosition( x,y,z );
-
-//EED01 29Mars2009
-// MACOS probleme vtk-window out of wx-window
-// _pointWidget->On();
-
- _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
-
-
-// PlaneWidget
- if(_planeWidget!=NULL)
- {
- _planeWidget->Delete();
- }
- _planeWidget = vtkPlaneWidget::New();
- _myCallback->SetVtkPlaneWidget(_planeWidget);
if(imageData){
+ if(_pointWidget==NULL){
+ _pointWidget = vtkPointWidget::New();
+ }
+ _pointWidget->SetInput( imageData );
+ _myCallback->SetVtkPointWidget(_pointWidget);
+ _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
+ _pointWidget->AllOff();
+ _pointWidget->PlaceWidget();
+
+ _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
+
+
+ if(_planeWidget==NULL)
+ {
+ _planeWidget = vtkPlaneWidget::New();
+ }
_planeWidget->SetInput( imageData );
- }
- _planeWidget->NormalToXAxisOn();
- _planeWidget->SetResolution(50);
- _planeWidget->SetRepresentationToOutline();
- int dim[3];
- if(imageData){
- imageData->GetDimensions(dim);
- }else{
- dim[0] = 0;
- dim[1] = 0;
- dim[2] = 0;
- }
- int px=(dim[0]/2);
- int py=(dim[1]/2);
- int pz=(dim[2]/2);
- int dd=20;
- _planeWidget->PlaceWidget( px-dd , px+dd , py-dd , py+dd , pz-dd , pz+dd );
-
-
- if(_vtkplane==NULL){
- _vtkplane = vtkPolyData::New();
- _probe = vtkProbeFilter::New();
- _probe->SetInput(_vtkplane);
+ _myCallback->SetVtkPlaneWidget(_planeWidget);
- _contourMapper = vtkPolyDataMapper::New();
+ _planeWidget->NormalToXAxisOn();
+ _planeWidget->SetResolution(50);
+ _planeWidget->SetRepresentationToOutline();
+
+ int dim[3];
+
+ imageData->GetDimensions(dim);
+ int px=(dim[0]/2);
+ int py=(dim[1]/2);
+ int pz=(dim[2]/2);
+ int dd=20;
+ _planeWidget->PlaceWidget( px-dd , px+dd , py-dd , py+dd , pz-dd , pz+dd );
- _contourMapper->SetInput( _probe->GetPolyDataOutput() );
+ if(_vtkplane==NULL){
+ _vtkplane = vtkPolyData::New();
+
+ _probe = vtkProbeFilter::New();
+ _probe->SetInput(_vtkplane);
- _contourPlaneActor = vtkActor::New();
- _contourPlaneActor->SetMapper(_contourMapper);
+ _contourMapper = vtkPolyDataMapper::New();
+
+ _contourMapper->SetInput( _probe->GetPolyDataOutput() );
- _contourPlaneActor->VisibilityOff();
+ _contourPlaneActor = vtkActor::New();
+ _contourPlaneActor->SetMapper(_contourMapper);
- _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
- _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
+ _contourPlaneActor->VisibilityOff();
- _planeWidget->Off();
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
+ _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
+ _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
- }
+ _planeWidget->Off();
+ _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
- _planeWidget->GetPolyData(_vtkplane);
- if(imageData){
+ }
+
+ _planeWidget->GetPolyData(_vtkplane);
_probe->SetSource( imageData );
_contourMapper->SetScalarRange( imageData->GetScalarRange() );
+
+
+ ConfigureFreePlanes();
}
- ConfigureFreePlanes();
+// _pointWidget->SetPosition( x,y,z );
+
+//EED01 29Mars2009
+// MACOS probleme vtk-window out of wx-window
+// _pointWidget->On();
+
+
+
+
+// PlaneWidget
+
+
+
+
+
+
+
+
+
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
void wxVtkMPR3DView::FreePlaneVisible(int plane, bool ok)
{
-
- if ((plane==1) && (ok==true)) _planeWidgetX->EnabledOn();
- if ((plane==2) && (ok==true)) _planeWidgetY->EnabledOn();
- if ((plane==3) && (ok==true)) _planeWidgetZ->EnabledOn();
- if ((plane==1) && (ok==false)) _planeWidgetX->EnabledOff();
- if ((plane==2) && (ok==false)) _planeWidgetY->EnabledOff();
- if ((plane==3) && (ok==false)) _planeWidgetZ->EnabledOff();
+ if(_planeWidgetX){
+ if ((plane==1) && (ok==true)) _planeWidgetX->EnabledOn();
+ if ((plane==2) && (ok==true)) _planeWidgetY->EnabledOn();
+ if ((plane==3) && (ok==true)) _planeWidgetZ->EnabledOn();
+ if ((plane==1) && (ok==false)) _planeWidgetX->EnabledOff();
+ if ((plane==2) && (ok==false)) _planeWidgetY->EnabledOff();
+ if ((plane==3) && (ok==false)) _planeWidgetZ->EnabledOff();
+ }
}
//-------------------------------------------------------------------
void wxVtkMPR3DView::FreePlaneInteraction(bool ok)
{
- if (ok==true)
- {
- _planeWidgetX->InteractionOn();
- _planeWidgetY->InteractionOn();
- _planeWidgetZ->InteractionOn();
- } else {
- _planeWidgetX->InteractionOff();
- _planeWidgetY->InteractionOff();
- _planeWidgetZ->InteractionOff();
+ if(_planeWidgetX){
+ if (ok==true)
+ {
+ _planeWidgetX->InteractionOn();
+ _planeWidgetY->InteractionOn();
+ _planeWidgetZ->InteractionOn();
+ } else {
+ _planeWidgetX->InteractionOff();
+ _planeWidgetY->InteractionOff();
+ _planeWidgetZ->InteractionOff();
+ }
}
}
y=y*spc[1];
z=z*spc[2];
- _pointWidget->SetPosition( x,y,z );
+ if(_pointWidget){
+ _pointWidget->SetPosition( x,y,z );
- double in[3];
- double normal[3];
- vtkTransform *transform = GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetTransformOrientation();
- in[0]=1; in[1]=0; in[2]=0;
- transform->TransformPoint(in,normal);
- _planeWidget->SetNormal( normal[0],normal[1],normal[2] );
+ double in[3];
+ double normal[3];
+ vtkTransform *transform = GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetTransformOrientation();
+ in[0]=1; in[1]=0; in[2]=0;
+ transform->TransformPoint(in,normal);
+ _planeWidget->SetNormal( normal[0],normal[1],normal[2] );
- _planeWidget->SetCenter( x,y,z );
- _planeWidget->UpdatePlacement();
- _planeWidget->GetPolyData(_vtkplane);
+ _planeWidget->SetCenter( x,y,z );
+ _planeWidget->UpdatePlacement();
+ _planeWidget->GetPolyData(_vtkplane);
+ }
}
//-------------------------------------------------------------------
wxPanel* wxVtkMPR3DView::CreateControlPanel(wxWindow *parent, bool align)
//-------------------------------------------------------------------
void wxVtkMPR3DView::VisiblePointWidget( bool visible )
{
- if (visible==true)
- {
- _pointWidget->On();
- } else {
- _pointWidget->Off();
+ if(_pointWidget){
+ if (visible==true)
+ {
+ _pointWidget->On();
+ } else {
+ _pointWidget->Off();
+ }
}
}
//-------------------------------------------------------------------
void wxVtkMPR3DView::VisiblePlaneWidget( bool visible )
{
- if (visible==true)
- {
- _planeWidget->On();
- _contourPlaneActor->VisibilityOn();
+ if(_planeWidget){
+ if (visible==true)
+ {
+ _planeWidget->On();
+ _contourPlaneActor->VisibilityOn();
- } else {
- _planeWidget->Off();
- _contourPlaneActor->VisibilityOff();
+ } else {
+ _planeWidget->Off();
+ _contourPlaneActor->VisibilityOff();
+ }
}
}
int maxY = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
int maxZ = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();*/
- int maxX = 1;
- int maxY = 1;
- int maxZ = 1;
+ //int maxX = 1;
+ //int maxY = 1;
+ //int maxZ = 1;
//CPR: Modified 30 Nov 2009
/*
*/
ckBoxX = new wxCheckBox(panel,-1,_T("X "));
- _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxSize(300,40), wxSL_HORIZONTAL | wxSL_LABELS);
+ _positionX = new wxSlider(panel,-1,0,0,1, wxDefaultPosition, wxSize(300,40), wxSL_HORIZONTAL | wxSL_LABELS);
ckBoxY = new wxCheckBox(panel,-1,_T("Y "));
- _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxSize(300,40), wxSL_HORIZONTAL | wxSL_LABELS);
+ _positionY = new wxSlider(panel,-1,0,0,1, wxDefaultPosition, wxSize(300,40), wxSL_HORIZONTAL | wxSL_LABELS);
ckBoxZ = new wxCheckBox(panel,-1,_T("Z "));
- _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxSize(300,40), wxSL_HORIZONTAL | wxSL_LABELS);
+ _positionZ = new wxSlider(panel,-1,0,0,1, wxDefaultPosition, wxSize(300,40), wxSL_HORIZONTAL | wxSL_LABELS);
wxButton *btnColorTable = new wxButton (panel, -1, _T("Color Table") );
_ckBoxXYZ = new wxCheckBox(panel,-1,_T("Show XYZ axis "));
panel->Layout();
panel->SetEventHandler((wxEvtHandler*)this);
-
+
//this->UpdateControlPanel();
}
void wxVtkMPR3DViewCntrlPanel::UpdateControlPanel()
/*int maxX = basedata->GetMaxPositionX();
int maxY = basedata->GetMaxPositionY();
int maxZ = basedata->GetMaxPositionZ();*/
+ vtkImageData* img = basedata->GetImageData();
int x0,x1,y0,y1,z0,z1;
-
- basedata->GetDimensionExtention(&x0,&x1,&y0,&y1,&z0,&z1);
/*int maxX = x1-x0;//basedata->GetMaxPositionX();
int maxY = y1-y0;//basedata->GetMaxPositionY();
int maxZ = z1-z0;//basedata->GetMaxPositionZ();*/
/*_positionX->SetRange(0,maxX);
_positionY->SetRange(0,maxY);
_positionZ->SetRange(0,maxZ);*/
- _positionX->SetRange(x0,x1);
- _positionY->SetRange(y0,y1);
- _positionZ->SetRange(z0,z1);
-
- _positionX->SetValue((x0+x1)/2);
- _positionY->SetValue((y0+y1)/2);
- _positionZ->SetValue((z0+z1)/2);
-
- _positionX->Update();
- _positionY->Update();
- _positionZ->Update();
- this->Update();
+ if(img){
+ img->GetExtent(x0,x1,y0,y1,z0,z1);
+ _positionX->SetRange(x0,x1);
+ _positionY->SetRange(y0,y1);
+ _positionZ->SetRange(z0,z1);
+
+ _positionX->SetValue((x0+x1)/2);
+ _positionY->SetValue((y0+y1)/2);
+ _positionZ->SetValue((z0+z1)/2);
+
+ _positionX->Update();
+ _positionY->Update();
+ _positionZ->Update();
+ this->Update();
+ }
+
}
}
mag = sqrt(pow(vect[0],2) + pow(vect[1],2) + pow(vect[2],2));
- std::cout<<"mag "<<mag <<std::endl;
+ //std::cout<<"mag "<<mag <<std::endl;
return mag;
}