Commit daa8aa9b45555e5f44f2b6008e4cbd4e2628f50c
1 parent
1b811e50
Added gui constructs to facilitate rankRetrieval
Showing
8 changed files
with
460 additions
and
0 deletions
openbr/gui/formcombowidget.cpp
0 → 100644
| 1 | +#include "formcombowidget.h" | ||
| 2 | + | ||
| 3 | +using namespace br; | ||
| 4 | + | ||
| 5 | +FormComboWidget::FormComboWidget(const QString &name, QWidget *parent) : | ||
| 6 | + QWidget(parent) | ||
| 7 | +{ | ||
| 8 | + combo = new QComboBox(this); | ||
| 9 | + form = new QFormLayout(this); | ||
| 10 | + | ||
| 11 | + form->addRow(name, combo); | ||
| 12 | + | ||
| 13 | + connect(combo, SIGNAL(activated(QString)), this, SIGNAL(activated(QString))); | ||
| 14 | + connect(combo, SIGNAL(currentIndexChanged(QString)), this, SIGNAL(currentIndexChanged(QString))); | ||
| 15 | +} |
openbr/gui/formcombowidget.h
0 → 100644
| 1 | +#ifndef BR_FORMCOMBOWIDGET_H | ||
| 2 | +#define BR_FORMCOMBOWIDGET_H | ||
| 3 | + | ||
| 4 | +#include <QWidget> | ||
| 5 | +#include <QFormLayout> | ||
| 6 | +#include <QStringList> | ||
| 7 | +#include <QComboBox> | ||
| 8 | + | ||
| 9 | +#include <openbr/openbr_plugin.h> | ||
| 10 | + | ||
| 11 | +namespace br { | ||
| 12 | + | ||
| 13 | +class BR_EXPORT FormComboWidget : public QWidget | ||
| 14 | +{ | ||
| 15 | + Q_OBJECT | ||
| 16 | + | ||
| 17 | + QStringList items; | ||
| 18 | + QFormLayout *form; | ||
| 19 | + QComboBox *combo; | ||
| 20 | + | ||
| 21 | +public: | ||
| 22 | + explicit FormComboWidget(const QString &name, QWidget *parent = 0); | ||
| 23 | + | ||
| 24 | +public slots: | ||
| 25 | + void addItem(const QString &str) { items.append(str); combo->clear(); combo->addItems(items); } | ||
| 26 | + | ||
| 27 | +signals: | ||
| 28 | + void activated(QString); | ||
| 29 | + void currentIndexChanged(QString); | ||
| 30 | +}; | ||
| 31 | + | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +#endif // BR_FORMCOMBOWIDGET_H |
openbr/gui/pageflipwidget.cpp
0 → 100644
| 1 | +#include "pageflipwidget.h" | ||
| 2 | + | ||
| 3 | +using namespace br; | ||
| 4 | + | ||
| 5 | +PageFlipWidget::PageFlipWidget(QWidget *parent) : | ||
| 6 | + QWidget(parent) | ||
| 7 | +{ | ||
| 8 | + firstPage = new QPushButton(this); | ||
| 9 | + firstPage->setIcon(QIcon(":/arrow-first.png")); | ||
| 10 | + firstPage->setMaximumWidth(30); | ||
| 11 | + firstPage->setToolTip("Go to first page"); | ||
| 12 | + | ||
| 13 | + connect(firstPage, SIGNAL(clicked()), this, SIGNAL(first())); | ||
| 14 | + | ||
| 15 | + previousPage = new QPushButton(this); | ||
| 16 | + previousPage->setIcon(QIcon(":/arrow-left.png")); | ||
| 17 | + previousPage->setMaximumWidth(30); | ||
| 18 | + previousPage->setToolTip("Go to previous page"); | ||
| 19 | + | ||
| 20 | + connect(previousPage, SIGNAL(clicked()), this, SIGNAL(previous())); | ||
| 21 | + | ||
| 22 | + nextPage = new QPushButton(this); | ||
| 23 | + nextPage->setIcon(QIcon(":/arrow-right.png")); | ||
| 24 | + nextPage->setMaximumWidth(30); | ||
| 25 | + nextPage->setToolTip("Go to next page"); | ||
| 26 | + | ||
| 27 | + connect(nextPage, SIGNAL(clicked()), this, SIGNAL(next())); | ||
| 28 | + | ||
| 29 | + lastPage = new QPushButton(this); | ||
| 30 | + lastPage->setIcon(QIcon(":/arrow-last.png")); | ||
| 31 | + lastPage->setMaximumWidth(30); | ||
| 32 | + lastPage->setToolTip("Go to last page"); | ||
| 33 | + | ||
| 34 | + connect(lastPage, SIGNAL(clicked()), this, SIGNAL(last())); | ||
| 35 | + | ||
| 36 | + boxLayout.addWidget(firstPage); | ||
| 37 | + boxLayout.addWidget(previousPage); | ||
| 38 | + boxLayout.addWidget(nextPage); | ||
| 39 | + boxLayout.addWidget(lastPage); | ||
| 40 | + | ||
| 41 | + setLayout(&boxLayout); | ||
| 42 | +} |
openbr/gui/pageflipwidget.h
0 → 100644
| 1 | +#ifndef BR_PAGEFLIPWIDGET_H | ||
| 2 | +#define BR_PAGEFLIPWIDGET_H | ||
| 3 | + | ||
| 4 | +#include <QWidget> | ||
| 5 | +#include <QPushButton> | ||
| 6 | +#include <QHBoxLayout> | ||
| 7 | + | ||
| 8 | +#include <openbr/openbr_plugin.h> | ||
| 9 | + | ||
| 10 | +namespace br { | ||
| 11 | + | ||
| 12 | +class BR_EXPORT PageFlipWidget : public QWidget | ||
| 13 | +{ | ||
| 14 | + Q_OBJECT | ||
| 15 | + | ||
| 16 | + QHBoxLayout boxLayout; | ||
| 17 | + | ||
| 18 | + QPushButton *firstPage; | ||
| 19 | + QPushButton *previousPage; | ||
| 20 | + QPushButton *nextPage; | ||
| 21 | + QPushButton *lastPage; | ||
| 22 | + | ||
| 23 | +public: | ||
| 24 | + explicit PageFlipWidget(QWidget *parent = 0); | ||
| 25 | + | ||
| 26 | +signals: | ||
| 27 | + | ||
| 28 | + void first(); | ||
| 29 | + void next(); | ||
| 30 | + void previous(); | ||
| 31 | + void last(); | ||
| 32 | + | ||
| 33 | +public slots: | ||
| 34 | + | ||
| 35 | +}; | ||
| 36 | + | ||
| 37 | +} // namespace br | ||
| 38 | + | ||
| 39 | +#endif // BR_PAGEFLIPWIDGET_H |
openbr/gui/rangewidget.cpp
0 → 100644
| 1 | +#include "rangewidget.h" | ||
| 2 | + | ||
| 3 | +using namespace br; | ||
| 4 | + | ||
| 5 | +RangeWidget::RangeWidget(QWidget *parent) : | ||
| 6 | + QWidget(parent) | ||
| 7 | +{ | ||
| 8 | + hLayout = new QHBoxLayout(); | ||
| 9 | + | ||
| 10 | + validator = new QIntValidator(0,100,this); | ||
| 11 | + | ||
| 12 | + median = new QLineEdit("20", this); | ||
| 13 | + median->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); | ||
| 14 | + median->setAlignment(Qt::AlignCenter); | ||
| 15 | + median->setValidator(validator); | ||
| 16 | + | ||
| 17 | + rangeSpin = new QSpinBox(this); | ||
| 18 | + rangeSpin->setValue(0); | ||
| 19 | + rangeSpin->setAlignment(Qt::AlignCenter); | ||
| 20 | + | ||
| 21 | + label = new QLabel(this); | ||
| 22 | + label->setAlignment(Qt::AlignCenter); | ||
| 23 | + label->setText(QString::fromUtf8("±")); | ||
| 24 | + | ||
| 25 | + hLayout->addWidget(median); | ||
| 26 | + hLayout->addWidget(label); | ||
| 27 | + hLayout->addWidget(rangeSpin); | ||
| 28 | + hLayout->setSpacing(0); | ||
| 29 | + | ||
| 30 | + connect(median, SIGNAL(textChanged(QString)), this, SLOT(rangeChanged())); | ||
| 31 | + connect(rangeSpin, SIGNAL(valueChanged(int)), this, SLOT(rangeChanged())); | ||
| 32 | + | ||
| 33 | + vLayout.addLayout(hLayout); | ||
| 34 | + | ||
| 35 | + setLayout(&vLayout); | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +void RangeWidget::setSingleStep(int step) | ||
| 39 | +{ | ||
| 40 | + rangeSpin->setSingleStep(step); | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +void RangeWidget::rangeChanged() | ||
| 44 | +{ | ||
| 45 | + emit newRange(median->text().toInt() - rangeSpin->value(), median->text().toInt() + rangeSpin->value()); | ||
| 46 | + emit newRange(); | ||
| 47 | +} |
openbr/gui/rangewidget.h
0 → 100644
| 1 | +#ifndef BR_RANGEWIDGET_H | ||
| 2 | +#define BR_RANGEWIDGET_H | ||
| 3 | + | ||
| 4 | +#include <QWidget> | ||
| 5 | +#include <QLineEdit> | ||
| 6 | +#include <QHBoxLayout> | ||
| 7 | +#include <QIntValidator> | ||
| 8 | +#include <QLabel> | ||
| 9 | +#include <QSpinBox> | ||
| 10 | + | ||
| 11 | +#include <openbr/openbr_plugin.h> | ||
| 12 | + | ||
| 13 | +namespace br { | ||
| 14 | + | ||
| 15 | +class BR_EXPORT RangeWidget : public QWidget | ||
| 16 | +{ | ||
| 17 | + Q_OBJECT | ||
| 18 | + | ||
| 19 | + QVBoxLayout vLayout; | ||
| 20 | + QHBoxLayout *hLayout; | ||
| 21 | + | ||
| 22 | + QIntValidator *validator; | ||
| 23 | + | ||
| 24 | + QLabel *label; | ||
| 25 | + QLineEdit *median; | ||
| 26 | + QSpinBox *rangeSpin; | ||
| 27 | + | ||
| 28 | +public: | ||
| 29 | + explicit RangeWidget(QWidget *parent = 0); | ||
| 30 | + | ||
| 31 | +signals: | ||
| 32 | + | ||
| 33 | + void newRange(int, int); | ||
| 34 | + void newRange(); | ||
| 35 | + | ||
| 36 | +public slots: | ||
| 37 | + | ||
| 38 | + void emitRange() { rangeChanged(); } | ||
| 39 | + int getLowerBound() const {return median->text().toInt() - rangeSpin->value();} | ||
| 40 | + int getUpperBound() const {return median->text().toInt() + rangeSpin->value();} | ||
| 41 | + void rangeChanged(); | ||
| 42 | + void setSingleStep(int step); | ||
| 43 | + | ||
| 44 | +}; | ||
| 45 | + | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +#endif // BR_AGERANGEWIDGET_H |
openbr/gui/recognitionbar.cpp
0 → 100644
| 1 | +#include "recognitionbar.h" | ||
| 2 | + | ||
| 3 | +#include <QFileDialog> | ||
| 4 | + | ||
| 5 | +using namespace br; | ||
| 6 | + | ||
| 7 | +RecognitionBar::RecognitionBar(QWidget *parent) : | ||
| 8 | + QToolBar(parent) | ||
| 9 | +{ | ||
| 10 | + setToolButtonStyle(Qt::ToolButtonTextOnly); | ||
| 11 | + | ||
| 12 | + addSeparator(); | ||
| 13 | + | ||
| 14 | + algorithmLabel = new QLabel(this); | ||
| 15 | + algorithmLabel->setAlignment(Qt::AlignCenter); | ||
| 16 | + algorithmLabel->setTextFormat(Qt::RichText); | ||
| 17 | + algorithmLabel->setText("<img src=:/algorithm.png> Algorithm"); | ||
| 18 | + addWidget(algorithmLabel); | ||
| 19 | + | ||
| 20 | + model = new FormComboWidget("Model: ", this); | ||
| 21 | + addWidget(model); | ||
| 22 | + | ||
| 23 | + connect(model, SIGNAL(currentIndexChanged(QString)), this, SIGNAL(newAlgorithm(QString))); | ||
| 24 | + | ||
| 25 | + landmarkCheck = new QCheckBox("Show Landmarks", this); | ||
| 26 | + addWidget(landmarkCheck); | ||
| 27 | + | ||
| 28 | + connect(landmarkCheck, SIGNAL(clicked(bool)), this, SIGNAL(showLandmarks(bool))); | ||
| 29 | + | ||
| 30 | + addSeparator(); | ||
| 31 | + | ||
| 32 | + demographicsLabel = new QLabel(this); | ||
| 33 | + demographicsLabel->setAlignment(Qt::AlignCenter); | ||
| 34 | + demographicsLabel->setTextFormat(Qt::RichText); | ||
| 35 | + demographicsLabel->setText("<img src=:/demographics.png> Demographics"); | ||
| 36 | + addWidget(demographicsLabel); | ||
| 37 | + | ||
| 38 | + maleCheck = new QCheckBox("Male", this); | ||
| 39 | + addWidget(maleCheck); | ||
| 40 | + femaleCheck = new QCheckBox("Female", this); | ||
| 41 | + addWidget(femaleCheck); | ||
| 42 | + | ||
| 43 | + connect(maleCheck, SIGNAL(clicked()), this, SLOT(genderChanged())); | ||
| 44 | + connect(femaleCheck, SIGNAL(clicked()), this, SLOT(genderChanged())); | ||
| 45 | + | ||
| 46 | + addSeparator(); | ||
| 47 | + | ||
| 48 | + whiteCheck = new QCheckBox("White", this); | ||
| 49 | + addWidget(whiteCheck); | ||
| 50 | + connect(whiteCheck, SIGNAL(clicked()), this, SLOT(raceChanged())); | ||
| 51 | + blackCheck = new QCheckBox("Black", this); | ||
| 52 | + addWidget(blackCheck); | ||
| 53 | + connect(blackCheck, SIGNAL(clicked()), this, SLOT(raceChanged())); | ||
| 54 | + hispanicCheck = new QCheckBox("Hispanic", this); | ||
| 55 | + addWidget(hispanicCheck); | ||
| 56 | + connect(hispanicCheck, SIGNAL(clicked()), this, SLOT(raceChanged())); | ||
| 57 | + asianCheck = new QCheckBox("Oriental/Asian", this); | ||
| 58 | + addWidget(asianCheck); | ||
| 59 | + connect(hispanicCheck, SIGNAL(clicked()), this, SLOT(raceChanged())); | ||
| 60 | + otherCheck = new QCheckBox("Other", this); | ||
| 61 | + addWidget(otherCheck); | ||
| 62 | + connect(otherCheck, SIGNAL(clicked()), this, SLOT(raceChanged())); | ||
| 63 | + | ||
| 64 | + addSeparator(); | ||
| 65 | + | ||
| 66 | + ageCheck = new QCheckBox("Age", this); | ||
| 67 | + addWidget(ageCheck); | ||
| 68 | + connect(ageCheck, SIGNAL(clicked()), this, SLOT(ageRangeChanged())); | ||
| 69 | + | ||
| 70 | + rangeWidget = new RangeWidget(this); | ||
| 71 | + connect(rangeWidget, SIGNAL(newRange(int,int)), this, SLOT(ageRangeChanged())); | ||
| 72 | + addWidget(rangeWidget); | ||
| 73 | + | ||
| 74 | + addSeparator(); | ||
| 75 | + | ||
| 76 | + findLabel = new QLabel(this); | ||
| 77 | + findLabel->setAlignment(Qt::AlignCenter); | ||
| 78 | + findLabel->setTextFormat(Qt::RichText); | ||
| 79 | + findLabel->setText("<img src=:/sketch.png> Find"); | ||
| 80 | + | ||
| 81 | + addWidget(findLabel); | ||
| 82 | + | ||
| 83 | + searchBox = new SearchBoxWidget(this); | ||
| 84 | + connect(this, SIGNAL(setFiles(br::FileList)), searchBox, SLOT(setFiles(br::FileList))); | ||
| 85 | + connect(searchBox, SIGNAL(newIndex(int)), this, SIGNAL(newIndex(int))); | ||
| 86 | + | ||
| 87 | + addWidget(searchBox); | ||
| 88 | + | ||
| 89 | + metadata = new Metadata(this); | ||
| 90 | + | ||
| 91 | + addWidget(metadata); | ||
| 92 | + | ||
| 93 | + spacer = new QWidget(this); | ||
| 94 | + spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | ||
| 95 | + addWidget(spacer); | ||
| 96 | + | ||
| 97 | + compareButton = new QPushButton(this); | ||
| 98 | + compareButton->setText("Compare"); | ||
| 99 | + compareButton->setIcon(QIcon(":/compare.png")); | ||
| 100 | + addWidget(compareButton); | ||
| 101 | + compareButton->setFocus(); | ||
| 102 | + | ||
| 103 | + connect(compareButton, SIGNAL(clicked()), this, SIGNAL(compare())); | ||
| 104 | + | ||
| 105 | + setOrientation(Qt::Vertical); | ||
| 106 | + | ||
| 107 | + addSeparator(); | ||
| 108 | + | ||
| 109 | + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); | ||
| 110 | +} | ||
| 111 | + | ||
| 112 | +void RecognitionBar::addAlgorithm() | ||
| 113 | +{ | ||
| 114 | + model->addItem(QFileDialog::getOpenFileName(this, "Add a model...", Context::scratchPath())); | ||
| 115 | +} | ||
| 116 | + | ||
| 117 | +void RecognitionBar::genderChanged() | ||
| 118 | +{ | ||
| 119 | + QStringList genders; | ||
| 120 | + | ||
| 121 | + if (maleCheck->isChecked()) genders.push_back(maleCheck->text()[0].toUpper()); | ||
| 122 | + if (femaleCheck->isChecked()) genders.push_back(femaleCheck->text()[0].toUpper()); | ||
| 123 | + | ||
| 124 | + emit newDemographics("GENDER", genders); | ||
| 125 | +} | ||
| 126 | + | ||
| 127 | +void RecognitionBar::raceChanged() | ||
| 128 | +{ | ||
| 129 | + QStringList races; | ||
| 130 | + | ||
| 131 | + if (whiteCheck->isChecked()) races.push_back(whiteCheck->text().toUpper()); | ||
| 132 | + if (blackCheck->isChecked()) races.push_back(blackCheck->text().toUpper()); | ||
| 133 | + if (hispanicCheck->isChecked()) races.push_back(hispanicCheck->text().toUpper()); | ||
| 134 | + if (asianCheck->isChecked()) races.push_back(asianCheck->text().toUpper()); | ||
| 135 | + if (otherCheck->isChecked()) races.push_back(otherCheck->text().toUpper()); | ||
| 136 | + | ||
| 137 | + emit newDemographics("RACE", races); | ||
| 138 | +} | ||
| 139 | + | ||
| 140 | +void RecognitionBar::ageRangeChanged() | ||
| 141 | +{ | ||
| 142 | + QStringList range; | ||
| 143 | + | ||
| 144 | + if (ageCheck->isChecked()) { | ||
| 145 | + int age = rangeWidget->getLowerBound(); | ||
| 146 | + while (age <= rangeWidget->getUpperBound()) { | ||
| 147 | + range.push_back(QString::number(age)); | ||
| 148 | + age++; | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + else range.clear(); | ||
| 152 | + | ||
| 153 | + emit newDemographics("Age", range); | ||
| 154 | +} | ||
| 155 | + | ||
| 156 | +#include "moc_recognitionbar.cpp" |
openbr/gui/recognitionbar.h
0 → 100644
| 1 | +#ifndef BR_RECOGNITIONBAR_H | ||
| 2 | +#define BR_RECOGNITIONBAR_H | ||
| 3 | + | ||
| 4 | +#include <QToolBar> | ||
| 5 | +#include <QPushButton> | ||
| 6 | +#include <QComboBox> | ||
| 7 | +#include <QActionGroup> | ||
| 8 | +#include <QAction> | ||
| 9 | +#include <QLabel> | ||
| 10 | +#include <QToolButton> | ||
| 11 | +#include <QCheckBox> | ||
| 12 | + | ||
| 13 | +#include "formcombowidget.h" | ||
| 14 | +#include "rangewidget.h" | ||
| 15 | +#include "pageflipwidget.h" | ||
| 16 | +#include "searchboxwidget.h" | ||
| 17 | +#include "metadata.h" | ||
| 18 | + | ||
| 19 | +#include <openbr/openbr_plugin.h> | ||
| 20 | + | ||
| 21 | +namespace br | ||
| 22 | +{ | ||
| 23 | + | ||
| 24 | +class BR_EXPORT RecognitionBar : public QToolBar | ||
| 25 | +{ | ||
| 26 | + Q_OBJECT | ||
| 27 | + | ||
| 28 | + QCheckBox *landmarkCheck; | ||
| 29 | + | ||
| 30 | + QCheckBox *maleCheck; | ||
| 31 | + QCheckBox *femaleCheck; | ||
| 32 | + | ||
| 33 | + QCheckBox *whiteCheck; | ||
| 34 | + QCheckBox *blackCheck; | ||
| 35 | + QCheckBox *hispanicCheck; | ||
| 36 | + QCheckBox *asianCheck; | ||
| 37 | + QCheckBox *otherCheck; | ||
| 38 | + | ||
| 39 | + QCheckBox *ageCheck; | ||
| 40 | + | ||
| 41 | + QLabel *demographicsLabel; | ||
| 42 | + QLabel *algorithmLabel; | ||
| 43 | + QLabel *findLabel; | ||
| 44 | + | ||
| 45 | + FormComboWidget *model; | ||
| 46 | + | ||
| 47 | + RangeWidget *rangeWidget; | ||
| 48 | + PageFlipWidget *pageFlipWidget; | ||
| 49 | + SearchBoxWidget *searchBox; | ||
| 50 | + QPushButton *compareButton; | ||
| 51 | + | ||
| 52 | + QWidget *spacer; | ||
| 53 | + | ||
| 54 | +public: | ||
| 55 | + explicit RecognitionBar(QWidget *parent = 0); | ||
| 56 | + | ||
| 57 | + Metadata *metadata; | ||
| 58 | + | ||
| 59 | +public slots: | ||
| 60 | + void addAlgorithm(); | ||
| 61 | + | ||
| 62 | +private slots: | ||
| 63 | + void genderChanged(); | ||
| 64 | + void raceChanged(); | ||
| 65 | + void ageRangeChanged(); | ||
| 66 | + | ||
| 67 | +signals: | ||
| 68 | + void newAlgorithm(QString); | ||
| 69 | + void newDemographics(QString, QStringList); | ||
| 70 | + void newIndex(int); | ||
| 71 | + void setFiles(br::FileList); | ||
| 72 | + void compare(); | ||
| 73 | + | ||
| 74 | + void showLandmarks(bool); | ||
| 75 | +}; | ||
| 76 | + | ||
| 77 | +} // namespace br | ||
| 78 | + | ||
| 79 | +#endif // BR_RECOGNITIONBAR_H |