Public Member Functions | Private Slots | Private Attributes | List of all members
TuneColorDialog Class Reference

#include <wizard.h>

Inheritance diagram for TuneColorDialog:

Public Member Functions

 TuneColorDialog (int hue, int sat, int gamma, QWidget *parent=0)
 
int getHue () const
 
int getSaturation () const
 
int getGamma () const
 

Private Slots

void updateImage (int hue, int sat, int val)
 

Private Attributes

QImage * m_image
 
QLabel * m_imageLab
 
int m_hue
 
int m_sat
 
int m_gam
 

Detailed Description

Definition at line 41 of file wizard.h.

Constructor & Destructor Documentation

TuneColorDialog::TuneColorDialog ( int  hue,
int  sat,
int  gamma,
QWidget *  parent = 0 
)

Definition at line 165 of file wizard.cpp.

165  : QDialog(parent)
166 {
167  setWindowTitle(tr("Tune the color of the HTML output"));
168  QGridLayout *layout = new QGridLayout(this);
169  m_image = new QImage(QString::fromLatin1(":/images/tunecolor.png"));
170  m_imageLab = new QLabel;
171  updateImage(hue,sat,gamma);
172  layout->addWidget(new QLabel(tr("Example output: use the sliders on the right to adjust the color")),0,0);
173  layout->addWidget(m_imageLab,1,0);
174  QHBoxLayout *buttonsLayout = new QHBoxLayout;
175 
176  QPushButton *okButton = new QPushButton(tr("Ok"));
177  connect(okButton,SIGNAL(clicked()),SLOT(accept()));
178  okButton->setDefault(true);
179  QPushButton *cancelButton = new QPushButton(tr("Cancel"));
180  connect(cancelButton,SIGNAL(clicked()),SLOT(reject()));
181 
182  ColorPicker *huePicker = new ColorPicker(ColorPicker::Hue);
183  huePicker->setCol(hue,sat,gamma);
184  huePicker->setFixedWidth(20);
185  layout->addWidget(huePicker,1,1);
187  satPicker->setCol(hue,sat,gamma);
188  satPicker->setFixedWidth(20);
189  layout->addWidget(satPicker,1,2);
190  ColorPicker *gamPicker = new ColorPicker(ColorPicker::Gamma);
191  gamPicker->setCol(hue,sat,gamma);
192  gamPicker->setFixedWidth(20);
193  layout->addWidget(gamPicker,1,3);
194 
195  connect(huePicker,SIGNAL(newHsv(int,int,int)),satPicker,SLOT(setCol(int,int,int)));
196  connect(satPicker,SIGNAL(newHsv(int,int,int)),huePicker,SLOT(setCol(int,int,int)));
197  connect(huePicker,SIGNAL(newHsv(int,int,int)),gamPicker,SLOT(setCol(int,int,int)));
198  connect(satPicker,SIGNAL(newHsv(int,int,int)),gamPicker,SLOT(setCol(int,int,int)));
199  connect(gamPicker,SIGNAL(newHsv(int,int,int)),satPicker,SLOT(setCol(int,int,int)));
200  connect(gamPicker,SIGNAL(newHsv(int,int,int)),huePicker,SLOT(setCol(int,int,int)));
201  connect(huePicker,SIGNAL(newHsv(int,int,int)),this,SLOT(updateImage(int,int,int)));
202  connect(satPicker,SIGNAL(newHsv(int,int,int)),this,SLOT(updateImage(int,int,int)));
203  connect(gamPicker,SIGNAL(newHsv(int,int,int)),this,SLOT(updateImage(int,int,int)));
204 
205  buttonsLayout->addStretch();
206  buttonsLayout->addWidget(okButton);
207  buttonsLayout->addWidget(cancelButton);
208  layout->addLayout(buttonsLayout,5,0,1,4);
209 }
void updateImage(int hue, int sat, int val)
Definition: wizard.cpp:277
QLabel * m_imageLab
Definition: wizard.h:56
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
def connect(nxgraph, k1, k2, p1=0, p2=0, kwds)
Definition: graph.py:30
void setCol(int h, int s, int g)
Definition: wizard.cpp:412
double gamma(double KE, const simb::MCParticle *part)
QImage * m_image
Definition: wizard.h:55
def parent(G, child, parent_type)
Definition: graph.py:67

Member Function Documentation

int TuneColorDialog::getGamma ( ) const

Definition at line 306 of file wizard.cpp.

307 {
308  return m_gam;
309 }
int TuneColorDialog::getHue ( ) const

Definition at line 296 of file wizard.cpp.

297 {
298  return m_hue;
299 }
int TuneColorDialog::getSaturation ( ) const

Definition at line 301 of file wizard.cpp.

302 {
303  return m_sat;
304 }
void TuneColorDialog::updateImage ( int  hue,
int  sat,
int  val 
)
privateslot

Definition at line 277 of file wizard.cpp.

278 {
279  QImage coloredImg(m_image->width(),m_image->height(),QImage::Format_RGB32);
280  uint *srcPixel = (uint *)m_image->scanLine(0);
281  uint *dstPixel = (uint *)coloredImg.scanLine(0);
282  uint nrPixels = coloredImg.width()*coloredImg.height();
283  for (uint i=0;i<nrPixels;i++,srcPixel++,dstPixel++)
284  {
285  QColor c = QColor::fromRgb(*srcPixel);
286  double r,g,b;
287  hsl2rgb(hue/359.0, sat/255.0, pow(c.green()/255.0,gam/100.0),&r,&g,&b);
288  *dstPixel = qRgb((int)(r*255.0),(int)(g*255.0),(int)(b*255.0));
289  }
290  m_imageLab->setPixmap(QPixmap::fromImage(coloredImg));
291  m_hue = hue;
292  m_sat = sat;
293  m_gam = gam;
294 }
static constexpr double g
Definition: Units.h:144
QLabel * m_imageLab
Definition: wizard.h:56
constexpr T pow(T x)
Definition: pow.h:72
QImage * m_image
Definition: wizard.h:55
static bool * b
Definition: config.cpp:1043
unsigned uint
Definition: qglobal.h:351
void hsl2rgb(double h, double s, double l, double *pRed, double *pGreen, double *pBlue)
Definition: wizard.cpp:211

Member Data Documentation

int TuneColorDialog::m_gam
private

Definition at line 59 of file wizard.h.

int TuneColorDialog::m_hue
private

Definition at line 57 of file wizard.h.

QImage* TuneColorDialog::m_image
private

Definition at line 55 of file wizard.h.

QLabel* TuneColorDialog::m_imageLab
private

Definition at line 56 of file wizard.h.

int TuneColorDialog::m_sat
private

Definition at line 58 of file wizard.h.


The documentation for this class was generated from the following files: