Ejemplo n.º 1
0
void GLWidget::paintGL ()
{
  qglClearColor (clearColor);
  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glLoadIdentity ();
  glTranslatef (0.0f, 0.0f, -10.0f);
  glRotatef (zRot / 16.0f, 0.0f, 0.0f, 1.0f);
  glRotatef (xRot / 16.0f, 1.0f, 0.0f, 0.0f);
  glRotatef (yRot / 16.0f, 0.0f, 1.0f, 0.0f);
  glScalef (scale, scale, scale);

  glDisable (GL_LIGHTING);
  /// Coordinate Lines
  glLineWidth(3);
  glBegin(GL_LINES);
    glColor4f (1, 0, 0, 1);
    glVertex3d(100, 0, 0);
    glVertex3d(-100, 0, 0);
  glEnd();
  qglColor(Qt::white);
  renderText(1, 0 , 0, QString::fromUtf8("X"), QFont() , 300);
  glBegin(GL_LINES);
    glColor4f (0, 1, 0, 1);
    glVertex3d(0, 100, 0);
    glVertex3d(0, -100, 0);
  glEnd();
  qglColor(Qt::white);
  renderText(0, 1 , 0, QString::fromUtf8("Y"), QFont() , 300);
  glBegin(GL_LINES);
    glColor4f (0, 0, 1, 1);
    glVertex3d(0, 0, 100);
    glVertex3d(0, 0, -100);
  glEnd();
  qglColor(Qt::white);
  renderText(0, 0 , 1, QString::fromUtf8("Z"), QFont() , 300);
  glLineWidth(1);
  /// Lights
  glEnable (GL_LIGHTING);
  glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
  glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
  glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
  glEnable (GL_LIGHT1);

  glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, gold_color);
  if (options != ONLY_APPROXIMATION)
    draw_function (function_index, draw_mesh);
  glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, blue_color);
  residual = 0.;
  if (options != ONLY_FUNCTION)
    {
      draw_approx = true;
      draw_function (function_index, draw_mesh);
      draw_approx = false;
    }
  emit sendmsg (trUtf8 ("Zoom %1, Residual: %3").arg (scale).arg (residual));
}
Ejemplo n.º 2
0
void draw_menu_iter(void)
{
	static bool sparse = FALSE;
	Simulation *sim = stgs.linked_sim;
#if LOOP_OPT_STEPS
	static size_t prev_steps = 0;
	bool do_draw = sim->steps-prev_steps >= exp(max(stgs.speed-LOOP_OPT_SPEED, 0));

	if (do_draw) {
#endif
		draw_dir_arrow();
		draw_function();
		draw_steps();
#if LOOP_OPT_STEPS
		prev_steps = sim->steps;
	}
#endif
	if (!sparse && is_grid_sparse(sim->grid)) {
		draw_edge();
		sparse = TRUE;
		do_draw = TRUE;
	}
#if LOOP_OPT_STEPS
	if (do_draw) {
#endif
		wnoutrefresh(menuw);
#if LOOP_OPT_STEPS
	}
#endif
}
Ejemplo n.º 3
0
void recalculate_and_draw(Coordinate_system *cs, char expr[], char number_of_derivatives, float step, bool clear_all)
{
	calc_function(cs, expr, number_of_derivatives, 0.001);
	if(clear_all)
		draw_empty_chart(cs->get_axis_coord('x'), cs->get_axis_coord('y'), GRAPH_WIDHT, GRAPH_HEIGHT, cs->get_scale_of_axis('x'), cs->get_scale_of_axis('y'));
	draw_function(cs, expr, number_of_derivatives);
}
Ejemplo n.º 4
0
int main() {
    complex value;
    double x0;
    FILE *file = fopen("data.txt", "r");
    fscanf(file, "%d%lf%lf", &n, &h, &x0);
    array_values = new double *[n];
    for (int i = 0; i < n; i++) array_values[i] = new double [2];
    array_values[0][0] = x0;
    array_values[0][1] = f(x0);
    for (int i = 1; i < n; i++) {
        array_values[i][0] = x0 + i * h;
        array_values[i][1] = f(array_values[i][0]);
    }
    fclose(file);
    printf("    X          Y\n");
    for (int i = 0; i < n; i++) {
        printf("%lf   %lf\n", array_values[i][0], array_values[i][1]);
    }
    printf("\n");
    value = trigonometric_interpolation(point);
    printf("Result: %lf %lf\n\n", value.real, value.image);
    init_window();
    draw_function(-10, 10);
    draw_real_part(-10, 10);
    draw_image_part(-10, 10);
    system("pause");
}
Ejemplo n.º 5
0
void draw_menu_full(void)
{
	draw_edge();
	draw_logo();
	draw_color_list();
	draw_init_size();
	draw_direction();
	draw_speed();
	draw_function();
	draw_control_buttons();
	draw_io_buttons();
	draw_size();
	draw_steps();
	draw_labels();
	wnoutrefresh(menuw);

	if (dialogw) {
		draw_dialog();
	}
}