Commit 80a9fc2e50a78bd2d43b5c1a6e64c7d2c5e6e42f
1 parent
3dee491d
Updated subjectviewer to show number of images per subject
Showing
5 changed files
with
50 additions
and
10 deletions
openbr/gui/subjectviewer.cpp
| ... | ... | @@ -3,10 +3,24 @@ |
| 3 | 3 | using namespace br; |
| 4 | 4 | |
| 5 | 5 | SubjectViewer::SubjectViewer(QWidget *parent) |
| 6 | - : TemplateViewer(parent) | |
| 6 | + : QWidget(parent) | |
| 7 | 7 | { |
| 8 | 8 | files = FileList(); |
| 9 | 9 | currentIndex = 0; |
| 10 | + | |
| 11 | + info.setText("-"); | |
| 12 | + info.setAlignment(Qt::AlignCenter); | |
| 13 | + info.setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum); | |
| 14 | + | |
| 15 | + layout.addWidget(&viewer); | |
| 16 | + layout.addWidget(&info); | |
| 17 | + | |
| 18 | + setLayout(&layout); | |
| 19 | + | |
| 20 | + connect(&viewer, SIGNAL(newInput(br::File)), this, SIGNAL(newInput(br::File))); | |
| 21 | + connect(&viewer, SIGNAL(newInput(QImage)), this, SIGNAL(newInput(QImage))); | |
| 22 | + connect(&viewer, SIGNAL(newMousePoint(QPointF)), this, SIGNAL(newMousePoint(QPointF))); | |
| 23 | + connect(&viewer, SIGNAL(selectedInput(br::File)), this, SIGNAL(selectedInput(br::File))); | |
| 10 | 24 | } |
| 11 | 25 | |
| 12 | 26 | void SubjectViewer::setFiles(const FileList &files) |
| ... | ... | @@ -15,17 +29,22 @@ void SubjectViewer::setFiles(const FileList &files) |
| 15 | 29 | |
| 16 | 30 | currentIndex = 0; |
| 17 | 31 | this->files = files; |
| 18 | - TemplateViewer::setFile(this->files[currentIndex]); | |
| 32 | + | |
| 33 | + info.setText(QString::number(currentIndex+1) + "/" + QString::number(files.size())); | |
| 34 | + viewer.setFile(this->files[currentIndex]); | |
| 19 | 35 | } |
| 20 | 36 | |
| 21 | 37 | void SubjectViewer::wheelEvent(QWheelEvent *event) |
| 22 | 38 | { |
| 23 | 39 | QPoint numDegrees = event->angleDelta(); |
| 24 | 40 | |
| 25 | - if (numDegrees.y() < 0 && currentIndex > 0) | |
| 26 | - TemplateViewer::setFile(this->files[--currentIndex]); | |
| 27 | - else if (numDegrees.y() > 0 && currentIndex < files.size()-1) | |
| 28 | - TemplateViewer::setFile(this->files[++currentIndex]); | |
| 41 | + if (numDegrees.y() < 0 && currentIndex > 0) { | |
| 42 | + viewer.setFile(this->files[--currentIndex]); | |
| 43 | + info.setText(QString::number(currentIndex+1) + "/" + QString::number(files.size())); | |
| 44 | + } else if (numDegrees.y() > 0 && currentIndex < files.size()-1) { | |
| 45 | + viewer.setFile(this->files[++currentIndex]); | |
| 46 | + info.setText(QString::number(currentIndex+1) + "/" + QString::number(files.size())); | |
| 47 | + } | |
| 29 | 48 | |
| 30 | 49 | event->accept(); |
| 31 | 50 | } | ... | ... |
openbr/gui/subjectviewer.h
| 1 | 1 | #ifndef SUBJECTVIEWER_H |
| 2 | 2 | #define SUBJECTVIEWER_H |
| 3 | 3 | |
| 4 | +#include <QObject> | |
| 5 | +#include <QSharedPointer> | |
| 4 | 6 | #include <QList> |
| 7 | +#include <QVBoxLayout> | |
| 5 | 8 | |
| 6 | 9 | #include <openbr/openbr_plugin.h> |
| 7 | 10 | #include <openbr/gui/templateviewer.h> |
| ... | ... | @@ -9,19 +12,31 @@ |
| 9 | 12 | namespace br |
| 10 | 13 | { |
| 11 | 14 | |
| 12 | -class BR_EXPORT SubjectViewer : public TemplateViewer | |
| 15 | +class BR_EXPORT SubjectViewer : public QWidget | |
| 13 | 16 | { |
| 17 | + Q_OBJECT | |
| 18 | + | |
| 19 | + QVBoxLayout layout; | |
| 20 | + QLabel info; | |
| 14 | 21 | FileList files; |
| 15 | 22 | int currentIndex; |
| 16 | 23 | |
| 17 | 24 | public: |
| 18 | 25 | explicit SubjectViewer(QWidget *parent = 0); |
| 19 | 26 | |
| 27 | + TemplateViewer viewer; | |
| 28 | + | |
| 20 | 29 | public slots: |
| 21 | 30 | void setFiles(const FileList &files); |
| 22 | 31 | |
| 23 | 32 | protected slots: |
| 24 | 33 | void wheelEvent(QWheelEvent *); |
| 34 | + | |
| 35 | +signals: | |
| 36 | + void newInput(br::File); | |
| 37 | + void newInput(QImage); | |
| 38 | + void newMousePoint(QPointF); | |
| 39 | + void selectedInput(br::File); | |
| 25 | 40 | }; |
| 26 | 41 | |
| 27 | 42 | } | ... | ... |
openbr/gui/subjectviewergrid.cpp
| ... | ... | @@ -6,6 +6,7 @@ SubjectViewerGrid::SubjectViewerGrid(QWidget *parent) : |
| 6 | 6 | QWidget(parent) |
| 7 | 7 | { |
| 8 | 8 | setLayout(&gridLayout); |
| 9 | + setFiles(QList<FileList>()); | |
| 9 | 10 | } |
| 10 | 11 | |
| 11 | 12 | void SubjectViewerGrid::setFiles(const QList<FileList> &files) |
| ... | ... | @@ -34,10 +35,10 @@ void SubjectViewerGrid::setFiles(const QList<FileList> &files) |
| 34 | 35 | if (i < files.size()) { |
| 35 | 36 | subjectViewers[i]->setFiles(files[i]); |
| 36 | 37 | } else { |
| 37 | - subjectViewers[i]->setDefaultText("<b>"+ (size > 1 ? QString() : QString("Drag Photo or Folder Here")) +"</b>"); | |
| 38 | + subjectViewers[i]->viewer.setDefaultText("<b>"+ (size > 1 ? QString() : QString("Drag Photo or Folder Here")) +"</b>"); | |
| 38 | 39 | subjectViewers[i]->setFiles(FileList()); |
| 39 | 40 | } |
| 40 | 41 | |
| 41 | - subjectViewers[i]->setEditable(files.size() == 1); | |
| 42 | + subjectViewers[i]->viewer.setEditable(files.size() == 1); | |
| 42 | 43 | } |
| 43 | 44 | } | ... | ... |
openbr/gui/subjectviewergrid.h
openbr/gui/templateviewer.cpp
| ... | ... | @@ -45,7 +45,7 @@ void TemplateViewer::setFile(const File &file_) |
| 45 | 45 | landmarks.append(QPointF()); |
| 46 | 46 | nearestLandmark = -1; |
| 47 | 47 | |
| 48 | - QtConcurrent::run(this, &TemplateViewer::refreshImage); | |
| 48 | + TemplateViewer::refreshImage(); | |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | void TemplateViewer::setEditable(bool enabled) | ... | ... |