#include "xmfract.h" #include "fractype.h" #include "macros.h" #include "helpdefs.h" #include "mpmath.h" #include "globals.h" #include "prototyp.h" #ifndef NO_IDENT #ident "$Id: create_image.c,v 1.400 1995/06/20 15:39:23 darryl Exp $" #endif /*ARGSUSED*/ void create_image_cb( Widget w, XtPointer client_data, XtPointer call_data) { int i, ret, done; double ftemp; char msg[256]; XEvent event; Boolean stat1; Boolean stat2; Boolean stat3; if(fractype == NOFRACTAL) { sprintf((char *) &msg, "No fractal type selected."); inform(main_window, (char *) &msg, NULL); return; } if(calc_status == IMG_ACTV_CALC || calc_status == IMG_INTR_RESM) { if(curfractalspecific->flags&NORESUME) { sprintf((char *) &msg, "This fractal type cannot be resumed. If you wish to re-calculate\nthis image using the same paramters, first clear the screen by\ninvoking the Clear Screen item from the Reset menu."); caution(main_window, (char *) &msg, NULL); return; } } if(calc_status == IMG_INTR_NRES) { sprintf((char *) &msg, "This fractal type cannot be resumed. If you wish to re-calculate\nthis image using the same paramters, first clear the screen by\ninvoking the Clear Screen item from the Reset menu."); caution(main_window, (char *) &msg, NULL); return; } if(calc_status == IMG_COMPLETED && !rubber_band_data.boxisactive) { sprintf((char *) &msg, "Parameters for this image have not changed.\n\nRe-calculate anyway?"); ret = confirm(main_window, (char *) &msg, OK_BTN | CANCEL_BTN, XmDIALOG_CANCEL_BUTTON); if(ret != 1) return; } if((xdots < window_presets.min_width || xdots > window_presets.max_width || ydots < window_presets.min_height || ydots > window_presets.max_height) && (!viewwindow)) { sprintf((char *) &msg, "The canvas is too small or too large to calculate an image.\n\nPlease resize the main window."); ret = confirm(main_window, (char *) &msg, OK_BTN | CANCEL_BTN, XmDIALOG_OK_BUTTON); if(ret != 1) return; else window_size_cb(main_window, NULL, NULL); return; } if(display3d) { showfile = 0; if(mapset) mapset = 0; display_file(); display3d = 0; return; } XDefineCursor(display, window, XCreateFontCursor(display, XC_watch)); if(rubber_band_data.boxisactive) { zrotate = 0; zskew = 0; zbx = (MIN(rubber_band_data.tl_x,rubber_band_data.br_x)-sxoffs)/dx_size; zby = (MIN(rubber_band_data.tl_y,rubber_band_data.br_y)-syoffs)/dy_size; zwidth = ABS(rubber_band_data.br_x-rubber_band_data.tl_x)/dx_size; zdepth = zwidth; rubber_band_data.boxisactive = 0; drawbox(); init_pan_or_recalc(0); update_zoom_menu(); } ok_to_cycle = 0; resize_window(main_window, NULL, NULL); if(viewwindow) { ftemp = finalaspectratio * (double)sydots / (double)sxdots / screenaspect; if ((xdots = viewxdots)) /* xdots specified */ { /* calc ydots? */ if ((ydots = viewydots) == 0) { ydots = (double)xdots * ftemp + 0.5; } } else { if (finalaspectratio <= screenaspect) { xdots = (double)sxdots / viewreduction + 0.5; ydots = (double)xdots * ftemp + 0.5; } else { ydots = (double)sydots / viewreduction + 0.5; xdots = (double)ydots / ftemp + 0.5; } } if (xdots > sxdots || ydots > sydots) { static char mesg[] = {"View window too large; using full screen."}; inform(main_window, (char *) &mesg, NULL); xdots = sxdots; ydots = sydots; } else if (xdots <= sxdots/20 || ydots <= sydots/20) /* so ssg works */ { static char message[] = {"View window too small; using full screen."}; inform(main_window, (char *) &message, NULL); xdots = sxdots; ydots = sydots; } sxoffs = (sxdots - xdots) / 2; syoffs = (sydots - ydots) / 3; if(xdots < window_presets.min_width || xdots > window_presets.max_width || ydots < window_presets.min_height || ydots > window_presets.max_height) { sprintf((char *) &msg, "The canvas is too small or too large to calculate an image.\n\nPlease resize the main window or turn off the preview mode."); ret = confirm(main_window, (char *) &msg, OK_BTN | CANCEL_BTN, XmDIALOG_OK_BUTTON); if(ret != 1) return; else window_size_cb(main_window, NULL, NULL); return; } } else if(sxoffs || syoffs || viewxdots || viewydots) { sxoffs = syoffs = 0; viewxdots = viewydots = 0; sxdots = videotable[0].xdots; sydots = videotable[0].ydots; xdots = sxdots; ydots = sydots; dx_size = xdots - 1; dy_size = ydots - 1; } dx_size = xdots - 1; dy_size = ydots - 1; if(calc_status <= IMG_PRMS_CHGD) clear_window(); calcfracinit(); /* save 3 corners for zoom.c ref points */ sxmin = xxmin; sxmax = xxmax; sx3rd = xx3rd; symin = yymin; symax = yymax; sy3rd = yy3rd; /* initialize the history file */ if (history[0].fractype == -1) { histocycle = 0; for (i = 0; i < MAXHISTORY; i++) { int j; historymax = -1; history[i].xxmax = xxmax; history[i].xxmin = xxmin; history[i].yymax = yymax; history[i].yymin = yymin; history[i].xx3rd = xx3rd; history[i].yy3rd = yy3rd; for(j=0;j IMG_INTR_NRES) || (rubber_band_data.panning == 1))) { int j; rubber_band_data.panning = 0; if(++historyptr == MAXHISTORY) { historymax = MAXHISTORY; historyptr = 0; histocycle = 1; } else if(historymax == MAXHISTORY) { if(historyptr >= MAXHISTORY) historyptr = 0; } else { historyptr = ++historymax; if(historyptr >= MAXHISTORY) { historymax = MAXHISTORY; historyptr = 0; histocycle = 1; } } history[historyptr].xxmax = xxmax; history[historyptr].xxmin = xxmin; history[historyptr].yymax = yymax; history[historyptr].yymin = yymin; history[historyptr].xx3rd = xx3rd; history[historyptr].yy3rd = yy3rd; for(j=0;jflags&NOZOOM))) toggle_zoom_grab(ZOOM_ON); XDefineCursor(display, window, XCreateFontCursor(display, XC_top_left_arrow)); buzzer(0); } void create_previous_image(int which) { int j; if(which < 10) { for(j = 0; j < which; j++) if(--historyptr < 0) historyptr = MAXHISTORY; } else { for(j = 0; j < which - 10; j++) if(++historyptr == MAXHISTORY) historyptr = 0; } xxmax = history[historyptr].xxmax; xxmin = history[historyptr].xxmin; yymax = history[historyptr].yymax; yymin = history[historyptr].yymin; xx3rd = history[historyptr].xx3rd; yy3rd = history[historyptr].yy3rd; for(j=0;j