]> Creatis software - creaMaracasVisu.git/commitdiff
*** empty log message ***
authorJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Mon, 20 Jul 2009 10:06:10 +0000 (10:06 +0000)
committerJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Mon, 20 Jul 2009 10:06:10 +0000 (10:06 +0000)
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManager.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererPanel.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.h

index 681263e93b8fb3b60537cc0df47260909ea558c2..a60429eaad88f0730d6b8eb046f0cb4765048daa 100644 (file)
@@ -80,6 +80,70 @@ HistogramDialog::HistogramDialog(wxWindow *parent,wxString title,vtkImageData* i
        SetBestSize(wxSize(600,600));
 }
 
+HistogramDialog::HistogramDialog(wxWindow *parent,wxString title)
+:wxDialog(parent,-1,title,wxDefaultPosition,wxDefaultSize,wxRESIZE_BORDER|wxDEFAULT_DIALOG_STYLE   ,_T("dialogBox")){
+       _ctfun=NULL;
+       _tfun=NULL;
+
+       SetBackgroundColour(wxColour(255,255,255));
+       /*
+       Pointers
+       */
+       wxvtkmpr3Dview=NULL;
+       wxvtkclipping3Dview=NULL;
+       
+       /*
+        Histogram
+       */
+       
+       histogramW=new HistogramWidget(this, -1);
+       
+       refreshed=false;
+
+       /*
+       Buttons
+       */
+       okBtn = new wxButton(this,wxID_OK ,_T("OK"));
+       cancelBtn = new wxButton(this,wxID_CANCEL,_T("Cancel"));
+       
+       saveDataBtn = new wxButton(this,ID_SAVE,_T("Save"));
+       loadDataBtn = new wxButton(this,ID_LOAD,_T("Load"));
+       refreshBtn = new wxButton(this,ID_REFRESH,_T("Refresh"));
+       
+       Connect(saveDataBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &HistogramDialog::OnSaveData       );
+       Connect(loadDataBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &HistogramDialog::OnLoadData       );
+       Connect(refreshBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &HistogramDialog::OnRefreshBtn      );
+       
+       //-------------------
+       //GUI
+       //-------------------
+       
+       //Upper Box
+       wxBoxSizer * upper_box = new wxBoxSizer( wxHORIZONTAL );
+       //Including components for plotter control
+       upper_box->Add( histogramW, 4, wxGROW);
+       
+
+       //bottom Sizer
+       wxBoxSizer *bottomBox = new wxBoxSizer( wxHORIZONTAL );
+       bottomBox->Add( okBtn, wxSizerFlags().Center());
+       bottomBox->AddSpacer(40);
+       bottomBox->Add( saveDataBtn,wxSizerFlags().Center() );
+       bottomBox->AddSpacer(40);
+       bottomBox->Add( loadDataBtn,wxSizerFlags().Center() );
+       bottomBox->AddSpacer(40);
+       bottomBox->Add( refreshBtn,wxSizerFlags().Center() );
+       bottomBox->AddSpacer(40);
+       bottomBox->Add( cancelBtn,wxSizerFlags().Center() );
+       //Sizer
+       wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+       sizer->Add(upper_box,1,wxEXPAND);       
+    sizer->Add(bottomBox,0,wxCENTER);
+       SetAutoLayout( TRUE );
+       SetSizer( sizer );
+       SetBestSize(wxSize(600,600));
+}
+
 //-----------------------
 //Handling events
 //-----------------------
@@ -488,3 +552,33 @@ void HistogramDialog::OnRefreshBtn(wxCommandEvent &event)
        }
 
 
+/**
+**     Initialize the histogram 
+*/
+       void HistogramDialog::initializeHistogram(vtkImageData* img){
+               histogramW->initializeHistogram(img);
+       }
+/**
+**     Returns two vectors, the grey level of the point and its value, the value is between [0,1]
+**/
+       void HistogramDialog::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value){
+
+               histogramW->GetValuesPointsFunction(greylevel, value);
+       }
+
+/**
+**     Returns two vectors, the grey level of the point and its value, the red, green
+**     and blue value is between [0,1]
+**/
+void HistogramDialog::GetValuesColorPointsFunction(std::vector<double>& greylevel,
+                                                               std::vector<double>& red,
+                                                               std::vector<double>& green,
+                                                               std::vector<double>& blue)
+{
+       histogramW->GetValuesColorPointsFunction(greylevel, red, green, blue);
+}
+
+void HistogramDialog::SetFunctions(vtkPiecewiseFunction* _opac, vtkColorTransferFunction* _color){
+       _tfun = _opac;
+       _ctfun = _color;        
+}
\ No newline at end of file
index a23cd3b2e528ec92db0ddab3627b1ca28fde85a9..d1881f6dd883cd620d5f09ade7825d24ccb11732 100644 (file)
@@ -34,6 +34,10 @@ public:
         Constructor
        */
        HistogramDialog(wxWindow *parent,wxString title,vtkImageData* imageData,int type);
