|
@@ -31,11 +31,14 @@ Experiment::Experiment ():QMainWindow()
|
|
|
filenames_json = NULL;
|
|
|
suffix = NULL;
|
|
|
choice = NULL;
|
|
|
+ side = NULL;
|
|
|
dataPath = new QString(QDir::currentPath()+"/data");
|
|
|
resultPath = NULL;
|
|
|
algo_side='X';
|
|
|
expeStarted = false;
|
|
|
|
|
|
+ openedImage = -1;
|
|
|
+
|
|
|
setWindowTitle (tr ("DSL - Draw Strength Line"));
|
|
|
|
|
|
QScreen *screen = QGuiApplication::primaryScreen ();
|
|
@@ -163,9 +166,11 @@ Experiment::start ()
|
|
|
delete filenames;
|
|
|
delete filenames_json;
|
|
|
delete choice;
|
|
|
+ delete side;
|
|
|
filenames = new QStringList();
|
|
|
filenames_json = new QStringList();
|
|
|
choice = new QStringList();
|
|
|
+ side = new QStringList();
|
|
|
|
|
|
QDirIterator it(*dataPath, {"*.jpg"}, QDir::Files);
|
|
|
while (it.hasNext()) {
|
|
@@ -204,6 +209,18 @@ Experiment::start ()
|
|
|
|
|
|
}
|
|
|
|
|
|
+void
|
|
|
+Experiment::undo ()
|
|
|
+{
|
|
|
+ openedImage = openedImage-2;
|
|
|
+ choice->removeLast();
|
|
|
+
|
|
|
+ if(openedImage < 1)
|
|
|
+ undoAct->setEnabled(false);
|
|
|
+
|
|
|
+ openNext();
|
|
|
+}
|
|
|
+
|
|
|
void Experiment::leftImage(){
|
|
|
if(expeStarted)
|
|
|
{
|
|
@@ -242,6 +259,9 @@ void Experiment::rightImage(){
|
|
|
void
|
|
|
Experiment::openNext (){
|
|
|
openedImage = openedImage+1;
|
|
|
+
|
|
|
+ if(openedImage == 1)
|
|
|
+ undoAct->setEnabled(true);
|
|
|
|
|
|
progressBar->setValue((int)((openedImage+1.0)/(filenames->size())*100.0));
|
|
|
|
|
@@ -280,29 +300,51 @@ Experiment::openNext (){
|
|
|
waLeft->loadImage (filenames->at(openedImage).toStdString ());
|
|
|
waRight->loadImage (filenames->at(openedImage).toStdString ());
|
|
|
|
|
|
- std::srand(static_cast<unsigned int>(std::time(nullptr)+std::rand()));
|
|
|
- if((std::rand()%2) == 0)
|
|
|
+
|
|
|
+
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ algo_side = (side->at(openedImage)[0]).toLatin1();
|
|
|
+
|
|
|
+ if(algo_side == 'L')
|
|
|
{
|
|
|
waLeft->loadSL (filenames_json->at(openedImage).toStdString ());
|
|
|
- algo_side='L';
|
|
|
- for(int i = 0 ; i < waLeft->getNumberOfLines() ; i++)
|
|
|
+ QString jsonFile = (*resultPath)+"/"+(QFileInfo(filenames->at(openedImage)).baseName()+(QString("_random"))+".json");
|
|
|
+ if(QFile(jsonFile).exists()==false)
|
|
|
{
|
|
|
- waRight->addRandomSL();
|
|
|
- QString jsonFile = (*resultPath)+"/"+(QFileInfo(filenames->at(openedImage)).baseName()+(QString("_random"))+".json");
|
|
|
+ for(int i = 0 ; i < waLeft->getNumberOfLines() ; i++)
|
|
|
+ waRight->addRandomSL();
|
|
|
waRight->saveStrengthLine (jsonFile.toStdString ());
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ waRight->loadSL(jsonFile.toStdString());
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
waRight->loadSL (filenames_json->at(openedImage).toStdString ());
|
|
|
- algo_side='R';
|
|
|
- for(int i = 0 ; i < waRight->getNumberOfLines() ; i++)
|
|
|
+ QString jsonFile = (*resultPath)+"/"+(QFileInfo(filenames->at(openedImage)).baseName()+(QString("_random"))+".json");
|
|
|
+ if(QFile(jsonFile).exists() == false)
|
|
|
{
|
|
|
- waLeft->addRandomSL();
|
|
|
- QString jsonFile = (*resultPath)+"/"+(QFileInfo(filenames->at(openedImage)).baseName()+(QString("_random"))+".json");
|
|
|
+ for(int i = 0 ; i < waRight->getNumberOfLines() ; i++)
|
|
|
+ waLeft->addRandomSL();
|
|
|
waLeft->saveStrengthLine (jsonFile.toStdString ());
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ waLeft->loadSL(jsonFile.toStdString());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
waLeft->setReadOnly(true);
|
|
|
waRight->setReadOnly(true);
|
|
|
waLeft->repaint();
|
|
@@ -322,6 +364,11 @@ Experiment::createActions ()
|
|
|
exitAct = new QAction (tr ("E&xit"), this);
|
|
|
exitAct->setShortcuts (QKeySequence::Quit);
|
|
|
connect (exitAct, &QAction::triggered, this, &QWidget::close);
|
|
|
+
|
|
|
+ undoAct = new QAction (tr ("&Undo"), this);
|
|
|
+ undoAct->setShortcuts (QKeySequence::Undo);
|
|
|
+ undoAct->setEnabled(false);
|
|
|
+ connect (undoAct, &QAction::triggered, this, &Experiment::undo);
|
|
|
}
|
|
|
|
|
|
void
|
|
@@ -333,4 +380,7 @@ Experiment::createMenus ()
|
|
|
fileMenu->addSeparator ();
|
|
|
|
|
|
fileMenu->addAction (exitAct);
|
|
|
+
|
|
|
+ editMenu = menuBar ()->addMenu (tr ("&Edit"));
|
|
|
+ editMenu->addAction (undoAct);
|
|
|
}
|