Mood Tracker

Project Description

The final product of this project is a Guided User Interface (GUI) that tracks the users mood. The mood-data is stored in form of histograms called Mood Histograms. Days are analogous to bins and the bin content is analogous to a mood. The GUI enables the user to view single Mood Histograms as well as comparing several Mood Histograms to each other.

Program Description

Get project.tar files here.
The program consist of three ".cpp" macros and one header file; "NewWeek.cpp", "Compare.cpp", "MoodHistogram.h" and "menu.cpp".

NewWeek.cpp

NewWeek() is the main function of “NewWeek.cpp”. The function creates a new Mood Histogram which plots mood vs. weekday and stores the histogram in “data.root”.

Compare.cpp

Compare() is the main function of “Compare.cpp”. When executed the code draws several Mood Histograms in the same canvas as well an overall average Mood Histogram in a separate canvas.

MoodHistogram.h

“MoodHistogram.h” is a header file. In this file there is a function called MoodHistogram(). The function generates a Mood Histogram template. “MoodHistogram.h” is included in NewWeek() and Compare().
In directory “Project” “#include “MoodHistogram.h” has been commented out in “NewWeek.cpp” and “Compare.cpp” , i.e. “//#include “MoodHistogram.h” ” in both NewWeek() and Comapre(). NewWeek() and Compare() will therefore not be able to run independently outside of menu().
In directory “Separate Code” one can run NewWeek() and Compare() separately from menu(). This is because “MoodHistogram.h” is included in both NewWeek() and Compre(), i.e “#include “MoodHistogram.h””.

menu.cpp

“menu.cpp” contains the main function “menu()”, which is the main code of this project. This function utilizes both NewWeek() and Compare().

Results

Menu

The menu() function creates a menu canvas with two buttons, “New Week” and “Compare”. When either buttons are clicked NewWeek() or Compare() is executed, respectively. The last mentioned functions are explained in the paragraphs above. The menu canvas is shown in Figure #. A welcome and instructions are printed in the terminal when menu() is executed, as shown in Figure #.

New Week

Two canvases are created. The first canvas is a control panel with a “draw histogram” and “save as pdf” button. The second displays the newly created Mood Histogram when “draw histogram” button is clicked. NewWeek() asks the user to declare which week they would like to track their mood for. The user must enter a weekday number (i.e “1” for Monday, “2” for Tuesday, etc...) and a corresponding mood, on a scale from 1 to 10. The function uses a while-loop to ask the user for input values, weekday and a corresponding mood. Inside the while-loop are if-statements which generate “error messages”. These error messages ensure that the user enters a valuable input. E.g if the user enters “-1” for a mood, which is not allowed since the mood is on a scale from 1-10, the following message is printed in the terminal: “ERROR: Enter a number between 1 and 10.”. The mentioned while-loop is generated by MoodInput(), at the end of the macro.
If NewWeek() is started a second time “data.root” is updated. At the end of the second session “data.root” will contain two Mood Histograms. Figure # is an example of a typical output from NewWeek().

Compare

Compare() opens an existing root file, “data.root”, created and updated by NewWeek(). The content of “data.root” is printed in the terminal. The user must enter the number of weeks and the specific week numbers they would like to compare. After input is entered three canvases are generated. The first canvas displays all the individual Mood Histogram for each week, the second an average mood per weekday Mood Histogram and the third a control panel with a “save as pdf” button. An analysis of the compared histograms is printed in the terminal, an overall average mood and average mood per weekday. Figure # is an example of a typical output from Compare().

Try it yourself!

To run the final program download .tar-file Project.tar.

Either write “root menu.cpp” in the terminal or “.L menu.cpp” followed by “.x menu()” in root.

E.g.
----------------------------
In terminal:
root menu.cpp
----------------------------
or
----------------------------
In root:
root [0] .L menu.cpp
root [1] .x menu()
----------------------------

To run NewWeek() and Compare() by themselves download NewWeek.cpp or Compare.cpp+demo.root, respectively.

Discussion/Conclusion

There is one obvious flaw with the program. When executing menu.cpp and clicking on either the “New Week” or “Compare” button, the terminal does not allow the user to view what they are typing into the terminal. This is not the case if the user executes NewWeek() and Compare() independently of menu(). The problem originates inside the TButton objects that execute NewWeek() and Compare(). According to Ladislav Kocbach it is not possible to combine showing text, in the terminal (an app), and “waiting for an input”, the button call (user interface object). He proposed to have a look at numberEntry.C which can be found in “tutorials/gui”, or here.Due to lack of time I did not explore this option any further.

The basic idea of tracking and analyzing mood has a lot of potential. There are several extensions that could be added to the code. For instance, if a .root-file with a years worth of Mood Histograms is generated, one could write a function that analyses how your mood changes throughout the year. The function could create a single Mood Histogram for the whole year and fit a mathematical function to the histogram. Further the function could inform you of which months were your happiest and saddest months as well as calculating the rate at which your mood changes from month to month.