+       /*
+        Constructor
+       */
+       HistogramDialog(wxWindow *parent,wxString title);
        /*
         Methods
        */
@@ -124,7 +128,25 @@ public:
        void OnSaveData(wxCommandEvent& event);
        void OnLoadData(wxCommandEvent& event);
        void OnRefreshBtn(wxCommandEvent& event);
-       
+
+       /**
+       **      Initialize the histogram 
+       */
+       void initializeHistogram(vtkImageData* img);
+       /**
+       **      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);
+       void SetFunctions(vtkPiecewiseFunction* _opac, vtkColorTransferFunction* _color);
 private:
        /*
        Histogram Widget
index 3947d320424c585061008a0c64df0f85f3994e7d..28c5184de22bb4bf31659c1b65a9972c3f4feffa 100644 (file)
@@ -41,7 +41,7 @@ public:
        HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag,vtkImageData* imageData,int type);
 
        HistogramWidget( wxWindow *parent, wxWindowID id);
-       void initializeHistogram(vtkImageData* img);
+       
        ~HistogramWidget();
 
        /*
@@ -136,6 +136,10 @@ public:
        int getHistogramSize();
        void setType(int type);
 
+       /**
+       **      Initialize the histogram 
+       */
+       void initializeHistogram(vtkImageData* img);
        /**
        **      Returns two vectors, the grey level of the point and its value, the value is between [0,1]
        **/
index 980ac8dbf7c3bd5d4dc6e88ae0699f3aeb132302..c95a8bc98f22f3ff23aa20456436863b4d55904c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracasMultipleVolumeRendererManager.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/07/10 13:18:24 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2009/07/20 10:06:12 $
+  Version:   $Revision: 1.3 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -102,7 +102,8 @@ vtkImageData* wxMaracasMultipleVolumeRendererManager::getImageData(std::string f
                vtkMetaImageReader* reader =  vtkMetaImageReader::New();        
                reader->SetFileName(filename.c_str());
                reader->Update();
-               vtkImageData* img = reader->GetOutput();                
+               vtkImageData* img = reader->GetOutput();        
+
                vtkImageCast* cast = vtkImageCast::New(); 
                cast->SetInput(img);
                cast->SetOutputScalarTypeToUnsignedShort();
@@ -110,6 +111,7 @@ vtkImageData* wxMaracasMultipleVolumeRendererManager::getImageData(std::string f
                //reader->Delete();
                //img->Delete();
                return cast->GetOutput();
+               //return img;
        }       
        return NULL;
 }
@@ -158,3 +160,11 @@ void wxMaracasMultipleVolumeRendererManager::deleteActor(int propid) throw (char
        }       
     
 }
+
+vtkPiecewiseFunction* wxMaracasMultipleVolumeRendererManager::GetTransferFunction(int volumeid){
+       return getViewData(volumeid)->GetTransferFunction();
+}
+vtkColorTransferFunction* wxMaracasMultipleVolumeRendererManager::GetColorFunction(int volumeid){
+
+       return getViewData(volumeid)->GetColorFunction();
+}
index cb55609fdcded0d655f8eda1a651704f0b8e88ae..0e64ccd901ff4947fd3ac203687cbd0809706af7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracasMultipleVolumeRendererManager.h,v $
   Language:  C++
-  Date:      $Date: 2009/07/08 15:14:03 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2009/07/20 10:06:12 $
+  Version:   $Revision: 1.3 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -82,6 +82,8 @@ public:
        **/
        void deleteActor(int volumeid)throw (char *);
        
+       vtkPiecewiseFunction* GetTransferFunction(int volumeid);
+       vtkColorTransferFunction* GetColorFunction(int volumeid);
 private:       
        std::vector<wxMaracasMultipleVolumeRendererManagerData*> prop3Dvect;
 
