From 4970ac35d6d4bc3cea54e8e6033b34c01c3103fb Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Tue, 25 Nov 2008 15:59:22 +0000 Subject: [PATCH] *** empty log message *** --- bbtk/src/bbmaracasvisuAxeVolume.cxx | 107 ++++++++ bbtk/src/bbmaracasvisuAxeVolume.h | 53 ++++ bbtk/src/bbmaracasvisuDrawAxe3D.cxx | 93 +++++++ bbtk/src/bbmaracasvisuDrawAxe3D.h | 61 +++++ bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx | 155 ++++++++++++ bbtk/src/bbmaracasvisuDrawAxisTree3D.h | 74 ++++++ bbtk/src/bbmaracasvisuShowNPoints.cxx | 238 ++++++++++++++++++ bbtk/src/bbmaracasvisuShowNPoints.h | 103 ++++++++ bbtk/src/bbmaracasvisuSliderMinMax.cxx | 3 +- .../wxWindows/Contour/ContourVOIWidget.cxx | 3 + .../wxWindows/widgets/pPlotter/mBarRange.cxx | 14 +- .../wxWindows/widgets/pPlotter/mBarRange.h | 17 +- .../wxWindows/widgets/pPlotter/mathplot.h | 2 +- .../widgets/pPlotter/pPlotterLayer.h | 2 +- lib/maracasVisuLib/src/kernel/marTypes.h | 6 +- 15 files changed, 915 insertions(+), 16 deletions(-) create mode 100644 bbtk/src/bbmaracasvisuAxeVolume.cxx create mode 100644 bbtk/src/bbmaracasvisuAxeVolume.h create mode 100644 bbtk/src/bbmaracasvisuDrawAxe3D.cxx create mode 100644 bbtk/src/bbmaracasvisuDrawAxe3D.h create mode 100644 bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx create mode 100644 bbtk/src/bbmaracasvisuDrawAxisTree3D.h create mode 100644 bbtk/src/bbmaracasvisuShowNPoints.cxx create mode 100644 bbtk/src/bbmaracasvisuShowNPoints.h diff --git a/bbtk/src/bbmaracasvisuAxeVolume.cxx b/bbtk/src/bbmaracasvisuAxeVolume.cxx new file mode 100644 index 0000000..be808e7 --- /dev/null +++ b/bbtk/src/bbmaracasvisuAxeVolume.cxx @@ -0,0 +1,107 @@ +#include "bbmaracasvisuAxeVolume.h" +#include "bbcreaMaracasVisuPackage.h" +namespace bbcreaMaracasVisu +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,AxeVolume) +BBTK_BLACK_BOX_IMPLEMENTATION(AxeVolume,bbtk::AtomicBlackBox); +void AxeVolume::Process() +{ + if ( mimage!=NULL ) + { + mimage->Delete(); + } + + int ext[6]; + bbGetInputIn()->GetExtent(ext); + int sizeX=ext[1]-ext[0]; + int sizeY=ext[3]-ext[2]; + int sizeZ=ext[5]-ext[4]; + + mimage = vtkImageData::New(); + mimage->SetDimensions(sizeX,sizeY,sizeZ); + mimage->SetOrigin(0,0,0); + mimage->SetExtent( 0 , sizeX-1 , 0 , sizeY-1 , 0, sizeZ-1 ); + mimage->SetWholeExtent( 0 , sizeX-1 , 0 , sizeY-1 , 0, sizeZ-1 ); + mimage->SetScalarTypeToUnsignedShort(); + mimage->AllocateScalars(); + + + int i,j,k; + int sizeLstPointR = bbGetInputlstPointR().size(); + int iAxe,sizeAxe=bbGetInputlstPointX().size(); + double rx,ry,rz; + double r,rr; + unsigned short *p; + int sizeImage = sizeX*sizeY*sizeZ; + double px,py,pz,px1,py1,pz1,px2,py2,pz2; + + // Clean image + p = (unsigned short*)mimage->GetScalarPointer (0, 0, 0); + for ( i=0 ; i=0) && (i=0) && (j=0) && (kGetScalarPointer (i, j, k); + *p=255; + } + } // inside point + } //for k + } //for j + } //for i + } // for iAxe + bbSetOutputOut( mimage ); +} + + + + +void AxeVolume::bbUserConstructor() +{ + mimage = NULL; +} +void AxeVolume::bbUserCopyConstructor() +{ + +} +void AxeVolume::bbUserDestructor() +{ + +} +} +// EO namespace bbcreaMaracasVisu + + diff --git a/bbtk/src/bbmaracasvisuAxeVolume.h b/bbtk/src/bbmaracasvisuAxeVolume.h new file mode 100644 index 0000000..7a573e2 --- /dev/null +++ b/bbtk/src/bbmaracasvisuAxeVolume.h @@ -0,0 +1,53 @@ +#ifndef __bbcreaMaracasVisuAxeVolume_h_INCLUDED__ +#define __bbcreaMaracasVisuAxeVolume_h_INCLUDED__ +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkImageData.h" + +namespace bbcreaMaracasVisu +{ + +class /*BBTK_EXPORT*/ AxeVolume + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(AxeVolume,bbtk::AtomicBlackBox); +//================================================================== +/// User callback called in the box contructor +virtual void bbUserConstructor(); +/// User callback called in the box copy constructor +virtual void bbUserCopyConstructor(); +/// User callback called in the box destructor +virtual void bbUserDestructor(); +//================================================================== + BBTK_DECLARE_INPUT( In , vtkImageData * ); + BBTK_DECLARE_INPUT( lstPointX , std::vector ); + BBTK_DECLARE_INPUT( lstPointY , std::vector ); + BBTK_DECLARE_INPUT( lstPointZ , std::vector ); + BBTK_DECLARE_INPUT( lstPointR , std::vector ); + BBTK_DECLARE_OUTPUT(Out,vtkImageData *); + BBTK_PROCESS(Process); + void Process(); + +private: + vtkImageData *mimage; +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(AxeVolume,bbtk::AtomicBlackBox); + BBTK_NAME("AxeVolume"); + BBTK_AUTHOR("eduardo.davila@hotmail.com"); + BBTK_DESCRIPTION("Axe Volume"); + BBTK_CATEGORY("__CATEGORY__"); + BBTK_INPUT(AxeVolume,In,"Size image X",vtkImageData*,""); + BBTK_INPUT(AxeVolume,lstPointX,"List of X values", std::vector ,""); + BBTK_INPUT(AxeVolume,lstPointY,"List of Y values", std::vector ,""); + BBTK_INPUT(AxeVolume,lstPointZ,"List of Z values", std::vector ,""); + BBTK_INPUT(AxeVolume,lstPointR,"List of Radius", std::vector ,""); + BBTK_OUTPUT(AxeVolume,Out,"Result image",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(AxeVolume); +} +// EO namespace bbcreaMaracasVisu + +#endif // __bbcreaMaracasVisuAxeVolume_h_INCLUDED__ + diff --git a/bbtk/src/bbmaracasvisuDrawAxe3D.cxx b/bbtk/src/bbmaracasvisuDrawAxe3D.cxx new file mode 100644 index 0000000..0ee6027 --- /dev/null +++ b/bbtk/src/bbmaracasvisuDrawAxe3D.cxx @@ -0,0 +1,93 @@ +#include "bbmaracasvisuDrawAxe3D.h" +#include "bbcreaMaracasVisuPackage.h" + + +#include "vtkImageData.h" +#include "vtkActor.h" +#include "vtkPolyDataMapper.h" +#include "vtkPoints.h" +#include "vtkCellArray.h" +#include "vtkProperty.h" + + +namespace bbcreaMaracasVisu +{ + + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,DrawAxe3D) +BBTK_BLACK_BOX_IMPLEMENTATION(DrawAxe3D,bbtk::AtomicBlackBox); +void DrawAxe3D::Process() +{ + + std::vector< double > vectx = bbGetInputlstPointX(); + std::vector< double > vecty = bbGetInputlstPointY(); + std::vector< double > vectz = bbGetInputlstPointZ(); + +// vtkImageData* img = bbGetInputImage(); + unsigned int i; + double spc[3]; +// img->GetSpacing(spc); + spc[0]=1; + spc[1]=1; + spc[2]=1; + + if(!vectx.empty()&&!vecty.empty()&&!vectz.empty()){ + vtkPoints* allPoints = vtkPoints::New( ); + vtkCellArray* allTopology = vtkCellArray::New( ); + allTopology->InsertNextCell( vectx.size() ); + + for( i = 0; i < vectx.size( ); i++) { + //multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom + //hay parĂ¡metro dycom, vtkImagedata valor spacing y esos datos hay que multiplicar al polydata + allPoints->InsertNextPoint( vectx[i]*spc[0], vecty[i]*spc[1], vectz[i]*spc[2] ); + allTopology->InsertCellPoint( i ); + } // rof + mallData->SetPoints( allPoints ); + mallData->SetLines( allTopology ); + allPoints->Delete(); + allTopology->Delete(); + } + + mvtkactor->GetProperty()->SetColor( bbGetInputColour()[0], + bbGetInputColour()[1], + bbGetInputColour()[2] ); + + + // Interface Update + if ((firsttime==true) && (bbGetInputRenderer()!=NULL )) + { + firsttime=false; + bbGetInputRenderer()->AddActor( mvtkactor ); + } + +} + +void DrawAxe3D::bbUserConstructor() +{ + firsttime = true; + mallData = vtkPolyData::New( ); + vtkPolyDataMapper* polydatamapper = vtkPolyDataMapper::New(); + mvtkactor = vtkActor::New(); + polydatamapper->SetInput(mallData); + mvtkactor->SetMapper(polydatamapper); + bbSetOutputOut(mvtkactor); + + std::vector colour; + colour.push_back(1.0); + colour.push_back(0.0); + colour.push_back(0.0); + bbSetInputColour(colour); +} + +void DrawAxe3D::bbUserCopyConstructor() +{ +} +void DrawAxe3D::bbUserDestructor() +{ +} + +} + +// EO namespace bbcreaMaracasVisu + + diff --git a/bbtk/src/bbmaracasvisuDrawAxe3D.h b/bbtk/src/bbmaracasvisuDrawAxe3D.h new file mode 100644 index 0000000..01998b4 --- /dev/null +++ b/bbtk/src/bbmaracasvisuDrawAxe3D.h @@ -0,0 +1,61 @@ +#ifndef __bbcreaMaracasVisuDrawAxe3D_h_INCLUDED__ +#define __bbcreaMaracasVisuDrawAxe3D_h_INCLUDED__ +#include "bbtkAtomicBlackBox.h" +#include "iostream" + + +#include "vtkRenderer.h" +#include "vtkPolyData.h" + + +namespace bbcreaMaracasVisu +{ + +class /*BBTK_EXPORT*/ DrawAxe3D + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(DrawAxe3D,bbtk::AtomicBlackBox); +//================================================================== +/// User callback called in the box contructor +virtual void bbUserConstructor(); +/// User callback called in the box copy constructor +virtual void bbUserCopyConstructor(); +/// User callback called in the box destructor +virtual void bbUserDestructor(); +//================================================================== + BBTK_DECLARE_INPUT(Renderer,vtkRenderer*); + BBTK_DECLARE_INPUT(lstPointX,std::vector); + BBTK_DECLARE_INPUT(lstPointY,std::vector); + BBTK_DECLARE_INPUT(lstPointZ,std::vector); + BBTK_DECLARE_INPUT(Colour,std::vector); + BBTK_DECLARE_OUTPUT(Out,vtkProp3D *); + +// BBTK_DECLARE_OUTPUT(Out,double); + BBTK_PROCESS(Process); + void Process(); + + private: + bool firsttime; + vtkPolyData *mallData; + vtkActor *mvtkactor; +}; + + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(DrawAxe3D,bbtk::AtomicBlackBox); +BBTK_NAME("DrawAxe3D"); +BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr"); +BBTK_DESCRIPTION("Draw a 3D axe in a vtk 3D Viewer"); +BBTK_CATEGORY("__CATEGORY__"); + BBTK_INPUT(DrawAxe3D,Renderer,"vtk Renderer 3D universe",vtkRenderer*,""); + BBTK_INPUT(DrawAxe3D,lstPointX,"list of point X",std::vector,""); + BBTK_INPUT(DrawAxe3D,lstPointY,"list of point Y",std::vector,""); + BBTK_INPUT(DrawAxe3D,lstPointZ,"list of point Z",std::vector,""); + BBTK_INPUT(DrawAxe3D,Colour,"Color of the line R(0..1) G(0..1) B(0..1) ",std::vector,"colour"); + BBTK_OUTPUT(DrawAxe3D,Out,"Actor",vtkProp3D*,""); +BBTK_END_DESCRIBE_BLACK_BOX(DrawAxe3D); +} +// EO namespace bbcreaMaracasVisu + +#endif // __bbcreaMaracasVisuDrawAxe3D_h_INCLUDED__ + diff --git a/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx b/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx new file mode 100644 index 0000000..4c80882 --- /dev/null +++ b/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx @@ -0,0 +1,155 @@ +#include "bbmaracasvisuDrawAxisTree3D.h" +#include "bbcreaMaracasVisuPackage.h" +namespace bbcreaMaracasVisu +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,DrawAxisTree3D) +BBTK_BLACK_BOX_IMPLEMENTATION(DrawAxisTree3D,bbtk::AtomicBlackBox); + + + +void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) +{ + vtkPolyData *polydata = vtkPolyData::New( ); + vtkPolyDataMapper *polydatamapper = vtkPolyDataMapper::New(); + vtkActor *vtkactor = vtkActor::New(); + + polydatamapper->SetInput(polydata); + vtkactor->SetMapper(polydatamapper); + + vecVtkPolyData.push_back( polydata ); + vecVtkPolyDataMaper.push_back( polydatamapper ); + vecVtkActors.push_back( vtkactor ); + +// vtkImageData* img = bbGetInputImage(); + unsigned int i,size; + double spc[3]; +// img->GetSpacing(spc); + spc[0]=1; + spc[1]=1; + spc[2]=1; + + if(!bbGetInputlstPointX().empty()){ + vtkPoints* allPoints = vtkPoints::New( ); + vtkCellArray* allTopology = vtkCellArray::New( ); + allTopology->InsertNextCell( numPoints ); + + size=iGeneral+numPoints; + for (i=iGeneral;iInsertNextPoint( bbGetInputlstPointX()[i]*spc[0], + bbGetInputlstPointY()[i]*spc[1], + bbGetInputlstPointZ()[i]*spc[2] ); + allTopology->InsertCellPoint( i-iGeneral ); + } // rof + polydata->SetPoints( allPoints ); + polydata->SetLines( allTopology ); + allPoints->Delete(); + allTopology->Delete(); + } + + // color + double r,g,b; + + if ( (iAxis*3+1) < bbGetInputColour().size() ){ + r = bbGetInputColour()[0+iAxis*3]; + g = bbGetInputColour()[1+iAxis*3]; + b = bbGetInputColour()[2+iAxis*3]; + } else { + r = bbGetInputColour()[0]; + g = bbGetInputColour()[1]; + b = bbGetInputColour()[2]; + } + + vtkactor->GetProperty()->SetColor( 1,0,0 ); + vtkactor->GetProperty()->SetLineWidth( 3 ); + + // Interface Update + if (bbGetInputRenderer()!=NULL ) + { + bbGetInputRenderer()->AddActor( vtkactor ); + } +} + + +void DrawAxisTree3D::Process() +{ + int iActor,sizeActors = vecVtkActors.size(); + for (iActor=0 ; iActorRemoveActor( vecVtkActors[iActor] ); + vecVtkPolyData[iActor]->Delete(); + vecVtkPolyDataMaper[iActor]->Delete(); + vecVtkActors[iActor]->Delete(); + } + } + vecVtkPolyData.clear(); + vecVtkPolyDataMaper.clear(); + vecVtkActors.clear(); + + + int iGeneral=0; + int iAxis,sizeLstAxis=bbGetInputlstIndexs().size(); + int numPoints; + for ( iAxis=0 ; iAxis colour; + // 1- red + colour.push_back(1.0); + colour.push_back(0.0); + colour.push_back(0.0); + // 2- blue + colour.push_back(0.0); + colour.push_back(0.0); + colour.push_back(1.0); + // 3- yellow + colour.push_back(1.0); + colour.push_back(1.0); + colour.push_back(0.0); + // 4- green + colour.push_back(0.0); + colour.push_back(1.0); + colour.push_back(0.0); + // 5- + colour.push_back(0.0); + colour.push_back(1.0); + colour.push_back(1.0); + + // 6- + colour.push_back(0.5); + colour.push_back(0.5); + colour.push_back(0.5); + + bbSetInputColour(colour); + +} + +void DrawAxisTree3D::bbUserCopyConstructor() +{ +} + +void DrawAxisTree3D::bbUserDestructor() +{ +} + +} +// EO namespace bbcreaMaracasVisu + + diff --git a/bbtk/src/bbmaracasvisuDrawAxisTree3D.h b/bbtk/src/bbmaracasvisuDrawAxisTree3D.h new file mode 100644 index 0000000..65080c1 --- /dev/null +++ b/bbtk/src/bbmaracasvisuDrawAxisTree3D.h @@ -0,0 +1,74 @@ +#ifndef __bbcreaMaracasVisuDrawAxisTree3D_h_INCLUDED__ +#define __bbcreaMaracasVisuDrawAxisTree3D_h_INCLUDED__ +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include +#include +#include "vtkImageData.h" +#include "vtkActor.h" +#include "vtkPolyData.h" +#include "vtkPolyDataMapper.h" +#include "vtkPoints.h" +#include "vtkCellArray.h" +#include "vtkProperty.h" + + + +namespace bbcreaMaracasVisu +{ + +class /*BBTK_EXPORT*/ DrawAxisTree3D + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(DrawAxisTree3D,bbtk::AtomicBlackBox); +//================================================================== +/// User callback called in the box contructor +virtual void bbUserConstructor(); +/// User callback called in the box copy constructor +virtual void bbUserCopyConstructor(); +/// User callback called in the box destructor +virtual void bbUserDestructor(); +//================================================================== + BBTK_DECLARE_INPUT(Renderer ,vtkRenderer*); + BBTK_DECLARE_INPUT(lstIndexs,std::vector); + BBTK_DECLARE_INPUT(lstPointX,std::vector); + BBTK_DECLARE_INPUT(lstPointY,std::vector); + BBTK_DECLARE_INPUT(lstPointZ,std::vector); + BBTK_DECLARE_INPUT(lstRadio ,std::vector); + BBTK_DECLARE_INPUT(Colour ,std::vector); + BBTK_DECLARE_INPUT(iAxis, int ); + BBTK_DECLARE_OUTPUT(OutAxis,vtkProp3D *); + BBTK_PROCESS(Process); + void Process(); + +private: + + std::vector vecVtkPolyData; + std::vector vecVtkPolyDataMaper; + std::vector vecVtkActors; + + void DrawOneAxis(int iGeneral,int numPoints, int iAxis); +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(DrawAxisTree3D,bbtk::AtomicBlackBox); +BBTK_NAME("DrawAxisTree3D"); +BBTK_AUTHOR("InfoTeam CREATIS-LRMN"); +BBTK_DESCRIPTION("Draw Axis Tree 3D"); +BBTK_CATEGORY("__CATEGORY__"); +BBTK_INPUT(DrawAxisTree3D,Renderer,"Renderer",vtkRenderer*,""); +BBTK_INPUT(DrawAxisTree3D,lstIndexs,"Indexs",std::vector,""); +BBTK_INPUT(DrawAxisTree3D,lstPointX,"lstPointX",std::vector,""); +BBTK_INPUT(DrawAxisTree3D,lstPointY,"lstPointY",std::vector,""); +BBTK_INPUT(DrawAxisTree3D,lstPointZ,"lstPointZ",std::vector,""); +BBTK_INPUT(DrawAxisTree3D,lstRadio,"lstRadio",std::vector,""); +BBTK_INPUT(DrawAxisTree3D,Colour,"Colour",std::vector,""); +BBTK_INPUT(DrawAxisTree3D,iAxis,"iAxis",int,""); +BBTK_OUTPUT(DrawAxisTree3D,OutAxis,"Axis[iAxis]",vtkProp3D *,""); +BBTK_END_DESCRIBE_BLACK_BOX(DrawAxisTree3D); +} +// EO namespace bbcreaMaracasVisu + +#endif // __bbcreaMaracasVisuDrawAxisTree3D_h_INCLUDED__ + diff --git a/bbtk/src/bbmaracasvisuShowNPoints.cxx b/bbtk/src/bbmaracasvisuShowNPoints.cxx new file mode 100644 index 0000000..7b47d87 --- /dev/null +++ b/bbtk/src/bbmaracasvisuShowNPoints.cxx @@ -0,0 +1,238 @@ +#include "bbmaracasvisuShowNPoints.h" +#include "bbcreaMaracasVisuPackage.h" + +#include "vtkProperty.h" +#include "vtkSphereSource.h" +#include "vtkPolyDataMapper.h" +#include "vtkRenderWindow.h" + +namespace bbcreaMaracasVisu +{ + + +//---------------------------------------------------------------------- + WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, vtkRenderer *renderer, ShowNPoints *box) + : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL) + { + mbbShowNPoints = box; + this->renderer = renderer; + wxPanel *panel = this; + wxSizer *sizer = NULL; + + + // Widget interface + wxButton *btnAddPoint = new wxButton( panel, -1, _T("Add Point")); + wxButton *btnEraseLstPoint = new wxButton( panel, -1, _T("Erase Last point")); + wxButton *btnDeleteAllPoints= new wxButton( panel, -1, _T("Delete all points")); + + + wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1); +// sizer1->Add(new wxStaticText(panel,-1,_T(" "))); + + Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint); + Connect(btnEraseLstPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint); + Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints); + + sizer1->Add(btnAddPoint); + sizer1->Add(btnEraseLstPoint); + sizer1->Add(btnDeleteAllPoints); + + sizer = sizer1; + panel -> SetSizer(sizer); + panel -> SetAutoLayout(true); + panel -> Layout(); + +} + + +//------------------------------------------------------------------------ +WidgetShowNPoints::~WidgetShowNPoints() +{ +} + +void WidgetShowNPoints::SetRadio(double radio) +{ + mradio=radio; +} + +//------------------------------------------------------------------------ +std::vector WidgetShowNPoints::GetLstPointsX() +{ + return lstPointsX; +} + +//------------------------------------------------------------------------ +std::vector WidgetShowNPoints::GetLstPointsY() +{ + return lstPointsY; +} + +//------------------------------------------------------------------------ +std::vector WidgetShowNPoints::GetLstPointsZ() +{ + return lstPointsZ; +} + + + + +//------------------------------------------------------------------------ +void WidgetShowNPoints::SetPoint(std::vector ppoint) +{ + mpoint = ppoint; +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::SetColour(std::vector colour) +{ + this->mcolour = colour; +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::SetOpacity(double opacity) +{ + this->mopacity=opacity; +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::SetImage(vtkImageData *image) +{ + this->mimage=image; +} + + + +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event) +{ +// printf("EED %p WidgetShowNPoints::OnAddPoint %d,%d,%d \n", this,mpoint[0],mpoint[1],mpoint[2] ); + + if (mpoint.size()==3){ + lstPointsX.push_back( mpoint[0] ); + lstPointsY.push_back( mpoint[1] ); + lstPointsZ.push_back( mpoint[2] ); + + // Sphere + vtkSphereSource *vtksphere = vtkSphereSource::New(); + vtksphere->SetThetaResolution (20); + vtksphere->SetPhiResolution (20); + vtksphere->SetRadius( mradio ); + vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New(); + sphereMapper->SetInput( vtksphere->GetOutput() ); + vtkActor *sphereActor = vtkActor::New(); + sphereActor->SetMapper(sphereMapper); + sphereActor->SetOrigin(0, 0, 0); + double spc[3]; + mimage->GetSpacing(spc); + sphereActor->SetPosition( spc[0]*mpoint[0] , spc[1]*mpoint[1] , spc[2]*mpoint[2] ); + sphereActor->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] ); + sphereActor->GetProperty()->SetOpacity( mopacity ); + + lstActors.push_back(sphereActor); + renderer->AddActor( sphereActor ); + + renderer->GetRenderWindow()->Render(); + + //--BBTK + mbbShowNPoints->bbSetModifiedStatus(); + mbbShowNPoints->bbSignalOutputModification("Point"); + + } +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event) +{ + int id = lstActors.size()-1; + if (id>=0){ + renderer->RemoveActor( lstActors[id] ); + lstActors.erase( lstActors.begin()+id ); + lstPointsX.erase( lstPointsX.begin()+id ); + lstPointsY.erase( lstPointsY.begin()+id ); + lstPointsZ.erase( lstPointsZ.begin()+id ); + renderer->GetRenderWindow()->Render(); + //--BBTK + mbbShowNPoints->bbSetModifiedStatus(); + mbbShowNPoints->bbSignalOutputModification("Point"); + } + +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event) +{ + int i,size=lstActors.size(); + for (i=0;iRemoveActor( lstActors[i] ); + } + lstActors.clear(); + lstPointsX.clear(); + lstPointsY.clear(); + lstPointsZ.clear(); + renderer->GetRenderWindow()->Render(); + //--BBTK + mbbShowNPoints->bbSetModifiedStatus(); + mbbShowNPoints->bbSignalOutputModification("Point"); +} + + + + + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints) +BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints,bbtk::WxBlackBox); + +void ShowNPoints::Process() +{ + mwxwidget->SetPoint( bbGetInputIn() ); + mwxwidget->SetImage( bbGetInputImage() ); + mwxwidget->SetColour( bbGetInputColour() ); + mwxwidget->SetOpacity( bbGetInputOpacity() ); + mwxwidget->SetRadio( bbGetInputRadio() ); + + bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() ); + bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() ); + bbSetOutputlstPointsZ( mwxwidget->GetLstPointsZ() ); +} + + +void ShowNPoints::CreateWidget() +{ + mwxwidget = new WidgetShowNPoints( bbGetWxParent() , bbGetInputRenderer(), this); + mwxwidget->SetPoint( bbGetInputIn() ); + + if (bbGetInputImage()==NULL) + { + printf("Missing Image (ShowNPoints) \n"); + } + + bbSetOutputWidget( mwxwidget ); + Process(); +} + +void ShowNPoints::bbUserConstructor() +{ + std::vector colour; + colour.push_back(1.0); + colour.push_back(0.0); + colour.push_back(0.0); + bbSetInputColour(colour); + bbSetInputOpacity(1); + bbSetInputImage(NULL); + bbSetInputRadio(0.5); +} + + +void ShowNPoints::bbUserCopyConstructor() +{ +} + +void ShowNPoints::bbUserDestructor() +{ +} + +} +// EO namespace bbcreaMaracasVisu + + diff --git a/bbtk/src/bbmaracasvisuShowNPoints.h b/bbtk/src/bbmaracasvisuShowNPoints.h new file mode 100644 index 0000000..814466f --- /dev/null +++ b/bbtk/src/bbmaracasvisuShowNPoints.h @@ -0,0 +1,103 @@ +#ifdef _USE_WXWIDGETS_ +#ifndef __bbcreaMaracasVisuShowNPoints_h_INCLUDED__ +#define __bbcreaMaracasVisuShowNPoints_h_INCLUDED__ +#include "bbtkWxBlackBox.h" + + +#include "vtkActor.h" +#include "vtkImageData.h" +#include "vtkRenderer.h" + +namespace bbcreaMaracasVisu +{ + + class ShowNPoints; + + //-------------------------------------------------------------------------- + class WidgetShowNPoints : public wxPanel + { + public: + WidgetShowNPoints( wxWindow *parent, vtkRenderer *renderer, ShowNPoints *box); + ~WidgetShowNPoints(); + void OnAddPoint(wxCommandEvent &event); + void OnErasePoint(wxCommandEvent &event); + void OnDeleteAllPoints(wxCommandEvent &event); + void SetPoint(std::vector ppoint); + void SetColour(std::vector colour); + void SetOpacity(double opacity); + void SetRadio(double radio); + void SetImage(vtkImageData *image); + std::vector GetLstPointsX(); + std::vector GetLstPointsY(); + std::vector GetLstPointsZ(); + + private: + ShowNPoints *mbbShowNPoints; + vtkRenderer *renderer; + std::vector lstPointsX; + std::vector lstPointsY; + std::vector lstPointsZ; + std::vector lstActors; + + std::vector mpoint; + vtkImageData *mimage; + std::vector mcolour; + double mopacity; + double mradio; + }; + + + +class /*BBTK_EXPORT*/ ShowNPoints + : + public bbtk::WxBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ShowNPoints,bbtk::WxBlackBox); +//================================================================== +/// User callback called in the box contructor +virtual void bbUserConstructor(); +/// User callback called in the box copy constructor +virtual void bbUserCopyConstructor(); +/// User callback called in the box destructor +virtual void bbUserDestructor(); +//================================================================== + BBTK_DECLARE_INPUT(In, std::vector ); + BBTK_DECLARE_INPUT(Renderer, vtkRenderer* ); + BBTK_DECLARE_INPUT(Image, vtkImageData* ); + BBTK_DECLARE_INPUT(Colour, std::vector ); + BBTK_DECLARE_INPUT(Opacity, double ); + BBTK_DECLARE_INPUT(Radio, double ); + BBTK_DECLARE_OUTPUT( lstPointsX, std::vector ); + BBTK_DECLARE_OUTPUT( lstPointsY, std::vector ); + BBTK_DECLARE_OUTPUT( lstPointsZ, std::vector ); + BBTK_PROCESS(Process); + void Process(); + BBTK_CREATE_WIDGET(CreateWidget); + void CreateWidget(); + +private: + WidgetShowNPoints *mwxwidget; + +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints,bbtk::WxBlackBox); +BBTK_NAME("ShowNPoints"); +BBTK_AUTHOR("Eduardo DAVILA"); +BBTK_DESCRIPTION("widget that shows N moints in 3D (vtkActors)"); +BBTK_CATEGORY("widgetVtk"); +BBTK_INPUT(ShowNPoints,In,"One Point",std::vector,""); +BBTK_INPUT(ShowNPoints,Renderer,"Renderer",vtkRenderer*,""); +BBTK_INPUT(ShowNPoints,Image,"vktkImageData",vtkImageData*,""); +BBTK_INPUT(ShowNPoints,Colour,"Colour of the actor",std::vector,"colour"); +BBTK_INPUT(ShowNPoints,Opacity,"Opacity of the actor",double,""); +BBTK_INPUT(ShowNPoints,Radio,"Radio of the spheres",double,""); +BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector ,""); +BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector ,""); +BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector ,""); +BBTK_END_DESCRIBE_BLACK_BOX(ShowNPoints); +} +// EO namespace bbcreaMaracasVisu + +#endif // __bbcreaMaracasVisuShowNPoints_h_INCLUDED__ +#endif // _USE_WXWIDGETS_ + diff --git a/bbtk/src/bbmaracasvisuSliderMinMax.cxx b/bbtk/src/bbmaracasvisuSliderMinMax.cxx index 54d0096..a8020e4 100644 --- a/bbtk/src/bbmaracasvisuSliderMinMax.cxx +++ b/bbtk/src/bbmaracasvisuSliderMinMax.cxx @@ -19,8 +19,9 @@ namespace bbcreaMaracasVisu mbbtkSliderMinMax = bbParent; modBarRange->PushEventHandler(this); Connect(modBarRange->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxWidgetSliderMinMax::onBarrange ); +// Connect(modBarRange->GetId(),98765,(wxObjectEventFunction) (wxCommandEventFunction) &wxWidgetSliderMinMax::onActualChange_Bar ); Connect(modBarRange->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxWidgetSliderMinMax::onActualChange_Bar ); - Connect(modBarRange->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxWidgetSliderMinMax::onStartChange_Bar ); + Connect(modBarRange->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxWidgetSliderMinMax::onStartChange_Bar ); Connect(modBarRange->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxWidgetSliderMinMax::onEndChange_Bar ); Connect(modBarRange->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxWidgetSliderMinMax::onSelectionEnd ); Connect(modBarRange->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxWidgetSliderMinMax::onMovedBar ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourVOIWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourVOIWidget.cxx index 0e78c68..854ab1d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourVOIWidget.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourVOIWidget.cxx @@ -40,12 +40,14 @@ } void wxWidgetSliderMinMaxVOI :: onActualChange_Bar(wxCommandEvent& event) { +std::cout << "wxWidgetSliderMinMaxVOI ::onActualChange_Bar" << std::endl; wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)mcontourtool->GetWxVtkBaseView(); wxvtk2dbaseview->GetVtkBaseData()->SetZ(modBarRange->GetActual()); wxvtk2dbaseview->Refresh(); } void wxWidgetSliderMinMaxVOI :: onStartChange_Bar(wxCommandEvent& event) { +std::cout << "wxWidgetSliderMinMaxVOI ::onStartChange_Bar" << std::endl; wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)mcontourtool->GetWxVtkBaseView(); wxvtk2dbaseview->GetVtkBaseData()->SetZ(modBarRange->GetStart()); wxvtk2dbaseview->Refresh(); @@ -53,6 +55,7 @@ } void wxWidgetSliderMinMaxVOI :: onEndChange_Bar(wxCommandEvent& event) { +std::cout << "wxWidgetSliderMinMaxVOI ::onEndChange_Bar" << std::endl; wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)mcontourtool->GetWxVtkBaseView(); wxvtk2dbaseview->GetVtkBaseData()->SetZ(modBarRange->GetEnd()); wxvtk2dbaseview->Refresh(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.cxx index 325eade..1c36af9 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.cxx @@ -2,6 +2,8 @@ #include "mBarRange.h" +//const wxEventType wxEVT_TSBAR = wxNewEventType(); + DEFINE_EVENT_TYPE(wxEVT_TSBAR) DEFINE_EVENT_TYPE(wxEVT_TSBAR_ACTUAL) DEFINE_EVENT_TYPE(wxEVT_TSBAR_START) @@ -9,6 +11,8 @@ DEFINE_EVENT_TYPE(wxEVT_TSBAR_END) DEFINE_EVENT_TYPE(wxEVT_TSBAR_MOVED) DEFINE_EVENT_TYPE(wxEVT_SELECTION_END) + + //---------------------------------------------------------------------------- //EVENT TABLE //---------------------------------------------------------------------------- @@ -880,7 +884,7 @@ void mBarRange::OnMouseMove(wxMouseEvent& event ) //------------------------------------------- // Sending the event of start triangle moved //------------------------------------------- - createAndSendEvent( wxEVT_TSBAR_START ); + createAndSendEvent( wxEVT_TSBAR_START ); } //start has to be less than actual else if (validPos_StartTri && _in_rangeProperty) @@ -893,7 +897,7 @@ void mBarRange::OnMouseMove(wxMouseEvent& event ) //------------------------------------------- // Sending the event of start triangle moved //------------------------------------------- - createAndSendEvent( wxEVT_TSBAR_START ); + createAndSendEvent( wxEVT_TSBAR_START ); } } } // _selectionMoveId == 1 @@ -940,7 +944,9 @@ void mBarRange::OnMouseMove(wxMouseEvent& event ) //Sending the event of actual triangle moved //------------------------------------------- createAndSendEvent( wxEVT_TSBAR_ACTUAL ); -printf("EED mBarRange::OnMouseMove \n"); +// createAndSendEvent( 98765 ); +printf("EED mBarRange::OnMouseMove XXXXXXX \n"); + } else if( validPos_ActualTri && _in_rangeProperty ) // the tringle in between start and end @@ -1351,7 +1357,7 @@ void mBarRange :: setVisibleLabels ( bool setVisibleLB ) return withActualDrawed; } - void mBarRange :: createAndSendEvent(WXTYPE theEventType) + void mBarRange::createAndSendEvent(WXTYPE theEventType) { wxCommandEvent cevent( theEventType, GetId() ); cevent.SetEventObject( this ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.h index 4acc744..f1d95b7 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.h @@ -27,16 +27,21 @@ //DECLARING THE NEW EVENT //wxEVT_TSBAR= event of the two side bar //---------------------------------------------------------------------------- + BEGIN_DECLARE_EVENT_TYPES() - DECLARE_EVENT_TYPE(wxEVT_TSBAR, -1) - DECLARE_EVENT_TYPE(wxEVT_TSBAR_ACTUAL, -1) - DECLARE_EVENT_TYPE(wxEVT_TSBAR_START, -1) - DECLARE_EVENT_TYPE(wxEVT_TSBAR_END, -1) - DECLARE_EVENT_TYPE(wxEVT_TSBAR_MOVED, -1) - DECLARE_EVENT_TYPE(wxEVT_SELECTION_END, -1) + DECLARE_EVENT_TYPE(wxEVT_TSBAR,-1) +//DECLARE_EVENT_TYPE(wxEVT_TSBAR_ACTUAL,-1) +//DECLARE_EXPORTED_EVENT_TYPE(MARACASVISULIB_EXPORTS,wxEVT_TSBAR_ACTUAL,-1) +extern MARACASVISULIB_EXPORTS const wxEventType wxEVT_TSBAR_ACTUAL; + DECLARE_EVENT_TYPE(wxEVT_TSBAR_START,-1) + DECLARE_EVENT_TYPE(wxEVT_TSBAR_END,-1) + DECLARE_EVENT_TYPE(wxEVT_TSBAR_MOVED,-1) + DECLARE_EVENT_TYPE(wxEVT_SELECTION_END,-1) END_DECLARE_EVENT_TYPES() + + //------------------------------------------------------------------------------------------------------------- // Enum declarations //------------------------------------------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.h index 1371715..749be40 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.h @@ -95,7 +95,7 @@ Examples for mpLayer implementations are function graphs, or scale rulers. For convenience mpLayer defines a name, a font (wxFont), and a pen (wxPen) as class members. These may or may not be used by implementations. */ -class mpLayer : public wxObject +class MARACASVISULIB_EXPORTS mpLayer : public wxObject { public: mpLayer(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h index f43b0fc..521fc10 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h @@ -30,7 +30,7 @@ //---------------------------------------------------------------------------- // Class definition //---------------------------------------------------------------------------- -class pPlotterLayer: public mpLayer +class MARACASVISULIB_EXPORTS pPlotterLayer: public mpLayer { public: diff --git a/lib/maracasVisuLib/src/kernel/marTypes.h b/lib/maracasVisuLib/src/kernel/marTypes.h index 887b2d7..60a06f9 100644 --- a/lib/maracasVisuLib/src/kernel/marTypes.h +++ b/lib/maracasVisuLib/src/kernel/marTypes.h @@ -3,8 +3,8 @@ Program: wxMaracas Module: $RCSfile: marTypes.h,v $ Language: C++ - Date: $Date: 2008/11/24 10:47:12 $ - Version: $Revision: 1.4 $ + Date: $Date: 2008/11/25 15:59:44 $ + Version: $Revision: 1.5 $ Copyright: (c) 2002, 2003 License: @@ -38,7 +38,7 @@ #ifdef creaMaracasVisu_BUILD_SHARED #define MARACASVISULIB_EXPORTS __declspec( dllexport ) #else - #define MARACASVISULIB_EXPORTS //__declspec( dllimport ) + #define MARACASVISULIB_EXPORTS __declspec( dllimport ) #endif //maracasvisulib_EXPORTS #else #define MARACASVISULIB_EXPORTS -- 2.47.1