1 #include "HistogramDialogComboBoxItem.h"
4 //-------------------------
6 //-------------------------
7 HistogramDialogComboBoxItem::HistogramDialogComboBoxItem()
14 colorBar_Bitmap = new wxBitmap(_bar_width, _bar_height);
17 HistogramDialogComboBoxItem::HistogramDialogComboBoxItem( int bar_width,int bar_height)
20 _bar_width = bar_width;
21 _bar_height = bar_height;
23 //_maxgreyvalue = maxgreyvalue;
25 colorBar_Bitmap = new wxBitmap(_bar_width, _bar_height);
28 HistogramDialogComboBoxItem::~HistogramDialogComboBoxItem(){
32 void HistogramDialogComboBoxItem::SetColors(std::vector<double> greyvect, std::vector<double> redvect, std::vector<double> greenvect, std::vector<double> bluevect){
40 temp_dc.SelectObject( *colorBar_Bitmap );
41 temp_dc.SetBrush(wxBrush( colourParent ,wxSOLID ));
42 temp_dc.SetPen(wxPen( colourParent,1,wxSOLID ));
44 temp_dc.DrawRectangle(0, 0, _bar_width, _bar_height);
45 temp_dc.SetPen(wxPen( wxColour(167,165,191),1,wxSOLID ));
46 temp_dc.DrawRectangle(0, 0, _bar_width, _bar_height);
48 double initial_r, initial_g, initial_b;
49 double next_r, next_g, next_b;
50 double initialgreyv=0, nextgreyv=0;
52 for (int i =0; i < _redvect.size(); i++){
53 initialgreyv = nextgreyv;
54 initial_r = _redvect[i]*255.0;
55 initial_g = _greenvect[i]*255.0;
56 initial_b = _bluevect[i]*255.0;
58 if(i < _redvect.size()-1){
59 nextgreyv = _greyvect[i+1];
60 next_r = _redvect[i+1]*255.0;
61 next_g = _greenvect[i+1]*255.0;
62 next_b = _bluevect[i+1]*255.0;
70 int ini_pixelX=_bar_width*initialgreyv;
71 int end_pixelX=_bar_width*nextgreyv;
73 double m_scope_r = (double)(next_r-initial_r)/(end_pixelX-ini_pixelX);
74 double m_scope_g = (double)(next_g-initial_g)/(end_pixelX-ini_pixelX);
75 double m_scope_b = (double)(next_b-initial_b)/(end_pixelX-ini_pixelX);
81 for (int Xi =ini_pixelX; Xi<= end_pixelX; Xi++)
83 temp_dc.SetBrush(wxBrush( wxColour(next_r, next_g, next_b),wxSOLID ));
84 temp_dc.SetPen(wxPen( wxColour(next_r, next_g, next_b),1,wxSOLID ));
86 temp_dc.DrawLine(Xi, 0, Xi, _bar_height);
88 next_r = (int)(m_scope_r + next_r);
89 next_g = (int)(m_scope_g + next_g);
90 next_b = (int)(m_scope_b + next_b);
95 wxBitmap HistogramDialogComboBoxItem::GetBitmap(){
97 return *colorBar_Bitmap;
99 void HistogramDialogComboBoxItem::SetTransferFunction(std::vector<double> greyvect, std::vector<double> value){
100 _greyvecttransfunct = greyvect;