main_window::main_window (QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::main_window)
{
  ui->setupUi(this);
  ui->statusBar->showMessage (trUtf8 ("Выберите функцию"));
  setWindowTitle (trUtf8 ("Метод наименьших квадратов"));
  ui->function_menu->setTitle (trUtf8 ("Функции"));
  ui->menuView->setTitle (trUtf8 ("Показать"));
  ui->menu_func->setText (trUtf8 ("Только функцию"));
  ui->menu_approx->setText (trUtf8 ("Только приближение"));
  ui->menu_both->setText (trUtf8 ("Функцию и приближение"));
  ui->menu_mesh->setText (trUtf8 ("Сетку"));
  ui->threads_label->setText (trUtf8 ("Число потоков:"));

  QColor clearColor = Qt::black;

  browser = new GLWidget(this);
  browser->setClearColor(clearColor);
  connect (ui->sin, SIGNAL (triggered ()), browser, SLOT (set_sin ()));
  connect (ui->linear, SIGNAL (triggered ()), browser, SLOT (set_linear ()));
  connect (ui->x2y2, SIGNAL (triggered ()), browser, SLOT (set_x2y2 ()));
  connect (ui->x2x, SIGNAL (triggered ()), browser, SLOT (set_x2x ()));
  connect (ui->menu_mesh, SIGNAL (triggered ()), browser, SLOT (mesh_draw_changed ()));
  connect (ui->menu_func, SIGNAL (triggered ()), browser, SLOT (only_func ()));
  connect (ui->menu_approx, SIGNAL (triggered ()), browser, SLOT (only_approx ()));
  connect (ui->menu_both, SIGNAL (triggered ()), browser, SLOT (draw_both ()));

  connect (browser, SIGNAL (sendmsg (QString)), ui->statusBar, SLOT (showMessage (QString)));
  ui->centralWidget->layout ()->addWidget (browser);
  browser->setFocus ();
  old_n1 = ui->n1_box->value ();
  old_n2 = ui->n2_box->value ();
  browser->update_approximation ();
}
Ejemplo n.º 2
0
Archivo: gfx.c Proyecto: Karethoth/jmc
void draw_classic_mode (SDL_Surface *sur) // take this as an example
{
    if (cur_pos - offset > play_len || cur_pos - offset < 0)
        return;
    int root_size, size, pad, y_off;
    album *root_album = playlist [cur_pos - offset];
    if (root_album == NULL)
        return;
    album *cur_album = root_album->prev;

    if (verbose)
        printf ("drawing\n");

    if (sur->w < sur->h)
        root_size = sur->w * root_size_opt;
    else
        root_size = sur->h * root_size_opt;
    if (root_size > max_size_opt)
        root_size = max_size_opt;
    size = size_opt * root_size;
    if (size > max_size_opt)
    {
        size = max_size_opt;
        root_size = size / size_opt;
    }
    pad = size * pad_opt;

    int root_offset = sur->w/2;
    int prev_offset = root_offset - pad- size;
    int next_offset = root_offset + pad;
    if (root_album->cover != NULL)
    {
        int extra = root_size/2;
        root_offset -= extra;
        prev_offset -= extra;
        next_offset += extra;
    }

    y_off = y_off_opt * size;
    if (y_off * 2 > root_size - size)
        y_off = (root_size - size) / 2;


    prev_is_nul = false;
    for (int i = prev_offset;
         i + size > 0 && cur_album != NULL;
         i -= pad + size, cur_album = cur_album->prev)
    {
        if (cur_album->cover != NULL)
        {
            draw_both (cur_album->cover, sur, i, sur->h/2 - size/2, size);
        }
    }
    if (cur_album == NULL)
        prev_is_nul = true;
    cur_album = root_album->next;
    next_is_nul = false;
    for (int i = next_offset;
         i < sur->w && cur_album != NULL;
         i += pad + size, cur_album = cur_album->next)
    {
        if (cur_album->cover != NULL)
        {
            draw_both (cur_album->cover, sur, i, sur->h/2 - size/2, size);
        }
    }
    if (cur_album == NULL)
        next_is_nul = true;

    if (root_album->cover != NULL)
    {
        draw_flipped (root_album->cover, sur,
                root_offset, sur->h/2 - root_size/2 - y_off, root_size);
        alpha_mask (sur, sur->h/2 + size/2);
        draw_album (root_album->cover, sur,
                root_offset, sur->h/2 - root_size/2 - y_off, root_size);
    }
    else
        alpha_mask (sur, sur->h/2 + size/2);
}