[TASK] Finish prepare the filter gui part.
This commit is contained in:
parent
a8365ea1f5
commit
ae501ec6be
|
@ -16,27 +16,54 @@ class FilterGui {
|
|||
private:
|
||||
QTableWidget* widget;
|
||||
|
||||
int filter_size;
|
||||
int size;
|
||||
int* data;
|
||||
|
||||
void recreateDataStorage() {
|
||||
if(data != NULL) {
|
||||
delete data;
|
||||
data = NULL;
|
||||
}
|
||||
int fields = this->size * this->size;
|
||||
data = (int*) malloc(sizeof(int) * fields);
|
||||
for(int i=0; i<fields; i++) data[i] = 0;
|
||||
}
|
||||
|
||||
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->setRowCount(this->size);
|
||||
this->widget->setColumnCount(this->size);
|
||||
for(int i=0; i<this->size; i++) {
|
||||
for(int j=0; j<this->size; j++) {
|
||||
this->widget->setItem(i, j, new QTableWidgetItem("0"));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void fetchData() {
|
||||
for(int i=0; i<this->size; i++) {
|
||||
for(int j=0; j<this->size; j++) {
|
||||
QString temp = this->widget->item(i, j)->text();
|
||||
this->data[i*this->size + j] = temp.toInt();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
FilterGui(int filter_size = 3) {
|
||||
this->data = NULL;
|
||||
this->widget = new QTableWidget();
|
||||
this->setSize(filter_size);
|
||||
};
|
||||
|
||||
~FilterGui() {
|
||||
delete this->widget;
|
||||
this->widget = NULL;
|
||||
if(this->widget != NULL) {
|
||||
delete this->widget;
|
||||
this->widget = NULL;
|
||||
}
|
||||
if(this->data != NULL) {
|
||||
delete this->data;
|
||||
this->data = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
QTableWidget* getWidget() {
|
||||
|
@ -44,14 +71,20 @@ class FilterGui {
|
|||
};
|
||||
|
||||
void setSize(int size) {
|
||||
this->filter_size = size;
|
||||
this->size = size;
|
||||
this->updateGui();
|
||||
};
|
||||
|
||||
int getSize() {
|
||||
return this->filter_size;
|
||||
return this->size;
|
||||
};
|
||||
|
||||
int* getData() {
|
||||
this->recreateDataStorage();
|
||||
this->fetchData();
|
||||
return this->data;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -472,6 +472,21 @@ void ImageViewer::succeedingHistogrammAdaption() {
|
|||
updateImageDisplay();
|
||||
}
|
||||
|
||||
void ImageViewer::applyFilter() {
|
||||
logFile << "Applying filter ...";
|
||||
|
||||
int* data = filter_gui->getData();
|
||||
|
||||
for(int i=0; i<filter_gui->getSize(); i++) {
|
||||
for(int j=0; j<filter_gui->getSize(); j++) {
|
||||
logFile << "@" << i << "," << j << " -> " << data[i*filter_gui->getSize() + j] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
logFile << "done." << std::endl;
|
||||
renewLogging();
|
||||
//updateImageDisplay();
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
|
@ -700,8 +715,12 @@ void ImageViewer::generateControlPanels() {
|
|||
|
||||
filter_gui = new FilterGui();
|
||||
|
||||
apply_filter = new QPushButton("Apply filter");
|
||||
QObject::connect(apply_filter, SIGNAL(clicked()), this, SLOT(applyFilter()));
|
||||
|
||||
task_tab4_scrolllayout->addWidget(filter_size_slider);
|
||||
task_tab4_scrolllayout->addWidget(filter_gui->getWidget());
|
||||
task_tab4_scrolllayout->addWidget(apply_filter);
|
||||
|
||||
tabWidget->addTab(task_tab4_widget, "Task #4");
|
||||
|
||||
|
|
|
@ -134,6 +134,7 @@ class ImageViewer : public QMainWindow {
|
|||
|
||||
QSlider* filter_size_slider;
|
||||
FilterGui* filter_gui;
|
||||
QPushButton* apply_filter;
|
||||
|
||||
// "My" space for storing data/results
|
||||
LazyImage* original;
|
||||
|
@ -156,6 +157,7 @@ class ImageViewer : public QMainWindow {
|
|||
void partialLinearHistogrammAdaption();
|
||||
void succeedingHistogrammAdaption();
|
||||
void changeFilterSize(int s);
|
||||
void applyFilter();
|
||||
|
||||
void open();
|
||||
void openReference();
|
||||
|
|
Loading…
Reference in New Issue