HistogramDialogComboBoxItem.cxx
Go to the documentation of this file.00001 #include "HistogramDialogComboBoxItem.h"
00002 #include <vector>
00003
00004
00005
00006
00007 HistogramDialogComboBoxItem::HistogramDialogComboBoxItem()
00008 {
00009
00010 _bar_width = 30;
00011 _bar_height = 20;
00012
00013
00014 colorBar_Bitmap = new wxBitmap(_bar_width, _bar_height);
00015
00016 }
00017 HistogramDialogComboBoxItem::HistogramDialogComboBoxItem( int bar_width,int bar_height)
00018 {
00019
00020 _bar_width = bar_width;
00021 _bar_height = bar_height;
00022
00023
00024
00025 colorBar_Bitmap = new wxBitmap(_bar_width, _bar_height);
00026
00027 }
00028 HistogramDialogComboBoxItem::~HistogramDialogComboBoxItem(){
00029
00030
00031 }
00032 void HistogramDialogComboBoxItem::SetColors(std::vector<double> greyvect, std::vector<double> redvect, std::vector<double> greenvect, std::vector<double> bluevect){
00033
00034 _greyvect=greyvect;
00035 _redvect=redvect;
00036 _greenvect=greenvect;
00037 _bluevect=bluevect;
00038
00039 wxMemoryDC temp_dc;
00040 temp_dc.SelectObject( *colorBar_Bitmap );
00041 temp_dc.SetBrush(wxBrush( colourParent ,wxSOLID ));
00042 temp_dc.SetPen(wxPen( colourParent,1,wxSOLID ));
00043
00044 temp_dc.DrawRectangle(0, 0, _bar_width, _bar_height);
00045 temp_dc.SetPen(wxPen( wxColour(167,165,191),1,wxSOLID ));
00046 temp_dc.DrawRectangle(0, 0, _bar_width, _bar_height);
00047
00048 double initial_r, initial_g, initial_b;
00049 double next_r, next_g, next_b;
00050 double initialgreyv=0, nextgreyv=0;
00051
00052 for (int i =0; i < _redvect.size(); i++){
00053 initialgreyv = nextgreyv;
00054 initial_r = _redvect[i]*255.0;
00055 initial_g = _greenvect[i]*255.0;
00056 initial_b = _bluevect[i]*255.0;
00057
00058 if(i < _redvect.size()-1){
00059 nextgreyv = _greyvect[i+1];
00060 next_r = _redvect[i+1]*255.0;
00061 next_g = _greenvect[i+1]*255.0;
00062 next_b = _bluevect[i+1]*255.0;
00063 }else{
00064 nextgreyv = 1;
00065 next_r = initial_r;
00066 next_g = initial_g;
00067 next_b = initial_b;
00068 }
00069
00070 int ini_pixelX=_bar_width*initialgreyv;
00071 int end_pixelX=_bar_width*nextgreyv;
00072
00073 double m_scope_r = (double)(next_r-initial_r)/(end_pixelX-ini_pixelX);
00074 double m_scope_g = (double)(next_g-initial_g)/(end_pixelX-ini_pixelX);
00075 double m_scope_b = (double)(next_b-initial_b)/(end_pixelX-ini_pixelX);
00076
00077 next_r = initial_r;
00078 next_g = initial_g;
00079 next_b = initial_b;
00080
00081 for (int Xi =ini_pixelX; Xi<= end_pixelX; Xi++)
00082 {
00083 temp_dc.SetBrush(wxBrush( wxColour(next_r, next_g, next_b),wxSOLID ));
00084 temp_dc.SetPen(wxPen( wxColour(next_r, next_g, next_b),1,wxSOLID ));
00085
00086 temp_dc.DrawLine(Xi, 0, Xi, _bar_height);
00087
00088 next_r = (int)(m_scope_r + next_r);
00089 next_g = (int)(m_scope_g + next_g);
00090 next_b = (int)(m_scope_b + next_b);
00091 }
00092 }
00093 }
00094
00095 wxBitmap HistogramDialogComboBoxItem::GetBitmap(){
00096
00097 return *colorBar_Bitmap;
00098 }
00099 void HistogramDialogComboBoxItem::SetTransferFunction(std::vector<double> greyvect, std::vector<double> value){
00100 _greyvecttransfunct = greyvect;
00101 _value=value;
00102 }