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
//-----------------------
}
+/**
+** 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
Constructor
*/
HistogramDialog(wxWindow *parent,wxString title,vtkImageData* imageData,int type);
+ /*
+ Constructor
+ */
+ HistogramDialog(wxWindow *parent,wxString title);
/*
Methods
*/
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
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();
/*
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]
**/
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:
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();
//reader->Delete();
//img->Delete();
return cast->GetOutput();
+ //return img;
}
return NULL;
}
}
}
+
+vtkPiecewiseFunction* wxMaracasMultipleVolumeRendererManager::GetTransferFunction(int volumeid){
+ return getViewData(volumeid)->GetTransferFunction();
+}
+vtkColorTransferFunction* wxMaracasMultipleVolumeRendererManager::GetColorFunction(int volumeid){
+
+ return getViewData(volumeid)->GetColorFunction();
+}
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:
**/
void deleteActor(int volumeid)throw (char *);
+ vtkPiecewiseFunction* GetTransferFunction(int volumeid);
+ vtkColorTransferFunction* GetColorFunction(int volumeid);
private:
std::vector<wxMaracasMultipleVolumeRendererManagerData*> prop3Dvect;
** Volume Opacity
**/
void setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value);
+
+ vtkPiecewiseFunction* GetTransferFunction(){
+ return _tfun;
+ }
+ vtkColorTransferFunction* GetColorFunction(){
+ return _ctfun;
+ }
protected:
/**
#include <wx/colordlg.h>
#include "wxMaracasMultipleVolumeRendererView.h"
#include "Color.xpm"
+//#include <vtkImageCast.h>
/**
** Implementation of viewProp3D
**/
wxMaracasMultipleVolumeRendererPanel::~wxMaracasMultipleVolumeRendererPanel(){
//wxMaracasIRMView::getInstance()->addRemoveActor(_propid, false);
wxMaracasMultipleVolumeRendererView::getInstance()->deleteVolume(_propid);
+ delete mwxwidget;
}
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));
- _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);
_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();
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());
#define wxMaracasMultipleVolumeRendererPanel_H_
#include <wx/wx.h>
-#include "HistogramWidget.h"
+#include "HistogramDialog.h"
class wxMaracasMultipleVolumeRendererPanel : public wxPanel{
int _propid;
- HistogramWidget* mwxwidget;
- wxFrame* _frame;
+ bool first;
+
+ HistogramDialog* mwxwidget;
+ //wxFrame* _frame;
};
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:
if(id!=-1){
wxMaracasMultipleVolumeRendererPanel* controlpan = new wxMaracasMultipleVolumeRendererPanel(this, id,img);
addVolumeViewPanel(controlpan, dataname);
+ controlpan->updateVolume();
}
}catch(char* str){
std::cout << "Exception : " << str << '\n';
volmanager->setVolumeOpacity(volid, greylevel, values);
}
+vtkPiecewiseFunction* wxMaracasMultipleVolumeRendererView::GetTransferFunction(int volumeid){
+ return volmanager->GetTransferFunction(volumeid);
+}
+vtkColorTransferFunction* wxMaracasMultipleVolumeRendererView::GetColorFunction(int volumeid){
+ return volmanager->GetColorFunction(volumeid);
+}
/**
**
**/
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:
void addVolumeViewPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname);
+ vtkPiecewiseFunction* GetTransferFunction(int volumeid);
+ vtkColorTransferFunction* GetColorFunction(int volumeid);
+
private:
static wxMaracasMultipleVolumeRendererView* instance;