|
@@ -11,6 +11,10 @@
|
|
|
#include <QVBoxLayout>
|
|
|
#include <QHBoxLayout>
|
|
|
#include <QPushButton>
|
|
|
+#include <QTextStream>
|
|
|
+#include <QJsonObject>
|
|
|
+#include <QJsonArray>
|
|
|
+#include <QJsonDocument>
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
@@ -25,6 +29,8 @@ Experiment::Experiment ():QMainWindow()
|
|
|
filenames = NULL;
|
|
|
filenames_json = NULL;
|
|
|
suffix = NULL;
|
|
|
+ choice = NULL;
|
|
|
+ algo_side='X';
|
|
|
|
|
|
setWindowTitle (tr ("DSL - Draw Strength Line"));
|
|
|
|
|
@@ -93,17 +99,14 @@ Experiment::Experiment ():QMainWindow()
|
|
|
progressBar->setFixedHeight(20);
|
|
|
progressBar->setRange(0, maxProgressBar);
|
|
|
progressBar->setValue(0);
|
|
|
- // connect(progressBar, SIGNAL(valueChanged(int)), this, SLOT(progressBarValueChanged(int)));
|
|
|
layoutV->addWidget(progressBar);
|
|
|
|
|
|
timer = new QTimer(central);
|
|
|
timer->setSingleShot(false);
|
|
|
timer->setInterval(time);
|
|
|
- // connect(timer, SIGNAL(timeout()), this, SLOT(ticTimer()));
|
|
|
|
|
|
setFixedSize (screenWidth, screenHeight);
|
|
|
|
|
|
- /*timer->start();*/
|
|
|
}
|
|
|
|
|
|
void
|
|
@@ -123,14 +126,16 @@ Experiment::open ()
|
|
|
bool ok;
|
|
|
suffix = new QString(QInputDialog::getText(this, tr("Your ID"),
|
|
|
tr("ID to use :"), QLineEdit::Normal,
|
|
|
- "_"+QDir::home().dirName(), &ok));
|
|
|
+ QDir::home().dirName(), &ok));
|
|
|
|
|
|
if(ok)
|
|
|
{
|
|
|
delete filenames;
|
|
|
delete filenames_json;
|
|
|
+ delete choice;
|
|
|
filenames = new QStringList();
|
|
|
filenames_json = new QStringList();
|
|
|
+ choice = new QStringList();
|
|
|
|
|
|
QDirIterator it(*directoryname, {"*.jpg", "*.png"}, QDir::Files);
|
|
|
while (it.hasNext()) {
|
|
@@ -169,27 +174,33 @@ Experiment::open ()
|
|
|
}
|
|
|
|
|
|
void Experiment::leftImage(){
|
|
|
- qDebug() << "Clic sur image gauche" << Qt::endl;
|
|
|
- progressBar->setValue(0);
|
|
|
+ if((algo_side != 'L') && (algo_side != 'R'))
|
|
|
+ {
|
|
|
+ qDebug() << "Something went wrong";
|
|
|
+ QApplication::quit();
|
|
|
+ }
|
|
|
+ if(algo_side == 'L')
|
|
|
+ choice->append(QString("algo"));
|
|
|
+ else
|
|
|
+ choice->append(QString("random"));
|
|
|
+
|
|
|
openNext();
|
|
|
}
|
|
|
|
|
|
void Experiment::rightImage(){
|
|
|
- qDebug() << "Clic sur image droite" << Qt::endl;
|
|
|
- progressBar->setValue(0);
|
|
|
+ if((algo_side != 'L') && (algo_side != 'R'))
|
|
|
+ {
|
|
|
+ qDebug() << "Something went wrong";
|
|
|
+ QApplication::quit();
|
|
|
+ }
|
|
|
+ if(algo_side == 'R')
|
|
|
+ choice->append(QString("algo"));
|
|
|
+ else
|
|
|
+ choice->append(QString("random"));
|
|
|
+
|
|
|
openNext();
|
|
|
}
|
|
|
|
|
|
-/*void Experiment::progressBarValueChanged(int value){
|
|
|
- if(value == maxProgressBar ){
|
|
|
- qDebug() << "That's all folks !" << Qt::endl;
|
|
|
- QApplication::quit();
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
-/*void Experiment::ticTimer(){
|
|
|
- progressBar->setValue(progressBar->value()+time);
|
|
|
- }*/
|
|
|
|
|
|
void
|
|
|
Experiment::openNext (){
|
|
@@ -200,6 +211,26 @@ Experiment::openNext (){
|
|
|
if(openedImage >= filenames->size())
|
|
|
{
|
|
|
qDebug() << "That's all folks !" << Qt::endl;
|
|
|
+
|
|
|
+ /* Saving result file*/
|
|
|
+ QJsonObject root;
|
|
|
+ QJsonArray choices;
|
|
|
+
|
|
|
+ for (int i = 0; i < choice->size (); i++){
|
|
|
+ QJsonObject choiceOnImage;
|
|
|
+ choiceOnImage["index"] = i;
|
|
|
+ choiceOnImage["image"] = QString(filenames->at(i));
|
|
|
+ choiceOnImage["choice"] = QString(choice->at(i));
|
|
|
+ choices.push_back(choiceOnImage);
|
|
|
+ }
|
|
|
+
|
|
|
+ root["choices"] = choices;
|
|
|
+
|
|
|
+ QByteArray ba = QJsonDocument(root).toJson();
|
|
|
+ QFile fout((*suffix)+QString::fromStdString (".json"));
|
|
|
+ fout.open(QIODevice::WriteOnly);
|
|
|
+ fout.write(ba);
|
|
|
+
|
|
|
QApplication::quit();
|
|
|
}
|
|
|
else
|
|
@@ -212,20 +243,17 @@ Experiment::openNext (){
|
|
|
if((std::rand()%2) == 0)
|
|
|
{
|
|
|
waLeft->loadSL (filenames_json->at(openedImage).toStdString ());
|
|
|
+ algo_side='L';
|
|
|
for(int i = 0 ; i < waLeft->getNumberOfLines() ; i++)
|
|
|
waRight->addRandomSL();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
waRight->loadSL (filenames_json->at(openedImage).toStdString ());
|
|
|
+ algo_side='R';
|
|
|
for(int i = 0 ; i < waRight->getNumberOfLines() ; i++)
|
|
|
waLeft->addRandomSL();
|
|
|
}
|
|
|
- /*waLeft->loadImage (image.toStdString ());
|
|
|
- waRight->loadImage (image.toStdString ());
|
|
|
- waLeft->loadSL(leftSL.toStdString());
|
|
|
- waRight->loadSL(rightSL.toStdString());
|
|
|
- waRight->addRandomSL();*/
|
|
|
waLeft->setReadOnly(true);
|
|
|
waRight->setReadOnly(true);
|
|
|
waLeft->repaint();
|