예제 #1
0
decimal r_right_cos(const decimal& a)
{
	if(r_right(a)) {
		return r_round(r_cos_deg(a,false));
	}
	return r_cos_deg(a);
}
예제 #2
0
void keyCheck()
{

     if (keyStates['i']||arrowKeys[UP_ARROW]){
		 r_up();    
	 }
     if (keyStates['j']||arrowKeys[LEFT_ARROW]) {
          r_left();                                                                                      
     }
     if (keyStates['k']||arrowKeys[DOWN_ARROW]){
          r_down();                                                                                                                                          
	 }   
     if (keyStates['l']||arrowKeys[RIGHT_ARROW]) {
		  r_right();		       
	 }

	 glutPostRedisplay();

}
예제 #3
0
void WMain::generateTables()
{
    // Amount of columns and rows.
    uint columns = ui -> sb_columns -> value();
    uint rows    = ui -> sb_rows    -> value();

    // Creating pixmaps.
    table = QPixmap(2 * columns * TABLE_CELL_W + 1, rows * TABLE_CELL_H + 1);
    checker = QPixmap(table.size());

    // Filling up 'em with white.
    table.fill();
    checker.fill();

    // Creating painters.
    QPainter p_table(&table);
    QPainter p_checker(&checker);

    // Setting up font size.
    QFont font = p_table.font();
    font.setPixelSize(TABLE_TEXT_SIZE);
    p_table.setFont(font);
    p_checker.setFont(font);

    // Array with available columns.
    std::vector<uint> column_array;
    if (ui -> cb_0 -> isChecked())  column_array.push_back(0);
    if (ui -> cb_1 -> isChecked())  column_array.push_back(1);
    if (ui -> cb_2 -> isChecked())  column_array.push_back(2);
    if (ui -> cb_3 -> isChecked())  column_array.push_back(3);
    if (ui -> cb_4 -> isChecked())  column_array.push_back(4);
    if (ui -> cb_5 -> isChecked())  column_array.push_back(5);
    if (ui -> cb_6 -> isChecked())  column_array.push_back(6);
    if (ui -> cb_7 -> isChecked())  column_array.push_back(7);
    if (ui -> cb_8 -> isChecked())  column_array.push_back(8);
    if (ui -> cb_9 -> isChecked())  column_array.push_back(9);
    if (ui -> cb_10 -> isChecked()) column_array.push_back(10);

    // WTF?
    if (column_array.size() == 0)
        return;

    // Initializing random.
    qsrand(QTime::currentTime().secsTo(QTime()));

    // Creating tables.
    for (uint i = 0; i < columns; i++)
        for (uint j = 0; j < rows; j++)
        {
            // Generating index.
            int index_1 = column_array[qrand() % column_array.size()];
            int index_2 = qrand() % names[index_1].size();

            // Preparing rectangles.
            QRect r_left(2 * i * TABLE_CELL_W, j * TABLE_CELL_H,
                         TABLE_CELL_W,         TABLE_CELL_H);
            QRect r_right((2 * i + 1) * TABLE_CELL_W, j * TABLE_CELL_H,
                          TABLE_CELL_W,               TABLE_CELL_H);

            // Drawing on table.
            p_table.drawText(r_left,
                             Qt::AlignCenter | Qt::AlignHCenter,
                             names[index_1][index_2]);
            p_table.drawRect(r_left);
            p_table.drawRect(r_right);

            // Drawing on checker.
            p_checker.drawText(r_left,
                               Qt::AlignCenter | Qt::AlignHCenter,
                               names[index_1][index_2]);
            p_checker.drawText(r_right,
                               Qt::AlignCenter | Qt::AlignHCenter,
                               letters[index_1][index_2]);
            p_checker.drawRect(r_left);
            p_checker.drawRect(r_right);
        }

    // Saving pictures (for debug).
#ifdef QT_DEBUG
    table.save("table.png", "png");
    checker.save("checker.png", "png");
#endif

    // We're ready now!
    ((QLabel*) ui -> sa_task    -> widget()) -> setPixmap(table);
    ((QLabel*) ui -> sa_checker -> widget()) -> setPixmap(checker);
    ui -> t_task    -> setEnabled(true);
    ui -> t_checker -> setEnabled(true);
}