1 #include "where_people_look/experiment.h"
7 #include "boost/filesystem.hpp"
11 #include "where_people_look/config.h"
16 void Experiment::init_gaze_tracker() {
17 this->gaze_tracker->init(this->config->get_subject_id());
20 void Experiment::read_stimuli_list() {
21 boost::filesystem::directory_iterator
22 iter(this->config->get_stimuli_dir_path());
23 for (boost::filesystem::directory_entry entry : iter) {
24 if (boost::filesystem::is_regular_file(entry)
25 && !boost::filesystem::extension(entry).compare(
".jpeg")) {
26 this->trials.push(entry.path().string());
31 gboolean Experiment::experiment_stop_trial(gpointer experiment) {
33 exp->gaze_tracker->stop_trial();
34 gtk_widget_hide(GTK_WIDGET(exp->image));
38 gboolean Experiment::experiment_start_trial(gpointer experiment) {
42 gtk_image_set_from_file(exp->image, image_file.
c_str());
43 gtk_widget_show(GTK_WIDGET(exp->image));
44 exp->gaze_tracker->start_trial(image_file);
50 gaze_tracker(new gaze::GazeTracker()),
54 Experiment::~Experiment() {
63 if (this->is_prepared) {
66 this->init_gaze_tracker();
67 this->read_stimuli_list();
68 this->is_prepared =
true;
73 if (this->is_started) {
77 this->is_started =
true;
82 if (this->is_calibrating) {
85 if (this->calibration_countdown-- == 0) {
86 this->is_calibrating =
true;
87 this->calibration_countdown = this->calibration_after;
91 if (!this->trials.empty()) {
92 g_timeout_add(0, Experiment::experiment_start_trial,
this);
93 g_timeout_add(this->trial_duration, Experiment::experiment_stop_trial,
95 g_timeout_add(this->trial_duration + this->pause_duration,
106 exp->is_calibrating =
false;
107 exp->gaze_tracker->calibrate();
113 GtkWidget* window = gtk_widget_get_ancestor(GTK_WIDGET(exp->image),
115 g_signal_emit_by_name(window,
"destroy");
130 const GdkEventKey*
const event_key,
132 if (event_key->keyval == GDK_KEY_space) {
133 if (!experiment->is_started) {
Experiment(GtkImage *const image, Config *const config)
static gboolean experiment_trial(gpointer experiment)
static bool experiment_prepare(const GtkWidget *const assistant, Experiment *const experiment)
static bool experiment_start(const GtkWidget *const window, const GdkEventKey *const event_key, Experiment *const experiment)
void lock(_L1 &__l1, _L2 &__l2, _L3 &...__l3)
Holds all configuration options for the experiment.
Implements an experiment flow for Judd et al. (2009) .
static gboolean experiment_calibrate(gpointer experiment)
const char * c_str() const noexcept
static gboolean experiment_quit_program(gpointer experiment)