From: Thomas Pietrzak Date: Fri, 31 Aug 2012 12:27:58 +0000 (+0000) Subject: Support for side keys X-Git-Url: https://git.thomaspietrzak.com/?a=commitdiff_plain;h=5be00a1888c6fc70a0e2bad116c5dfffaf048f0b;p=DynamicKeyboardLib.git Support for side keys Initial import for expe keyboard git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@93 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- diff --git a/Arduino/dynamickeyboard/dynamickeyboard.ino b/Arduino/dynamickeyboard/dynamickeyboard.ino index 7dcf20f..5b7a88b 100644 --- a/Arduino/dynamickeyboard/dynamickeyboard.ino +++ b/Arduino/dynamickeyboard/dynamickeyboard.ino @@ -84,9 +84,9 @@ void setup() FkTRBL F: event type (force) k: key ID - T: force on the top + T: force on the front R: force on the right - B: force on the bottom + B: force on the back L: force on the left */ //TODO: manage any number of keys diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary-old/DynamicKeyboardLibrary.vcxproj b/DynamicKeyboardLibrary/DynamicKeyboardLibrary-old/DynamicKeyboardLibrary.vcxproj new file mode 100644 index 0000000..9cc579a --- /dev/null +++ b/DynamicKeyboardLibrary/DynamicKeyboardLibrary-old/DynamicKeyboardLibrary.vcxproj @@ -0,0 +1,77 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {291779F7-46DD-489D-BEB2-73D81107CFB3} + DynamicKeyboardLibrary + + + + DynamicLibrary + true + MultiByte + + + DynamicLibrary + false + true + MultiByte + + + + + + + + + + + + + + + Level3 + Disabled + + + true + arduinoseriald.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + + + true + true + true + arduinoserial.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary.pro b/DynamicKeyboardLibrary/DynamicKeyboardLibrary.pro new file mode 100644 index 0000000..5a11a46 --- /dev/null +++ b/DynamicKeyboardLibrary/DynamicKeyboardLibrary.pro @@ -0,0 +1,16 @@ +###################################################################### +# Automatically generated by qmake (2.01a) jeu. 30. août 11:28:15 2012 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . DynamicKeyboardLibrary +INCLUDEPATH += . + +# Input +HEADERS += DynamicKeyboardLibrary/DynamicKeyboardController.h \ + DynamicKeyboardLibrary/QKeySideEvent.h \ + DynamicKeyboardLibrary/QPushKeysKeyboardController.h +SOURCES += DynamicKeyboardLibrary/DynamicKeyboardController.cpp \ + DynamicKeyboardLibrary/QKeySideEvent.cpp \ + DynamicKeyboardLibrary/QPushKeysKeyboardController.cpp diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary.sln b/DynamicKeyboardLibrary/DynamicKeyboardLibrary.sln index 26c28c0..0077845 100644 --- a/DynamicKeyboardLibrary/DynamicKeyboardLibrary.sln +++ b/DynamicKeyboardLibrary/DynamicKeyboardLibrary.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DynamicKeyboardLibrary", "DynamicKeyboardLibrary\DynamicKeyboardLibrary.vcxproj", "{291779F7-46DD-489D-BEB2-73D81107CFB3}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DynamicKeyboardLibrary", "DynamicKeyboardLibrary\DynamicKeyboardLibrary.vcxproj", "{8240F82A-FD4C-4F9F-BBA2-EBD3B0A07F08}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -9,10 +9,10 @@ Global Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {291779F7-46DD-489D-BEB2-73D81107CFB3}.Debug|Win32.ActiveCfg = Debug|Win32 - {291779F7-46DD-489D-BEB2-73D81107CFB3}.Debug|Win32.Build.0 = Debug|Win32 - {291779F7-46DD-489D-BEB2-73D81107CFB3}.Release|Win32.ActiveCfg = Release|Win32 - {291779F7-46DD-489D-BEB2-73D81107CFB3}.Release|Win32.Build.0 = Release|Win32 + {8240F82A-FD4C-4F9F-BBA2-EBD3B0A07F08}.Debug|Win32.ActiveCfg = Debug|Win32 + {8240F82A-FD4C-4F9F-BBA2-EBD3B0A07F08}.Debug|Win32.Build.0 = Debug|Win32 + {8240F82A-FD4C-4F9F-BBA2-EBD3B0A07F08}.Release|Win32.ActiveCfg = Release|Win32 + {8240F82A-FD4C-4F9F-BBA2-EBD3B0A07F08}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary.suo b/DynamicKeyboardLibrary/DynamicKeyboardLibrary.suo index 4b5efe3..46612a8 100644 Binary files a/DynamicKeyboardLibrary/DynamicKeyboardLibrary.suo and b/DynamicKeyboardLibrary/DynamicKeyboardLibrary.suo differ diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardController.cpp b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardController.cpp index c7e8419..e7d6afd 100644 --- a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardController.cpp +++ b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardController.cpp @@ -25,6 +25,11 @@ DynamicKeyboardController::DynamicKeyboardController(char *port, int baudrate) } } +DynamicKeyboardController::~DynamicKeyboardController() +{ + delete _comPort; +} + void DynamicKeyboardController::setConfiguration(UINT16 config) { if (!_comPort) diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardController.h b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardController.h index 4cc73cc..bb6de18 100644 --- a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardController.h +++ b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardController.h @@ -14,7 +14,7 @@ typedef unsigned char UINT8; typedef unsigned short int UINT16; -class DynamicKeyboardController +class EXPORTED DynamicKeyboardController { public: /* @@ -23,23 +23,29 @@ class DynamicKeyboardController baudrate is the baudrate for the communication, the default value may be sufficient */ - EXPORTED DynamicKeyboardController(char *port, int baudrate = 115200); + DynamicKeyboardController(char *port, int baudrate = 115200); + + /* + Releases the serial port + */ + + virtual ~DynamicKeyboardController(); /* sets a configuration on keys XY is the configuration. Here 1 represent a raised key, 0 a lowered key. */ - EXPORTED void setConfiguration(UINT16 config); + void setConfiguration(UINT16 config); /* raise the specified keys 1 raises a key, 0 does not change its state */ - EXPORTED void raiseKeys(UINT16 config); + void raiseKeys(UINT16 config); /* lowers the specified keys 1 lowers a key, 0 does not change its state */ - EXPORTED void lowerKeys(UINT16 config); + void lowerKeys(UINT16 config); /* higher duty cycle values results to higher voltage @@ -48,25 +54,25 @@ class DynamicKeyboardController the values are choosen with empirical tests, depending on the solenoids and the power supply */ - EXPORTED void setMaximumDutyCycle(UINT8 val) const; - EXPORTED void setMinimumDutyCycle(UINT8 val) const; + void setMaximumDutyCycle(UINT8 val) const; + void setMinimumDutyCycle(UINT8 val) const; /* The shorter the boost mode the better since it goes beyond the standards The longer the boost mode is, the longer we should wait before changing the keys state again. */ - EXPORTED void setBoostDuration(UINT16) const; + void setBoostDuration(UINT16) const; /* returns the state of the solenoids, the max and min duty cycle and the boost duration */ - EXPORTED bool getState(UINT16 &solenoids, UINT8 &minDutyCycle, UINT8 &maxDutyCycle, UINT16 &boostDuration) const; + bool getState(UINT16 &solenoids, UINT8 &minDutyCycle, UINT8 &maxDutyCycle, UINT16 &boostDuration) const; /* returns on the stream the state of the solenoids, the max and min duty cycle and the boost duration */ - EXPORTED friend std::ostream& operator<< (std::ostream& stream, const DynamicKeyboardController& controller); + friend std::ostream& operator<< (std::ostream& stream, const DynamicKeyboardController& controller); protected: Serial *_comPort; diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardLibrary.vcxproj b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardLibrary.vcxproj index dcbb1b3..a1c04c0 100644 --- a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardLibrary.vcxproj +++ b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardLibrary.vcxproj @@ -10,64 +10,89 @@ Win32 + + + + + + + + + + - {291779F7-46DD-489D-BEB2-73D81107CFB3} - DynamicKeyboardLibrary + {8240F82A-FD4C-4F9F-BBA2-EBD3B0A07F08} + Qt4VSv1.0 DynamicLibrary - true - MultiByte DynamicLibrary - false - true - MultiByte - + - + - + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(ProjectName)d + - Level3 + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_CORE_LIB;DYNAMICKEYBOARDLIBRARY_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;%(AdditionalIncludeDirectories) Disabled + ProgramDatabase + MultiThreadedDebugDLL + false + Windows + $(OutDir)\$(ProjectName)d.dll + $(QTDIR)\lib;%(AdditionalLibraryDirectories) true - arduinoseriald.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ArduinoSeriald.lib;qtmaind.lib;QtCored4.lib;%(AdditionalDependencies) - Level3 - MaxSpeed - true - true + UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;DYNAMICKEYBOARDLIBRARY_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;%(AdditionalIncludeDirectories) + + + MultiThreadedDLL + false - true - true - true - arduinoserial.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + Windows + $(OutDir)\$(ProjectName).dll + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + false + ArduinoSerial.lib;qtmain.lib;QtCore4.lib;%(AdditionalDependencies) - - - - - - + + + + + \ No newline at end of file diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardLibrary.vcxproj.filters b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardLibrary.vcxproj.filters index 76cd099..51c5a9d 100644 --- a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardLibrary.vcxproj.filters +++ b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/DynamicKeyboardLibrary.vcxproj.filters @@ -3,25 +3,47 @@ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + cpp;cxx;c;def {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd + h + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} + qrc;* + false + + + {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} + moc;h;cpp + False + + Header Files + Header Files + + Header Files + + + Source Files + Source Files + + Source Files + \ No newline at end of file diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QPushKeysKeyboardController.cpp b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QPushKeysKeyboardController.cpp new file mode 100644 index 0000000..aa24af5 --- /dev/null +++ b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QPushKeysKeyboardController.cpp @@ -0,0 +1,37 @@ +#include "QPushKeysKeyboardController.h" + +#include +#include "QSideKeyEvent.h" + +QPushKeysKeyboardController::QPushKeysKeyboardController(char *port, int baudrate, QObject *receiver) +: DynamicKeyboardController(port, baudrate), _receiver(receiver) +{ +} + + +QPushKeysKeyboardController::~QPushKeysKeyboardController(void) +{ +} + +void QPushKeysKeyboardController::run() +{ + char buffer[6]; + + while (true) + { + if (_comPort->ReadData(buffer, 6) == 6 && _receiver) + { + QSideKeyEvent::Sides sides = 0; + if (buffer[2] > 0) + sides |= QSideKeyEvent::Front; + if (buffer[3] > 0) + sides |= QSideKeyEvent::Right; + if (buffer[4] > 0) + sides |= QSideKeyEvent::Back; + if (buffer[5] > 0) + sides |= QSideKeyEvent::Left; + + QCoreApplication::postEvent(_receiver, new QSideKeyEvent(buffer[1], sides)); + } + } +} diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QPushKeysKeyboardController.h b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QPushKeysKeyboardController.h new file mode 100644 index 0000000..01e5d5d --- /dev/null +++ b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QPushKeysKeyboardController.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +#include "DynamicKeyboardController.h" + +class EXPORTED QPushKeysKeyboardController: public DynamicKeyboardController, QThread +{ + public: + QPushKeysKeyboardController(char *port, int baudrate, QObject *receiver=NULL); + + ~QPushKeysKeyboardController(); + + protected: + void run(); + QObject *_receiver; +}; + diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QSideKeyEvent.cpp b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QSideKeyEvent.cpp new file mode 100644 index 0000000..c3b07e0 --- /dev/null +++ b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QSideKeyEvent.cpp @@ -0,0 +1,14 @@ +#include "QSideKeyEvent.h" + +const QEvent::Type QSideKeyEvent::QSideKeyEventType = + static_cast(QEvent::registerEventType()); + +QSideKeyEvent::QSideKeyEvent(int key, Sides sides) +:QEvent(QSideKeyEvent::QSideKeyEventType), _key(key), _sides(sides) +{ +} + + +QSideKeyEvent::~QSideKeyEvent() +{ +} diff --git a/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QSideKeyEvent.h b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QSideKeyEvent.h new file mode 100644 index 0000000..d02fb18 --- /dev/null +++ b/DynamicKeyboardLibrary/DynamicKeyboardLibrary/QSideKeyEvent.h @@ -0,0 +1,35 @@ +#pragma once + +#include +#include + +#ifdef __MACOSX__ +#define EXPORTED +#else +#define EXPORTED __declspec(dllexport) +#endif + +class EXPORTED QSideKeyEvent: public QEvent +{ + public: + enum Side { + Front = 0x01, + Right = 0x02, + Back = 0x04, + Left = 0x08 }; + + typedef QFlags Sides; + + QSideKeyEvent(int key, Sides sides); + ~QSideKeyEvent(); + + int getKey() { return _key; } + Sides getSides() {return _sides; } + + static const QEvent::Type QSideKeyEventType; + + private: + int _key; + Sides _sides; +}; + diff --git a/Expe-selection/dyna-expe2/Controler.cpp b/Expe-selection/dyna-expe2/Controler.cpp new file mode 100644 index 0000000..f4a92d2 --- /dev/null +++ b/Expe-selection/dyna-expe2/Controler.cpp @@ -0,0 +1,330 @@ +#include "Controler.h" +#include "expe/Global.h" +#include "HCISheet.h" +#include "ihm.h" +#include +#include + +int secondScreenWidth = 1920; +int secondScreenHeight = 1200; + +void Controler::setFullScreen(){ + widgetParent->setWindowState(Qt::WindowFullScreen); + //widgetParent->resize(1280,1024); + + widgetParent->move(0,0); + HCISheet* sheet = dynamic_cast(this->trialSheet); + + sheet->resize(this->widgetParent->width(), this->widgetParent->height()); +} + +Controler::Controler(MainWindow *_experimenterWindow) : Expe(),successSound(":ressources/success.wav"), errorSound("ressources/error.wav") +{ + + this->experimenterWindow = _experimenterWindow; + //qDebug() << __PRETTY_FUNCTION__ ; + setNbBlock(5); //TODO + setNbTrials(28); //TODO + +} + +//----------------------------- +QString Controler::CSVDirectoryOutput(){ + QString res = Global::appPath()+"/../../dyna-expe2/log/"; + qDebug()<< res; + return res; +} + +//----------------------------- +void Controler::initCSVWriter(const QStringList &l) +{ + QString title = this->CSVDirectoryOutput(); + + for(int i=0;iexpeLoader.header.at(i); + h = h.mid(0,1); + title += h+"["+l.at(i) +"]"; + } + //title += "tec["+ this->tech +"]"; + //title += "set" + this->set +"]"; + title +=".csv"; + csvWriter.openFile(title); + csvWriter.setColumnNames(columNames); +} + +//---------------------- +void Controler::start(const QString& nameFile, QString user, const QString& , const QString& ) +{ + // qDebug()<<__PRETTY_FUNCTION__; + QFile f(nameFile); + qDebug()<< ""<<" valid="<screenGeometry(); + this->widgetParent->move(0, 0); + //this->widgetParent->resize(1280,1024); + widgetParent->resize(1280,1024); + this->interBlockWidget->resize(1280,1024); + this->interTrialWidget->resize(1280,1024); + this->trialSheet->resize(1280,1024); + + //successSound.play(); + + if(hasInterBlock()) + { + //TODO + } + + if(hasInterTrial()) + { + //TODO + } + + HCISheet* sheet = dynamic_cast(this->trialSheet); + connect(sheet, SIGNAL(hotkeyPressed(QString)), this, SLOT(hotkeyPressed(QString))); + connect(sheet, SIGNAL(hotkeyReleased(QString)), this, SLOT(hotkeyReleased(QString))); + this->setFullScreen(); +} + +//---------------------- +void Controler::prepareBlockData(const QMap &/*prop*/) +{ + if(this->numBlock() <3) + { + }else + { + } + + //HCISheet * sheet = dynamic_cast(this->trialSheet); + + //this->configuration = this->numBlock(); + emit blockPrepared(); + QString message= "Configuration: " + QString::number(numBlock()); + qDebug()<setMessage(""); + this->interTrialWidget->setValue(0); + this->interTrialWidget->setFocus(); +} + +//----------------------- +void Controler::prepareTrialData(const QMap& prop) +{ + csvWriter.write("time", "0"); + //csvWriter.write("tech", tech); + //csvWriter.write("set", set); + csvWriter.write("correct","0"); + csvWriter.write("false","0"); + + keyTarget = prop["target"]; + keyTarget = keyTarget.replace("5",";"); + keyTarget = keyTarget.replace("6","^"); + keyTarget = keyTarget.replace("0",QString::fromUtf8("à ")); + keyTarget = keyTarget.replace("9",QString::fromUtf8("ç")); + keyTarget = keyTarget.replace("4","'"); + + QString key = keyTarget.left(1); + QString type = keyTarget.right(1); + + //this->keyId = key.toInt(); + //QString target = this->getCharFromConfiguration(keyId, configuration); + csvWriter.write("target", keyTarget); + csvWriter.write("key", key); + csvWriter.write("type", type); + bool raised = key=="d"|| key=="o"; + csvWriter.write("raised", QString::number(raised)); + + HCISheet * sheet = dynamic_cast(this->trialSheet); + sheet->setTargetKey(key, type); + + // QString str_item = prop["item"]; + //define the stimulus + //display the stimulus. +} + +//---------------------- +InterBlock* Controler::createInterBlockWidget() +{ + static bool first = true; + if(first){ + first = false; + InterBlock * myInterBlock = new InterBlock(widgetParent); + //define signal for next block + //connect(this->experimenterWindow, SIGNAL(nextBlock()),myInterBlock, SLOT(buttonClicked())); + return myInterBlock; + } + return this->interBlockWidget; +} + +//---------------------- +InterTrial* Controler::createInterTrialWidget() +{ + static bool first = true; + if(first){ + first = false; + InterTrial * it = new InterTrial(widgetParent); + //it->setTimer(10); + it->setAnswerVisible(false); + return it; + } + return this->interTrialWidget; +} + +//------------------------ +TrialSheet* Controler::createTrialSheet() +{ + static bool first = true; + if(first){ + first = false; + + HCISheet *ts = new HCISheet(widgetParent); + return ts; + } + return this->trialSheet; +} + +//----------------- +bool Controler::hasInterBlock(){ return true; } + +//----------------- +bool Controler::hasInterTrial(){ return true; } + + +//----------------------- +QStringList Controler::completeCSVHeaderData() +{ + csvWriter.setSeparator("\t"); + QStringList res; + res << "key"; + res << "type"; + res <<"raised"; + res << "keyf"; + res << "typef"; + res << "targetf"; + res << "correct"; + res << "false"; + res << "time"; + return res; +} + +//----------------------- +void Controler::onTrialEntry() +{ + time = QTime::currentTime(); + //this->trialSheet->grabKeyboard(); + this->trialSheet->setFocus(); + QWidget *wid = trialSheet->keyboardGrabber(); + if(wid== this->trialSheet){ + qDebug()<<"keyboard grabber: trialsheet = true"; + } + this->interTrialWidget->setValue(this->numTrial()); +} + +//------------------------ +void Controler::onTrialExit() +{ + csvWriter.write("endtrial","1"); + csvWriter.write("time",QString::number(deltaTime()), true); + this->interTrialWidget->setFocus(); + //this->trialSheet->releaseKeyboard(); + //successSound.play(); +} + +QString Controler::getCharFromConfiguration(int keyId, int configuration) +{ + QString key="g"; + if (configuration==1){ + if(keyId==1) key= "3"; + if(keyId==2) key ="8"; + if(keyId==3) key= "a"; + if(keyId==4) key ="g"; + if(keyId==5) key= "l"; + } + + if (configuration==2){ + if(keyId==1) key= "2"; + if(keyId==2) key ="6"; + if(keyId==3) key= "0"; + if(keyId==4) key ="s"; + if(keyId==5) key= "j"; + } + if (configuration==3){ + if(keyId==1) key= "7"; + if(keyId==2) key ="w"; + if(keyId==3) key= "o"; + if(keyId==4) key ="f"; + if(keyId==5) key= "n"; + } + if (configuration==4){ + if(keyId==1) key= "r"; + if(keyId==2) key ="p"; + if(keyId==3) key= "k"; + if(keyId==4) key ="z"; + if(keyId==5) key= "b"; + } + + return key; +} + +//--------------------------- +void Controler::hotkeyPressed(QString c) +{ + +} + +//--------------------------- +void Controler::raisedKeyReleased(QString key, int side, int force){ + QString res=key; + if(side==1) key+="l"; + else if(side=2)key+="r"; + else if(side=3)key+="f"; + else if(side=4)key+="b"; + + if(force>0){ + if(false){//during trial + activateHotkey(res); + } + } + +} + +//--------------------------- +void Controler::hotkeyReleased(QString keyf) +{ + activateHotkey(keyf+"t"); +} + + +void Controler::activateHotkey(QString advHotkey) +{ + csvWriter.write("keyf", advHotkey.left(1)); + csvWriter.write("typef", advHotkey.right(1)); + csvWriter.write("targetf", advHotkey); + + qDebug()<<"target: "<< keyTarget << " targetf "<< advHotkey; + + if(keyTarget == advHotkey) + { + succes = true; + QSound::play(Global::appPath() + "/../../dyna-expe1/resources/success.wav"); + + }else{ + succes = false; + QSound::play(Global::appPath() + "/../../dyna-expe1/resources/error.wav"); + + } + + csvWriter.write("correct", QString::number(succes)); + csvWriter.write("false", QString::number(!succes)); + interTrialWidget->setAnswer(succes,"",""); + interTrialWidget->m_answer_str = advHotkey; + trialSheet->setEndTrial(); +} + + + + + + diff --git a/Expe-selection/dyna-expe2/Controler.h b/Expe-selection/dyna-expe2/Controler.h new file mode 100644 index 0000000..bdfffd6 --- /dev/null +++ b/Expe-selection/dyna-expe2/Controler.h @@ -0,0 +1,68 @@ +#ifndef CONTROLER_H +#define CONTROLER_H + +#include +#include +#include "expe/Expe.h" +#include "HCISheet.h" +#include "MainWindow.h" + +class Controler : public Expe +{ + Q_OBJECT + +public: + static int target; + + Controler(MainWindow* _experimenterWindow); + void start(const QString &fileName, QString user, const QString& option1="", const QString& option2=""); + + //void setExperimenterWindow(MainWindow* _experimenterWindow); + + + +signals: + void blockPrepared(); + +public slots: + void setFullScreen(); + void hotkeyPressed(QString c); + void hotkeyReleased(QString c); + //key will probably D or O. + //side can be l(left), r(right) f(front) b(back) t(top) + //force is the force + void raisedKeyReleased(QString key, int side, int force);//thomas, you can call this method + void activateHotkey(QString advHotkey); + + +protected: + virtual QStringList completeCSVHeaderData(); + virtual void prepareBlockData(const QMap& prop); + virtual void prepareTrialData(const QMap& prop); + virtual bool hasInterBlock(); + virtual bool hasInterTrial(); + virtual void initCSVWriter(const QStringList &l); + virtual TrialSheet* createTrialSheet(); + virtual InterBlock* createInterBlockWidget(); + virtual InterTrial* createInterTrialWidget(); + virtual void onTrialEntry(); + virtual void onTrialExit(); + virtual QString CSVDirectoryOutput(); + + +protected: + QString getCharFromConfiguration(int keyId, int configuration); + int execTime; + //QString tech; + //QString set; + QSound successSound; + QSound errorSound; + MainWindow* experimenterWindow; + int keyId; + QString keyTarget; + //int configuration; + bool succes; + +}; + +#endif // CONTROLER_H diff --git a/Expe-selection/dyna-expe2/HCISheet.cpp b/Expe-selection/dyna-expe2/HCISheet.cpp new file mode 100644 index 0000000..88f47e3 --- /dev/null +++ b/Expe-selection/dyna-expe2/HCISheet.cpp @@ -0,0 +1,625 @@ +#include "HCISheet.h" +#include "QKeyEvent" +#include +#include +#include +#include + + +HCISheet::HCISheet(QWidget *parent):TrialSheet(parent) +{ + this->buildPosLetterMapping(); + this->setStyleSheet("color:white;background-color:black"); + //this->resize(parent->width(),parent->height()); + this->resize(1280, 1024); + qDebug()<<" new HCISheet"; + //this->addAction(QAction("c",)); + this->ctrl_pressed = false; + QAction *act_ctrlF = new QAction(this); + act_ctrlF->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); + connect(act_ctrlF, SIGNAL(triggered()), this, SLOT(ctrlF())); + this->addAction(act_ctrlF); + + QAction *act_ctrlA = new QAction(this); + act_ctrlA->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A)); + connect(act_ctrlA, SIGNAL(triggered()), this, SLOT(ctrlA())); + this->addAction(act_ctrlA); + + QAction *act_ctrlS = new QAction(this); + act_ctrlS->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); + connect(act_ctrlS, SIGNAL(triggered()), this, SLOT(ctrlS())); + this->addAction(act_ctrlS); + + QAction *act_ctrlD = new QAction(this); + act_ctrlD->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); + connect(act_ctrlD, SIGNAL(triggered()), this, SLOT(ctrlD())); + this->addAction(act_ctrlD); + + QAction *act_ctrlG = new QAction(this); + act_ctrlG->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G)); + connect(act_ctrlG, SIGNAL(triggered()), this, SLOT(ctrlG())); + this->addAction(act_ctrlG); + + QAction *act_ctrlE = new QAction(this); + act_ctrlE->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E)); + connect(act_ctrlE, SIGNAL(triggered()), this, SLOT(ctrlE())); + this->addAction(act_ctrlE); + + QAction *act_ctrl4 = new QAction(this); + act_ctrl4->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_4)); + connect(act_ctrl4, SIGNAL(triggered()), this, SLOT(ctrl4())); + this->addAction(act_ctrl4); + + QAction *act_ctrlX = new QAction(this); + act_ctrlX->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X)); + connect(act_ctrlX, SIGNAL(triggered()), this, SLOT(ctrlX())); + this->addAction(act_ctrlX); + + QAction *act_ctrlC = new QAction(this); + act_ctrlC->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C)); + connect(act_ctrlC, SIGNAL(triggered()), this, SLOT(ctrlC())); + this->addAction(act_ctrlC); + + QAction *act_ctrlH = new QAction(this); + act_ctrlH->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_H)); + connect(act_ctrlH, SIGNAL(triggered()), this, SLOT(ctrlH())); + this->addAction(act_ctrlH); + + QAction *act_ctrlQ = new QAction(this); + act_ctrlQ->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); + connect(act_ctrlQ, SIGNAL(triggered()), this, SLOT(ctrlQ())); + this->addAction(act_ctrlQ); + + QAction *act_ctrlW = new QAction(this); + act_ctrlW->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); + connect(act_ctrlW, SIGNAL(triggered()), this, SLOT(ctrlW())); + this->addAction(act_ctrlW); + + QAction *act_ctrlR = new QAction(this); + act_ctrlR->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R)); + connect(act_ctrlR, SIGNAL(triggered()), this, SLOT(ctrlR())); + this->addAction(act_ctrlR); + + QAction *act_ctrlT = new QAction(this); + act_ctrlT->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T)); + connect(act_ctrlT, SIGNAL(triggered()), this, SLOT(ctrlT())); + this->addAction(act_ctrlT); + + QAction *act_ctrlY = new QAction(this); + act_ctrlY->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Y)); + connect(act_ctrlY, SIGNAL(triggered()), this, SLOT(ctrlY())); + this->addAction(act_ctrlY); + + QAction *act_ctrlU = new QAction(this); + act_ctrlU->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); + connect(act_ctrlU, SIGNAL(triggered()), this, SLOT(ctrlU())); + this->addAction(act_ctrlU); + + QAction *act_ctrlI = new QAction(this); + act_ctrlI->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_I)); + connect(act_ctrlI, SIGNAL(triggered()), this, SLOT(ctrlI())); + this->addAction(act_ctrlI); + + QAction *act_ctrlO = new QAction(this); + act_ctrlO->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O)); + connect(act_ctrlO, SIGNAL(triggered()), this, SLOT(ctrlO())); + this->addAction(act_ctrlO); + + QAction *act_ctrlP = new QAction(this); + act_ctrlP->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P)); + connect(act_ctrlP, SIGNAL(triggered()), this, SLOT(ctrlP())); + this->addAction(act_ctrlP); + + QAction *act_ctrlBracketLeft = new QAction(this); + act_ctrlBracketLeft->setShortcut(QKeySequence("Ctrl+[")); + connect(act_ctrlBracketLeft, SIGNAL(triggered()), this, SLOT(ctrlBracketLeft())); + this->addAction(act_ctrlBracketLeft); + + QAction *act_ctrlBracketRight = new QAction(this); + act_ctrlBracketRight->setShortcut(QKeySequence("Ctrl+]")); + connect(act_ctrlBracketRight, SIGNAL(triggered()), this, SLOT(ctrlBracketRight())); + this->addAction(act_ctrlBracketRight); + + QAction *act_ctrlJ = new QAction(this); + act_ctrlJ->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_J)); + connect(act_ctrlJ, SIGNAL(triggered()), this, SLOT(ctrlJ())); + this->addAction(act_ctrlJ); + + QAction *act_ctrlK = new QAction(this); + act_ctrlK->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_K)); + connect(act_ctrlK, SIGNAL(triggered()), this, SLOT(ctrlK())); + this->addAction(act_ctrlK); + + QAction *act_ctrlL = new QAction(this); + act_ctrlL->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L)); + connect(act_ctrlL, SIGNAL(triggered()), this, SLOT(ctrlL())); + this->addAction(act_ctrlL); + + QAction *act_ctrlPointVirgule = new QAction(this); + act_ctrlPointVirgule->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Semicolon)); + connect(act_ctrlPointVirgule, SIGNAL(triggered()), this, SLOT(ctrlPointVirgule())); + this->addAction(act_ctrlPointVirgule); + + QAction *act_ctrlApostrophe = new QAction(this); + act_ctrlApostrophe->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Apostrophe)); + connect(act_ctrlApostrophe, SIGNAL(triggered()), this, SLOT(ctrlApostrophe())); + this->addAction(act_ctrlApostrophe); + + QAction *act_ctrlZ = new QAction(this); + act_ctrlZ->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z)); + connect(act_ctrlZ, SIGNAL(triggered()), this, SLOT(ctrlZ())); + this->addAction(act_ctrlZ); + + QAction *act_ctrlV = new QAction(this); + act_ctrlV->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V)); + connect(act_ctrlV, SIGNAL(triggered()), this, SLOT(ctrlV())); + this->addAction(act_ctrlV); + + QAction *act_ctrlB = new QAction(this); + act_ctrlB->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); + connect(act_ctrlB, SIGNAL(triggered()), this, SLOT(ctrlB())); + this->addAction(act_ctrlB); + + QAction *act_ctrlN = new QAction(this); + act_ctrlN->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N)); + connect(act_ctrlN, SIGNAL(triggered()), this, SLOT(ctrlN())); + this->addAction(act_ctrlN); + + QAction *act_ctrlM = new QAction(this); + act_ctrlM->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); + connect(act_ctrlM, SIGNAL(triggered()), this, SLOT(ctrlM())); + this->addAction(act_ctrlM); + + QAction *act_ctrlVirgule = new QAction(this); + act_ctrlVirgule->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Comma)); + connect(act_ctrlVirgule, SIGNAL(triggered()), this, SLOT(ctrlVirgule())); + this->addAction(act_ctrlVirgule); + + QAction *act_ctrlPoint = new QAction(this); + act_ctrlPoint->setShortcut(QKeySequence("Ctrl+.")); + connect(act_ctrlPoint, SIGNAL(triggered()), this, SLOT(ctrlPoint())); + this->addAction(act_ctrlPoint); + + QAction *act_ctrlSlash = new QAction(this); + act_ctrlSlash->setShortcut(QKeySequence("Ctrl+/")); + connect(act_ctrlSlash, SIGNAL(triggered()), this, SLOT(ctrlSlash())); + this->addAction(act_ctrlSlash); + + + //-------------- + QAction *act_ctrlChapeau = new QAction(this); + act_ctrlChapeau->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Dead_Circumflex)); + connect(act_ctrlChapeau, SIGNAL(triggered()), this, SLOT(ctrlChapeau())); + this->addAction(act_ctrlChapeau); + + QAction *act_ctrlDollar = new QAction(this); + act_ctrlDollar->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Dollar)); + connect(act_ctrlDollar, SIGNAL(triggered()), this, SLOT(ctrlDollar())); + this->addAction(act_ctrlDollar); + + QAction *act_ctrlStar = new QAction(this); + act_ctrlStar->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Asterisk)); + connect(act_ctrlStar, SIGNAL(triggered()), this, SLOT(ctrlStar())); + this->addAction(act_ctrlStar); + + QAction *act_ctrlAdvU = new QAction(this); + act_ctrlAdvU->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Ugrave)); + connect(act_ctrlAdvU, SIGNAL(triggered()), this, SLOT(ctrlAdvU())); + this->addAction(act_ctrlAdvU); + + QAction *act_ctrlChevron = new QAction(this); + act_ctrlChevron->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Less)); + connect(act_ctrlChevron, SIGNAL(triggered()), this, SLOT(ctrlChevron())); + this->addAction(act_ctrlChevron); + + QAction *act_ctrlDoubleDot = new QAction(this); + act_ctrlDoubleDot->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Colon)); + connect(act_ctrlDoubleDot, SIGNAL(triggered()), this, SLOT(ctrlDoubleDot())); + this->addAction(act_ctrlDoubleDot); + + QAction *act_ctrlExclamation = new QAction(this); + act_ctrlExclamation->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Exclam)); + connect(act_ctrlExclamation, SIGNAL(triggered()), this, SLOT(ctrlExclamation())); + this->addAction(act_ctrlExclamation); + + //-------------- + QAction *act_ctrlEtCommercial = new QAction(this); + act_ctrlEtCommercial->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Ampersand)); + connect(act_ctrlEtCommercial, SIGNAL(triggered()), this, SLOT(ctrlEtCommercial())); + this->addAction(act_ctrlEtCommercial); + + QAction *act_ctrlEAigu = new QAction(this); + act_ctrlEAigu->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Eacute)); + connect(act_ctrlEAigu, SIGNAL(triggered()), this, SLOT(ctrlEAigu())); + this->addAction(act_ctrlEAigu); + + QAction *act_ctrlEGrave = new QAction(this); + act_ctrlEGrave->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Egrave)); + connect(act_ctrlEGrave, SIGNAL(triggered()), this, SLOT(ctrlEGrave())); + this->addAction(act_ctrlEGrave); + + QAction *act_ctrlGuillemet = new QAction(this); + act_ctrlGuillemet->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_QuoteDbl)); + connect(act_ctrlGuillemet, SIGNAL(triggered()), this, SLOT(ctrlGuillement())); + this->addAction(act_ctrlGuillemet); + + QAction *act_ctrlParentheseO = new QAction(this); + act_ctrlParentheseO->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_ParenLeft)); + connect(act_ctrlParentheseO, SIGNAL(triggered()), this, SLOT(ctrlParentheseO())); + this->addAction(act_ctrlParentheseO); + + QAction *act_ctrlParentheseF = new QAction(this); + act_ctrlParentheseF->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_ParenRight)); + connect(act_ctrlParentheseF, SIGNAL(triggered()), this, SLOT(ctrlParentheseF())); + this->addAction(act_ctrlParentheseF); + + QAction *act_ctrl_ = new QAction(this); + act_ctrl_->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Underscore)); + connect(act_ctrl_, SIGNAL(triggered()), this, SLOT(ctrl_())); + this->addAction(act_ctrl_); + + QAction *act_ctrlCedille = new QAction(this); + act_ctrlCedille->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Ccedilla)); + connect(act_ctrlCedille, SIGNAL(triggered()), this, SLOT(ctrlCedille())); + this->addAction(act_ctrlCedille); + + QAction *act_ctrlAGrave = new QAction(this); + act_ctrlAGrave->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Agrave)); + connect(act_ctrlAGrave, SIGNAL(triggered()), this, SLOT(ctrlAGrave())); + this->addAction(act_ctrlAGrave); + + QAction *act_ctrlEqual = new QAction(this); + act_ctrlEqual->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Equal)); + connect(act_ctrlEqual, SIGNAL(triggered()), this, SLOT(ctrlEqual())); + this->addAction(act_ctrlEqual); + + QAction *act_ctrlMinus = new QAction(this); + act_ctrlMinus->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Minus)); + connect(act_ctrlMinus, SIGNAL(triggered()), this, SLOT(ctrlMinus())); + this->addAction(act_ctrlMinus); + + + +} + +//--------------------------- +void HCISheet::paintEvent(QPaintEvent *){ + static bool first = true; + static QImage left; + static QImage right; + static QImage front; + static QImage back; + static QImage keyboard; + if(first){ + left = QImage(":/resources/left.png"); + left = left.scaledToHeight(30); + right = QImage(":/resources/right.png"); + right = right.scaledToHeight(30); + front = QImage(":/resources/front.png"); + front = front.scaledToHeight(30); + back = QImage(":/resources/back.png"); + back = back.scaledToHeight(30); + keyboard = QImage(":/resources/keyboard.gif"); + keyboard = keyboard.scaledToWidth(this->width() - 100); + first = false; + } + key = key.toUpper(); + QPainter p(this); + p.fillRect(0,0,width(),height(),Qt::white); + p.drawImage(width()/2 - keyboard.width()/2, height()/2- keyboard.height()/2, keyboard); + // p.fillRect(0,0,200,200,Qt::gray); + /* int x = 100; + int y = 100;*/ + int w = 30; int h =30; + // p.drawText(x+10, y+20, key); + + this->paintRaisedKeys(p); + + + QColor c1(Qt::darkCyan); + c1.setAlpha(150); + p.setBrush(c1); + p.setPen(c1); + + if(type == "t"){ + //p.drawRect(x-15+15, y-15+15, 30,30); + p.setBrush(Qt::white); + p.setPen(Qt::white); + p.drawEllipse(posLetter[key].x()-w/2 + 5, posLetter[key].y()-h/2 - 7, w, h); + p.setBrush(c1); + p.setPen(c1); + p.drawEllipse(posLetter[key].x()-w/2 + 5, posLetter[key].y()-h/2 -7, w, h); + } + if(!type.compare("l")){ + //p.drawImage(x-15,y, left); + p.setBrush(Qt::white); + p.setPen(Qt::white); + if(key=="D"){ + p.drawRect(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, 10, 46); + p.setBrush(c1); + p.setPen(c1); + p.drawRect(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, 10, 46); + //p.drawImage(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, left); + + }else { + p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2, 10, 46); + p.setBrush(c1); + p.setPen(c1); + p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2, 10, 46); + + } + + } + if(!type.compare("r")){ + //p.drawImage(x+15,100, right); + p.setBrush(Qt::white); + p.setPen(Qt::white); + if(key=="D"){ + + p.drawRect(posLetter["D"].x() - 23 + 12 + 46 - 10, posLetter["D"].y() - 23 - 2, 10, 46); + p.setBrush(c1); + p.setPen(c1); + p.drawRect(posLetter["D"].x() - 23 + 12 + 46 - 10, posLetter["D"].y() - 23 - 2, 10, 46); + //p.drawImage(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, left); + + }else { + + p.drawRect(posLetter["O"].x() - 23 + 6 + 46 - 10, posLetter["O"].y() - 23- 2, 10, 46); + p.setBrush(c1); + p.setPen(c1); + p.drawRect(posLetter["O"].x() - 23 + 6 + 46 - 10, posLetter["O"].y() - 23- 2, 10, 46); + + } + } + if(type =="f"){ + //p.drawImage(x,y+15, front); + p.setBrush(Qt::white); + p.setPen(Qt::white); + + if(key=="D"){ + + p.drawRect(posLetter["D"].x() - 23 + 12 , posLetter["D"].y() - 23 - 2+46-10, 46, 10); + p.setBrush(c1); + p.setPen(c1); + p.drawRect(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2+46-10, 46, 10); + //p.drawImage(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, left); + + }else { + + p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2+46-10, 46, 10); + p.setBrush(c1); + p.setPen(c1); + p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2+46-10, 46, 10); + + } + + } + if(type =="b"){ + //p.drawImage(x,y-15, back); + p.setBrush(Qt::white); + p.setPen(Qt::white); + + if(key=="D"){ + + p.drawRect(posLetter["D"].x() - 23 + 12 , posLetter["D"].y() - 23 - 2, 46, 10); + p.setBrush(c1); + p.setPen(c1); + p.drawRect(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, 46, 10); + //p.drawImage(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, left); + + }else { + + p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2, 46, 10); + p.setBrush(c1); + p.setPen(c1); + p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2, 46, 10); + + } + } + + + paintLetters(p); +} + +void HCISheet::paintRaisedKeys(QPainter &p){ + QColor c(Qt::darkMagenta); + c.setAlpha(50); + p.setBrush(c); + p.setPen(c); + p.drawRect(posLetter["O"].x() - 23 + 6, posLetter["O"].y() - 23- 2, 46, 46); + p.drawRect(posLetter["D"].x() - 23 + 12, posLetter["D"].y() - 23 - 2, 46, 46); +} + +void HCISheet::buildPosLetterMapping(){ + int x = 180; int y = 434; + float step = 48.5; + posLetter["A"] = QPoint(x,y); + posLetter["Z"] = QPoint(x+1*step,y); + posLetter["E"] = QPoint(x+2*step,y); + posLetter["R"] = QPoint(x+3*step,y); + posLetter["T"] = QPoint(x+4*step,y); + posLetter["Y"] = QPoint(x+5*step,y); + posLetter["U"] = QPoint(x+6*step,y); + posLetter["I"] = QPoint(x+7*step,y); + posLetter["O"] = QPoint(x+8*step,y); + posLetter["P"] = QPoint(x+9*step,y); + posLetter["^"] = QPoint(x+10*step,y); + posLetter["$"] = QPoint(x+11*step,y); + + x = 192; y = 482; + posLetter["Q"] = QPoint(x,y); + posLetter["S"] = QPoint(x+1*step,y); + posLetter["D"] = QPoint(x+2*step,y); + posLetter["F"] = QPoint(x+3*step,y); + posLetter["G"] = QPoint(x+4*step,y); + posLetter["H"] = QPoint(x+5*step,y); + posLetter["J"] = QPoint(x+6*step,y); + posLetter["K"] = QPoint(x+7*step,y); + posLetter["L"] = QPoint(x+8*step,y); + posLetter["M"] = QPoint(x+9*step,y); + posLetter[QString::fromUtf8("ù")] = QPoint(x+10*step,y); + posLetter["*"] = QPoint(x+11*step,y); + + x = 215; y = 530; + posLetter["<"] = QPoint(x - 1*step ,y); + posLetter["W"] = QPoint(x,y); + posLetter["X"] = QPoint(x+1*step,y); + posLetter["C"] = QPoint(x+2*step,y); + posLetter["V"] = QPoint(x+3*step,y); + posLetter["B"] = QPoint(x+4*step,y); + posLetter["N"] = QPoint(x+5*step,y); + posLetter[","] = QPoint(x+6*step,y); + posLetter[";"] = QPoint(x+7*step,y); + posLetter[":"] = QPoint(x+8*step,y); + //posLetter["="] = QPoint(x+9*step,y); + posLetter["!"] = QPoint(x+9*step,y); + + x = 107; y = 388; + //posLetter["`"] = QPoint(x,y); + posLetter["&"] = QPoint(x+1*step,y); + posLetter[QString::fromUtf8("é")] = QPoint(x+2*step,y); + posLetter["\""] = QPoint(x+3*step,y); + posLetter["'"] = QPoint(x+4*step,y); + posLetter["("] = QPoint(x+5*step,y); + posLetter["-"] = QPoint(x+6*step,y); + posLetter[QString::fromUtf8("è")] = QPoint(x+7*step,y); + posLetter["_"] = QPoint(x+8*step,y); + posLetter[QString::fromUtf8("ç").toUpper()] = QPoint(x+9*step,y); + posLetter[QString::fromUtf8("à ").toUpper()] = QPoint(x+10*step,y); + posLetter[")"] = QPoint(x+11*step,y); + posLetter["="] = QPoint(x+12*step,y); + + specialLetter["enter"] = QPoint(180 + 12*step, 434); + specialLetter["delete"] = QPoint(180 + 12*step, 384); + specialLetter["tab"] = QPoint(100, 434); + specialLetter["Caps lock"] = QPoint(100, 484); + specialLetter["shift l"] = QPoint(100, 534); + specialLetter["shift r"] = QPoint(760, 534); + specialLetter["ctrl l"] = QPoint(100, 584); + specialLetter["ctrl r"] = QPoint(760, 584); + //specialLetter["win l"] = QPoint(170, 584); + specialLetter["alt l"] = QPoint(230, 584); + specialLetter["alt r"] = QPoint(580, 584); +} + +void HCISheet::paintLetters(QPainter& p){ + + p.setPen(Qt::black); + QFont f; f.setPixelSize(20); + p.setFont(f); + + //float step = 48.5; + //int x = 180; int y = 434; + QMap::const_iterator i = posLetter.constBegin(); + while (i != posLetter.constEnd()) { + p.drawText(i.value(), i.key()); + ++i; + } + + f.setPixelSize(12); + p.setFont(f); + + QMap::const_iterator j = specialLetter.constBegin(); + while (j != specialLetter.constEnd()) { + p.drawText(j.value(), j.key()); + ++j; + } + + + f.setPixelSize(12); + p.setFont(f); + + +} + +//--------------------------- +void HCISheet::keyPressEvent(QKeyEvent *ke){ + //qDebug()<<"keyPressEvent hci sheet "<text() <modifiers(); + + if(ke->text() != "") + { + emit hotkeyPressed(ke->text()); + } + if(ke->modifiers()==Qt::CTRL){ + this->ctrl_pressed = true; + } +} + +void HCISheet::ctrlF(){ qDebug()<<"ctrl F"; emit hotkeyReleased("f"); } +void HCISheet::ctrlA(){ qDebug()<<"ctrl A"; emit hotkeyReleased("a"); } +void HCISheet::ctrlS(){ qDebug()<<"ctrl S"; emit hotkeyReleased("s"); } +void HCISheet::ctrlD(){ qDebug()<<"ctrl D"; emit hotkeyReleased("d"); } +void HCISheet::ctrlG(){ qDebug()<<"ctrl G"; emit hotkeyReleased("g"); } +void HCISheet::ctrlE(){ qDebug()<<"ctrl E"; emit hotkeyReleased("e"); } +void HCISheet::ctrl4(){ qDebug()<<"ctrl F"; emit hotkeyReleased("4"); } +void HCISheet::ctrlX(){ qDebug()<<"ctrl X"; emit hotkeyReleased("x"); } +void HCISheet::ctrlC(){ qDebug()<<"ctrl C"; emit hotkeyReleased("c"); } +void HCISheet::ctrlH(){ qDebug()<<"ctrl H"; emit hotkeyReleased("h"); } + +void HCISheet::ctrlQ(){ qDebug()<<"ctrl Q"; emit hotkeyReleased("q"); } +void HCISheet::ctrlW(){ qDebug()<<"ctrl W"; emit hotkeyReleased("w"); } +void HCISheet::ctrlR(){ qDebug()<<"ctrl R"; emit hotkeyReleased("r"); } +void HCISheet::ctrlT(){ qDebug()<<"ctrl T"; emit hotkeyReleased("t"); } +void HCISheet::ctrlY(){ qDebug()<<"ctrl Y"; emit hotkeyReleased("y"); } +void HCISheet::ctrlU(){ qDebug()<<"ctrl U"; emit hotkeyReleased("u"); } +void HCISheet::ctrlI(){ qDebug()<<"ctrl I"; emit hotkeyReleased("i"); } +void HCISheet::ctrlO(){ qDebug()<<"ctrl O"; emit hotkeyReleased("o"); } +void HCISheet::ctrlP(){ qDebug()<<"ctrl P"; emit hotkeyReleased("p"); } +void HCISheet::ctrlBracketLeft(){ qDebug()<<"ctrl ["; emit hotkeyReleased("["); } +void HCISheet::ctrlBracketRight(){ qDebug()<<"ctrl ]"; emit hotkeyReleased("]"); } +void HCISheet::ctrlJ(){ qDebug()<<"ctrl J"; emit hotkeyReleased("j"); } +void HCISheet::ctrlK(){ qDebug()<<"ctrl K"; emit hotkeyReleased("k"); } +void HCISheet::ctrlL(){ qDebug()<<"ctrl L"; emit hotkeyReleased("l"); } +void HCISheet::ctrlPointVirgule(){ qDebug()<<"ctrl ;"; emit hotkeyReleased(";"); } +void HCISheet::ctrlApostrophe(){ qDebug()<<"ctrl '"; emit hotkeyReleased("'"); } +void HCISheet::ctrlZ(){ qDebug()<<"ctrl Z"; emit hotkeyReleased("z"); } +void HCISheet::ctrlV(){ qDebug()<<"ctrl V"; emit hotkeyReleased("v"); } +void HCISheet::ctrlB(){ qDebug()<<"ctrl B"; emit hotkeyReleased("b"); } +void HCISheet::ctrlN(){ qDebug()<<"ctrl N"; emit hotkeyReleased("n"); } +void HCISheet::ctrlM(){ qDebug()<<"ctrl M"; emit hotkeyReleased("m"); } +void HCISheet::ctrlVirgule(){ qDebug()<<"ctrl ,"; emit hotkeyReleased(","); } +void HCISheet::ctrlPoint(){ qDebug()<<"ctrl ."; emit hotkeyReleased("."); } +void HCISheet::ctrlSlash(){ qDebug()<<"ctrl /"; emit hotkeyReleased("/"); } + +void HCISheet::ctrlChapeau(){ qDebug()<<"ctrl ^"; emit hotkeyReleased("^"); } +void HCISheet::ctrlDollar(){ qDebug()<<"ctrl $"; emit hotkeyReleased("$"); } +void HCISheet::ctrlStar(){ qDebug()<<"ctrl *"; emit hotkeyReleased("*"); } +void HCISheet::ctrlAdvU(){ qDebug()<<("ctrl " + QString::fromUtf8("ù")); emit hotkeyReleased(QString::fromUtf8("ù")); } +void HCISheet::ctrlChevron(){ qDebug()<<"ctrl <"; emit hotkeyReleased("<"); } +void HCISheet::ctrlDoubleDot(){ qDebug()<<"ctrl :"; emit hotkeyReleased(":"); } +void HCISheet::ctrlExclamation(){ qDebug()<<"ctrl !"; emit hotkeyReleased("!"); } + +void HCISheet::ctrlEtCommercial(){ qDebug()<<"ctrl &"; emit hotkeyReleased("&"); } +void HCISheet::ctrlEAigu(){ qDebug()<<"ctrl "+QString::fromUtf8("é"); emit hotkeyReleased(QString::fromUtf8("é")); } +void HCISheet::ctrlEGrave(){ qDebug()<<"ctrl "+QString::fromUtf8("è"); emit hotkeyReleased(QString::fromUtf8("è")); } +void HCISheet::ctrlGuillement(){ qDebug()<<"ctrl \""; emit hotkeyReleased("\""); } +void HCISheet::ctrlParentheseO(){ qDebug()<<"ctrl ("; emit hotkeyReleased("("); } +void HCISheet::ctrlParentheseF(){ qDebug()<<"ctrl )"; emit hotkeyReleased(")"); } +void HCISheet::ctrl_(){ qDebug()<<"ctrl _"; emit hotkeyReleased("_"); } +void HCISheet::ctrlCedille(){ qDebug()<<"ctrl "+ QString::fromUtf8("ç"); emit hotkeyReleased(QString::fromUtf8("ç")); } +void HCISheet::ctrlAGrave(){ qDebug()<<"ctrl "+QString::fromUtf8("à "); emit hotkeyReleased(QString::fromUtf8("à ")); } +void HCISheet::ctrlEqual(){ qDebug()<<"ctrl ="; emit hotkeyReleased("="); } +void HCISheet::ctrlMinus(){ qDebug()<<"ctrl -"; emit hotkeyReleased("-"); } + +//--------------------------- +void HCISheet::keyReleaseEvent(QKeyEvent *ke){ + + qDebug()<<"keyReleaseEvent hci sheet"<key() << " " << ke->text() << " " << ke->modifiers(); +/* + if(this->ctrl_pressed){ + qDebug()<<"keyReleaseEvent hci sheet 2"<key() <modifiers(); + if(ke->key()!=0) + { + qDebug()<<"keyReleaseEvent hci sheet 3"<text() <modifiers(); + emit hotkeyReleased(QString(ke->key())); + } + } +// if(ke->text() != "") +// { +// emit hotkeyReleased(ke->text()); +// } + if(ke->modifiers()!=Qt::CTRL){ + this->ctrl_pressed = false; + } +*/ +} diff --git a/Expe-selection/dyna-expe2/HCISheet.h b/Expe-selection/dyna-expe2/HCISheet.h new file mode 100644 index 0000000..b3e7cd1 --- /dev/null +++ b/Expe-selection/dyna-expe2/HCISheet.h @@ -0,0 +1,93 @@ +#ifndef HCISHEET_H +#define HCISHEET_H +#include +#include +#include "expe/expeWidget/TrialSheet.h" + +class HCISheet : public TrialSheet +{ + Q_OBJECT + +public: + HCISheet(QWidget *parent =0); + virtual ~HCISheet(){} + + + void paintEvent(QPaintEvent *); + void keyPressEvent(QKeyEvent *); + void keyReleaseEvent(QKeyEvent *); + void paintLetters(QPainter& p); + void paintRaisedKeys(QPainter& p); + void buildPosLetterMapping(); + + +signals: + void hotkeyPressed(QString c); + void hotkeyReleased(QString c); + +public slots: + void setTargetKey(QString _key, QString _type){key = _key; type = _type; } + void ctrlF(); + void ctrlA(); + void ctrlS(); + void ctrlD(); + void ctrlG(); + void ctrlH(); + void ctrlE(); + void ctrl4(); + void ctrlX(); + void ctrlC(); + + + void ctrlQ(); + void ctrlW(); + void ctrlR(); + void ctrlT(); + void ctrlY(); + void ctrlU(); + void ctrlI(); + void ctrlO(); + void ctrlP(); + void ctrlBracketLeft(); + void ctrlBracketRight(); + void ctrlJ(); + void ctrlK(); + void ctrlL(); + void ctrlPointVirgule(); + void ctrlApostrophe(); + void ctrlZ(); + void ctrlV(); + void ctrlB(); + void ctrlN(); + void ctrlM(); + void ctrlVirgule(); + void ctrlPoint(); + void ctrlSlash(); + void ctrlChapeau(); + void ctrlDollar(); + void ctrlStar(); + void ctrlAdvU(); + void ctrlChevron(); + void ctrlDoubleDot(); + void ctrlExclamation(); + void ctrlEtCommercial(); + void ctrlEAigu(); + void ctrlEGrave(); + void ctrlGuillement(); + void ctrlParentheseO(); + void ctrlParentheseF(); + void ctrl_(); + void ctrlCedille(); + void ctrlAGrave(); + void ctrlEqual(); + void ctrlMinus(); + +protected: + QString key; + QString type; + bool ctrl_pressed; + QMap posLetter; + QMap specialLetter; +}; + +#endif // HCISHEET_H diff --git a/Expe-selection/dyna-expe2/MainWindow.cpp b/Expe-selection/dyna-expe2/MainWindow.cpp new file mode 100644 index 0000000..8ffffac --- /dev/null +++ b/Expe-selection/dyna-expe2/MainWindow.cpp @@ -0,0 +1,50 @@ +#include "MainWindow.h" +#include +#include +#include +#include +#include +#include +#include "HCISheet.h" + + + +//----------------------------- +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent) +{ + + // QRect geometry = QApplication::desktop()->screenGeometry(); + //HCISheet * hciSheet = new HCISheet(); + //setCentralWidget(hciSheet); + //hciSheet->show(); +} + + + + + +bool MainWindow::event(QEvent *e) +{ + if(e->type() == QEvent::KeyPress) + { + QKeyEvent * ke = dynamic_cast (e); + if(ke){ + + } + } + if(e->type() == QEvent::KeyRelease) + { + QKeyEvent * ke = dynamic_cast (e); + if(ke){ + if(ke->key() == Qt::Key_Space) + { + //emit nextBlock(); + //return true; + } + + //return true; + } + } + return QMainWindow::event(e); +} diff --git a/Expe-selection/dyna-expe2/MainWindow.h b/Expe-selection/dyna-expe2/MainWindow.h new file mode 100644 index 0000000..5dd532e --- /dev/null +++ b/Expe-selection/dyna-expe2/MainWindow.h @@ -0,0 +1,24 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +class MainWindow : public QMainWindow +{ + Q_OBJECT +public: + explicit MainWindow(QWidget *parent = 0); + + bool event(QEvent *event); + +//signals: +// void nextBlock(); //space bar + +public slots: + + +protected: + +}; + +#endif // MAINWINDOW_H diff --git a/Expe-selection/dyna-expe2/design/dyna-expe1-old.xml b/Expe-selection/dyna-expe2/design/dyna-expe1-old.xml new file mode 100644 index 0000000..3ad9ba9 --- /dev/null +++ b/Expe-selection/dyna-expe2/design/dyna-expe1-old.xml @@ -0,0 +1,4920 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Expe-selection/dyna-expe2/design/dyna-expe1.xml b/Expe-selection/dyna-expe2/design/dyna-expe1.xml new file mode 100644 index 0000000..6b3b91e --- /dev/null +++ b/Expe-selection/dyna-expe2/design/dyna-expe1.xml @@ -0,0 +1,6439 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Expe-selection/dyna-expe2/design/dyna-selection-2-old.xml b/Expe-selection/dyna-expe2/design/dyna-selection-2-old.xml new file mode 100644 index 0000000..e87928e --- /dev/null +++ b/Expe-selection/dyna-expe2/design/dyna-selection-2-old.xml @@ -0,0 +1,3219 @@ +' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Expe-selection/dyna-expe2/design/dyna-selection-2.xml b/Expe-selection/dyna-expe2/design/dyna-selection-2.xml new file mode 100644 index 0000000..d7f88b1 --- /dev/null +++ b/Expe-selection/dyna-expe2/design/dyna-selection-2.xml @@ -0,0 +1,3219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Expe-selection/dyna-expe2/dyna-expe2.pro b/Expe-selection/dyna-expe2/dyna-expe2.pro new file mode 100644 index 0000000..3165056 --- /dev/null +++ b/Expe-selection/dyna-expe2/dyna-expe2.pro @@ -0,0 +1,54 @@ +# ------------------------------------------------- +# Project created by QtCreator 2009-10-20T18:00:49 +# ------------------------------------------------- +TARGET = dyna-expe2 +DESTDIR = ../tmp/exec/ +TEMPLATE = app +QT += xml +OBJECTS_DIR = ./obj +MOC_DIR = ./moc +UI_DIR = ./ui + +INCLUDEPATH += expe + +RESOURCES += resources.qrc + + + +HEADERS += Controler.h \ + HCISheet.h +SOURCES += main.cpp Controler.cpp \ + HCISheet.cpp + +HEADERS += MainWindow.h +SOURCES += MainWindow.cpp + +# experience librairie +HEADERS += expe/ExpeData.h \ + expe/Global.h \ + expe/ExpeLoader.h \ + expe/Expe.h \ + expe/ExpeConfig.h +SOURCES += expe/ExpeData.cpp \ + expe/Global.cpp \ + expe/ExpeLoader.cpp \ + expe/Expe.cpp \ + expe/Expe_p.cpp \ + expe/ExpeConfig.cpp +HEADERS += expe/xml/DataImport.h \ + expe/xml/DataFactory.h +SOURCES += expe/xml/DataImport.cpp \ + expe/xml/DataFactory.cpp +HEADERS += expe/expeWidget/InterBlock.h \ + expe/expeWidget/InterTrial.h \ + expe/expeWidget/ExpeWidget.h \ + expe/expeWidget/TrialSheet.h +SOURCES += expe/expeWidget/InterBlock.cpp \ + expe/expeWidget/InterTrial.cpp \ + expe/expeWidget/ExpeWidget.cpp \ + expe/expeWidget/TrialSheet.cpp +HEADERS += expe/csv/CSVWriter.h +SOURCES += expe/csv/CSVWriter.cpp + + +FORMS += expe/ExpeConfig.ui diff --git a/Expe-selection/dyna-expe2/expe/Expe.cpp b/Expe-selection/dyna-expe2/expe/Expe.cpp new file mode 100644 index 0000000..9ee34ae --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/Expe.cpp @@ -0,0 +1,217 @@ +#include +#include +#include +#include +#include +#include "Expe.h" +#include "Global.h" +#include "ExpeConfig.h" + +//----------------- +Expe::Expe() +{ + expeConfig = new ExpeConfig(NULL,this); + expeConfig->show(); +} + +//---------------- +void Expe::start(const QString& nameFile, QString user, const QString& option1, const QString& option2) +{ + this->designFileName = nameFile; + widgetParent = createWidgetParent(); + //widgetParent->setWindowState(Qt::WindowFullScreen); + interBlockWidget = createInterBlockWidget(); + interTrialWidget = createInterTrialWidget(); + trialSheet = createTrialSheet(); + widgetParent->show(); + + resetNumBlock(); + resetNumTrial(); + + initStateMachine(); + + expeLoader.user = user; + expeLoader.load(nameFile); + + if(hasInterBlock()) + { + QSignalTransition* trans = initState->addTransition(initState,SIGNAL(propertiesAssigned()),interBlockState); + QObject::connect(trans, SIGNAL(triggered()),this,SLOT(prepareBlock())); + interBlockState->addTransition(interBlockWidget, SIGNAL(interBlockDone()), blockState); + connect(interBlockState,SIGNAL(propertiesAssigned()), + this->interBlockWidget, SLOT(actionOnPropertiesAssigned())); + + }else{ + QSignalTransition* trans = initState->addTransition(initState, SIGNAL(propertiesAssigned()), blockState); + connect(trans,SIGNAL(triggered()), this, SLOT(prepareBlock())); + } + + if(hasInterTrial()) + { + QSignalTransition* trans = preTrialState->addTransition(preTrialState,SIGNAL(propertiesAssigned()),interTrialState); + connect(trans,SIGNAL(triggered()), this, SLOT(prepareTrial())); + interTrialState->addTransition(interTrialWidget, SIGNAL(interTrialDone()), trialState); + }else{ + QSignalTransition* trans = preTrialState->addTransition(preTrialState,SIGNAL(propertiesAssigned()),trialState); + connect(trans,SIGNAL(triggered()), this, SLOT(prepareTrial())); + } + + createCSVHeader(); + + + stateMachine.start(); + +} + +//---------------- +void Expe::prepareBlock() +{ + incrNumBlock(); + if(numBlock() > nbBlock()) + { + qDebug()<<"fin de l'experience"; + QMessageBox::information(0, "End of the experiment", "Danke"); + exit(0); + } + qDebug()<<"prepare block "< property = expeLoader.getTrialProperty(ptr_nextTrial); + + if(hasInterBlock()) + { + QString _numBlock = trialData[expeLoader.header.indexOf("block")]; + interBlockWidget->setTitle("Block "+ QString::number(numBlock())); + interBlockWidget->setDetail("block " + QString::number(numBlock()) + "/" + QString::number(nbBlock())); + //QString heightKey = trialData[expeLoader.header.indexOf("height")]; + + if(!_numBlock.compare("1")) + { + //interBlockWidget->setMessage(heightKey); + } + else + { + //interBlockWidget->setMessage(heightKey); + //interBlockWidget->setMessage("Prenez une pause avant de commencer le bloc suivant"); + } + } + + resetNumTrial(); + + initCSVWriter(trialData); + csvWriter.write("nbblock", QString::number(nbBlock())); + csvWriter.write("nbtrial", QString::number(nbTrial())); + csvWriter.write("username", m_userName); + + prepareBlockData(property); +} + +//---------------- +void Expe::prepareTrial() +{ + incrNumTrial(); + //qDebug()<<"prepare trial "<setTitle("Essai "+QString::number(numTrial())); + interTrialWidget->setDetail("(Bloc "+ numBlock+") : essai " + QString::number(numTrial())+"/"+QString::number(nbTrial())); + if( numTrial() == 1) + { + //interTrialWidget->setMessage("Commencer le premier essai"); + //interTrialWidget->setAnswerVisible(false); + } + else + { + //interTrialWidget->setMessage("Prenez une petite pause avant de commencer"); + //interTrialWidget->setAnswerVisible(true); + } + interTrialWidget->actionOnEntry(); + } + + if(!expeLoader.hasNextTrial()){ + qDebug()<<"no next trial "; + exit(1); + } + QMap property = expeLoader.nextTrial(); + QString str = expeLoader.trial[expeLoader.ptr_trial].join(";"); + //trialSheet->label->setText(QString::number(numTrial())+ " : "+str); + //trialSheet->label->setText(""); + prepareTrialData(property); + csvWriter.write(property); + csvWriter.write("trial",QString::number(numTrial())); + csvWriter.write("endtrial","0"); +} + +//----------------------------- +void Expe::initStateMachine() +{ + initState = new QState(&stateMachine); + stateMachine.setInitialState(initState); + + blockState = new QState(&stateMachine); + preTrialState = new QState(blockState); + postTrialState = new PostTrialState(blockState, &expeLoader, this); + blockState->setInitialState(preTrialState); + interBlockState = new QState(&stateMachine); + trialState = new TrialState(&stateMachine,this); + interTrialState = new QState(&stateMachine); + + + interBlockState->assignProperty(interBlockWidget, "visible", true); + interTrialState->assignProperty(interTrialWidget,"visible",true); + initState->assignProperty(interBlockWidget,"visible",false); + initState->assignProperty(trialSheet,"visible",false); + initState->assignProperty(interTrialWidget, "visible",false); + + blockState->assignProperty(interBlockWidget,"visible",false); + blockState->assignProperty(trialSheet,"visible",false); + blockState->assignProperty(interTrialWidget, "visible",false); + + trialState->assignProperty(trialSheet, "visible",true); + trialState->assignProperty(interTrialWidget, "visible", false); + trialState->assignProperty(interBlockWidget,"visible",false); + + //trialSheet->setProperty("visible", false); + + qDebug() << "test = " << trialSheet->size().height(); + trialState->addTransition(trialSheet, SIGNAL(endTrial()), postTrialState); + postTrialState->addTransition(postTrialState,SIGNAL(notEndOfBlock()), preTrialState); + postTrialState->addTransition(postTrialState,SIGNAL(endOfBlock()),initState); + connect(trialState,SIGNAL(trialStarted()), this, SLOT(onTrialEntry())); + connect(trialState, SIGNAL(trialFinished()), this, SLOT(onTrialExit())); +} + +//----------------------------- +void Expe::initCSVWriter(const QStringList &l) +{ + QString title = this->CSVDirectoryOutput(); + + for(int i=0;iexpeLoader.header.at(i); + h = h.mid(0,1); + title += h+"["+l.at(i) +"]"; + } + title +=".csv"; + csvWriter.openFile(title); + csvWriter.setColumnNames(columNames); +} + +//----------------------- +void Expe::createCSVHeader() +{ + QStringList l = expeLoader.header; + l.push_back("username"); + l.push_back("nbblock"); + l.push_back("nbtrial"); + l.push_back("trial"); + l.push_back("endtrial"); + QStringList l2 = this->completeCSVHeaderData(); + columNames = l + l2; +} + + diff --git a/Expe-selection/dyna-expe2/expe/Expe.h b/Expe-selection/dyna-expe2/expe/Expe.h new file mode 100644 index 0000000..fdb0d2d --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/Expe.h @@ -0,0 +1,200 @@ +#ifndef EXPE_H +#define EXPE_H + +#include +#include +#include +#include "ExpeLoader.h" +#include "expeWidget/InterBlock.h" +#include "expeWidget/InterTrial.h" +//#include "expeWidget/InterTrialTargetPie.h" +#include "expeWidget/TrialSheet.h" +#include "csv/CSVWriter.h" +#include "QTime" +#include + + +class PostTrialState; +class TrialState; +class ExpeConfig; +class Expe : public QObject +{ + Q_OBJECT +public: + friend class ExpeConfig; + friend class PostTrialState; + /* + DefaultConstructeur + */ + Expe(); + + /* + launch the experiment + @param fileName : the name of file with the experimental design + @param user : the user id : "S0, S1, S2, ..." + */ + virtual void start(const QString& fileName, QString user, const QString& option1="", const QString& option2=""); + + +protected: + /* + the designer need to return the list of dependent variables (time, error, reacttime, exectime, etc.) + */ + virtual QStringList completeCSVHeaderData(); //method to implement to add new column name in the csv + + /* + this method is called before each block. it can be used to create the new technique, etc. + @param the list of factors + */ + virtual void prepareBlockData(const QMap& prop); //method to implement to take into account specificities of the experiment + + /* + this method is called before each trial. it can be used to update the new command, etc. + @param the list of factors (name, value) + */ + virtual void prepareTrialData(const QMap& prop);//method to implement to take into account specificities of the experiment + + /* + this defines if the experiment has interblock + */ + virtual bool hasInterBlock(); //method to implement + + /* + this defines if the experiment has intertrial + */ + virtual bool hasInterTrial(); //method to implement + + /* this defines the number of blocks. TODO, guess from the xml file */ + virtual int nbBlock(){ return m_nbBlock; } //method to implement //infos non dispo dans le xml + + /* this defines the number of trials. TODO, guess from the xml file*/ + virtual int nbTrial(){ return m_nbTrial; } + + virtual QString CSVDirectoryOutput(){ return "./csv/"; } + +protected slots: + /* this method is called at the begining of the trial. it is useful to start the timer*/ + virtual void onTrialEntry(); + + /* this method is called at the end of the trial. it is useful to stop the timer*/ + virtual void onTrialExit(); + +protected: + /* these methods can be overided to customize widgets */ + virtual InterBlock* createInterBlockWidget(); + virtual InterTrial* createInterTrialWidget(); + virtual TrialSheet* createTrialSheet(); + virtual QWidget * createWidgetParent(); + +public slots: + virtual void prepareBlock(); + virtual void prepareTrial(); + void setNbTrials(int nb){ m_nbTrial = nb;} + void setNbBlock(int nb){ m_nbBlock = nb;} + + + +protected: + virtual void initStateMachine(); + virtual void initCSVWriter(const QStringList &l);//l is concateneted to write the file name for each block + virtual void createCSVHeader(); + + virtual int numTrial(){ return m_numTrial; } + virtual void incrNumTrial(){ m_numTrial++; } + virtual void resetNumTrial(){ m_numTrial =0;} + + virtual int numBlock(){ return m_numBlock;} + virtual void incrNumBlock(){m_numBlock++;} + virtual void resetNumBlock(){m_numBlock=0;} + + virtual void writeTime(){ csvWriter.write("time",QString::number(deltaTime()), true); } //for convenience + + +protected: + QStateMachine stateMachine; + QState *initState, *blockState, *preTrialState, *interBlockState, *interTrialState; + TrialState *trialState; + PostTrialState *postTrialState; + ExpeLoader expeLoader; + + virtual int deltaTime(){ return time.msecsTo(QTime::currentTime()); } + + InterBlock *interBlockWidget; + InterTrial *interTrialWidget; + TrialSheet *trialSheet; + QWidget *widgetParent; + CSVWriter csvWriter; + QStringList columNames; + QTime time; + QString designFileName; + ExpeConfig *expeConfig; + int m_nbTrial, m_nbBlock; + QString m_userName; + + +private: + int m_numTrial; + int m_numBlock; +}; + + +class TrialState: public QState{ + Q_OBJECT +public: + TrialState(QState *s, Expe* _expe):QState(s),m_expe(_expe){} +protected: + virtual void onEntry(QEvent *event) + { + QState::onEntry(event); + emit trialStarted(); + } + + virtual void onExit(QEvent *event) + { + trialFinished(); + QState::onExit(event); + } +signals: + void trialStarted(); + void trialFinished(); +private: + Expe *m_expe; +}; + + + +class PostTrialState: public QState{ + Q_OBJECT +public: + PostTrialState(QState *s, ExpeLoader* _expeLoader, Expe* _expe):QState(s),m_expeLoader(_expeLoader), m_expe(_expe){} +protected: + virtual void onEntry(QEvent *event) + { + + QState::onEntry(event); + if(this->m_expe->numTrial() == this->m_expe->nbTrial()) + { + qDebug()<<"emit end of block"; + emit endOfBlock(); + }else{ + emit notEndOfBlock(); + } + /* + if(m_expeLoader->endOfBlock()) + { + qDebug()<<"emit end of block"; + emit endOfBlock(); + }else{ + emit notEndOfBlock(); + } + */ + } +signals: + void endOfBlock(); + void notEndOfBlock(); +private: + ExpeLoader *m_expeLoader; + Expe * m_expe; +}; + +#endif // EXPE_H diff --git a/Expe-selection/dyna-expe2/expe/ExpeConfig.cpp b/Expe-selection/dyna-expe2/expe/ExpeConfig.cpp new file mode 100644 index 0000000..78e15d6 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/ExpeConfig.cpp @@ -0,0 +1,43 @@ +#include "ExpeConfig.h" +#include "ui_ExpeConfig.h" +#include "Global.h" + +ExpeConfig::ExpeConfig(QWidget *parent, Expe *_expe) : + QWidget(parent), expe(_expe), + ui(new Ui::ExpeConfig) +{ + ui->setupUi(this); + //ui->file->setText("expemenu2.xml"); + connect(ui->buttonOK, SIGNAL(clicked()), this, SLOT(run())); +} + +ExpeConfig::~ExpeConfig() +{ + delete ui; +} + +void ExpeConfig::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void ExpeConfig::run() +{ + QString userId = ui->userId->text(); + QString name = ui->userName->text(); + QString file = ui->file->text(); + QString technique = ui->technique->text(); + QString set = ui->set->text(); + expe->m_userName = name; + + expe->start(Global::appPath() + +"/../../dyna-expe2/design/"+ file, userId, technique, set); + this->setVisible(false); + +} diff --git a/Expe-selection/dyna-expe2/expe/ExpeConfig.h b/Expe-selection/dyna-expe2/expe/ExpeConfig.h new file mode 100644 index 0000000..51ecd9c --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/ExpeConfig.h @@ -0,0 +1,32 @@ +#ifndef EXPECONFIG_H +#define EXPECONFIG_H + +#include +#include +#include "Expe.h" + +namespace Ui { + class ExpeConfig; +} + +class ExpeConfig : public QWidget { + Q_OBJECT +public: + ExpeConfig(QWidget *parent = 0, Expe *_expe = 0); + ~ExpeConfig(); + +signals: + void importValues(QMap values); + +public slots: + void run(); + +protected: + void changeEvent(QEvent *e); + Expe *expe; + +private: + Ui::ExpeConfig *ui; +}; + +#endif // EXPECONFIG_H diff --git a/Expe-selection/dyna-expe2/expe/ExpeConfig.ui b/Expe-selection/dyna-expe2/expe/ExpeConfig.ui new file mode 100644 index 0000000..6cd30e2 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/ExpeConfig.ui @@ -0,0 +1,225 @@ + + + ExpeConfig + + + Qt::NonModal + + + true + + + + 0 + 0 + 400 + 306 + + + + Form + + + + + 120 + 0 + 181 + 41 + + + + + 24 + + + + Configuration + + + + + + 270 + 260 + 113 + 32 + + + + OK + + + + + + 20 + 50 + 361 + 91 + + + + Utilisateur + + + + + 100 + 30 + 111 + 22 + + + + S0 + + + + + + 10 + 30 + 41 + 16 + + + + Id : + + + + + + 10 + 60 + 61 + 16 + + + + Name : + + + + + + 100 + 60 + 113 + 22 + + + + Name + + + + + + + 10 + 40 + 381 + 16 + + + + Qt::Horizontal + + + + + + 20 + 140 + 361 + 121 + + + + Expérience + + + + + 10 + 60 + 81 + 16 + + + + tech + + + + + + 100 + 60 + 113 + 22 + + + + linear + + + + + + 10 + 30 + 61 + 16 + + + + file : + + + + + + 100 + 30 + 113 + 22 + + + + dyna-selection-2.xml + + + + + + 100 + 90 + 113 + 22 + + + + 1 + + + + + + 10 + 90 + 81 + 16 + + + + set + + + + + + + diff --git a/Expe-selection/dyna-expe2/expe/ExpeData.cpp b/Expe-selection/dyna-expe2/expe/ExpeData.cpp new file mode 100644 index 0000000..40902a6 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/ExpeData.cpp @@ -0,0 +1,137 @@ +#include "ExpeData.h" + +//------------------- +void ExpeData::setProperties(QString name, QString value) +{ + properties[name]=value; +} + +//------------------- +void ExpeData::print(){ + QString prop; + qDebug()<<" "; + qDebug()<m_loader; + //qDebug()<<"hits"; + //return new ExpeDataList(); + } + else if(!className.compare("factor")) + { + ExpeFactor *factor = new ExpeFactor(); + m_loader->factor.push_back(factor); + return factor; + //qDebug()<<" Hit"; + //return new ExpeData(); + } + return 0; +} + +void ExpeDataFactory::setObjectParent(QObject* parent, QObject* child) +{ + //ExpeDataList* _p = dynamic_cast(parent); + //ExpeData* _c = dynamic_cast(child); + //_p->addData(_c); +} + +void ExpeDataFactory::setMProperty(QObject* obj, QString metaName, QString name, QString value) +{ + qDebug()<(obj); +// ExpeData->keywords.push_back(value); +// } +// else if(!name.compare("actors")) +// { +// ExpeData* ExpeData = dynamic_cast(obj); +// ExpeData->actors.push_back(value); +// } +// else if(!name.compare("genres")) +// { +// ExpeData* ExpeData = dynamic_cast(obj); +// ExpeData->genres.push_back(value); +// } +// else if(!name.compare("directors")) +// { +// ExpeData* ExpeData = dynamic_cast(obj); +// ExpeData->directors.push_back(value); +// } +// else +// { +// ExpeData* ExpeData = dynamic_cast(obj); +// if(ExpeData) +// { +// ExpeData->properties[name] = value; +// }else{ +// qDebug()<<"ExpeData is null in setMProperty in dataFactory"; +// } +// } +// }else if(!metaName.compare("MetaText")) +// { +// qDebug()<<"metatext"; +// if(!name.compare("title")) +// { +// qDebug()<<"metatext title"; +// myState = "title"; +// } + /* + + Mr. and Mrs. Smith + + */ +// }else if(!metaName.compare("TextSeg")) +// { +// if(!myState.compare("title")){ +// ExpeData* ExpeData = dynamic_cast(obj); +// if(ExpeData) +// { +// ExpeData->properties["title"] = value; +// qDebug()<<"title = "<(m_Current); +// if(list){ +// return list; +// }else{ +// qDebug()<<"getRoot()"<< "ce n'est pas un ExpeDataList"; +// exit(1); +// } + + return m_Current; +} + + diff --git a/Expe-selection/dyna-expe2/expe/ExpeData.h b/Expe-selection/dyna-expe2/expe/ExpeData.h new file mode 100644 index 0000000..ced069e --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/ExpeData.h @@ -0,0 +1,87 @@ + +#ifndef __MDATA__ +#define __MDATA__ + +#include +#include +#include +#include +#include "ExpeLoader.h" +#include "xml/DataExport.h" +#include "xml/DataImport.h" + +class MDataFactory; +//--------------------------------------- +//--------------------------------------- +class ExpeData: public QObject +{ + public: + ExpeData(){} + void setProperties(QString name, QString value); + void print(); + QString property(const QString& name, bool& b); + + protected: + QMap properties; + +}; + + + +//------------------------------------- +//------------------------------------- +class ExpeDataFactory : public DataFactory +{ + public: + ExpeDataFactory(ExpeLoader *loader=0){m_loader = loader; } + virtual QObject* newObject(const QString& className); + + virtual void setObjectParent(QObject* parent, QObject* child); + virtual void setMProperty(QObject* obj, QString metaName, QString name, QString value); + +protected: + DataFactory* createFactory(); + ExpeLoader *m_loader; +}; + + +//-------------------------------------- +//-------------------------------------- +class ExpeDataImport : public DataImport +{ + public: + ExpeDataImport(ExpeDataFactory *factory):DataImport(factory){} + ExpeDataImport(const QString& filename, ExpeDataFactory *factory): + DataImport(filename,factory){} + + QObject* getRoot(); +}; + + +//--------------------------------------- +//--------------------------------------- +//class ExpeDataExport : public DataExport { +//public: +// ExpeDataExport(const QString& path= "defaultMData.xml"):DataExport(path){} +// +//protected: +// +// //reimplement +// virtual QVector children(const QObject*){ +// qDebug() << "children const ModelItem"; +// QVector retval; +//// const ModelMenu *menu = dynamic_cast (item); +//// if(menu) +//// { +//// for(int i=0; icountItems(); ++i) +//// retval.push_back(menu->item(i)); +//// } +// return retval; +// } +// +//}; + + + +#endif + diff --git a/Expe-selection/dyna-expe2/expe/ExpeLoader.cpp b/Expe-selection/dyna-expe2/expe/ExpeLoader.cpp new file mode 100644 index 0000000..32e2b3d --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/ExpeLoader.cpp @@ -0,0 +1,157 @@ +#include "ExpeLoader.h" +#include "ExpeData.h" +#include "xml/DataImport.h" +#include "xml/DataFactory.h" +#include "Global.h" +#include +//------------------------ +ExpeLoader::ExpeLoader() +{ + user = "S0"; + ptr_trial = -1; +} + + + +//-------------------------- +QMap ExpeLoader::getTrialProperty(int i) +{ + QMap res; + QStringList trialData = trial[i]; + + for(int j =0;j ExpeLoader::nextTrial() +{ + if(!hasNextTrial()) + { + qDebug()<<"ExpeLoader next trial1: no next trial"; + exit(1); + } + ptr_trial++; + bool find = false; + while(!find){ + QStringList trialData = trial[ptr_trial]; + QString type = trialData[header.indexOf("expe_type")]; + if(!type.compare("expe")) + { + find = true; + }else + { + if(!hasNextTrial()) + { + qDebug()<<"ExpeLoader next trial2: no next trial"; + exit(1); + } + ptr_trial++; + } + } + + QMap prop = getTrialProperty(ptr_trial); + return prop; +} + +//---------------------------------- +int ExpeLoader::getNextTrialPtr(int ptr_start) +{ + if(ptr_start == -1) ptr_start = this->ptr_trial; + int ptr_tmp = ptr_start +1; + while(true) + { + if(ptr_tmp>= trial.size()) return -1; + QStringList trialData = trial[ptr_tmp]; + QString type = trialData[header.indexOf("expe_type")]; + if(!type.compare("expe")) + { + return ptr_tmp; + } + ptr_tmp++; + } + return false; +} + +//-------------------------- +bool ExpeLoader::endOfBlock() +{ + int indexBlock = header.indexOf("block"); + QStringList trialData = trial[ptr_trial]; + int curNumBlock = trialData[indexBlock].toInt(); + + int ptr_tmp = ptr_trial +1; + bool find = false; + while(!find) + { + if(ptr_tmp>= trial.size()) return true; + QStringList trialData = trial[ptr_tmp]; + QString type = trialData[header.indexOf("expe_type")]; + if(!type.compare("expe")) + { + int numBlockTmp = trialData[indexBlock].toInt(); + if( numBlockTmp == curNumBlock ) + return false; + else + return true; + }else + { + ptr_tmp++; + } + } + return false; +} + +//-------------------------- +void ExpeLoader::updateCurTrial(const QString& name, const QString& value){ + //updateTrial("user", "S0"); + if(header.contains(name)) + { + curTrial.replace(header.indexOf(name),value); + }else{ + header.push_back(name); + curTrial.push_back(value); + } +} + +//------------------------ +void ExpeLoader::updateCurTrial(const QString& nameValue){ + QStringList tab = nameValue.split("="); + //qDebug()<< nameValue << tab; + + updateCurTrial(tab[0], tab[1]); + //updateTrial("user=S0"); +} + +//------------------------ +void ExpeLoader::load(const QString& fileName) +{ + ExpeDataFactory factory(this); + ExpeDataImport import(fileName, &factory); + //print(); + //MDataList * mdataList = dynamic_cast< MDataList* >(mdataImport.getRoot()); + //return mdataList; + +} + +void ExpeLoader::print() +{ + qDebug()<property; + for(int i=0;ifactor.size();i++) + { + qDebug()<< factor[i]->property; + qDebug()<value; + } + qDebug()<<" "; + qDebug()<header.join(";"); + qDebug()<<" "; + for(int j=0;jtrial.size();j++) + { + qDebug()<< trial[j].join(";"); + } + + +} diff --git a/Expe-selection/dyna-expe2/expe/ExpeLoader.h b/Expe-selection/dyna-expe2/expe/ExpeLoader.h new file mode 100644 index 0000000..3d1b252 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/ExpeLoader.h @@ -0,0 +1,62 @@ +#ifndef EXPELOADER_H +#define EXPELOADER_H + +#include +#include +#include +#include "xml/DataFactory.h" + +class ExpeFactor; + + + +//---------------------------- +class ExpeLoader : public QObject +{ +public: + friend class Expe; + ExpeLoader(); + + //---------- + void updateCurTrial(const QString& name, const QString& value); //updateTrial("user", "S0"); + void updateCurTrial(const QString& nameValue); //updateTrial("user=S0"); + void updateTrial(){trial.push_back(curTrial);} + void print(); + + //------------ + QMap getTrialProperty(int i); + void load(const QString& fileName); + QMap nextTrial(); + bool hasNextTrial(){ return (ptr_trial+1) property; + QVector factor; + QStringList header; + QVector trial; + QStringList curTrial; + QString user; +private: + + int ptr_trial; +}; + + +/* + + + + + + +*/ +class ExpeFactor:public QObject{ +public: + ExpeFactor():QObject(){} + QVector value; + QMap property; +}; + +#endif // EXPELOADER_H diff --git a/Expe-selection/dyna-expe2/expe/Expe_p.cpp b/Expe-selection/dyna-expe2/expe/Expe_p.cpp new file mode 100644 index 0000000..20a64bb --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/Expe_p.cpp @@ -0,0 +1,98 @@ +#include +#include "Expe.h" +#include "Global.h" + +//---------------------- +InterBlock* Expe::createInterBlockWidget() +{ + static bool first = true; + if(first){ + first = false; + return (new InterBlock(widgetParent)); + } + return this->interBlockWidget; +} + +//---------------------- +InterTrial* Expe::createInterTrialWidget() +{ + static bool first = true; + if(first){ + first = false; + return (new InterTrial(widgetParent)); + } + return this->interTrialWidget; +} + + +//---------------------- +TrialSheet* Expe::createTrialSheet() +{ + static bool first = true; + if(first){ + first = false; + return (new TrialSheet(widgetParent)); + } + return this->trialSheet; +} + +//---------------------- +QWidget * Expe::createWidgetParent() +{ + static bool first = true; + if(first){ + first = false; + QWidget *w = new QWidget(0); + QRect rect = Global::app->desktop()->screenGeometry(); + w->resize(rect.width(), rect.height()-100); + return w; + } + return this->widgetParent; +} + +//----------------- +bool Expe::hasInterBlock() +{ + return true; +} + +//----------------- +bool Expe::hasInterTrial() +{ + return true; +} + +//---------------------- +void Expe::prepareBlockData(const QMap &prop) +{ + qDebug()<<"prepare block data :"<& prop) +{ + qDebug()<applicationDirPath()); + //qDebug() << configDir.absolutePath(); + + #if defined(Q_OS_MAC) + if (configDir.dirName() == "MacOS") + { + configDir.cdUp(); + configDir.cdUp(); + configDir.cdUp(); + + //traitement du cas xcode qui rajoute deux niveaux de profondeurs + if(configDir.dirName().toLower() == "debug" || configDir.dirName().toLower() == "release") + { + configDir.cdUp(); + configDir.cdUp(); + } + } + +#elif defined(Q_OS_WIN) + if (configDir.dirName().toLower() == "debug" || configDir.dirName().toLower() == "release"){ + configDir.cdUp(); + } + #endif + + configDir.cd("config"); + //qDebug() << configDir.absolutePath(); + path = configDir.absolutePath(); + } + + return path; +} + +float Global::distCarre(float a1, float b1, float c1, float a2, float b2, float c2) +{ + return (a1-a2)*(a1-a2) + (b1-b2)*(b1-b2) + (c1-c2)*(c1-c2); +} + + diff --git a/Expe-selection/dyna-expe2/expe/Global.h b/Expe-selection/dyna-expe2/expe/Global.h new file mode 100644 index 0000000..4ea4802 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/Global.h @@ -0,0 +1,25 @@ +#ifndef GLOBAL_H +#define GLOBAL_H + +#include +#include +#include + + +//------------------ +class Global{ + public: + static const QString& appPath(QApplication* app=0); + static QString imgSoftPath(){ return appPath()+"/images/soft/";} + static QApplication *app; + static float distCarre(float a1, float b1, float c1, float a2, float b2, float c2); + +}; + + + +#endif // GLOBAL_H + + + + diff --git a/Expe-selection/dyna-expe2/expe/csv/CSVWriter.cpp b/Expe-selection/dyna-expe2/expe/csv/CSVWriter.cpp new file mode 100644 index 0000000..d90f3ce --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/csv/CSVWriter.cpp @@ -0,0 +1,175 @@ +#include "CSVWriter.h" + +#include +#include + + +//----------------------- +CSVWriter::CSVWriter() +{ + m_File = NULL; + m_Sep = ","; +} + +//----------------------- +CSVWriter::~CSVWriter() +{ + if (m_File != NULL && m_File->isOpen()) + m_File->close(); + delete m_File; +} + +//----------------------- +bool CSVWriter::openFile(const QString & fileName) +{ + if(m_File!= NULL) + { + qDebug() << "WARNING: a file was already opened."; + closeFile(); + } + + m_File = new QFile(fileName); + + if (!m_File->open(QIODevice::WriteOnly)) + { + qDebug() << "WARNING: impossible to open the file " <isOpen()) + m_File->close(); + delete m_File; + m_File = NULL; + //m_Columns.clear(); + +} + +//----------------------- +void CSVWriter::clear() +{ + closeFile(); + m_Columns.clear(); + current.clear(); +} + +//----------------------- +void CSVWriter::setColumnNames(const QStringList& names) +{ + if(!m_Columns.empty()) + { + if(names != m_Columns) + { + qDebug()<<"column header is different in CSVWriter::setColumnNames"; + qDebug()<<"m_Columns :"<& map, bool w) +{ + bool res = true; + QMap::const_iterator i = map.constBegin(); + while (i != map.constEnd()) { + res = res && write(i.key(),i.value(),w); + ++i; + } + return res; +} + +//----------------------- +bool CSVWriter::write(const QString &name, const QString &value, bool w) +{ + if (m_Columns.empty() || m_File==NULL){ + qDebug()<< "WARNING : impossible to write in the file because m_Columns.empty() ("<m_Columns.size()) + { + qDebug()<< "WARNING list: impossible to write in the file because list.size != m_Columns.size() return false"; + return false; + } + + current = list; + + if(w) //write + write(); + + return true; +} + + +//----------------------- +void CSVWriter::setSeparator(const QString &sep) +{ + m_Sep = sep; +} + +//----------------------- +const QString& CSVWriter::separator() +{ + return m_Sep; +} + + diff --git a/Expe-selection/dyna-expe2/expe/csv/CSVWriter.h b/Expe-selection/dyna-expe2/expe/csv/CSVWriter.h new file mode 100644 index 0000000..538e14d --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/csv/CSVWriter.h @@ -0,0 +1,42 @@ +#ifndef CSVWRITER_H +#define CSVWRITER_H + +#include +#include + +class CSVWriter : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString Separator READ separator WRITE setSeparator DESIGNABLE true USER true) + Q_PROPERTY(QStringList ColumnNames READ columnNames DESIGNABLE true USER true) + +public: + CSVWriter(); + virtual ~CSVWriter(); + + const QStringList& columnNames(); + const QString& separator(); + +signals: + void lineWritten(QStringList); + +public slots: + bool openFile(const QString&); + void closeFile(); + bool write(); + bool write(const QString& name, const QString& value, bool w = false); + bool write(QStringList list, bool w = false); + bool write(const QMap &list, bool w = false); + void setColumnNames(const QStringList&); + void setSeparator(const QString&); + void clear(); + +protected: + QString m_Sep; + QFile* m_File; + QStringList m_Columns; + QStringList current; + +}; + +#endif diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/ExpeWidget.cpp b/Expe-selection/dyna-expe2/expe/expeWidget/ExpeWidget.cpp new file mode 100644 index 0000000..de23f10 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/ExpeWidget.cpp @@ -0,0 +1,82 @@ +#include + +#include "ExpeWidget.h" +#include + + +ExpeWidget::ExpeWidget(QWidget* _parent):QWidget(_parent) +{ + if(_parent) + { + resize(_parent->width(), _parent->height()); + } + + int defaultFontSize = 8; + m_Title.setParent(this); //message type, Fin trial, Fin block + QFont fontMessageType; + fontMessageType.setBold(true); + fontMessageType.setPointSize(3*defaultFontSize); + m_Title.setFont(fontMessageType); + m_Title.setAlignment(Qt::AlignHCenter); + + m_Message.setParent(this); //message blablabla + m_Message.setText("Prenez une petite pause"); + QFont fontMessage("Helvetica Nueue", 6*defaultFontSize, 15, false); + fontMessage.setBold(true); + m_Message.setAlignment(Qt::AlignHCenter); + m_Message.setFont(fontMessage); + + + button.setParent(this); //message du button + QFont fontButton; + fontButton.setBold(true); + fontButton.setPointSize(3*defaultFontSize); + button.setFont(fontButton); + button.setMaximumWidth(500); + + + m_MessageDetail.setParent(this); + QFont fontDetail; + fontDetail.setBold(true); + fontDetail.setPointSize(2*defaultFontSize); + m_MessageDetail.setFont(fontDetail); + + m_Left.setParent(this); + m_Left.setText(" "); + + QWidget * w = new QWidget(this); + QGridLayout* layout = new QGridLayout(this); + //layout->addWidget(&tryoutButton,0,0,1,1,Qt::AlignLeft); + layout->addWidget(&m_Title,1,1,1,1,Qt::AlignHCenter);//row, col + layout->addWidget(&m_Message,2,1,1,1, Qt::AlignHCenter); + layout->addWidget(w, 3,1,1,1,Qt::AlignHCenter); + layout->addWidget(&button,4,1,1,1,Qt::AlignHCenter); + layout->addWidget(&m_MessageDetail,5,2,1,1,Qt::AlignHCenter); + layout->addWidget(&m_Left,5,0,1,1,Qt::AlignHCenter); + + + layout->setColumnStretch(0,1); + layout->setColumnStretch(1,1); + layout->setColumnStretch(2,1); + + connect(&button,SIGNAL(clicked()), this, SLOT(buttonClicked())); + //connect(&tryoutButton,SIGNAL(clicked()), this, SLOT(tryoutSignalHandler())); +} + +//--------------------------- +void ExpeWidget::setTitle(const QString& _title) +{ + m_Title.setText(_title); +} + +//--------------------------- +void ExpeWidget::setMessage(const QString& _message) +{ + m_Message.setText(_message); +} + +//--------------------------- +void ExpeWidget::setDetail(const QString& _detail) +{ + m_MessageDetail.setText(_detail); +} diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/ExpeWidget.h b/Expe-selection/dyna-expe2/expe/expeWidget/ExpeWidget.h new file mode 100644 index 0000000..f10cfdc --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/ExpeWidget.h @@ -0,0 +1,28 @@ +#ifndef EXPEWIDGET_H +#define EXPEWIDGET_H + +#include +#include +#include + +class ExpeWidget : public QWidget +{ + Q_OBJECT +public: + ExpeWidget(QWidget *parent=0); + +public slots: + void setTitle(const QString& _title); + void setMessage(const QString& _message); + void setDetail(const QString& _detail); + +protected slots: + virtual void buttonClicked(){} + +protected: + QLabel m_Message, m_Title, m_MessageDetail, m_Left; + QPushButton button; //tryoutButton; + +}; + +#endif // EXPEWIDGET_H diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/InterBlock.cpp b/Expe-selection/dyna-expe2/expe/expeWidget/InterBlock.cpp new file mode 100644 index 0000000..f8751af --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/InterBlock.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include +//#include "TargetPie/targetpie.h" + + +#include "InterBlock.h" + +//--------------------------- +InterBlock::InterBlock(QWidget* parent):ExpeWidget(parent) +{ + int defaultFontSize = 8; + QFont fontButton; + fontButton.setBold(true); + fontButton.setPointSize(3*defaultFontSize); + setTitle(""); + setMessage("Take a break"); + setDetail("details"); + button.setFont(fontButton); + button.setText("start"); +} + +void InterBlock::actionOnPropertiesAssigned() +{ + //qDebug()<<"InterBlock action on properties assigned"; + //emit this->interBlockDone(); +} + + +//--------------------------- +InterBlock::~InterBlock(){} + + + diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/InterBlock.h b/Expe-selection/dyna-expe2/expe/expeWidget/InterBlock.h new file mode 100644 index 0000000..d574c07 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/InterBlock.h @@ -0,0 +1,31 @@ +#ifndef __INTER_BLOCK__ +#define __INTER_BLOCK__ + +#include +#include +#include +#include + +#include "ExpeWidget.h" + + +//=============== +class InterBlock : public ExpeWidget{ + + Q_OBJECT +public: + InterBlock(QWidget* parent = 0); + virtual ~InterBlock(); + +protected slots: + virtual void buttonClicked(){ emit interBlockDone(); } + virtual void actionOnPropertiesAssigned(); + + +signals: + void interBlockDone(); + +}; + +#endif + diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/InterBlockRollExpe.cpp b/Expe-selection/dyna-expe2/expe/expeWidget/InterBlockRollExpe.cpp new file mode 100644 index 0000000..f381aa5 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/InterBlockRollExpe.cpp @@ -0,0 +1,94 @@ +#include "InterBlockRollExpe.h" +#include +#include +#include + + + +static const float PI = 3.14159265; +static int nbRange = 0; + + +void InterBlockRollExpe::actionOnPropertiesAssigned() +{ + static int nbInterBlock = 0; + if(nbInterBlock != 0 && nbInterBlock != 5 && nbInterBlock != 10 && nbInterBlock != 15 ) + { + qDebug()<<"InterBlock is bypassed"; + emit this->interBlockDone(); + }else{ + + } + nbInterBlock++; +} + + +InterBlockRollExpe::InterBlockRollExpe(QWidget *parent, QWiimote *wm, Controler *c): + InterBlock(parent), state(0), _angleMin(0.), _angleMax(0.), _angleNeutral(0.), + _angleNeutralFromLeft(0), _angleNeutralFromRight(0), wiimote(wm), controler(c) +{ + if (wiimote == 0){ + qDebug()<<"interblockRollExpe : new qWiimote"; + wiimote = new QWiimote(); + } + //rs->setMinimumSize(100, 100); + //rs->rs_setTarget(-1); + //layout()->addWidget(rs); + //m_Message.setText(trUtf8("Veuillez tenir la télécomande dans une position confortable\n et valider avec le bouton B")); + connect(wiimote,SIGNAL(button2Released()), this, SLOT(setInitialValue())); + //connect(wiimote,SIGNAL(buttonBReleased()), &button, SIGNAL(clicked())); + //connect(&wiimote->motionPlus, SIGNAL(gyroAngleChanged(float,float,float, unsigned long)), this, SLOT(updateRollValue(float, float, float))); + //qDebug() << "InterBlockCountID = " << ++InterBlockCount; + button.setVisible(false); +} + + + +void InterBlockRollExpe::setInitialValue() +{ + controler->setNeutralAngle(this->_angleNeutral); + emit button.click(); +} + +void InterBlockRollExpe::updateRollValue(float x, float y, float roll) +{ + this->_angleNeutral = roll; +} + +void InterBlockRollExpe::resetInitialValue() +{ + state = 0; + m_Message.setText(trUtf8("Veuillez incliner la télécommande\n dans le sens anti-horaire au maximum\n et valider avec le bouton A")); +} + +float InterBlockRollExpe::getAngleFromAcc(float xAcc, float zAcc) +{ + float angleTmp = 0.; + if (zAcc < 0) + angleTmp = (xAcc - 1) * PI/2 * -180/PI; + else + //angleTmp = xAcc<0?-PI:0; + angleTmp = ((xAcc - 1) * PI/2 +PI) * -180/PI + 360; + //qDebug() << __PRETTY_FUNCTION__ << " angleTemp = " << angleTmp; + return angleTmp; +} + +float InterBlockRollExpe::angleMax(){ + return _angleMax; +} + +float InterBlockRollExpe::angleMin(){ + return _angleMin; +} + +float InterBlockRollExpe::angleNeutral(){ + return _angleNeutral; +} + +float InterBlockRollExpe::angleNeutralFromLeft(){ + return this->angleNeutralFromLeft(); +} + +float InterBlockRollExpe::angleNeutralFromRight(){ + return this->angleNeutralFromRight(); +} diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/InterBlockRollExpe.h b/Expe-selection/dyna-expe2/expe/expeWidget/InterBlockRollExpe.h new file mode 100644 index 0000000..31ea97f --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/InterBlockRollExpe.h @@ -0,0 +1,37 @@ +#ifndef INTERBLOCKROLLEXPE_H +#define INTERBLOCKROLLEXPE_H + +#include "InterBlock.h" +#include "rollSelection/RollSelection.h" +#include "Controler.h" + +class InterBlockRollExpe : public InterBlock +{ + Q_OBJECT + +public: + InterBlockRollExpe(QWidget * parent = 0, QWiimote *wm = 0, Controler *c = 0); + float angleMin(); + float angleMax(); + float angleNeutral(); + float angleNeutralFromRight(); + float angleNeutralFromLeft(); + +public slots: + void setInitialValue(); + void resetInitialValue(); + float getAngleFromAcc(float xAcc, float zAcc); + void updateRollValue(float, float, float); + + +public: + virtual void actionOnPropertiesAssigned(); + + int state; + float _angleMin, _angleMax, _angleNeutral, _angleNeutralFromLeft, _angleNeutralFromRight; + Controler *controler; + QWiimote *wiimote; + +}; + +#endif // INTERBLOCKROLLEXPE_H diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/InterTrial.cpp b/Expe-selection/dyna-expe2/expe/expeWidget/InterTrial.cpp new file mode 100644 index 0000000..854ada1 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/InterTrial.cpp @@ -0,0 +1,123 @@ +#include +#include +#include +#include +#include +#include "Global.h" +#include +#include +#include +#include "InterTrial.h" + + +//--------------------------- +InterTrial::InterTrial(QWidget* parent):ExpeWidget(parent) +{ + this->m_answer_str = ""; + //this->setStyleSheet("background-color:black"); + this->m_answerCorrect = true; + m_Answer.setParent(this); + m_Answer.setStyleSheet("background-color : lightgrey"); + QLabel* answerTitle = new QLabel("Reponse pour : ", &m_Answer); + m_AnswerStimulus.setParent(this); + m_Answer.setMinimumWidth(250); + m_Answer.setMaximumWidth(250); + m_Answer.setMaximumHeight(70); + m_AnswerIcon.setParent(&m_Answer); + m_AnswerIcon.setMinimumWidth(50); + m_AnswerIcon.setMaximumHeight(50); + m_AnswerText.setParent(&m_Answer); + QFont fontAnswer; + fontAnswer.setBold(false); + fontAnswer.setPointSize(16); + m_AnswerText.setFont(fontAnswer); + + fontAnswer.setPointSize(18); fontAnswer.setBold(true); + answerTitle->setFont(fontAnswer); + m_AnswerStimulus.setFont(fontAnswer); + QGridLayout* layoutAnswer = new QGridLayout(&m_Answer); + layoutAnswer->addWidget(&m_AnswerStimulus,0,1,1,1,Qt::AlignLeft);//row, col + layoutAnswer->addWidget(answerTitle,0,0,1,1,Qt::AlignLeft);//row, col + layoutAnswer->addWidget(&m_AnswerIcon,1,0,1,1,Qt::AlignLeft);//row, col + layoutAnswer->addWidget(&m_AnswerText,1,1,1,1,Qt::AlignLeft);//row, col + setAnswer(true, "answer", "Answer"); + + + button.setVisible(true); + setTitle(""); + setMessage(""); + button.setText("Appuyez sur la barre d'espace \n avec les deux mains \n pour commencer "); + button.resize(500,100); + m_Answer.setVisible(true); + + setVisible(false); + this->m_Answer.setVisible(false); + this->m_Message.setVisible(false); + this->m_MessageDetail.setVisible(false); + //connect(&button,SIGNAL(clicked()),this,SLOT(buttonClicked())); + + this->progressBar = new QProgressBar(this); + this->progressBar->move(0,0); + this->progressBar->resize(width(), 30); + this->progressBar->setMaximum(50); + this->progressBar->setValue(0); + this->progressBar->setStyle(new QWindowsStyle()); +} + +void InterTrial::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.fillRect(0, 0, width(), height(), Qt::black); + + if(this->m_answerCorrect) + { + painter.setBrush(Qt::green); + }else + { + painter.setBrush(Qt::red); + } + painter.setBrush(Qt::black); + painter.drawRect(width()/2 - height()/4, height()/4, height()/2, height()/2); + painter.drawText(width()/2 - height()/4, height()/4, this->m_answer_str); + +} + +void InterTrial::setTimer(int delay) +{ + if(delay>0) + { + timer.setInterval(delay); + timer.setSingleShot(true); + connect(&timer, SIGNAL(timeout()), this, SIGNAL(interTrialDone())); + this->button.setVisible(false); + } +} + +//--------------------------- +InterTrial::~InterTrial(){} + + +//--------------------------- +void InterTrial::setAnswer(bool b, QString sti, QString ans_) +{ + this->m_answerCorrect = b; + if(b) + { + m_AnswerIcon.setStyleSheet("background-color: rgb(10,190,10)"); + } + else + { + m_AnswerIcon.setStyleSheet("background-color: rgb(255,30,30)"); + } + m_AnswerText.setText(ans_); + m_AnswerStimulus.setText(sti); +} + +//-------------------------- +void InterTrial::keyReleaseEvent(QKeyEvent* ke) +{ + //qDebug()<<"key release event in InterTrial" << ke->key(); + if(ke->key() == Qt::Key_Space){ + emit interTrialDone(); + } +} diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/InterTrial.h b/Expe-selection/dyna-expe2/expe/expeWidget/InterTrial.h new file mode 100644 index 0000000..c7894c6 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/InterTrial.h @@ -0,0 +1,50 @@ +#ifndef __INTER_TRIAL__ +#define __INTER_TRIAL__ + +#include +#include +#include +#include +#include +#include "ExpeWidget.h" +#include +//=============== +class InterTrial : public ExpeWidget{ + Q_OBJECT + +public: + + InterTrial(QWidget* parent=0); + virtual ~InterTrial(); + void setTimer(int delay); + +public slots: + void setAnswer(bool b, QString stimulus, QString answer); + void setAnswerVisible(bool b){m_Answer.setVisible(b);} + void setInterTrialDone(){ emit interTrialDone(); } + void setValue(int idTrial){ this->progressBar->setValue(idTrial);} + + virtual void actionOnEntry(){ if(timer.interval() >0) timer.start();} + virtual void paintEvent(QPaintEvent *); + virtual void keyReleaseEvent(QKeyEvent *ke); + +signals: + void interTrialDone(); + +protected slots : + virtual void buttonClicked(){ emit interTrialDone(); } + + +public: + QLabel m_AnswerIcon, m_AnswerText, m_AnswerStimulus; + bool m_answerCorrect; + QWidget m_Answer; + QTimer timer; + QProgressBar *progressBar; + int num_stimulus; + int num_answer; + QString m_answer_str; +}; + +#endif + diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/RollSelectionTrialSheet.cpp b/Expe-selection/dyna-expe2/expe/expeWidget/RollSelectionTrialSheet.cpp new file mode 100644 index 0000000..e409f86 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/RollSelectionTrialSheet.cpp @@ -0,0 +1,20 @@ +#include "RollSelectionTrialSheet.h" +#include + +RollSelectionTrialSheet::RollSelectionTrialSheet(QWidget *_parent): TrialSheet(_parent) +{ + this->rollSelection = new RollSelection(this); + this->showMaximized(); + button->setVisible(false); +} + +RollSelection* RollSelectionTrialSheet::getRollSelection() +{ + return rollSelection; +} + +void RollSelectionTrialSheet::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + rollSelection->drawGraphics(painter, width(), height()); +} diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/RollSelectionTrialSheet.h b/Expe-selection/dyna-expe2/expe/expeWidget/RollSelectionTrialSheet.h new file mode 100644 index 0000000..1030cbc --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/RollSelectionTrialSheet.h @@ -0,0 +1,19 @@ +#ifndef ROLLSELECTIONTRIALSHEET_H +#define ROLLSELECTIONTRIALSHEET_H + +#include "TrialSheet.h" +#include "rollSelection/RollSelection.h" + +class RollSelectionTrialSheet : public TrialSheet +{ +public: + RollSelectionTrialSheet(QWidget *_parent = 0); + RollSelection* getRollSelection(); + +protected: + virtual void paintEvent(QPaintEvent *); + RollSelection* rollSelection; + +}; + +#endif // ROLLSELECTIONTRIALSHEET_H diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/TrialSheet.cpp b/Expe-selection/dyna-expe2/expe/expeWidget/TrialSheet.cpp new file mode 100644 index 0000000..fafd7a7 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/TrialSheet.cpp @@ -0,0 +1,35 @@ +#include "TrialSheet.h" +#include + +//----------------------- +TrialSheet::TrialSheet(QWidget *_parent):QWidget(_parent) +{ + if(_parent) + { + resize(_parent->width(), _parent->height()); + } +/* + QVBoxLayout *layout = new QVBoxLayout(this); + //this->setStyleSheet("background-color:white"); + + label = new QLabel(this); + label->setText("empty"); + layout->addWidget(label); + button = new QPushButton(this); + button->setText("click to finish the trial"); + button->setObjectName("button"); + layout->addWidget(button); + connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked())); + + */ + setVisible(false); +} + + +void TrialSheet::setLabelButton(QString label) +{ + button->setText(label); +} + +//----------------------- +TrialSheet::~TrialSheet(){} diff --git a/Expe-selection/dyna-expe2/expe/expeWidget/TrialSheet.h b/Expe-selection/dyna-expe2/expe/expeWidget/TrialSheet.h new file mode 100644 index 0000000..0883f7b --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/expeWidget/TrialSheet.h @@ -0,0 +1,31 @@ +#ifndef TRIALSHEET_H +#define TRIALSHEET_H + +#include +#include +#include +#include + +class TrialSheet : public QWidget{ + Q_OBJECT + +public: + TrialSheet(QWidget *_parent=0); + virtual void setLabelButton(QString label); + virtual ~TrialSheet(); + QLabel *label; + virtual void keyReleaseEvent(QKeyEvent *){} + +public slots: + void buttonClicked(){emit endTrial();} + void setEndTrial(){emit endTrial();} + +signals: + void endTrial(); + +protected: + QPushButton *button; + +}; + +#endif // TRIALSHEET_H diff --git a/Expe-selection/dyna-expe2/expe/xml/DataExport.cpp b/Expe-selection/dyna-expe2/expe/xml/DataExport.cpp new file mode 100644 index 0000000..8407a47 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/xml/DataExport.cpp @@ -0,0 +1,103 @@ +/* + * DataExport.cpp + * MTM + * + * Created by gilles bailly on 03/05/09. + * Copyright 2009 enst. All rights reserved. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "DataExport.h" + +DataExport::DataExport(const QString& _path):m_Path(_path){} + +DataExport::~DataExport(){} + +void DataExport::exec(const QObject *item ) +{ + if(item==0){ + qDebug() << "Warning : "; + qDebug() << "void DataExport::exec(const QObject *item );"; + qDebug() << "item ==0"; + return; + } + + QFile file(path()); + if( !file.open(QIODevice::WriteOnly | QIODevice::Text ) ) + { + qDebug() << QString("DataExport::save -> impossible to write in %1").arg(path()); + return; + } + + QTextStream out (&file); + out << objectToXML(item, 0) << "\n"; + +} + + +QString DataExport::objectToXML(const QObject * item, int indentLevel) +{ + QString result; + QString indentSpace; + + indentSpace.fill(' ', indentLevel*6); + const QMetaObject *meta = item->metaObject(); + result += QString("\n%1"). + arg(indentSpace). + arg(meta->className()). + arg(item->objectName()); + + result += writeData(item, indentLevel); + qDebug()<<"appel de children();"; + QVector _children = children( item ); + for(int i=0; i< _children.size();i++) + { + result += objectToXML(_children[i], indentLevel+1); + } + + result += QString("\n%1").arg(indentSpace); + + + return result /*.join("\n")*/; +} + + +QString DataExport::writeData( const QObject* obj, int indentLevel) +{ + const QMetaObject* meta = obj->metaObject(); + QString result; + QString indentSpace; + indentSpace.fill(' ', indentLevel*6); + + for(int i=0; i< meta->propertyCount(); ++i) + { + QMetaProperty qmp = meta->property(i); + const char* propName = qmp.name(); + if( strcmp(propName, "objectName")==0) + continue; + QVariant qv; + if(qmp.isEnumType()) + { + QMetaEnum qme = qmp.enumerator(); + qv = qme.valueToKey(qv.toInt()); + }else + { + qv = obj->property(propName); + } + + result += QString("\n%1 ") + .arg(indentSpace) + .arg(propName) + .arg(qv.typeName()) + .arg(qv.toString()); + } + + return result; +} diff --git a/Expe-selection/dyna-expe2/expe/xml/DataExport.h b/Expe-selection/dyna-expe2/expe/xml/DataExport.h new file mode 100644 index 0000000..2c6e346 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/xml/DataExport.h @@ -0,0 +1,37 @@ +/* + * PropertiesExport.h + * MTM + * + * Created by gilles bailly on 03/05/09. + * Copyright 2009 enst. All rights reserved. + * + */ +#ifndef __DATA_EXPORT__ +#define __DATA_EXPORT__ + +#include + +class DataExport { +public: + DataExport(const QString& path= "defaultProperties.xml"); + virtual ~DataExport(); + + virtual void exec( const QObject* ); + virtual QString objectToXML(const QObject *item, int indentLevel=0); + + virtual void setPath( const QString& path){m_Path = path;} + virtual const QString& path()const{return m_Path;} + + virtual QVector children(const QObject*){ return QVector(); } + //to implement for hierarchical cases, by default return an empty vector + + +protected: + + QString writeData( const QObject*, int indentLevel); + QString m_Path; + +}; + +#endif + diff --git a/Expe-selection/dyna-expe2/expe/xml/DataFactory.cpp b/Expe-selection/dyna-expe2/expe/xml/DataFactory.cpp new file mode 100644 index 0000000..be7d79c --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/xml/DataFactory.cpp @@ -0,0 +1,50 @@ +/* + * DataImport.cpp + * MTM + * + * Created by gilles bailly on 26/05/09. + * Copyright 2009 enst. All rights reserved. + * + */ + +#include +#include + +#include "DataFactory.h" + +DataFactory* DataFactory::m_DataFactory = 0; +DataFactory::DataFactory(){} +DataFactory::~DataFactory(){} + +DataFactory* DataFactory::instance() +{ + if (!m_DataFactory) + { + DataFactory tmp; + m_DataFactory = tmp.createFactory(); + } + + return m_DataFactory; +} + +DataFactory* DataFactory::createFactory() +{ + return new DataFactory(); +} + +QObject* DataFactory::newObject(const QString& ) +{ + qDebug()<< "QObject* DataFactory::newObject(const QString& )"; + return new QObject(); +} + +void DataFactory::setObjectParent(QObject* parent, QObject* child) +{ + qDebug() << "void DataFactory::setObjectParent(QObject* parent, QObject* child)"; + child->setParent( parent); +} + +void DataFactory::setMProperty(QObject*, QString, QString, QString) +{ + +} diff --git a/Expe-selection/dyna-expe2/expe/xml/DataFactory.h b/Expe-selection/dyna-expe2/expe/xml/DataFactory.h new file mode 100644 index 0000000..fb75d32 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/xml/DataFactory.h @@ -0,0 +1,36 @@ +/* + * PropertiesImport.h + * MTM + * + * Created by gilles bailly on 26/05/09. + * Copyright 2009 enst. All rights reserved. + * + */ + +#ifndef __DATA_FACTORY_H__ +#define __DATA_FACTORY_H__ + +#include +#include +#include +#include + +class DataFactory +{ + public: + static DataFactory* instance(); + + virtual ~DataFactory(); + virtual QObject* newObject(const QString& className); + virtual void setObjectParent(QObject* parent, QObject* child); + virtual void setMProperty(QObject*, QString, QString, QString); + + protected: + static DataFactory* m_DataFactory; + virtual DataFactory* createFactory(); + DataFactory(); + +}; + +#endif + diff --git a/Expe-selection/dyna-expe2/expe/xml/DataImport.cpp b/Expe-selection/dyna-expe2/expe/xml/DataImport.cpp new file mode 100644 index 0000000..e98b621 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/xml/DataImport.cpp @@ -0,0 +1,362 @@ +/* + * DataImport.cpp + * MTM + * + * Created by gilles bailly on 26/05/09. + * Copyright 2009 enst. All rights reserved. + * + */ + +#include +#include + +#include "DataImport.h" +#include "../ExpeLoader.h" +#include + + +DataImport::DataImport(DataFactory *factory): m_Current(0), m_Factory(factory) { this->readCharacters=false;} + +DataImport::DataImport(const QString& filename, DataFactory* factory):m_Current(0), m_Factory(factory) +{ + this->readCharacters=false; + parseFile(filename); +} + + +DataImport::~DataImport(){} + + +void DataImport::parseFile(const QString& filename) +{ + m_Current =0; + + QFile file(filename); + if( !file.open(QIODevice::ReadOnly | QIODevice::Text ) ) + { + qDebug() << QString("DataImport::parseFile -> impossible to read in %1").arg(filename); + return; + } + qDebug()<<"parse file"; + QXmlInputSource source(&file); + QXmlSimpleReader reader; + reader.setContentHandler(this); + reader.parse(source); + clear(); + +} + +QObject* DataImport::getRoot(){ return m_Current;} + + +void DataImport::clear() +{ + m_ObjectList.clear(); + m_ParentStack.clear(); + indent =""; +} + + +bool DataImport::startElement( const QString &, //namespaceURI, + const QString & elementName, + const QString &,// qualifiedName, + const QXmlAttributes &atts) { + + static bool goodUser=false; + static int blockId =1; + static QString blockValues =""; + +// + if(elementName == "experiment") + { + if(m_Current != 0 ){ + m_ParentStack.push(m_Current); + } + m_Current = m_Factory->newObject(elementName); + + if(!m_ParentStack.empty()) + m_Factory->setObjectParent(m_ParentStack.top(), m_Current); + + ExpeLoader* loader = dynamic_cast(m_Current); + for(int i=0;iproperty[atts.qName(i)] = atts.value(i); + } + } + + if(elementName=="factor") + { + if(m_Current != 0 ){ + m_ParentStack.push(m_Current); + } + m_Current = m_Factory->newObject(elementName); + + if(!m_ParentStack.empty()) + m_Factory->setObjectParent(m_ParentStack.top(), m_Current); + + ExpeFactor* factor = dynamic_cast(m_Current); + for(int i=0;iproperty[atts.qName(i)] = atts.value(i); + } + } + + if(!elementName.compare("value")) + { + ExpeFactor* factor = dynamic_cast(m_Current); + for(int i=0;ivalue.push_back(atts.value(i)); + //qDebug()<<"att: "<(m_Current); + if(loader){ + if(!loader->user.compare(atts.value(atts.index("id")))) + { + goodUser = true; + loader->updateCurTrial("user", atts.value(atts.index("id"))); + loader->updateCurTrial("block", QString::number(-1)); + }else{ + goodUser = false; + } + + } + } + + if(!elementName.compare("practice")) + { + if(goodUser) + { + ExpeLoader* loader = dynamic_cast(m_Current); + if(loader){ + loader->updateCurTrial("expe_type","practice"); + + if(atts.index("values") == -1) return true; + QStringList nameValue = atts.value(atts.index("values")).split(","); + for(int i=0; i< nameValue.size();i++) + { + loader->updateCurTrial(nameValue[i]); + } + + } + } + } + + if(!elementName.compare("trial")) + { + if(goodUser) + { + ExpeLoader* loader = dynamic_cast(m_Current); + if(loader){ + if(atts.index("values") == -1) return true; + QStringList nameValue = atts.value(atts.index("values")).split(","); + for(int i=0; i< nameValue.size();i++) + { + loader->updateCurTrial(nameValue[i]); + } + loader->updateTrial(); + } + } + } + + if(!elementName.compare("block")) + { + if(goodUser) + { + ExpeLoader* loader = dynamic_cast(m_Current); + if(loader){ + loader->updateCurTrial("expe_type","expe"); + if(atts.index("values") == -1) return true; + QString values = atts.value(atts.index("values")); + if(!blockValues.compare(values)) + { + blockId+=1; + }else{ + blockValues = values; + blockId = 1; + } + + loader->updateCurTrial("block", QString::number(blockId)); + + QStringList nameValue = values.split(","); + for(int i=0; i< nameValue.size();i++) + { + loader->updateCurTrial(nameValue[i]); + } + + } + } + } + + +// }else if(!elementName.compare("experiment") ) +// { +// if(m_Current != 0 ){ +// m_ParentStack.push(m_Current); +// } +// m_Current = m_Factory->newObject("hits"); +// +// } + +// +// else if (!elementName.compare("Hit")) +// { +// if(m_Current != 0 ){ +// m_ParentStack.push(m_Current); +// } +// m_Current = m_Factory->newObject("Hit"); +// if(!m_ParentStack.empty()) +// m_Factory->setObjectParent(m_ParentStack.top(), m_Current); +// +// } +// else if (!elementName.compare("MetaString")) +// { +// readCharacters=true; +// //qDebug()<< "uri: "<metaStringType = atts.value(0); +// } +// else +// { +// qDebug()<< "MetaString atts.count() = "<newObject(className); +// if(!m_ParentStack.empty()) +// DataFactory::instance()->setObjectParent(m_ParentStack.top(), m_Current); +// } else +// { +// m_Current = m_Factory->newObject(className); +// if(!m_ParentStack.empty()) +// m_Factory->setObjectParent(m_ParentStack.top(), m_Current); +// } +// m_Current->setObjectName(instanceName); +// +// +// return true; +// } + + if(elementName == "property" ) + { + qDebug()<< "property"; + QString fieldType = atts.value("type"); + QString fieldName = atts.value("name"); + QString fieldValue = atts.value("value"); + qDebug()<setProperty(fieldName.toAscii(), qv); + if(!ok) + { + qDebug() << "setProperty(" <productionDate +//2008 +bool DataImport::characters ( const QString & ch ) +{ + if(!ch.compare("\n")) + return true; + + if( !metaStringType.compare("name")) + { + metaString["name"] = ch; + } + else if( !metaStringType.compare("value")) + { + + //if(!metaString["name"].compare("keywords") || + // !metaString["name"].compare("actors") || + // !metaString["name"].compare("thumbnail")) + //{ + metaString["value"] = ch; + m_Factory->setMProperty(m_Current, "MetaString", metaString["name"], metaString["value"]); + //} + metaString.clear(); + metaStringType.clear(); + }else if (metaStringType.compare("")) + { + m_Factory->setMProperty(m_Current, "MetaString", metaStringType, ch); + } + + return true; +} + +bool DataImport::endElement(const QString &,// namespaceURI, + const QString & elementName, + const QString &)// qualifiedName) +{ + + if(elementName == "experiment" || elementName == "factor") + { + if(!m_ParentStack.empty()) + { + m_Current = m_ParentStack.pop(); + }else + { + //addCurrentToQueue(); + qDebug()<<"addCurrentToQueue()->"<< elementName; + } + } + + return true; +} + +bool DataImport::endDocument() +{ + return true; +} + +QVariant DataImport::variantFrom(const QString &fieldType, const QString &value) +{ + int id = QMetaType::type(fieldType.toAscii()); + if (id == -1) + { + qDebug() << "variantFrom("<< fieldType << " " << value << ");" ; + return QVariant(); + } + + QVariant qv(id); + qv.setValue(value); + return qv; +} + + + + + + + + + + + diff --git a/Expe-selection/dyna-expe2/expe/xml/DataImport.h b/Expe-selection/dyna-expe2/expe/xml/DataImport.h new file mode 100644 index 0000000..d10c1b3 --- /dev/null +++ b/Expe-selection/dyna-expe2/expe/xml/DataImport.h @@ -0,0 +1,66 @@ +/* + * PropertiesImport.h + * MTM + * + * Created by gilles bailly on 26/05/09. + * Copyright 2009 enst. All rights reserved. + * + */ + +#ifndef __DATA_IMPORT_H__ +#define __DATA_IMPORT_H__ + +#include +#include +#include +#include +#include + +#include "DataFactory.h" + +//----------------------------------------- +//----------------------------------------- +class DataImport : public QXmlDefaultHandler +{ + public: + DataImport(DataFactory *factory=0); + DataImport(const QString& filename, DataFactory* factory=0); + virtual ~DataImport(); + + //void parse(QString text); + void parseFile(const QString& filename); + QObject* getRoot(); + + //callback methods from QXmlDefaultHandler + bool startElement( const QString &namespaceURI, + const QString &elementName, + const QString &qualifiedName, + const QXmlAttributes &attributes ); + + bool characters ( const QString & ch ); + + bool endElement( const QString &namespaceURI, + const QString &localName, + const QString &qualifiedName ); + + bool endDocument(); + + void clear(); //do not clear the factory + + protected: + QObject *m_Current; + + private: + void addCurrentToQueue(); + QVariant variantFrom(const QString& type, const QString& value); + DataFactory *m_Factory; + QQueue m_ObjectList; + QStack m_ParentStack; + QString indent; + bool readCharacters; + QMap metaString; + QString metaStringType; +}; + +#endif + diff --git a/Expe-selection/dyna-expe2/ihm.cpp b/Expe-selection/dyna-expe2/ihm.cpp new file mode 100644 index 0000000..6a869d5 --- /dev/null +++ b/Expe-selection/dyna-expe2/ihm.cpp @@ -0,0 +1,92 @@ +#include "ihm.h" +#include "ui_ihm.h" +#include +#include + +ihm* ihm::ihmWizard = 0; + +ihm::ihm(QWidget *parent) : + QWidget(parent), + ui(new Ui::ihm) +{ + ui->setupUi(this); + wizard = false; + setFocusPolicy(Qt::StrongFocus); + this->ui->Title->setText("S:FullScreen-B:block-SpaceBar:trial"); +} + +ihm::~ihm() +{ + delete ui; +} + +//----------------- +void ihm::setLeftDigit(const QString& left) +{ + this->ui->left->setText(left); +} + +//----------------- +void ihm::setRightDigit(const QString& right) +{ + this->ui->right->setText(right); +} + +void ihm::setInterBlock() +{ + this->ui->left->setVisible(false); + this->ui->right->setVisible(false); +} + +//----------------- +void ihm::setWizard(bool b) +{ + wizard = b; + ui->Title->setVisible(b); + if(b) + { + ihmWizard = this; + } +} + +//---------------- +void ihm::setDisplaySize(int w, int h) +{ + resize(w,h); + ui->Title->resize(w, 100); + ui->Title->move(0,0); + ui->left->resize(w/2, h-100); + ui->left->move(0,100); + ui->right->resize(w/2, h-100); + ui->right->move(w/2,100); +} + +void ihm::keyPressEvent(QKeyEvent *e) +{ + if(!wizard) + return; + + switch(e->key()) + { + case Qt::Key_Space: + emit endTrial(); + break; + + case Qt::Key_B: + qDebug()<<"button b pressed"; + ui->left->setVisible(true); + ui->right->setVisible(true); + emit startBlock(); + break; + case Qt::Key_S: + emit startExpe(); + default: + break; + } + +} + + +//iterer et realiser +//vs. +//preconiser et diff --git a/Expe-selection/dyna-expe2/ihm.h b/Expe-selection/dyna-expe2/ihm.h new file mode 100644 index 0000000..b19ce54 --- /dev/null +++ b/Expe-selection/dyna-expe2/ihm.h @@ -0,0 +1,40 @@ +#ifndef IHM_H +#define IHM_H + +#include + +namespace Ui { + class ihm; +} + +class ihm : public QWidget +{ + Q_OBJECT + +public: + static ihm* ihmWizard; + + explicit ihm(QWidget *parent = 0); + ~ihm(); + +signals: + void endTrial(); + void startBlock(); + void startExpe(); + +public slots: + void setLeftDigit(const QString& left); + void setRightDigit(const QString& right); + void setWizard(bool b); + void setDisplaySize(int w, int h); + void setInterBlock(); + +protected: + virtual void keyPressEvent(QKeyEvent *); + +private: + Ui::ihm *ui; + bool wizard; +}; + +#endif // IHM_H diff --git a/Expe-selection/dyna-expe2/ihm.ui b/Expe-selection/dyna-expe2/ihm.ui new file mode 100644 index 0000000..c6bbf40 --- /dev/null +++ b/Expe-selection/dyna-expe2/ihm.ui @@ -0,0 +1,107 @@ + + + ihm + + + + 0 + 0 + 640 + 480 + + + + Form + + + + + 20 + 110 + 198 + 354 + + + + + 300 + 75 + true + + + + 5 + + + Qt::AlignCenter + + + + + + 0 + 10 + 631 + 29 + + + + + 16777215 + 300 + + + + + 24 + 75 + true + + + + Wizard + + + Qt::AlignCenter + + + + + + 440 + 120 + 198 + 354 + + + + + 300 + 75 + true + + + + 6 + + + Qt::AlignCenter + + + + + + 2 + 635 + 1199 + 264 + + + + + + + + + + diff --git a/Expe-selection/dyna-expe2/img/background.jpg b/Expe-selection/dyna-expe2/img/background.jpg new file mode 100644 index 0000000..9853c5f Binary files /dev/null and b/Expe-selection/dyna-expe2/img/background.jpg differ diff --git a/Expe-selection/dyna-expe2/img/k_1.png b/Expe-selection/dyna-expe2/img/k_1.png new file mode 100644 index 0000000..2786bf7 Binary files /dev/null and b/Expe-selection/dyna-expe2/img/k_1.png differ diff --git a/Expe-selection/dyna-expe2/img/k_2.png b/Expe-selection/dyna-expe2/img/k_2.png new file mode 100644 index 0000000..8b3b308 Binary files /dev/null and b/Expe-selection/dyna-expe2/img/k_2.png differ diff --git a/Expe-selection/dyna-expe2/img/k_3.png b/Expe-selection/dyna-expe2/img/k_3.png new file mode 100644 index 0000000..206f454 Binary files /dev/null and b/Expe-selection/dyna-expe2/img/k_3.png differ diff --git a/Expe-selection/dyna-expe2/img/k_4.png b/Expe-selection/dyna-expe2/img/k_4.png new file mode 100644 index 0000000..f576792 Binary files /dev/null and b/Expe-selection/dyna-expe2/img/k_4.png differ diff --git a/Expe-selection/dyna-expe2/img/k_5.png b/Expe-selection/dyna-expe2/img/k_5.png new file mode 100644 index 0000000..a02661f Binary files /dev/null and b/Expe-selection/dyna-expe2/img/k_5.png differ diff --git a/Expe-selection/dyna-expe2/img/m_1.png b/Expe-selection/dyna-expe2/img/m_1.png new file mode 100644 index 0000000..a69ef37 Binary files /dev/null and b/Expe-selection/dyna-expe2/img/m_1.png differ diff --git a/Expe-selection/dyna-expe2/img/m_2.png b/Expe-selection/dyna-expe2/img/m_2.png new file mode 100644 index 0000000..4c4b457 Binary files /dev/null and b/Expe-selection/dyna-expe2/img/m_2.png differ diff --git a/Expe-selection/dyna-expe2/img/m_3.png b/Expe-selection/dyna-expe2/img/m_3.png new file mode 100644 index 0000000..5f8b1d7 Binary files /dev/null and b/Expe-selection/dyna-expe2/img/m_3.png differ diff --git a/Expe-selection/dyna-expe2/img/m_4.png b/Expe-selection/dyna-expe2/img/m_4.png new file mode 100644 index 0000000..983d4db Binary files /dev/null and b/Expe-selection/dyna-expe2/img/m_4.png differ diff --git a/Expe-selection/dyna-expe2/img/m_5.png b/Expe-selection/dyna-expe2/img/m_5.png new file mode 100644 index 0000000..05625b3 Binary files /dev/null and b/Expe-selection/dyna-expe2/img/m_5.png differ diff --git a/Expe-selection/dyna-expe2/main.cpp b/Expe-selection/dyna-expe2/main.cpp new file mode 100644 index 0000000..af650a2 --- /dev/null +++ b/Expe-selection/dyna-expe2/main.cpp @@ -0,0 +1,42 @@ +/** + * @file main.cpp + * Main source file. + */ + +#include +#include "Global.h" +#include "Controler.h" +#include "MainWindow.h" +//#include "ihm.h" +#include +#include +void unitTest() +{ + qDebug()<<"run keyboard experiment"; + //QFile file(":/resources/error.wav"); + //qDebug()<<"file : " << file.open(QIODevice::ReadOnly); + + + //qDebug()<<"sound is available: "<show(); + + Controler controler(mainWindow); + + return a.exec(); +} + diff --git a/Expe-selection/dyna-expe2/resources.qrc b/Expe-selection/dyna-expe2/resources.qrc new file mode 100644 index 0000000..7c94e3c --- /dev/null +++ b/Expe-selection/dyna-expe2/resources.qrc @@ -0,0 +1,12 @@ + + + resources/error.wav + resources/success.wav + resources/back.png + resources/front.png + resources/left.png + resources/right.png + resources/keyboard.jpg + resources/keyboard.gif + + diff --git a/Expe-selection/dyna-expe2/resources/back.png b/Expe-selection/dyna-expe2/resources/back.png new file mode 100644 index 0000000..f592f7e Binary files /dev/null and b/Expe-selection/dyna-expe2/resources/back.png differ diff --git a/Expe-selection/dyna-expe2/resources/error.wav b/Expe-selection/dyna-expe2/resources/error.wav new file mode 100644 index 0000000..9227a3f Binary files /dev/null and b/Expe-selection/dyna-expe2/resources/error.wav differ diff --git a/Expe-selection/dyna-expe2/resources/front.png b/Expe-selection/dyna-expe2/resources/front.png new file mode 100644 index 0000000..dc052e6 Binary files /dev/null and b/Expe-selection/dyna-expe2/resources/front.png differ diff --git a/Expe-selection/dyna-expe2/resources/keyboard.jpg b/Expe-selection/dyna-expe2/resources/keyboard.jpg new file mode 100644 index 0000000..2f203d2 Binary files /dev/null and b/Expe-selection/dyna-expe2/resources/keyboard.jpg differ diff --git a/Expe-selection/dyna-expe2/resources/keyboard.png b/Expe-selection/dyna-expe2/resources/keyboard.png new file mode 100644 index 0000000..eddbb04 Binary files /dev/null and b/Expe-selection/dyna-expe2/resources/keyboard.png differ diff --git a/Expe-selection/dyna-expe2/resources/left.png b/Expe-selection/dyna-expe2/resources/left.png new file mode 100644 index 0000000..1c3b3b6 Binary files /dev/null and b/Expe-selection/dyna-expe2/resources/left.png differ diff --git a/Expe-selection/dyna-expe2/resources/right.png b/Expe-selection/dyna-expe2/resources/right.png new file mode 100644 index 0000000..b79e1a9 Binary files /dev/null and b/Expe-selection/dyna-expe2/resources/right.png differ diff --git a/Expe-selection/dyna-expe2/resources/success.wav b/Expe-selection/dyna-expe2/resources/success.wav new file mode 100644 index 0000000..24a13d4 Binary files /dev/null and b/Expe-selection/dyna-expe2/resources/success.wav differ diff --git a/Expe-selection/dyna-expe2/resources/success2.wav b/Expe-selection/dyna-expe2/resources/success2.wav new file mode 100644 index 0000000..d1b259e Binary files /dev/null and b/Expe-selection/dyna-expe2/resources/success2.wav differ