]> Creatis software - creaMaracasVisu.git/commitdiff
*** empty log message ***
authorJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Wed, 8 Jul 2009 14:22:08 +0000 (14:22 +0000)
committerJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Wed, 8 Jul 2009 14:22:08 +0000 (14:22 +0000)
26 files changed:
bbtk/src/bbcreaMaracasVisuIRMViewer.cxx
bbtk/src/bbcreaMaracasVisuVolumeRendering.cxx
bbtk/src/bbcreaMaracasVisuVolumeRendering.h
bbtk/src/bbmaracasvisuTransferFunctionView.cxx
bbtk/src/bbmaracasvisuTransferFunctionView.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pColorBar.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotter.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotter.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleY.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.h [new file with mode: 0644]

index c09a5156ee4d047633a6b026de26a5b380958105..2feba98c693666574ba87e9818503dafae670f6b 100644 (file)
@@ -16,8 +16,6 @@ void IRMViewer::Process()
        std::vector<vtkProp3D*> tempvect;
        int i;
 
-       
-
        if(irmview != NULL){
                vtkRenderer* renderer = bbGetInputRenderer();
                irmview->setRenderer(renderer);
index 5cfc7e9eec0e107200ff51193803b658c672b3fd..80326a21c0958401569be0ca08b5de6328203619 100644 (file)
@@ -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()
 {
index 0d1d5b40bf7bf0939169c1d78f3972e01a5bce9f..27ba054bc05841f8dd5cf6bfd5c9d6a1aaa3e0f2 100644 (file)
@@ -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 <vtkVolumeRayCastCompositeFunction.h>
-#include <vtkPlanes.h>
-#include <vtkVolumeRayCastMapper.h>
-#include <vtkVolumeProperty.h>
-#include <vtkVolume.h>
-#include <vtkPiecewiseFunction.h>
-#include <vtkColorTransferFunction.h>
+
 #include <vtkImageData.h>
-#include <vtkProp3D.h>
+#include <vtkRenderer.h>
 
 
 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<double> );
+       BBTK_DECLARE_INPUT(Value, std::vector<double> );
+       BBTK_DECLARE_INPUT(GreyLevelColors, std::vector<double>);
+       BBTK_DECLARE_INPUT(Red, std::vector<double>);
+       BBTK_DECLARE_INPUT(Green, std::vector<double>);
+       BBTK_DECLARE_INPUT(Blue, std::vector<double>);*/
+       //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<double>,"");
+  BBTK_INPUT(VolumeRendering,Value,"Value of the transparency in the transfer function",std::vector<double>,"");
+  BBTK_INPUT(VolumeRendering,GreyLevelColors,"Grey level of the color in the transfer function",std::vector<double>,"");
+  BBTK_INPUT(VolumeRendering,Red,"Red value according to the GreyLevelColors",std::vector<double>,"");
+  BBTK_INPUT(VolumeRendering,Green,"Green value according to the GreyLevelColors",std::vector<double>,"");
+  BBTK_INPUT(VolumeRendering,Blue,"Blue value according to the GreyLevelColors",std::vector<double>,"");*/
 BBTK_END_DESCRIBE_BLACK_BOX(VolumeRendering);
 }
 // EO namespace bbcreaMaracasVisu
index f95262df8dfc5aeea3d6a8e3df77254a50ae65ca..137f82b6b61a2eeb815732bfeded97b975773fda 100644 (file)
@@ -9,13 +9,56 @@ BBTK_BLACK_BOX_IMPLEMENTATION(TransferFunctionView,bbtk::WxBlackBox);
 //-----------------------------------------------------
 void TransferFunctionView::Process()
 {
-       if(bbGetInputIn()!=NULL){
-               mwxwidget->initializeHistogram(bbGetInputIn()); 
-               mwxwidget->Refresh();
-       }
-       
+
+       std::vector<double> greylevel;
+       std::vector<double> value;
+
+       std::vector<double> greylevelcolors;
+       std::vector<double> red;
+       std::vector<double> green;
+       std::vector<double> 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 "<<greylevel[i]<<" "<< value[i]<<std::endl;
+               }
+               _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 "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
+               }               
+
+
+               bbSetOutputOpacityFunction(_tfun);
+               bbSetOutputColorFunction(_ctfun);
+               /*bbSetOutputGreyLevel(greylevel);
+               bbSetOutputValue(value);
+               bbSetOutputGreyLevelColors(greylevelcolors);
+               bbSetOutputRed(red);
+               bbSetOutputGreen(green);
+               bbSetOutputBlue(blue);*/
+
+
+
+
+       }
+               
+    
 }
 
 //-----------------------------------------------------