index b117450246c7e622b6434678ba1889ac474f2eaf..b1ad57e7e8d794bc2647c3e57ae5dc17cbbccc7a 100644 (file)
@@ -59,6 +59,13 @@ public:
        **      Volume Opacity
        **/
        void setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value);
+
+       vtkPiecewiseFunction* GetTransferFunction(){
+               return _tfun;
+       }
+       vtkColorTransferFunction* GetColorFunction(){
+               return _ctfun;
+       }
        
 protected:
        /**
index 3327a852fc274172cbd9fe62fa369fa671dadbdb..6337f764210bbe01be1d5354aaf34b9e1599a489 100644 (file)
@@ -3,6 +3,7 @@
 #include <wx/colordlg.h>
 #include "wxMaracasMultipleVolumeRendererView.h"
 #include "Color.xpm"
+//#include <vtkImageCast.h>
 /**
 **     Implementation of viewProp3D
 **/
@@ -18,6 +19,7 @@ wxMaracasMultipleVolumeRendererPanel::wxMaracasMultipleVolumeRendererPanel(wxWin
 wxMaracasMultipleVolumeRendererPanel::~wxMaracasMultipleVolumeRendererPanel(){ 
        //wxMaracasIRMView::getInstance()->addRemoveActor(_propid, false);
        wxMaracasMultipleVolumeRendererView::getInstance()->deleteVolume(_propid);
+       delete mwxwidget;
 }
 
 void wxMaracasMultipleVolumeRendererPanel::createControls(vtkImageData* img){
@@ -31,9 +33,7 @@ void wxMaracasMultipleVolumeRendererPanel::createControls(vtkImageData* img){
        Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange);     
        checkbox->SetValue(true);       
 
-       sizerirmprop->Add(checkbox,wxFIXED_MINSIZE);
-
-       //this->addControl(checkbox);   
+       sizerirmprop->Add(checkbox,wxFIXED_MINSIZE);    
        
        wxBitmap bitmap(Color_xpm);
        _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));    
