#include "wxVtkBaseView.h"
+
vtkStandardNewMacro(vtkInteractorStyleBaseView);
vtkStandardNewMacro(vtkInteractorStyleBaseView2D);
vtkStandardNewMacro(vtkInteractorStyleBaseView3D);
//-------------------------------------------------------------------
vtkImageViewer2_XYZ::~vtkImageViewer2_XYZ()
{
- _vtkimageviewer2->Delete();
+ //_vtkimageviewer2->Delete();
}
//-------------------------------------------------------------------
void vtkImageViewer2_XYZ::SetExtentDimension(int x1,int x2,
wxVtkBaseView::~wxVtkBaseView()
{
// _iren -> Delete();
+ _iren=NULL;
}
//-------------------------------------------------------------------
-wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor()
+wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor() throw (char*)
{
+
+ if(_iren==NULL){
+ throw "wxVtkBaseView::GetWxVTKRenderWindowInteractor() _iren wxVTKRenderWindowInteractorPlus =NULL";
+ }
return _iren;
}
//-------------------------------------------------------------------
#if defined(WIN32)
_iren->Refresh(false);
#else
- _iren->Render();
+
+//EED 01Avril2009
+// _iren->Render();
+ vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
+ vri->vtkRenderWindowInteractor::Render();
+
+
//_iren->Refresh();
#endif
bool vtkInteractorScrollZ::OnMouseMove ()
{
if (_stateFordware==true){
- int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
+ //int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0]; // JPRx
int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
int delta = (_fordwareY - fy)/3;
_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->SetActualSlice( _sliceZ + delta);
// this->vtkInteractorStyleTrackballCamera::OnMouseMove();
- int x = this->Interactor->GetEventPosition()[0];
- int y = this->Interactor->GetEventPosition()[1];
+ // int x = this->Interactor->GetEventPosition()[0]; // JPRx
+ // int y = this->Interactor->GetEventPosition()[1]; // JPRx
- vtkRenderWindowInteractor *rwi = this->Interactor;
+ // vtkRenderWindowInteractor *rwi = this->Interactor;
- int lx = rwi->GetLastEventPosition()[0];
- int ly = rwi->GetLastEventPosition()[1];
- int dx = rwi->GetEventPosition()[0] ;
- int dy = rwi->GetEventPosition()[1] ;
+ // int lx = rwi->GetLastEventPosition()[0]; // JPRx
+ // int ly = rwi->GetLastEventPosition()[1]; // JPRx
+ // int dx = rwi->GetEventPosition()[0] ; // JPRx
+ // int dy = rwi->GetEventPosition()[1] ; // JPRx
switch (this->State)
// Text Window Level
vtkTextActor *textActor = vtkTextActor::New();
textActor->SetDisplayPosition(px, py);
- textActor->SetInput("--");
+ textActor->SetInput("0");
// Set coordinates to match the old vtkScaledTextActor default value
textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
char zTzxt[20];
char resultText[50];
- strcpy(resultText,"NG: ");
- if (ok==true) {
- unsigned short *pOrg=(unsigned short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
-// itoa (*pOrg,zTzxt,10);
- int tmp=*pOrg;
- sprintf(zTzxt,"%d",tmp);
-
- } else {
+ strcpy(resultText,"GL: ");
+ if (ok==true)
+ {
+ if (imagedata->GetScalarType()==VTK_BIT)
+ {
+ char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ if(*pOrg==0)
+ {
+ sprintf(zTzxt,"%d",0);
+ }
+ else
+ {
+ sprintf(zTzxt,"%d",1);
+ }
+ }
+
+ if (imagedata->GetScalarType()==VTK_CHAR)
+ {
+ char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ int tmp=*pOrg;
+ sprintf(zTzxt,"%d",tmp);
+ }
+
+ if (imagedata->GetScalarType()==VTK_SIGNED_CHAR)
+ {
+ signed char *pOrg=(signed char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ int tmp=*pOrg;
+ sprintf(zTzxt,"%d",tmp);
+ }
+
+ if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR)
+ {
+ unsigned char *pOrg=(unsigned char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ int tmp=*pOrg;
+ sprintf(zTzxt,"%d",tmp);
+ }
+
+ if (imagedata->GetScalarType()==VTK_SHORT)
+ {
+ short *pOrg=(short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ int tmp=*pOrg;
+ sprintf(zTzxt,"%d",tmp);
+ }
+
+ if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT)
+ {
+ unsigned short *pOrg=(unsigned short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ int tmp=*pOrg;
+ sprintf(zTzxt,"%d",tmp);
+ }
+
+ if (imagedata->GetScalarType()==VTK_INT)
+ {
+ int *pOrg=(int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ sprintf(zTzxt,"%d",*pOrg);
+ }
+
+ if (imagedata->GetScalarType()==VTK_UNSIGNED_INT)
+ {
+ unsigned int *pOrg=(unsigned int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ int tmp=*pOrg;
+ sprintf(zTzxt,"%d",tmp);
+ }
+
+ if (imagedata->GetScalarType()==VTK_LONG)
+ {
+ long *pOrg=(long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ double tmp=*pOrg;
+ sprintf(zTzxt,"%3.2f",tmp);
+ }
+
+ if (imagedata->GetScalarType()==VTK_UNSIGNED_LONG)
+ {
+ unsigned long *pOrg=(unsigned long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ double tmp=*pOrg;
+ sprintf(zTzxt,"%3.2f",tmp);
+ }
+
+ if (imagedata->GetScalarType()==VTK_FLOAT)
+ {
+ long *pOrg=(long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ double tmp=*pOrg;
+ sprintf(zTzxt,"%3.2f",tmp);
+ }
+
+ if (imagedata->GetScalarType()==VTK_DOUBLE)
+ {
+ double *pOrg=(double*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
+ // itoa (*pOrg,zTzxt,10);
+ double tmp=*pOrg;
+ sprintf(zTzxt,"%3.2f",tmp);
+ }
+ }
+ else
+ {
strcpy(zTzxt,"---");
}
strcat(resultText,zTzxt);
double xx=X,yy=Y,zz=z;
_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->TransfromeCoordScreenToWorld(xx,yy,zz);
+
GetVtkInfoTextImage()->PutWindowLevel();
GetVtkInfoTextImage()->PutColorLevel();
GetVtkInfoTextImage()->PutPosition( (int)xx , (int)yy , (int)zz );
_vtkIinfoTextImage = NULL;
}
+//EED 5mai2009
//-------------------------------------------------------------------
wxVtk2DBaseView::~wxVtk2DBaseView()
-{
- if (_imageViewer2XYZ!=NULL) {
- delete _imageViewer2XYZ;
- }
-
- if (_imageViewer2XYZ!=NULL) {
+{
+ if (_vtkIinfoTextImage!=NULL)
+ {
delete _vtkIinfoTextImage;
}
+ if (_imageViewer2XYZ!=NULL)
+ {
+ delete _imageViewer2XYZ;
+ }
}
//-------------------------------------------------------------------
_imageViewer2XYZ -> SetExtentDimension(x1,x2,y1,y2,z1,z2);
_imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren );
-printf("EED wxVtk2DBaseView::ResetView podemos 01\n ");
_imageViewer2XYZ->GetVtkImageViewer2()->Render();
-printf("EED wxVtk2DBaseView::ResetView podemos 02\n ");
-
SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
}
vtkImageViewer2 *IV2=_imageViewer2XYZ->GetVtkImageViewer2();
vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera();
+
+//EED 17Avril2009
+/*
camera->SetViewUp ( spx*0 , -spy*1 , spz*0 );
camera->SetPosition ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , -spz*10000 );
camera->SetFocalPoint ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0 );
+*/
+ camera->SetViewUp ( spx*0 , spy*1 , spz*0 );
+ camera->SetPosition ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*10000 );
+ camera->SetFocalPoint ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0 );
+
+
camera->SetClippingRange( 0.01 , 1000000 );
camera->ComputeViewPlaneNormal();
camera->SetParallelScale( spx*(x2-x1)/3.0 );
-
+
// text information over the graphic window
_vtkIinfoTextImage = new vtkInfoTextImage();
_vtkIinfoTextImageInteractor = new vtkInfoTextImageInteractor();
iren->SetInteractorStyle(interactorstylebaseview);
interactorstylebaseview->SetwxVtkBaseView(this);
- vtkMaracasImageViewer2Callback *cbk = vtkMaracasImageViewer2Callback::New();
+ vtkMaracasImageViewer2Callback * cbk = vtkMaracasImageViewer2Callback::New();
cbk->IV = _imageViewer2XYZ->GetVtkImageViewer2();
interactorstylebaseview->AddObserver( vtkCommand::WindowLevelEvent, cbk );
interactorstylebaseview->AddObserver( vtkCommand::StartWindowLevelEvent, cbk );
if (_configure==false)
{
_configure=true;
- wxVtkBaseView::Configure();
+ //wxVtkBaseView::Configure();
_aRenderer = vtkRenderer::New();
_renWin = vtkRenderWindow::New();
_renWin->AddRenderer(_aRenderer);
// (ResetCamera() method) this vector is used to position the camera
// to look at the data in this direction.
_aCamera = vtkCamera::New();
+
+//EED 17Avril2009
+/*
_aCamera->SetViewUp (0, 0, -1);
_aCamera->SetPosition (0, 1, 0);
+ */
+ _aCamera->SetViewUp (0, 1, 0);
+ _aCamera->SetPosition (0, 0, 1);
+
_aCamera->SetFocalPoint (0, 0, 0);
_aCamera->ComputeViewPlaneNormal();
+
}
}
//-------------------------------------------------------------------