DrawArea::DrawArea(StateMachine& _state_machine, sca::ca::input_ca* ca, QWidget *parent) :
	QWidget(parent),
	state_machine(_state_machine),
	pixel_factor(1),
	TIMER_INTERVAL(250),
	min_color(0,255,0),
	max_color(255,0,0),
	ca(ca),
	grid_layout(this)
{
	set_timeout_interval(TIMER_INTERVAL);

	connect(&next_fire_timer, SIGNAL(timeout()),
		this, SLOT(slot_timeout()));
	connect(&state_machine, SIGNAL(updated(StateMachine::STATE)),
		this, SLOT(state_updated(StateMachine::STATE)));

	ColorTable tmp_ct(min_color, max_color, 0, 7);
	int entry = 0;

	for(ColorTable::const_iterator itr(tmp_ct); itr.valid();
		++itr, ++entry)
	{
		itr->to_32bit((int*)(color_table + entry));
	}
	color_table[8] = 0; // sentinel - black

	pixmap_table.resize(9);
	for(int i = 0; i < 9; ++i)
	{
		pixmap_table[i] = QPixmap(1, 1);
		pixmap_table[i].fill(color_table[i]);
	}

}
Beispiel #2
0
		void set_priority(int prio)
		{
			TORRENT_ASSERT(prio <= 255 && prio >= 0);
			if (prio > 255) prio = 255;
			else if (prio < 0) prio = 0;
			m_priority = prio;
			state_updated();
		}
void MainWindow::setup_ui()
{
	/*
		MENU BAR
	*/
	setMenuBar(&menu_bar);

	/*
		TOOL BAR
	*/
//	tool_bar.setIconSize(QSize(24, 24));
//	addToolBar(Qt::TopToolBarArea, &tool_bar);

	/*
		CENTRAL WIDGET
	*/
	setCentralWidget(&central_widget);
	hbox_main.addLayout(&vbox_left, 1);
	hbox_main.addLayout(&vbox_right);

	vbox_left.addWidget(&draw_area, 0);
	vbox_right.addWidget(&spacer, 1);
	vbox_right.addWidget(&btn_run);
	vbox_right.addWidget(&btn_step);
	vbox_right.addLayout(&pixel_size_chooser.layout());
	vbox_right.addLayout(&time_interval_chooser.layout());
	ca_type_edit.widget().setText("Select ca");
	vbox_right.addLayout(&ca_type_edit.layout());
	btn_run.setCheckable(true);

	connect(&time_interval_chooser.widget(), SIGNAL(valueChanged(int)),
		&draw_area, SLOT(set_timeout_interval(int)));
	connect(&pixel_size_chooser.widget(), SIGNAL(valueChanged(int)),
		this, SLOT(change_pixel_size(int)));
	connect(&state_machine, SIGNAL(updated(StateMachine::STATE)),
		this, SLOT(state_updated(StateMachine::STATE)));
	connect(&btn_step, SIGNAL(released()),
		&state_machine, SLOT(trigger_step()));
	connect(&btn_run, SIGNAL(released()),
		&state_machine, SLOT(trigger_pause()));
	connect(&ca_type_edit.widget(), SIGNAL(clicked()),
		this, SLOT(change_ca_type()));
	connect(&menu_bar, SIGNAL(toggle_fullscreen()),
		this, SLOT(slot_fullscreen()));

	draw_area.fill_grid();
	draw_area.set_pixel_size(pixel_size_chooser.widget().value());

	/*pixel_size_chooser.widget().setMinimum(1);
	pixel_size_chooser.widget().setMaximum(255);
	pixel_size_chooser.widget().setValue(4);
	time_interval_chooser.widget().setMinimum(0);
	time_interval_chooser.widget().setMaximum(1000);
	time_interval_chooser.widget().setValue(10);*/
}