|
@@ -28,13 +28,14 @@ Experiment::Experiment ():QMainWindow()
|
|
|
createMenus ();
|
|
|
|
|
|
filenames = NULL;
|
|
|
- filenames_json = NULL;
|
|
|
+ //filenames_json = NULL;
|
|
|
+ experimentation = NULL;
|
|
|
suffix = NULL;
|
|
|
choice = NULL;
|
|
|
side = NULL;
|
|
|
dataPath = new QString(QDir::currentPath()+"/data");
|
|
|
resultPath = NULL;
|
|
|
- algo_side='X';
|
|
|
+ //algo_side='X';
|
|
|
expeStarted = false;
|
|
|
|
|
|
openedImage = -1;
|
|
@@ -164,11 +165,13 @@ Experiment::start ()
|
|
|
if(ok)
|
|
|
{
|
|
|
delete filenames;
|
|
|
- delete filenames_json;
|
|
|
+ //delete filenames_json;
|
|
|
+ delete experimentation;
|
|
|
delete choice;
|
|
|
delete side;
|
|
|
filenames = new QStringList();
|
|
|
- filenames_json = new QStringList();
|
|
|
+ //filenames_json = new QStringList();
|
|
|
+ experimentation = new QList<QStringList*>();
|
|
|
choice = new QStringList();
|
|
|
side = new QStringList();
|
|
|
|
|
@@ -177,30 +180,74 @@ Experiment::start ()
|
|
|
filenames->append( it.next() );
|
|
|
}
|
|
|
|
|
|
+ std::srand(static_cast<unsigned int>(std::time(nullptr)+std::rand()));
|
|
|
+
|
|
|
for(int i = 0 ; i<filenames->size() ; i++)
|
|
|
{
|
|
|
QString jsonFile((*dataPath)+"/"+QFileInfo(filenames->at(i)).baseName()+(*suffix_algo)+".json");
|
|
|
- if(! (QFile(jsonFile).exists()) )
|
|
|
+ QString jsonFile2((*dataPath)+"/"+QFileInfo(filenames->at(i)).baseName()+(*suffix_expert)+".json");
|
|
|
+ if((! (QFile(jsonFile).exists()) ) || (! (QFile(jsonFile2).exists()) ))
|
|
|
{
|
|
|
qDebug() << "WARNING !!!! " << jsonFile << " file missing";
|
|
|
+ qDebug() << "OR\nWARNING !!!! " << jsonFile2 << " file missing";
|
|
|
ok=false;
|
|
|
- }else{
|
|
|
- filenames_json->append(jsonFile);
|
|
|
- }
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ //filenames_json->append(jsonFile);
|
|
|
+ QStringList *toAppend = new QStringList();
|
|
|
+ toAppend->append(filenames->at(i));
|
|
|
+ if((std::rand()%2) == 0)
|
|
|
+ {
|
|
|
+ toAppend->append(QString((*dataPath)+"/"+QFileInfo(filenames->at(i)).baseName()+(*suffix_algo)+".json"));
|
|
|
+ toAppend->append(QString((*resultPath)+"/"+QFileInfo(filenames->at(i)).baseName()+(*suffix_random)+".json"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ toAppend->append(QString((*resultPath)+"/"+QFileInfo(filenames->at(i)).baseName()+(*suffix_random)+".json"));
|
|
|
+ toAppend->append(QString((*dataPath)+"/"+QFileInfo(filenames->at(i)).baseName()+(*suffix_algo)+".json"));
|
|
|
+ }
|
|
|
+ experimentation->append(toAppend);
|
|
|
+ toAppend = new QStringList();
|
|
|
+ toAppend->append(filenames->at(i));
|
|
|
+ if((std::rand()%2) == 0)
|
|
|
+ {
|
|
|
+ toAppend->append(QString((*dataPath)+"/"+QFileInfo(filenames->at(i)).baseName()+(*suffix_algo)+".json"));
|
|
|
+ toAppend->append(QString((*dataPath)+"/"+QFileInfo(filenames->at(i)).baseName()+(*suffix_expert)+".json"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ toAppend->append(QString((*dataPath)+"/"+QFileInfo(filenames->at(i)).baseName()+(*suffix_expert)+".json"));
|
|
|
+ toAppend->append(QString((*dataPath)+"/"+QFileInfo(filenames->at(i)).baseName()+(*suffix_algo)+".json"));
|
|
|
+ }
|
|
|
+ experimentation->append(toAppend);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ for(int i=0 ; i<experimentation->size() ; i++)
|
|
|
+ {
|
|
|
+ // std::cout << experimentation->at(i)->at(0).toStdString() << " - " << experimentation->at(i)->at(1).toStdString() << " - " << experimentation->at(i)->at(2).toStdString() << std::endl;
|
|
|
+ // std::cout << experimentation->at(i)->at(0).toStdString() << std::endl;
|
|
|
+ }
|
|
|
+ std::cout << std::endl << std::endl;
|
|
|
+
|
|
|
if(!ok)
|
|
|
std::exit(EXIT_FAILURE);
|
|
|
-
|
|
|
- std::srand(static_cast<unsigned int>(std::time(nullptr)+std::rand()));
|
|
|
|
|
|
- for(int i = 0 ; i<filenames->size()*2 ; i++)
|
|
|
+ /*for(int i = 0 ; i<filenames->size()*2 ; i++)
|
|
|
{
|
|
|
int rand1 = std::rand()%filenames->size();
|
|
|
int rand2 = std::rand()%filenames->size();
|
|
|
filenames->swapItemsAt(rand1, rand2);
|
|
|
filenames_json->swapItemsAt(rand1, rand2);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ for(int i = 0 ; i<experimentation->size()*4 ; i++)
|
|
|
+ {
|
|
|
+ int rand1 = std::rand()%filenames->size();
|
|
|
+ int rand2 = std::rand()%filenames->size();
|
|
|
+ experimentation->swapItemsAt(rand1, rand2);
|
|
|
}
|
|
|
+
|
|
|
openedImage = -1;
|
|
|
|
|
|
expeStarted = true;
|
|
@@ -224,7 +271,7 @@ Experiment::undo ()
|
|
|
void Experiment::leftImage(){
|
|
|
if(expeStarted)
|
|
|
{
|
|
|
- if((algo_side != 'L') && (algo_side != 'R'))
|
|
|
+ /*if((algo_side != 'L') && (algo_side != 'R'))
|
|
|
{
|
|
|
qDebug() << "Something went wrong";
|
|
|
QApplication::quit();
|
|
@@ -232,7 +279,24 @@ void Experiment::leftImage(){
|
|
|
if(algo_side == 'L')
|
|
|
choice->append(QString("algo"));
|
|
|
else
|
|
|
- choice->append(QString("random"));
|
|
|
+ choice->append(QString("random"));*/
|
|
|
+
|
|
|
+
|
|
|
+ if(experimentation->at(openedImage)->at(1).at(experimentation->at(openedImage)->length()-6) == 'o')
|
|
|
+ {
|
|
|
+ choice->append(QString("algo"));
|
|
|
+ std::cout << "Choix algo" << std::endl;
|
|
|
+ }
|
|
|
+ if(experimentation->at(openedImage)->at(1).at(experimentation->at(openedImage)->length()-6) == 'm')
|
|
|
+ {
|
|
|
+ choice->append(QString("random"));
|
|
|
+ std::cout << "Choix random" << std::endl;
|
|
|
+ }
|
|
|
+ if(experimentation->at(openedImage)->at(1).at(experimentation->at(openedImage)->length()-6) == 't')
|
|
|
+ {
|
|
|
+ choice->append(QString("expert"));
|
|
|
+ std::cout << "Choix expert" << std::endl;
|
|
|
+ }
|
|
|
|
|
|
openNext();
|
|
|
}
|
|
@@ -241,7 +305,7 @@ void Experiment::leftImage(){
|
|
|
void Experiment::rightImage(){
|
|
|
if(expeStarted)
|
|
|
{
|
|
|
- if((algo_side != 'L') && (algo_side != 'R'))
|
|
|
+ /*if((algo_side != 'L') && (algo_side != 'R'))
|
|
|
{
|
|
|
qDebug() << "Something went wrong";
|
|
|
QApplication::quit();
|
|
@@ -249,7 +313,26 @@ void Experiment::rightImage(){
|
|
|
if(algo_side == 'R')
|
|
|
choice->append(QString("algo"));
|
|
|
else
|
|
|
- choice->append(QString("random"));
|
|
|
+ choice->append(QString("random"));*/
|
|
|
+
|
|
|
+ std::cout << experimentation->at(openedImage)->at(2).at(experimentation->at(openedImage)->length()-6).toLatin1() << std::endl;
|
|
|
+
|
|
|
+ if(experimentation->at(openedImage)->at(2).at(experimentation->at(openedImage)->length()-6) == 'o')
|
|
|
+ {
|
|
|
+ choice->append(QString("algo"));
|
|
|
+ std::cout << "Choix algo" << std::endl;
|
|
|
+ }
|
|
|
+ if(experimentation->at(openedImage)->at(2).at(experimentation->at(openedImage)->length()-6) == 'm')
|
|
|
+ {
|
|
|
+ choice->append(QString("random"));
|
|
|
+ std::cout << "Choix random" << std::endl;
|
|
|
+ }
|
|
|
+ if(experimentation->at(openedImage)->at(2).at(experimentation->at(openedImage)->length()-6) == 't')
|
|
|
+ {
|
|
|
+ choice->append(QString("expert"));
|
|
|
+ std::cout << "Choix expert" << std::endl;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
openNext();
|
|
|
}
|
|
@@ -260,6 +343,8 @@ void
|
|
|
Experiment::openNext (){
|
|
|
openedImage = openedImage+1;
|
|
|
|
|
|
+ std::cout << experimentation->at(openedImage)->at(0).toStdString() << " - " << experimentation->at(openedImage)->at(1).toStdString() << " - " << experimentation->at(openedImage)->at(2).toStdString() << std::endl;
|
|
|
+
|
|
|
if(openedImage == 1)
|
|
|
undoAct->setEnabled(true);
|
|
|
|
|
@@ -297,24 +382,46 @@ Experiment::openNext (){
|
|
|
else
|
|
|
{
|
|
|
|
|
|
- waLeft->loadImage (filenames->at(openedImage).toStdString ());
|
|
|
- waRight->loadImage (filenames->at(openedImage).toStdString ());
|
|
|
+ // waLeft->loadImage (filenames->at(openedImage).toStdString ());
|
|
|
+ // waRight->loadImage (filenames->at(openedImage).toStdString ());
|
|
|
|
|
|
-
|
|
|
+ waLeft->loadImage (experimentation->at(openedImage)->at(0).toStdString ());
|
|
|
+ waRight->loadImage (experimentation->at(openedImage)->at(0).toStdString ());
|
|
|
|
|
|
- if(side->size() == openedImage)
|
|
|
+
|
|
|
+ // left display
|
|
|
+ if(QFile(experimentation->at(openedImage)->at(1)).exists()==false)
|
|
|
+ {
|
|
|
+ for(int i = 0 ; i < waLeft->getNumberOfLines() ; i++)
|
|
|
+ waLeft->addRandomSL();
|
|
|
+ waLeft->saveStrengthLine (experimentation->at(openedImage)->at(1).toStdString ());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ waLeft->loadSL(experimentation->at(openedImage)->at(1).toStdString());
|
|
|
+
|
|
|
+ // right display
|
|
|
+ if(QFile(experimentation->at(openedImage)->at(2)).exists()==false)
|
|
|
+ {
|
|
|
+ for(int i = 0 ; i < waRight->getNumberOfLines() ; i++)
|
|
|
+ waRight->addRandomSL();
|
|
|
+ waRight->saveStrengthLine (experimentation->at(openedImage)->at(2).toStdString ());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ waRight->loadSL(experimentation->at(openedImage)->at(2).toStdString());
|
|
|
+
|
|
|
+ /*if(side->size() == openedImage)
|
|
|
{
|
|
|
std::srand(static_cast<unsigned int>(std::time(nullptr)+std::rand()));
|
|
|
if((std::rand()%2) == 0)
|
|
|
algo_side='L';
|
|
|
else
|
|
|
algo_side='R';
|
|
|
- side->append(QString(algo_side));
|
|
|
+ side->append(QString(algo_side));
|
|
|
}
|
|
|
else
|
|
|
- algo_side = (side->at(openedImage)[0]).toLatin1();
|
|
|
+ algo_side = (side->at(openedImage)[0]).toLatin1();*/
|
|
|
|
|
|
- if(algo_side == 'L')
|
|
|
+ /*if(algo_side == 'L')
|
|
|
{
|
|
|
waLeft->loadSL (filenames_json->at(openedImage).toStdString ());
|
|
|
QString jsonFile = (*resultPath)+"/"+(QFileInfo(filenames->at(openedImage)).baseName()+(QString("_random"))+".json");
|
|
@@ -343,7 +450,7 @@ Experiment::openNext (){
|
|
|
{
|
|
|
waLeft->loadSL(jsonFile.toStdString());
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
waLeft->setReadOnly(true);
|
|
|
waRight->setReadOnly(true);
|