Пример #1
0
static void dev_close(enum device dev)
{
	if (dev == dev_wii) {
		wii_set_leds(&wii, 1, 0, 0, 0);
		wii_disconnect(&wii);			
		printf("Disconnected.\n");
		fflush(stdout);
		if (g_mode == graphical) {
			percentage += 0.1;
			if (percentage < 0.7) {
				update_gui("Gesture was created", percentage);
			} else {
				update_gui("Gesture was trained", percentage);
			}
		}
	} else if ((dev == dev_neo2) || (dev == dev_neo3)) 	{
		neo_close(&neo);
		printf("Closed.\n");
		fflush(stdout);
		if (g_mode == graphical) {
			percentage += 0.1;
			if (percentage < 0.7) {
				update_gui("Gesture was created", percentage);
			} else {
				update_gui("Gesture was trained", percentage);
			}
		}
	} else if (dev == dev_sim) {
		sim_close(&sim);
		printf("Closed.\n");
		fflush(stdout);
	}
}
Пример #2
0
void MainWindow::on_clip_clicked()
{


	ElevatorEvent* el_event = elevator_detector->get_selected_event();
	int start_frame = el_event->user->get_first_frame() - 50;
	int end_frame = el_event->user->get_last_frame() + 50;

	QString window_name = elevator_detector->get_event_description(el_event->id);

	switch(clip_state)
	{
	case STATE_STOP_CLIP:
		//start the clip...
		clip_state = STATE_PLAY_CLIP;
		update_gui();
		video_loader.reset(start_frame, end_frame);
		play_clip(window_name.toAscii().constData());
		break;
	case STATE_PLAY_CLIP:
		//pause the clip...
		clip_state = STATE_PAUSE_CLIP;
		update_gui();
		break;
	case STATE_PAUSE_CLIP:
		//resume the clip...
		clip_state = STATE_PLAY_CLIP;
		update_gui();
		play_clip(window_name.toAscii().constData());
		break;
	}
}
Пример #3
0
MainWindow::MainWindow(QWidget *parent)
	: QMainWindow(parent), ui(new Ui::MainWindowClass), tracker_state(STATE_NOT_STARTED), clip_state(STATE_STOP_CLIP), writer(NULL),
	selected_trace(NULL), selected_target(NULL), elevator_detector(NULL), extra_frame_countdown(0),
	image_buffer(NULL), recording(false), videofile_index(0)

{
	ui->setupUi(this);
	tracker = new EventTracker();
	QStringList lables;
	lables << tr("ID#") << tr("Name") << tr("Initial Frame") << tr("Last Frame") << tr("Length");
	ui->trace_table->setHorizontalHeaderLabels(lables);
	ui->trace_table->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
	ui->trace_table->setShowGrid(true);

	QStringList target_lables;
	target_lables << tr("ID#") << tr("Trace IDs") << tr("Initial Frame") << tr("Last Frame");
	ui->target_table->setHorizontalHeaderLabels(target_lables);
	ui->target_table->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
	ui->target_table->setShowGrid(true);

	QStringList event_lables;
	event_lables << tr("Event") << tr("Frame");
	ui->event_table->setHorizontalHeaderLabels(event_lables);
	ui->event_table->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
	ui->event_table->setShowGrid(true);

	frame_count = 0;

	update_gui();

}
Пример #4
0
/**
 * Change current cursor to a animated watch (if animation supported
 * by environment).
 *
 * \param force_update		Call a gtk iteration to ensure cursor
 *				is updated.  May cause trouble if
 *				called from some signal handlers.
 */
