From cc00f80af2e160ce2af3ddd2903c4a41c023cc94 Mon Sep 17 00:00:00 2001 From: Juan Prieto Date: Wed, 8 Jul 2009 14:22:08 +0000 Subject: [PATCH] *** empty log message *** --- bbtk/src/bbcreaMaracasVisuIRMViewer.cxx | 2 - bbtk/src/bbcreaMaracasVisuVolumeRendering.cxx | 89 ++++---- bbtk/src/bbcreaMaracasVisuVolumeRendering.h | 66 +++--- .../src/bbmaracasvisuTransferFunctionView.cxx | 59 +++++- bbtk/src/bbmaracasvisuTransferFunctionView.h | 23 +++ .../widgets/pPlotter/HistogramWidget.cxx | 17 ++ .../widgets/pPlotter/HistogramWidget.h | 13 ++ .../wxWindows/widgets/pPlotter/mathplot.cxx | 14 +- .../wxWindows/widgets/pPlotter/mathplot.h | 17 +- .../wxWindows/widgets/pPlotter/pColorBar.cxx | 2 +- .../widgets/pPlotter/pGraphicalFunction.cxx | 3 +- .../wxWindows/widgets/pPlotter/pHistogram.cxx | 6 +- .../wxWindows/widgets/pPlotter/pPlotter.cxx | 50 +++++ .../wxWindows/widgets/pPlotter/pPlotter.h | 15 ++ .../widgets/pPlotter/pPlotterLayer.cxx | 91 ++++---- .../widgets/pPlotter/pPlotterLayer.h | 10 +- .../widgets/pPlotter/pPlotterScaleX.cxx | 22 +- .../widgets/pPlotter/pPlotterScaleY.cxx | 20 +- ...wxMaracasMultipleVolumeRendererManager.cxx | 155 ++++++++++++++ .../wxMaracasMultipleVolumeRendererManager.h | 97 +++++++++ ...racasMultipleVolumeRendererManagerData.cxx | 116 +++++++++++ ...MaracasMultipleVolumeRendererManagerData.h | 92 +++++++++ .../wxMaracasMultipleVolumeRendererPanel.cxx | 124 +++++++++++ .../wxMaracasMultipleVolumeRendererPanel.h | 33 +++ .../wxMaracasMultipleVolumeRendererView.cxx | 195 ++++++++++++++++++ .../wxMaracasMultipleVolumeRendererView.h | 106 ++++++++++ 26 files changed, 1290 insertions(+), 147 deletions(-) create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.cxx create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.h create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.cxx create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.h create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.cxx create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.h create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.cxx create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.h diff --git a/bbtk/src/bbcreaMaracasVisuIRMViewer.cxx b/bbtk/src/bbcreaMaracasVisuIRMViewer.cxx index c09a515..2feba98 100644 --- a/bbtk/src/bbcreaMaracasVisuIRMViewer.cxx +++ b/bbtk/src/bbcreaMaracasVisuIRMViewer.cxx @@ -16,8 +16,6 @@ void IRMViewer::Process() std::vector tempvect; int i; - - if(irmview != NULL){ vtkRenderer* renderer = bbGetInputRenderer(); irmview->setRenderer(renderer); diff --git a/bbtk/src/bbcreaMaracasVisuVolumeRendering.cxx b/bbtk/src/bbcreaMaracasVisuVolumeRendering.cxx index 5cfc7e9..80326a2 100644 --- a/bbtk/src/bbcreaMaracasVisuVolumeRendering.cxx +++ b/bbtk/src/bbcreaMaracasVisuVolumeRendering.cxx @@ -1,10 +1,13 @@ #include "bbcreaMaracasVisuVolumeRendering.h" #include "bbcreaMaracasVisuPackage.h" + +#include "wxMaracasMultipleVolumeRendererView.h" + namespace bbcreaMaracasVisu { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,VolumeRendering) -BBTK_BLACK_BOX_IMPLEMENTATION(VolumeRendering,bbtk::AtomicBlackBox); +BBTK_BLACK_BOX_IMPLEMENTATION(VolumeRendering,bbtk::WxBlackBox); void VolumeRendering::Process() { @@ -19,64 +22,56 @@ void VolumeRendering::Process() // (the one provided in the attribute 'name' of the tag 'input') // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') - - - vtkImageData* _img = bbGetInputIn(); - - if(_img!=NULL){ - double range[2]; - _img->GetScalarRange(range); - double max = range[1]; - _tfun->AddPoint(max * 0/2 , 0.0); - _tfun->AddPoint(max * 1/2 , 1.0); - _tfun->AddPoint(max * 2/2 , 1.0); - _ctfun->AddRGBPoint( max*0/4 , 0.0, 0.0, 0.0); - _ctfun->AddRGBPoint( max*1/4 , 1.0, 0.0, 0.0); - _ctfun->AddRGBPoint( max*2/4 , 0.0, 0.0, 1.0); - _ctfun->AddRGBPoint( max*3/4 , 0.0, 1.0, 0.0); - _ctfun->AddRGBPoint( max*4/4 , 0.0, 0.2, 0.0); + wxMaracasMultipleVolumeRendererView* volview = (wxMaracasMultipleVolumeRendererView*)bbGetOutputWidget(); + vtkImageData* _img1 = bbGetInputIn1(); + vtkImageData* _img2 = bbGetInputIn2(); + vtkImageData* _img3 = bbGetInputIn3(); + vtkImageData* _img4 = bbGetInputIn4(); + vtkRenderer* renderer = bbGetInputRenderer(); - _volumeMapper->SetInput( _img ); - - _volumeMapper->Update(); - _newvol->Update(); + if(volview!=NULL){ + if(renderer!=NULL&&_currentrenderer != renderer){ + volview->setRenderer(renderer); + _currentrenderer = renderer; + } + if(_currentrenderer!=NULL){ + if(_img1 !=NULL){ + volview->addVolume(_img1, "INPUT 1"); + } + if(_img2 !=NULL){ + volview->addVolume(_img2, "INPUT 2"); + } + if(_img3 !=NULL){ + volview->addVolume(_img3, "INPUT 3"); + } + if(_img4 !=NULL){ + volview->addVolume(_img4, "INPUT 4"); + } + } + } +} +void VolumeRendering::CreateWidget(wxWindow* parent) +{ - bbSetOutputOut(_newvol); - } - + wxMaracasMultipleVolumeRendererView* volview = wxMaracasMultipleVolumeRendererView::getInstance(parent); + bbSetOutputWidget(volview); - } void VolumeRendering::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 - bbSetInputIn(0); - bbSetOutputOut(0); + bbSetInputIn1(0); + bbSetInputIn2(0); + bbSetInputIn3(0); + bbSetInputIn4(0); + bbSetInputRenderer(0); } void VolumeRendering::bbUserInitializeProcessing() -{ - _tfun = vtkPiecewiseFunction::New(); - _ctfun = vtkColorTransferFunction::New(); - - _volumePlanes = vtkPlanes::New(); - _compositeFunction = vtkVolumeRayCastCompositeFunction::New(); - _volumeMapper = vtkVolumeRayCastMapper::New(); - _volumeMapper->SetVolumeRayCastFunction(_compositeFunction); - _volumeMapper->SetClippingPlanes( _volumePlanes ); - _volumeMapper->AutoAdjustSampleDistancesOn(); - _volumeProperty = vtkVolumeProperty::New(); - _volumeProperty->SetInterpolationTypeToLinear(); - _volumeProperty->ShadeOn(); - _volumeProperty->DisableGradientOpacityOn(); - _volumeProperty->SetColor(_ctfun); - _volumeProperty->SetScalarOpacity( _tfun ); - _newvol = vtkVolume::New(); - _newvol->SetMapper(_volumeMapper ); - _newvol->SetProperty(_volumeProperty ); - +{ + _currentrenderer = NULL; } void VolumeRendering::bbUserFinalizeProcessing() { diff --git a/bbtk/src/bbcreaMaracasVisuVolumeRendering.h b/bbtk/src/bbcreaMaracasVisuVolumeRendering.h index 0d1d5b4..27ba054 100644 --- a/bbtk/src/bbcreaMaracasVisuVolumeRendering.h +++ b/bbtk/src/bbcreaMaracasVisuVolumeRendering.h @@ -1,18 +1,12 @@ #ifndef __bbcreaMaracasVisuVolumeRendering_h_INCLUDED__ #define __bbcreaMaracasVisuVolumeRendering_h_INCLUDED__ #include "bbcreaMaracasVisu_EXPORT.h" -#include "bbtkAtomicBlackBox.h" +#include "bbtkWxBlackBox.h" #include "iostream" -#include -#include -#include -#include -#include -#include -#include + #include -#include +#include namespace bbcreaMaracasVisu @@ -20,31 +14,57 @@ namespace bbcreaMaracasVisu class bbcreaMaracasVisu_EXPORT VolumeRendering : - public bbtk::AtomicBlackBox + public bbtk::WxBlackBox { - BBTK_BLACK_BOX_INTERFACE(VolumeRendering,bbtk::AtomicBlackBox); - BBTK_DECLARE_INPUT(In,vtkImageData*); - BBTK_DECLARE_OUTPUT(Out,vtkProp3D*); + BBTK_BLACK_BOX_INTERFACE(VolumeRendering,bbtk::WxBlackBox); + + + + BBTK_DECLARE_INPUT(In1,vtkImageData*); + BBTK_DECLARE_INPUT(In2,vtkImageData*); + BBTK_DECLARE_INPUT(In3,vtkImageData*); + BBTK_DECLARE_INPUT(In4,vtkImageData*); + BBTK_DECLARE_INPUT(Renderer,vtkRenderer*); + + + /*BBTK_DECLARE_INPUT(GreyLevel, std::vector ); + BBTK_DECLARE_INPUT(Value, std::vector ); + BBTK_DECLARE_INPUT(GreyLevelColors, std::vector); + BBTK_DECLARE_INPUT(Red, std::vector); + BBTK_DECLARE_INPUT(Green, std::vector); + BBTK_DECLARE_INPUT(Blue, std::vector);*/ + //BBTK_DECLARE_OUTPUT(Out,vtkProp3D*); BBTK_PROCESS(Process); void Process(); + BBTK_CREATE_WIDGET(CreateWidget); + void CreateWidget(wxWindow*); private: - vtkVolumeRayCastCompositeFunction *_compositeFunction; - vtkPlanes *_volumePlanes; - vtkVolumeRayCastMapper *_volumeMapper; - vtkVolumeProperty *_volumeProperty; - vtkVolume *_newvol; - vtkPiecewiseFunction* _tfun; - vtkColorTransferFunction* _ctfun; + vtkRenderer* _currentrenderer; + }; -BBTK_BEGIN_DESCRIBE_BLACK_BOX(VolumeRendering,bbtk::AtomicBlackBox); +BBTK_BEGIN_DESCRIBE_BLACK_BOX(VolumeRendering,bbtk::WxBlackBox); BBTK_NAME("VolumeRendering"); BBTK_AUTHOR("car-prie@uniandes.edu.co"); BBTK_DESCRIPTION("Volume Rendering of a given image"); BBTK_CATEGORY("__CATEGORY__"); -BBTK_INPUT(VolumeRendering,In,"Image to create the volume rendering",vtkImageData*,""); -BBTK_OUTPUT(VolumeRendering,Out,"Prop3D resulting from the volume rendering",vtkProp3D*,""); + +BBTK_INPUT(VolumeRendering,In1,"Image to create the volume rendering",vtkImageData*,""); +BBTK_INPUT(VolumeRendering,In2,"Image to create the volume rendering",vtkImageData*,""); +BBTK_INPUT(VolumeRendering,In3,"Image to create the volume rendering",vtkImageData*,""); +BBTK_INPUT(VolumeRendering,In4,"Image to create the volume rendering",vtkImageData*,""); +BBTK_INPUT(VolumeRendering,Renderer,"Image to create the volume rendering",vtkRenderer*,""); + + +//BBTK_OUTPUT(VolumeRendering,Out,"Prop3D resulting from the volume rendering",vtkProp3D*,""); + +/*BBTK_INPUT(VolumeRendering,GreyLevel,"Greylevel related to the transparency",std::vector,""); + BBTK_INPUT(VolumeRendering,Value,"Value of the transparency in the transfer function",std::vector,""); + BBTK_INPUT(VolumeRendering,GreyLevelColors,"Grey level of the color in the transfer function",std::vector,""); + BBTK_INPUT(VolumeRendering,Red,"Red value according to the GreyLevelColors",std::vector,""); + BBTK_INPUT(VolumeRendering,Green,"Green value according to the GreyLevelColors",std::vector,""); + BBTK_INPUT(VolumeRendering,Blue,"Blue value according to the GreyLevelColors",std::vector,"");*/ BBTK_END_DESCRIBE_BLACK_BOX(VolumeRendering); } // EO namespace bbcreaMaracasVisu diff --git a/bbtk/src/bbmaracasvisuTransferFunctionView.cxx b/bbtk/src/bbmaracasvisuTransferFunctionView.cxx index f95262d..137f82b 100644 --- a/bbtk/src/bbmaracasvisuTransferFunctionView.cxx +++ b/bbtk/src/bbmaracasvisuTransferFunctionView.cxx @@ -9,13 +9,56 @@ BBTK_BLACK_BOX_IMPLEMENTATION(TransferFunctionView,bbtk::WxBlackBox); //----------------------------------------------------- void TransferFunctionView::Process() { - if(bbGetInputIn()!=NULL){ - mwxwidget->initializeHistogram(bbGetInputIn()); - mwxwidget->Refresh(); - } - + + std::vector greylevel; + std::vector value; + + std::vector greylevelcolors; + std::vector red; + std::vector green; + std::vector blue; + + if(bbGetInputIn()!=NULL){ + + if(_currentimg != bbGetInputIn()){ + _currentimg = bbGetInputIn(); + mwxwidget->initializeHistogram(_currentimg); + mwxwidget->Refresh(); + } + + mwxwidget->GetValuesPointsFunction(greylevel, value); + mwxwidget->GetValuesColorPointsFunction(greylevelcolors,red, green,blue); + + + _tfun->RemoveAllPoints(); + for(int i = 0; i < greylevel.size();i++){ + _tfun->AddPoint(greylevel[i], value[i]); +// std::cout<<"transfer function "<RemoveAllPoints(); + for(int i = 0; i < greylevelcolors.size();i++){ + _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]); +// std::cout<<"transfer color function "< ); + BBTK_DECLARE_OUTPUT(Value, std::vector ); + BBTK_DECLARE_OUTPUT(GreyLevelColors, std::vector); + BBTK_DECLARE_OUTPUT(Red, std::vector); + BBTK_DECLARE_OUTPUT(Green, std::vector); + BBTK_DECLARE_OUTPUT(Blue, std::vector);*/ + BBTK_PROCESS(Process); void Process(); BBTK_CREATE_WIDGET(CreateWidget); @@ -22,6 +34,9 @@ class /*BBTK_EXPORT*/ TransferFunctionView private: HistogramWidget *mwxwidget; + vtkImageData* _currentimg; + vtkPiecewiseFunction* _tfun; + vtkColorTransferFunction* _ctfun; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(TransferFunctionView,bbtk::WxBlackBox); @@ -30,6 +45,14 @@ BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr"); BBTK_DESCRIPTION("Transfer Function Window"); //BBTK_CATEGORY("__CategoryBlackBox__"); BBTK_INPUT(TransferFunctionView,In,"Input image",vtkImageData*,""); + BBTK_OUTPUT(TransferFunctionView,OpacityFunction,"Transfer function for the opacity", vtkPiecewiseFunction*,""); + BBTK_OUTPUT(TransferFunctionView,ColorFunction,"Transfer function for the color", vtkColorTransferFunction*,""); + /*BBTK_OUTPUT(TransferFunctionView,GreyLevel,"Greylevel related to the transparency",std::vector,""); + BBTK_OUTPUT(TransferFunctionView,Value,"Value of the transparency in the transfer function",std::vector,""); + BBTK_OUTPUT(TransferFunctionView,GreyLevelColors,"Grey level of the color in the transfer function",std::vector,""); + BBTK_OUTPUT(TransferFunctionView,Red,"Red value according to the GreyLevelColors",std::vector,""); + BBTK_OUTPUT(TransferFunctionView,Green,"Green value according to the GreyLevelColors",std::vector,""); + BBTK_OUTPUT(TransferFunctionView,Blue,"Blue value according to the GreyLevelColors",std::vector,"");*/ BBTK_END_DESCRIBE_BLACK_BOX(TransferFunctionView); } // EO namespace bbcreaMaracasVisu diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.cxx index d5dd0d7..1badcef 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.cxx @@ -383,4 +383,21 @@ printf("EED %p HistogramWidget::addPointToTransferenceFunction tp%p x%f y%f %d\n this->type=type; } +/** +** Returns two vectors, the grey level of the point and its value, the value is between [0,1] +**/ + void HistogramWidget::GetValuesPointsFunction(std::vector& greylevel,std::vector& value){ + plotter->GetValuesPointsFunction(greylevel,value,histogramSize); + } +/** +** Returns two vectors, the grey level of the point and its value, the red, green +** and blue value is between [0,1] +**/ + void HistogramWidget::GetValuesColorPointsFunction(std::vector& greylevel, + std::vector& red, + std::vector& green, + std::vector& blue) + { + plotter->GetValuesColorPointsFunction(greylevel,red,green,blue); + } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.h index 7b48d59..3947d32 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.h @@ -136,6 +136,19 @@ public: int getHistogramSize(); void setType(int type); + /** + ** Returns two vectors, the grey level of the point and its value, the value is between [0,1] + **/ + void GetValuesPointsFunction(std::vector& greylevel,std::vector& value); + + /** + ** Returns two vectors, the grey level of the point and its value, the red, green + ** and blue value is between [0,1] + **/ + void GetValuesColorPointsFunction(std::vector& greylevel, + std::vector& red, + std::vector& green, + std::vector& blue); private: diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx index 4b37ef9..fc7203f 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx @@ -320,7 +320,7 @@ mpScaleY::mpScaleY(wxString name) SetFont( ff ); } -void mpScaleY::Plot(wxDC & dc, mpWindow & w) +void mpScaleY::Plot(wxDC & dc, mpWindow & w, int orgy) { dc.SetPen( m_pen); dc.SetFont( m_font); @@ -328,7 +328,9 @@ void mpScaleY::Plot(wxDC & dc, mpWindow & w) const int orgx = -(int)(w.GetPosX() * w.GetScaleX()); const int extend = w.GetScrY()/2; - dc.DrawLine( orgx, -extend, orgx, extend); + double sizedc = dc.GetSize().GetHeight()-orgy; + + dc.DrawLine( orgx, GetYTranslated(sizedc, -extend), orgx, GetYTranslated(sizedc, extend)); const double dig = floor( log( 128.0 / w.GetScaleY() ) / mpLN10 ); const double step = exp( mpLN10 * dig); @@ -354,19 +356,19 @@ void mpScaleY::Plot(wxDC & dc, mpWindow & w) for (;n < end; n += step) { const int p = (int)((w.GetPosY() - n) * w.GetScaleY()); - dc.DrawLine( orgx, p, orgx+4, p); + dc.DrawLine( orgx, GetYTranslated(sizedc, p), orgx+4, GetYTranslated(sizedc,p)); s.Printf(fmt, n); dc.GetTextExtent(s, &tx, &ty); if ((tmp-p+ty/2) > 32) { - dc.DrawText( s, orgx+4, p-ty/2); + dc.DrawText( s, orgx+4, GetYTranslated(sizedc,p-ty/2)); tmp=p-ty/2; } } dc.GetTextExtent(m_name, &tx, &ty); - dc.DrawText( m_name, orgx-tx-4, -extend + ty + 4); + dc.DrawText( m_name, orgx-tx-4, GetYTranslated(sizedc,-extend + ty + 4)); } //----------------------------------------------------------------------------- @@ -589,7 +591,7 @@ printf("EED mpWindow::OnPaint %d %d\n",m_scrX,m_scrY); //dc.SetDeviceOrigin(70,40); //dc.SetAxisOrientation(false,true); - temp_dc.SetAxisOrientation(true,false); + //temp_dc.SetAxisOrientation(true,false); //EED 14mai2009 //dc.Blit(0,0, m_scrX, m_scrY, &temp_dc,-70,-m_scrY+40); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.h index e8b67dc..0856926 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.h @@ -194,6 +194,14 @@ public: */ void SetPen(wxPen& pen) { m_pen = pen; } + /** + ** Get the translation of the Y coordinate acoording to the new orientation of the axis du to the problem + ** identified in MACOS with the funtion 'SetAxisOrientation' + **/ + int GetYTranslated(double sizey, double y){ + return -y+sizey; + } + protected: wxFont m_font; //!< Layer's font wxPen m_pen; //!< Layer's pen @@ -385,7 +393,7 @@ public: /** Layer plot handler. This implementation will plot the ruler adjusted to the visible area. */ - virtual void Plot(wxDC & dc, mpWindow & w); + virtual void Plot(wxDC & dc, mpWindow & w, int orgy); /** Check whether this layer has a bounding box. This implementation returns \a FALSE thus making the ruler invisible @@ -784,6 +792,13 @@ public: /** Refresh display */ void UpdateAll(); + /** + ** Get the translation of the Y coordinate + **/ + int GetYTranslated(wxSize size, double y){ + return size.GetHeight()-y; + } + protected: void Refresh(bool eraseBackground = true, const wxRect* rect = NULL); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pColorBar.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pColorBar.cxx index c735b34..d83e4d4 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pColorBar.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pColorBar.cxx @@ -363,7 +363,7 @@ pColorBar :: ~pColorBar() void pColorBar :: onAddColorPoint ( wxCommandEvent& anEvent ) { bool addedPoint = false; - double real_x = getOrientation() ? convertToRealValue( clickedX ) : convertToRealValue( clickedY );; + double real_x = getOrientation() ? convertToRealValue( clickedX ) : convertToRealValue( clickedY ); wxColour selectedColor = getSelectedColour(); if (okSelectedColor) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx index a425cb9..c02da99 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx @@ -285,6 +285,7 @@ wxNode* pGraphicalFunction:: getBefore(pFunctionPoint* point) int minDiference=10000000; wxNode* node=logicFunction->GetPointAt(0); wxNode* before=NULL; + while(node) { pFunctionPoint* before1=(pFunctionPoint*)node->GetData(); @@ -395,7 +396,7 @@ double pGraphicalFunction::interpolateY(double m, int x1,int y1,int x) //realPoints.DeleteC np = logicFunction->getSizePoints(); - nps = 100; + nps = 200; delta=( double ) ( np ) / ( double ) ( nps ); for( i = 0; i < nps; i++ ) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx index 28c7d30..19a2af2 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx @@ -149,6 +149,7 @@ void pHistogram::setPoints(vtkImageData* imageData) */ maxLevelOfGrey=(int)range[1]; minLevelOfGrey=(int)range[0]; + //std::cout<<"maxLevelOfGrey "<& greylevel,std::vector& value, int histogramsize) +{ + if(actualFunction != NULL){ + double* xval = actualFunction->getX_RealValues(); + double* yval = actualFunction->getY_RealValues(); + + actualFunction->getScaleY(); + for(int i = 0; i < actualFunction->getSizePoints();i++){ + greylevel.push_back(xval[i]); + value.push_back(yval[i]/histogramsize); + } + } +} + +/** +** Returns two vectors, the grey level of the point and its value, the red, green +** and blue value is between [0,1] +**/ +void pPlotter::GetValuesColorPointsFunction(std::vector& greylevel, + std::vector& red, + std::vector& green, + std::vector& blue) +{ + + if(color_bar != NULL){ + + std::vector colors; + color_bar->getAddedColorsPointsList(colors); + + for(int i = 0; i < colors.size();i++){ + pColorPoint* pcolor = colors[i]; + + greylevel.push_back(pcolor->getRealX()); + wxColour colour = pcolor->getColor(); + + double _red = (double)(colour.Red())/255.0; + double _green = (double)(colour.Green())/255.0; + double _blue = (double)(colour.Blue())/255.0; + + red.push_back(_red); + green.push_back(_green); + blue.push_back(_blue); + } + } +} + + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotter.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotter.h index 5049e85..e648a9a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotter.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotter.h @@ -204,6 +204,21 @@ public: bool zoomOut,bool showPoints,bool noShowPoints,bool changeColor, bool addP, bool delPoint,bool load,bool save); + + /** + ** Returns two vectors, the grey level of the point and its value, the value is between [0,1] + **/ + void GetValuesPointsFunction(std::vector& greylevel,std::vector& value, int histogramsize); + + /** + ** Returns two vectors, the grey level of the point and its value, the red, green + ** and blue value is between [0,1] + **/ + void GetValuesColorPointsFunction(std::vector& greylevel, + std::vector& red, + std::vector& green, + std::vector& blue); + //---------------------------------------------------------------------------------------- // Attributes declration //---------------------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.cxx index 37c7ba2..c8c64d6 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.cxx @@ -41,7 +41,7 @@ pPlotterLayer:: pPlotterLayer(wxString name , int flags ) Draw the line from (x1,y1) to (x2,y2) only passing by the positive points in the line */ -void pPlotterLayer::draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,double y2) +void pPlotterLayer::draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,double y2, int orgy) { //intercepts @@ -49,23 +49,24 @@ void pPlotterLayer::draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,d float x0=-y1/m+x1; float y0=-m*x1+y1; + double sizedc = dc.GetSize().GetHeight()-orgy; //analyzing the curve if(x1<=0 && x2>=0) { if(y2>=0 && y1>=0) - dc.DrawLine(0,y0, x2,y2); + dc.DrawLine(0,GetYTranslated(sizedc,y0), x2,GetYTranslated(sizedc,y2)); else if(y2<=0 && y1>=0) { if(y0>=0 && x0>=0) - dc.DrawLine(0,y0,x0,0 ); + dc.DrawLine(0,GetYTranslated(sizedc,y0),x0,GetYTranslated(sizedc,0) ); } else if(y2>=0 && y1<=0) { if(y0>=0) - dc.DrawLine(0,y0,x2,y2 ); + dc.DrawLine(0,GetYTranslated(sizedc,y0),x2,GetYTranslated(sizedc,y2) ); } } @@ -73,11 +74,11 @@ void pPlotterLayer::draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,d if(x1>=0 && x2>=0) { if(y1>=0 && y2>=0 ) - dc.DrawLine(x1,y1, x2,y2); + dc.DrawLine(x1,GetYTranslated(sizedc,y1), x2,GetYTranslated(sizedc,y2)); else if(y1>=0 && y2<=0) - dc.DrawLine(x1,y1,x0,0 ); + dc.DrawLine(x1,GetYTranslated(sizedc,y1),x0,GetYTranslated(sizedc,0) ); else if(y1<=0 && y2>=0) - dc.DrawLine(x0,0,x2,y2); + dc.DrawLine(x0,GetYTranslated(sizedc,0),x2,GetYTranslated(sizedc,y2)); } @@ -87,7 +88,7 @@ void pPlotterLayer::draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,d * Draw the function with th spline points * */ -void pPlotterLayer::drawSplineCurve(wxDC & dc,mpWindow & w) +void pPlotterLayer::drawSplineCurve(wxDC & dc,mpWindow & w, int orgy) { std::vector vx=getXSpline(); std::vector vy=getYSpline(); @@ -139,7 +140,7 @@ void pPlotterLayer::drawSplineCurve(wxDC & dc,mpWindow & w) if(type!=2) - draw(dc,w,cxi,cyi,cxj,cyj); + draw(dc,w,cxi,cyi,cxj,cyj,orgy); else if(type==2) { if(!initializePolygon(ppoints,cxi,cyi,cxj,cyj) && ((cxi<=0 && cxj>=0)||(cxi>=0 && cxj>=0))) @@ -174,6 +175,10 @@ void pPlotterLayer::drawSplineCurve(wxDC & dc,mpWindow & w) dc.SetBrush(wxBrush( wxColour(239,238,242) ,wxSOLID )); dc.SetPen(wxPen( wxColour(0,0,0) ,1,wxSOLID )); //dc.DrawPolygon(vx.size()+2,ppoints,0,0); + for(int i = 0; i <= j + 1; i++){ + int sizedc = dc.GetSize().GetHeight()-orgy; + ppoints[i].y = GetYTranslated(sizedc, ppoints[i].y); + } dc.DrawPolygon(j+2,ppoints,0,0); } @@ -282,7 +287,7 @@ bool pPlotterLayer::initializePolygon(wxPoint* points,double x1, double y1,doubl /** * Draw the lines between the points of the function */ -void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w) +void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w, int orgy) { @@ -301,6 +306,8 @@ void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w) dc.GetSize(&scrwX, &scrwY); //Lines between the points + + int sizedc = dc.GetSize().GetHeight()-orgy; GetPoints(points); @@ -329,7 +336,7 @@ void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w) ppoints=(wxPoint*)malloc(sizeof(int)*2*(points.GetCount()+2)); //initialize points point.x=-5000; - point.y=-5000; + point.y=GetYTranslated(sizedc,-5000); ppoints[0]=point; ppoints[1]=point; @@ -355,14 +362,14 @@ void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w) int cyj=pyj* scaleY+ offsetpy ; //dc.DrawLine(pxi* scaleX + offsetpx,pyi* scaleY+ offsetpy, pxj* scaleX + offsetpx,pyj* scaleY+ offsetpy ); if(type!=2) - draw(dc,w,pxi* scaleX + offsetpx,pyi* scaleY+ offsetpy, pxj* scaleX + offsetpx,pyj* scaleY+ offsetpy ); + draw(dc,w,pxi* scaleX + offsetpx,pyi* scaleY+ offsetpy, pxj* scaleX + offsetpx,pyj* scaleY+ offsetpy,orgy ); //dc.DrawLine(pxi* scaleX + offsetpx,pyi* scaleY+ offsetpy, pxj* scaleX + offsetpx,pyj* scaleY+ offsetpy ); else if(type==2) { if(!initializePolygon(ppoints,cxi,cyi,cxj,cyj) && ((cxi<=0 && cxj>=0)||(cxi>=0 && cxj>=0))) { point.x=cxj; - point.y=cyj; + point.y=GetYTranslated(sizedc,cyj); ppoints[j]=point; j++; @@ -376,7 +383,7 @@ void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w) { //point.x=vx.at(size-1)* scaleX + offsetpx; point.x=ppoints[j-1].x; - point.y=0; + point.y=GetYTranslated(sizedc,0); //ppoints[vx.size()]=point; ppoints[j]=point; /* @@ -386,7 +393,7 @@ void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w) //settings for fill //point.x=vx.at(0)*scaleX + offsetpx; point.x=ppoints[0].x; - point.y=0; + point.y=GetYTranslated(sizedc,0); //ppoints[vx.size()+1]=point; ppoints[j+1]=point; @@ -402,13 +409,14 @@ void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w) /** * Draw the points of the function */ -void pPlotterLayer::drawPoints(wxDC & dc,mpWindow & w) +void pPlotterLayer::drawPoints(wxDC & dc,mpWindow & w, int orgy) { Rewind(); double x, y; int minX,maxX,minY,maxY; + double sizedc = dc.GetSize().GetHeight()-orgy; /* This is the offset of every point scale to the window @@ -434,13 +442,13 @@ void pPlotterLayer::drawPoints(wxDC & dc,mpWindow & w) dc.SetBrush(wxBrush( wxColour(255,0,0),wxSOLID )); //dc.SetPen(wxPen(wxColour(0,0,0),1,wxSOLID) ); points[0].x=((x-minX-offsetX)*scaleX + offsetpx-MOVE); - points[0].y=((y-minY-offsetY)*scaleY+ offsetpy-MOVE); + points[0].y=GetYTranslated(sizedc,((y-minY-offsetY)*scaleY+ offsetpy-MOVE)); points[1].x=((x-minX-offsetX)*scaleX+ offsetpx+MOVE); - points[1].y=((y-minY-offsetY)*scaleY+ offsetpy-MOVE); + points[1].y=GetYTranslated(sizedc,((y-minY-offsetY)*scaleY+ offsetpy-MOVE)); points[2].x=((x-minX-offsetX)*scaleX+ offsetpx+MOVE); - points[2].y=((y-minY-offsetY)*scaleY+ offsetpy+MOVE); + points[2].y=GetYTranslated(sizedc,((y-minY-offsetY)*scaleY+ offsetpy+MOVE)); points[3].x=((x-minX-offsetX)*scaleX+ offsetpx-MOVE); - points[3].y=((y-minY-offsetY)*scaleY+ offsetpy+MOVE); + points[3].y=GetYTranslated(sizedc,((y-minY-offsetY)*scaleY+ offsetpy+MOVE)); if((x-minX-offsetX)*scaleX >=0 && (y-minY-offsetY/*w.getMinScrY()*/)*scaleY>=0) dc.DrawPolygon(4,points,0,0); } @@ -450,7 +458,7 @@ void pPlotterLayer::drawPoints(wxDC & dc,mpWindow & w) * Draw the line between the last point of the function * and the position of the mouse */ -void pPlotterLayer::drawLineToMousePoint(wxDC & dc,mpWindow & w) +void pPlotterLayer::drawLineToMousePoint(wxDC & dc,mpWindow & w, int orgy) { int x,y,sizeP,maxX,maxY,minX,minY; bool direction; @@ -535,6 +543,7 @@ void pPlotterLayer::Plot(wxDC & dc, mpWindow & w) */ dc.GetSize(&scrwX, &scrwY); + getIfActual(actual); //getMax(maxX, maxY); /***********/ @@ -576,39 +585,41 @@ void pPlotterLayer::Plot(wxDC & dc, mpWindow & w) // dc.SetAxisOrientation(true,true); int orgy = 40; - dc.SetDeviceOrigin( orgx ,orgy); - dc.SetAxisOrientation(true,false); + //dc.SetDeviceOrigin( orgx ,orgy); + dc.SetDeviceOrigin( orgx ,0); + int sizedc = dc.GetSize().GetHeight()-orgy; + //dc.SetAxisOrientation(true,false); //if the user dont want to see the points of the function and if he stops drawing //we have to draw the function if(!show && !drawing && type==1) - drawFunction(dc,w); + drawFunction(dc,w,orgy); else if(!show && !drawing && type==2) - drawSplineCurve(dc,w); + drawSplineCurve(dc,w,orgy); //we just draw the point that the user just clicked else if(drawing && type==1) { - drawFunction(dc,w); - drawLineToMousePoint(dc,w); - drawPoints(dc,w); + drawFunction(dc,w,orgy); + drawLineToMousePoint(dc,w,orgy); + drawPoints(dc,w,orgy); } else if(drawing && type==1) { - drawSplineCurve(dc,w); - drawLineToMousePoint(dc,w); - drawPoints(dc,w); + drawSplineCurve(dc,w,orgy); + drawLineToMousePoint(dc,w,orgy); + drawPoints(dc,w,orgy); } else if(show && type==1) { - drawFunction(dc,w); - drawPoints(dc,w); + drawFunction(dc,w,orgy); + drawPoints(dc,w,orgy); } else if(show && type==2) { - drawSplineCurve(dc,w); - drawPoints(dc,w); + drawSplineCurve(dc,w,orgy); + drawPoints(dc,w,orgy); } // Drawing the guides according to real values entered according to the integrated interaction (IS NOT WORKING!!!) @@ -621,13 +632,19 @@ void pPlotterLayer::Plot(wxDC & dc, mpWindow & w) int realX_guide = w.getRealGuideX(); if( realX_guide!=-1 ) { - dc.DrawLine( (realX_guide/*-w.getMinScrX()*/-offsetX)*scaleX + offsetpx, 0, (realX_guide/*-w.getMinScrX()*/-offsetX)*scaleX + offsetpx, scrwY); + dc.DrawLine( (realX_guide/*-w.getMinScrX()*/-offsetX)*scaleX + offsetpx, + GetYTranslated(sizedc,0), + (realX_guide/*-w.getMinScrX()*/-offsetX)*scaleX + offsetpx, + GetYTranslated(sizedc,scrwY)); } int realY_guide = w.getRealGuideY(); if( realY_guide!=-1 ) { - dc.DrawLine( 0,(realY_guide/*-w.getMinScrY()*/-offsetX)*scaleX + offsetpx, scrwX, (realY_guide/*-w.getMinScrY()*/-offsetX)*scaleX + offsetpx); + dc.DrawLine( 0, + GetYTranslated(sizedc,(realY_guide/*-w.getMinScrY()*/-offsetX)*scaleX + offsetpx), + scrwX, + GetYTranslated(sizedc,(realY_guide/*-w.getMinScrY()*/-offsetX)*scaleX + offsetpx)); } } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h index ca89d1b..5ef2f59 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h @@ -47,27 +47,27 @@ public: Draw the line from (x1,y1) to (x2,y2) only passing by the positive points in the line */ -void draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,double y2); +void draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,double y2, int orgy); /** * Draw the function with th spline points * */ - void drawSplineCurve(wxDC & dc,mpWindow & w); + void drawSplineCurve(wxDC & dc,mpWindow & w, int orgy); /** * Draw the line between the last point of the function * and the position of the mouse */ - void drawLineToMousePoint(wxDC & dc,mpWindow & w); + void drawLineToMousePoint(wxDC & dc,mpWindow & w, int orgy); /** * Draw le lines between the points of the function */ - void drawFunction(wxDC & dc,mpWindow & w); + void drawFunction(wxDC & dc,mpWindow & w, int orgy); /** * Draw the points of the function */ - void drawPoints(wxDC & dc,mpWindow & w); + void drawPoints(wxDC & dc,mpWindow & w, int orgy ); /** Get the value of the traslation diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx index 28ce942..45d0abe 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx @@ -40,6 +40,8 @@ void pPlotterScaleX::Plot(wxDC& dc, mpWindow& w) dc.SetPen( m_pen); dc.SetFont( m_font); + + //data float min=(float)w.getMinScrX(); @@ -57,14 +59,16 @@ void pPlotterScaleX::Plot(wxDC& dc, mpWindow& w) // dc.SetAxisOrientation(true,true); //EED MacOx ??? const int orgy = 40; - dc.SetDeviceOrigin(70,orgy); - dc.SetAxisOrientation(true,false); - + //dc.SetDeviceOrigin(70,orgy); + dc.SetDeviceOrigin(70,0); + //dc.SetAxisOrientation(true,false); + double sizedc = dc.GetSize().GetY()-orgy; + //const int extend = w.GetScrX()-100; //JPRx //draw the axe - dc.DrawLine(0,0,(max-min)*scaleX,0); + dc.DrawLine(0,GetYTranslated(sizedc, 0),(max-min)*scaleX,GetYTranslated(sizedc, 0)); //maximum value in x int d=max-min; @@ -84,9 +88,9 @@ void pPlotterScaleX::Plot(wxDC& dc, mpWindow& w) //drawing the first line - dc.DrawLine(0,0,0,-10); + dc.DrawLine(0,GetYTranslated(sizedc, 0),0,GetYTranslated(sizedc, -10)); s.Printf(_T("%d"),(int)(min)); - dc.DrawText(s,(wxCoord)0,(wxCoord)-20); + dc.DrawText(s,(wxCoord)0,GetYTranslated(sizedc, (wxCoord)-20)); for(float i=0;i<=(max);i+=step) { @@ -96,14 +100,14 @@ void pPlotterScaleX::Plot(wxDC& dc, mpWindow& w) { dc.DrawLine(p,0,p,-10); s.Printf(_T("%d"),(int)(i)); - dc.DrawText(s,(wxCoord)p,(wxCoord)-20); + dc.DrawText(s,(wxCoord)p,GetYTranslated(sizedc, (wxCoord)-20)); } } //drawing the last line int p=(max-min-offsetX)*scaleX+offsetpx; - dc.DrawLine(p,0,p,-10); + dc.DrawLine(p,GetYTranslated(sizedc, 0),p,GetYTranslated(sizedc, -10)); s.Printf(_T("%d"),(int)(max)); - dc.DrawText(s,(wxCoord)p,(wxCoord)-20); + dc.DrawText(s,(wxCoord)p,GetYTranslated(sizedc, (wxCoord)-20)); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleY.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleY.cxx index 18d585e..2f3ba1d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleY.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleY.cxx @@ -58,13 +58,15 @@ void pPlotterScaleY::Plot(wxDC& dc, mpWindow& w) // dc.SetAxisOrientation(true,true); //EED MacOx ??? const int orgy = 40; - dc.SetDeviceOrigin(70,orgy); - dc.SetAxisOrientation(true,false); + //dc.SetDeviceOrigin(70,orgy); + dc.SetDeviceOrigin(70,0); + double sizedc = dc.GetSize().GetY()-orgy; + //dc.SetAxisOrientation(true,false); // const int extend = w.GetScrY()-50; //EED //draw the axe - dc.DrawLine( 0,0, 0, (max-min)*scaleY); + dc.DrawLine( 0,GetYTranslated(sizedc, 0), 0, GetYTranslated(sizedc, (max-min)*scaleY)); //maximum value in Y int d=max-min; @@ -83,9 +85,9 @@ void pPlotterScaleY::Plot(wxDC& dc, mpWindow& w) //drawing the axe with the numbers wxString s; //drawing the first line - dc.DrawLine(0,0,-10,0); + dc.DrawLine(0,GetYTranslated(sizedc, 0),-10,GetYTranslated(sizedc, 0)); s.Printf(_T("%d"),(int)(min)); - dc.DrawText(s,(wxCoord)-20,(wxCoord)0); + dc.DrawText(s,(wxCoord)-20,GetYTranslated(sizedc, (wxCoord)0)); for(float i=0;i<=(max);i+=step) @@ -94,16 +96,16 @@ void pPlotterScaleY::Plot(wxDC& dc, mpWindow& w) int p=(i-min-offsetY)*scaleY+offsetpy; if(p>=0) { - dc.DrawLine(0,p,-10,p); + dc.DrawLine(0,GetYTranslated(sizedc, p),-10,GetYTranslated(sizedc, p)); s.Printf(_T("%d"),(int)(i)); - dc.DrawText(s,(wxCoord)-20,(wxCoord)p); + dc.DrawText(s,(wxCoord)-20,GetYTranslated(sizedc, (wxCoord)p)); } } //drawing the last line int p=(max-min-offsetY)*scaleY+offsetpy; - dc.DrawLine(0,p,-10,p); + dc.DrawLine(0,GetYTranslated(sizedc, p),-10,GetYTranslated(sizedc, p)); s.Printf(_T("%d"),(int)(max)); - dc.DrawText(s,(wxCoord)-20,(wxCoord)p); + dc.DrawText(s,(wxCoord)-20,GetYTranslated(sizedc, (wxCoord)p)); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.cxx new file mode 100644 index 0000000..16186ba --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.cxx @@ -0,0 +1,155 @@ +/*========================================================================= + + Program: wxMaracas + Module: $RCSfile: wxMaracasMultipleVolumeRendererManager.cxx,v $ + Language: C++ + Date: $Date: 2009/07/08 14:22:14 $ + Version: $Revision: 1.1 $ + + 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 "wxMaracasMultipleVolumeRendererManager.h" + +#include +/** +** Start of the manager class +**/ +wxMaracasMultipleVolumeRendererManager::wxMaracasMultipleVolumeRendererManager(){ + _renderer = NULL; + _idCount=0; +} +wxMaracasMultipleVolumeRendererManager::~wxMaracasMultipleVolumeRendererManager(){ +} + +/** +** Sets the renderer to manage the prop3D from the view +**/ +void wxMaracasMultipleVolumeRendererManager::setRenderer(vtkRenderer* renderer){ + _renderer = renderer; +} +/** +** Adds a prop3D to the manager and returns the identifier +**/ +int wxMaracasMultipleVolumeRendererManager::addVolume(vtkImageData* vol, std::string dataname) throw(char*){ + checkInvariant(); + if(vol != NULL){ + wxMaracasMultipleVolumeRendererManagerData* data = new wxMaracasMultipleVolumeRendererManagerData(vol, dataname); + prop3Dvect.push_back(data); + _renderer->AddActor(data->getProp3D()); + data->setId(_idCount); + _idCount++; + return data->getId(); + }else{ + throw "Check mhd imagefile file or input"; + } + return -1; +} +/** +** adds or removes an actor depending of the bool value +**/ + +void wxMaracasMultipleVolumeRendererManager::addRemoveActor(int propid, bool addremove) throw(char*){ + checkInvariant(); + + wxMaracasMultipleVolumeRendererManagerData* data = this->getViewData(propid); + if(data->getProp3D()!=NULL){ + if(addremove){ + _renderer->AddViewProp(data->getProp3D()); + }else{ + _renderer->RemoveViewProp(data->getProp3D()); + } + _renderer->Render(); + } + +} +/** +** Changes the opacity in a prop3D +**/ +void wxMaracasMultipleVolumeRendererManager::setVolumeOpacity(int propid, std::vector greylevel,std::vector value) throw(char*){ + checkInvariant(); + + this->getViewData(propid)->setVolumeOpacity(greylevel, value); + + _renderer->Render(); + +} + +/** +** Set Volume Color +**/ +void wxMaracasMultipleVolumeRendererManager::setVolumeColor(int volid, std::vector greylevel, + std::vector red, + std::vector green, + std::vector blue) +{ + checkInvariant(); + + this->getViewData(volid)->setVolumeColor(greylevel, red, green, blue); + + _renderer->Render(); +} + +vtkImageData* wxMaracasMultipleVolumeRendererManager::getImageData(std::string filename){ + if(filename.compare("")!= 0){ + + + vtkMetaImageReader* reader = vtkMetaImageReader::New(); + reader->SetFileName(filename.c_str()); + reader->Update(); + vtkImageData* img = reader->GetOutput(); + //reader->Delete(); + return img; + } + return NULL; +} + +void wxMaracasMultipleVolumeRendererManager::checkInvariant() throw(char*){ + if(this->_renderer==NULL){ + throw "Renderer not set"; + } +} + +wxMaracasMultipleVolumeRendererManagerData* wxMaracasMultipleVolumeRendererManager::getViewData(int id) throw(char*){ + int i; + for(i = 0; i < (int)(prop3Dvect.size());i++){ + if(prop3Dvect[i]->getId() == id){ + return prop3Dvect[i]; + } + } + throw "id not found in the data"; + + return NULL; +} + +void wxMaracasMultipleVolumeRendererManager::deleteActor(int propid) throw (char *){ + checkInvariant(); + + this->addRemoveActor(propid, false); + + int i,n; + bool exit = false; + for(i = 0; i < (int)(prop3Dvect.size())&&!exit;i++){ + if(prop3Dvect[i]->getId() == propid){ + n=i; + exit = true; + } + } + if(exit){ + wxMaracasMultipleVolumeRendererManagerData* data = prop3Dvect[n]; + int j; + for(j = i; j < (int)(prop3Dvect.size())-1;j++){ + prop3Dvect[j] = prop3Dvect[j+1]; + } + delete data; + prop3Dvect.pop_back(); + }else{ + throw "id not found in the data"; + } + +} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.h new file mode 100644 index 0000000..ae206c2 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.h @@ -0,0 +1,97 @@ +/*========================================================================= + + Program: wxMaracas + Module: $RCSfile: wxMaracasMultipleVolumeRendererManager.h,v $ + Language: C++ + Date: $Date: 2009/07/08 14:22:14 $ + Version: $Revision: 1.1 $ + + 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. + +=========================================================================*/ + + + + +#ifndef __wxMaracasMultipleVolumeRendererManagerH__ +#define __wxMaracasMultipleVolumeRendererManagerH__ + +#include +#include + +#include "wxMaracasMultipleVolumeRendererManagerData.h" + + +class wxMaracasMultipleVolumeRendererManager { + +public: + wxMaracasMultipleVolumeRendererManager(); + ~wxMaracasMultipleVolumeRendererManager(); + + /** + ** Sets the renderer to manage the prop3D from the view + **/ + void setRenderer(vtkRenderer* renderer); + /** + ** Adds a volume + **/ + int addVolume(vtkImageData* img, std::string dataname) throw (char*); + + /** + ** loads a prop3D from a nSTL file + **/ + vtkProp3D* getVolume(std::string filename); + + /** + ** loads a MHD file to convert it into an actor + **/ + vtkImageData* getImageData(std::string filename); + + /** + ** adds or removes an actor depending of the bool value + **/ + void addRemoveActor(int propid, bool addremove) throw(char*); + /** + ** Check if the variables are setted correctly + **/ + void checkInvariant()throw(char*); + + /** + ** Set Volume Opacity + **/ + void setVolumeOpacity(int propid, std::vector greylevel,std::vector value); + /** + ** Set Volume Color + **/ + void setVolumeColor(int volid, std::vector greylevel, + std::vector red, + std::vector green, + std::vector blue); + + /** + ** Given an id search the data in the vector + **/ + wxMaracasMultipleVolumeRendererManagerData* getViewData(int id)throw(char*); + /** + ** + **/ + void deleteActor(int volumeid)throw (char *); + +private: + std::vector prop3Dvect; + + vtkRenderer* _renderer; + + int _idCount; + + + + +}; + +#endif diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.cxx new file mode 100644 index 0000000..de064e3 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.cxx @@ -0,0 +1,116 @@ + +#include "wxMaracasMultipleVolumeRendererManagerData.h" + +/******************************************************************************************** +** Start of data viewmanagerData +*********************************************************************************************/ + +wxMaracasMultipleVolumeRendererManagerData::wxMaracasMultipleVolumeRendererManagerData(vtkImageData* vol, std::string dataname){ + + _vol = vol; + _dataname = dataname; + + _tfun = vtkPiecewiseFunction::New(); + _ctfun = vtkColorTransferFunction::New(); + + _volumePlanes = vtkPlanes::New(); + _compositeFunction = vtkVolumeRayCastCompositeFunction::New(); + _volumeMapper = vtkVolumeRayCastMapper::New(); + _volumeMapper->SetVolumeRayCastFunction(_compositeFunction); + _volumeMapper->SetClippingPlanes( _volumePlanes ); + _volumeMapper->AutoAdjustSampleDistancesOn(); + _volumeProperty = vtkVolumeProperty::New(); + _volumeProperty->SetInterpolationTypeToLinear(); + _volumeProperty->ShadeOn(); + _volumeProperty->DisableGradientOpacityOn(); + _volumeProperty->SetColor(_ctfun); + _volumeProperty->SetScalarOpacity(_tfun ); + + _newvol = vtkVolume::New(); + _newvol->SetMapper(_volumeMapper ); + _newvol->SetProperty(_volumeProperty ); + _volumeMapper->SetInput( _vol ); + _volumeMapper->Update(); + _newvol->Update(); +} + + +wxMaracasMultipleVolumeRendererManagerData::~wxMaracasMultipleVolumeRendererManagerData(){ + + _tfun->Delete(); + _ctfun->Delete(); + _volumePlanes->Delete(); + _compositeFunction->Delete(); + _volumeMapper->Delete(); + _volumeProperty->Delete(); + _newvol->Delete(); + +} +/** +** Set Volume Color +**/ +void wxMaracasMultipleVolumeRendererManagerData::setVolumeColor(std::vector& greylevelcolors, + std::vector& red, + std::vector& green, + std::vector& blue) +{ + + _ctfun->RemoveAllPoints(); + for(int i = 0; i < greylevelcolors.size();i++){ + _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]); + // std::cout<<"transfer color function "<Update(); +} + +/** +** Volume Opacity +**/ +void wxMaracasMultipleVolumeRendererManagerData::setVolumeOpacity(std::vector greylevel,std::vector value){ + + _tfun->RemoveAllPoints(); + for(int i = 0; i < greylevel.size();i++){ + _tfun->AddPoint(greylevel[i], value[i]); +// std::cout<<"transfer function "<Update(); +} + +/** +** Check if the variables are setted correctly +**/ +void wxMaracasMultipleVolumeRendererManagerData::checkInvariant(){ + +} +/** +** get the prop3D +**/ +vtkProp3D* wxMaracasMultipleVolumeRendererManagerData::getProp3D(){ + return this->_newvol; +} +/** +** return the id from the daat +**/ +int wxMaracasMultipleVolumeRendererManagerData::getId(){ + return _id; +} +/** +** set data id +**/ +void wxMaracasMultipleVolumeRendererManagerData::setId(int propid){ + _id = propid; +} + +/** +** Get the filanme +**/ +std::string wxMaracasMultipleVolumeRendererManagerData::getDataname(){ + return _dataname; +} +/** +** Set the filanme +**/ +void wxMaracasMultipleVolumeRendererManagerData::setDataname(std::string dataname){ + _dataname = dataname; +} + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.h new file mode 100644 index 0000000..b117450 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.h @@ -0,0 +1,92 @@ +#ifndef wxMaracasMultipleVolumeRendererManagerData_H_ +#define wxMaracasMultipleVolumeRendererManagerData_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +class wxMaracasMultipleVolumeRendererManagerData { + +public: + wxMaracasMultipleVolumeRendererManagerData(vtkImageData* vol, std::string dataname=""); + ~wxMaracasMultipleVolumeRendererManagerData(); + + /** + ** Check if the variables are setted correctly + **/ + void checkInvariant(); + /** + ** get the prop3D + **/ + vtkProp3D* getProp3D(); + /** + ** return the id from the daat + **/ + int getId(); + /** + ** set data id + **/ + void setId(int propid); + /** + ** Get the filanme + **/ + std::string getDataname(); + /** + ** Set the filanme + **/ + void setDataname(std::string dataname); + + + /** + ** Set Volume Color + **/ + void setVolumeColor(std::vector& greylevel, + std::vector& red, + std::vector& green, + std::vector& blue); + + /** + ** Volume Opacity + **/ + void setVolumeOpacity(std::vector greylevel,std::vector value); + +protected: + /** + * Prop 3D (data actor) + */ + vtkImageData* _vol; + /** + * Dataname given by the user (ex. filename) + **/ + std::string _dataname; + + +private: + + /* + * id of the data + */ + int _id; + + vtkVolumeRayCastCompositeFunction *_compositeFunction; + vtkPlanes *_volumePlanes; + vtkVolumeRayCastMapper *_volumeMapper; + vtkVolumeProperty *_volumeProperty; + vtkVolume *_newvol; + vtkPiecewiseFunction* _tfun; + vtkColorTransferFunction* _ctfun; + + +}; + +#endif /*wxMaracasMultipleVolumeRendererManagerData_H_*/ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.cxx new file mode 100644 index 0000000..3327a85 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.cxx @@ -0,0 +1,124 @@ +#include "wxMaracasMultipleVolumeRendererPanel.h" + +#include +#include "wxMaracasMultipleVolumeRendererView.h" +#include "Color.xpm" +/** +** Implementation of viewProp3D +**/ + +wxMaracasMultipleVolumeRendererPanel::wxMaracasMultipleVolumeRendererPanel(wxWindow* parent,int propid, vtkImageData* img) +: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize) +{ + _propid = propid; + + createControls(img); +} + +wxMaracasMultipleVolumeRendererPanel::~wxMaracasMultipleVolumeRendererPanel(){ + //wxMaracasIRMView::getInstance()->addRemoveActor(_propid, false); + wxMaracasMultipleVolumeRendererView::getInstance()->deleteVolume(_propid); +} + +void wxMaracasMultipleVolumeRendererPanel::createControls(vtkImageData* img){ + + wxFlexGridSizer* sizerirmprop = new wxFlexGridSizer(1,1,1); + + wxString choices[2]; + choices[0] = wxString(_T("On")); + choices[1] = wxString(_T("Off")); + checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor"))); + Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange); + checkbox->SetValue(true); + + sizerirmprop->Add(checkbox,wxFIXED_MINSIZE); + + //this->addControl(checkbox); + + wxBitmap bitmap(Color_xpm); + _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30)); + Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onColorChange); + sizerirmprop->Add(_colorchoose,wxFIXED_MINSIZE); + + + this->SetSizer(sizerirmprop, true); + this->SetAutoLayout( true ); + + + + _frame = new wxFrame(this, 10, _T("Configure Transfer Functions")); + + wxButton* button1 = new wxButton(_frame,20,_T("OK")); + Connect(button1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onOK); + wxButton* button2 = new wxButton(_frame,30,_T("Cancel") ); + Connect(button2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCancel); + wxButton* button3 = new wxButton(_frame,40,_T("Update")); + Connect(button3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onUpdate); + + + mwxwidget = new HistogramWidget(_frame, -1); + + mwxwidget->initializeHistogram(img); + mwxwidget->Refresh(); + + wxBoxSizer* boxSizer0 = new wxBoxSizer(wxHORIZONTAL); + boxSizer0->Add(mwxwidget, 4, wxGROW); + + wxBoxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL); + boxSizer->AddSpacer(40); + boxSizer->Add(button1, wxCENTER); + boxSizer->AddSpacer(40); + boxSizer->Add(button2, wxCENTER); + boxSizer->AddSpacer(40); + boxSizer->Add(button3, wxCENTER); + + wxBoxSizer* boxsizer2 = new wxBoxSizer(wxVERTICAL); + boxsizer2->Add(boxSizer0,1,wxEXPAND); + boxsizer2->Add(boxSizer,0,wxCENTER); + + _frame->SetAutoLayout(true); + + + _frame->SetSizer(boxsizer2); + + _frame->Refresh(); + _frame->Update(); + +} +void wxMaracasMultipleVolumeRendererPanel::onOK(wxCommandEvent& event){ + updateVolume(); + _frame->Show(false); +} +void wxMaracasMultipleVolumeRendererPanel::onCancel(wxCommandEvent& event){ + _frame->Show(false); +} +void wxMaracasMultipleVolumeRendererPanel::onUpdate(wxCommandEvent& event){ + updateVolume(); +} +void wxMaracasMultipleVolumeRendererPanel::updateVolume(){ + std::vector greylevelcolors; + std::vector red; + std::vector green; + std::vector blue; + + std::vector greylevel; + std::vector values; + + mwxwidget->GetValuesColorPointsFunction(greylevelcolors, red, green, blue); + mwxwidget->GetValuesPointsFunction(greylevel, values); + + + wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesColorPointsFunction(this->_propid, greylevelcolors, red, green, blue); + wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesPointsFunction(this->_propid, greylevel, values); + +} +void wxMaracasMultipleVolumeRendererPanel::onColorChange(wxCommandEvent& event){ + _frame->Show(true); +} +void wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange(wxCommandEvent& event){ + wxMaracasMultipleVolumeRendererView::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue()); +} + +int wxMaracasMultipleVolumeRendererPanel::getPropId(){ + return _propid; +} \ No newline at end of file diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.h new file mode 100644 index 0000000..4e56b5c --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.h @@ -0,0 +1,33 @@ +#ifndef wxMaracasMultipleVolumeRendererPanel_H_ +#define wxMaracasMultipleVolumeRendererPanel_H_ + +#include +#include "HistogramWidget.h" + +class wxMaracasMultipleVolumeRendererPanel : public wxPanel{ + +public: + wxMaracasMultipleVolumeRendererPanel(wxWindow* parent, int propid, vtkImageData* img); + ~wxMaracasMultipleVolumeRendererPanel(); + void createControls(vtkImageData* img); + void onCheckBoxChange(wxCommandEvent& event); + void onColorChange(wxCommandEvent& event); + void onOK(wxCommandEvent& event); + void onCancel(wxCommandEvent& event); + void onUpdate(wxCommandEvent& event); + + void updateVolume(); + int getPropId(); + +private: + wxCheckBox* checkbox; + wxBitmapButton* _colorchoose; + + int _propid; + + HistogramWidget* mwxwidget; + wxFrame* _frame; + +}; + +#endif /*wxMaracasMultipleVolumeRendererPanel_H_*/ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.cxx new file mode 100644 index 0000000..539648a --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.cxx @@ -0,0 +1,195 @@ +/*========================================================================= + + Program: wxMaracas + Module: $RCSfile: wxMaracasMultipleVolumeRendererView.cxx,v $ + Language: C++ + Date: $Date: 2009/07/08 14:22:14 $ + Version: $Revision: 1.1 $ + + 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. + +=========================================================================*/ + + + +// EOF - wxMaracasMPR.cxx + +#include "wxMaracasMultipleVolumeRendererView.h" + + +#include +#include + +#include +#include + +wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::instance=NULL; + +wxMaracasMultipleVolumeRendererView::wxMaracasMultipleVolumeRendererView( wxWindow* parent,std::string path) +: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){ + + wxauimanager = new wxAuiManager(this); + + _path = path; + + volmanager = new wxMaracasMultipleVolumeRendererManager(); + std::string iconsdir = path; + iconsdir+="/data/Icons"; + this->_toolb = new ToolBarMultipleVolumeRenderer(this,iconsdir); + wxAuiPaneInfo paneinfo; + wxauimanager->AddPane(_toolb,paneinfo.ToolbarPane().Top()); + + wxauimanager->Update(); + +} +wxMaracasMultipleVolumeRendererView::~wxMaracasMultipleVolumeRendererView( ){ + + delete _toolb; + +} + +std::string wxMaracasMultipleVolumeRendererView::getPath(){ + return _path; +} + +wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::getInstance(wxWindow* parent,std::string path){ + if(instance==NULL){ + instance = new wxMaracasMultipleVolumeRendererView(parent,path); + } + return instance; +} + +wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::getInstance(){ + return instance; +} + +void wxMaracasMultipleVolumeRendererView::setRenderer(vtkRenderer* renderer){ + volmanager->setRenderer(renderer); +} + +void wxMaracasMultipleVolumeRendererView::addRemoveActor(int id, bool addremove){ + volmanager->addRemoveActor(id, addremove); +} + +void wxMaracasMultipleVolumeRendererView::onLoadImageFile(){ + + wxString mhd(_T("mhd")); + + wxFileDialog* fildial = new wxFileDialog(this, wxString(_T("Select a MHD file")),wxString(_T("")), + wxString(_T("")),wxString(_T("MHD files (*.mhd)|*.mhd")) ); + + if(fildial->ShowModal()==wxID_OK){ + wxString filename = fildial->GetFilename(); + wxString pathfile(fildial->GetDirectory() + _T("/") + filename); + if(filename.EndsWith(mhd)){ + loadVolume(pathfile,filename); + } + } + delete fildial; + +} + +void wxMaracasMultipleVolumeRendererView::addVolumeViewPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname){ + + wxString s(dataname.c_str(),wxConvUTF8 ); + wxAuiPaneInfo paneinfo; + wxauimanager->AddPane(irmview, paneinfo.DefaultPane().Centre().DestroyOnClose().Caption(s)); + wxauimanager->Update(); + + +} + +void wxMaracasMultipleVolumeRendererView::addVolume(vtkImageData* img, std::string dataname){ + + try{ + int id = volmanager->addVolume(img,dataname); + if(id!=-1){ + wxMaracasMultipleVolumeRendererPanel* controlpan = new wxMaracasMultipleVolumeRendererPanel(this, id,img); + addVolumeViewPanel(controlpan, dataname); + } + }catch(char* str){ + std::cout << "Exception : " << str << '\n'; + wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR); + diag->ShowModal(); + } +} + +void wxMaracasMultipleVolumeRendererView::loadVolume(wxString filename, wxString dataname){ + + std::string s = std::string(filename.mb_str()); + vtkImageData* img = volmanager->getImageData(s); + if(img!=NULL){ + s = std::string(dataname.mb_str()); + addVolume(img, s); + } + +} + +void wxMaracasMultipleVolumeRendererView::deleteVolume(int volid){ + volmanager->deleteActor(volid); +} + +void wxMaracasMultipleVolumeRendererView::SetValuesColorPointsFunction(int volid, std::vector greylevelcolors,std::vector red,std::vector green,std::vector blue){ + volmanager->setVolumeColor(volid, greylevelcolors, red, green, blue); +} +void wxMaracasMultipleVolumeRendererView::SetValuesPointsFunction(int volid, std::vector greylevel, std::vector values){ + volmanager->setVolumeOpacity(volid, greylevel, values); +} + +/** +** +**/ + +ToolBarMultipleVolumeRenderer::ToolBarMultipleVolumeRenderer(wxWindow * parent,std::string iconsdir) +: wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize) +{ + + + std::string iconfil = iconsdir; + + //iconfil+= "/OpenImage.png"; + //wxBitmap* bitmap0 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG); + wxBitmap bitmap0(OpenImage_xpm); + this->AddTool(1, wxString(_T("test")),bitmap0); + + /*iconfil+= "/Open.png"; + wxBitmap* bitmap2 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG); + this->AddTool(2, wxString(_T("test")),*bitmap2); */ + + /*iconfil = iconsdir; + iconfil+= "/Open.png"; + wxBitmap* bitmap30 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG); + this->AddTool(30, wxString(_T("test")),*bitmap30);*/ + + this->Realize(); + + _evthand = new ToolBarEventHandlerMultipleVolumeRenderer(); + this->SetEventHandler(_evthand); + +} + +ToolBarMultipleVolumeRenderer::~ToolBarMultipleVolumeRenderer(void){ +} + +ToolBarEventHandlerMultipleVolumeRenderer::ToolBarEventHandlerMultipleVolumeRenderer() +: wxEvtHandler(){ +} +ToolBarEventHandlerMultipleVolumeRenderer::~ToolBarEventHandlerMultipleVolumeRenderer(){ +} + +void ToolBarEventHandlerMultipleVolumeRenderer::onLoadImageFile(wxCommandEvent& event){ + wxMaracasMultipleVolumeRendererView::getInstance()->onLoadImageFile(); +} + + + +BEGIN_EVENT_TABLE(ToolBarEventHandlerMultipleVolumeRenderer, wxEvtHandler) + EVT_MENU(1, ToolBarEventHandlerMultipleVolumeRenderer::onLoadImageFile) +END_EVENT_TABLE() + + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.h new file mode 100644 index 0000000..3272b0d --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.h @@ -0,0 +1,106 @@ +/*========================================================================= + + Program: wxMaracas + Module: $RCSfile: wxMaracasMultipleVolumeRendererView.h,v $ + Language: C++ + Date: $Date: 2009/07/08 14:22:14 $ + Version: $Revision: 1.1 $ + + 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. + +=========================================================================*/ + +#ifndef __wxMaracasMultipleVolumeRendererViewPanelH__ +#define __wxMaracasMultipleVolumeRendererViewPanelH__ + +#include +#include +#include "wx/aui/aui.h" +#include +#include "marTypes.h" +#include "vtkProp3D.h" + +#include "wxMaracasMultipleVolumeRendererManager.h" +#include "wxMaracasMultipleVolumeRendererPanel.h" + + + +class creaMaracasVisu_EXPORT wxMaracasMultipleVolumeRendererView : public wxPanel +{ + +public: + wxMaracasMultipleVolumeRendererView( wxWindow* parent, std::string path); + ~wxMaracasMultipleVolumeRendererView( ); + + static wxMaracasMultipleVolumeRendererView* getInstance(wxWindow* parent,std::string path=""); + + static wxMaracasMultipleVolumeRendererView* getInstance(); + + void setRenderer(vtkRenderer* renderer); + + void addVolume(vtkImageData* img, std::string dataname=""); + + void loadVolume(wxString filename, wxString dataname); + + void onLoadImageFile(); + + void addVolumeRendererPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname=""); + + std::string getPath(); + + void deleteVolume(int volid); + + void addRemoveActor(int id, bool remove); + + void SetValuesColorPointsFunction(int volid, std::vector greylevelcolors,std::vector red,std::vector green,std::vector blue); + void SetValuesPointsFunction(int volid, std::vector greylevel, std::vector values); + + void addVolumeViewPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname); + +private: + static wxMaracasMultipleVolumeRendererView* instance; + + wxMaracasMultipleVolumeRendererManager* volmanager; + + wxAuiManager* wxauimanager; + + std::string _path; + + wxToolBar* _toolb; + +}; + +class ToolBarEventHandlerMultipleVolumeRenderer : public wxEvtHandler{ + + public: + ToolBarEventHandlerMultipleVolumeRenderer(); + ~ToolBarEventHandlerMultipleVolumeRenderer(); + + void onLoadImageFile(wxCommandEvent& event); + + private: + + DECLARE_EVENT_TABLE() + }; + +class ToolBarMultipleVolumeRenderer : public wxToolBar{ + + +public: + ToolBarMultipleVolumeRenderer(wxWindow * parent,std::string iconsdir); + ~ToolBarMultipleVolumeRenderer(void); + + +private: + + ToolBarEventHandlerMultipleVolumeRenderer* _evthand; + +}; + +#endif + -- 2.45.1