void TransferFunctionView::Process()
{
- std::vector<double> greylevel;
- std::vector<double> value;
-
- std::vector<double> greylevelcolors;
- std::vector<double> red;
- std::vector<double> green;
- std::vector<double> blue;
+
//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<<"TransferFunctionView::Process()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<<"TransferFunctionView::Process()transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
- }
-
-
- bbSetOutputOpacityFunction(_tfun);
- bbSetOutputColorFunction(_ctfun);
+ onColorChange();
+
/*bbSetOutputGreyLevel(greylevel);
bbSetOutputValue(value);
bbSetOutputGreyLevelColors(greylevelcolors);
}
+void TransferFunctionView::onColorChange(){
+
+ std::vector<double> greylevel;
+ std::vector<double> value;
+
+ std::vector<double> greylevelcolors;
+ std::vector<double> red;
+ std::vector<double> green;
+ std::vector<double> blue;
+
+ 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<<"TransferFunctionView::Process()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<<"TransferFunctionView::Process()transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
+ }
+
+ bbSignalOutputModification();
+
+ bbSetOutputOpacityFunction(_tfun);
+ bbSetOutputColorFunction(_ctfun);
+}
+
+void TransferFunctionView::onSliderChange(){
+
+
+
+
+ bbSignalOutputModification();
+
+ bbSetOutputWindowLevel(mwxwidget->GetWindowLevel());
+ bbSetOutputColorLevel(mwxwidget->GetColorLevel());
+
+}
+
//-----------------------------------------------------
void TransferFunctionView::CreateWidget(wxWindow* parent)
{
bbtkDebugMessageInc("Core",9,"TransferFunctionView::CreateWxWindow()"<<std::endl);
+
+ mwxwidget = new HistogramDialogComboBox(parent);
+
- //mwxwidget = new HistogramWidget(parent, -1);
- mwxwidget = new HistogramDialogComboBox(parent);
+ HandlerTransferFunctionView* handler = new HandlerTransferFunctionView(this);
+
+ parent->Connect(mwxwidget->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED, (wxObjectEventFunction) (&HandlerTransferFunctionView::onColorChange),NULL,handler);
+ parent->Connect(mwxwidget->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) (&HandlerTransferFunctionView::onSliderChange),NULL,handler);
bbtkDebugDecTab("Core",9);
- bbSetOutputWidget( mwxwidget );
+ bbSetOutputWidget( mwxwidget );
}
//-----------------------------------------------------
+
void TransferFunctionView::bbUserSetDefaultValues()
{
mwxwidget = NULL;
void TransferFunctionView::bbUserFinalizeProcessing()
{
}
-
+
+
//-----------------------------------------------------------------
+
+
+ HandlerTransferFunctionView::HandlerTransferFunctionView(TransferFunctionView* box){
+ _box = box;
+ }
+ HandlerTransferFunctionView::~HandlerTransferFunctionView(){
+
+ }
+ void HandlerTransferFunctionView::onColorChange(wxCommandEvent& event){
+ _box->onColorChange();
+ }
+ void HandlerTransferFunctionView::onSliderChange(wxCommandEvent& event){
+ _box->onSliderChange();
+ }
}
+
+
// EO namespace bbcreaMaracasVisu
#include "vtkPiecewiseFunction.h"
#include "vtkColorTransferFunction.h"
+#include <wx/wx.h>
namespace bbcreaMaracasVisu
{
+
+
class /*BBTK_EXPORT*/ TransferFunctionView
:
public bbtk::WxBlackBox
BBTK_DECLARE_INPUT(In, vtkImageData*);
BBTK_DECLARE_OUTPUT(OpacityFunction, vtkPiecewiseFunction*);
BBTK_DECLARE_OUTPUT(ColorFunction, vtkColorTransferFunction*);
+
+ BBTK_DECLARE_OUTPUT(WindowLevel, double);
+ BBTK_DECLARE_OUTPUT(ColorLevel, double);
/*BBTK_DECLARE_OUTPUT(GreyLevel, std::vector<double> );
BBTK_DECLARE_OUTPUT(Value, std::vector<double> );
BBTK_DECLARE_OUTPUT(GreyLevelColors, std::vector<double>);
BBTK_PROCESS(Process);
void Process();
BBTK_CREATE_WIDGET(CreateWidget);
- void CreateWidget(wxWindow* parent);
+ void CreateWidget(wxWindow* parent);
+
+ void onColorChange();
+
+ void onSliderChange();
private:
//HistogramWidget *mwxwidget;
vtkColorTransferFunction* _ctfun;
};
+class HandlerTransferFunctionView : public wxEvtHandler
+{
+ public:
+ HandlerTransferFunctionView(TransferFunctionView* box);
+ ~HandlerTransferFunctionView();
+
+ void onColorChange(wxCommandEvent& event);
+
+ void onSliderChange(wxCommandEvent& event);
+
+ private:
+ TransferFunctionView *_box;
+};
+
BBTK_BEGIN_DESCRIBE_BLACK_BOX(TransferFunctionView,bbtk::WxBlackBox);
BBTK_NAME("TransferFunctionView");
BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr");
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,WindowLevel,"WidowLevel for the current window", double,"");
+ BBTK_OUTPUT(TransferFunctionView,ColorLevel,"ColorLevel for the current window", double,"");
/*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,Blue,"Blue value according to the GreyLevelColors",std::vector<double>,"");*/
BBTK_END_DESCRIBE_BLACK_BOX(TransferFunctionView);
}
+
+
// EO namespace bbcreaMaracasVisu
#endif // __bbcreaMaracasVisuTransferFunctionView_h_INCLUDED__
if(bbGetInputColorFunction()!=NULL){
mwxwidget->setColorTransferFunction(bbGetInputColorFunction());
}
+
+ if(bbGetInputWindowLevel()!=-1){
+ mwxwidget->setWindowLevel(bbGetInputWindowLevel());
+ }
+ if(bbGetInputColorLevel()!=-1){
+ mwxwidget->setColorLevel(bbGetInputColorLevel());
+ }
}
}
bbSetOutputRenderer3( NULL );
bbSetOutputRenderer4( NULL );
bbSetInputColorFunction(NULL);
+ bbSetInputWindowLevel(-1);
+ bbSetInputColorLevel(-1);
}
//-----------------------------------------------------------------
BBTK_DECLARE_INPUT(In, vtkImageData *);
BBTK_DECLARE_INPUT(nTypeView, std::vector<int> );
BBTK_DECLARE_INPUT(ColorFunction, vtkColorTransferFunction* );
+ BBTK_DECLARE_INPUT(WindowLevel, int );
+ BBTK_DECLARE_INPUT(ColorLevel, int );
BBTK_DECLARE_OUTPUT(wxVtkBaseView1,wxVtkBaseView*);
BBTK_DECLARE_OUTPUT(wxVtkBaseView2,wxVtkBaseView*);
BBTK_DECLARE_OUTPUT(wxVtkBaseView3,wxVtkBaseView*);
BBTK_INPUT(ViewerNV,In,"Input image",vtkImageData*,"");
BBTK_INPUT(ViewerNV,nTypeView,"vector of viewer types (default 5 0 1 3 ): -1=Z_2DwithOutAxis 0=Z_2D 1=X_2D 2=Y_2D 3=Plane 4=Sphere 5=3D 6=3Dplane",std::vector<int>,"");
BBTK_INPUT(ViewerNV,ColorFunction,"Optional: set a different color for the viewers 2D",vtkColorTransferFunction*,"");
+ BBTK_INPUT(ViewerNV,WindowLevel,"Optional: set a different Window level by using an other widget",int,"");
+ BBTK_INPUT(ViewerNV,ColorLevel,"Optional: set a different Color level by using an other widget",int,"");
BBTK_OUTPUT(ViewerNV,wxVtkBaseView1,"wxVtkBaseView 1",wxVtkBaseView *,"");
BBTK_OUTPUT(ViewerNV,wxVtkBaseView2,"wxVtkBaseView 2",wxVtkBaseView *,"");
BBTK_OUTPUT(ViewerNV,wxVtkBaseView3,"wxVtkBaseView 3",wxVtkBaseView *,"");
: wxPanel(parent)
{
+ _img = NULL;
+ _bitmapcombo=NULL;
+ _slidercolor=NULL;
+ _sliderwindowlevel=NULL;
+ colorBar_Bitmap=NULL;
+ _bitmapsizer=NULL;
+
this->SetSizer(getBitmapCombo());
_img = NULL;
_currentitem = -1;
wxSizer* HistogramDialogComboBox::getBitmapCombo(){
- _bitmapsizer = new wxBoxSizer(wxHORIZONTAL);
+ //_bitmapsizer = new wxBoxSizer(wxVERTICAL);
+ _bitmapsizer = new wxBoxSizer(wxVERTICAL);
+
+
+
+ wxBoxSizer* comboeditsizer = new wxBoxSizer(wxHORIZONTAL);
_bitmapcombo = getBitmapComboElements();
wxBitmapButton* edit = new wxBitmapButton(this, -1, bitmap1,wxDefaultPosition,wxSize(30,30));
Connect(edit->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&HistogramDialogComboBox::OnEditBitmapCombo);
- _bitmapsizer->Add(_bitmapcombo,wxSizerFlags().Center().FixedMinSize());
- _bitmapsizer->Add(edit,wxSizerFlags().Center());
+ comboeditsizer->Add(_bitmapcombo,wxSizerFlags().Center().FixedMinSize());
+ comboeditsizer->Add(edit,wxSizerFlags().Center());
+
+
+ _bitmapsizer->Add(comboeditsizer,wxSizerFlags().FixedMinSize().Center());
+ _bitmapsizer->AddSpacer(5);
+ _bitmapsizer->Add(getSlidersWlCo(),wxSizerFlags().Expand().Center());
return _bitmapsizer;
+}
+wxSizer* HistogramDialogComboBox::getSlidersWlCo(){
+ wxBoxSizer* sizersliders = new wxBoxSizer(wxVERTICAL);
+
+ _slidercolor = new wxSlider(this, -1,1,0,1,wxDefaultPosition,wxDefaultSize,wxSL_LABELS);
+ _sliderwindowlevel = new wxSlider(this, -1,1,0,1,wxDefaultPosition,wxDefaultSize,wxSL_LABELS);
+
+ sizersliders->Add(_slidercolor,wxSizerFlags().Expand().Center());
+ sizersliders->Add(_sliderwindowlevel,wxSizerFlags().Expand().Center());
+
+ Connect(_slidercolor->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&HistogramDialogComboBox::OnColorLevelChanged);
+ Connect(_sliderwindowlevel->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&HistogramDialogComboBox::OnWindowLevelChanged);
+
+ return sizersliders;
+
+}
+
+double HistogramDialogComboBox::GetWindowLevel(){
+ if(_sliderwindowlevel != NULL){
+ return _sliderwindowlevel->GetValue();
+ }
+}
+double HistogramDialogComboBox::GetColorLevel(){
+ if(_slidercolor != NULL){
+ return _slidercolor->GetValue();
+ }
+}
+
+void HistogramDialogComboBox::OnColorLevelChanged(wxCommandEvent& event){
+ _slidercolor->GetValue();
+
+ wxCommandEvent newevent(wxEVT_SCROLL_THUMBTRACK,this->GetId());
+ ProcessEvent(newevent);
+
+}
+void HistogramDialogComboBox::OnWindowLevelChanged(wxCommandEvent& event){
+ _sliderwindowlevel->GetValue();
+
+ wxCommandEvent newevent(wxEVT_SCROLL_THUMBTRACK,this->GetId());
+ ProcessEvent(newevent);
+
}
void HistogramDialogComboBox::setImageData(vtkImageData* img){
_maxgreyvalue = img->GetScalarRange()[1];
_img = img;
+
+ setSlidersValue();
+
+}
+void HistogramDialogComboBox::setSlidersValue(){
+ if(_img!=NULL){
+ if(_slidercolor!=NULL){
+ _slidercolor->SetRange(_img->GetScalarRange()[0],_img->GetScalarRange()[1]);
+ _slidercolor->SetValue((_img->GetScalarRange()[0]+_img->GetScalarRange()[1])/2);
+ }
+ if(_sliderwindowlevel!=NULL){
+ _sliderwindowlevel->SetRange(_img->GetScalarRange()[0],_img->GetScalarRange()[1]);
+ _sliderwindowlevel->SetValue((_img->GetScalarRange()[0]+_img->GetScalarRange()[1])/2);
+ }
+ }
}
void HistogramDialogComboBox::OnEditBitmapCombo(wxCommandEvent& event){
bitmapcombo->SetSize(65,30);
Connect(bitmapcombo->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED, (wxObjectEventFunction)&HistogramDialogComboBox::OnBitmapComboItemSelected);
-
+
+
for(int i = 0; i < bitmapsitems.size(); i++){
bitmapcombo->SetItemBitmap(i, bitmapsitems[i]->GetBitmap());
wxCommandEvent newevent(wxEVT_COMMAND_COMBOBOX_SELECTED,this->GetId());
ProcessEvent(newevent);
}
+
+
}
void OnEditBitmapCombo(wxCommandEvent& event);
void OnBitmapComboItemSelected(wxCommandEvent& event);
+ void OnColorLevelChanged(wxCommandEvent& event);
+ void OnWindowLevelChanged(wxCommandEvent& event);
+
void setImageData(vtkImageData* img);
/**
std::vector<double>& green,
std::vector<double>& blue);
+ double GetWindowLevel();
+ double GetColorLevel();
+
private:
std::vector<double> _greyvect;
* Represents the color of the backGround. Default color is the parent color.
*/
- wxBitmapComboBox* _bitmapcombo;
+ wxBitmapComboBox* _bitmapcombo;
+ wxSlider* _slidercolor;
+ wxSlider* _sliderwindowlevel;
std::vector<HistogramDialogComboBoxItem*> _bitmapsitems;
wxBitmap* colorBar_Bitmap;
wxSizer* _bitmapsizer;
wxSizer* getBitmapCombo();
+ wxSizer* getSlidersWlCo();
wxBitmapComboBox* getBitmapComboElements();
void OnLoadComboBoxData(std::vector<HistogramDialogComboBoxItem*>& itembitmaps,std::string filename);
void saveCurrentConfiguration(std::vector<HistogramDialogComboBoxItem*>& itembitmaps,std::string filename);
+ void setSlidersValue();
+
+
};
Program: wxMaracas
Module: $RCSfile: wxMaracas_N_ViewersWidget.cxx,v $
Language: C++
- Date: $Date: 2009/07/27 07:58:20 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2009/09/15 11:25:07 $
+ Version: $Revision: 1.12 $
Copyright: (c) 2002, 2003
License:
}
}
+void wxMaracas_N_ViewersWidget::setWindowLevel(double level){
+ if (wxwindow1!=NULL) {
+ wxwindow1->setWindowLevel(level);
+ }
+ if (wxwindow2!=NULL) {
+ wxwindow2->setWindowLevel(level);
+ }
+ if (wxwindow3!=NULL) {
+ wxwindow3->setWindowLevel(level);
+ }
+ if (wxwindow4!=NULL) {
+ wxwindow4->setWindowLevel(level);
+ }
+}
+void wxMaracas_N_ViewersWidget::setColorLevel(double level){
+ if (wxwindow1!=NULL) {
+ wxwindow1->setColorLevel(level);
+ }
+ if (wxwindow2!=NULL) {
+ wxwindow2->setColorLevel(level);
+ }
+ if (wxwindow3!=NULL) {
+ wxwindow3->setColorLevel(level);
+ }
+ if (wxwindow4!=NULL) {
+ wxwindow4->setColorLevel(level);
+ }
+}
+
Program: wxMaracas
Module: $RCSfile: wxMaracas_N_ViewersWidget.h,v $
Language: C++
- Date: $Date: 2009/07/27 07:58:20 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2009/09/15 11:25:07 $
+ Version: $Revision: 1.8 $
Copyright: (c) 2002, 2003
License:
void setColorTransferFunction(vtkColorTransferFunction* colortable);
+ void setWindowLevel(double level);
+ void setColorLevel(double level);
+
//------------------------------------------------------------------------------------------------------------
// Attributes
//------------------------------------------------------------------------------------------------------------
Program: wxMaracas
Module: $RCSfile: wxMaracas_ViewerWidget.cxx,v $
Language: C++
- Date: $Date: 2009/09/08 08:14:30 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2009/09/15 11:25:07 $
+ Version: $Revision: 1.17 $
Copyright: (c) 2002, 2003
License:
if(mwxvtkmpr3Dview!=NULL){
mwxvtkmpr3Dview->setColorTransferFunction(colortable);
}
- }
\ No newline at end of file
+ }
+
+ void wxMaracas_ViewerWidget::setWindowLevel(double level){
+ if(mvtkmpr2Dview_X!=NULL){
+ mvtkmpr2Dview_X->setWindowLevel(level);
+ }
+ if(mvtkmpr2Dview_Y!=NULL){
+ mvtkmpr2Dview_Y->setWindowLevel(level);
+ }
+ if(mvtkmpr2Dview_Z!=NULL){
+ mvtkmpr2Dview_Z->setWindowLevel(level);
+ }
+ /*if(mwxvtkmpr3Dview!=NULL){
+ mwxvtkmpr3Dview->setWindowLevel(level);
+ }*/
+ }
+
+ void wxMaracas_ViewerWidget::setColorLevel(double level){
+ if(mvtkmpr2Dview_X!=NULL){
+ mvtkmpr2Dview_X->setColorLevel(level);
+ }
+ if(mvtkmpr2Dview_Y!=NULL){
+ mvtkmpr2Dview_Y->setColorLevel(level);
+ }
+ if(mvtkmpr2Dview_Z!=NULL){
+ mvtkmpr2Dview_Z->setColorLevel(level);
+ }
+ /*if(mwxvtkmpr3Dview!=NULL){
+ mwxvtkmpr3Dview->setColorLevel(level);
+ }*/
+ }
\ No newline at end of file
Program: wxMaracas
Module: $RCSfile: wxMaracas_ViewerWidget.h,v $
Language: C++
- Date: $Date: 2009/07/27 07:58:20 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2009/09/15 11:25:07 $
+ Version: $Revision: 1.8 $
Copyright: (c) 2002, 2003
License:
//------------------------------------------------------------------------------------------------------------
void setColorTransferFunction(vtkColorTransferFunction* colortable);
+
+ void setWindowLevel(double level);
+
+ void setColorLevel(double level);
private:
int mType;
void wxVtk2DBaseView::setColorTransferFunction(vtkColorTransferFunction* colortable){
if(_imageViewer2XYZ!=NULL){
_imageViewer2XYZ->setColorTransferFunction(colortable);
+ this->Refresh();
}
}
+
+void wxVtk2DBaseView::setWindowLevel(double level){
+ _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow(level);
+
+ this->Refresh();
+}
+
+void wxVtk2DBaseView::setColorLevel(double level){
+ _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel(level);
+ this->Refresh();
+}
void setColorTransferFunction(vtkColorTransferFunction* colortable);
+ void setWindowLevel(double level);
+
+ void setColorLevel(double level);
+
private:
vtkBaseData *_vtkbasedata;
void SetVisibleAxis(bool ok);
+
private:
int _backX;