void gsb_status_wait ( gboolean force_update )
{
    GdkWindow * current_window;

    gdk_window_set_cursor ( run.window -> window,
			    gdk_cursor_new_for_display ( gdk_display_get_default ( ),
							 GDK_WATCH ) );

    current_window = gdk_display_get_window_at_pointer ( gdk_display_get_default ( ),
							 NULL, NULL );

    if ( current_window && GDK_IS_WINDOW ( current_window )
     &&
	 current_window != run.window -> window )
    {
	GdkWindow * parent = gdk_window_get_toplevel ( current_window );

	if ( parent && parent != current_window )
	{
	    current_window = parent;
	}

	gdk_window_set_cursor ( current_window,
				gdk_cursor_new_for_display ( gdk_display_get_default ( ),
							     GDK_WATCH ) );

	tracked_window = current_window;
    }

    if ( force_update )
	update_gui ( );
}
Пример #5
0
static void cmd_model_new_end(char *file)
{
	//printf("reached cmd_model_new_end\n");
	//fflush(stdout);
	//hmm_print_3d(&hmm);
	//printf("state len: %d\n", hmm.state_len);
	//printf("wrote HMM\n");
	//fflush(stdout);
	hmm_write_3d(&hmm, file);
	printf("Done.\n");
	fflush(stdout);
	if (g_mode == graphical) {
		percentage += 0.2;
		update_gui("Done creating gesture", percentage);
	}

	if (g_mode == graphical) {
		dev_close(g_dev);
		//pthread_exit(0); /* don't exit, as we probably going to train the gesture */
	} else {
		kill(getpid(), SIGTERM);
	}

	gauss_mix_delete_3d(&endpoint.each[0]);
	gauss_mix_delete_3d(&endpoint.each[1]);
	hmm_delete_3d(&hmm);
	
	seq.index = 0;
	detected = 0;
	seq.till_end = FRAME_AFTER;
	seq.begin = 0;
	seq.end = 0;
}
Пример #6
0
static void add_channel(struct channel *c)
{
	c->vbox = gtk_vbox_new(FALSE, 5);
	c->vscale = gtk_vscale_new(GTK_ADJUSTMENT(gtk_adjustment_new(
					mixer_get(c), 0, 100, 0, 0, 0)));
	gtk_scale_set_draw_value(GTK_SCALE(c->vscale), FALSE);
	gtk_range_set_inverted(GTK_RANGE(c->vscale), TRUE);
	gtk_container_add(GTK_CONTAINER(hbox), c->vbox);
	gtk_box_pack_start(GTK_BOX(c->vbox), c->vscale, TRUE, TRUE, 0);

	g_signal_connect((gpointer)c->vscale,
			"value_changed", G_CALLBACK(vol_change), c);
	g_signal_connect(c->vscale,
			"scroll-event", G_CALLBACK(scale_scroll), c);

	if (_has_switch(c->elem, c->playback)) {
		c->mute = gtk_check_button_new_with_label(
				c->playback ? _("Mute") : _("Capture"));
		g_signal_connect((gpointer)c->mute,
				"toggled", G_CALLBACK(mute), c);
		gtk_box_pack_end(GTK_BOX(c->vbox), c->mute, FALSE, FALSE, 0);
	}
	
	update_gui(c);
}
Пример #7
0
static void cmd_model_train_end(char *file)
{
	//printf("reached cmd_model_train_end\n");
	//fflush(stdout);
	hmm_write_3d(&hmm, file);
	printf("Done.\n");
	fflush(stdout);
	if (g_mode == graphical) {
		percentage += 0.2;
		update_gui("Done training gesture", percentage);
	}
	
	if (g_mode == graphical) {
		dev_close(g_dev);
		//pthread_exit(0);
	} else {
		kill(getpid(), SIGTERM);
	}

	gauss_mix_delete_3d(&endpoint.each[0]);
	gauss_mix_delete_3d(&endpoint.each[1]);
	hmm_delete_3d(&hmm);
	
	seq.index = 0;
	detected = 0;
	seq.till_end = FRAME_AFTER;
	seq.begin = 0;
	seq.end = 0;
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    cl = new dhcp_client;
    connect(cl, SIGNAL(update_info()), this, SLOT(update_gui()));
}
Пример #9
0
void replay_controller::reset_replay()
{
	DBG_REPLAY << "replay_controller::reset_replay\n";

	gui_->clear_chat_messages();
	is_playing_ = false;
	player_number_ = 1;
	current_turn_ = 1;
	it_is_a_new_turn_ = true;
	skip_replay_ = false;
	tod_manager_= tod_manager_start_;
	recorder.start_replay();
	recorder.set_skip(false);
	units_ = units_start_;
	gamestate_ = gamestate_start_;
	teams_ = teams_start_;
	if (events_manager_ ){
		// NOTE: this double reset is required so that the new
		// instance of game_events::manager isn't created before the
		// old manager is actually destroyed (triggering an assertion
		// failure)
		events_manager_.reset();
		events_manager_.reset(new game_events::manager(level_));
	}

	gui_->labels().read(level_);

	resources::gamedata->rng().seed_random(level_["random_seed"], level_["random_calls"]);
	statistics::fresh_stats();
	set_victory_when_enemies_defeated(level_["victory_when_enemies_defeated"].to_bool(true));

	// Add era events for MP game.
	if (const config &era_cfg = level_.child("era")) {
		game_events::add_events(era_cfg.child_range("event"), "era_events");
	}

	// Scenario initialization. (c.f. playsingle_controller::play_scenario())
	fire_preload();
	if(true){ //block for set_scontext_synced
		config* pstart = recorder.get_next_action();
		assert(pstart->has_child("start"));
		/*
			use this after recorder.add_synced_command
			because set_scontext_synced sets the checkup to the last added command
		*/
		set_scontext_synced sync;
		
		fire_prestart(true);
		init_gui();
		fire_start(true);
	}
	// Since we did not fire the start event, it_is_a_new_turn_ has the wrong value.
	it_is_a_new_turn_ = true;
	update_gui();

	reset_replay_ui();
}
Пример #10
0
void PluginClient::plugin_update_gui()
{
	
	update_gui();
	
// Delete unused GUI frames
	while(frame_buffer.size() > MAX_FRAME_BUFFER)
		frame_buffer.remove_object_number(0);

}
Пример #11
0
//make only one side move
void replay_controller::play_side(const unsigned int /*team_index*/, bool){

	DBG_REPLAY << "Status turn number: " << turn() << "\n";
	DBG_REPLAY << "Replay_Controller turn number: " << current_turn_ << "\n";
	DBG_REPLAY << "Player number: " << player_number_ << "\n";

	try{
		// If a side is empty skip over it.
		bool has_end_turn = true;
		if (!current_team().is_empty()) {
			statistics::reset_turn_stats(current_team().save_id());

			play_controller::init_side(player_number_ - 1, true);

			DBG_REPLAY << "doing replay " << player_number_ << "\n";
			// if have reached the end we don't want to execute finish_side_turn and finish_turn
			// becasue we might not have enough data to execute them (like advancements during turn_end for example)
			// !has_end_turn == we reached the end of teh replay without finding and end turn tag.
			has_end_turn = do_replay(player_number_);
			if(!has_end_turn)
			{
				return;
			}
			finish_side_turn();
		}

		player_number_++;

		if (static_cast<size_t>(player_number_) > teams_.size()) {
			//during the orginal game player_number_ would also be teams_.size(),
			player_number_ = teams_.size();
			finish_turn();
			tod_manager_.next_turn();
			it_is_a_new_turn_ = true;
			player_number_ = 1;
			current_turn_++;
			gui_->new_turn();
		}

		// This is necessary for replays in order to show possible movements.
		BOOST_FOREACH(unit &u, units_) {
			if (u.side() == player_number_) {
				u.new_turn();
			}
		}

		update_teams();
		update_gui();
	}
	catch(end_level_exception& e){
		//VICTORY/DEFEAT end_level_exception shall not return to title screen
		if (e.result != VICTORY && e.result != DEFEAT) throw;
	}
}
Пример #12
0
void MainWindow::on_event_table_cellClicked(int row, int column)
{
	QTableWidgetItem* first_cell = ui->event_table->item(row,0);

	selected_target = NULL;
	selected_trace = NULL;
	elevator_detector->set_selected_event(row);

	update_gui();
	ui->event_table->selectRow(row);
}
Пример #13
0
/**
 * Display a message in the status bar.
 *
 * \param message	Message to display.
 */
void gsb_status_message ( gchar * message )
{
    if ( ! main_statusbar || ! GTK_IS_STATUSBAR ( main_statusbar ) )
	return;

    gsb_status_clear ();
    message_id = gtk_statusbar_push ( GTK_STATUSBAR (main_statusbar), context_id, message );

    /* force status message to be displayed NOW */
    update_gui ( );
}
Пример #14
0
//start the tracker
void MainWindow::start_tracking()
{
	cvNamedWindow("binary");
	cvNamedWindow("vid");
	IplImage* image=NULL;
	IplImage* binary_image = NULL;

	//int k = 0;      //skipped frame count
	clock_t start_time = clock();

	while(tracker_state == STATE_STARTED_TRACKING && 
		((image = video_loader.next_frame())!= NULL))
	{
		tracker->next_image(image);
		binary_image = tracker->get_binary_model();
		draw_targets(image);

		//Record when there is substantial motion
		if (config->record_activity) {
			cout << "RECORDING" << endl;
			record_activity(image);
		}

		cvShowImage("binary", binary_image);
		cvShowImage("vid", image);
		cvWaitKey(1);
	}

	clock_t elapsed_time = clock() - start_time;

	cout << "clock ticks = " << elapsed_time << endl;
	cout << "seconds = " << (float)elapsed_time/(float)CLOCKS_PER_SEC << endl;


	if (tracker_state == STATE_STARTED_TRACKING && !image)
	{
		//video is over, terminate tracking.
		tracker->end_tracking();
		ReleaseVideoWriter();
		ReleaseVideoBuffer();
		tracker_state = STATE_NOT_STARTED;

		//Update the trace table
		update_trace_list();
		//Update the target table
		update_target_list();
		//Update the elevator list table
		update_event_list();

		update_gui();
	}

}
Пример #15
0
void DelayAudioWindow::create_objects()
{
	add_subwindow(new BC_Title(10, 10, _("Delay seconds:")));
	length = new DelayAudioTextBox(
		plugin, 
		this,
		10, 
		40);
	length->create_objects();
	update_gui();
	show_window();
}
Пример #16
0
//start button handler
void MainWindow::on_start_clicked()
{
	switch(tracker_state)
	{
	case STATE_NOT_STARTED:
		//start the tracker...
		tracker_state = STATE_STARTED_TRACKING;
		update_gui();
		video_loader.reset();
		//if (config->detect_elevator_events) prepare_elevator_detector();
		if (config->record_activity) prepare_image_buffer();
		start_tracking();
		break;
	case STATE_STARTED_TRACKING:
		//pause the tracker...
		update_trace_list();
		//Update the target table
		update_target_list();
		//Update the elevator list table
		update_event_list();

		tracker_state = STATE_STOPPED_TRACKING;
		update_gui();
		break;
	case STATE_STOPPED_TRACKING:
		//resume the tracker...

		//Update the trace table
		update_trace_list();
		//Update the target table
		update_target_list();
		//Update the elevator list table
		update_event_list();

		tracker_state = STATE_STARTED_TRACKING;
		update_gui();
		start_tracking();
		break;
	}
}
Пример #17
0
static gboolean on_mixer_event(GIOChannel* channel, GIOCondition cond, void *ud)
{
	if (mixer_evt_idle == 0) {
		mixer_evt_idle = g_idle_add_full(G_PRIORITY_DEFAULT,
						 (GSourceFunc) reset_mixer_evt_idle,
						 NULL, NULL);
		snd_mixer_handle_events (mixer);
	}

	if (cond & G_IO_IN) {
		/* update mixer status */
		update_gui(&ch[0]);
		update_gui(&ch[1]);
	}

	if (cond & G_IO_HUP) {
		/* FIXME: This means there're some problems with alsa. */
		return FALSE;
	}

	return TRUE;
}
Пример #18
0
/**
 * Clear any message in the status bar.
 */
