All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
#include <ColorHistogram.h>
Public Slots | |
void | scrollChanged (int) |
Public Member Functions | |
ColorHistogram (QRgb *colors, int *values, int num, QWidget *parent=0) | |
void | paintEvent (QPaintEvent *e) |
void | resizeEvent (QResizeEvent *e) |
~ColorHistogram () | |
Protected Attributes | |
QRgb * | _colors |
int | _maxVal |
int | _numColors |
int * | _values |
QScrollBar | sBar |
QGpGuiTools::ColorHistogram::ColorHistogram | ( | QRgb * | colors, |
int * | values, | ||
int | num, | ||
QWidget * | parent = 0 |
||
) |
References _colors, _maxVal, _numColors, _values, sBar, scrollChanged(), and TRACE.
: QWidget(parent, Qt::Window), sBar(Qt::Vertical,this) { TRACE; setAttribute(Qt::WA_DeleteOnClose); _colors=colors; _numColors=num; _values=values; _maxVal=0; for(int i=0;i < _numColors;i++ ) { if(_values[ i ] > _maxVal) _maxVal=_values[ i ]; } sBar.setMinimum(0); sBar.setMaximum(_numColors - 1); sBar.setSingleStep(1); sBar.setPageStep(10); sBar.setValue(0); connect (&sBar, SIGNAL(valueChanged( int) ), this, SLOT(scrollChanged( int) )); setGeometry(50, 50, 400, 400); }
void QGpGuiTools::ColorHistogram::paintEvent | ( | QPaintEvent * | e | ) |
References _colors, _maxVal, _numColors, _values, COLOR_HEIGHT, COLOR_WIDTH, sBar, str, TEXT_WIDTH, and TRACE.
{ TRACE; int i=sBar.value(); int maxi=i + height()/COLOR_HEIGHT + 1; QPainter p(this); p.fillRect(0, 0, width(), height(), Qt::white); int y=0; int dx0=16 + 6 * TEXT_WIDTH; int dx1=dx0 + COLOR_WIDTH; int dx=width() - dx0; QString str( "%1" ); while(i < maxi && i < _numColors) { QColor col(_colors[ i ] ); int h, v, s; col.getHsv(&h, &s, &v); p.drawText(16, y + COLOR_HEIGHT, str.arg(col.red()) ); p.drawText(16 + TEXT_WIDTH, y + COLOR_HEIGHT, str.arg(col.green()) ); p.drawText(16 + 2 * TEXT_WIDTH, y + COLOR_HEIGHT, str.arg(col.blue()) ); p.drawText(16 + 3 * TEXT_WIDTH, y + COLOR_HEIGHT, str.arg(h) ); p.drawText(16 + 4 * TEXT_WIDTH, y + COLOR_HEIGHT, str.arg(s) ); p.drawText(16 + 5 * TEXT_WIDTH, y + COLOR_HEIGHT, str.arg(v) ); p.setPen(QColor( _colors[ i ] )); p.setBrush(QColor( _colors[ i ] )); p.drawRect(dx0, y, COLOR_WIDTH, COLOR_HEIGHT); int y2=y + (COLOR_HEIGHT >> 2); p.setPen(QPen( Qt::black, 2) ); p.drawLine(dx1, y2, dx1 + _values[ i ] * dx/_maxVal, y2); i++; y += COLOR_HEIGHT; } }
void QGpGuiTools::ColorHistogram::resizeEvent | ( | QResizeEvent * | e | ) |
void QGpGuiTools::ColorHistogram::scrollChanged | ( | int | ) | [slot] |
QRgb* QGpGuiTools::ColorHistogram::_colors [protected] |
Referenced by ColorHistogram(), paintEvent(), and ~ColorHistogram().
int QGpGuiTools::ColorHistogram::_maxVal [protected] |
Referenced by ColorHistogram(), and paintEvent().
int QGpGuiTools::ColorHistogram::_numColors [protected] |
Referenced by ColorHistogram(), and paintEvent().
int* QGpGuiTools::ColorHistogram::_values [protected] |
Referenced by ColorHistogram(), paintEvent(), and ~ColorHistogram().
QScrollBar QGpGuiTools::ColorHistogram::sBar [protected] |
Referenced by ColorHistogram(), paintEvent(), and resizeEvent().