+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+# pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+# This software is governed by the CeCILL-B license under French law and
+# abiding by the rules of distribution of free software. You can use,
+# modify and/ or redistribute the software under the terms of the CeCILL-B
+# license as circulated by CEA, CNRS and INRIA at the following URL
+# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+# or in the file LICENSE.txt.
+#
+# As a counterpart to the access to the source code and rights to copy,
+# modify and redistribute granted by the license, users are provided only
+# with a limited warranty and the software's author, the holder of the
+# economic rights, and the successive licensors have only limited
+# liability.
+#
+# The fact that you are presently reading this means that you have had
+# knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
/*=========================================================================
Program: wxMaracas
Module: $RCSfile: wxMPRWidget.cxx,v $
Language: C++
- Date: $Date: 2009/05/07 15:35:46 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2012/11/15 14:14:35 $
+ Version: $Revision: 1.17 $
Copyright: (c) 2002, 2003
License:
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the above copyright notice for more information.
-
-=========================================================================*/
-
-
-#include <vtkObjectFactory.h>
-#include <vtkInteractorStyleSwitch.h>
-#include <vtkCamera.h>
-#include <vtkImageActor.h>
-#include <vtkRenderer.h>
-#include <vtkRenderWindowInteractor.h>
-#include <vtkRenderWindow.h>
-
-#include <vtkRenderer.h>
-#include <vtkImageViewer2.h>
-#include <vtkInteractorStyleImage.h>
-
-#include <vtkProperty.h>
-#include <vtkPolyData.h>
-#include <vtkDataSet.h>
-#include <vtkStripper.h>
-#include <vtkCellArray.h>
-#include <vtkPointData.h>
-#include <vtkInteractorStyleTrackballCamera.h>
-
-#include <vtkPlanes.h>
-#include <vtkProbeFilter.h>
-#include <vtkPlane.h>
-#include <vtkPointPicker.h>
-
-
-#include "vtkClosePolyData.h"
-#include <vtkTriangleFilter.h>
-#include <vtkSTLWriter.h>
-#include <vtkPolyDataConnectivityFilter.h>
-
-// EED 25 Janvier 2007 - TestLoic
-#include <vtkCutter.h>
-#include <vtkWindowLevelLookupTable.h>
-#include <vtkLookupTable.h>
-#include <vtkMetaImageWriter.h>
-
-
-
-#include "wxMPRWidget.h"
-#include "wxVTKRenderWindowInteractor.h"
-#include "UtilVtk3DGeometriSelection.h"
-#include "../kernel/marDicomBase.h"
-
-
-#include <wx/wx.h>
-#include <wx/notebook.h>
-#include <wx/colordlg.h>
-
-#include "matrix.h"
-#include <string>
-#include <stdio.h>
-
-
-
-#include "pPlotter/HistogramDialog.h"
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-idAlBeRa::idAlBeRa(int id, double radio,int deltavoxel)
-{
- _id = id;
- _radio = radio;
- _deltavoxel = deltavoxel;
-}
-
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-vtkInteractorStyleSphere::vtkInteractorStyleSphere()
-{
- _stateRadio = false;
- _stateRotate = false;
-}
-
-//---------------------------------------------------------------------------
-
-vtkInteractorStyleSphere::~vtkInteractorStyleSphere()
-{
-}
-
-
-//---------------------------------------------------------------------------
-
-bool vtkInteractorStyleSphere::OnRightButtonDown()
-{
- if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) && (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
- {
- _stateRadio = true;
- //_fordwareX = this->Interactor->GetEventPosition()[0];
- _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
-
- wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
-
- _radio = wxsphereview->GetRadio();
- }
-
- return true;
-}
-
-//---------------------------------------------------------------------------
-
-bool vtkInteractorStyleSphere::OnRightButtonUp()
-{
- if (_stateRadio==true)
- {
- wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
- wxsphereview->SetDeltaVoxel(1);
- double radio=wxsphereview->GetRadio();
- wxsphereview->GetIdOfImage(radio+0.1);
- wxsphereview->GetIdOfImage(radio+0.2);
- wxsphereview->GetIdOfImage(radio-0.1);
- wxsphereview->GetIdOfImage(radio-0.2);
-
- wxsphereview->RefreshView();
- _stateRadio = false;
- }
-
- return true;
-}
-//---------------------------------------------------------------------------
-
-bool vtkInteractorStyleSphere::OnLeftButtonDown()
-{
- _stateRotate = true;
- _fordwareX = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
- _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
- return true;
-}
-
-
-//---------------------------------------------------------------------------
-
-bool vtkInteractorStyleSphere::OnLeftButtonUp()
-{
- wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
- if (_stateRotate==true){
- int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
- int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
-
- if ((_fordwareX==fx)&&(_fordwareY==fy)){
- double x=fx,y=fy,z=1;
- _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
- wxsphereview->SetXYZtoParent(x,y);
- wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);
- wxsphereview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent);
- } else {
- wxsphereview->RotationEnd();
- }
- wxsphereview->RefreshView();
- _stateRotate = false;
- }
-
- return true;
-}
-
-
-//---------------------------------------------------------------------------
-
-bool vtkInteractorStyleSphere::OnMouseMove ()
-{
- wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
- if (_stateRotate==true)
- {
- bool ok_v, ok_ang;
- ok_v=false;
- ok_ang=false;
- if (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==1)
- {
- ok_v = true;
- }
- if (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==1)
- {
- ok_ang = true;
- }
- int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
- int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
- wxsphereview->RotationStart( fx - _fordwareX , -(fy - _fordwareY) , ok_v, ok_ang);
- wxsphereview->RefreshView();
- }
- if (_stateRadio==true)
- {
- //int fx = this->Interactor->GetEventPosition()[0];
- int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
- double dif=(fy-_fordwareY) / 10.0;
- wxsphereview->SetRadio( _radio + dif );
- wxsphereview->SetDeltaVoxel(3);
- wxsphereview->RefreshView();
- }
-
- return true;
-}
-
-
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-wxSphereView::wxSphereView( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata, vtkImageData *imageData )
-: wxVtk2DBaseView(parent)
-{
- _delta = 1;
- _vtkmprbasedata = vtkmprbasedata;
- _imageDataOriginal = imageData;
-
- _imageSphere = vtkImageData::New();
- _imageSphere->SetDimensions (150,150,500);
- _imageSphere->SetScalarTypeToUnsignedShort();
- _imageSphere->AllocateScalars();
- _imageSphere->Update();
-
-
- vtkBaseData *vtkbasedata = new vtkBaseData();
- vtkbasedata->SetMarImageData( new marImageData(_imageSphere) );
- this->SetVtkBaseData(vtkbasedata);
-
- _transform = vtkTransform::New();
- _transform1 = vtkTransform::New();
- _transform2 = vtkTransform::New();
- _transform ->Identity();
- _transform1->Identity();
- _transform2->Identity();
-
- _radio=25;
-}
-
-//-------------------------------------------------------------------
-
-wxSphereView::~wxSphereView()
-{
- _transform -> Delete();
- _transform1 -> Delete();
- _transform2 -> Delete();
- ResetlstId();
-}
-
-//----------------------------------------------------------------------------
-
-double wxSphereView::GetRadio()
-{
- return _radio;
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::SetRadio(double radio)
-{
- if (radio<0)
- {
- radio=0;
- }
- _radio=radio;
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::Configure()
-{
- wxVtk2DBaseView::Configure();
-
- _vtkinteractorstylesphere = new vtkInteractorStyleSphere();
- GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _vtkinteractorstylesphere );
- double points[4][3];
-
-// EED purify 12/sep/2006
- int i,j;
- for (i=0;i<4;i++)
- {
- for (j=0;j<3;j++)
- {
- points[i][j]=0;
- }
- }
-
- InitSphere(points);
- DefineImageSphere();
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::RefreshPoint()
-{
- double x = _vtkmprbasedata->GetX() - _centerX;
- double y = _vtkmprbasedata->GetY() - _centerY;
- double z = _vtkmprbasedata->GetZ() - _centerZ;
- double alpha= atan2(x,z);
- double beta = atan2( y , sqrt(z*z+x*x) );
-
- alpha = alpha*180/3.1416;
- beta = beta*180/3.1416;
-
- _transform1->Identity();
- _transform1->RotateY(alpha);
- _transform1->RotateX(-beta);
-
- _radio= sqrt(x*x + y*y +z*z);
-
- RefreshView();
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::RefreshView()
-{
- DefineImageSphere();
- wxVtk2DBaseView::Refresh();
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::RotationEnd()
-{
- _transform1->RotateWXYZ(_ang,_vxb,_vyb,0);
- _transform2->Identity();
- SetDeltaVoxel(1);
- ResetlstId();
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::RotationStart(double vx, double vy, bool ok_v, bool ok_ang)
-{
- if (ok_ang==false)
- {
- _ang = -sqrt( vx*vx + vy*vy ) / 1.0;
- }
-
- if (ok_v==false){
- _vxb=-vy;
- _vyb=vx;
- }
-
- _transform2->Identity();
- _transform2->RotateWXYZ(_ang,_vxb,_vyb,0);
- SetDeltaVoxel(3);
- ResetlstId();
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::GetPointSphere(double p[3],double r1,double angA,double angB)
-{
- double in[3],out[3];
- in[0]=0;
- in[1]=r1;
- in[2]=0;
- vtkTransform *transform = vtkTransform::New();
- transform->Identity();
- transform->RotateX(angB);
- transform->RotateZ(angA);
- transform->TransformPoint(in,out);
- p[0]=out[0];
- p[1]=out[1];
- p[2]=out[2];
- transform->Delete();
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::RotatePointOverTheSphere( double pp[3], double p[3],double cc[3])
-{
-
- double out[3];
- _transform->TransformPoint(p,out);
- pp[0] = out[0] + cc[0];
- pp[1] = out[1] + cc[1];
- pp[2] = out[2] + cc[2];
-
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::TransferePoints(double pp1[3],double pp2[3],double AngX,double AngY,vtkImageData *image)
-{
- double t;
- double difX = pp2[0]-pp1[0];
- double difY = pp2[1]-pp1[1];
- double difZ = pp2[2]-pp1[2];
-
- double max = 200;
-
- int dimOrg[3];
- int dimRes[3];
- int z;
- _imageDataOriginal->GetDimensions(dimOrg);
- image->GetDimensions(dimRes);
-
- int i;
- double x1=pp1[0];
- double y1=pp1[1];
- double z1=pp1[2];
- int xx=-1,yy=-1,zz=-1;
-
- for (i=0;i<max;i++)
- {
- t = i/max;
- xx = (int) (x1+t*difX);
- yy = (int) (y1+t*difY);
- zz = (int) (z1+t*difZ);
-
- z=i;
- if ((xx>=0) && (xx<dimOrg[0]) && (yy>=0) && (yy<dimOrg[1]) && (zz>=0) && (zz<dimOrg[2]) &&
- (AngX>=0) && (AngX<dimRes[0]) && (AngY>=0) && (AngY<dimRes[1]) && (z>=0) && (z<dimRes[2]) )
- {
- unsigned short *pOrg=(unsigned short*)_imageDataOriginal->GetScalarPointer (xx,yy,zz);
- unsigned short *pRes=(unsigned short*)image->GetScalarPointer( (int)AngX , (int)AngY , z );
- *pRes=*pOrg;
- }
- }
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::ResetlstId()
-{
- int i,size=_lstId.size();
- for (i=size-1;i>=0;i--)
- {
- delete _lstId[i];
- }
- _lstId.clear();
-}
-
-//----------------------------------------------------------------------------
-
-int wxSphereView::GetIdOfImage(double radio)
-{
- int id=0;
- int dim[3];
- _imageSphere->GetDimensions(dim);
- int sizeMaxList = dim[2];
- // Search in list >> alpha beta radio
- int i,size=_lstId.size();
- for (i=0; i<size;i++)
- {
- //idAlBeRa *tmp=_lstId[i]; // JPRx
- if ((_lstId[i]->_radio==radio) && (_lstId[i]->_deltavoxel==_delta))
- {
- return _lstId[i]->_id;
- }
- }
- if (size>sizeMaxList)
- {
- delete _lstId[size-1];
- _lstId.pop_back();
- }
- if (size!=0){
- id=_lstId[0]->_id+1;
- id = id % sizeMaxList;
- } else {
- id = 0;
- }
-
- FiltreImage(id,radio);
- _lstId.insert(_lstId.begin(),1,new idAlBeRa(id,radio,_delta) );
-
- return id;
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::DefineImageSphere()
-{
- int id;
- id=GetIdOfImage( _radio );
- GetVtkBaseData()->SetZ( id );
-}
-
-
-//----------------------------------------------------------------------------
-void wxSphereView::SetDeltaVoxel(int delta)
-{
- _delta=delta;
-}
-
-//----------------------------------------------------------------------------
-void wxSphereView::SetVoxel(double i, double j, int delta,double id, unsigned short gris)
-{
- int ii,jj,delta2;
- unsigned short *pRes;
- int dimRes[3];
- _imageSphere->GetDimensions(dimRes);
-
- delta2=delta-1;
- for ( ii=(int)(i-delta2) ; ii<=(int)(i+delta2) ; ii++ )
- {
- for ( jj=(int)(j-delta2) ; jj<=(int)(j+delta2) ; jj++ )
- {
- if ( (ii>=0)&&(ii<dimRes[0]) &&
- (jj>=0)&&(jj<dimRes[1]) )
- {
- pRes = (unsigned short*)_imageSphere->GetScalarPointer( ii , jj , (int)id );
- *pRes=gris;
- }
- }
- }
-
-}
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::SetXYZtoParent(double i, double j)
-{
-
- double factor = 0.75;
- double radio2 = _radio*_radio;
- double pxx,pyy,d2x,d2y;
- double cc[3],p[3],pp[3];
- cc[0]=_centerX;
- cc[1]=_centerY;
- cc[2]=_centerZ;
- double aa;
- int dimRes[3],dimOrig[3];
- _imageSphere->GetDimensions(dimRes);
- d2x=dimRes[0]/2;
- d2y=dimRes[1]/2;
- _imageDataOriginal->GetDimensions(dimOrig);
-
- p[0] = (i - d2x)*factor;
- pxx=p[0]*p[0];
- p[1] = (j - d2y)*factor;
- pyy=p[1]*p[1];
- aa = pxx + pyy;
- if (radio2>aa){
- aa=radio2-aa;
- p[2] = sqrt(aa);
- RotatePointOverTheSphere( pp, p,cc);
- if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
- (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
- (pp[2]>=0) && (pp[2]<dimOrig[2]) )
- {
- if (_vtkmprbasedata){
- _vtkmprbasedata->SetX(pp[0]);
- _vtkmprbasedata->SetY(pp[1]);
- _vtkmprbasedata->SetZ(pp[2]);
- }
- }
- }
-}
-
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::FiltreImageB(int id, double radio, bool ok,int deltaTMP)
-{
- double factor = 0.75;
- double radioB = radio/3;
- double radio2 = radio*radio;
- double pxx,pyy,d2x,d2y;
- double cc[3],p[3],pp[3];
- cc[0]=_centerX;
- cc[1]=_centerY;
- cc[2]=_centerZ;
- double aa;
- unsigned short *pOrig;
- int dimRes[3],dimOrig[3];
- double i,j;
- int ext[6];
- _imageSphere->GetExtent(ext);
- _imageSphere->GetDimensions(dimRes);
- //JCP 24 - 04 -09
- //_imageSphere->SetExtent(0,dimRes[0]-1,0,dimRes[1]-1,0,dimRes[2]-1);
- _imageSphere->SetExtent(ext);
- //JCP 24 - 04 -09
- d2x=dimRes[0]/2;
- d2y=dimRes[1]/2;
-// double deltaTMP=_delta;
- _imageDataOriginal->GetDimensions(dimOrig);
-
- int start,end;
- int limitA,limitB;
- limitA = (int) ( (-radioB/factor)+d2x );
- limitB = (int) ( (radioB/factor)+d2x );
- if (ok==true){
- start = limitA;
- end = limitB;
- } else {
- start=0;
- end=dimRes[0];
- }
-
- for ( i=start ; i<end ; i=i+deltaTMP )
- {
- p[0] = (i - d2x)*factor;
- pxx=p[0]*p[0];
- for (j=start;j<end;j=j+deltaTMP)
- {
- p[1] = (j - d2y)*factor;
- pyy=p[1]*p[1];
- aa = pxx + pyy;
-
- if (( ((ok==false) && (!((i>limitA) && (i<limitB) && (j>limitA) && (j<limitB)))) )
- ||
- (ok==true))
- {
- if (radio2>aa){
- aa=radio2-aa;
- p[2] = sqrt(aa);
- RotatePointOverTheSphere( pp, p,cc);
- if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
- (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
- (pp[2]>=0) && (pp[2]<dimOrig[2]) )
- {
- pOrig=(unsigned short*)_imageDataOriginal->GetScalarPointer( (int)(pp[0]) , (int)(pp[1]) , (int)(pp[2]) );
- SetVoxel(i,j,deltaTMP,id,*pOrig);
- } else {
- SetVoxel(i,j,deltaTMP,id,2000);
- }
- } else {
- SetVoxel(i,j,deltaTMP,id,0);
- }
- }
- }
- }
-
- _imageSphere->Modified();
- _imageSphere->Update();
-}
-
-
-
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::FiltreImage(int id, double radio)
-{
-
- _transform -> Identity();
- _transform -> Concatenate(_transform1);
- _transform -> Concatenate(_transform2);
-
- FiltreImageB(id,radio,false, _delta);
- FiltreImageB(id,radio,true, 1);
-}
-
-
-//----------------------------------------------------------------------------
-
-/*
-void wxSphereView::FiltreImage(int id, double radio)
-{
- double radio2 = radio*radio;
- double radio2TMP= (radio/2)*(radio/2);
- double pxx,pyy,d2x,d2y;
- double cc[3],p[3],pp[3];
- cc[0]=_centerX;
- cc[1]=_centerY;
- cc[2]=_centerZ;
- double aa;
- unsigned short *pOrig;
- int dimRes[3],dimOrig[3];
- double i,j;
- _imageSphere->GetDimensions(dimRes);
- _imageSphere->SetExtent(0,dimRes[0]-1,0,dimRes[1]-1,0,dimRes[2]-1);
- d2x=dimRes[0]/2;
- d2y=dimRes[1]/2;
- double deltaTMP=_delta;
- _imageDataOriginal->GetDimensions(dimOrig);
-
- for ( i=0 ; i<dimRes[0] ; i=i+deltaTMP )
- {
- p[0] = (i - d2x)*0.75;
- pxx=p[0]*p[0];
- for (j=0;j<dimRes[1];j=j+deltaTMP)
- {
- p[1] = (j - d2y)*0.75;
- pyy=p[1]*p[1];
- aa = pxx + pyy;
-
- if (aa>radio2TMP)
- {
- if (radio2>aa){
- aa=radio2-aa;
- p[2] = sqrt(aa);
- RotatePointOverTheSphere( pp, p,cc);
- if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
- (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
- (pp[2]>=0) && (pp[2]<dimOrig[2]) )
- {
- pOrig=(unsigned short*)_imageDataOriginal->GetScalarPointer( pp[0] , pp[1] , pp[2] );
- SetVoxel(i,j,deltaTMP,id,*pOrig);
- } else {
- SetVoxel(i,j,deltaTMP,id,2000);
- }
- } else {
- SetVoxel(i,j,deltaTMP,id,0);
- }
- }
- }
- }
-
-
- deltaTMP=1;
- for ( i=0 ; i<dimRes[0] ; i=i+deltaTMP )
- {
- p[0] = (i - d2x)*0.75;
- pxx=p[0]*p[0];
- for (j=0;j<dimRes[1];j=j+deltaTMP)
- {
- p[1] = (j - d2y)*0.75;
- pyy=p[1]*p[1];
- aa = pxx + pyy;
- if (aa<=radio2TMP)
- {
- if (radio2>aa){
- aa=radio2-aa;
- p[2] = sqrt(aa);
- RotatePointOverTheSphere( pp, p,cc);
- if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
- (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
- (pp[2]>=0) && (pp[2]<dimOrig[2]) )
- {
- pOrig=(unsigned short*)_imageDataOriginal->GetScalarPointer( pp[0] , pp[1] , pp[2] );
- SetVoxel(i,j,deltaTMP,id,*pOrig);
- } else {
- SetVoxel(i,j,deltaTMP,id,2000);
- }
- } else {
- SetVoxel(i,j,deltaTMP,id,0);
- }
- }
- }
- }
-
- _imageSphere->Modified();
- _imageSphere->Update();
-}
-*/
-/*
-void wxSphereView::FiltreImage(vtkImageData *imageSphere)
-{
- int dim[3],i,j,k;
- imageSphere->GetDimensions(dim);
- for (i=0;i<dim[0];i++)
- {
- for (j=0;j<dim[1];j++)
- {
- for (k=0;k<dim[2];k++)
- {
- unsigned short *pRes=(unsigned short*)imageSphere->GetScalarPointer (i,j,k);
- *pRes=0;
- }
- }
- }
-
- double deltaA=90;
- double cc[3],p1[3],p2[3],pp1[3],pp2[3];
- cc[0]=_centerX;
- cc[1]=_centerY;
- cc[2]=_centerZ;
- double r1 = _sl_radio->GetValue() - _sl_thickness->GetValue()/2;
- double r2 = _sl_radio->GetValue() + _sl_thickness->GetValue()/2;
- if (r1<10)
- {
- r1=10;
- }
- double alpha= _sl_alpha->GetValue();
- double beta = _sl_beta->GetValue();
-
- double angA,angB;
- for (angA=-deltaA;angA<deltaA;angA++)
- {
- for (angB=-deltaA;angB<deltaA;angB++)
- {
- GetPointSphere(p1,r1,angA,angB);
- GetPointSphere(p2,r2,angA,angB);
- RotatePointOverTheSphere( pp1, alpha, beta, p1 ,cc );
- RotatePointOverTheSphere( pp2, alpha, beta, p2 ,cc );
- TransferePoints(pp1,pp2,angA+alpha+180,angB+beta+90,imageSphere);
- }
- }
-}
-*/
-
-
-//----------------------------------------------------------------------------
-
-void wxSphereView::InitSphere(double points[4][3])
-{
- double cc[3];
- double r = SphereFindCenter(points,cc); // 4-points , center
- if (r > 0)
- {
- _centerX = (int)(cc[0]);
- _centerY = (int)(cc[1]);
- _centerZ = (int)(cc[2]);
- } else {
- int dim[3];
- _imageDataOriginal->GetDimensions(dim);
- _centerX = (int)(dim[0]/2);
- _centerY = (int)(dim[1]/2);
- _centerZ = (int)(dim[2]/2);
- }
-}
-
-//----------------------------------------------------------------------------
-
-// Calculate center and radius of sphere given four points
-// http://home.att.net/~srschmitt/script_sphere_solver.html
-// source code HTML <script language=JavaScript>
-double wxSphereView::SphereFindCenter(double P[4][3], double cc[3])
-{
- int i;
- double r, m11, m12, m13, m14, m15;
- double a[4][4];
-
- for (i = 0; i < 4; i++) // find minor 11
- {
- a[i][0] = P[i][0];
- a[i][1] = P[i][1];
- a[i][2] = P[i][2];
- a[i][3] = 1;
- }
- m11 = determinant( a, 4 );
-
- for (i = 0; i < 4; i++) // find minor 12
- {
- a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
- a[i][1] = P[i][1];
- a[i][2] = P[i][2];
- a[i][3] = 1;
- }
- m12 = determinant( a, 4 );
-
- for (i = 0; i < 4; i++) // find minor 13
- {
- a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
- a[i][1] = P[i][0];
- a[i][2] = P[i][2];
- a[i][3] = 1;
- }
- m13 = determinant( a, 4 );
-
- for (i = 0; i < 4; i++) // find minor 14
- {
- a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
- a[i][1] = P[i][0];
- a[i][2] = P[i][1];
- a[i][3] = 1;
- }
- m14 = determinant( a, 4 );
-
-
- for (i = 0; i < 4; i++) // find minor 15
- {
- a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
- a[i][1] = P[i][0];
- a[i][2] = P[i][1];
- a[i][3] = P[i][2];
- }
- m15 = determinant( a, 4 );
-
- if (m11 == 0)
- {
- r = 0;
- }
- else
- {
- // center of sphere
- cc[0] = 0.5*m12/m11; //cx
- cc[1] = -0.5*m13/m11; //cy
- cc[2] = 0.5*m14/m11; //cz
- // Sphere radio
- r = sqrt( cc[0]*cc[0] + cc[1]*cc[1] + cc[2]*cc[2] - m15/m11 );
- }
-
- return r; // the radius
-}
-//----------------------------------------------------------------------------
-
-// Recursive definition of determinate using expansion by minors.
-double wxSphereView::determinant(double a[4][4], int n)
-{
- int i, j, j1, j2;
- double d;
- double m[4][4];
-
- for (i=0;i<4;i++)
- {
- for (j=0;j<4;j++)
- {
- m[i][j]=0;
- }
- }
-
- if (n == 2) // terminate recursion
- {
- d = a[0][0]*a[1][1] - a[1][0]*a[0][1];
- }
- else
- {
- d = 0;
- for (j1 = 0; j1 < n; j1++ ) // do each column
- {
- for (i = 1; i < n; i++) // create minor
- {
- j2 = 0;
- for (j = 0; j < n; j++)
- {
- if (j == j1) continue;
- m[i-1][j2] = a[i][j];
- j2++;
- }
- }
-
- // sum (+/-)cofactor * minor
- d = d + pow(-1.0, j1)*a[0][j1]*determinant( m, n-1 );
- }
- }
-
- return d;
-}
-
-
-
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-vtkInteractorStylePlane2D::vtkInteractorStylePlane2D()
-{
- _stateRotate=false;
-}
-//---------------------------------------------------------------------------
-vtkInteractorStylePlane2D::~vtkInteractorStylePlane2D()
-{
-}
-
-//---------------------------------------------------------------------------
-bool vtkInteractorStylePlane2D::GetStateRotate()
-{
- return _stateRotate;
-}
-
-//---------------------------------------------------------------------------
-bool vtkInteractorStylePlane2D::OnLeftButtonDown() // vitual
-{
- _stateRotate = true;
- _fordwareX = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
- _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
- vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
- vtkplane2Dview->RotationStart();
-
- return true;
-}
-
-//---------------------------------------------------------------------------
-bool vtkInteractorStylePlane2D::OnLeftButtonUp() // virtual
-{
- if (_stateRotate==true)
- {
- _stateRotate = false;
- vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
- vtkplane2Dview->ResetBack();
-// this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
- }
-
- return true;
-}
-
-//---------------------------------------------------------------------------
-bool vtkInteractorStylePlane2D::OnRightButtonUp() // virtual
-{
- if (_stateRotate==true){
- //vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()); // JPRx
-
-// EED Borrame
-// vtkplane2Dview->RotationEnd();
-
- _stateRotate = false;
- }
-
- return true;
-}
-//---------------------------------------------------------------------------
-bool vtkInteractorStylePlane2D::OnMouseMove () // virtual
-{
- bool ok_v, ok_ang;
- if (_stateRotate==true){
- ok_v=false;
- ok_ang=false;
- if (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==1)
- {
- ok_v=true;
- }
- if (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==1)
- {
- ok_ang=true;
- }
- int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
- int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
- vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
- vtkplane2Dview->RotationDrag( fx - _fordwareX , fy - _fordwareY , ok_v , ok_ang);
- this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
- }
- return true;
-}
-//-------------------------------------------------------------------
-bool vtkInteractorStylePlane2D::OnLeftDClick() // virtual
-{
- int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
- int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
- double xx=fx;
- double yy=fy;
- double zz=0;
-
- vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
- vtkMPRBaseData *vtkmprbasedata = vtkplane2Dview->GetVtkmprbasedata();
-
- vtkplane2Dview->TransfromeCoordViewWorld2(xx,yy,zz);
-
- vtkmprbasedata->SetX( xx );
- vtkmprbasedata->SetY( yy );
- vtkmprbasedata->SetZ( zz );
- this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
-
- return true;
-}
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-vtkPlane2DView::vtkPlane2DView( wxWindow *parent)
-: wxVtk2DBaseView(parent)
-{
-
- _backX = -99999;
- _backY = -99999;
- _backZ = -99999;
-
- _backOrient[0] = -99999;
- _backOrient[1] = -99999;
- _backOrient[2] = -99999;
- _backOrient[3] = -99999;
-
- _active = true;
- _mip_visualization = true;
- _mip_width = 2;
-
- _transform1 = vtkTransform::New();
- _transform2 = vtkTransform::New();
- _transform1->Identity();
- _transform2->Identity();
-
- _sizeIma = 200;
-
- _pSource = NULL;
- _3Dslices = NULL;
- _stPoints = NULL;
- _change = NULL;
- _imageResult = NULL;
-
- // line horizontal
- _pts = NULL;
- _lineActor = NULL;
- _lineMapper = NULL;
- _pd = NULL;
-
- _interactorstyleplane2D = false;
-}
-//-------------------------------------------------------------------
-vtkPlane2DView::~vtkPlane2DView()
-{
- ResetPlane();
-
- // Horizontal Line
- if (_pts != NULL) { _pts -> Delete(); }
- if (_lineActor != NULL) { _lineActor -> Delete(); }
- if (_lineMapper != NULL) { _lineMapper -> Delete(); }
- if (_pd != NULL) { _pd -> Delete(); }
-
- _transform1 -> Delete();
- _transform2 -> Delete();
-}
-
-//-------------------------------------------------------------------
-void vtkPlane2DView::ResetBack()
-{
- _backX=-1;
- _backY=-1;
- _backZ=-1;
- _backOrient[0]=-1;
- _backOrient[1]=-1;
- _backOrient[2]=-1;
- _backOrient[3]=-1;
-}
-
-//-------------------------------------------------------------------
-void vtkPlane2DView::ResetPlane(){
- if (_pSource !=NULL) { _pSource -> Delete(); }
- if (_3Dslices !=NULL) { _3Dslices -> Delete(); }
- if (_stPoints !=NULL) { _stPoints -> Delete(); }
- if (_change !=NULL) { _change -> Delete(); }
-}
-//-------------------------------------------------------------------
-vtkMPRBaseData *vtkPlane2DView::GetVtkmprbasedata()
-{
- return (vtkMPRBaseData*)GetVtkBaseData();
-}
-
-//-------------------------------------------------------------------
-void vtkPlane2DView::SetPSource(int sizeIma){
- int dimIma = sizeIma;
-
- double x = GetVtkmprbasedata()->GetX();
- double y = GetVtkmprbasedata()->GetY();
- double z = GetVtkmprbasedata()->GetZ();
-
- double spc[3];
- vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
- imagedata->GetSpacing(spc);
- x=x*spc[0];
- y=y*spc[1];
- z=z*spc[2];
-
-
- vtkMPRBaseData *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
- vtkTransform *transform = mprbasedata->GetTransformOrientation();
-
- double in[3]; // temp
- double pA[3];
- double pB[3];
- in[0]=1; in[1]=0; in[2]=0;
- transform->TransformPoint(in,_n);
-
- in[0]=0; in[1]=dimIma-1; in[2] = 0;
- transform->TransformPoint(in,pA);
-
- in[0]=0; in[1]=0; in[2]=dimIma-1;
- transform->TransformPoint(in,pB);
-
- _pSource -> SetPoint1( pA );
- _pSource -> SetPoint2( pB );
-
- _pSource -> SetOrigin( 0 , 0 , 0 );
- _pSource -> SetResolution( sizeIma-1 , sizeIma -1 );
- _pSource -> Update();
- _pSource -> SetCenter( x, y, z );
- _pSource -> SetNormal( _n );
- _pSource -> Update( );
-
-// EED Borrame
-// transform->Delete();
-
-}
-
-//-------------------------------------------------------------------
-void vtkPlane2DView::ExtractPlane()
-{
-
- double x = GetVtkmprbasedata()->GetX();
- double y = GetVtkmprbasedata()->GetY();
- double z = GetVtkmprbasedata()->GetZ();
-
- double spc[3];
- vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
- imagedata->GetSpacing(spc);
- x=x*spc[0];
- y=y*spc[1];
- z=z*spc[2];
-
- vtkTransform *transform = GetVtkmprbasedata()->GetTransformOrientation();
- double orientation[4];
- transform->GetOrientationWXYZ(orientation);
-
- bool okOrientation=true;
- if ((orientation[0]!=_backOrient[0]) || (orientation[1]!=_backOrient[1]) ||
- (orientation[2]!=_backOrient[2]) || (orientation[3]!=_backOrient[3]))
- {
- okOrientation=false;
- }
-
- bool okPosicion=true;
- if ( (x!=_backX) || (y!=_backY) || (z!=_backZ) )
- {
- okPosicion=false;
- }
-
- if ((okPosicion==false) || (okOrientation==false) ) {
- if (_active==true){
-
- bool ok = false;
-
- if ( _mip_visualization==true )
- {
- if (_interactorstyleplane2D!=NULL)
- {
- if (_interactorstyleplane2D->GetStateRotate()==false )
- {
- ok=true;
- }
- }
- }
-// ok=true;
-
- if (ok==true)
- {
- Extract_MIP_PlaneVTK();
- } else {
- Extract_One_PlaneVTK();
- } // ok
-
- } // active
- _backX=x;
- _backY=y;
- _backZ=z;
- _backOrient[0]=orientation[0];
- _backOrient[1]=orientation[1];
- _backOrient[2]=orientation[2];
- _backOrient[3]=orientation[3];
- } //okPosition okOrientation
-}
-
-//-------------------------------------------------------------------
-
-void vtkPlane2DView::Extract_One_PlaneVTK()
-{
- vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
- SetPSource(_sizeIma);
- _3Dslices -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
- _3Dslices -> SetSource( imagedata );
- _3Dslices -> Update( );
- _stPoints -> GetPointData( )->SetScalars( _3Dslices->GetOutput()->GetPointData()->GetScalars() );
- _stPoints -> SetDimensions( _sizeIma, _sizeIma, 1 );
- _stPoints -> SetScalarType( imagedata->GetScalarType() );
- _stPoints -> SetScalarTypeToShort();
- _stPoints -> Update();
-// _change -> SetInput( _stPoints );
-// _change -> Update(); //important
- _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _stPoints );
-// _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _change->GetOutput() );
- // vtkImageActor *imageActor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor();
-}
-
-//-------------------------------------------------------------------
-
-void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ )
-{
-
- int mipWidth;
- double sp;
- int sizeWidth = (_mip_width*2)+1 ;
- int deltaPixel;
- int iWidth,itmp,tmpSizeWith;
-
- double spc[3];
- vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
- SetPSource(_sizeIma);
- imagedata->GetSpacing(spc);
-
- bool heightDefinition=false;
- if (_mip_width<3)
- {
- heightDefinition=true;
- }
-
- if (heightDefinition==true)
- {
- mipWidth = _mip_width;
- sp = spc[0];
- deltaPixel = 1;
- } else {
- mipWidth = 2;
- tmpSizeWith = (mipWidth*2) + 1;
- sp = (spc[0]*sizeWidth)/tmpSizeWith;
- sizeWidth = tmpSizeWith;
- deltaPixel = 4;
- }
-
-
-
- std::vector< vtkProbeFilter* > slicesLST;
-
- _pSource->Push( -mipWidth * sp );
- _pSource->Update();
-
- for ( iWidth=0 ; iWidth<sizeWidth ; iWidth++ )
- {
- vtkProbeFilter *slice = vtkProbeFilter::New();
- slice -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
- slice -> SetSource( imagedata );
- slice -> Update( );
- slicesLST.push_back( slice );
- _pSource->Push( sp );
- }
-
- if (_imageResult ==NULL)
- {
- _imageResult = vtkImageData::New();
- _imageResult -> SetDimensions(_sizeIma,_sizeIma,1);
- _imageResult -> SetSpacing(1,1,1);
- _imageResult -> SetScalarType( imagedata->GetScalarType() );
- _imageResult -> SetExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
- _imageResult -> SetWholeExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
- _imageResult -> AllocateScalars();
- _imageResult -> Update();
- }
-
- unsigned short *pTemp;
- unsigned short *pResult;
- pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 );
-
- int iPixels , sizePixels = _sizeIma*_sizeIma;
- for(iPixels=0 ; iPixels<sizePixels ; iPixels=iPixels+deltaPixel)
- {
-
- pTemp = (unsigned short*)slicesLST[0]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
-
- pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 );
- pResult[iPixels] = pTemp[iPixels];
-
- for (iWidth=1;iWidth<sizeWidth;iWidth++)
- {
- pTemp = (unsigned short*)slicesLST[iWidth]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
-
- if (pResult[iPixels]< pTemp[iPixels])
- {
- pResult[iPixels] = pTemp[iPixels];
- }
- }
-
- if (deltaPixel!=1)
- {
- for (itmp=1;itmp<deltaPixel;itmp++)
- {
- pResult[iPixels+itmp] = pResult[iPixels];
- }
- }
-
- }
-
- for (iWidth=0;iWidth<sizeWidth;iWidth++)
- {
- slicesLST[iWidth]->Delete();
- }
-
- _imageResult->Modified();
- _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _imageResult );
-
-}
-
-//-------------------------------------------------------------------
-void vtkPlane2DView::Configure( )
-{
- wxVtk2DBaseView::Configure(false);
-
- HorizontalLine();
-// Borrame
-// CircleLine();
-
- _pSource = vtkPlaneSource::New( );
- _3Dslices = vtkProbeFilter::New( ) ;
- _stPoints = vtkStructuredPoints::New( );
- _change = vtkImageChangeInformation::New();
-
- wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
- ExtractPlane();
-// SetActive(false);
- _imageViewer2XYZ -> GetVtkImageViewer2() -> SetupInteractor ( iren );
-
- SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
-
- _interactorstyleplane2D = new vtkInteractorStylePlane2D();
- GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _interactorstyleplane2D );
-
- vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
-
- camera->SetViewUp ( 0 , 1 , 0 );
- camera->SetPosition ((0+_sizeIma)/2 , (0+_sizeIma)/2 , 10000 );
-
- camera->SetFocalPoint ((0+_sizeIma)/2 , (0+_sizeIma)/2 , 0 );
- camera->SetClippingRange(0.01, 100000);
- camera->ComputeViewPlaneNormal();
- camera->SetParallelScale( _sizeIma/3.0 );
-
- // text information over the graphic window
- _vtkInfoTextImage = new vtkInfoTextImage();
- _vtkInfoTextImageInteractorPlane2D = new vtkInfoTextImageInteractorPlane2D();
- _vtkInfoTextImage->SetWxVtk2DBaseView(this);
- _vtkInfoTextImage->SetMarImageData( GetVtkmprbasedata()->GetMarImageData() );
- _vtkInfoTextImageInteractorPlane2D->SetModelVtkInfoTextImage(_vtkInfoTextImage);
- _vtkInfoTextImage->Configure();
- this->GetInteractorStyleBaseView()->AddInteractorStyleMaracas(_vtkInfoTextImageInteractorPlane2D);
-
-
-}
-
-//-------------------------------------------------------------------
-void vtkPlane2DView::HorizontalLine()
-{
-// Axe Horizontal
- _pts = vtkPoints::New();
- _pts->SetNumberOfPoints(2);
- _pts->SetPoint(0, -1000 , -1000 , -1000 );
- _pts->SetPoint(1, 1000 , 1000 , 1000 );
- vtkCellArray *lines = vtkCellArray::New();
- lines->InsertNextCell(2);
- lines->InsertCellPoint(0);
- lines->InsertCellPoint(1);
- _pd = vtkPolyData::New();
- _pd->SetPoints( _pts );
- _pd->SetLines( lines );
- lines->Delete(); //do not delete lines ??
- _lineActor = vtkActor::New();
- _lineMapper = vtkPolyDataMapper::New();
- _lineMapper->SetInput(_pd);
- _lineMapper->ImmediateModeRenderingOn();
- _lineActor->SetMapper(_lineMapper);
- _lineActor->GetProperty()->BackfaceCullingOn();
- _lineActor->GetProperty()->SetDiffuseColor(0,0,1);
- _lineActor->GetProperty()->SetLineWidth(2);
- _lineActor->GetProperty()->SetOpacity(0);
- _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineActor );
-}
-
-//-------------------------------------------------------------------
-void vtkPlane2DView::RotationStart()
-{
- vtkMPRBaseData *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
- vtkTransform *transform = mprbasedata->GetTransformOrientation();
- _transform1->SetMatrix( transform->GetMatrix() );
-}
-//-------------------------------------------------------------------
-void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang)
-{
- if (ok_ang==false)
- {
- _ang =sqrt( vx*vx + vy*vy ) / 1.5;
- }
-
- if (ok_v==false){
- _vxb=-vy;
- _vyb=vx;
- }
- _transform2->Identity();
- _transform2->RotateWXYZ(_ang,0,_vxb,_vyb);
-
- vtkMPRBaseData *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
- vtkTransform *transform = vtkTransform::New();
- transform->Identity();
- transform->Concatenate(_transform1);
- transform->Concatenate(_transform2);
- mprbasedata->InitTransformOrientation(transform);
- transform->Delete();
-
- // Refresh Horizontal Line
- _pts->SetPoint( 0 , (_sizeIma/2) - _vxb*2 , (_sizeIma/2) - _vyb*2 , 1 );
- _pts->SetPoint( 1 , (_sizeIma/2) + _vxb*2 , (_sizeIma/2) + _vyb*2 , 1 );
-// RefreshCircleLine();
-}
-
-//-------------------------------------------------------------------
-void vtkPlane2DView::Refresh( )
-{
- ExtractPlane();
- wxVtkBaseView::Refresh();
-}
-//-------------------------------------------------------------------
-void vtkPlane2DView::SetImgSize( int imgSize )
-{
- _sizeIma = imgSize;
-}
-//-------------------------------------------------------------------
-int vtkPlane2DView::GetImgSize()
-{
- return _sizeIma;
-}
-//-------------------------------------------------------------------
-int vtkPlane2DView::GetActualSlice() // virtual
-{
- _cx = GetVtkmprbasedata()->GetX();
- _cy = GetVtkmprbasedata()->GetY();
- _cz = GetVtkmprbasedata()->GetZ();
- return 0;
-}
-
-//-------------------------------------------------------------------
-
-bool vtkPlane2DView::GetMipVisualization()
-{
- return _mip_visualization;
-}
-
-//-------------------------------------------------------------------
-int vtkPlane2DView::GetMipWidth()
-{
- return _mip_width;
-}
-
-//-------------------------------------------------------------------
-void vtkPlane2DView::SetActualSlice(int slice) // Virtual
-{
- double dir=(double)slice/3.0;
- GetVtkmprbasedata()->SetX( _cx + (_n[0]*dir) );
- GetVtkmprbasedata()->SetY( _cy + (_n[1]*dir) );
- GetVtkmprbasedata()->SetZ( _cz + (_n[2]*dir) );
-}
-//---------------------------------------------------------------------------
-vtkInteractorStylePlane2D *vtkPlane2DView::GetInteractorstyleplane2D()
-{
- return this->_interactorstyleplane2D;
-}
-//---------------------------------------------------------------------------
-void vtkPlane2DView::SetActive(bool active)
-{
- _active = active;
-}
-
-//---------------------------------------------------------------------------
-
-void vtkPlane2DView::SetMipVisualization(bool ok)
-{
- _mip_visualization=ok;
-}
-
-//---------------------------------------------------------------------------
-
-void vtkPlane2DView::SetMipWidth(int value)
-{
- _mip_width=value;
-}
-
-//---------------------------------------------------------------------------
-void vtkPlane2DView::SetVisibleLine(bool ok)
-{
- double opacity;
- if (ok==true)
- {
- opacity=1;
- } else {
- opacity=0;
- }
- _lineActor->GetProperty()->SetOpacity(opacity);
-}
-// ----------------------------------------------------------------------------
-void vtkPlane2DView::TransfromeCoordViewWorld2(double &X, double &Y, double &Z)
-{
- double spc[3];
- GetVtkmprbasedata()->GetImageData()->GetSpacing(spc);
-
- double xx = X;
- double yy = Y;
- double zz = 0;
-
- TransfromeCoordScreenToWorld(xx,yy,zz);
-
-
- vtkTransform *transf1 = vtkTransform::New();
- transf1->Identity();
- vtkTransform *transf2 = GetVtkmprbasedata()->GetTransformOrientation();
- transf1->Concatenate(transf2->GetMatrix());
- double in[4], out[4];
- double center = GetImgSize() / 2;
- in[0] = 0;
- in[1] = xx - center;
- in[2] = yy - center;
- in[3] = 0;
-
- transf1->MultiplyPoint(in,out);
- transf1->Delete();
-
- X = out[0] + GetVtkmprbasedata()->GetX() ;
- Y = out[1] + GetVtkmprbasedata()->GetY() ;
- Z = out[2] + GetVtkmprbasedata()->GetZ() ;
-
-}
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-vtkInfoTextImageInteractorPlane2D::vtkInfoTextImageInteractorPlane2D()
-{
-}
-//-------------------------------------------------------------------
-vtkInfoTextImageInteractorPlane2D::~vtkInfoTextImageInteractorPlane2D()
-{
-}
-//-------------------------------------------------------------------
-bool vtkInfoTextImageInteractorPlane2D::OnMouseMove()
-{
- int X,Y;
- wxVTKRenderWindowInteractor *wxVTKiren;
- wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
- wxVTKiren->GetEventPosition(X,Y);
-
- int z = (int) (_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetVtkBaseData()->GetZ());
- double xx=X,yy=Y,zz=z;
-
-// --> dif
- vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView();
- vtkplane2Dview->TransfromeCoordViewWorld2(xx,yy,zz);
-
- GetVtkInfoTextImage()->PutWindowLevel();
- GetVtkInfoTextImage()->PutColorLevel();
- GetVtkInfoTextImage()->PutPosition( (int)xx , (int)yy , (int)zz );
- GetVtkInfoTextImage()->PutPixelIntensity( (int)xx , (int)yy , (int)zz );
-
- this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
- return true;
-}
-
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-manualViewPerpPlaneContour::manualViewPerpPlaneContour()
-{
-}
-// ----------------------------------------------------------------------------
-manualViewPerpPlaneContour::~manualViewPerpPlaneContour()
-{
-}
-
-
-// ----------------------------------------------------------------------------
-manualViewPerpPlaneContour * manualViewPerpPlaneContour :: Clone()
-{
- manualViewPerpPlaneContour * clone = new manualViewPerpPlaneContour();
- CopyAttributesTo(clone);
- return clone;
-}
-
-// ---------------------------------------------------------------------------
-
-void manualViewPerpPlaneContour::CopyAttributesTo( manualViewPerpPlaneContour * cloneObject)
-{
- // Fathers object
- manualViewContour::CopyAttributesTo(cloneObject);
-}
-
-
-
-
-// ----------------------------------------------------------------------------
-void manualViewPerpPlaneContour::UpdateViewPoint(int id)
-{ // virtual
- double x,y,z;
- manualPoint *mp = _manContModel->GetManualPoint(id);
- x = mp->GetX();
- y = mp->GetY();
- z = mp->GetZ();
- FilterCordinateXYZ(x,y,z);
-
- _lstViewPoints[id]->SetPositionXY( x , y ,GetRange(), z );
- if ((z>=-1) && (z<=1))
- {
- _lstViewPoints[id]->GetVtkActor()->VisibilityOn();
- } else {
- _lstViewPoints[id]->GetVtkActor()->VisibilityOff();
- }
-}
-// ----------------------------------------------------------------------------
-void manualViewPerpPlaneContour::FilterCordinateXYZ (double &x, double &y, double &z)
-{
- vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
- vtkMPRBaseData *vtkmprbasedata = vtkplane2Dview->GetVtkmprbasedata();
- vtkTransform *transf1 = vtkTransform::New();
- vtkTransform *transf2 = vtkmprbasedata->GetTransformOrientation();
- transf1->SetMatrix( transf2->GetMatrix() );
- transf1->Inverse();
-
- double in[4], out[4];
- double center = vtkplane2Dview->GetImgSize() / 2;
-
- in[0] = x - vtkmprbasedata->GetX();
- in[1] = y - vtkmprbasedata->GetY();
- in[2] = z - vtkmprbasedata->GetZ();
- in[3] = 0;
-
- transf1->MultiplyPoint(in,out);
- z = out[0];
- x = out[1]+center;
- y = out[2]+center;
-
- double spc[3];
- this->GetWxVtkBaseView()->GetSpacing(spc);
- x = x / spc[0];
- y = y / spc[1];
- z = z / spc[2];
-
- transf1->Delete();
-}
-
-// ----------------------------------------------------------------------------
-void manualViewPerpPlaneContour::TransfromeCoordViewWorld( double &X,double &Y,double &Z,int type )
-{
- Z = 0;
- vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
- vtkplane2Dview->TransfromeCoordViewWorld2(X,Y,Z);
-}
-
-
-// ----------------------------------------------------------------------------
-void manualViewPerpPlaneContour::RefreshContour() // virtual
-{
-// manualViewContour::RefreshContour();
-
- double pp1[3];
- double pp2[3];
- double u;
-
-// JSTG 25-02-08 ----------------------------------------------------------
-// tt;
-//--------------------------------------------------------
-
- double pp[3];
- double ppB[3];
- double ppC[3];
- ppB[0] = 999999;
- double dist,distMin = 99999999;
-
- vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
- double center = vtkplane2Dview->GetImgSize() / 2;
-
- int i,np,nps;
- np = GetNumberOfPoints( );
-
-//JSTG 25-02-08 ------------------------------------------
- //double t,delta;
- //nps = GetNumberOfPointsSpline();
- nps = _manContModel->GetNumberOfPointsSpline();
- //delta = ( double ) ( np ) / ( double ) ( nps-1 );
- _manContModel->UpdateSpline();
-//--------------------------------------------------------
-
- if ( np >= 2 )
- {
- for( i = 0; i < nps; i++ )
- {
-// JSTG 25-02-08 ----------------------------------------------------------
- //t = delta * (double)i ;
- //tt = delta * (double)(i+1) ;
- //_manContModel->GetSplinePoint(t ,pp1[0],pp1[1],pp1[2]);
- //_manContModel->GetSplinePoint(tt,pp2[0],pp2[1],pp2[2]);
- _manContModel->GetSpline_i_Point(i ,&pp1[0],&pp1[1],&pp1[2]);
- _manContModel->GetSpline_i_Point(i+1,&pp2[0],&pp2[1],&pp2[2]);
-//--------------------------------------------------------------------------
- FilterCordinateXYZ(pp1[0],pp1[1],pp1[2]);
- FilterCordinateXYZ(pp2[0],pp2[1],pp2[2]);
- if (pp2[2]*pp1[2]<=0)
- {
- if (pp1[2]-pp2[2]!=0) {
- u = -pp2[2] / (pp1[2]-pp2[2]);
- } else {
- u=9999999;
- }
- pp[0] = ( pp1[0]-pp2[0] )*u + pp2[0];
- pp[1] = ( pp1[1]-pp2[1] )*u + pp2[1];
- pp[2] = ( pp1[2]-pp2[2] )*u + pp2[2];
- ppC[0] = pp[0] - center;
- ppC[1] = pp[1] - center;
- ppC[2] = pp[2] ;
- dist = sqrt( ppC[0]*ppC[0] + ppC[1]*ppC[1] + ppC[2]*ppC[2] );
- if (dist<distMin)
- {
- distMin=dist;
- ppB[0] = pp[0];
- ppB[1] = pp[1];
- ppB[2] = pp[2];
- }
- }
-
- }// for
- } else {
- _pts->SetPoint(0, 0 , 0 , 0);
- _pts->SetPoint(1, 0 , 0 , 0);
- } // if
-
-//EED 27 sep 2006
- ppB[0]=ppB[0]*_spc[0];
- ppB[1]=ppB[1]*_spc[1];
-
- _pts->SetPoint( 0, ppB[0] , ppB[1]+1 , 1 );
- _pts->SetPoint( 1, ppB[0] , ppB[1]-1 , 1 );
- _pts->SetPoint( 2, ppB[0] , ppB[1] , 1 );
- _pts->SetPoint( 3, ppB[0]-1 , ppB[1] , 1 );
- _pts->SetPoint( 4, ppB[0]+1 , ppB[1] , 1 );
-
-
- for( i = 5; i < nps; i++ )
- {
- _pts->SetPoint( i, ppB[0] , ppB[1] , 1 );
- }
-
-}
-
-//---------------------------------------------------------------------------
-bool manualViewPerpPlaneContour::ifTouchContour( int x, int y, int z)
-{
- bool ok=false;
- vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
- double X=x;
- double Y=y;
- double Z=z;
- vtkplane2Dview->TransfromeCoordScreenToWorld(X,Y,Z);
- double ppA[3];
- _pts->GetPoint(0, ppA);
- if (sqrt( (ppA[0]-X)*(ppA[0]-X) + (ppA[1]-Y)*(ppA[1]-Y) ) <=2)
- {
- ok = true;
- }
- return ok;
-}
-
-
-//---------------------------------------------------------------------------
-//---------------------------------------------------------------------------
-//---------------------------------------------------------------------------
-vtkInteractorStyleMPRView::vtkInteractorStyleMPRView()
-{
- _stateMoveAxisX = false;
- _stateMoveAxisY = false;
- _stateMoveAxisZ = false;
-}
-//---------------------------------------------------------------------------
-vtkInteractorStyleMPRView::~vtkInteractorStyleMPRView()
-{
-}
-
-
-//---------------------------------------------------------------------------
-bool vtkInteractorStyleMPRView::OnLeftDClick () // virtual
-{
- wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
- double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
- double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
- double z = 1;
- _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
- wxvtkmpr2Dview->MoveX(x,y,z);
- wxvtkmpr2Dview->MoveY(x,y,z);
- wxvtkmpr2Dview->MoveZ(x,y,z);
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
- wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122); // Doble click
- wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
-
- return true;
-}
-//---------------------------------------------------------------------------
-bool vtkInteractorStyleMPRView::OnLeftButtonDown ()
-{
- wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
- double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
- double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
- double z = 1;
- //double xx = x; // JPRx
- //double yy = y; // JPRx
- _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
-
-/*EED Borrame
- if ((_xBack==xx) && (_yBack==yy))
- {
- wxvtkmpr2Dview->MoveX(x,y,z);
- wxvtkmpr2Dview->MoveY(x,y,z);
- wxvtkmpr2Dview->MoveZ(x,y,z);
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
- wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122); // Doble click
- wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
- }
-
- _xBack=xx;
- _yBack=yy;
-*/
-
- _stateMoveAxisX = wxvtkmpr2Dview->IfMouseTouchX(x,y,z);
- _stateMoveAxisY = wxvtkmpr2Dview->IfMouseTouchY(x,y,z);
- _stateMoveAxisZ = wxvtkmpr2Dview->IfMouseTouchZ(x,y,z);
-
- return true;
-}
-//---------------------------------------------------------------------------
-bool vtkInteractorStyleMPRView::OnLeftButtonUp ()
-{
- if (_stateMoveAxisX==true)
- {
- _stateMoveAxisX=false;
- }
- if (_stateMoveAxisY==true)
- {
- _stateMoveAxisY=false;
- }
- if (_stateMoveAxisZ==true)
- {
- _stateMoveAxisZ=false;
- }
- return true;
-}
-//---------------------------------------------------------------------------
-bool vtkInteractorStyleMPRView::OnMouseMove ()
-{
- double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
- double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
-
- double z=1;
- _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
- wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
-// wxvtkmpr2Dview->TransfromeCoordViewWorld(x,y,z);
-
- wxvtkmpr2Dview->ChangeAxisColor(x,y,z);
-
- if ((_stateMoveAxisX==true) || (_stateMoveAxisY==true) || (_stateMoveAxisZ==true) )
- {
- if (_stateMoveAxisX==true)
- {
- wxvtkmpr2Dview-> MoveX(x,y,z);
- }
- if (_stateMoveAxisY==true)
- {
- wxvtkmpr2Dview->MoveY(x,y,z);
- }
- if (_stateMoveAxisZ==true)
- {
- wxvtkmpr2Dview->MoveZ(x,y,z);
- }
-
- this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
- }
- return true;
-}
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-wxVtkMPR2DView::wxVtkMPR2DView( wxWindow *parent, int direction)
- :wxVtk2DBaseView(parent)
-{
- _backX = -99999;
- _backY = -99999;
- _backZ = -99999;
- _direction = direction;
- _ptsA = NULL;
- _lineAActor = NULL;
- _lineAMapper = NULL;
- _pdA = NULL;
- _ptsB = NULL;
- _lineBActor = NULL;
- _lineBMapper = NULL;
- _pdB = NULL;
-}
-
-//-------------------------------------------------------------------
-wxVtkMPR2DView::~wxVtkMPR2DView()
-{
- if (_ptsA!=NULL) { _ptsA -> Delete(); }
- if (_lineAActor!=NULL) { _lineAActor -> Delete(); }
- if (_lineAMapper!=NULL) { _lineAMapper -> Delete(); }
- if (_pdA!=NULL) { _pdA -> Delete(); }
- if (_ptsB!=NULL) { _ptsB -> Delete(); }
- if (_lineBActor!=NULL) { _lineBActor -> Delete(); }
- if (_lineBMapper!=NULL) { _lineBMapper -> Delete(); }
- if (_pdB!=NULL) { _pdB -> Delete(); }
-}
-//-------------------------------------------------------------------
-vtkMPRBaseData *wxVtkMPR2DView::GetVtkmprbasedata()
-{
- return (vtkMPRBaseData*)GetVtkBaseData();
-}
-//-------------------------------------------------------------------
-void wxVtkMPR2DView::Configure(){
- wxVtk2DBaseView::Configure();
-
- _interactorstylemprview = new vtkInteractorStyleMPRView();
- GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _interactorstylemprview );
-
- int x1,x2,y1,y2,z1,z2;
- GetVtkmprbasedata() -> GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
-
- double spc[3];
- vtkImageData* img = GetVtkmprbasedata()->GetImageData();
- if(img!=NULL){
- img->GetSpacing(spc);
- x1 = (int)(x1*spc[0]);
- y1 = (int)(y1*spc[1]);
- z1 = (int)(z1*spc[2]);
-
- x2 = (int)(x2*spc[0]);
- y2 = (int)(y2*spc[1]);
- z2 = (int)(z2*spc[2]);
-
- _visibleAxis = true;
-
- // Axe A
- _ptsA = vtkPoints::New();
- _ptsA->SetNumberOfPoints(2);
- _ptsA->SetPoint(0, -1000 , -1000 , -1000 );
- _ptsA->SetPoint(1, 1000 , 1000 , 1000 );
- vtkCellArray *linesA;
- linesA = vtkCellArray::New();
- linesA->InsertNextCell(2);
- linesA->InsertCellPoint(0);
- linesA->InsertCellPoint(1);
- _pdA = vtkPolyData::New();
- _pdA->SetPoints( _ptsA );
- _pdA->SetLines( linesA );
- linesA->Delete(); //do not delete lines ??
- _lineAActor = vtkActor::New();
- _lineAMapper = vtkPolyDataMapper::New();
- _lineAMapper->SetInput(_pdA);
- _lineAMapper->ImmediateModeRenderingOn();
- _lineAActor->SetMapper(_lineAMapper);
-// _lineAActor->GetProperty()->BackfaceCullingOn();
- _lineAActor->GetProperty()->SetDiffuseColor(1,0,0);
- _lineAActor->GetProperty()->SetLineWidth(2);
- _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
-
- // Axe B
- _ptsB = vtkPoints::New();
- _ptsB->SetNumberOfPoints(2);
- _ptsB->SetPoint(0, -1000 , -1000 , -1000 );
- _ptsB->SetPoint(1, 1000 , 1000 , 1000 );
- vtkCellArray *linesB;
- linesB = vtkCellArray::New();
- linesB->InsertNextCell(2);
- linesB->InsertCellPoint(0);
- linesB->InsertCellPoint(1);
- _pdB = vtkPolyData::New();
- _pdB->SetPoints( _ptsB );
- _pdB->SetLines( linesB );
- linesB->Delete(); //do not delete lines ??
- _lineBActor = vtkActor::New();
- _lineBMapper = vtkPolyDataMapper::New();
- _lineBMapper->SetInput(_pdB);
- _lineBMapper->ImmediateModeRenderingOn();
- _lineBActor->SetMapper(_lineBMapper);
-// _lineBActor->GetProperty()->BackfaceCullingOn();
- _lineBActor->GetProperty()->SetDiffuseColor(1,0,0);
- _lineBActor->GetProperty()->SetLineWidth(2);
- _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==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) {
- 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==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 );
- }
-
-
-
- }
-
-// _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160);
-// _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800);
-
-}
-
-void wxVtkMPR2DView::SetVisibleAxis(bool ok)
-{
- if (ok!=_visibleAxis)
- {
- _visibleAxis=ok;
- if (_visibleAxis==true)
- {
- _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
- _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
- }
- if (_visibleAxis==false)
- {
- _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineAActor );
- _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineBActor );
- }
-
- }
-}
-
-//-------------------------------------------------------------------
-void wxVtkMPR2DView::Refresh()
-{
- //wxVtk2DBaseView::Refresh();
-
-
- //vtkImageViewer2 *IV2=_imageViewer2XYZ->GetVtkImageViewer2(); // JPRx
- //vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera(); // JPRx
-
-
-
- int x1,x2,y1,y2,z1,z2;
- GetVtkmprbasedata()->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
- double spc[3];
-
- vtkImageData* img = GetVtkmprbasedata()->GetImageData();
- if(img!=NULL){
- img->GetSpacing(spc);
- x1 = (int)(x1*spc[0]);
- y1 = (int)(y1*spc[1]);
- z1 = (int)(z1*spc[2]);
-
- x2 = (int)(x2*spc[0]);
- y2 = (int)(y2*spc[1]);
- z2 = (int)(z2*spc[2]);
-
- int x = (int)(GetVtkmprbasedata()->GetX());
- int y = (int)(GetVtkmprbasedata()->GetY());
- int z = (int)(GetVtkmprbasedata()->GetZ());
-
- x = (int)(x*spc[0]);
- y = (int)(y*spc[1]);
- z = (int)(z*spc[2]);
-
-
-
- if ((x!=_backX) || (y!=_backY) || (z!=_backZ)) {
-
- if (_direction==0) {
- _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) {
- _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) {
- _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
- _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
- // _ptsA->SetPoint(0, x1 , y , -z2 );
- // _ptsA->SetPoint(1, x2 , y , -z2 );
- // _ptsB->SetPoint(0, x , y1, -z2 );
- // _ptsB->SetPoint(1, x , y2, -z2 );
-
- _ptsA->SetPoint(0, x1 , y , z2 );
- _ptsA->SetPoint(1, x2 , y , z2 );
- _ptsB->SetPoint(0, x , y1, z2 );
- _ptsB->SetPoint(1, x , y2, z2 );
- }
- _backX=x;
- _backY=y;
- _backZ=z;
- }
- wxVtkBaseView::Refresh();
- }
-}
-//-------------------------------------------------------------------
-int wxVtkMPR2DView::GetActualSlice() // virtual
-{
- int result;
- if (_direction==0)
- {
- result = (int)(GetVtkmprbasedata()->GetX());
- }
- if (_direction==1)
- {
- result = (int)(GetVtkmprbasedata()->GetY());
- }
- if (_direction==2)
- {
- result = (int)(GetVtkmprbasedata()->GetZ());
- }
- return result;
-}
-//-------------------------------------------------------------------
-void wxVtkMPR2DView::SetActualSlice(int slice) // virtual
-{
- if (_direction==0)
- {
- GetVtkmprbasedata()->SetX(slice);
- }
- if (_direction==1)
- {
- GetVtkmprbasedata()->SetY(slice);
- }
- if (_direction==2)
- {
- GetVtkmprbasedata()->SetZ(slice);
- }
-}
-//-------------------------------------------------------------------
-bool wxVtkMPR2DView::IfMouseTouchX(double x, double y, double z)
-{
- double delta=5;
- bool result=false;
- if (_direction==0)
- {
- }
- if (_direction==1)
- {
- if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
- {
- result = true;
- }
- }
- if (_direction==2)
- {
- if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
- {
- result = true;
- }
- }
- return result;
-}
-//-------------------------------------------------------------------
-bool wxVtkMPR2DView::IfMouseTouchY(double x, double y, double z)
-{
- double delta=5;
- bool result=false;
- if (_direction==0)
- {
- if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
- {
- result = true;
- }
- }
- if (_direction==1)
- {
- }
- if (_direction==2)
- {
- if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
- {
- result = true;
- }
- }
- return result;
-}
-//-------------------------------------------------------------------
-bool wxVtkMPR2DView::IfMouseTouchZ(double x, double y, double z)
-{
- double delta=5;
- bool result=false;
- if (_direction==0)
- {
- if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
- {
- result = true;
- }
- }
- if (_direction==1)
- {
- if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
- {
- result = true;
- }
- }
- if (_direction==2)
- {
- }
- return result;
-}
-//-------------------------------------------------------------------
-void wxVtkMPR2DView::MoveX(double x, double y, double z)
-{
- if (_direction==0)
- {
- }
- if (_direction==1)
- {
- GetVtkmprbasedata()->SetX(x);
- }
- if (_direction==2)
- {
- GetVtkmprbasedata()->SetX(x);
- }
-}
-//-------------------------------------------------------------------
-void wxVtkMPR2DView::MoveY(double x, double y, double z)
-{
- if (_direction==0)
- {
- GetVtkmprbasedata()->SetY(y);
- }
- if (_direction==1)
- {
- }
- if (_direction==2)
- {
- GetVtkmprbasedata()->SetY(y);
- }
-}
-//-------------------------------------------------------------------
-void wxVtkMPR2DView::MoveZ(double x, double y, double z)
-{
- if (_direction==0)
- {
- GetVtkmprbasedata()->SetZ(z);
- }
- if (_direction==1)
- {
- GetVtkmprbasedata()->SetZ(z);
- }
- if (_direction==2)
- {
- }
-}
-//-------------------------------------------------------------------
-void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z)
-{
- double c1r=1,c1g=1,c1b=0;
- double c2r=1,c2g=0,c2b=0;
-
- if (_direction==0)
- {
- if (IfMouseTouchY(x,y,z)==true)
- {
- _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
- } else {
- _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
- }
- if (IfMouseTouchZ(x,y,z)==true)
- {
- _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
- } else {
- _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
- }
- }
-
- if (_direction==1)
- {
- if (IfMouseTouchX(x,y,z)==true)
- {
- _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
- } else {
- _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
- }
- if (IfMouseTouchZ(x,y,z)==true)
- {
- _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
- } else {
- _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
- }
- }
-
- if (_direction==2)
- {
- if (IfMouseTouchX(x,y,z)==true)
- {
- _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
- } else {
- _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
- }
- if (IfMouseTouchY(x,y,z)==true)
- {
- _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
- } else {
- _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
- }
- }
- Refresh();
-}
-//-------------------------------------------------------------------
-void wxVtkMPR2DView::TransfromeCoordViewWorld(double &X, double &Y, double &Z, int type) // virtual
-{
- wxVtkBaseView::TransfromeCoordScreenToWorld(X,Y,Z,_direction);
-
- if (_direction==0)
- {
- X = ((vtkMPRBaseData*)GetVtkBaseData())->GetX();
- }
- if (_direction==1)
- {
- Y = ((vtkMPRBaseData*)GetVtkBaseData())->GetY();
- }
- if (_direction==2)
- {
- Z = ((vtkMPRBaseData*)GetVtkBaseData())->GetZ();
- }
-}
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//void boxVolumeObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) { // virtual
-// if (eventId==vtkCommand::StartInteractionEvent){
-// _renWin->SetDesiredUpdateRate(10);
-// }
-// if (eventId==vtkCommand::InteractionEvent){
-// _renWin->SetDesiredUpdateRate(0.001);
-// }
-// if (eventId==vtkCommand::EndInteractionEvent){
-// vtkPlanes *planes = vtkPlanes::New();
-// vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
-// boxwidget->GetPlanes(planes);
-// _volumeMapper->SetClippingPlanes(planes);
-// planes -> Delete();
-// }
-//}
-
-//-------------------------------------------------------------------
-//void boxVolumeObserver::SetRenWin( vtkRenderWindow *renWin ){
-// _renWin = renWin;
-//}
-//-------------------------------------------------------------------
-//void boxVolumeObserver::SetVolumeMapper(vtkVolumeRayCastMapper *volumeMapper){
-// _volumeMapper = volumeMapper;
-//}
-
-
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-// EED 9 fev 2007
-void boxSurfaceObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) { // virtual
- vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
- boxwidget->GetPlanes(_planes);
-
- if ( _vtkVolumeRayCastMapper != NULL )
- {
- _vtkVolumeRayCastMapper->RemoveAllClippingPlanes();
-// vtkPlanes *planes = vtkPlanes::New();
-// boxwidget->GetPlanes(planes);
-// _vtkVolumeRayCastMapper->SetClippingPlanes(planes);
- _vtkVolumeRayCastMapper->SetClippingPlanes(_planes);
- }
-
-// _actor->VisibilityOn();
-
-}
-//-------------------------------------------------------------------
-void boxSurfaceObserver::SetPlanes(vtkPlanes *planes){
- _planes = planes;
-}
-//-------------------------------------------------------------------
-void boxSurfaceObserver::SetActor(vtkProp *actor){
- _actor = actor;
-}
-
-//-------------------------------------------------------------------
-void boxSurfaceObserver::SetvtkVolumeRayCastMapper(vtkVolumeRayCastMapper *vtkvolumeraycastmapper)
-{
- _vtkVolumeRayCastMapper = vtkvolumeraycastmapper;
-}
-
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-wxVtkMPR3DViewCntrlPanel::wxVtkMPR3DViewCntrlPanel(wxWindow *parent, wxVtkMPR3DView *wxvtkmpr3Dview )
-: wxPanel(parent, -1)
-{
-
- wxPanel *panel = this;
- _wxvtkmpr3Dview = wxvtkmpr3Dview;
-
- /*int maxX = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
- int maxY = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
- int maxZ = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();*/
-
- int maxX = 1;
- int maxY = 1;
- int maxZ = 1;
-
- wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,_T("X "));
- _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
- wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,_T("Y "));
- _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
- wxCheckBox *ckBoxZ = new wxCheckBox(panel,-1,_T("Z "));
- _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
- wxButton *btnColorTable = new wxButton (panel, -1, _T("Edit Color Table") );
-
- _ckBoxXYZ = new wxCheckBox(panel,-1,_T("XYZ "));
- _ckBoxPlane = new wxCheckBox(panel,-1,_T("Plane"));
-
- ckBoxX->SetValue(false);
- ckBoxY->SetValue(false);
- ckBoxZ->SetValue(false);
- _ckBoxXYZ->SetValue(false);
- _ckBoxPlane->SetValue(false);
-
- _positionX->SetSize(400,20);
- _positionY->SetSize(400,20);
- _positionZ->SetSize(400,20);
-
- Connect(ckBoxX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX );
- Connect(_positionX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionX );
- Connect(ckBoxY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY );
- Connect(_positionY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionY );
- Connect(ckBoxZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ );
- Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
- Connect(btnColorTable->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnEditColorTable );
-
- Connect(_ckBoxXYZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ );
- Connect(_ckBoxPlane->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisiblePlane );
-
-
- wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
-// wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-
-// wxBoxSizer *sizerH4 = new wxBoxSizer(wxHORIZONTAL);
- wxFlexGridSizer *sizerH4 = new wxFlexGridSizer(10);
- wxFlexGridSizer *sizerH5 = new wxFlexGridSizer(10);
-
-
-
-//EED 28 sep 2006
-// wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10);
-// wxFlexGridSizer *sizerH7 = new wxFlexGridSizer(10);
-
-// sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
-// sizerH4->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
-// sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0);
-
-// sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
-// sizerH5->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
-// sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0);
-
-// sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
-// sizerH6->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
-// sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0);
-
-// sizerH7->Add( _ckBoxXYZ , 1, wxALL|wxEXPAND, 0);
-// sizerH7->Add( _ckBoxPlane , 1, wxALL|wxEXPAND, 0);
-
-// sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2);
-// sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
-// sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2);
-// sizer->Add( sizerH7 , 1, wxALL|wxEXPAND, 2);
-
- sizerH4->Add( _positionX ,1,wxGROW , 0 );
- sizerH4->Add( ckBoxX ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
- sizerH4->Add( _positionY ,1,wxGROW , 0 );
- sizerH4->Add( ckBoxY ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
- sizerH4->Add( _positionZ ,1,wxGROW , 0 );
- sizerH4->Add( ckBoxZ ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
- sizerH4->Add( btnColorTable ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
-
- sizerH5->Add( _ckBoxXYZ , 1, wxALL|wxEXPAND, 0);
- sizerH5->Add( _ckBoxPlane , 1, wxALL|wxEXPAND, 0);
- sizerH5->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
-// sizerH5->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
-// sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
-// sizerH5->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
-
- sizer->Add( sizerH4 , 1, wxALL|wxGROW, 2);
- sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
-
-
- panel->SetSize(400,50);
- panel->SetAutoLayout(true);
- panel->SetSizer(sizer);
- panel->Layout();
-
- panel->SetEventHandler((wxEvtHandler*)this);
-
- //this->UpdateControlPanel();
-
-}
-void wxVtkMPR3DViewCntrlPanel::UpdateControlPanel()
-{
-
- vtkMPRBaseData* basedata = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData();
- if(basedata != NULL){
-
- /*int maxX = basedata->GetMaxPositionX();
- int maxY = basedata->GetMaxPositionY();
- int maxZ = basedata->GetMaxPositionZ();*/
- 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();*/
-
-
-
- //std::cout<<"wxVtkMPR3DViewCntrlPanel::UpdateControlPanel() maxX="<<maxX<<" maxY="<<maxY<<" maxZ="<<maxZ<<std::endl;
- /*_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();
- }
-
-}
-//-------------------------------------------------------------------
-wxVtkMPR3DViewCntrlPanel::~wxVtkMPR3DViewCntrlPanel()
-{
-}
-//-------------------------------------------------------------------
-void wxVtkMPR3DViewCntrlPanel::Refresh()
-{
-// wxPanel::Refresh();
- _positionX->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX( )) );
- _positionY->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY( )) );
- _positionZ->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ( )) );
-}
-/*
-//-------------------------------------------------------------------
-int wxVtkMPR3DViewCntrlPanel::GetIdTissue()
-{
- int idTissue=-1;
- if (_surfA->GetValue()==true)
- {
- idTissue=0;
- }
- if (_surfB->GetValue()==true)
- {
- idTissue=1;
- }
- if (_surfC->GetValue()==true)
- {
- idTissue=2;
- }
- if (_surfD->GetValue()==true)
- {
- idTissue=3;
- }
-
- return idTissue;
-}
-*/
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DViewCntrlPanel::OnEditColorTable(wxCommandEvent& event)
-{
-
- vtkColorTransferFunction *ctfun = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetvtkColorTransferFunction();
- std::vector<double> *ctfunVectorPoint = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorPoint();
- std::vector<double> *ctfunVectorRed = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorRed();
- std::vector<double> *ctfunVectorGreen = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorGreen();
- std::vector<double> *ctfunVectorBlue = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorBlue();
-
- printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfun %p\n", this, ctfun);
- printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorPoint %p\n", this, ctfunVectorPoint);
- printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorRed %p\n", this, ctfunVectorRed);
- printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorGreen %p\n", this, ctfunVectorGreen);
- printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorBlue %p\n", this, ctfunVectorBlue);
-
-
- //void *p=this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer(); // JPRx
-
-
- int i=0,xi,r,g,b;
-
- vtkImageData *imagedata = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
-
- HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Color table"),imagedata,2);
-
-
- hDlg->erasePointsTransferenceFunction();
- int ctfSize=ctfunVectorRed->size();
- if(ctfSize>0)
- {
-// MACHETE OJO Eduardo
- int i=0;
- while(i<ctfSize)
- {
- double gr = (*ctfunVectorPoint)[i];
- double r = (*ctfunVectorRed)[i];
- double g = (*ctfunVectorGreen)[i];
- double b = (*ctfunVectorBlue)[i];
-
-hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
- i++;
- }
- }
-
- //
- // when the user had changed the transference Function
- //
-
- //setting variables if the user wants to do refresh
-
- hDlg->setCTF(ctfun);
- hDlg->setMPR3Dview(_wxvtkmpr3Dview);
-
- if(hDlg->ShowModal()== wxID_OK )
- {
-
- // -- vtkColorTransferFunction --
- ctfun->RemoveAllPoints ();
- //clean colors
- ctfunVectorPoint->clear();
- ctfunVectorRed->clear();
- ctfunVectorGreen->clear();
- ctfunVectorBlue->clear();
-
- int nCTFpoints=hDlg->getSizeBarColor();
-// Machete .. Ojo Eduardo
- i=0;
- while(i<nCTFpoints)
- {
- hDlg->getDataBarColorPoint(i,xi,r,g,b);
- /*
- if (i==0)
- {
- hDlg->getDataBarColorPoint(1,xi,r,g,b);
- }
- if (i==nCTFpoints)
- {
- hDlg->getDataBarColorPoint(i-1,xi,r,g,b);
- }
- */
- ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
- ctfunVectorPoint->push_back(xi);
- ctfunVectorRed->push_back(r/255.0);
- ctfunVectorGreen->push_back(g/255.0);
- ctfunVectorBlue->push_back(b/255.0);
- i++;
-
- }
-
- }
-
- else
- {
-
- if(hDlg->getRefreshed())
- {
- // -- vtkColorTransferFunction --
- ctfun->RemoveAllPoints ();
-
- int i=0;
- int size=ctfunVectorPoint->size();
-
- for(i=0;i<size;i++)
- {
- double grey2=(*ctfunVectorPoint)[i];
- double red =(*ctfunVectorRed)[i];
- double green =(*ctfunVectorGreen)[i];
- double blue = (*ctfunVectorBlue)[i];
- ctfun->AddRGBPoint(grey2,red,green,blue);
- }
- }
-
- }
-
- hDlg->Destroy();
-}
-
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
-{
- _wxvtkmpr3Dview->VisibleImageActor(0, event.IsChecked() );
- _wxvtkmpr3Dview->Refresh();
-
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
-
- try{
- _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
- }catch(char* e){
- std::cout<<e<<std::endl;
- }
-
-}
-//-------------------------------------------------------------------
-void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
-{
- _wxvtkmpr3Dview->VisibleImageActor(1, event.IsChecked() );
- _wxvtkmpr3Dview->Refresh();
-
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-
-}
-//-------------------------------------------------------------------
-void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
-{
- _wxvtkmpr3Dview->VisibleImageActor(2, event.IsChecked() );
- _wxvtkmpr3Dview->Refresh();
-
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-}
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ(wxCommandEvent& event)
-{
- _wxvtkmpr3Dview->VisiblePointWidget(event.IsChecked());
-}
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DViewCntrlPanel::OnVisiblePlane(wxCommandEvent& event)
-{
- _wxvtkmpr3Dview->VisiblePlaneWidget(event.IsChecked());
-}
-
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DViewCntrlPanel::OnPositionX(wxScrollEvent& event)
-{
- _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( _positionX->GetValue() );
- _wxvtkmpr3Dview->RefreshView();
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-}
-//-------------------------------------------------------------------
-void wxVtkMPR3DViewCntrlPanel::OnPositionY(wxScrollEvent& event)
-{
- _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( _positionY->GetValue() );
- _wxvtkmpr3Dview->RefreshView();
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-}
-//-------------------------------------------------------------------
-void wxVtkMPR3DViewCntrlPanel::OnPositionZ(wxScrollEvent& event)
-{
- _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( _positionZ->GetValue() );
- _wxvtkmpr3Dview->RefreshView();
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-}
-
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-wxVtkClipping3DViewCntrlPanel::wxVtkClipping3DViewCntrlPanel(wxWindow *parent, wxVtkClipping3DView *wxvtkclipping3Dview )
-: wxPanel(parent, -1)
-{
- wxPanel *panel = this;
- _wxvtkclipping3Dview = wxvtkclipping3Dview;
-
-//EEDx2.6
-// wxStaticText *text1 = new wxStaticText(panel, -1,_T(" "));
-// wxStaticText *text2 = new wxStaticText(panel, -1,_T(" "));
-
- _surfA = new wxRadioButton(panel,-1,_T("A"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
- _surfB = new wxRadioButton(panel,-1,_T("B"));
- _surfC = new wxRadioButton(panel,-1,_T("C"));
- _surfD = new wxRadioButton(panel,-1,_T("D"));
-
- wxCheckBox *ckVolum = new wxCheckBox(panel,-1,_T("Vol"));
- wxCheckBox *ckBoxSurface = new wxCheckBox(panel,-1,_T("Surface Box"));
- wxCheckBox *ckBoxVolume = new wxCheckBox(panel,-1,_T("Volume Box"));
-
- _color = new wxButton(panel,-1,_T(""));
- _visible = new wxCheckBox(panel,-1,_T("Vis"));
- _opacity = new wxSlider(panel,-1,50,0,100, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_LABELS);
-
- wxStaticText *isoValueTitle = new wxStaticText(panel,-1,_T("isoValue"));
- _isoValue = new wxSlider(panel,-1,2000,110,2000, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS);
-
-
- _wireFrameRep = new wxRadioButton(panel,-1,_T("WireFrame"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
- _surfaceRep = new wxRadioButton(panel,-1,_T("Surface"));
-
-
- double range[2];
- vtkImageData *vtkimagedata = wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
- vtkimagedata->GetScalarRange( range );
- _isoValue->SetRange( (int)(range[1]*0.1) , (int)(range[1]) );
- _isoValue->SetValue( (int)(wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(0)) );
-
-
- _isoValue->SetTickFreq(25,0);
-
- _isoValueSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT );
- _isoValueSpin->SetRange(1,8);
- _isoValueSpin->SetValue(5);
- Connect(_isoValueSpin->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin );
-
- wxButton *btnSTL = new wxButton(panel,-1,_T("Create STL File"));
- wxButton *btnSaveRaw = new wxButton(panel,-1,_T("Save Raw Volume"));
-
- wxButton *btnVolumeFunctions = new wxButton(panel,-1,_T("Read Volume Functions"));
-
-
- Connect(btnSTL->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL );
- Connect(btnSaveRaw->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume );
- Connect(btnVolumeFunctions->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions );
-
-
- wxButton *btnMeshVTKLoad = new wxButton(panel,-1,_T("Load Mesh"));
- Connect(btnMeshVTKLoad->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad );
-
-
-/*
- int maxX = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
- int maxY = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
- int maxZ = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();
- wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,"X");
- _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
- wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,"Y");
- _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
- wxCheckBox *ckBoxZ = new wxCheckBox(panel,-1,"Z");
- _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
-*/
-
-// ckVolum->Enable(false);
- ckBoxSurface->SetValue(false);
- ckBoxVolume->SetValue(false);
- _color->SetSize(40,20);
- _opacity->SetSize(370,20);
-// ckBoxX->SetValue(true);
-// ckBoxY->SetValue(true);
-// ckBoxZ->SetValue(true);
- _surfA->SetValue(true);
- _wireFrameRep->SetValue(false);
- _surfaceRep->SetValue(true);
- _visible->SetValue(false);
-// _positionX->SetSize(400,20);
-// _positionY->SetSize(400,20);
-// _positionZ->SetSize(400,20);
-
- Connect(ckVolum->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleVolume );
- Connect(ckBoxVolume->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume );
-
- Connect(_surfA->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
- Connect(_surfB->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
- Connect(_surfC->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
- Connect(_surfD->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
- Connect(ckBoxSurface->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface );
-
- Connect(_wireFrameRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
- Connect(_surfaceRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
-
- Connect(_color->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnColor );
- Connect(_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleSurface );
- Connect(_opacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnOpacity );
-
-//EED 27Dic2007
-// Connect(_isoValue->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
- Connect(_isoValue->GetId() , wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
-
-/*
- Connect(ckBoxX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX );
- Connect(_positionX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionX );
- Connect(ckBoxY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY );
- Connect(_positionY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionY );
- Connect(ckBoxZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ );
- Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
-*/
-
- wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
- wxFlexGridSizer *sizerH0 = new wxFlexGridSizer(20);
- wxFlexGridSizer *sizerH1 = new wxFlexGridSizer(20);
- wxFlexGridSizer *sizerH2 = new wxFlexGridSizer(10);
- wxFlexGridSizer *sizerH3 = new wxFlexGridSizer(10);
- //wxFlexGridSizer *sizerH4 = new wxFlexGridSizer(10); // JPRx
- //wxFlexGridSizer *sizerH5 = new wxFlexGridSizer(10); // JPRx
- //wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10); // JPRx
-
- sizerH0->Add( ckVolum , 1, wxALL|wxEXPAND, 0);
- sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
- sizerH0->Add( ckBoxVolume , 1, wxALL|wxEXPAND, 0);
- sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
- sizerH0->Add( btnVolumeFunctions , 1, wxALL|wxEXPAND, 0);
- sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
- sizerH0->Add( btnMeshVTKLoad , 1, wxALL|wxEXPAND, 0);
-
-
- sizerH1->Add( _surfA , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( _surfB , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( _surfC , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( _surfD , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( ckBoxSurface , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( btnSTL , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
- sizerH1->Add( btnSaveRaw , 1, wxALL|wxEXPAND, 0);
-
-
-// sizerH2->Add( new wxStaticText(panel, -1,_T(" ") , 1, wxALL|wxEXPAND, 0);
- sizerH2->Add( _color , 1, wxALL|wxEXPAND, 0);
- sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
- sizerH2->Add( _visible , 1, wxALL|wxEXPAND, 0);
- sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
-
-
- sizerH2->Add( _wireFrameRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
- sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
- sizerH2->Add( _surfaceRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
- sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
-
- sizerH2->Add( _opacity , 1, wxALL|wxEXPAND, 0);
-
-
- sizerH3->Add( isoValueTitle , 1, wxALL|wxEXPAND, 0);
- sizerH3->Add( _isoValueSpin , 1, wxALL|wxEXPAND, 0);
- sizerH3->Add( _isoValue , 1, wxALL|wxEXPAND, 0);
-
-/*
- sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
- sizerH4->Add( text2 , 1, wxALL|wxEXPAND, 0);
- sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0);
-
- sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
- sizerH5->Add( text2 , 1, wxALL|wxEXPAND, 0);
- sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0);
-
- sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
- sizerH6->Add( text2 , 1, wxALL|wxEXPAND, 0);
- sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0);
-*/
- sizer->Add( sizerH0 , 1, wxALL|wxEXPAND, 2);
- sizer->Add( sizerH1 , 1, wxALL|wxEXPAND, 2);
- sizer->Add( sizerH2 , 1, wxALL|wxEXPAND, 2);
- sizer->Add( sizerH3 , 1, wxALL|wxEXPAND, 2);
-// sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2);
-// sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
-// sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2);
-
- panel->SetSize(300,60);
- panel->SetAutoLayout(true);
- panel->SetSizer(sizer);
- panel->Layout();
-
- panel->SetEventHandler((wxEvtHandler*)this);
-
-}
-//-------------------------------------------------------------------
-wxVtkClipping3DViewCntrlPanel::~wxVtkClipping3DViewCntrlPanel()
-{
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::Refresh()
-{
-// wxPanel::Refresh();
-/*
- _positionX->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetX( ) );
- _positionY->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetY( ) );
- _positionZ->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetZ( ) );
-*/
-}
-//-------------------------------------------------------------------
-int wxVtkClipping3DViewCntrlPanel::GetIdTissue()
-{
- int idTissue=-1;
- if (_surfA->GetValue()==true)
- {
- idTissue=0;
- }
- if (_surfB->GetValue()==true)
- {
- idTissue=1;
- }
- if (_surfC->GetValue()==true)
- {
- idTissue=2;
- }
- if (_surfD->GetValue()==true)
- {
- idTissue=3;
- }
-
- return idTissue;
-}
-/*
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
-{
- _wxvtkclipping3Dview->VisibleImageActor(0, event.IsChecked() );
- _wxvtkclipping3Dview->Refresh();
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
-{
- _wxvtkclipping3Dview->VisibleImageActor(1, event.IsChecked() );
- _wxvtkclipping3Dview->Refresh();
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
-{
- _wxvtkclipping3Dview->VisibleImageActor(2, event.IsChecked() );
- _wxvtkclipping3Dview->Refresh();
-}
-*/
-
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnSurface(wxCommandEvent& event)
-{
- int idTissue=GetIdTissue();
- if (idTissue!=-1)
- {
- // Color
- vtkActor *tmpActor;
- tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
- double rgb[3];
- tmpActor->GetProperty()->GetColor( rgb );
- wxColour colour( (int)(rgb[0]*255) , (int)(rgb[1]*255) , (int)(rgb[2]*255) );
- _color->SetBackgroundColour(colour);
-
- // Visible
- _visible->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVisibleTissue(idTissue));
-
- // Opacity
- _opacity->SetValue( (int)(tmpActor->GetProperty()->GetOpacity()*100) );
-
- // Representation Type WireFrame / Surface
- _surfaceRep->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
- _wireFrameRep->SetValue(!_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
-
- // isoValue
- int isoValue= (int)(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(idTissue));
- _isoValue->SetValue(isoValue);
- }
-}
-
-
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame(wxCommandEvent& event)
-{
- int idTissue=GetIdTissue();
- if (idTissue!=-1)
- {
- _wxvtkclipping3Dview->SetRepSurfaceWireFrame(idTissue , _surfaceRep->GetValue() );
-
- _wxvtkclipping3Dview->Refresh();
-
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-
- }
-}
-
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnVisibleVolume(wxCommandEvent& event)
-{
- _wxvtkclipping3Dview->VisibleVolumeActor( event.IsChecked() );
- _wxvtkclipping3Dview->Refresh();
-
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface(wxCommandEvent& event)
-{
- _wxvtkclipping3Dview->SetVisibleBoxSurface(event.IsChecked() );
- _wxvtkclipping3Dview->Refresh();
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume(wxCommandEvent& event)
-{
- _wxvtkclipping3Dview->SetVisibleBoxVolume(event.IsChecked() );
- _wxvtkclipping3Dview->Refresh();
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnColor(wxCommandEvent& event)
-{
- int idTissue=GetIdTissue();
- if (idTissue!=-1)
- {
-// EED 17 Janvier 2007
- wxColourDialog dlgColour(this);
-// dlgColour.ShowModal();
- if( dlgColour.ShowModal( ) == wxID_OK )
- {
- vtkActor *tmpActor;
- tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
- float r=dlgColour.GetColourData().GetColour().Red()/255;
- float g=dlgColour.GetColourData().GetColour().Green()/255;
- float b=dlgColour.GetColourData().GetColour().Blue()/255;
- tmpActor->GetProperty()->SetColor( r , g , b );
- _color->SetBackgroundColour(dlgColour.GetColourData().GetColour());
-
- _wxvtkclipping3Dview->Refresh();
-
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
- }
- }
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnVisibleSurface(wxCommandEvent& event)
-{
- int idTissue=GetIdTissue();
- if (idTissue!=-1)
- {
- _wxvtkclipping3Dview->VisibleActor(idTissue, _visible->GetValue());
-
- _wxvtkclipping3Dview->Refresh();
-
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
- }
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnOpacity(wxScrollEvent& event)
-{
- int idTissue=GetIdTissue();
- if (idTissue!=-1)
- {
- vtkActor *tmpActor;
- tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
- float opacity=_opacity->GetValue();
- tmpActor->GetProperty()->SetOpacity( opacity/100 );
-
- _wxvtkclipping3Dview->Refresh();
-
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
- }
-}
-
-//----------------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin(wxScrollEvent& event)
-{
- int value = _isoValue->GetValue();
- int delta= (int)pow( 4 , _isoValueSpin->GetValue() );
- int min=value - delta/2;
- int max=value + delta/2;
- if (min<0)
- {
- min=0;
- max=delta;
- }
- _isoValue->SetRange(min,max);
-}
-
-
-//------------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnIsoValue(wxScrollEvent& event)
-{
- wxBusyCursor wait;
-
- int idTissue=GetIdTissue();
- if (idTissue!=-1)
- {
- int isoValue=_isoValue->GetValue();
- _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->SetIsovalue(idTissue,isoValue);
-// wxString tmpStr;
-// tmpStr.Printf("%d",isoValue);
-
- _wxvtkclipping3Dview->Refresh();
-
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
- }
-
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL(wxCommandEvent& event)
-{
-
- int idTissue=GetIdTissue();
- if (idTissue==-1)
- {
- idTissue=0;
- }
-
-
- wxString dirSTL = wxGetHomeDir( ) ;
- wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
-
- if( dialog.ShowModal( ) == wxID_OK )
- {
-
-
- // ------------------------------------------------------------------------
- // 1. GENERATE STL FILES
- // ------------------------------------------------------------------------
-// const char* fileprefix = "c:\\Creatis\\";
- std::string prefix = (const char*) (dialog.GetPath().mb_str() );
- std::string filename;
-
- // 1.1. Se hace un filtro triangular puesto que el stl writer solo recibe poligonos triangulares.
-
- vtkTriangleFilter *filtro = vtkTriangleFilter::New();
-
-
- filtro->SetInput( this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueClipper(idTissue)->GetOutput() );
- vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
- pdcf->SetInput( filtro->GetOutput() );
- vtkClosePolyData *cpd = vtkClosePolyData::New();
- cpd->SetInput( pdcf->GetOutput() );
-
- // 1.2 se escribe a disco el archivo stl de la superficie interna
- cpd->Update();
- vtkSTLWriter *writer = vtkSTLWriter::New();
- writer->SetInput( cpd->GetOutput() );
- filename =prefix;
- writer->SetFileName(filename.c_str());
- writer->SetFileTypeToASCII();
- writer->Write();
- writer->Delete();
-
-
- filtro->Delete();
- cpd->Delete();
- pdcf->Delete();
- }
-
-}
-
-//EED 30 Janvier 2007
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume(wxCommandEvent& event)
-{
- wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.maracas"), wxSAVE );
- if (dialog.ShowModal() == wxID_OK)
- {
- std::string directory = (const char*) (dialog.GetDirectory().mb_str() );
- std::string filename = (const char*) (dialog.GetFilename().mb_str() );
- float rescalaSlope = 1;
- float rescalaIntercept = 0;
- vtkMPRBaseData *vtkmprbasedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData();
- vtkImageData *vtkimagedata = vtkmprbasedata->GetImageData();
- int dim[3];
- vtkimagedata->GetDimensions(dim);
- int voi[6];
- voi[0]=0;
- voi[1]=dim[0];
- voi[2]=0;
- voi[3]=dim[1];
- voi[4]=0;
- voi[5]=dim[2];
-//EED 10 oct 2007 MaracasVisu pour bbMaracasvisu
- marRAW2Files marraw2;
- marraw2.saveVolume(directory,filename,vtkimagedata,voi,rescalaSlope,rescalaIntercept);
- }
-}
-
-//EED 22 Fevrier 2007
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
-{
-
- int /*i=0,*/ xi,yi,r,g,b; // JPRx
- vtkColorTransferFunction* ctfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetColorTransferenceFunction();
- vtkPiecewiseFunction* tfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTransferencefunction();
- std::vector<double>* gtf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValuesTransferenceFVector();
- std::vector<double>* itf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIntensityValuesTransferenceFVector();
- std::vector<double>* greyctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValueColorsOfColorTransferenceFVector();
- std::vector<double>* rctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRedColorsOfColorTransferenceFVector();
- std::vector<double>* gctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreenColorsOfColorTransferenceFVector();
- std::vector<double>* bctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetBlueColorsOfColorTransferenceFVector();
- vtkImageData *imagedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
-
-
-
- //use for update in the refresh
- /*
- vtkVolumeRayCastMapper* volumeMapper = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeMapper();
- vtkVolume* newvol =this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeActor();
- */
-
- /*
- MMLR BORRAME
- wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.MarVolConf"), wxOPEN);
- if (dialog.ShowModal() == wxID_OK)
- {
- _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions( (char *)dialog.GetPath().c_str() );
-
-
- }
- */
-
- HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata,1);
- //
- // put in a method
- //
- int tfSize=gtf->size();
- if(tfSize>0)
- {
- int i=0;
- hDlg->erasePointsTransferenceFunction();
- while(i<tfSize)
- {
- double g=(*gtf)[i];
- double in=(*itf)[i];
- hDlg->addPointToTransferenceFunction(g,in*100);
- i++;
- }
-
- }
-
- int ctfSize=rctf->size();
- if(ctfSize>0)
- {
- int i=0;
- while(i<ctfSize)
- {
- double gr=(*greyctf)[i];
- double r=(*rctf)[i];
- double g=(*gctf)[i];
- double b=(*bctf)[i];
- hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
- i++;
- }
- }
- //setting variables if the user wants to do refresh
- hDlg->setCTF(ctfun);
- hDlg->setTF(tfun);
- hDlg->setClipping3DView(_wxvtkclipping3Dview);
- /*
- hDlg->setVolume(newvol);
- hDlg->setVolumeMapper(volumeMapper);
- */
- //
- // when the user had changed the transference Function
- //
- if(hDlg->ShowModal()== wxID_OK )
- {
- // -- vtkPiecewiseFunction --
- tfun->RemoveAllPoints();
- gtf->clear();
- itf->clear();
-
- int nTFPoints=hDlg->getSizeTransferenceFunction();
- int i=0;
- while(i<nTFPoints)
- {
- hDlg->getTransferenceFunctionPoint(i,xi,yi);
- tfun->AddPoint( xi , yi/100.0 );
- gtf->push_back(xi);
- itf->push_back(yi/100.0);
- i++;
- }
- // -- vtkColorTransferFunction --
- ctfun->RemoveAllPoints ();
- //clean colors
- rctf->clear();
- gctf->clear();
- bctf->clear();
- greyctf->clear();
-
- int nCTFpoints=hDlg->getSizeBarColor();
- i=0;
- while(i<nCTFpoints)
- {
- hDlg->getDataBarColorPoint(i,xi,r,g,b);
- ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
- rctf->push_back(r/255.0);
- gctf->push_back(g/255.0);
- bctf->push_back(b/255.0);
- greyctf->push_back(xi);
- i++;
- }
- //---------------------------------
- // Refreshing and sending the event
- //---------------------------------
- //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
- _wxvtkclipping3Dview->Refresh();
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-
- /*
- volumeMapper->Update();
- newvol->Update();
- */
- }
-
- else
- {
-
- if(hDlg->getRefreshed())
- {
- int i=0,size;
- //--Transference Function----
- tfun->RemoveAllPoints();
- i=0;
- size=gtf->size();
- for(i=0;i<size;i++)
- {
- double grey1=(*gtf)[i];
- double in2=(*itf)[i];
- tfun->AddPoint( grey1 , in2 );
- }
-
- // -- vtkColorTransferFunction --
- ctfun->RemoveAllPoints ();
-
- i=0;
- size=greyctf->size();
- for(i=0;i<size;i++)
- {
- double grey2=(*greyctf)[i];
- double red =(*rctf)[i];
- double green =(*gctf)[i];
- double blue = (*bctf)[i];
- ctfun->AddRGBPoint(grey2,red,green,blue);
- }
-
- //---------------------------------
- // Refreshing and sending the event
- //---------------------------------
- //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
- _wxvtkclipping3Dview->Refresh();
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-
- /*
- volumeMapper->Update();
- newvol->Update();
- */
- }
-
- }
- //destroy the dialog
- hDlg->Destroy();
-}
-
-//EED 23 Mai 2007
-//-------------------------------------------------------------------
-void wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad(wxCommandEvent& event)
-{
- wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.vtk"), wxOPEN);
- if (dialog.ShowModal() == wxID_OK)
- {
- _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadMeshVTK( (char *)dialog.GetPath().c_str() );
- _wxvtkclipping3Dview->Refresh();
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
- }
-}
-
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-
-wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview )
-{
- _wxvtk3Dbaseview = wxvtk3Dbaseview;
- _vtkmpr3Ddataviewer = NULL;
- _wxvtkmpr3DviewCntrlPanel = NULL;
- _myCallback=NULL;
- _pointWidget=NULL;
- _planeWidget=NULL;
- _vtkplane=NULL;
- _probe=NULL;
- _contourMapper=NULL;
-}
-void wxVtkMPR3DView::RemoveActor(vtkActor* actor){
-
- _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor);
-
-
-}
-void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc){
- if(ext == NULL){
-
- _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
- _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
- }else{
- /*double x = (spc[0])*(origin[0]+(((double)ext[1]-(double)ext[0])/2.0));
- double y = (spc[1])*(origin[1]+(double)ext[3]);
- double z = (spc[2])*(origin[2]+(((double)ext[5]-(double)ext[4])/2.0));*/
- /*double x0=(spc[0])*((double)ext[0]+origin[0]);
- double x1=(spc[0])*((double)ext[1]+origin[0]);
- double y0=(spc[1])*((double)ext[2]+origin[1]);
- double y1=(spc[1])*((double)ext[3]+origin[1]);
- double z0=(spc[2])*((double)ext[4]+origin[2]);
- double z1=(spc[2])*((double)ext[5]+origin[2]);*/
- double x0=(spc[0])*((double)ext[0]);
- double x1=(spc[0])*((double)ext[1]);
- double y0=(spc[1])*((double)ext[2]);
- double y1=(spc[1])*((double)ext[3]);
- double z0=(spc[2])*((double)ext[4]);
- double z1=(spc[2])*((double)ext[5]);
-
- _wxvtk3Dbaseview->GetRenderer()->ResetCamera(x0,x1,y0,y1,z0,z1);
- //_wxvtk3Dbaseview->GetCamera()->SetPosition(x,y,z);
- _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
- }
-}
-void wxVtkMPR3DView::Configure(){
-
- _wxvtk3Dbaseview->Configure();
- _wxvtkmpr3DviewCntrlPanel->UpdateControlPanel();
-
-//EED ?????? 07Mai2009
-// _wxvtk3Dbaseview->GetRenderer()->Clear();
-
-
- // Actors are added to the renderer.
- vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor();
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
-// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(0) ); // _saggital
-// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(1) ); // _axial
-// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(2) ); // _coronal
-
-
- // An initial camera view is created. The Dolly() method moves
- // the camera towards the FocalPoint, thereby enlarging the image.
- _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
- this->ResetCamera();
-
-
- // Set a background color for the renderer and set the size of the
- // render window (expressed in pixels).
- _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
- _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
-
- // Note that when camera movement occurs (as it does in the Dolly()
- // method), the clipping planes often need adjusting. Clipping planes
- // consist of two planes: near and far along the view direction. The
- // near plane clips out objects in front of the plane; the far plane
- // clips out objects behind the plane. This way only what is drawn
- // between the planes is actually rendered.
- _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
-
-
- // vtkPointWidget
- if(_myCallback!=NULL){
- _myCallback->Delete();
-
- }
- _myCallback = vtkmyPWCallback_3DPointWidget::New();
- _myCallback->SetWxVtkMPR3DView(this);
-
- if(_pointWidget!=NULL){
- _pointWidget->Delete();
- }
- _pointWidget = vtkPointWidget::New();
- _myCallback->SetVtkPointWidget(_pointWidget);
- _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
- _pointWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
-
- _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);
- _planeWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
- _planeWidget->NormalToXAxisOn();
- _planeWidget->SetResolution(50);
- _planeWidget->SetRepresentationToOutline();
- int dim[3];
- GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->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 );
-
-
- if(_vtkplane==NULL){
- _vtkplane = vtkPolyData::New();
-
- _probe = vtkProbeFilter::New();
- _probe->SetInput(_vtkplane);
-
- _contourMapper = vtkPolyDataMapper::New();
-
- _contourMapper->SetInput( _probe->GetPolyDataOutput() );
-
- _contourPlaneActor = vtkActor::New();
- _contourPlaneActor->SetMapper(_contourMapper);
-
- _contourPlaneActor->VisibilityOff();
-
- _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
- _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
-
- _planeWidget->Off();
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
-
- }else{
-
- }
- _planeWidget->GetPolyData(_vtkplane);
-
-
- vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
- _probe->SetSource( imageData );
-
-
- _contourMapper->SetScalarRange( imageData->GetScalarRange() );
-
-
-
-
-}
-//-------------------------------------------------------------------
-wxVtkMPR3DView::~wxVtkMPR3DView()
-{
-}
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DView::Refresh() // virtual
-{
- _vtkmpr3Ddataviewer -> Refresh();
- if (_wxvtkmpr3DviewCntrlPanel!=NULL)
- {
- _wxvtkmpr3DviewCntrlPanel->Refresh();
- }
-
-}
-//-------------------------------------------------------------------
-void wxVtkMPR3DView::RefreshView() // virtual
-{
- double spc[3];
- this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
-
- //double nx=1,ny=0,nz=0; // JPRx
- Refresh();
- double x=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetX();
- double y=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetY();
- double z=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetZ();
-
- x=x*spc[0];
- y=y*spc[1];
- z=z*spc[2];
-
- _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] );
-
-
- _planeWidget->SetCenter( x,y,z );
- _planeWidget->UpdatePlacement();
- _planeWidget->GetPolyData(_vtkplane);
-}
-//-------------------------------------------------------------------
-wxPanel* wxVtkMPR3DView::CreateControlPanel(wxWindow *parent)
-{
- _wxvtkmpr3DviewCntrlPanel = new wxVtkMPR3DViewCntrlPanel(parent,this);
- return _wxvtkmpr3DviewCntrlPanel;
-}
-//-------------------------------------------------------------------
-vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
-{
- return _vtkmpr3Ddataviewer;
-}
-//-------------------------------------------------------------------
-wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() throw (char*)
-{
- if(_wxvtk3Dbaseview==NULL){
- throw "wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
- }
- return _wxvtk3Dbaseview;
-}
-//-------------------------------------------------------------------
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){
- if (visible!=_vtkmpr3Ddataviewer->GetVisiblePosition(idPosition)){
- if (visible==false){
- _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
- } else {
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
- }
- _vtkmpr3Ddataviewer->SetVisiblePosition(idPosition,visible);
- }
-}
-
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DView::VisiblePointWidget( bool visible )
-{
- if (visible==true)
- {
- _pointWidget->On();
- } else {
- _pointWidget->Off();
- }
-}
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DView::VisiblePlaneWidget( bool visible )
-{
- if (visible==true)
- {
- _planeWidget->On();
- _contourPlaneActor->VisibilityOn();
-
- } else {
- _planeWidget->Off();
- _contourPlaneActor->VisibilityOff();
- }
-}
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DView::SetVtkMPR3DDataViewer(vtkMPR3DDataViewer *vtkmpr3Ddataviewer)
-{
- _vtkmpr3Ddataviewer = vtkmpr3Ddataviewer;
-}
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DView::InitOrientationPointWidget()
-{
- this->_planeWidget->SetNormal(1,0,0);
-}
-
-
-
-
-//-------------------------------------------------------------------
-// EED 25 Janvier 2007 testLoic
-void wxVtkMPR3DView::TestLoic1()
-{
-
- int sizeIma = 128;
- double dimIma = sizeIma*2;
-
- vtkImageData *vtkimagedata = this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
-
- double spc[3];
- vtkimagedata->GetSpacing(spc);
-
- vtkimagedata->Update();
-
-
- double p[3], n[3];
- this->_planeWidget->GetOrigin(p);
- this->_planeWidget->GetNormal(n);
-
-
-
- vtkPlaneSource* pSource = vtkPlaneSource::New( );
- pSource->SetResolution( sizeIma - 1, sizeIma - 1 );
- pSource->SetOrigin( p[ 0 ], p[ 1 ], p[ 2 ] );
- pSource->SetPoint1( p[ 0 ] + dimIma - 1.0, p[ 1 ], p[ 2 ] );
- pSource->SetPoint2( p[ 0 ], p[ 1 ]+ dimIma - 1.0 , p[ 2 ] );
- pSource->Update( );
- pSource->SetCenter( p[ 0 ], p[ 1 ], p[ 2 ] );
- pSource->SetNormal( n[ 0 ], n[ 1 ], n[ 2 ] );
- pSource->Update( );
-
- vtkProbeFilter* slices = vtkProbeFilter::New();
- slices->SetInput( ( vtkDataSet* )pSource->GetOutput( ) );
- slices->SetSource( vtkimagedata );
- slices->Update( );
- pSource->Delete( );
-
- vtkStructuredPoints *stPoints = vtkStructuredPoints::New();
- stPoints -> GetPointData( )->SetScalars( slices->GetOutput()->GetPointData()->GetScalars() );
- stPoints -> SetDimensions( sizeIma, sizeIma, 1 );
- stPoints -> SetScalarType( vtkimagedata->GetScalarType() );
- stPoints -> SetScalarTypeToShort();
- stPoints -> Update();
-
- vtkImageChangeInformation *change = vtkImageChangeInformation ::New();
- change -> SetInput( stPoints );
- change -> Update(); //important
-
- double _range[2];
- vtkimagedata->GetScalarRange(_range);
- vtkWindowLevelLookupTable *_bwlookup = vtkWindowLevelLookupTable::New( );
- _bwlookup->SetHueRange( 0 , 1 );
- _bwlookup->SetNumberOfColors( (int)(_range[1] - _range[0] + 1) );
- _bwlookup->SetTableRange( _range[0] , _range[1] );
- _bwlookup->SetSaturationRange( 0 , 0 );
- _bwlookup->SetValueRange( 0 , 1 );
- _bwlookup->SetAlphaRange( 1 , 1 );
- _bwlookup->Build( );
-
- vtkLookupTable * _collookup = vtkLookupTable::New( );
- _collookup->SetNumberOfColors( 256 );
- _collookup->SetTableRange( 0 , 255 );
- _collookup->Build( );
- _collookup->SetTableValue( 0 , 1 , 0 , 0 , 1 );
- _collookup->SetTableValue(128 , 0 , 0 , 1 , 1 );
- _collookup->SetTableValue(255 , 0 , 1 , 0 , 1 );
-
-
- vtkMetaImageWriter *writer = vtkMetaImageWriter::New( );
- writer->SetInput( stPoints );
- writer->SetFileName( "C:/Users/Images/temp_EED/image.mhd" );
- writer->SetFileDimensionality( 2 );
- writer->Write( );
-
-
-
- vtkDataSetMapper *_3DSliceMapper = vtkDataSetMapper::New( );
- _3DSliceMapper->SetInput(change->GetOutput( ) );
- _3DSliceMapper->SetLookupTable( _bwlookup );
- _3DSliceMapper->SetScalarRange( _range );
- _3DSliceMapper->ImmediateModeRenderingOn( );
-
- vtkActor *_3DSliceActor = vtkActor::New( );
- _3DSliceActor->SetMapper( _3DSliceMapper );
-
- // The usual rendering stuff.
- vtkCamera *camera = vtkCamera::New();
- camera->SetPosition(1,1,1);
- camera->SetFocalPoint(0,0,0);
-
- vtkRenderer *renderer = vtkRenderer::New();
- vtkRenderWindow *renWin = vtkRenderWindow::New();
- renWin->AddRenderer(renderer);
-
- vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
- iren->SetRenderWindow(renWin);
-
- renderer->AddActor( _3DSliceActor );
- renderer->SetActiveCamera(camera);
- renderer->ResetCamera();
- renderer->SetBackground(1,1,1);
-
- renWin->SetSize(300,300);
-
- // interact with data
- renWin->Render();
- iren->Start();
-
-
-
-
-
-}
-
-//-------------------------------------------------------------------
-// EED 25 Janvier 2007 testLoic
-void wxVtkMPR3DView::TestLoic2()
-{
-/*
- vtkVectorNorm *vecMagnitude = vtkVectorNorm::New();
- vecMagnitude->SetInput(VtkMainGrid);
- vecMagnitude->NormalizeOff();
- vecMagnitude->Update();
-*/
-
- vtkPlane *slicePlane = vtkPlane::New();
- this->_planeWidget->GetPlane( slicePlane );
-
-
- vtkCutter* sliceCutter = vtkCutter::New();
- vtkImageData *vtkimagedata = this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
- sliceCutter->SetInput( vtkimagedata );
- sliceCutter->SetCutFunction( slicePlane );
-
-//EED
-// vtkLookupTable *lut = BuildHueWeightBaseMap();
-
-
- vtkPolyDataMapper *slice = vtkPolyDataMapper::New();
- slice->SetInput( sliceCutter->GetOutput() );
- double range[2];
-// EED
-// slice->Update();
- vtkimagedata->GetScalarRange(range);
-// vecMagnitude->GetOutput()->GetScalarRange( range );
-// range[1] *= 0.7; // reduce the upper range by 30%
-// slice->SetScalarRange( range );
-// slice->SetLookupTable( lut );
-
-// vtkActor *sliceActor = vtkActor::New();
-// sliceActor->SetMapper( slice );
-
- vtkPolyDataMapper *contourMapper = vtkPolyDataMapper::New();
- contourMapper->SetInput( sliceCutter->GetOutput() );
- contourMapper->SetScalarRange( range );
- // contourMapper->SetLookupTable( lut );
-
-
- vtkActor *contourActor = vtkActor::New();
- contourActor->SetMapper( contourMapper );
-
-
-
- // The usual rendering stuff.
- vtkCamera *camera = vtkCamera::New();
- camera->SetPosition(1,1,1);
- camera->SetFocalPoint(0,0,0);
-
- vtkRenderer *renderer = vtkRenderer::New();
- vtkRenderWindow *renWin = vtkRenderWindow::New();
- renWin->AddRenderer(renderer);
-
- vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
- iren->SetRenderWindow(renWin);
-
- renderer->AddActor( contourActor );
-// renderer->AddActor(cubeActor);
- renderer->SetActiveCamera(camera);
- renderer->ResetCamera();
- renderer->SetBackground(1,1,1);
-
- renWin->SetSize(300,300);
-
- // interact with data
- renWin->Render();
- iren->Start();
-
-
-}
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-wxVtkClipping3DView::wxVtkClipping3DView(wxVtk3DBaseView* wxvtk3Dbaseview)
-{
- _wxvtk3Dbaseview = wxvtk3Dbaseview;
- _vtkclipping3Ddataviewer = NULL;
- _wxvtkclipping3DviewCntrlPanel = NULL;
-
- _boxWidgetVolume = NULL;
- _boxWidgetS1 = NULL;
-}
-
-//-------------------------------------------------------------------
-wxVtkClipping3DView::~wxVtkClipping3DView(){
- if (_boxWidgetVolume!=NULL) { _boxWidgetVolume -> Delete(); }
- if (_boxWidgetS1!=NULL) { _boxWidgetS1 -> Delete(); }
- if (_vtkclipping3Ddataviewer!=NULL) { delete _vtkclipping3Ddataviewer; }
- if (_wxvtkclipping3DviewCntrlPanel!=NULL){ delete _wxvtkclipping3DviewCntrlPanel; }
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DView::SetVisibleBoxSurface(bool visible)
-{
- if (visible==true){
- _boxWidgetS1->On();
- } else {
- _boxWidgetS1->Off();
- }
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DView::SetVisibleBoxVolume(bool visible)
-{
- if (_boxWidgetVolume!=NULL){
- if (visible==true){
- _boxWidgetVolume->On();
- } else {
- _boxWidgetVolume->Off();
- }
- }
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DView::Refresh()
-{
- _vtkclipping3Ddataviewer->Refresh();
- if (_wxvtkclipping3DviewCntrlPanel!=NULL)
- {
- _wxvtkclipping3DviewCntrlPanel->Refresh();
- }
-}
-//-------------------------------------------------------------------
-wxPanel* wxVtkClipping3DView::CreateControlPanel(wxWindow *parent)
-{
- _wxvtkclipping3DviewCntrlPanel = new wxVtkClipping3DViewCntrlPanel(parent,this);
- return _wxvtkclipping3DviewCntrlPanel;
-}
-//-------------------------------------------------------------------
-vtkClipping3DDataViewer* wxVtkClipping3DView::GetVtkClipping3DDataViewer()
-{
- return _vtkclipping3Ddataviewer;
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DView::VisibleActor(int idTissue, bool visTissue){
- if (visTissue!=_vtkclipping3Ddataviewer->GetVisibleTissue(idTissue)){
- if (visTissue==false){
- _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
- } else {
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
-// _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(idTissue) );
-// _actor->VisibilityOn();
- }
- _vtkclipping3Ddataviewer->SetVisibleTissue(idTissue,visTissue);
- }
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DView::SetRepSurfaceWireFrame(int idTissue , bool representationType )
-{
- vtkActor *tmpActor;
- tmpActor = GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
-
- if (representationType==false){
- tmpActor->GetProperty()->SetRepresentationToWireframe();
- } else {
- tmpActor->GetProperty()->SetRepresentationToSurface();
- }
-
- _vtkclipping3Ddataviewer->SetRepresentationType(idTissue,representationType);
-}
-
-//-------------------------------------------------------------------
-void wxVtkClipping3DView::VisibleVolumeActor( bool visVolume){
- if (visVolume!=_vtkclipping3Ddataviewer->GetVisibleVolume() ){
- if (visVolume==false){
-//EED 31/03/2008
-// _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
- _wxvtk3Dbaseview->GetRenderer()->RemoveVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
- } else {
-//EED 31/03/2008
-// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
- _wxvtk3Dbaseview->GetRenderer()->AddVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
- }
- _vtkclipping3Ddataviewer->SetVisibleVolume(visVolume);
- }
-}
-//-------------------------------------------------------------------
-wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()throw(char*)
-{
- if(_wxvtk3Dbaseview==NULL){
- throw "wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
- }
- return _wxvtk3Dbaseview;
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DView::Configure(){
- _wxvtk3Dbaseview->Configure();
-
- // Actors are added to the renderer.
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetOutlineActor() );
-
- _boxWidgetS1 = vtkBoxWidget::New();
- _boxWidgetS1->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
- _boxWidgetS1->SetPlaceFactor(1.25);
-
-
-
- vtkStripper *stripper=_vtkclipping3Ddataviewer->GetTissueStripper(0);
- vtkPolyData *polydata= stripper->GetOutput();
-
-
- _boxWidgetS1->SetInput( polydata );
- _boxWidgetS1->PlaceWidget();
-
- int i;
- for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
- {
- _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverS(i) );
- }
-
-
-
-
-// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(0) );
-// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(3));
-
- VisibleActor(0, false );
- VisibleActor(1, false );
- VisibleActor(2, false );
- VisibleActor(3, false );
-
- _boxWidgetS1->HandlesOn ();
-
-//EED 29Mars2009
-// _boxWidgetS1->On();
-
- _boxWidgetS1->Off();
-
- _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) );
- _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(1) );
- _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(2) );
- _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );
-
-// EED 9 fev 2007
-// box Volume
- _boxWidgetVolume = vtkBoxWidget::New();
- _boxWidgetVolume->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
- _boxWidgetVolume->SetPlaceFactor(1.25);
-
- _boxWidgetVolume->SetInput( this->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
- _boxWidgetVolume->PlaceWidget();
-
- _boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverV() );
-
- _boxWidgetVolume->HandlesOn ();
-
-//EED 29Mars2009
-// _boxWidgetVolume->On();
-
- _boxWidgetVolume->Off();
-
-
-// vtkPlanes *vtkplanes=this->GetVtkClipping3DDataViewer()->GetVolumePlanes();
-// _boxWidgetVolume->GetPlanes( vtkplanes );
-
-
- // An initial camera view is created. The Dolly() method moves
- // the camera towards the FocalPoint, thereby enlarging the image.
- _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
- _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
- _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
-
- // Set a background color for the renderer and set the size of the
- // render window (expressed in pixels).
- _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
- _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
-
- // Note that when camera movement occurs (as it does in the Dolly()
- // method), the clipping planes often need adjusting. Clipping planes
- // consist of two planes: near and far along the view direction. The
- // near plane clips out objects in front of the plane; the far plane
- // clips out objects behind the plane. This way only what is drawn
- // between the planes is actually rendered.
- _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
-}
-//-------------------------------------------------------------------
-void wxVtkClipping3DView::SetVtkClipping3DDataViewer(vtkClipping3DDataViewer *vtkclipping3Ddataviewer)
-{
- _vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
-}
-
-
-//---------------------------------------------------------------------------
-//---------------------------------------------------------------------------
-//---------------------------------------------------------------------------
-vtkInteractorStyle3DView::vtkInteractorStyle3DView()
-{
-}
-//---------------------------------------------------------------------------
-vtkInteractorStyle3DView::~vtkInteractorStyle3DView()
-{
-}
-//---------------------------------------------------------------------------
-bool vtkInteractorStyle3DView::OnLeftDClick()
-{
- SelectMarchibCubePoint();
- return true;
-}
-//---------------------------------------------------------------------------
-bool vtkInteractorStyle3DView::SelectMarchibCubePoint()
-{
- bool ok=false;
- gtm::TVector< double > pO( 3 ), pF( 3 ), pp( 3 ), cp( 3 );
- gtm::TVector< double > xc( 3 );
- gtm::TVector< double > x1( 3 ), n1( 3 );
- gtm::TVector< double > x2( 3 ), n2( 3 );
-
- double pickPoint[ 3 ], cameraPos[ 3 ];
- int eventrwi[2];
- vtkPointPicker* picker = vtkPointPicker::New( );
- eventrwi[0]= _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
- eventrwi[1]= _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
- vtkRenderer *pRenderer = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetRenderer();
- picker->Pick( eventrwi[0], eventrwi[1], 0.0, pRenderer );
- pRenderer->GetActiveCamera( )->GetPosition( cameraPos );
- picker->GetPickPosition( pickPoint );
- picker->Delete( );
-
- pp( 0 ) = pickPoint[ 0 ]; pp( 1 ) = pickPoint[ 1 ]; pp( 2 ) = pickPoint[ 2 ];
- cp( 0 ) = cameraPos[ 0 ]; cp( 1 ) = cameraPos[ 1 ]; cp( 2 ) = cameraPos[ 2 ];
-
-
-//EED 27 sep 2006 (1/2)
-// wxVtkMPR3DView *wxvtkmpr3Dview = (wxVtkMPR3DView *)_vtkInteractorStyleBaseView->GetWxVtk3DBaseView();
-// double spc[3];
-// wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetSpacing(spc);
-
-
- vtkImageData *imageData = GetWxVtkMPR3DView()->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
- int dim[3];
- double spc[3];
- imageData->GetDimensions(dim);
- imageData->GetSpacing(spc);
-
-
- vtkMarchingCubes *mcubes = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetMCubes(0);
-
-
- UtilVtk3DGeometriSelection utilVtk3DGeometriSelection;
- utilVtk3DGeometriSelection.SetDimentions(dim[0],dim[1],dim[2]);
-
- utilVtk3DGeometriSelection.SetMarchingCube(mcubes);
-
- double fac;
- fac = GTM_MAX( dim[0], dim[2] );
-
-
- if( utilVtk3DGeometriSelection.FindCubePointsFromPoints(
- pO.GetAnsiRef( ), pF.GetAnsiRef( ),
- pp.GetAnsiRef( ), cp.GetAnsiRef( ) ) )
- {
-
- if( utilVtk3DGeometriSelection.GetPointAndNormalIntersection(
- x1.GetAnsiRef( ), n1.GetAnsiRef( ),
- pO.GetAnsiRef( ), pF.GetAnsiRef( ) ) )
- {
- if( utilVtk3DGeometriSelection.GetPointAndNormalIntersection(
- x2.GetAnsiRef( ), n2.GetAnsiRef( ),
- ( x1 - n1 ).GetAnsiRef( ), ( x1 - ( n1 * fac ) ).GetAnsiRef( ) ) )
- {
- xc = ( x2 + x1 ) * 0.5;
-//EED 27 sep 2006 (2/2)
- this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX(xc(0)/spc[0]);
- this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY(xc(1)/spc[1]);
- this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ(xc(2)/spc[2]);
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- this->_wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
- ok=true;
- }
- }
- }
-
-
- return ok;
-}
-//-------------------------------------------------------------------
-void vtkInteractorStyle3DView::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
-{
- _wxvtkmpr3Dview = wxvtkmpr3Dview;
-}
-//-------------------------------------------------------------------
-wxVtkMPR3DView *vtkInteractorStyle3DView::GetWxVtkMPR3DView()
-{
- return _wxvtkmpr3Dview;
-}
-//-------------------------------------------------------------------
-wxVtkClipping3DView *vtkInteractorStyle3DView::GetWxVtkClipping3DView()
-{
- return _wxvtkclipping3Dview;
-}
-//-------------------------------------------------------------------
-void vtkInteractorStyle3DView::SetWxVtkClipping3DView( wxVtkClipping3DView *wxvtkclipping3Dview)
-{
- _wxvtkclipping3Dview = wxvtkclipping3Dview;
-}
-
-
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-void vtkmyPWCallback_3DPointWidget::Execute(vtkObject *caller, unsigned long, void*)
-{
- double n[3];
- double p[3];
- double delta = 0.000000001;
-
- vtkInteractorStyleBaseView *isbv = _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
-
- if (caller==_pointWidget)
- {
- _pointWidget->GetPosition(p);
- }
- if (caller==_planeWidget)
- {
- _planeWidget->GetCenter(p);
- _planeWidget->GetNormal(n);
- _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetNormal(n[0],n[1],n[2]);
- }
-
- double spc[3];
- _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
- p[0]=p[0]/spc[0];
- p[1]=p[1]/spc[1];
- p[2]=p[2]/spc[2];
-
- // Orientation change
- if ( (fabs(n[0]-_backNormal[0])>delta) || (fabs(n[1]-_backNormal[1])>delta) || (fabs(n[2]-_backNormal[2])>delta) )
- {
- _backNormal[0] = n[0];
- _backNormal[1] = n[1];
- _backNormal[2] = n[2];
- isbv->SetParent_refresh_waiting();
- }
-
- // ----------
-
- double tx = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX();
- double ty = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY();
- double tz = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ();
-
- // Position Change
- if ( (fabs(tx-p[0])>delta) || (fabs(ty-p[1])>delta) || (fabs(tz-p[2])>delta) )
- {
- _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( p[0] );
- _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( p[1] );
- _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( p[2] );
- vtkInteractorStyleBaseView *isbv = _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
- isbv->BlockRefresh();
- isbv->vtkInteractorStyleBaseView::OnLeftButtonDown();
- isbv->SetParent_refresh_waiting();
- isbv->vtkInteractorStyleBaseView::OnMouseMove();
- isbv->UnBlockRefresh();
- }
- isbv->EvaluateToRefresh();
-}
-//-------------------------------------------------------------------
-void vtkmyPWCallback_3DPointWidget::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
-{
- _wxvtkmpr3Dview=wxvtkmpr3Dview;
-}
-//-------------------------------------------------------------------
-void vtkmyPWCallback_3DPointWidget::SetVtkPointWidget( vtkPointWidget *pointWidget )
-{
- _pointWidget=pointWidget;
-}
-//-------------------------------------------------------------------
-void vtkmyPWCallback_3DPointWidget::SetVtkPlaneWidget( vtkPlaneWidget *planeWidget )
-{
- _planeWidget=planeWidget;
-}
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-wxPanelCuttingImageData::wxPanelCuttingImageData (wxWindow *parent)
-: wxPanel( parent, -1)
-{
- _imageData=NULL;
- _histogrammeVector=NULL;
- _wxvtk3Dbaseview=NULL;
- _wxvtkbaseView=NULL;
- CreateInterface();
- CreateModel();
- Create3DViewObjects();
-}
-
-//-------------------------------------------------------------------
-wxPanelCuttingImageData::~wxPanelCuttingImageData()
-{
-
-
- delete _modelCube;
- delete _modelSphere;
- delete _modelCylinder;
- _vtkcube -> Delete();
- _vtksphere -> Delete();
- _vtkcylinder -> Delete();
- _cubeMapper -> Delete();
- _sphereMapper -> Delete();
- _cylinderMapper -> Delete();
- _cubeActor -> Delete();
- _sphereActor -> Delete();
- _cylinderActor -> Delete();
-// _xyplot->RemoveAllInputs();
- _xyplot -> Delete();
- _histogrammeVector->Delete();
- _renplotter->Delete();
-
- if(_wxvtkbaseView!=NULL){
- delete _wxvtkbaseView;
- }
- //delete _vtkclipping3Ddataviewer;
-
-
- //fclose(file);
-
-}
-
-//-------------------------------------------------------------------
-void wxPanelCuttingImageData::RemoveActors()
-{
- _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
-}
-
-
-//-------------------------------------------------------------------
-void wxPanelCuttingImageData::SetWxVtk3DBaseView( wxVtk3DBaseView * wxvtk3Dbaseview )
-{
- _wxvtk3Dbaseview=wxvtk3Dbaseview;
-}
-
-//-------------------------------------------------------------------
-
-void wxPanelCuttingImageData::SetVtkClipping3DDataViewer( vtkClipping3DDataViewer *vtkclipping3Ddataviewer )
-{
- this->_vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
-}
-
-//-------------------------------------------------------------------
-void wxPanelCuttingImageData::Create3DViewObjects()
-{
- // Sphere
- _vtksphere = vtkSphereSource::New();
- _vtksphere->SetThetaResolution (20);
- _vtksphere->SetPhiResolution (20);
- _sphereMapper = vtkPolyDataMapper::New();
- _sphereMapper->SetInput( _vtksphere->GetOutput() );
- _sphereActor = vtkActor::New();
- _sphereActor->SetMapper(_sphereMapper);
- _sphereActor->SetOrigin(0, 0, 0);
- _sphereActor->SetPosition(0, 0, 0);
- _sphereActor->GetProperty()->SetColor(1, 0, 0);
- _sphereActor->SetUserTransform( _modelSphere->GetVtkTransform() );
-
- // cube
- _vtkcube = vtkCubeSource::New();
- _vtkcube->SetXLength (1);
- _vtkcube->SetYLength (1);
- _vtkcube->SetZLength (1);
- _cubeMapper = vtkPolyDataMapper::New();
- _cubeMapper->SetInput( _vtkcube->GetOutput() );
- _cubeActor = vtkActor::New();
- _cubeActor->SetMapper(_cubeMapper);
- _cubeActor->SetOrigin(0, 0, 0);
- _cubeActor->SetPosition(0, 0, 0);
- _cubeActor->GetProperty()->SetColor(1, 0, 0);
- _cubeActor->SetUserTransform( _modelCube->GetVtkTransform() );
-
- // cylinder
- _vtkcylinder = vtkCylinderSource::New();
- _vtkcylinder->SetResolution(20);
- _cylinderMapper = vtkPolyDataMapper::New();
- _cylinderMapper->SetInput( _vtkcylinder->GetOutput() );
- _cylinderActor = vtkActor::New();
- _cylinderActor->SetMapper(_cylinderMapper);
- _cylinderActor->SetOrigin(0, 0, 0);
- _cylinderActor->SetPosition(0, 0, 0);
- _cylinderActor->GetProperty()->SetColor(1, 0, 0);
- _cylinderActor->SetUserTransform( _modelCylinder->GetVtkTransform() );
-
-
-}
-
-//-------------------------------------------------------------------
-void wxPanelCuttingImageData::CreateModel()
-{
- _modelCube = new figureCuttingCubeModel();
- _modelSphere = new figureCuttingSphereModel();
- _modelCylinder = new figureCuttingCylinderModel();
-
-// _modelCube->SetVtkTransform( _modelCube->GetVtkTransform() );
-// _modelSphere->SetVtkTransform( _modelSphere->GetVtkTransform() );
-// _modelCylinder->SetVtkTransform( _modelCylinder->GetVtkTransform() );
-}
-
-//-------------------------------------------------------------------
-
-void wxPanelCuttingImageData::InitHistogramme()
-{
- double rangeA[2];
- if (_imageData==NULL)
- {
- rangeA[1]=1;
- } else {
- _imageData->GetScalarRange(rangeA);
- }
- _xyplot->RemoveAllInputs();
-/*
- if ( _histogrammeVector!=NULL )
- {
- _histogrammeVector -> Delete();
- }
-*/
- _histogrammeVector = vtkImageData::New();
- _histogrammeVector -> SetDimensions ( (int)(rangeA[1]),1,1 );
- _histogrammeVector -> SetScalarTypeToUnsignedShort();
- _histogrammeVector -> AllocateScalars();
- _histogrammeVector -> Update();
-
- unsigned short *p_vol = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
- int i,size = (int) (rangeA[1]);
- for (i=0; i < size; i++)
- {
- *p_vol=0;
- p_vol++;
- }
- _xyplot->SetXRange(0, rangeA[1]);
- _xyplot->SetYRange(0, 10);
- _xyplot->AddInput( _histogrammeVector );
-}
-
-//-------------------------------------------------------------------
-wxWindow *wxPanelCuttingImageData::CreatePlotHistogrammeInterface()
-{
- _xyplot = vtkXYPlotActor::New();
- InitHistogramme();
- _xyplot->GetPositionCoordinate()->SetValue(0.00, 0.00, 0);
- _xyplot->GetPosition2Coordinate()->SetValue(1.0, 1.00, 0); //relative to Position
- _xyplot->SetXValuesToArcLength();
- _xyplot->SetNumberOfXLabels(6);
-
- _xyplot->SetTitle("Histogramme");
- _xyplot->SetXTitle("Gray level");
- _xyplot->SetYTitle("Occurrences ");
- _xyplot->GetProperty()->SetColor(1, 0, 0);
- _xyplot->GetProperty()->SetPointSize(2);
- vtkTextProperty *tprop = _xyplot->GetTitleTextProperty();
- tprop->SetColor( 1,0,1 );
- tprop->BoldOff ();
- _xyplot->SetAxisTitleTextProperty(tprop);
- _xyplot->SetAxisLabelTextProperty(tprop);
- _xyplot->PlotPointsOn();
- _xyplot->GetProperty()->SetPointSize(3);
-
- _wxvtkbaseView = new wxVtkBaseView(this);
- _wxvtkbaseView->Configure();
-
- _renplotter = vtkRenderer::New();
- vtkRenderWindow *renWin = _wxvtkbaseView->GetRenWin();
- renWin->AddRenderer( _renplotter );
- _renplotter->AddActor2D( _xyplot );
-
- return _wxvtkbaseView->GetWxVTKRenderWindowInteractor();
-}
-
-//-------------------------------------------------------------------
-
-void wxPanelCuttingImageData::CreateInterface()
-{
- SetSize(300,500);
- wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); // Principal sizer
-
- wxBoxSizer *sizerH0 = new wxBoxSizer(wxHORIZONTAL ); // type of segmentation figure
- wxBoxSizer *sizerH2 = new wxBoxSizer(wxHORIZONTAL ); // scale
- wxBoxSizer *sizerH3 = new wxBoxSizer(wxHORIZONTAL ); // rotation
- wxBoxSizer *sizerH4 = new wxBoxSizer(wxHORIZONTAL ); // intern extern
- wxBoxSizer *sizerH5 = new wxBoxSizer(wxHORIZONTAL ); // Isovalue
- wxBoxSizer *sizerH6 = new wxBoxSizer(wxHORIZONTAL ); // Buttons
- wxFlexGridSizer *sizerH7 = new wxFlexGridSizer(2 ); // Volumic information
-
-
- _typeFig = new wxChoice(this,-1);
- _opacityFig = new wxSlider(this,-1,100,0,100, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
-
- _scaleX = new wxSlider(this,-1,6,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
- _scaleY = new wxSlider(this,-1,20,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
- _scaleZ = new wxSlider(this,-1,7,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
-
- _rotationX = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
- _rotationY = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
- _rotationZ = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
-
- _volIntern = new wxRadioButton(this,-1, _T("Volume intern " ));
- _volExtern = new wxRadioButton(this,-1, _T("Volume extern " ));
-
- _histogrammeAccumulated = new wxCheckBox(this,-1,_T("Histogramme accumulated"));
-
- _isoValue = new wxSlider(this,-1, 200, 0,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
- _valueBeforeIsoValue = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
- _valueAfterIsoValue = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
-
- wxButton *btnExtract = new wxButton(this, -1,_T("Extract"));
-
- _infoToVo = new wxStaticText(this,-1,_T("########################"));
- _infoSuVoA = new wxStaticText(this,-1,_T("############"));
- _infoSuVo = new wxStaticText(this,-1,_T("############"));
- _infoPixLe = new wxStaticText(this,-1,_T("############"));
- _infoPixHi = new wxStaticText(this,-1,_T("############"));
-
-
-
-
- _typeFig->Append(_T("Cylindre"));
- _typeFig->Append(_T("Cube"));
- _typeFig->Append(_T("Sphere"));
- _typeFig->SetSelection(0);
- _volIntern->SetValue(true);
-
- Connect(_typeFig->GetId() , wxEVT_COMMAND_CHOICE_SELECTED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTypeFig );
-
- Connect(_opacityFig->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnOpacityFig );
- Connect(_rotationX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
- Connect(_rotationY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
- Connect(_rotationZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
- Connect(_scaleX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
- Connect(_scaleY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
- Connect(_scaleZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
- Connect(btnExtract->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnExtract );
-
-
-// wxStaticText *text=new wxStaticText(this,-1, " ");
-
- sizerH0 -> Add( new wxStaticText(this,-1, _T("Fig. Type: "),wxDefaultPosition, wxSize(50,20)) ,1,wxALL ,0);
- sizerH0 -> Add( _typeFig ,1,wxALL ,0);
- sizerH0 -> Add( _opacityFig ,1,wxALL|wxEXPAND ,0);
-
- sizerH2 -> Add( new wxStaticText(this,-1,_T("Scale : ")) ,1,wxALL ,0);
- sizerH2 -> Add( _scaleX ,1,wxALL | wxEXPAND ,0 );
- sizerH2 -> Add( _scaleY ,1,wxALL | wxEXPAND ,0 );
- sizerH2 -> Add( _scaleZ ,1,wxALL | wxEXPAND ,0 );
-
- sizerH3 -> Add( new wxStaticText(this,-1,_T("Rotation : ")) ,1,wxALL ,0);
- sizerH3 -> Add( _rotationX ,1,wxALL | wxEXPAND ,0 );
- sizerH3 -> Add( _rotationY ,1,wxALL | wxEXPAND ,0 );
- sizerH3 -> Add( _rotationZ ,1,wxALL | wxEXPAND ,0 );
-
-
- sizerH4 -> Add( new wxStaticText(this,-1,_T("Intern / Extern : ")) ,1,wxALL ,0);
- sizerH4 -> Add( _volIntern ,1,wxALL ,0);
- sizerH4 -> Add( new wxStaticText(this,-1, _T(" ")) ,1,wxALL ,0);
- sizerH4 -> Add( _volExtern ,1,wxALL ,0);
-
- sizerH5 -> Add( new wxStaticText(this,-1,_T("Isovalue ")) ,1,wxALL ,0);
- sizerH5 -> Add( _isoValue ,1,wxALL | wxEXPAND ,0 );
- sizerH5 -> Add( _valueBeforeIsoValue ,1,wxALL | wxEXPAND ,0 );
- sizerH5 -> Add( _valueAfterIsoValue ,1,wxALL | wxEXPAND ,0 );
-
- sizerH6 -> Add( new wxStaticText(this,-1, _T(" ")) ,1,wxALL ,0);
- sizerH6 -> Add( btnExtract ,1,wxALL ,0);
-
- sizerH7 -> Add( new wxStaticText(this,-1,_T("Total Volume: "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
- sizerH7 -> Add( _infoToVo , 1 , wxALL ,0);
- sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume: "), wxDefaultPosition, wxSize(200,12) ) , 1 , wxALL ,0);
- sizerH7 -> Add( _infoSuVo , 1 , wxALL ,0);
- sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume (ana.): "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
- sizerH7 -> Add( _infoSuVoA , 1 , wxALL ,0);
- sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix < isovalue: ") , wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
- sizerH7 -> Add( _infoPixLe , 1 , wxALL ,0);
- sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix > isovalue: "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
- sizerH7 -> Add( _infoPixHi , 1 , wxALL ,0);
-// sizerH7 -> SetMinSize(300, 120);
-
- // Figure type
- topsizer -> Add( sizerH0 ,1,wxALL|wxEXPAND ,0);
-
- // Scale
- topsizer -> Add( sizerH2 ,1,wxALL|wxEXPAND ,0);
-
- // Rotation
- topsizer -> Add( sizerH3 ,1,wxALL|wxEXPAND ,0);
-
- // Intern / Extern
- topsizer -> Add( sizerH4 ,1,wxALL ,0);
-
-
- // Isovalue limite
- topsizer -> Add( sizerH5 ,1,wxALL |wxEXPAND ,0);
-
- // btn Extraction
- topsizer -> Add( sizerH6 , 1 , wxALL ,0);
-
- // Histograme
- topsizer -> Add( _histogrammeAccumulated ,1, wxALL ,0);
-
- // Volumic information
- topsizer -> Add( sizerH7 , 1 , wxALL|wxEXPAND ,0);
-
-
-
-// wxBoxSizer *sizerHor = new wxBoxSizer(wxHORIZONTAL);
- wxBoxSizer *sizerHor = new wxBoxSizer(wxVERTICAL);
- sizerHor -> Add( topsizer , 1 , wxALL | wxEXPAND ,0);
-
-
- wxWindow *panelPlotHistogramme = CreatePlotHistogrammeInterface();
- sizerHor -> Add( panelPlotHistogramme , 1 , wxGROW ,0);
-
-
- this->SetAutoLayout(true);
- this->SetSizer( sizerHor );
- this->Layout();
-//EEDxx2.4
-// this->FitInside();
-}
-
-//-------------------------------------------------------------------
-
-void wxPanelCuttingImageData::OnExtract(wxCommandEvent& event)
-{
- wxBusyCursor wait;
-
- bool inside;
- bool volInt, volExt;
- int xx,yy,zz;
- unsigned short *pOrg;
- unsigned short *p_histogramme;
- int dim[3];
- double spc[3];
- long int contAfter = 0;
- long int contBefor = 0;
-
- double min=999999999;
- double max=-999999999;
-
- volExt=_volExtern->GetValue();
- volInt=_volIntern->GetValue();
- int isoValue = _isoValue->GetValue();
- int valueBeforeIsoValue = _valueBeforeIsoValue->GetValue();
- int valueAfterIsoValue = _valueAfterIsoValue ->GetValue();
-
- InitHistogramme();
- p_histogramme = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
-
- _imageData->GetDimensions(dim);
- _imageData->GetSpacing(spc);
- _actualCuttingModel->CalculeInversMatrix();
-
- for (xx=0;xx<dim[0]; xx++)
- {
- for (yy=0;yy<dim[1]; yy++)
- {
- for (zz=0;zz<dim[2];zz++)
- {
- inside=_actualCuttingModel->IfPointInside(xx,yy,zz);
- if ( ((inside==true)&&(volInt==true)) || ((!inside==true)&&(volExt==true)) )
- {
- pOrg=(unsigned short*)_imageData->GetScalarPointer (xx,yy,zz);
-
- if ((*pOrg)<isoValue)
- {
- contBefor++;
- if (valueBeforeIsoValue!=-1)
- {
- *pOrg=valueBeforeIsoValue;
- }
- } else {
- contAfter++;
- if (valueAfterIsoValue!=-1)
- {
- *pOrg=valueAfterIsoValue;
- } // if
- } // if isovalue
-
- p_histogramme[*pOrg]++;
- if (*pOrg<min) min=*pOrg;
- if (*pOrg>max) max=*pOrg;
- } // if inside
- } // for zz
- } // for yy
- } // for xx
-
-
- // Information
- wxString infoToVo;
- wxString infoSuVo;
- wxString infoSuVoA;
- wxString infoPixLe;
- wxString infoPixHi;
-
- double volumeUnit = spc[0]*spc[1]*spc[2];
- long int totalSubVolume = contBefor + contAfter;
- double contBeforPorc = 100*(double)contBefor/(double)totalSubVolume;
- double contAfterPorc = 100*(double)contAfter/(double)totalSubVolume;
- infoToVo.Printf(_T("%dx%dx%d = %d"),dim[0],dim[1],dim[2], dim[0]*dim[1]*dim[2] );
- infoSuVo.Printf(_T("%ld") , totalSubVolume);
- infoSuVoA.Printf(_T("%.2f"), _actualCuttingModel->GetTheoricVolume() );
- infoPixLe.Printf(_T("%ld pix. (%.2f %s) - %.2f mm^3"),contBefor, contBeforPorc ,_T("%"),contBefor*volumeUnit);
- infoPixHi.Printf(_T("%ld pix. (%.2f %s) - %.2f mm^3"),contAfter, contAfterPorc ,_T("%"),contAfter*volumeUnit);
-
- _infoToVo->SetLabel(infoToVo);
- _infoSuVo->SetLabel(infoSuVo);
- _infoSuVoA->SetLabel(infoSuVoA);
- _infoPixLe->SetLabel(infoPixLe);
- _infoPixHi->SetLabel(infoPixHi);
-
- // Histogram
- if ( _histogrammeAccumulated->GetValue()==true )
- {
- int dimHist[3];
- _histogrammeVector -> GetDimensions ( dimHist );
-
- int i,size=dimHist[0];
- for (i=1; i<=size; i++)
- {
- p_histogramme[i] = p_histogramme[i] + p_histogramme[i-1];
- }
- }
- double range[2];
- _histogrammeVector->Update();
- _histogrammeVector->GetScalarRange(range);
- _xyplot->SetYRange( 0 , range[1] );
- _xyplot->SetXRange( min , max );
-
- _vtkclipping3Ddataviewer->RefreshSurface();
- _wxvtkbaseView->Refresh();
-
-// _wxvtkbaseView->RefreshView();
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkbaseView->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
-}
-
-
-//-------------------------------------------------------------------
-void wxPanelCuttingImageData::OnTypeFig(wxCommandEvent& event)
-{
- _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
-
- if (_typeFig->GetSelection()==0){
- _actualCuttingModel=_modelCylinder;
- _actualActor=_cylinderActor;
- }
- if (_typeFig->GetSelection()==1){
- _actualCuttingModel=_modelCube;
- _actualActor=_cubeActor;
- }
- if (_typeFig->GetSelection()==2){
- _actualCuttingModel=_modelSphere;
- _actualActor=_sphereActor;
- }
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
- RefreshOpacity();
- RefreshView();
-}
-
-//-------------------------------------------------------------------
-void wxPanelCuttingImageData::RefreshOpacity()
-{
- double op= _opacityFig->GetValue()/100.0;
- _actualActor->GetProperty()->SetOpacity( op );
-}
-
-//-------------------------------------------------------------------
-void wxPanelCuttingImageData::OnOpacityFig(wxScrollEvent& event)
-{
- RefreshOpacity();
- Refresh();
-}
-//-------------------------------------------------------------------
-void wxPanelCuttingImageData::RefreshView()
-{
- SetParamsOfTransformation( );
- Refresh();
-}
-//-------------------------------------------------------------------
-void wxPanelCuttingImageData::Refresh()
-{
- _wxvtk3Dbaseview->Refresh();
-}
-
-//-------------------------------------------------------------------
-void wxPanelCuttingImageData::SetParamsOfTransformation( )
-{
- double spc[3];
- vtkImageData *vtkimagedata = _vtkmprbasedata->GetImageData();
- vtkimagedata->GetSpacing(spc);
- int px = (int) (_vtkmprbasedata->GetX() );
- int py = (int) (_vtkmprbasedata->GetY() );
- int pz = (int) (_vtkmprbasedata->GetZ() );
- int sx = (int) (_scaleX->GetValue() * spc[0] );
- int sy = (int) (_scaleY->GetValue() * spc[1] );
- int sz = (int) (_scaleZ->GetValue() * spc[2] );
- _actualCuttingModel -> SetScale ( sx , sy , sz );
- _actualCuttingModel -> SetPosition ( px , py , pz );
- _actualCuttingModel -> SetRotation ( _rotationX->GetValue() , _rotationY->GetValue() , _rotationZ->GetValue() );
- _actualCuttingModel -> SetSpacing ( spc[0] , spc[1] , spc[2] );
- _actualCuttingModel -> CalculeMatrix();
-}
-
-//-------------------------------------------------------------------
-
-void wxPanelCuttingImageData::OnTransform(wxScrollEvent& event)
-{
- RefreshView();
-}
-
-//-------------------------------------------------------------------
-void wxPanelCuttingImageData::SetVtkMPRBaseData( vtkMPRBaseData *vtkmprbasedata )
-{
- _vtkmprbasedata = vtkmprbasedata;
- _imageData = _vtkmprbasedata->GetImageData();
-}
-
-//-------------------------------------------------------------------
-
-void wxPanelCuttingImageData::Configure()
-{
- _actualCuttingModel=_modelCylinder;
- _actualActor=_cylinderActor;
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
- SetParamsOfTransformation();
- RefreshView();
-}
-
-
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-/*
-BEGIN_EVENT_TABLE( wxWidgetMesure2D , wxSplitterWindow )
- EVT_MENU( 12121, wxWidgetMesure2D::OnRefreshView )
-END_EVENT_TABLE( );
-*/
-//-------------------------------------------------------------------
-
-wxWidgetMesure2D::wxWidgetMesure2D( wxWindow *parent )
-: wxSplitterWindow( parent , -1)
-{
-// EED 27 oct 2007
- this->SplitHorizontally( new wxPanel(this,-1) , new wxPanel(this,-1), 2 );
- this->SetMinimumPaneSize(50);
-}
-//-------------------------------------------------------------------
-wxWidgetMesure2D::~wxWidgetMesure2D()
-{
-}
-//-------------------------------------------------------------------
-wxWindow *wxWidgetMesure2D::CreateWin1a(wxWindow *parent) // virtual
-{
- wxPanel *panel = new wxPanel(parent,-1);
-
- _cb_messuretool = new wxCheckBox(panel,-1,_T("Active messure tool "));
- _cb_mt_visible = new wxCheckBox(panel,-1,_T("Visibles "));
- _cb_closeContour = new wxCheckBox(panel,-1,_T("Close/Open "));
- _cb_visibleText = new wxCheckBox(panel,-1,_T("Information "));
-
- _cb_mt_visible->SetValue(true);
- _cb_closeContour->SetValue(true);
- _cb_visibleText->SetValue(true);
-
- wxFlexGridSizer *sizer = new wxFlexGridSizer(4);
-
- sizer->Add(_cb_messuretool);
- sizer->Add(_cb_mt_visible);
- sizer->Add(_cb_closeContour);
- sizer->Add(_cb_visibleText);
-
- panel->SetAutoLayout(true);
- panel->SetSizer(sizer);
- panel->SetSize(400,30);
- panel->Layout();
-//EEDxx2.4
-// panel->FitInside();
-
- Connect(_cb_messuretool->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnActiveMessureTool );
- Connect(_cb_mt_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleMessureTool );
- Connect(_cb_closeContour->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnCloseContour );
- Connect(_cb_visibleText->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleInformation );
-
- return panel;
-}
-
-//-------------------------------------------------------------------
-void wxWidgetMesure2D::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
-{
- _wxvtk2Dbaseview = wxvtk2Dbaseview;
-
- // Contorno 1
- _manContourControl_1 = new manualContourControler();
- _mContourModel_1 = new manualContourModel();
- _mViewContour_1 = new manualViewContour();
- _mViewContour_1->SetModel( _mContourModel_1 );
- _mViewContour_1->SetWxVtkBaseView( _wxvtk2Dbaseview );
- _mViewContour_1->SetRange( 1 );
-
-// EED 3 oct 2006
-// double spc[3];
-// _wxvtk2Dbaseview->GetSpacing( spc );
-// _mViewContour_1->SetSpacing( spc );
-
-
-
- _manContourControl_1->SetZ( 1000 );
- _manContourControl_1->SetModelView( _mContourModel_1 , _mViewContour_1 );
- _wxvtk2Dbaseview->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _manContourControl_1 );
- _manContourControl_1->CreateNewManualContour();
- _manContourControl_1->SetActive( false );
- _mViewContour_1->RefreshContour();
-
-//EED 27 Oct 2007
-
-// this->ReplaceWindow( this->GetWindow1() , CreateWin1a(this) );
-// this->ReplaceWindow( this->GetWindow2() , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() );
-// CreateWin1a(this->GetWindow1() );
-
- wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
- sizerA->Add( CreateWin1a( this->GetWindow1()) ,1, wxGROW );
- this->GetWindow1()->SetSizer(sizerA);
- this->SetAutoLayout(true);
- this->Layout();
-
- wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);
- sizerB->Add( _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() ,1, wxGROW );
- this->GetWindow2()->SetSizer(sizerB);
- this->SetAutoLayout(true);
- this->Layout();
-
-
-// this->SplitHorizontally( CreateWin1a(this) , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() , 2 );
-
-
-//EEDxx2.4
-// this->FitInside();
-}
-
-
-//-------------------------------------------------------------------
-void wxWidgetMesure2D::ActiveMessureTool(bool ok)
-{
- _wxvtk2Dbaseview->GetInteractorStyleBaseView()->SetActiveAllInteractors(!ok);
- _manContourControl_1->SetActive( ok );
-}
-
-//-------------------------------------------------------------------
-void wxWidgetMesure2D::OnActiveMessureTool(wxCommandEvent& event)
-{
- ActiveMessureTool( _cb_messuretool->GetValue() );
- if ( _cb_messuretool->GetValue() == true )
- {
- _cb_mt_visible->SetValue(true);
- _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
- _cb_closeContour->Enable(true);
- _cb_visibleText->Enable(true);
- } else{
- _cb_closeContour->Enable(false);
- _cb_visibleText->Enable(false);
- }
- _wxvtk2Dbaseview->Refresh();
- _wxvtk2Dbaseview->RefreshView();
-}
-
-//-------------------------------------------------------------------
-void wxWidgetMesure2D::OnVisibleMessureTool(wxCommandEvent& event)
-{
- _cb_messuretool->SetValue( _cb_mt_visible->GetValue() );
- if (_cb_messuretool->GetValue()==true)
- {
- _cb_closeContour->Enable(true);
- _cb_visibleText->Enable(true);
- }
- ActiveMessureTool( _cb_messuretool->GetValue() );
- _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
- _mViewContour_1->Refresh();
- _wxvtk2Dbaseview->Refresh();
- _wxvtk2Dbaseview->RefreshView();
-}
-
-//-------------------------------------------------------------------
-void wxWidgetMesure2D::OnCloseContour(wxCommandEvent& event)
-{
- _mContourModel_1->SetCloseContour( _cb_closeContour->GetValue() );
- _mViewContour_1->Refresh();
- _wxvtk2Dbaseview->Refresh();
- _wxvtk2Dbaseview->RefreshView();
-
-}
-//-------------------------------------------------------------------
-void wxWidgetMesure2D::OnVisibleInformation(wxCommandEvent& event)
-{
- _mViewContour_1->SetShowText( _cb_visibleText->GetValue() );
- _mViewContour_1->Refresh();
- _wxvtk2Dbaseview->Refresh();
- _wxvtk2Dbaseview->RefreshView();
-}
-//-------------------------------------------------------------------
-void wxWidgetMesure2D::SetMesureScale(double mesureScale)
-{
- _mViewContour_1->SetMesureScale(mesureScale);
-}
-//-------------------------------------------------------------------
-manualContourModel* wxWidgetMesure2D::GetManualContourModel()
-{
- return _mContourModel_1;
-}
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-
-wxWidgetMesure2D_Plane::wxWidgetMesure2D_Plane(wxWindow *parent)
-: wxWidgetMesure2D(parent)
-{
- // Circle 1
- _ptsCircle1 = NULL;
- _circle1Actor = NULL;
- _circle1Mapper = NULL;
- _pdCircle1 = NULL;
- // Circle 2
- _ptsCircle2 = NULL;
- _circle2Actor = NULL;
- _circle2Mapper = NULL;
- _pdCircle2 = NULL;
- // line reference 1
- _ptsLineRef1 = NULL;
- _lineRef1Actor = NULL;
- _lineRef1Mapper = NULL;
- _pdLineRef1 = NULL;
- // line reference 2
- _ptsLineRef2 = NULL;
- _lineRef2Actor = NULL;
- _lineRef2Mapper = NULL;
- _pdLineRef2 = NULL;
-
-}
-
-//-------------------------------------------------------------------
-
-wxWidgetMesure2D_Plane::~wxWidgetMesure2D_Plane()
-{
- // Circle 1
- if ( _ptsCircle1 != NULL){ _ptsCircle1 -> Delete(); }
- if ( _circle1Actor != NULL){ _circle1Actor -> Delete(); }
- if ( _circle1Mapper != NULL){ _circle1Mapper -> Delete(); }
- if ( _pdCircle1 != NULL){ _pdCircle1 -> Delete(); }
- // Circle 2
- if ( _ptsCircle2 != NULL){ _ptsCircle2 -> Delete(); }
- if ( _circle2Actor != NULL){ _circle2Actor -> Delete(); }
- if ( _circle2Mapper != NULL){ _circle2Mapper -> Delete(); }
- if ( _pdCircle2 != NULL){ _pdCircle2 -> Delete(); }
- // line reference 1
- if ( _ptsLineRef1 != NULL){ _ptsLineRef1 -> Delete(); }
- if ( _lineRef1Actor != NULL){ _lineRef1Actor -> Delete(); }
- if ( _lineRef1Mapper != NULL){ _lineRef1Mapper -> Delete(); }
- if ( _pdLineRef1 != NULL){ _pdLineRef1 -> Delete(); }
- // line reference 2
- if ( _ptsLineRef2 != NULL){ _ptsLineRef2 -> Delete(); }
- if ( _lineRef2Actor != NULL){ _lineRef2Actor -> Delete(); }
- if ( _lineRef2Mapper != NULL){ _lineRef2Mapper -> Delete(); }
- if ( _pdLineRef2 != NULL){ _pdLineRef2 -> Delete(); }
-}
-
-//-------------------------------------------------------------------
-
-wxWindow *wxWidgetMesure2D_Plane::CreateWin1a(wxWindow *parent) // virtual
-{
- wxPanel *panel = new wxPanel(parent,-1);
-
- _cb_circle = new wxCheckBox(panel,-1,_T("Circle "));
- _cb_line = new wxCheckBox(panel,-1,_T("Rotation Axe "));
-
-
- wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
- sizerA->Add(_cb_circle);
- sizerA->Add(_cb_line);
-
-
- wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
- sizer->Add( sizerA );
- sizer->Add( wxWidgetMesure2D::CreateWin1a(panel) );
-
- panel->SetAutoLayout(true);
- panel->SetSizer(sizer);
- panel->SetSize(400,30);
- panel->Layout();
-//EEDxx2.4
-// panel->FitInside();
-
- Connect(_cb_line->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveLine );
- Connect(_cb_circle->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveCirlcle );
-
- return panel;
-}
-
-
-//-------------------------------------------------------------------
-void wxWidgetMesure2D_Plane::OnActiveCirlcle(wxCommandEvent& event)
-{
- SetVisibleCircle( _cb_circle->GetValue() );
- _wxvtk2Dbaseview->RefreshView();
-}
-
-//-------------------------------------------------------------------
-void wxWidgetMesure2D_Plane::SetVisibleCircle( bool ok )
-{
- double opacity;
- if (ok==true)
- {
- opacity=1;
- } else {
- opacity=0;
- }
- _lineRef1Actor->GetProperty()->SetOpacity( opacity );
- _lineRef2Actor->GetProperty()->SetOpacity( opacity );
- _circle1Actor->GetProperty()->SetOpacity( opacity );
- _circle2Actor->GetProperty()->SetOpacity( opacity );
-}
-//-------------------------------------------------------------------
-void wxWidgetMesure2D_Plane::OnActiveLine(wxCommandEvent& event)
-{
- vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
- vtkplane2Dview->SetVisibleLine( _cb_line->GetValue() );
- _wxvtk2Dbaseview->RefreshView();
-}
-
-
-//-------------------------------------------------------------------
-void wxWidgetMesure2D_Plane::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
-{
- wxWidgetMesure2D::ConfigureA(wxvtk2Dbaseview);
- CircleLine();
- ConfigureCircleLine();
- SetVisibleCircle(false);
-}
-
-
-//-------------------------------------------------------------------
-void wxWidgetMesure2D_Plane::ConfigureCircleLine()
-{
- double ang;
-
- vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
- int sizeIma = vtkplane2Dview->GetImgSize();
-
- double i,maxPts=20;
- double k=(360/(maxPts-1)) * (3.1416/180);
- double x,y,r1=5,r2=10,r3=15;
- for (i=0;i<maxPts;i++)
- {
- x=cos( k*i ) ;
- y=sin( k*i ) ;
- _ptsCircle1->SetPoint( (int)i , (sizeIma/2) + x*r1 , (sizeIma/2) + y*r1 , 1 );
- _ptsCircle2->SetPoint( (int)i , (sizeIma/2) + x*r2 , (sizeIma/2) + y*r2 , 1 );
- }
-
- //
- ang=(45) * (3.1416/180);
- x=cos( ang ) ;
- y=sin( ang ) ;
- _ptsLineRef1->SetPoint( 0 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
-
- ang=(45+180) * (3.1416/180);
- x=cos( ang ) ;
- y=sin( ang ) ;
- _ptsLineRef1->SetPoint( 1 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
-
- //
- ang=(135) * (3.1416/180);
- x=cos( ang ) ;
- y=sin( ang ) ;
- _ptsLineRef2->SetPoint( 0 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
-
- ang=(135+180) * (3.1416/180);
- x=cos( ang ) ;
- y=sin( ang ) ;
- _ptsLineRef2->SetPoint( 1 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
-}
-
-
-
-//-------------------------------------------------------------------
-void wxWidgetMesure2D_Plane::CircleLine()
-{
- int i,maxPts=20;
- vtkCellArray *lines;
-
- vtkImageViewer2_XYZ *imageViewer2XYZ = _wxvtk2Dbaseview->_imageViewer2XYZ;
-
-
-// Circle 1 Horizontal
- _ptsCircle1 = vtkPoints::New();
- _ptsCircle1->SetNumberOfPoints(maxPts);
- lines = vtkCellArray::New();
- lines->InsertNextCell(maxPts);
- for (i=0;i<maxPts;i++)
- {
- lines->InsertCellPoint(i);
- _ptsCircle1->SetPoint(i, 0 , 0 , 0 );
- }
- lines->InsertCellPoint(0);
- _ptsCircle1->SetPoint(0, -1000 , -1000 , -1000 );
- _ptsCircle1->SetPoint(1, 1000 , 1000 , 1000 );
-
- _pdCircle1 = vtkPolyData::New();
- _pdCircle1->SetPoints( _ptsCircle1 );
- _pdCircle1->SetLines( lines );
- lines->Delete(); //do not delete lines ??
- _circle1Actor = vtkActor::New();
- _circle1Mapper = vtkPolyDataMapper::New();
- _circle1Mapper->SetInput(_pdCircle1);
- _circle1Mapper->ImmediateModeRenderingOn();
- _circle1Actor->SetMapper(_circle1Mapper);
- _circle1Actor->GetProperty()->BackfaceCullingOn();
- _circle1Actor->GetProperty()->SetDiffuseColor(0,0,1);
- _circle1Actor->GetProperty()->SetLineWidth(2);
- imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle1Actor );
-
-// Circle 2 Horizontal
- _ptsCircle2 = vtkPoints::New();
- _ptsCircle2->SetNumberOfPoints(maxPts);
- lines = vtkCellArray::New();
- lines->InsertNextCell(maxPts);
- for (i=0;i<maxPts;i++)
- {
- lines->InsertCellPoint(i);
- _ptsCircle2->SetPoint(i, 0 , 0 , 0 );
- }
- _ptsCircle2->SetPoint(0, -1000 , -1000 , -1000 );
- _ptsCircle2->SetPoint(1, 1000 , 1000 , 1000 );
-
- _pdCircle2 = vtkPolyData::New();
- _pdCircle2->SetPoints( _ptsCircle2 );
- _pdCircle2->SetLines( lines );
- lines->Delete(); //do not delete lines ??
- _circle2Actor = vtkActor::New();
- _circle2Mapper = vtkPolyDataMapper::New();
- _circle2Mapper->SetInput(_pdCircle2);
- _circle2Mapper->ImmediateModeRenderingOn();
- _circle2Actor->SetMapper(_circle2Mapper);
- _circle2Actor->GetProperty()->BackfaceCullingOn();
- _circle2Actor->GetProperty()->SetDiffuseColor(0,0,1);
- _circle2Actor->GetProperty()->SetLineWidth(2);
- imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle2Actor );
-
-// Line Referance 1
- _ptsLineRef1 = vtkPoints::New();
- _ptsLineRef1->SetNumberOfPoints(2);
- _ptsLineRef1->SetPoint(0, -1000 , -1000 , -1000 );
- _ptsLineRef1->SetPoint(1, 1000 , 1000 , 1000 );
- lines = vtkCellArray::New();
- lines->InsertNextCell(2);
- lines->InsertCellPoint(0);
- lines->InsertCellPoint(1);
-
- _pdLineRef1 = vtkPolyData::New();
- _pdLineRef1->SetPoints( _ptsLineRef1 );
- _pdLineRef1->SetLines( lines );
- lines->Delete(); //do not delete lines ??
- _lineRef1Actor = vtkActor::New();
- _lineRef1Mapper = vtkPolyDataMapper::New();
- _lineRef1Mapper->SetInput(_pdLineRef1);
- _lineRef1Mapper->ImmediateModeRenderingOn();
- _lineRef1Actor->SetMapper(_lineRef1Mapper);
- _lineRef1Actor->GetProperty()->BackfaceCullingOn();
- _lineRef1Actor->GetProperty()->SetDiffuseColor(0,0,1);
- _lineRef1Actor->GetProperty()->SetLineWidth(2);
- imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef1Actor );
-
-// Line Referance 2
- _ptsLineRef2 = vtkPoints::New();
- _ptsLineRef2->SetNumberOfPoints(2);
- _ptsLineRef2->SetPoint(0, -1000 , -1000 , -1000 );
- _ptsLineRef2->SetPoint(1, 1000 , 1000 , 1000 );
- lines = vtkCellArray::New();
- lines->InsertNextCell(2);
- lines->InsertCellPoint(0);
- lines->InsertCellPoint(1);
-
- _pdLineRef2 = vtkPolyData::New();
- _pdLineRef2->SetPoints( _ptsLineRef2 );
- _pdLineRef2->SetLines( lines );
- lines->Delete(); //do not delete lines ??
- _lineRef2Actor = vtkActor::New();
- _lineRef2Mapper = vtkPolyDataMapper::New();
- _lineRef2Mapper->SetInput(_pdLineRef2);
- _lineRef2Mapper->ImmediateModeRenderingOn();
- _lineRef2Actor->SetMapper(_lineRef2Mapper);
- _lineRef2Actor->GetProperty()->BackfaceCullingOn();
- _lineRef2Actor->GetProperty()->SetDiffuseColor(0,0,1);
- _lineRef2Actor->GetProperty()->SetLineWidth(2);
- imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef2Actor );
-
+ PURPOSE. See the above copyright notice for more information.
-}
+=========================================================================*/
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
+#include <vtkObjectFactory.h>
+#include <vtkInteractorStyleSwitch.h>
+#include <vtkCamera.h>
+#include <vtkImageActor.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkRenderWindow.h>
-wxWidgetMesure2D_Plane_in_MPR::wxWidgetMesure2D_Plane_in_MPR(wxWindow *parent)
-:wxWidgetMesure2D_Plane(parent)
-{
- _vtkplane2Dview=NULL;
-}
+#include <vtkRenderer.h>
+#include <vtkImageViewer2.h>
+#include <vtkInteractorStyleImage.h>
-//-------------------------------------------------------------------
+#include <vtkProperty.h>
+#include <vtkPolyData.h>
+#include <vtkDataSet.h>
+#include <vtkStripper.h>
+#include <vtkCellArray.h>
+#include <vtkPointData.h>
+#include <vtkInteractorStyleTrackballCamera.h>
-wxWidgetMesure2D_Plane_in_MPR::~wxWidgetMesure2D_Plane_in_MPR()
-{
-}
-//-------------------------------------------------------------------
-void wxWidgetMesure2D_Plane_in_MPR::OnActiveLink(wxCommandEvent& event)
-{
- if (_vtkplane2Dview!=NULL)
- {
- _vtkplane2Dview->SetActive( _cb_link->GetValue() );
- _vtkplane2Dview->Refresh();
- _vtkplane2Dview->RefreshView();
- }
-}
+#include <vtkPlanes.h>
+#include <vtkProbeFilter.h>
+#include <vtkPlane.h>
+#include <vtkPointPicker.h>
-//-------------------------------------------------------------------
-void wxWidgetMesure2D_Plane_in_MPR::SetActiveLink(bool ok)
-{
- _cb_link->SetValue(ok);
- if (_vtkplane2Dview!=NULL)
- {
- _vtkplane2Dview->SetActive( _cb_link->GetValue() );
- }
-}
-//-------------------------------------------------------------------
+#include "vtkClosePolyData.h"
+#include <vtkTriangleFilter.h>
+#include <vtkSTLWriter.h>
+#include <vtkPolyDataConnectivityFilter.h>
-void wxWidgetMesure2D_Plane_in_MPR::SetVtkPlane2DView(vtkPlane2DView *vtkplane2Dview)
-{
- _vtkplane2Dview = vtkplane2Dview;
-}
+// EED 25 Janvier 2007 - TestLoic
+#include <vtkCutter.h>
+#include <vtkWindowLevelLookupTable.h>
+#include <vtkLookupTable.h>
+#include <vtkMetaImageWriter.h>
-//-------------------------------------------------------------------
-wxWindow *wxWidgetMesure2D_Plane_in_MPR::CreateWin1a(wxWindow *parent) // virtual
-{
- wxPanel *panel = new wxPanel(parent,-1);
- _cb_link = new wxCheckBox(panel,-1,_T("LINK "));
- _cb_link->SetValue(true);
+#include "wxMPRWidget.h"
+#include "creawxVTKRenderWindowInteractor.h"
+#include "UtilVtk3DGeometriSelection.h"
+#include "../kernel/marDicomBase.h"
- wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
- sizer->Add(_cb_link);
+#include <wx/wx.h>
+#include <wx/notebook.h>
+#include <wx/colordlg.h>
- sizer->Add( wxWidgetMesure2D_Plane::CreateWin1a(panel) );
+#include "matrix.h"
+#include <string>
+#include <stdio.h>
- panel->SetAutoLayout(true);
- panel->SetSizer(sizer);
- panel->SetSize(400,30);
- panel->Layout();
-//EEDxx2.4
-// panel->FitInside();
- Connect(_cb_link->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxWidgetMesure2D_Plane_in_MPR::OnActiveLink );
+#include "pPlotter/HistogramDialog.h"
- return panel;
-}
+#include "vtkInteractorStyle3DView.h"
+//-------------------------------------------------------------------
+//-------------------------------------------------------------------
+//-------------------------------------------------------------------
wxMPRWidget::wxMPRWidget( wxWindow* parent,
- marImageData *marimageData , double voxelSize)
+ marImageData *marimageData )
: wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
{
if(marimageData!=NULL){
_marImageData = marimageData;
- _voxelSize = voxelSize;
_vtkmprbasedata = new vtkMPRBaseData();
_vtkmprbasedata->SetMarImageData(_marImageData);
wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
pnlSplitter -> SetMinimumPaneSize( 2 );
+ //RaC Nov2012 Correctly resize internal panels with the window resize event
+ pnlSplitter->SetSashGravity(0.5);
wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
_refreshBPage=0;
}
-void wxMPRWidget::setImageData(vtkImageData * img, double voxelsize){
+
+//----------------------------------------------------------------------------
+void wxMPRWidget::setImageData(vtkImageData * img)
+{
if(_marImageData!=NULL){
_marImageData->removeImageData(0);
_marImageData->AddImageData(img);
}else{
- _marImageData = new marImageData(img);
+ _marImageData = new marImageData(img);
}
- _voxelSize = voxelsize;
-
if(_vtkmprbasedata==NULL){
_vtkmprbasedata = new vtkMPRBaseData();
_vtkmprbasedata->SetMarImageData(_marImageData);
- wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
+ wxSplitterWindow *pnlSplitter= new wxSplitterWindow( this , -1);
pnlSplitter -> SetMinimumPaneSize( 2 );
+ //RaC Nov2012 Correctly resize internal panels with the window resize event
+ pnlSplitter->SetSashGravity(0.5);
- wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
+ wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 );
this->GetSizer() -> Add( pnlSplitter ,1,wxGROW ,0);
}
-
-
-
}
-//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
wxMPRWidget::~wxMPRWidget( )
{
//EEDxx2.4 DELETE
if (type==3)
{
_widgetMesure_B = new wxWidgetMesure2D_Plane_in_MPR(panel);
- _vtkplane2Dview_B = new vtkPlane2DView( _widgetMesure_B->GetWindow2());
+ _vtkplane2Dview_B = new vtkPlane2DView( _widgetMesure_B->GetWindow2());
_widgetMesure_B->SetVtkPlane2DView( _vtkplane2Dview_B );
_vtkplane2Dview_B->SetImgSize( 200 );
_vtkplane2Dview_B->SetVtkBaseData(vtkmprbasedata);
}
if (type==4)
{
- _wxsphereview_B = new wxSphereView( panel , vtkmprbasedata, vtkmprbasedata->GetImageData() );
+//EED
+// _wxsphereview_B = new wxSphereView( panel , vtkmprbasedata, vtkmprbasedata->GetImageData() );
+ _wxsphereview_B = new wxSphereView( panel , vtkmprbasedata );
wxwindow=_wxsphereview_B->GetWxVTKRenderWindowInteractor();
}
if (type==5)
{
wxSplitterWindow *panelMPR3D = new wxSplitterWindow( panel , -1);
- _wxvtk3Dbaseview_MPR3D_B = new wxVtk3DBaseView( panelMPR3D );
+ _wxvtk3Dbaseview_MPR3D_B = new wxVtk3DBaseView( panelMPR3D , vtkmprbasedata );
- _wxvtkmpr3Dview_B = new wxVtkMPR3DView(_wxvtk3Dbaseview_MPR3D_B);
+ _wxvtkmpr3Dview_B = new wxVtkMPR3DView(_wxvtk3Dbaseview_MPR3D_B);
vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
vtkmpr3Ddataviewer->Configure();
_wxvtkmpr3Dview_B->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
- wxWindow *window3D = _wxvtk3Dbaseview_MPR3D_B->GetWxVTKRenderWindowInteractor();
- wxPanel *controlPanel3D = _wxvtkmpr3Dview_B->CreateControlPanel(panelMPR3D);
+ wxWindow *window3D = _wxvtk3Dbaseview_MPR3D_B->GetWxVTKRenderWindowInteractor();
+ wxPanel *controlPanel3D = _wxvtkmpr3Dview_B->CreateControlPanel(panelMPR3D, false);
//EEDxx2.4
panelMPR3D -> SetMinimumPaneSize( 5 );
panelMPR3D -> SplitHorizontally( controlPanel3D,window3D,600 );
+ //RaC Nov2012 Correctly resize internal panels with the window resize event
+ panelMPR3D->SetSashGravity(0.5);
wxwindow=panelMPR3D;
}
if (type==6)
{
wxSplitterWindow *panelClipping3D = new wxSplitterWindow( panel , -1);
- _wxvtk3Dbaseview_Clipping3D_BB = new wxVtk3DBaseView( panelClipping3D );
+ _wxvtk3Dbaseview_Clipping3D_BB = new wxVtk3DBaseView( panelClipping3D , vtkmprbasedata );
_wxvtkclipping3Dview_BB = new wxVtkClipping3DView(_wxvtk3Dbaseview_Clipping3D_BB);
vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
vtkmpr3Ddataviewer->Configure();
_wxvtkmpr3Dview_BB->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
- wxWindow *window3D = _wxvtk3Dbaseview_Clipping3D_BB->GetWxVTKRenderWindowInteractor();
+ wxWindow *window3D = _wxvtk3Dbaseview_Clipping3D_BB->GetWxVTKRenderWindowInteractor();
wxPanel *panelControl = new wxPanel(panelClipping3D,-1);
- wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview_BB->CreateControlPanel(panelControl);
- wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview_BB->CreateControlPanel(panelControl);
+ wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview_BB->CreateControlPanel(panelControl, false);
+ wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview_BB->CreateSurfControlPanel(panelControl);
_btnCutImageData = new wxCheckBox(panelControl,-1,_T("Cut Module"));
Connect(_btnCutImageData->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxMPRWidget::OnCutImagaData );
//EEDxx2.4
panelClipping3D -> SetMinimumPaneSize( 5 );
panelClipping3D -> SplitHorizontally( panelControl , window3D , 10 );
+ //RaC Nov2012 Correctly resize internal panels with the window resize event
+ panelClipping3D->SetSashGravity(0.5);
wxwindow=panelClipping3D;
}
// view 0
_vtkmpr2Dview[0] = new wxVtkMPR2DView(panel,0);
_vtkmpr2Dview[0]->SetVtkBaseData(vtkmprbasedata);
- wxVTKRenderWindowInteractor *iren0 = _vtkmpr2Dview[0]->GetWxVTKRenderWindowInteractor();
+ crea::wxVTKRenderWindowInteractor *iren0 = _vtkmpr2Dview[0]->GetWxVTKRenderWindowInteractor();
// view 1
_vtkmpr2Dview[1] = new wxVtkMPR2DView(panel,1);
_vtkmpr2Dview[1]->SetVtkBaseData(vtkmprbasedata);
- wxVTKRenderWindowInteractor *iren1 = _vtkmpr2Dview[1]->GetWxVTKRenderWindowInteractor();
+ crea::wxVTKRenderWindowInteractor *iren1 = _vtkmpr2Dview[1]->GetWxVTKRenderWindowInteractor();
// view 2
_vtkmpr2Dview[2] = new wxVtkMPR2DView(panel,2);
_vtkmpr2Dview[2]->SetVtkBaseData(vtkmprbasedata);
- wxVTKRenderWindowInteractor *iren2 = _vtkmpr2Dview[2]->GetWxVTKRenderWindowInteractor();
+ crea::wxVTKRenderWindowInteractor *iren2 = _vtkmpr2Dview[2]->GetWxVTKRenderWindowInteractor();
// view 3
wxNotebook *notebook = new wxNotebook( panel, -1 );
notebook->AddPage( _widgetMesure, _T("Plane") );
// view 3.1
- _wxsphereview = new wxSphereView( notebook , vtkmprbasedata, vtkmprbasedata->GetImageData());
- wxVTKRenderWindowInteractor *iren3B = _wxsphereview->GetWxVTKRenderWindowInteractor();
+// EED
+// _wxsphereview = new wxSphereView( notebook , vtkmprbasedata, vtkmprbasedata->GetImageData());
+ _wxsphereview = new wxSphereView( notebook , vtkmprbasedata );
+ crea::wxVTKRenderWindowInteractor *iren3B = _wxsphereview->GetWxVTKRenderWindowInteractor();
notebook->AddPage( iren3B, _T("Sphere") );
-
// view 3.2
wxSplitterWindow *panelMPR3D = new wxSplitterWindow( notebook , -1);
- _wxvtk3Dbaseview_MPRClipping3D = new wxVtk3DBaseView( panelMPR3D );
+ _wxvtk3Dbaseview_MPRClipping3D = new wxVtk3DBaseView( panelMPR3D ,vtkmprbasedata );
_wxvtkmpr3Dview = new wxVtkMPR3DView( _wxvtk3Dbaseview_MPRClipping3D );
vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
_wxvtkclipping3Dview->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
- wxWindow *window3D = _wxvtk3Dbaseview_MPRClipping3D->GetWxVTKRenderWindowInteractor();
-
+ wxWindow *window3D = _wxvtk3Dbaseview_MPRClipping3D->GetWxVTKRenderWindowInteractor();
wxPanel *panelControl = new wxPanel(panelMPR3D,-1);
- wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview->CreateControlPanel(panelControl);
- wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview->CreateControlPanel(panelControl);
-
-
-
+ wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview->CreateControlPanel(panelControl, false);
+ wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview->CreateSurfControlPanel(panelControl);
// wxBoxSizer *sizerCtrol = new wxBoxSizer(wxVERTICAL);
wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
-
panelControl->SetAutoLayout(true);
panelControl->SetSizer(sizerCtrol);
panelControl->SetSize(400,150);
//EEDxx2.4
panelMPR3D -> SetMinimumPaneSize( 5 );
-
+ //RaC Nov2012 Correctly resize internal panels with the window resize event
+ panelMPR3D->SetSashGravity(0.5);
panelMPR3D -> SplitHorizontally( panelControl,window3D,200 );
-
notebook->AddPage( panelMPR3D, _T("MPR 3D - Clipping") );
-
-
Connect(notebook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , (wxObjectEventFunction) &wxMPRWidget::OnPageBChanged );
-
wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *sizerH1= new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *sizerH2= new wxBoxSizer(wxHORIZONTAL);
if (_vtkmprbasedata!=NULL)
{
_vtkmprbasedata->Configure();
- x=_vtkmprbasedata -> GetMaxPositionX()/2;
- y=_vtkmprbasedata -> GetMaxPositionY()/2;
- z=_vtkmprbasedata -> GetMaxPositionZ()/2;
+ x = _vtkmprbasedata->GetMaxPositionX()/2;
+ y = _vtkmprbasedata->GetMaxPositionY()/2;
+ z = _vtkmprbasedata->GetMaxPositionZ()/2;
_vtkmprbasedata->SetX( x );
_vtkmprbasedata->SetY( y );
_vtkmprbasedata->SetZ( z );
}
- if(_vtkmpr2Dview[0]!=NULL) {_vtkmpr2Dview[0] -> Configure();}
- if(_vtkmpr2Dview[1]!=NULL) {_vtkmpr2Dview[1] -> Configure();}
- if(_vtkmpr2Dview[2]!=NULL) {_vtkmpr2Dview[2] -> Configure();}
+ if(_vtkmpr2Dview[0]!=NULL) { _vtkmpr2Dview[0]->Configure(); }
+ if(_vtkmpr2Dview[1]!=NULL) { _vtkmpr2Dview[1]->Configure(); }
+ if(_vtkmpr2Dview[2]!=NULL) { _vtkmpr2Dview[2]->Configure(); }
+ if (_vtkmpr2Dview_B[0]!=NULL) { _vtkmpr2Dview_B[0]->Configure(); }
+ if (_vtkmpr2Dview_B[1]!=NULL) { _vtkmpr2Dview_B[1]->Configure(); }
+ if (_vtkmpr2Dview_B[2]!=NULL) { _vtkmpr2Dview_B[2]->Configure(); }
- if (_vtkmpr2Dview_B[0]!=NULL) { _vtkmpr2Dview_B[0] -> Configure(); }
- if (_vtkmpr2Dview_B[1]!=NULL) { _vtkmpr2Dview_B[1] -> Configure(); }
- if (_vtkmpr2Dview_B[2]!=NULL) { _vtkmpr2Dview_B[2] -> Configure(); }
-
-
-
-
- if (_vtkplane2Dview!=NULL){_vtkplane2Dview -> Configure();}
- if (_widgetMesure!=NULL){_widgetMesure -> ConfigureA(_vtkplane2Dview);}
- if (_widgetMesure!=NULL){_widgetMesure -> SetActiveLink(true);}
- if (_widgetMesure!=NULL){_widgetMesure -> SetMesureScale( _voxelSize );}
- if (_wxsphereview!=NULL){_wxsphereview -> Configure();}
+ if (_vtkplane2Dview!=NULL) { _vtkplane2Dview->Configure(); }
+ if (_widgetMesure!=NULL) { _widgetMesure->ConfigureA(_vtkplane2Dview); }
+ if (_widgetMesure!=NULL) { _widgetMesure->SetActiveLink(true); }
+ if (_wxsphereview!=NULL) { _wxsphereview->Configure(); }
- if (_wxvtk3Dbaseview_MPRClipping3D!=NULL){_wxvtk3Dbaseview_MPRClipping3D -> Configure();}
- if (_wxvtkmpr3Dview!=NULL){
- _wxvtkmpr3Dview -> Configure();
- }
- if (_wxvtkclipping3Dview!=NULL){_wxvtkclipping3Dview -> Configure();}
+ if (_wxvtk3Dbaseview_MPRClipping3D!=NULL){_wxvtk3Dbaseview_MPRClipping3D->Configure();}
+ if (_wxvtkmpr3Dview!=NULL) { _wxvtkmpr3Dview->Configure(); }
+ if (_wxvtkclipping3Dview!=NULL) { _wxvtkclipping3Dview->Configure(); }
- if (_vtkplane2Dview_B!=NULL){ _vtkplane2Dview_B -> Configure(); }
- if (_widgetMesure_B!=NULL){ _widgetMesure_B -> ConfigureA( _vtkplane2Dview_B ); }
- if (_widgetMesure_B!=NULL){ _widgetMesure_B -> SetActiveLink(true); }
+ if (_vtkplane2Dview_B!=NULL) { _vtkplane2Dview_B->Configure(); }
+ if (_widgetMesure_B!=NULL) { _widgetMesure_B->ConfigureA( _vtkplane2Dview_B ); }
+ if (_widgetMesure_B!=NULL) { _widgetMesure_B->SetActiveLink(true); }
//EEDx3
// double spc[3];
// imageData->GetSpacing(spc);
// _widgetMesure_B->SetMesureScale(spc[0]);
- if (_widgetMesure_B!=NULL) {_widgetMesure_B->SetMesureScale( _voxelSize );}
-
if (_wxsphereview_B!=NULL) {_wxsphereview_B -> Configure();}
if (_wxvtk3Dbaseview_Clipping3D_BB!=NULL)
{
- _wxvtk3Dbaseview_Clipping3D_BB->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( vtkinteractorstyle3Dview );
+ ((vtkInteractorStyleBaseView*)_wxvtk3Dbaseview_Clipping3D_BB->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( vtkinteractorstyle3Dview );
}
//EED 29Mars2009
return _vtkmpr2Dview[direction];
}
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-wxMPRWidget2::wxMPRWidget2(wxWindow* parent,marImageData *marimagedata,double voxelSize)
-: wxMPRWidget(parent,marimagedata,voxelSize)
-{
-}
-//----------------------------------------------------------------------------
-wxMPRWidget2::~wxMPRWidget2()
-{
-}
-//----------------------------------------------------------------------------
-void wxMPRWidget2::OnRefreshView(wxCommandEvent & event) // Virtual
-{
- wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- this->GetParent()->ProcessEvent(newevent1);
-}
-
-
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-figureCuttingModel::figureCuttingModel()
-{
- _inversModel = vtkTransform::New();
- _matrixModel = vtkTransform::New();
- _matrixVisual = vtkTransform::New();
-
- _spcX=1;
- _spcY=1;
- _spcZ=1;
-}
-//----------------------------------------------------------------------------
-figureCuttingModel::~figureCuttingModel() // virtual
-{
- _inversModel->Delete();
-}
-//----------------------------------------------------------------------------
-void figureCuttingModel::SetPosition(double x,double y, double z)
-{
- _px=x;
- _py=y;
- _pz=z;
-}
-//----------------------------------------------------------------------------
-void figureCuttingModel::SetScale(double sx,double sy, double sz)
-{
- _sx=sx;
- _sy=sy;
- _sz=sz;
-}
-//----------------------------------------------------------------------------
-void figureCuttingModel::SetRotation(double alfa,double beta, double teta)
-{
- _alfa=alfa;
- _beta=beta;
- _teta=teta;
-}
-
-//----------------------------------------------------------------------------
-void figureCuttingModel::CalculeMatrix()
-{
- _matrixModel->Identity();
- _matrixModel->Translate(_px,_py,_pz);
- _matrixModel->RotateY(_beta);
- _matrixModel->RotateX(_alfa);
- _matrixModel->RotateY(_teta);
- _matrixModel->Scale(_sx,_sy,_sz);
-
- _matrixVisual->Identity();
- _matrixVisual->Translate( _px*_spcX , _py*_spcY , _pz*_spcZ );
- _matrixVisual->RotateY(_beta);
- _matrixVisual->RotateX(_alfa);
- _matrixVisual->RotateY(_teta);
- _matrixVisual->Scale( _sx*_spcX , _sy*_spcY , _sz*_spcZ );
-
-}
-
-
-//----------------------------------------------------------------------------
-void figureCuttingModel::CalculeInversMatrix()
-{
- _inversModel->Identity ();
- _inversModel->Concatenate ( _matrixModel );
- _inversModel->Inverse();
-}
-//----------------------------------------------------------------------------
-bool figureCuttingModel::IfPointInside(double x, double y, double z) // virtual
-{
- return true;
-}
-
-//----------------------------------------------------------------------------
-vtkTransform *figureCuttingModel::GetVtkTransform()
-{
- return _matrixVisual;
-}
-
-//----------------------------------------------------------------------------
-//void figureCuttingModel::SetVtkTransform(vtkTransform *matrix)
-//{
-// _matrixModel = matrix;
-//}
-
-//----------------------------------------------------------------------------
-double figureCuttingModel::GetTheoricVolume() // virtual
-{
- return 0;
-}
-
-//----------------------------------------------------------------------------
-double figureCuttingModel::GetPositionX()
-{
- return _px;
-}
-//----------------------------------------------------------------------------
-double figureCuttingModel::GetPositionY()
-{
- return _py;
-}
-//----------------------------------------------------------------------------
-double figureCuttingModel::GetPositionZ()
-{
- return _pz;
-}
-//----------------------------------------------------------------------------
-double figureCuttingModel::GetScaleX()
-{
- return _sx;
-}
-//----------------------------------------------------------------------------
-double figureCuttingModel::GetScaleY()
-{
- return _sy;
-}
-//----------------------------------------------------------------------------
-double figureCuttingModel::GetScaleZ()
-{
- return _sz;
-}
-//----------------------------------------------------------------------------
-double figureCuttingModel::GetAngleAlfa()
-{
- return _alfa;
-}
-//----------------------------------------------------------------------------
-double figureCuttingModel::GetAngleBeta()
-{
- return _beta;
-}
-//----------------------------------------------------------------------------
-double figureCuttingModel::GetAngleTeta()
-{
- return _teta;
-}
-//----------------------------------------------------------------------------
-char *figureCuttingModel::GetName() // virtual
-{
- return "--";
-}
-
-//----------------------------------------------------------------------------
-void figureCuttingModel::SetSpacing(double spcX,double spcY, double spcZ)
-{
- _spcX = spcX;
- _spcY = spcY;
- _spcZ = spcZ;
-}
-
-//----------------------------------------------------------------------------
-
-
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-figureCuttingSphereModel::figureCuttingSphereModel()
-{
-}
-//----------------------------------------------------------------------------
-figureCuttingSphereModel::~figureCuttingSphereModel() // virtual
-{
-}
-//----------------------------------------------------------------------------
-bool figureCuttingSphereModel::IfPointInside(double x, double y, double z) // virtual
-{
- double in[4],out[4];
- in[0]=x;
- in[1]=y;
- in[2]=z;
- in[3]=1;
- _inversModel->MultiplyPoint (in, out);
-
- bool result=false;
- if (sqrt( out[0]*out[0] + out[1]*out[1] + out[2]*out[2] )<0.5 )
- {
- result=true;
- }
- return result;
-}
-//----------------------------------------------------------------------------
-double figureCuttingSphereModel::GetTheoricVolume() // virtual
-{
- double piTMP=3.14159265;
- return (4.0/3.0) * piTMP * (_sx/2)*(_sy/2)*(_sz/2);
-}
-//----------------------------------------------------------------------------
-char *figureCuttingSphereModel::GetName() // virtual
-{
- return "Sphere";
-}
-
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-figureCuttingCubeModel::figureCuttingCubeModel()
-{
-}
-//----------------------------------------------------------------------------
-figureCuttingCubeModel::~figureCuttingCubeModel() // virtual
-{
-}
-//----------------------------------------------------------------------------
-bool figureCuttingCubeModel::IfPointInside(double x, double y, double z) // virtual
-{
- double in[4],out[4];
- in[0]=x;
- in[1]=y;
- in[2]=z;
- in[3]=1;
- _inversModel->MultiplyPoint (in, out);
-
- bool result=false;
- if ((out[0]>-0.5) && (out[0]<0.5) && (out[1]>-0.5) && (out[1]<0.5) && (out[2]>-0.5) && (out[2]<0.5) )
- {
- result=true;
- }
- return result;
-}
-//----------------------------------------------------------------------------
-double figureCuttingCubeModel::GetTheoricVolume() // virtual
-{
- return _sx * _sy * _sz;
-}
//----------------------------------------------------------------------------
-char *figureCuttingCubeModel::GetName() // virtual
-{
- return "Cube";
-}
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-figureCuttingCylinderModel::figureCuttingCylinderModel()
-{
-}
-//----------------------------------------------------------------------------
-figureCuttingCylinderModel::~figureCuttingCylinderModel() // virtual
-{
-}
-//----------------------------------------------------------------------------
-bool figureCuttingCylinderModel::IfPointInside(double x, double y, double z) // virtual
-{
- double in[4],out[4];
- in[0]=x;
- in[1]=y;
- in[2]=z;
- in[3]=1;
- _inversModel->MultiplyPoint (in, out);
-
- bool result=false;
- if ((sqrt( out[0]*out[0] + out[2]*out[2] )<0.5 ) && (out[1]>-0.5) && (out[1]<0.5) )
- {
- result=true;
- }
- return result;
-}
//----------------------------------------------------------------------------
-double figureCuttingCylinderModel::GetTheoricVolume() // virtual
-{
- double piTMP=3.14159265;
- return piTMP*(_sx/2)*(_sz/2)*_sy;
-}
//----------------------------------------------------------------------------
-char *figureCuttingCylinderModel::GetName() // virtual
-{
- return "Cylinder";
-}
//----------------------------------------------------------------------------