static void update_vector_prev (void) { static gint ok = 0; gint i, x, y; gdouble dir, xo, yo; gdouble val; static gdouble last_val = 0.0; guchar gray[3] = {120, 120, 120}; guchar red[3] = {255, 0, 0}; guchar white[3] = {255, 255, 255}; if (vector_preview_brightness_adjust) val = 1.0 - gtk_adjustment_get_value (GTK_ADJUSTMENT (vector_preview_brightness_adjust)) / 100.0; else val = 0.5; if (!ok || (val != last_val)) { infile_copy_to_ppm (&update_vector_preview_backup); ppm_apply_brightness (&update_vector_preview_backup, val, 1,1,1); if ((update_vector_preview_backup.width != OMWIDTH) || (update_vector_preview_backup.height != OMHEIGHT)) resize_fast (&update_vector_preview_backup, OMWIDTH, OMHEIGHT); ok = 1; } ppm_copy (&update_vector_preview_backup, &update_vector_preview_buffer); for (i = 0; i < num_vectors; i++) { gdouble s; x = vector[i].x * OMWIDTH; y = vector[i].y * OMHEIGHT; dir = gimp_deg_to_rad (vector[i].dir); s = gimp_deg_to_rad (vector[i].str); xo = sin (dir) * (6.0+100*s); yo = cos (dir) * (6.0+100*s); if (i == selectedvector) { ppm_drawline (&update_vector_preview_buffer, x - xo, y - yo, x + xo, y + yo, red); } else { ppm_drawline (&update_vector_preview_buffer, x - xo, y - yo, x + xo, y + yo, gray); } ppm_put_rgb (&update_vector_preview_buffer, x - xo, y - yo, white); } gimp_preview_area_draw (GIMP_PREVIEW_AREA (vector_preview), 0, 0, OMWIDTH, OMHEIGHT, GIMP_RGB_IMAGE, (guchar *)update_vector_preview_buffer.col, OMWIDTH * 3); }
static void updatesmvectorprev (void) { static int ok = 0; gint i, x, y; gdouble val; static gdouble last_val = 0.0; guchar gray[3] = {120, 120, 120}; guchar red[3] = {255, 0, 0}; guchar white[3] = {255, 255, 255}; if (smvectprevbrightadjust) val = 1.0 - gtk_adjustment_get_value (GTK_ADJUSTMENT (smvectprevbrightadjust)) / 100.0; else val = 0.5; if (!ok || (val != last_val)) { #if 0 if (!PPM_IS_INITED (&infile)) updatepreview (NULL, (void *)2); /* Force grabarea () */ ppm_copy (&infile, &update_vector_preview_backup); #else infile_copy_to_ppm (&update_vector_preview_backup); #endif ppm_apply_brightness (&update_vector_preview_backup, val, 1,1,1); if (update_vector_preview_backup.width != OMWIDTH || update_vector_preview_backup.height != OMHEIGHT) resize_fast (&update_vector_preview_backup, OMWIDTH, OMHEIGHT); ok = 1; } ppm_copy (&update_vector_preview_backup, &update_vector_preview_sbuffer); for (i = 0; i < numsmvect; i++) { x = smvector[i].x * OMWIDTH; y = smvector[i].y * OMHEIGHT; if (i == selectedsmvector) { ppm_drawline (&update_vector_preview_sbuffer, x-5, y, x+5, y, red); ppm_drawline (&update_vector_preview_sbuffer, x, y-5, x, y+5, red); } else { ppm_drawline (&update_vector_preview_sbuffer, x-5, y, x+5, y, gray); ppm_drawline (&update_vector_preview_sbuffer, x, y-5, x, y+5, gray); } ppm_put_rgb (&update_vector_preview_sbuffer, x, y, white); } gimp_preview_area_draw (GIMP_PREVIEW_AREA (smvectorprev), 0, 0, OMWIDTH, OMHEIGHT, GIMP_RGB_IMAGE, update_vector_preview_sbuffer.col, OMWIDTH * 3); gtk_widget_set_sensitive (prev_button, (numsmvect > 1)); gtk_widget_set_sensitive (next_button, (numsmvect > 1)); gtk_widget_set_sensitive (add_button, (numsmvect < MAXORIENTVECT)); gtk_widget_set_sensitive (kill_button, (numsmvect > 1)); }