void regenerer_test(TxDonneesFenetre *onglet_leto) { type_groupe *groupe1, *groupe2, *groupe; type_liaison * liaison; TxPoint point; int i, j, largeur = 0, hauteur = 0; if (!GDK_IS_DRAWABLE(onglet_leto->pixmap)) { return; } init_cairo(onglet_leto); groupe = sc->deb_groupe; liaison = sc->deb_liaison; point.x = sc->xmin; point.y = sc->ymin; TxDessinerRectangle(onglet_leto, sc->couleur_fond, TxPlein, point, sc->xmax - sc->xmin, sc->ymax - sc->ymin, 0);/* background */ for (i = 0; i < limite_nbre_max_ech; i++) { sc->boite_x_min[i] = 999999; sc->boite_y_min[i] = 999999; sc->boite_x_max[i] = 0; sc->boite_y_max[i] = 0; } sc->nbre_max_ech = -1; while (groupe != NULL) { point.x = groupe->posx; point.y = groupe->posy; if (groupe->posx > sc->xmin && groupe->posy > sc->ymin && groupe->posx < sc->xmax && groupe->posy < sc->ymax) if (sc->display_plane[abs(groupe->reverse)] == 1 && (groupe->deja_active == 0 || sc->show_sub_networks == 1)) { if (groupe->type != No_Sub_Network) affiche_groupe(point, groupe, onglet_leto); else affiche_macro(point, groupe, onglet_leto); } if (groupe->ech_temps > sc->nbre_max_ech) sc->nbre_max_ech = groupe->ech_temps; if (sc->boite_x_min[groupe->ech_temps] > point.x) sc->boite_x_min[groupe->ech_temps] = point.x; if (sc->boite_y_min[groupe->ech_temps] > point.y) sc->boite_y_min[groupe->ech_temps] = point.y; if (sc->boite_x_max[groupe->ech_temps] < point.x) sc->boite_x_max[groupe->ech_temps] = point.x; if (sc->boite_y_max[groupe->ech_temps] < point.y) sc->boite_y_max[groupe->ech_temps] = point.y; groupe = groupe->s; } liaison = sc->deb_liaison; while (liaison != NULL) { if (liaison->depart >= 0) /* ne pas s'occuper de la premiere liaison qui lie micro-neurone et macro-neurone */ /* typage general, pas vraie connexion */ { groupe1 = trouver_groupe(liaison->depart); if (groupe1 == NULL) { printf("\nListe des groupes existants = \n\n"); affiche_liste_groupes(); EXIT_ON_ERROR("Le gpe1 %d %s de la liaison n'a pas ete trouve liaison->depart \n", liaison->depart, liaison->depart_name); } groupe2 = trouver_groupe(liaison->arrivee); if (groupe2 == NULL) { printf("\nListe des groupes existants = \n\n"); affiche_liste_groupes(); EXIT_ON_ERROR("Le gpe2 %d %s de la liaison n'a pas ete trouve liaison->depart \n", liaison->arrivee, liaison->arrivee_name); } if ((groupe1->posx < sc->xmin && groupe2->posx < sc->xmin) || (groupe1->posx > sc->xmax && groupe2->posx > sc->xmax) || (groupe1->posy < sc->ymin && groupe2->posy < sc->ymin) || (groupe1->posy > sc->ymax && groupe2->posy > sc->ymax)) { liaison = liaison->s; continue; } if (sc->display_plane[abs(groupe1->reverse)] == 1 && sc->display_plane[abs(groupe2->reverse)] == 1 && (sc->show_sub_networks == 1 || liaison->deja_active == 0)) affiche_liaison(liaison, groupe1, groupe2, onglet_leto); } liaison = liaison->s; } for (i = 0; i <= sc->nbre_max_ech; i++) for (j = i + 1; j <= sc->nbre_max_ech; j++) { if (sc->boite_x_min[j] > sc->boite_x_min[i]) sc->boite_x_min[j] = sc->boite_x_min[i]; if (sc->boite_y_min[j] > sc->boite_y_min[i]) sc->boite_y_min[j] = sc->boite_y_min[i]; if (sc->boite_x_max[j] < sc->boite_x_max[i]) sc->boite_x_max[j] = sc->boite_x_max[i]; if (sc->boite_y_max[j] < sc->boite_y_max[i]) sc->boite_y_max[j] = sc->boite_y_max[i]; } for (i = 0; i <= sc->nbre_max_ech; i++) { if (sc->boite_x_min[i] <= sc->boite_x_max[i] && sc->boite_y_min[i] <= sc->boite_y_max[i]) { point.x = sc->boite_x_min[i] - distc - 2 * deltax; point.y = sc->boite_y_min[i] - (2 * deltay + i * 5); largeur = sc->boite_x_max[i] - point.x + distc + 2 * deltax + 5 * i; hauteur = sc->boite_y_max[i] - point.y + 4 * deltay + 5 * i; TxDessinerRectangle(onglet_leto, lut_g[i], TxVide, point, largeur, hauteur, 2); } } TxFlushDessin(onglet_leto, sc->xmin, sc->ymin, sc->xmax - sc->xmin, sc->ymax - sc->ymin); }
static int gra2cairofile_output(struct objlist *obj, N_VALUE *inst, N_VALUE *rval, int argc, char **argv) { char code, *fname; int *cpar, format, r; struct gra2cairo_local *local; cairo_surface_t *surface; local = (struct gra2cairo_local *)argv[2]; code = *(char *)(argv[3]); cpar = (int *)argv[4]; switch (code) { case 'I': r = init_cairo(obj, inst, local, cpar[3], cpar[4]); if (r) { _getobj(obj, "file", inst, &fname); error2(obj, r + 100, fname); return 1; } break; case 'E': _getobj(obj, "format", inst, &format); if (local->cairo) { switch (format) { case TYPE_PNG: gra2cairo_draw_path(local); _getobj(obj, "file", inst, &fname); if (fname == NULL) return 1; #if WINDOWS fname = g_locale_from_utf8(fname, -1, NULL, NULL, NULL); #else /* WINDOWS */ fname = g_filename_from_utf8(fname, -1, NULL, NULL, NULL); #endif /* WINDOWS */ if (fname == NULL) { error(obj, CAIRO_STATUS_NO_MEMORY + 100); return 1; } surface = cairo_get_target(local->cairo); r = cairo_surface_write_to_png(surface, fname); g_free(fname); if (r) { _getobj(obj, "file", inst, &fname); error2(obj, r + 100, fname); return 1; } break; #ifdef CAIRO_HAS_WIN32_SURFACE case TYPE_EMF: gra2cairo_draw_path(local); surface = cairo_get_target(local->cairo); r = close_emf(surface); if (r) { _getobj(obj, "file", inst, &fname); error2(obj, CAIRO_STATUS_WRITE_ERROR + 100, fname); return 1; } break; #endif /* CAIRO_HAS_WIN32_SURFACE */ } } break; } if (_exeparent(obj, (char *)argv[1], inst, rval, argc, argv)) return 1; return 0; }