[TASK] Add a TableWidget for the filter value input.

This commit is contained in:
Jan Philipp Timme 2015-11-27 13:53:39 +01:00
parent d1ea7d200f
commit a8365ea1f5
3 changed files with 78 additions and 0 deletions

58
filter_gui.cpp Normal file
View File

@ -0,0 +1,58 @@
#ifndef FILTER_GUI_C
#define FILTER_GUI_C
#include <QtGlobal>
#include <QMainWindow>
#include <QColor>
#include <qboxlayout.h>
#include <QTableWidget>
#include <iostream>
#include <math.h>
class FilterGui {
private:
QTableWidget* widget;
int filter_size;
void updateGui() {
this->widget->setRowCount(this->filter_size);
this->widget->setColumnCount(this->filter_size);
for(int i=0; i<this->filter_size; i++) {
for(int j=0; j<this->filter_size; j++) {
this->widget->setItem(i, j, new QTableWidgetItem("0"));
}
}
};
public:
FilterGui(int filter_size = 3) {
this->widget = new QTableWidget();
this->setSize(filter_size);
};
~FilterGui() {
delete this->widget;
this->widget = NULL;
};
QTableWidget* getWidget() {
return this->widget;
};
void setSize(int size) {
this->filter_size = size;
this->updateGui();
};
int getSize() {
return this->filter_size;
};
};
#endif

View File

@ -480,6 +480,12 @@ void ImageViewer::succeedingHistogrammAdaption() {
* *
*****************************************************************************************/ *****************************************************************************************/
void ImageViewer::changeFilterSize(int s) {
filter_gui->setSize(((s+1)*2)+1);
logFile << "done." << std::endl;
renewLogging();
}
void ImageViewer::generateControlPanels() { void ImageViewer::generateControlPanels() {
// Tab for first task // Tab for first task
task_tab1_widget = new QWidget(); task_tab1_widget = new QWidget();
@ -686,7 +692,16 @@ void ImageViewer::generateControlPanels() {
task_tab4_scrolllayout->setSizeConstraint(QLayout::SetMaximumSize); task_tab4_scrolllayout->setSizeConstraint(QLayout::SetMaximumSize);
task_tab4_scrollwidget->setLayout(task_tab4_scrolllayout); task_tab4_scrollwidget->setLayout(task_tab4_scrolllayout);
filter_size_slider = new QSlider(Qt::Horizontal);
filter_size_slider->setMinimum(0);
filter_size_slider->setMaximum(4);
filter_size_slider->setValue(0);
QObject::connect(filter_size_slider, SIGNAL(valueChanged(int)), this, SLOT(changeFilterSize(int)));
filter_gui = new FilterGui();
task_tab4_scrolllayout->addWidget(filter_size_slider);
task_tab4_scrolllayout->addWidget(filter_gui->getWidget());
tabWidget->addTab(task_tab4_widget, "Task #4"); tabWidget->addTab(task_tab4_widget, "Task #4");

View File

@ -55,6 +55,7 @@
#include <iostream> #include <iostream>
#include "lazy_image.cpp" #include "lazy_image.cpp"
#include "filter_gui.cpp"
class QAction; class QAction;
class QLabel; class QLabel;
@ -131,6 +132,9 @@ class ImageViewer : public QMainWindow {
QScrollArea* task_tab4_scrollarea; QScrollArea* task_tab4_scrollarea;
QVBoxLayout* task_tab4_scrolllayout; QVBoxLayout* task_tab4_scrolllayout;
QSlider* filter_size_slider;
FilterGui* filter_gui;
// "My" space for storing data/results // "My" space for storing data/results
LazyImage* original; LazyImage* original;
LazyImage* working_copy; LazyImage* working_copy;
@ -151,6 +155,7 @@ class ImageViewer : public QMainWindow {
void linearHistogrammAdaption(); void linearHistogrammAdaption();
void partialLinearHistogrammAdaption(); void partialLinearHistogrammAdaption();
void succeedingHistogrammAdaption(); void succeedingHistogrammAdaption();
void changeFilterSize(int s);
void open(); void open();
void openReference(); void openReference();