@@ -32,6 +75,10 @@ void TransferFunctionView::CreateWidget(wxWindow* parent)
 void TransferFunctionView::bbUserSetDefaultValues()
 {
        mwxwidget = NULL;
+       _currentimg = NULL;
+
+       _tfun = NULL;
+       _ctfun = NULL;   
 
 }
 
@@ -39,6 +86,8 @@ void TransferFunctionView::bbUserSetDefaultValues()
        //-----------------------------------------------------------------     
        void TransferFunctionView::bbUserInitializeProcessing()
        {
+               _tfun = vtkPiecewiseFunction::New();
+               _ctfun = vtkColorTransferFunction::New();   
                bbSetInputIn(NULL);
        }
        
index e9c3b08148b4f0a08ba0eae7bec6b8de9edd7205..5f7a0fe8ed4999a3df9f79b1ccfbab416b33c5df 100644 (file)
@@ -6,6 +6,9 @@
 #include "vtkImageData.h"
 #include "HistogramWidget.h"
 
+#include "vtkPiecewiseFunction.h"
+#include "vtkColorTransferFunction.h"
+
 namespace bbcreaMaracasVisu
 {
 
@@ -15,6 +18,15 @@ class /*BBTK_EXPORT*/ TransferFunctionView
 {
   BBTK_BLACK_BOX_INTERFACE(TransferFunctionView,bbtk::WxBlackBox);
        BBTK_DECLARE_INPUT(In, vtkImageData*);
+       BBTK_DECLARE_OUTPUT(OpacityFunction, vtkPiecewiseFunction*);
+       BBTK_DECLARE_OUTPUT(ColorFunction, vtkColorTransferFunction*);
+       /*BBTK_DECLARE_OUTPUT(GreyLevel, std::vector<double> );
+       BBTK_DECLARE_OUTPUT(Value, std::vector<double> );
+       BBTK_DECLARE_OUTPUT(GreyLevelColors, std::vector<double>);
+       BBTK_DECLARE_OUTPUT(Red, std::vector<double>);
+       BBTK_DECLARE_OUTPUT(Green, std::vector<double>);
+       BBTK_DECLARE_OUTPUT(Blue, std::vector<double>);*/
+
   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<double>,"");
+  BBTK_OUTPUT(TransferFunctionView,Value,"Value of the transparency in the transfer function",std::vector<double>,"");
+  BBTK_OUTPUT(TransferFunctionView,GreyLevelColors,"Grey level of the color in the transfer function",std::vector<double>,"");
+  BBTK_OUTPUT(TransferFunctionView,Red,"Red value according to the GreyLevelColors",std::vector<double>,"");
+  BBTK_OUTPUT(TransferFunctionView,Green,"Green value according to the GreyLevelColors",std::vector<double>,"");
+  BBTK_OUTPUT(TransferFunctionView,Blue,"Blue value according to the GreyLevelColors",std::vector<double>,"");*/
 BBTK_END_DESCRIBE_BLACK_BOX(TransferFunctionView);
 }
 // EO namespace bbcreaMaracasVisu
index d5dd0d772b6a63f7b31143de3cbbc4291242840c..1badcefd5ddff0a367a7622d46443ede3ecddf04 100644 (file)
@@ -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<double>& greylevel,std::vector<double>& 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<double>& greylevel,
+                                                               std::vector<double>& red,
+                                                               std::vector<double>& green,
+                                                               std::vector<double>& blue)
+       {
+               plotter->GetValuesColorPointsFunction(greylevel,red,green,blue);
+       }
index 7b48d59f6a317fe33be226db9582d475e07675cc..3947d320424c585061008a0c64df0f85f3994e7d 100644 (file)
@@ -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<double>& greylevel,std::vector<double>& 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<double>& greylevel,
+                                                                       std::vector<double>& red,
+                                                                       std::vector<double>& green,
+                                                                       std::vector<double>& blue);
 
 
 private:
index 4b37ef916bcf6c4722029202a8758f120a407f1a..fc7203f6be4fac7673d9efbf32ad21f92bc6845f 100644 (file)
@@ -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);
index e8b67dc375c238f2fbf67a485e8cfd50ee2eea0b..0856926539196dbf1f63d73607b18d976191d6d8 100644 (file)
@@ -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);
index c735b345c4be550e424cd0407db4e5a5bdfae4d9..d83e4d43e146606b8d9ef78a514c0b06adac22cb 100644 (file)
@@ -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)
                {
index a425cb98722d34aacba2500264ab11a76f0c2b84..c02da995befa6c75f63f27782b5a3d609dd50f38 100644 (file)
@@ -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++ )
                {
index 28c7d306a23d5cc167f3048560f006bdc7fc4207..19a2af26fdd5a52a5382221e5367b1cebb286b3e 100644 (file)
@@ -149,6 +149,7 @@ void pHistogram::setPoints(vtkImageData* imageData)
        */
        maxLevelOfGrey=(int)range[1];
        minLevelOfGrey=(int)range[0];
+       //std::cout<<"maxLevelOfGrey "<<maxLevelOfGrey<<" minLevelOfGrey "<<minLevelOfGrey<<std::endl;
        /*
         Image Size
        */
@@ -184,6 +185,7 @@ void pHistogram::setPoints(vtkImageData* imageData)
                //j=p*k;
                
                j=getIndex(*dataImagePointer);
+               //std::cout<<j<<std::endl;
                dataHistogramPointer[j]++;
                dataImagePointer++;
        }
@@ -213,8 +215,10 @@ image
 */
 int pHistogram::getIndex(int gValue)
 {
-       double p=((float)gValue-minLevelOfGrey)/(maxLevelOfGrey-minLevelOfGrey);
+
+       double p=((double)gValue-minLevelOfGrey)/(maxLevelOfGrey-minLevelOfGrey);
        double k=p*(size-1);
+       //std::cout<<"gValue "<<gValue<<" k "<<k<<std::endl;
        return (int)k;
 }
 /*
index 81726093f4c39d38fe68d4a972afa3b65c5ed63a..643743ca0d422b17f2598dc3f523bb40cffdf430 100644 (file)
@@ -717,5 +717,55 @@ void pPlotter :: sendTMessage(wxString theText)
        */
        
 
+/**
+**     Returns two vectors, the grey level of the point and its value, the value is between [0,1]
+**/
+void pPlotter::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& 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<double>& greylevel,
+                                                               std::vector<double>& red,
+                                                               std::vector<double>& green,
+                                                               std::vector<double>& blue)
+{
+
+       if(color_bar != NULL){
+
+               std::vector<pColorPoint*> 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);
+               }               
+       }
+}
+
+
 
 
index 5049e85955fdc5c718ad6efddfe4c7f191e02237..e648a9ab55b4507edebf1c829e0dd05d4d2b46de 100644 (file)
@@ -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<double>& greylevel,std::vector<double>& 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<double>& greylevel,
+                                                                       std::vector<double>& red,
+                                                                       std::vector<double>& green,
+                                                                       std::vector<double>& blue);
+       
        //----------------------------------------------------------------------------------------
        // Attributes declration
        //----------------------------------------------------------------------------------------
index 37c7ba27e888de661a642d41591f83af455fd833..c8c64d66267484952324d736535856044a361b7b 100644 (file)
@@ -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<double> vx=getXSpline();
        std::vector<double> 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));
                }
        }
    
index ca89d1b30435ecf5f3095b7df39eb96c96b20aa7..5ef2f599dba924959942b5aba7ba3f61b0604d1c 100644 (file)
@@ -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
index 28ce942f508b5d6aff296d4b6207c2737081553c..45d0abe3b71b5b970551bccee8611be282e3839b 100644 (file)
@@ -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));
 
 }
 
index 18d585ecbd1a990676b7b23595e8794bc56e012b..2f3ba1d668fdd612683f8741dee22c2b372bbd56 100644 (file)
@@ -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 (file)
index 0000000..16186ba
--- /dev/null
@@ -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 <vtkMetaImageReader.h>
+/**
+**     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<double> greylevel,std::vector<double> value)  throw(char*){
+       checkInvariant();               
+
+       this->getViewData(propid)->setVolumeOpacity(greylevel, value);
+       
+       _renderer->Render();
+
+}
+
+/**
+**     Set Volume Color
+**/
+void wxMaracasMultipleVolumeRendererManager::setVolumeColor(int volid, std::vector<double> greylevel,
+                                                               std::vector<double> red,
+                                                               std::vector<double> green,
+                                                               std::vector<double> 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 (file)
index 0000000..ae206c2
--- /dev/null
@@ -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 <iostream>
+#include <vector>
+
+#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<double> greylevel,std::vector<double> value);
+       /**
+       **      Set Volume Color
+       **/
+       void setVolumeColor(int volid, std::vector<double> greylevel,
+                                                                       std::vector<double> red,
+                                                                       std::vector<double> green,
+                                                                       std::vector<double> 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<wxMaracasMultipleVolumeRendererManagerData*> 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 (file)
index 0000000..de064e3
--- /dev/null
@@ -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<double>& greylevelcolors,
+                                                               std::vector<double>& red,
+                                                               std::vector<double>& green,
+                                                               std::vector<double>& 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 "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
+       }               
+       _newvol->Update();      
+}
+                               
+/**
+**     Volume Opacity
+**/
+void wxMaracasMultipleVolumeRendererManagerData::setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value){
+               
+       _tfun->RemoveAllPoints();
+       for(int i = 0; i < greylevel.size();i++){
+               _tfun->AddPoint(greylevel[i], value[i]);
+//                     std::cout<<"transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
+       }
+    _newvol->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 (file)
index 0000000..b117450
--- /dev/null
@@ -0,0 +1,92 @@
+#ifndef wxMaracasMultipleVolumeRendererManagerData_H_
+#define wxMaracasMultipleVolumeRendererManagerData_H_
+
+#include <vtkVolumeRayCastCompositeFunction.h>
+#include <vtkPlanes.h>
+#include <vtkVolumeRayCastMapper.h>
+#include <vtkVolumeProperty.h>
+#include <vtkVolume.h>
+#include <vtkPiecewiseFunction.h>
+#include <vtkColorTransferFunction.h>
+#include <vtkImageData.h>
+#include <vtkProp3D.h>
+#include <vtkRenderer.h>
+
+#include <vector>
+
+
+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<double>& greylevel,
+                                                                       std::vector<double>& red,
+                                                                       std::vector<double>& green,
+                                                                       std::vector<double>& blue);     
+
+       /**
+       **      Volume Opacity
+       **/
+       void setVolumeOpacity(std::vector<double> greylevel,std::vector<double> 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 (file)
index 0000000..3327a85
--- /dev/null
@@ -0,0 +1,124 @@
+#include "wxMaracasMultipleVolumeRendererPanel.h"
+
+#include <wx/colordlg.h>
+#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<double> greylevelcolors;
+       std::vector<double> red;
+       std::vector<double> green;
+       std::vector<double> blue;
+
+       std::vector<double> greylevel;
+       std::vector<double> 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 (file)
index 0000000..4e56b5c
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef wxMaracasMultipleVolumeRendererPanel_H_
+#define wxMaracasMultipleVolumeRendererPanel_H_
+
+#include <wx/wx.h>
+#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 (file)
index 0000000..539648a
--- /dev/null
@@ -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 <wx/colordlg.h>
+#include <wx/bmpbuttn.h>
+
+#include <OpenImage.xpm>
+#include <Color.xpm>
+
+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<double> greylevelcolors,std::vector<double> red,std::vector<double> green,std::vector<double> blue){
+       volmanager->setVolumeColor(volid, greylevelcolors, red, green, blue);
+}
+void wxMaracasMultipleVolumeRendererView::SetValuesPointsFunction(int volid, std::vector<double> greylevel, std::vector<double> 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 (file)
index 0000000..3272b0d
--- /dev/null
@@ -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 <vector>
+#include <wx/wx.h>
+#include "wx/aui/aui.h"
+#include <iostream>
+#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<double> greylevelcolors,std::vector<double> red,std::vector<double> green,std::vector<double> blue);
+       void SetValuesPointsFunction(int volid, std::vector<double> greylevel, std::vector<double> 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
+