Skip to content
Snippets Groups Projects
Commit e2428718 authored by Provot Bertrand's avatar Provot Bertrand
Browse files

filter update part3: cleaner interface & no more comments

parent b60b2c2b
No related branches found
No related tags found
No related merge requests found
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <QPushButton> #include <QPushButton>
#include <QSpinBox> #include <QSpinBox>
#include <QTableView> #include <QTableView>
#include <QTextEdit> #include <QLineEdit>
#include <QFile> #include <QFile>
#include <QDomDocument> #include <QDomDocument>
...@@ -98,13 +98,9 @@ void FilterChoice::initUI() ...@@ -98,13 +98,9 @@ void FilterChoice::initUI()
_labelCustom = new QLabel(this); _labelCustom = new QLabel(this);
_labelCustom->setText(tr("Path to custom filter:")); _labelCustom->setText(tr("Path to custom filter:"));
_filterPath = new QTextEdit("/"); _filterPath = new QLineEdit("/");
// _filterPath->setMaximumWidth(200);
_filterPath->setReadOnly(true); _filterPath->setReadOnly(true);
// _filterPath->setMaximumHeight(25);
_filterPath->setLineWrapMode(QTextEdit::FixedColumnWidth);
_filterPath->setLineWrapColumnOrWidth(190);
_filterPathSelect = new QPushButton("..."); _filterPathSelect = new QPushButton("...");
_filterPathSelect->setFixedWidth(40); _filterPathSelect->setFixedWidth(40);
_pathLayout = new QHBoxLayout(); _pathLayout = new QHBoxLayout();
...@@ -173,7 +169,6 @@ void FilterChoice::initUI() ...@@ -173,7 +169,6 @@ void FilterChoice::initUI()
QObject::connect(_number, SIGNAL(valueChanged(const QString&)), this, SLOT(dataChanged(const QString&))); QObject::connect(_number, SIGNAL(valueChanged(const QString&)), this, SLOT(dataChanged(const QString&)));
QObject::connect(_stdDevBox, SIGNAL(valueChanged(const QString&)), this, SLOT(dataChanged(const QString&))); QObject::connect(_stdDevBox, SIGNAL(valueChanged(const QString&)), this, SLOT(dataChanged(const QString&)));
QObject::connect(_filterPathSelect, SIGNAL(clicked()), this, SLOT(openFile())); QObject::connect(_filterPathSelect, SIGNAL(clicked()), this, SLOT(openFile()));
QObject::connect(_filterPath, SIGNAL(textChanged()), this, SLOT(updatePath()));
QWidget* rightWidget = new QWidget(); QWidget* rightWidget = new QWidget();
...@@ -224,12 +219,8 @@ void FilterChoice::initUI() ...@@ -224,12 +219,8 @@ void FilterChoice::initUI()
*/ */
QStringList FilterChoice::initFilters() { QStringList FilterChoice::initFilters() {
QStringList blurs = QStringList(); QStringList blurs = QStringList();
std::cout << "------\n";
std::cout << "IN INITFILTER\n";
std::cout << "is custom button checked ?" << _customButton->isChecked() << "\n";
if(!_customButton->isChecked()){ if(!_customButton->isChecked()){
std::cout << "not checked\n";
blurs << tr("Uniform") << tr("Gaussian") << tr("Prewitt") << tr("Roberts") << tr("Sobel") << tr("SquareLaplacien"); blurs << tr("Uniform") << tr("Gaussian") << tr("Prewitt") << tr("Roberts") << tr("Sobel") << tr("SquareLaplacien");
_filters.push_back(Filter::uniform(3)); _filters.push_back(Filter::uniform(3));
_filters.push_back(Filter::gaussian(3, 1.)); _filters.push_back(Filter::gaussian(3, 1.));
...@@ -237,7 +228,6 @@ QStringList FilterChoice::initFilters() { ...@@ -237,7 +228,6 @@ QStringList FilterChoice::initFilters() {
_filters.push_back(Filter::roberts()); _filters.push_back(Filter::roberts());
_filters.push_back(Filter::sobel()); _filters.push_back(Filter::sobel());
_filters.push_back(Filter::squareLaplacien()); _filters.push_back(Filter::squareLaplacien());
std::cout << "filters size : " << _filters.size() << "\n";
} }
else{ else{
//Personal filters //Personal filters
...@@ -304,21 +294,12 @@ QStringList FilterChoice::initFilters() { ...@@ -304,21 +294,12 @@ QStringList FilterChoice::initFilters() {
* @param z * @param z
*/ */
void FilterChoice::updateBlur(bool){ void FilterChoice::updateBlur(bool){
std::cout << "#########\n";
std::cout << "IN UPDATE BLUR \n";
std::cout << "filters size:" << _filters.size() << "\n";
_filters.clear(); _filters.clear();
std::cout << "filters size after clearance:" << _filters.size() << "\n";
std::cout << "blur choices count:" << _blurChoices->count() <<"\n";
if(_blurChoices->count()!=0){ if(_blurChoices->count()!=0){
_blurChoices->clear(); _blurChoices->clear();
} }
QStringList blurs = initFilters(); QStringList blurs = initFilters();
_blurChoices->addItems(blurs); _blurChoices->addItems(blurs);
std::cout << "filters size when exiting updateblur:" << _filters.size() << "\n";
std::cout << "current index : " << _blurChoices->currentIndex() << "\n";
std::cout << "OUT UPDATE BLUR \n";
std::cout << "#-#-#-#-#\n";
} }
/** /**
...@@ -327,7 +308,6 @@ void FilterChoice::updateBlur(bool){ ...@@ -327,7 +308,6 @@ void FilterChoice::updateBlur(bool){
* @param a selects whether or not the custom filter are enabled * @param a selects whether or not the custom filter are enabled
*/ */
void FilterChoice::showCustom(bool a){ void FilterChoice::showCustom(bool a){
std::cout << "in showcustom\n";
if(a){ if(a){
_labelCustom->setVisible(true); _labelCustom->setVisible(true);
_filterPath->setVisible(true); _filterPath->setVisible(true);
...@@ -339,7 +319,6 @@ void FilterChoice::showCustom(bool a){ ...@@ -339,7 +319,6 @@ void FilterChoice::showCustom(bool a){
_filterPath->setVisible(false); _filterPath->setVisible(false);
_filterPathSelect->setVisible(false); _filterPathSelect->setVisible(false);
} }
std::cout << "out showcustom \n";
_a=false; _a=false;
} }
...@@ -371,37 +350,45 @@ void FilterChoice::dataChanged(const QString&) ...@@ -371,37 +350,45 @@ void FilterChoice::dataChanged(const QString&)
void FilterChoice::validate() void FilterChoice::validate()
{ {
int num = _number->value(); int num = _number->value();
switch(_blurChoices->currentIndex()) if(_blurChoices->currentIndex()==-1){
{ QMessageBox msgBox(QMessageBox::Critical, tr("Error!"), tr("Filter application is impossible."));
case 0: msgBox.setInformativeText(tr("Filter selection is empty, please select a filter."));
_filtering = new Filtering(Filtering::uniformBlur(num)); msgBox.setStandardButtons(QMessageBox::Ok);
break; msgBox.setDefaultButton(QMessageBox::Ok);
case 1: msgBox.exec();
_filtering = new Filtering(Filtering::gaussianBlur(num, _stdDevBox->value())); }else{
break; switch(_blurChoices->currentIndex())
case 2: {
_filtering = new Filtering(Filtering::prewitt(num)); case 0:
break; _filtering = new Filtering(Filtering::uniformBlur(num));
default: break;
_filtering = new Filtering(_filters[_blurChoices->currentIndex()]); case 1:
} _filtering = new Filtering(Filtering::gaussianBlur(num, _stdDevBox->value()));
break;
switch(_policyChoices->currentIndex()) case 2:
{ _filtering = new Filtering(Filtering::prewitt(num));
case 1: break;
_filtering->setPolicy(Filtering::POLICY_MIRROR); default:
break; _filtering = new Filtering(_filters[_blurChoices->currentIndex()]);
case 2: }
_filtering->setPolicy(Filtering::POLICY_NEAREST);
break; switch(_policyChoices->currentIndex())
case 3: {
_filtering->setPolicy(Filtering::POLICY_TOR); case 1:
break; _filtering->setPolicy(Filtering::POLICY_MIRROR);
default: break;
_filtering->setPolicy(Filtering::POLICY_BLACK); case 2:
_filtering->setPolicy(Filtering::POLICY_NEAREST);
break;
case 3:
_filtering->setPolicy(Filtering::POLICY_TOR);
break;
default:
_filtering->setPolicy(Filtering::POLICY_BLACK);
}
this->accept();
} }
this->accept();
} }
/** /**
...@@ -467,7 +454,6 @@ void FilterChoice::deleteFilter() ...@@ -467,7 +454,6 @@ void FilterChoice::deleteFilter()
*/ */
void FilterChoice::updateDisplay() void FilterChoice::updateDisplay()
{ {
std::cout << "we are in the switch\n";
std::vector<Filter*> filters; std::vector<Filter*> filters;
_deleteButton->setEnabled(false); _deleteButton->setEnabled(false);
int num = _number->value(); int num = _number->value();
...@@ -476,7 +462,6 @@ void FilterChoice::updateDisplay() ...@@ -476,7 +462,6 @@ void FilterChoice::updateDisplay()
switch(_blurChoices->currentIndex()) switch(_blurChoices->currentIndex())
{ {
case 0: case 0:
std::cout << "past case0\n";
filters = Filter::uniform(num); filters = Filter::uniform(num);
_number->show(); _number->show();
_labelNumber->show(); _labelNumber->show();
...@@ -484,7 +469,6 @@ void FilterChoice::updateDisplay() ...@@ -484,7 +469,6 @@ void FilterChoice::updateDisplay()
_stdDevLabel->hide(); _stdDevLabel->hide();
break; break;
case 1: case 1:
std::cout << "past case1\n";
filters = Filter::gaussian(num, _stdDevBox->value()); filters = Filter::gaussian(num, _stdDevBox->value());
_number->show(); _number->show();
_labelNumber->show(); _labelNumber->show();
...@@ -492,7 +476,6 @@ void FilterChoice::updateDisplay() ...@@ -492,7 +476,6 @@ void FilterChoice::updateDisplay()
_stdDevLabel->show(); _stdDevLabel->show();
break; break;
case 2: case 2:
std::cout << "past case2\n";
filters = Filter::prewitt(num); filters = Filter::prewitt(num);
_number->show(); _number->show();
_labelNumber->show(); _labelNumber->show();
...@@ -500,15 +483,11 @@ void FilterChoice::updateDisplay() ...@@ -500,15 +483,11 @@ void FilterChoice::updateDisplay()
_stdDevLabel->hide(); _stdDevLabel->hide();
break; break;
default: default:
std::cout << "past default\n";
std::cout << filters.size();
std::cout << _filters.size();
filters = _filters[_blurChoices->currentIndex()]; filters = _filters[_blurChoices->currentIndex()];
_number->hide(); _number->hide();
_labelNumber->hide(); _labelNumber->hide();
_stdDevBox->hide(); _stdDevBox->hide();
_stdDevLabel->hide(); _stdDevLabel->hide();
std::cout << "outt default\n";
} }
}else{ }else{
filters = _filters[_blurChoices->currentIndex()]; filters = _filters[_blurChoices->currentIndex()];
...@@ -585,9 +564,10 @@ void FilterChoice::openFile() { ...@@ -585,9 +564,10 @@ void FilterChoice::openFile() {
QString file = QFileDialog::getOpenFileName(this, tr("Open a file"), QString(), tr("XML Documents (*.xml)")); QString file = QFileDialog::getOpenFileName(this, tr("Open a file"), QString(), tr("XML Documents (*.xml)"));
if(file.size()==0) return; if(file.size()==0) return;
_filterPath->setText(file); _filterPath->setText(file);
updatePath();
} }
void FilterChoice::updatePath(){ void FilterChoice::updatePath(){
_path = _filterPath->toPlainText(); _path = _filterPath->text();
updateBlur(true); updateBlur(true);
} }
...@@ -81,7 +81,7 @@ namespace filtrme ...@@ -81,7 +81,7 @@ namespace filtrme
QComboBox* _policyChoices; QComboBox* _policyChoices;
QLabel* _label; QLabel* _label;
QTextEdit* _filterPath; QLineEdit* _filterPath;
QPushButton* _filterPathSelect; QPushButton* _filterPathSelect;
QLabel* _labelCustom; QLabel* _labelCustom;
QRadioButton* _stdButton; QRadioButton* _stdButton;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment