Commit 0679df43 authored by Adrien Dorsaz's avatar Adrien Dorsaz

Update UI to have record button and a tool topbar.

parent 57e5c8a5
......@@ -16,6 +16,13 @@ Emotions::Emotions()
_trainedArousalClasses = new QMap<QString, QMap<double, double>*>();
_trainedValenceClasses = new QMap<QString, QMap<double, double>*>();
_guess=false;
_record=false;
_saveCalm=false;
_saveJoy=false;
_saveSad=false;
_saveFear=false;
getClassifiers();
}
......@@ -23,8 +30,10 @@ void Emotions::arousalValence(double arousal, double valence){
arousal=int(arousal)%10;
valence=int(valence)%10;
insertValueAndTotal(_arousalSet, _totalArousalOccurrences, arousal);
insertValueAndTotal(_valenceSet, _totalValenceOccurrences, valence);
if(_record){
insertValueAndTotal(_arousalSet, _totalArousalOccurrences, arousal);
insertValueAndTotal(_valenceSet, _totalValenceOccurrences, valence);
}
if(_saveCalm){
updateTrainedClass("calm", "positive");
......@@ -98,6 +107,13 @@ void Emotions::toggleSaveFear(bool save){
_valenceSet->clear();
}
void Emotions::recordData(bool record){
_record=record;
if(!record){
resetCurrData();
}
}
void Emotions::guessEmotion(){
_guess=true;
}
......
......@@ -27,6 +27,7 @@ private:
bool _saveSad;
bool _saveFear;
bool _guess;
bool _record;
QMap<double, double>* _arousalSet;
QMap<double, double>* _valenceSet;
......@@ -48,7 +49,7 @@ public slots:
void toggleSaveSad(bool save);
void toggleSaveJoy(bool save);
void guessEmotion();
void recordData(bool record);
void storeClassifiers();
signals:
......
......@@ -41,6 +41,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
QObject::connect(rootObject, SIGNAL(toggleSaveJoy(bool)), emotions, SLOT(toggleSaveJoy(bool)));
QObject::connect(rootObject, SIGNAL(storeClassifiers()), emotions, SLOT(storeClassifiers()));
QObject::connect(rootObject, SIGNAL(guessEmotion()), emotions, SLOT(guessEmotion()));
QObject::connect(rootObject, SIGNAL(recordData(bool)), emotions, SLOT(recordData(bool)));
QObject::connect(emotions, SIGNAL(giveEmotion(QVariant)), rootObject, SLOT(updateEmotion(QVariant)));
QObject::connect(myCallback,SIGNAL(timeTick8()),rootObject,SLOT(timeTick()));
......
......@@ -28,6 +28,8 @@ Rectangle {
signal toggleSaveJoy(bool saving);
signal guessEmotion();
signal storeClassifiers();
signal recordData(bool record);
Rectangle
{
id: guessRectangle;
......@@ -51,8 +53,12 @@ Rectangle {
anchors.fill: parent
onClicked:
{
guessEmotion();
infoText.text = "I guess...";
if(!recordButton.record){
infoText.text = "Record some data before I can guess";
}else{
guessEmotion();
infoText.text = "I guess...";
}
}
}
}
......@@ -285,74 +291,100 @@ Rectangle {
}
}
Rectangle
{
//quit button
color: "red"
anchors.right: parent.right
anchors.top: parent.top
width: 50
height: 50
Text
{
anchors.centerIn: parent
font.pixelSize: 40
color: "white";
text: "X"
}
MouseArea
{
anchors.fill: parent
onClicked:
Rectangle{
id:topbar;
anchors.top:parent.top;
anchors.left:parent.left;
color:"black";
height:50;
width:parent.width;
Rectangle{
id:storeButton;
color:"black";
border.color: "white";
anchors.left:parent.left;
anchors.top:parent.top;
height:parent.height;
width:150;
Text{
anchors.centerIn: parent
font.pixelSize: 20
color: "white";
text: "Store conf."
}
MouseArea
{
Qt.quit();
anchors.fill: parent
onClicked:
{
if(!initCalmDiv.saving && !initFearDiv.saving && !initSadDiv.saving && !initJoyDiv.saving){
infoText.text="";
page.storeClassifiers();
}else{
infoText.text="Please stop training before saving";
}
}
}
}
}
Rectangle
{
//quit button
color: "black";
border.color: "white";
anchors.right: parent.right
anchors.top: parent.top
width: 50
height: 50
Text
{
anchors.centerIn: parent
font.pixelSize: 40
color: "white";
text: "X"
Rectangle{
id:recordButton;
color:"black";
border.color: "white";
anchors.left:storeButton.right;
anchors.top:parent.top;
height:parent.height;
width:150;
property bool record: false;
Text{
id:recordText;
anchors.centerIn: parent
font.pixelSize: 20
color: "white";
text: "Start record"
}
MouseArea
{
anchors.fill: parent
onClicked:
{
parent.record=!parent.record;
recordData(parent.record);
if(parent.record){
recordText.text="Stop record"; // it's the next action
}else{
recordText.text="Start record";
}
}
}
}
}
Rectangle{
color:"black";
border.color: "white";
anchors.left:parent.left;
anchors.top:parent.top;
height:50;
width:150;
Text{
anchors.centerIn: parent
font.pixelSize: 20
color: "white";
text: "Store conf."
}
MouseArea
Rectangle
{
anchors.fill: parent
onClicked:
//quit button
anchors.right: parent.right
anchors.top: parent.top
width: 50
height: parent.height;
color:"black"
border.color: "white"
Text
{
if(!initCalmDiv.saving && !initFearDiv.saving && !initSadDiv.saving && !initJoyDiv.saving){
infoText.text="";
page.storeClassifiers();
}else{
infoText.text="Please stop training before saving";
anchors.centerIn: parent
font.pixelSize: parent.height;
color: "white";
text: "X"
}
MouseArea
{
anchors.fill: parent
onClicked:
{
Qt.quit();
}
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment