From a8365ea1f5a5032ccfa633793b980062ce5b82c7 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Fri, 27 Nov 2015 13:53:39 +0100 Subject: [PATCH] [TASK] Add a TableWidget for the filter value input. --- filter_gui.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++ imageviewer-qt4.cpp | 15 ++++++++++++ imageviewer-qt4.h | 5 ++++ 3 files changed, 78 insertions(+) create mode 100644 filter_gui.cpp diff --git a/filter_gui.cpp b/filter_gui.cpp new file mode 100644 index 0000000..e2e0d52 --- /dev/null +++ b/filter_gui.cpp @@ -0,0 +1,58 @@ +#ifndef FILTER_GUI_C +#define FILTER_GUI_C + +#include +#include +#include +#include +#include + +#include + +#include + +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; ifilter_size; i++) { + for(int j=0; jfilter_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 diff --git a/imageviewer-qt4.cpp b/imageviewer-qt4.cpp index 5c92099..b98cca0 100644 --- a/imageviewer-qt4.cpp +++ b/imageviewer-qt4.cpp @@ -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() { // Tab for first task task_tab1_widget = new QWidget(); @@ -686,7 +692,16 @@ void ImageViewer::generateControlPanels() { task_tab4_scrolllayout->setSizeConstraint(QLayout::SetMaximumSize); 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"); diff --git a/imageviewer-qt4.h b/imageviewer-qt4.h index 67bbcd2..829b1a3 100644 --- a/imageviewer-qt4.h +++ b/imageviewer-qt4.h @@ -55,6 +55,7 @@ #include #include "lazy_image.cpp" +#include "filter_gui.cpp" class QAction; class QLabel; @@ -131,6 +132,9 @@ class ImageViewer : public QMainWindow { QScrollArea* task_tab4_scrollarea; QVBoxLayout* task_tab4_scrolllayout; + QSlider* filter_size_slider; + FilterGui* filter_gui; + // "My" space for storing data/results LazyImage* original; LazyImage* working_copy; @@ -151,6 +155,7 @@ class ImageViewer : public QMainWindow { void linearHistogrammAdaption(); void partialLinearHistogrammAdaption(); void succeedingHistogrammAdaption(); + void changeFilterSize(int s); void open(); void openReference();