Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.atnf.csiro.au/computing/software/gipsy/pguide/gui-example8.html
Дата изменения: Unknown Дата индексирования: Sat Jan 17 05:27:20 2009 Кодировка: Поисковые слова: md-11 |
In the example program below, GgiPlotColorEditor() is called twice.
In the first call the color map manipulation element is created. The first
argument, ggiCreate, is a symbolic constant which indicates that
an element is to be created. The second and third arguments indicate the
start color index and the number of color indices (in the master color map)
to be manipulated. The last argument can be used to specify the color index
to be used for BLANK pixels. This feature is not used here. If it would,
some extra components would be added to the element. These components would
enable the user to modify the color representation of BLANK pixels.
The second call modifies the element created in the first call.
In this case data limits are specified for annotation purposes.
In this example both the plot field and the color wedge are placed in the
application's main window. An alternative would be detaching the
manipulation element from the main window and putting it in a separate
window which can be "popped up" whenever the user needs it.
How this can be done will be shown in a later example.
/* example8.c -XT */ #include "stddef.h" #include "math.h" #include "gipsyc.h" #include "cmain.h" #include "init.h" #include "finis.h" #include "userfio.h" #include "pgplot.h" #include "ggi.h" #define ROWS 100 /* number of image rows */ #define COLS 100 /* number of image columns */ #define NCI 50 /* number of color indices */ /* * QUIT= keyword handler */ static void quit(ident id, char *key, int code, void *arg) { bool button=toflog(FALSE); (void)userflog(&button, 1, 2, key, " "); if (tobool(button)) { wkeyf(key); finis_c(); } } /* * Main program */ MAIN_PROGRAM_ENTRY { ident plotter, wedge, bquit; float image[ROWS][COLS]; int i, j; float tr[6]; float a1=0.0, a2=1.0; fint idim=COLS, jdim=ROWS, i1=1, i2=COLS, j1=1, j2=ROWS; fint cilo=16, cihi=16+NCI-1; init_c(); GgiAutoLayout(FALSE); /* custom layout */ GgiPostponeRealize(TRUE); /* don't show immediately */ (void)GgiPlotColors(NULL, 16+NCI); /* NCI additional colors */ plotter = GgiPlotField("PLOT", 325, 325); /* create plot field */ GgiPlotMapColors(plotter, 0, 16, 16, NCI, -1); /* assign colors to plotter */ wedge = GgiPlotColorEditor(ggiCreate, 16, NCI, 0); /* manipulate colors */ (void)GgiPlotColorEditor(ggiLimits, wedge, 0.0, 1.0); /* set wedge range */ bquit = GgiButton("QUIT=", NULL); GgiSetPosition(plotter, 0, NULL, 0, NULL); /* top left */ GgiSetPosition(wedge, 0, NULL, 0, plotter); /* below plotter, left */ GgiSetPosition(bquit, 0, NULL, 0, wedge); /* below wedge, left */ (void)ScheduleKeyevent(quit, "QUIT=", KEYCHANGE, NULL); /* handle QUIT */ GgiRealize(); /* show what we've made */ for (j=0; j<ROWS; j++) { /* build "image" */ for (i=0; i<COLS; i++) { float x = i-COLS/2, y = j-ROWS/2, w = 3*COLS; image[j][i] = exp(-(x*x+y*y)/w); } } (void)pgopen_c(tofchar("PLOT")); /* open plotter */ pgscir_c(&cilo, &cihi); /* set color index range */ /* tranformation matrix */ tr[0] = 0.0; tr[1] = 1.0/(float)COLS; tr[2] = 0.0; tr[3] = 0.0; tr[4] = 0.0; tr[5] = 1.0/(float)ROWS; /* display image */ pgimag_c(&image[0][0], &idim, &jdim, &i1, &i2, &j1, &j2, &a1, &a2, tr); MainLoop(); }
Maintained by J. P. Terlouw |