@@ -46,22 +46,39 @@ void wxMaracasMultipleVolumeRendererPanel::createControls(vtkImageData* img){
 
     
 
-       _frame = new wxFrame(this, 10, _T("Configure Transfer Functions"));     
+       //_frame = new wxFrame(this, 10, _T("Configure Transfer Functions"));   
 
-       wxButton* button1 = new wxButton(_frame,20,_T("OK"));
+       /*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);                                
-
+       Connect(button3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onUpdate);                                */
 
-       mwxwidget = new HistogramWidget(_frame, -1);
 
+       mwxwidget = new HistogramDialog(this, _T("Color Transfer Function"));
        mwxwidget->initializeHistogram(img);
-       mwxwidget->Refresh();
 
-       wxBoxSizer* boxSizer0 = new wxBoxSizer(wxHORIZONTAL);
+       mwxwidget->erasePointsTransferenceFunction();
+       double range[2];
+       img->GetScalarRange(range);
+       double max = range[1];
+
+       /*
+       adding the poinst of the transference function
+       */
+       //X
+       mwxwidget->addPointToTransferenceFunction(max * 0/2,0.0);
+       mwxwidget->addPointToTransferenceFunction(max * 1/2,100.0);
+       mwxwidget->addPointToTransferenceFunction(max * 2/2,100.0);
+
+       mwxwidget->addColorPoint(max*0/4,(int)(0.0*255),(int)(0.0*255),(int)(0.0*255));
+       mwxwidget->addColorPoint(max*1/4,(int)(1.0*255),(int)(0.0*255),(int)(0.0*255));
+       mwxwidget->addColorPoint(max*2/4,(int)(0.0*255),(int)(0.0*255),(int)(1.0*255));
+       mwxwidget->addColorPoint(max*3/4,(int)(0.0*255),(int)(1.0*255),(int)(0.0*255));
+       mwxwidget->addColorPoint(max*4/4,(int)(0.0*255),(int)(0.0*255),(int)(0.2*255)); 
+
+       /*wxBoxSizer* boxSizer0 = new wxBoxSizer(wxHORIZONTAL);
        boxSizer0->Add(mwxwidget, 4, wxGROW);
 
        wxBoxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL);
@@ -82,15 +99,17 @@ void wxMaracasMultipleVolumeRendererPanel::createControls(vtkImageData* img){
     _frame->SetSizer(boxsizer2);
 
        _frame->Refresh();
-       _frame->Update();
-       
+       _frame->Update();*/     
+       mwxwidget->SetFunctions(wxMaracasMultipleVolumeRendererView::getInstance()->GetTransferFunction(getPropId()),
+                                                       wxMaracasMultipleVolumeRendererView::getInstance()->GetColorFunction(getPropId()));
+       mwxwidget->Refresh();   
 }
 void wxMaracasMultipleVolumeRendererPanel::onOK(wxCommandEvent& event){
     updateVolume();
-       _frame->Show(false);
+       //_frame->Show(false);
 }
 void wxMaracasMultipleVolumeRendererPanel::onCancel(wxCommandEvent& event){
-       _frame->Show(false);
+       //_frame->Show(false);
 }
 void wxMaracasMultipleVolumeRendererPanel::onUpdate(wxCommandEvent& event){
        updateVolume();    
@@ -112,8 +131,12 @@ void wxMaracasMultipleVolumeRendererPanel::updateVolume(){
        wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesPointsFunction(this->_propid, greylevel, values);
 
 }
-void wxMaracasMultipleVolumeRendererPanel::onColorChange(wxCommandEvent& event){
-    _frame->Show(true);    
+void wxMaracasMultipleVolumeRendererPanel::onColorChange(wxCommandEvent& event){       
+
+       if(mwxwidget->ShowModal()==wxID_OK){
+        updateVolume();
+               mwxwidget->Show(false);
+       }       
 }
 void wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange(wxCommandEvent& event){    
        wxMaracasMultipleVolumeRendererView::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());    
index 4e56b5ccdc3bb2f1ce236622970ae9512e88d0c1..13d240529d646ad97b3c601f4dc5db2e51047195 100644 (file)
@@ -2,7 +2,7 @@
 #define wxMaracasMultipleVolumeRendererPanel_H_
 
 #include <wx/wx.h>
-#include "HistogramWidget.h"
+#include "HistogramDialog.h"
 
 class wxMaracasMultipleVolumeRendererPanel : public wxPanel{
        
@@ -25,8 +25,10 @@ private:
        
        int _propid;
 
-       HistogramWidget* mwxwidget;
-       wxFrame* _frame;
+       bool first;
+
+       HistogramDialog* mwxwidget;
+       //wxFrame* _frame;
        
 };
 
index 539648acc4411fa72eef397f500474e8e3b80aec..ec3512ba757c485a2ccab3163dd0f755f419e8d9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracasMultipleVolumeRendererView.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/07/08 14:22:14 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2009/07/20 10:06:12 $
+  Version:   $Revision: 1.2 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -111,6 +111,7 @@ void wxMaracasMultipleVolumeRendererView::addVolume(vtkImageData* img, std::stri
                if(id!=-1){
                        wxMaracasMultipleVolumeRendererPanel* controlpan = new wxMaracasMultipleVolumeRendererPanel(this, id,img);
                        addVolumeViewPanel(controlpan, dataname);
+                       controlpan->updateVolume();
                }
        }catch(char* str){
                std::cout << "Exception : " << str << '\n';
@@ -141,6 +142,12 @@ void wxMaracasMultipleVolumeRendererView::SetValuesPointsFunction(int volid, std
        volmanager->setVolumeOpacity(volid, greylevel, values);
 }
 
+vtkPiecewiseFunction* wxMaracasMultipleVolumeRendererView::GetTransferFunction(int volumeid){
+       return volmanager->GetTransferFunction(volumeid);
+}
+vtkColorTransferFunction* wxMaracasMultipleVolumeRendererView::GetColorFunction(int volumeid){
+    return volmanager->GetColorFunction(volumeid);
+}
 /**
 **
 **/
index 3272b0ddf53e6ebdac09306fe65399f86d6debce..c23b67611c857db56d1e0ced04dc6e053135917e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracasMultipleVolumeRendererView.h,v $
   Language:  C++
-  Date:      $Date: 2009/07/08 14:22:14 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2009/07/20 10:06:12 $
+  Version:   $Revision: 1.2 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -62,6 +62,9 @@ public:
 
        void addVolumeViewPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname);
 
+        vtkPiecewiseFunction* GetTransferFunction(int volumeid);
+        vtkColorTransferFunction* GetColorFunction(int volumeid);
+
 private:
        static wxMaracasMultipleVolumeRendererView* instance;