1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "HistogramDialogComboBoxItem.h"
29 //-------------------------
31 //-------------------------
32 HistogramDialogComboBoxItem::HistogramDialogComboBoxItem()
39 colorBar_Bitmap = new wxBitmap(_bar_width, _bar_height);
42 HistogramDialogComboBoxItem::HistogramDialogComboBoxItem( int bar_width,int bar_height)
45 _bar_width = bar_width;
46 _bar_height = bar_height;
48 //_maxgreyvalue = maxgreyvalue;
50 colorBar_Bitmap = new wxBitmap(_bar_width, _bar_height);
53 HistogramDialogComboBoxItem::~HistogramDialogComboBoxItem(){
57 void HistogramDialogComboBoxItem::SetColors(std::vector<double> greyvect, std::vector<double> redvect, std::vector<double> greenvect, std::vector<double> bluevect){
65 temp_dc.SelectObject( *colorBar_Bitmap );
66 temp_dc.SetBrush(wxBrush( colourParent ,wxSOLID ));
67 temp_dc.SetPen(wxPen( colourParent,1,wxSOLID ));
69 temp_dc.DrawRectangle(0, 0, _bar_width, _bar_height);
70 temp_dc.SetPen(wxPen( wxColour(167,165,191),1,wxSOLID ));
71 temp_dc.DrawRectangle(0, 0, _bar_width, _bar_height);
73 double initial_r, initial_g, initial_b;
74 double next_r, next_g, next_b;
75 double initialgreyv=0, nextgreyv=0;
77 for (int i =0; i < _redvect.size(); i++){
78 initialgreyv = nextgreyv;
79 initial_r = _redvect[i]*255.0;
80 initial_g = _greenvect[i]*255.0;
81 initial_b = _bluevect[i]*255.0;
83 if(i < _redvect.size()-1){
84 nextgreyv = _greyvect[i+1];
85 next_r = _redvect[i+1]*255.0;
86 next_g = _greenvect[i+1]*255.0;
87 next_b = _bluevect[i+1]*255.0;
95 int ini_pixelX=_bar_width*initialgreyv;
96 int end_pixelX=_bar_width*nextgreyv;
98 double m_scope_r = (double)(next_r-initial_r)/(end_pixelX-ini_pixelX);
99 double m_scope_g = (double)(next_g-initial_g)/(end_pixelX-ini_pixelX);
100 double m_scope_b = (double)(next_b-initial_b)/(end_pixelX-ini_pixelX);
106 for (int Xi =ini_pixelX; Xi<= end_pixelX; Xi++)
108 temp_dc.SetBrush(wxBrush( wxColour(next_r, next_g, next_b),wxSOLID ));
109 temp_dc.SetPen(wxPen( wxColour(next_r, next_g, next_b),1,wxSOLID ));
111 temp_dc.DrawLine(Xi, 0, Xi, _bar_height);
113 next_r = (int)(m_scope_r + next_r);
114 next_g = (int)(m_scope_g + next_g);
115 next_b = (int)(m_scope_b + next_b);
120 wxBitmap HistogramDialogComboBoxItem::GetBitmap(){
122 return *colorBar_Bitmap;
124 void HistogramDialogComboBoxItem::SetTransferFunction(std::vector<double> greyvect, std::vector<double> value){
125 _greyvecttransfunct = greyvect;