void gsb_status_clear (  )
{
    if ( ! main_statusbar || ! GTK_IS_STATUSBAR ( main_statusbar ) )
	return;

    if ( message_id >= 0 )
    {
	gtk_statusbar_remove ( GTK_STATUSBAR (main_statusbar), context_id, message_id );
	message_id = -1;
    }

    /* force status message to be displayed NOW */
    update_gui ( );
}
Пример #19
0
/**
 * Change current cursor to default cursor.
 *
 * \param force_update		Call a gtk iteration to ensure cursor
 *				is updated.  May cause trouble if
 *				called from some signal handlers.
 */
void gsb_status_stop_wait ( gboolean force_update )
{
    if ( ! run.window )
	return;

    gdk_window_set_cursor ( run.window -> window, NULL );

    if ( tracked_window && gdk_window_is_visible ( tracked_window ) )
    {
	gdk_window_set_cursor ( tracked_window, NULL );
	tracked_window = NULL;
    }

    if ( force_update )
	update_gui ( );
}
void replay_controller::play_side(const unsigned int /*team_index*/, bool){
	if (recorder.at_end()){
		return;
	}

	DBG_REPLAY << "Status turn number: " << turn() << "\n";
	DBG_REPLAY << "Replay_Controller turn number: " << current_turn_ << "\n";
	DBG_REPLAY << "Player number: " << player_number_ << "\n";

	try{
		// If a side is empty skip over it.
		if (!current_team().is_empty()) {
			statistics::reset_turn_stats(current_team().save_id());

			play_controller::init_side(player_number_ - 1, true);

			DBG_REPLAY << "doing replay " << player_number_ << "\n";
			do_replay(player_number_);

			finish_side_turn();

			// This is necessary for replays in order to show possible movements.
			for (unit_map::iterator uit = units_.begin(); uit != units_.end(); ++uit) {
				if (uit->second.side() != player_number_) {
					uit->second.new_turn();
				}
			}
		}

		player_number_++;

		if (static_cast<size_t>(player_number_) > teams_.size()) {
			next_turn();
			finish_turn();
			player_number_ = 1;
			current_turn_++;
		}

		update_teams();
		update_gui();
	}
	catch(end_level_exception& e){
		//VICTORY/DEFEAT end_level_exception shall not return to title screen
		if ((e.result != VICTORY) && (e.result != DEFEAT)) { throw e; }
	}
}
Пример #21
0
// the full stack has 4 levels of indirection:
// midi CC -> control_index -> param_index -> byte offset
static void proc_pd_cc(struct proc_pd *x, t_float cc_f, t_float val) {
    if ((cc_f >= 0) && (cc_f <= 127)) {
        int cc = cc_f;
        int control_index = x->cc_map[(int)cc];
        if (control_index >= 0) { // -1 means not mapped
            int param_index = proc_instance_find_control(x->proc_instance, control_index);
            float range_val = val * (1.0f / 127.0f);
            proc_instance_set_param(x->proc_instance, param_index, range_val);

            // FIXME: should we really do this from here??
            update_gui(x, control_index);
        }
        else {
            post("cc %d not mapped", cc);
        }
    }
}
Пример #22
0
void MainWindow::on_trace_table_cellClicked(int row, int column)
{
	QTableWidgetItem* first_cell = ui->trace_table->item(row,0);
	int id = atoi((const char*) first_cell->text().toLatin1());

	selected_trace = NULL;
	selected_target = NULL;

	QList<Trace*> traces = tracker->get_history();
	for (QList<Trace*>::iterator iter = traces.begin(); iter != traces.end(); iter++)
	{
		if ((*iter)->get_id() == id)
		{
			selected_trace = *iter;
			break;
		}
	}
	update_gui();
	ui->trace_table->selectRow(row);
}
Пример #23
0
void MainWindow::play_clip(const char* window_name)
{
	cvNamedWindow(window_name);
	IplImage* image=NULL;

	while(clip_state == STATE_PLAY_CLIP && ((image = video_loader.next_frame())!= NULL))
	{
		cvShowImage(window_name, image);
		cvWaitKey(5);
	}

	if (clip_state == STATE_PLAY_CLIP && !image)
	{
		//video is over.
		clip_state = STATE_STOP_CLIP;
		cvDestroyWindow(window_name);
		update_gui();
	}

}
void replay_controller::init(){
	DBG_REPLAY << "in replay_controller::init()...\n";

	//guarantee the cursor goes back to 'normal' at the end of the level
	const cursor::setter cursor_setter(cursor::NORMAL);
	init_replay_display();

	fire_prestart(true);
	init_gui();
	statistics::fresh_stats();
	set_victory_when_enemies_defeated(
		utils::string_bool(level_["victory_when_enemies_defeated"], true));

	DBG_REPLAY << "first_time..." << (recorder.is_skipping() ? "skipping" : "no skip") << "\n";

	fire_start(!loading_game_);
	update_gui();

	units_start_ = units_;
	teams_start_ = teams_;
}
Пример #25
0
void replay_controller::reset_replay(){

	gui_->clear_chat_messages();
	is_playing_ = false;
	player_number_ = 1;
	current_turn_ = 1;
	it_is_a_new_turn_ = true;
	skip_replay_ = false;
	tod_manager_= tod_manager_start_;
	recorder.start_replay();
	recorder.set_skip(false);
	units_ = units_start_;
	gamestate_ = gamestate_start_;
	teams_ = teams_start_;
	if (events_manager_ ){
		// NOTE: this double reset is required so that the new
		// instance of game_events::manager isn't created before the
		// old manager is actually destroyed (triggering an assertion
		// failure)
		events_manager_.reset();
		events_manager_.reset(new game_events::manager(level_));
	}

	gui_->labels().read(level_);

	statistics::fresh_stats();
	set_victory_when_enemies_defeated(level_["victory_when_enemies_defeated"].to_bool(true));

	// Add era events for MP game.
	if (const config &era_cfg = level_.child("era")) {
		game_events::add_events(era_cfg.child_range("event"), "era_events");
	}

	fire_prestart(true);
	init_gui();
	fire_start(true);
	update_gui();

	reset_replay_ui();
}
Пример #26
0
//make only one side move
void replay_controller::play_side(const unsigned int /*team_index*/, bool){

	DBG_REPLAY << "Status turn number: " << turn() << "\n";
	DBG_REPLAY << "Replay_Controller turn number: " << current_turn_ << "\n";
	DBG_REPLAY << "Player number: " << player_number_ << "\n";

	try{
		// If a side is empty skip over it.
		if (!current_team().is_empty()) {
			statistics::reset_turn_stats(current_team().save_id());

			play_controller::init_side(player_number_ - 1, true);

			DBG_REPLAY << "doing replay " << player_number_ << "\n";
			do_replay(player_number_);

			finish_side_turn();

			// This is necessary for replays in order to show possible movements.
			foreach (unit &u, units_) {
				if (u.side() != player_number_) {
					u.new_turn();
				}
			}
		}

		player_number_++;

		if (static_cast<size_t>(player_number_) > teams_.size()) {
			finish_turn();
			tod_manager_.next_turn();
			it_is_a_new_turn_ = true;
			player_number_ = 1;
			current_turn_++;
			gui_->new_turn();
		}

		update_teams();
		update_gui();
	}
Пример #27
0
void MainWindow::on_reset_clicked()
{
	while (ui->trace_table->rowCount())
		ui->trace_table->removeRow(0);

	while (ui->target_table->rowCount())
		ui->target_table->removeRow(0);

	traces.clear();
	targets.clear();
	tracker->reset();
	video_loader.reset();

	tracker_state = STATE_NOT_STARTED;

	target_flag_zero();
	trace_flag_zero();

	frame_count = 0;

	update_gui();
}
void replay_controller::preferences(bool use_classic){
	play_controller::preferences(use_classic);
	update_gui();
}
void replay_controller::replay_show_team1(){
	show_everything_ = false;
	show_team_ = 1;
	update_teams();
	update_gui();
}
void replay_controller::replay_show_everything(){
	show_everything_ = true;
	show_team_ = 0;
	update_teams();
	update_gui();
}