#include "HistogramDialogComboBoxItem.h" #include //------------------------- //Constructor //------------------------- HistogramDialogComboBoxItem::HistogramDialogComboBoxItem() { _bar_width = 30; _bar_height = 20; colorBar_Bitmap = new wxBitmap(_bar_width, _bar_height); } HistogramDialogComboBoxItem::HistogramDialogComboBoxItem( int bar_width,int bar_height) { _bar_width = bar_width; _bar_height = bar_height; //_maxgreyvalue = maxgreyvalue; colorBar_Bitmap = new wxBitmap(_bar_width, _bar_height); } HistogramDialogComboBoxItem::~HistogramDialogComboBoxItem(){ } void HistogramDialogComboBoxItem::SetColors(std::vector greyvect, std::vector redvect, std::vector greenvect, std::vector bluevect){ _greyvect=greyvect; _redvect=redvect; _greenvect=greenvect; _bluevect=bluevect; wxMemoryDC temp_dc; temp_dc.SelectObject( *colorBar_Bitmap ); temp_dc.SetBrush(wxBrush( colourParent ,wxSOLID )); temp_dc.SetPen(wxPen( colourParent,1,wxSOLID )); temp_dc.DrawRectangle(0, 0, _bar_width, _bar_height); temp_dc.SetPen(wxPen( wxColour(167,165,191),1,wxSOLID )); temp_dc.DrawRectangle(0, 0, _bar_width, _bar_height); double initial_r, initial_g, initial_b; double next_r, next_g, next_b; double initialgreyv=0, nextgreyv=0; for (int i =0; i < _redvect.size(); i++){ initialgreyv = nextgreyv; initial_r = _redvect[i]*255.0; initial_g = _greenvect[i]*255.0; initial_b = _bluevect[i]*255.0; if(i < _redvect.size()-1){ nextgreyv = _greyvect[i+1]; next_r = _redvect[i+1]*255.0; next_g = _greenvect[i+1]*255.0; next_b = _bluevect[i+1]*255.0; }else{ nextgreyv = 1; next_r = initial_r; next_g = initial_g; next_b = initial_b; } int ini_pixelX=_bar_width*initialgreyv; int end_pixelX=_bar_width*nextgreyv; double m_scope_r = (double)(next_r-initial_r)/(end_pixelX-ini_pixelX); double m_scope_g = (double)(next_g-initial_g)/(end_pixelX-ini_pixelX); double m_scope_b = (double)(next_b-initial_b)/(end_pixelX-ini_pixelX); next_r = initial_r; next_g = initial_g; next_b = initial_b; for (int Xi =ini_pixelX; Xi<= end_pixelX; Xi++) { temp_dc.SetBrush(wxBrush( wxColour(next_r, next_g, next_b),wxSOLID )); temp_dc.SetPen(wxPen( wxColour(next_r, next_g, next_b),1,wxSOLID )); temp_dc.DrawLine(Xi, 0, Xi, _bar_height); next_r = (int)(m_scope_r + next_r); next_g = (int)(m_scope_g + next_g); next_b = (int)(m_scope_b + next_b); } } } wxBitmap HistogramDialogComboBoxItem::GetBitmap(){ return *colorBar_Bitmap; } void HistogramDialogComboBoxItem::SetTransferFunction(std::vector greyvect, std::vector value){ _greyvecttransfunct = greyvect; _value=value; }