[TASK] Add gui elements for task2.

This commit is contained in:
Jan Philipp Timme 2015-11-06 12:21:36 +01:00
parent 6af05f9c79
commit 352fc1cf80
2 changed files with 34 additions and 16 deletions

View File

@ -110,7 +110,7 @@ void ImageViewer::drawRainbowCross(int initialHue=0) {
int h = initialHue; int h = initialHue;
QColor myColor = QColor::fromHsl(h, 255, 125); QColor myColor = QColor::fromHsl(h, 255, 125);
int image_width = image->width()-1; int image_width = image->width()-1;
int range = lineSlider->value(); int range = line_slider->value();
if(range > image->width()-2) range = image->width()-2; if(range > image->width()-2) range = image->width()-2;
for(int i=0;i<std::min(image->width(),image->height());i++) { for(int i=0;i<std::min(image->width(),image->height());i++) {
int color = myColor.rgba(); int color = myColor.rgba();
@ -231,7 +231,7 @@ void ImageViewer::updateHistogramm() {
} }
histogramm = new QImage(256, 100, QImage::Format_RGB32); histogramm = new QImage(256, 100, QImage::Format_RGB32);
histogramm->fill(QColor::fromRgb(150,150,150)); histogramm->fill(QColor::fromRgb(200,200,200));
int black = QColor::fromRgb(0,0,0).rgba(); int black = QColor::fromRgb(0,0,0).rgba();
for(int x=0; x<256; x++) { for(int x=0; x<256; x++) {
int k_max = (int)((100*grayscale_relative_histogramm[x])/max); int k_max = (int)((100*grayscale_relative_histogramm[x])/max);
@ -241,7 +241,7 @@ void ImageViewer::updateHistogramm() {
} }
logFile << "Histogramm done." << std::endl; logFile << "Histogramm done." << std::endl;
renewLogging(); renewLogging();
histogrammLabel->setPixmap(QPixmap::fromImage(*histogramm)); histogramm_label->setPixmap(QPixmap::fromImage(*histogramm));
} }
/**************************************************************************************** /****************************************************************************************
@ -272,10 +272,10 @@ void ImageViewer::generateControlPanels() {
task_tab1_button4->setText("Draw a diagonal cross"); task_tab1_button4->setText("Draw a diagonal cross");
QObject::connect(task_tab1_button4, SIGNAL(clicked()), this, SLOT (drawDiagonalCross())); QObject::connect(task_tab1_button4, SIGNAL(clicked()), this, SLOT (drawDiagonalCross()));
lineSlider = new QSlider(Qt::Horizontal); line_slider = new QSlider(Qt::Horizontal);
lineSlider->setMinimum(1); line_slider->setMinimum(1);
lineSlider->setMaximum(150); line_slider->setMaximum(150);
lineSlider->setValue(3); line_slider->setValue(3);
//QObject::connect(lineSlider, SIGNAL(valueChanged(int)), this, SLOT (drawRainbowCross())); //QObject::connect(lineSlider, SIGNAL(valueChanged(int)), this, SLOT (drawRainbowCross()));
task_tab1->addWidget(new QLabel("Let's draw something!")); task_tab1->addWidget(new QLabel("Let's draw something!"));
@ -284,7 +284,7 @@ void ImageViewer::generateControlPanels() {
task_tab1->addWidget(task_tab1_button3); task_tab1->addWidget(task_tab1_button3);
task_tab1->addWidget(task_tab1_button4); task_tab1->addWidget(task_tab1_button4);
task_tab1->addWidget(new QLabel("This will not stop unless process is killed.")); task_tab1->addWidget(new QLabel("This will not stop unless process is killed."));
task_tab1->addWidget(lineSlider); task_tab1->addWidget(line_slider);
task_tab1->addWidget(new QLabel("Sets the width of the cross.")); task_tab1->addWidget(new QLabel("Sets the width of the cross."));
tabWidget->addTab(task_tab_widget1, "Task #1"); tabWidget->addTab(task_tab_widget1, "Task #1");
@ -299,17 +299,32 @@ void ImageViewer::generateControlPanels() {
task_tab2_button1->setText("Analyze image"); task_tab2_button1->setText("Analyze image");
QObject::connect(task_tab2_button1, SIGNAL(clicked()), this, SLOT (analyzeImage())); QObject::connect(task_tab2_button1, SIGNAL(clicked()), this, SLOT (analyzeImage()));
histogrammLabel = new QLabel(); histogramm_label = new QLabel();
histogrammLabel->setBackgroundRole(QPalette::Base); histogramm_label->setBackgroundRole(QPalette::Base);
histogrammLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); histogramm_label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
histogrammLabel->setScaledContents(false); histogramm_label->setScaledContents(false);
task_tab2_stats = new QLabel(); task_tab2_stats = new QLabel();
task_tab2_stats->setText("Results will go here ..."); task_tab2_stats->setText("Intensity will be shown here.");
brightness_slider = new QSlider(Qt::Horizontal);
brightness_slider->setMinimum(0);
brightness_slider->setMaximum(255);
brightness_slider->setValue(127);
contrast_slider = new QSlider(Qt::Horizontal);
contrast_slider->setMinimum(0);
contrast_slider->setMaximum(255);
contrast_slider->setValue(127);
task_tab2->addWidget(task_tab2_button1); task_tab2->addWidget(task_tab2_button1);
task_tab2->addWidget(task_tab2_stats); task_tab2->addWidget(task_tab2_stats);
task_tab2->addWidget(histogrammLabel); task_tab2->addWidget(new QLabel("Histogramm"));
task_tab2->addWidget(histogramm_label);
task_tab2->addWidget(new QLabel("Brightness"));
task_tab2->addWidget(brightness_slider);
task_tab2->addWidget(new QLabel("Contrast"));
task_tab2->addWidget(contrast_slider);
tabWidget->addTab(task_tab_widget2, "Task #2"); tabWidget->addTab(task_tab_widget2, "Task #2");

View File

@ -76,7 +76,7 @@ class ImageViewer : public QMainWindow {
QPushButton* task_tab1_button3; QPushButton* task_tab1_button3;
QPushButton* task_tab1_button4; QPushButton* task_tab1_button4;
QSlider* lineSlider; QSlider* line_slider;
// Second task tab // Second task tab
QWidget* task_tab_widget2; QWidget* task_tab_widget2;
@ -84,7 +84,10 @@ class ImageViewer : public QMainWindow {
QPushButton* task_tab2_button1; QPushButton* task_tab2_button1;
QLabel* task_tab2_stats; QLabel* task_tab2_stats;
QLabel* histogrammLabel; QLabel* histogramm_label;
QSlider* brightness_slider;
QSlider* contrast_slider;
// Third task tab // Third task tab
QWidget* task_tab_widget3; QWidget* task_tab_widget3;