PLplot
5.9.9
|
Go to the source code of this file.
Macros | |
#define | DEBUG |
#define | NEED_PLDEBUG |
#define | BUFFER_SIZE 256 |
#define | COLLEN 30 |
#define | PALLEN 160 |
#define | MSGLEN 1024 |
#define | FUZZ_EPSILON 1.e-4 |
#define | PLLIBDEV "/usr/local/plplot/lib" |
#define | color_def(i, r, g, b, a, n) if ( i >= imin && i <= imax ) color_set( i, r, g, b, a, n ); |
#define | fuzzy_range_check(value, min, max, fuzz, err_number) |
#define | MAX_NUM_TRIES 10 |
Functions | |
static void | color_set (PLINT i, U_CHAR r, U_CHAR g, U_CHAR b, PLFLT a, const char *name) |
static void | strcat_delim (char *dirspec) |
static void | plcmap0_def (int imin, int imax) |
static void | plcmap1_def (void) |
static PLFLT | value (double n1, double n2, double hue) |
static char * | read_line (char *buffer, int length, FILE *fp) |
static void | cmap0_palette_read (const char *filename, int *number_colors, unsigned int **r, unsigned int **g, unsigned int **b, double **a) |
void | c_plcol0 (PLINT icol0) |
void | c_plcol1 (PLFLT col1) |
void | c_plscolbg (PLINT r, PLINT g, PLINT b) |
void | c_plscolbga (PLINT r, PLINT g, PLINT b, PLFLT a) |
void | c_plgcolbg (PLINT *r, PLINT *g, PLINT *b) |
void | c_plgcolbga (PLINT *r, PLINT *g, PLINT *b, PLFLT *a) |
void | c_plscol0 (PLINT icol0, PLINT r, PLINT g, PLINT b) |
void | c_plscol0a (PLINT icol0, PLINT r, PLINT g, PLINT b, PLFLT a) |
void | c_plgcol0 (PLINT icol0, PLINT *r, PLINT *g, PLINT *b) |
void | c_plgcol0a (PLINT icol0, PLINT *r, PLINT *g, PLINT *b, PLFLT *a) |
void | c_plscmap0 (const PLINT *r, const PLINT *g, const PLINT *b, PLINT ncol0) |
void | c_plscmap0a (const PLINT *r, const PLINT *g, const PLINT *b, const PLFLT *a, PLINT ncol0) |
void | c_plscmap1 (const PLINT *r, const PLINT *g, const PLINT *b, PLINT ncol1) |
void | c_plscmap1a (const PLINT *r, const PLINT *g, const PLINT *b, const PLFLT *a, PLINT ncol1) |
void | c_plscmap1l (PLINT itype, PLINT npts, const PLFLT *pos, const PLFLT *coord1, const PLFLT *coord2, const PLFLT *coord3, const PLINT *alt_hue_path) |
void | c_plscmap1la (PLINT itype, PLINT npts, const PLFLT *pos, const PLFLT *coord1, const PLFLT *coord2, const PLFLT *coord3, const PLFLT *a, const PLINT *alt_hue_path) |
void | plcmap1_calc (void) |
void | c_plscmap1_range (PLFLT min_color, PLFLT max_color) |
void | c_plgcmap1_range (PLFLT *min_color, PLFLT *max_color) |
void | c_plscmap0n (PLINT ncol0) |
void | c_plscmap1n (PLINT ncol1) |
void | c_plscolor (PLINT color) |
void | c_plhlsrgb (PLFLT h, PLFLT l, PLFLT s, PLFLT *p_r, PLFLT *p_g, PLFLT *p_b) |
void | c_plrgbhls (PLFLT r, PLFLT g, PLFLT b, PLFLT *p_h, PLFLT *p_l, PLFLT *p_s) |
void | c_plspal0 (const char *filename) |
void | c_plspal1 (const char *filename, PLBOOL interpolate) |
void | plwarn (const char *errormsg) |
void | plabort (const char *errormsg) |
void | plsabort (void(*handler)(const char *)) |
void | plexit (const char *errormsg) |
void | plsexit (int(*handler)(const char *)) |
void | c_plgra (void) |
void | c_plxormod (PLINT mode, PLINT *status) |
void | c_plsdrawmode (PLINT mode) |
PLINT | c_plgdrawmode () |
void | c_pltext (void) |
Switches to text screen. More... | |
void | pl_cmd (PLINT op, void *ptr) |
char * | plFindCommand (const char *fn) |
FILE * | plLibOpen (const char *fn) |
PDFstrm * | plLibOpenPdfstrm (const char *fn) |
int | plFindName (char *p) |
void | plGetName (const char *dir, const char *subdir, const char *filename, char **filespec) |
void | plcol_interp (PLStream *pls, PLColor *newcolor, int i, int ncol) |
void | plOpenFile (PLStream *pls) |
void | plCloseFile (PLStream *pls) |
void | plP_getmember (PLStream *pls) |
void | plP_sfnam (PLStream *pls, const char *fnam) |
void | plFamInit (PLStream *pls) |
void | plGetFam (PLStream *pls) |
void | plRotPhy (PLINT orient, PLINT xmin, PLINT ymin, PLINT xmax, PLINT ymax, PLINT *px, PLINT *py) |
PLDev * | plAllocDev (PLStream *pls) |
void | plGinInit (PLGraphicsIn *gin) |
PLINT | plGetInt (const char *s) |
PLFLT | plGetFlt (const char *s) |
char PLDLLIMPEXP * | plstrdup (const char *src) |
int | plsnprintf (char *buffer, int n, const char *format,...) |
int | plsnscanf (const char *buffer, int n, const char *format,...) |
void | c_plseed (unsigned int s) |
PLFLT | c_plrandd (void) |
char * | plsave_set_locale (void) |
void | plrestore_locale (char *saved_lc_numeric_locale) |
Variables | |
char PLDLLIMPEXP * | plplotLibDir = 0 |
static int(* | exit_handler )(const char *errormsg) |
static void(* | abort_handler )(const char *errormsg) |
Part 1: Color map routines. Part 2: "A grab-bag of various control routines".
Definition in file plctrl.c.
This code fragment used a lot in plspal1 to deal with floating-point range checking of a value and the adjustment of that value when close to the range when there is floating-point errors.
value | The value to range check. |
min | The minimum allowable value. |
max | The maximum allowable value. |
fuzz | Amount of slop to allow beyond the range defined by min & max. |
err_number | The error number. |
#define MAX_NUM_TRIES 10 |
Returns 8 bit RGB values for given color from color map 0 Values are negative if an invalid color id is given
icol0 | Index of the color to be return (0 - plsc->ncol0). |
r | Current red value of the color. |
g | Current green value of the color. |
b | Current blue value of the color. |
Returns 8 bit RGB values for given color from color map 0 and alpha value Values are negative if an invalid color id is given
icol0 | Index of the color to be return (0 - plsc->ncol0). |
r | Current red value of the color. |
g | Current green value of the color. |
b | Current blue value of the color. |
a | Current alpha value of the color. |
Returns the background color (cmap0[0]) by 8 bit RGB value and alpha value
r | Current red value of the background color. |
g | Current green value of the background color. |
b | Current blue value of the background color. |
a | Current alpha value of the background color. |
Convert HLS color to RGB color. Bounds on HLS (input): hue [0., 360.] degrees lightness [0., 1.] magnitude saturation [0., 1.] magnitude
Hue is always mapped onto the interval [0., 360.] regardless of input. Bounds on RGB (output) is always [0., 1.]. Convert to RGB color values by multiplying by 2**nbits (nbits typically 8).
h | hue in HLS color scheme (0.0 - 360.0) |
l | lightness in HLS color scheme (0.0 - 1.0) |
s | saturation in HLS color scheme (0.0 - 1.0) |
p_r | red value of the HLS color |
p_g | green value of the HLS color |
p_b | blue value of the HLS color |
Convert RGB color to HLS color. Bounds on RGB (input) is always [0., 1.]. Bounds on HLS (output): hue [0., 360.] degrees lightness [0., 1.] magnitude saturation [0., 1.] magnitude
r | red in RGB color scheme (0.0 - 1.0) |
g | green in RGB color scheme (0.0 - 1.0) |
b | blue in RGB color scheme (0.0 - 1.0) |
p_h | hue value of the RGB color. |
p_l | lightness value of the RGB color. |
p_s | saturation value of the RGB color. |
void c_plscmap0a | ( | const PLINT * | r, |
const PLINT * | g, | ||
const PLINT * | b, | ||
const PLFLT * | a, | ||
PLINT | ncol0 | ||
) |
Set color map 0 colors by 8 bit RGB and alpha value. This sets the entire color map – only as many colors as specified will be allocated.
r | Array of red values. |
g | Array of green values. |
b | Array of blue values. |
a | Array of alpha values. |
ncol0 | Total number of RGBA values. |
Set number of colors in cmap 0, (re-)allocate cmap 0, and fill with default values for those colors not previously allocated (and less than index 15, after that you just get grey).
The driver is not guaranteed to support all of these.
ncol0 | Total number of colors. |
Set the color map 1 value range to use in continuous color plots.
min_color | Specifies the minimum color to use. A value of 0.0 or less indicates that the range should start at the lowest color map 1 value available. |
max_color | Specifies the maximum color to use. A value of 1.0 or greater indicates that the range should exten to the highest color map 1 value available. |
If min_color > max_color or min_color is greater than 1.0 or max_color is less than 0.0 then no change is made.
void c_plscmap1l | ( | PLINT | itype, |
PLINT | npts, | ||
const PLFLT * | pos, | ||
const PLFLT * | coord1, | ||
const PLFLT * | coord2, | ||
const PLFLT * | coord3, | ||
const PLINT * | alt_hue_path | ||
) |
Set color map 1 colors using a piece-wise linear relationship between position in the color map (from 0 to 1) and position in HLS or RGB color space. May be called at any time.
The idea here is to specify a number of control points that specify the mapping between HLS (or RGB or CMY) and palette 1 value. Between these points, linear interpolation is used. By mapping position in the color map to function value, this gives a smooth variation of color with intensity. Any number of control points may be specified, located at arbitrary positions (intensities), although typically 2 - 4 are enough. Another way of stating this is that we are traversing a given number of lines through HLS (or RGB) space as we move through cmap 1 entries. The control points at the minimum and maximum intensity (0 and 1) must always be specified. By adding more control points you can get more variation. One good technique for plotting functions that vary about some expected average is to use an additional 2 control points in the center (intensity ~= 0.5) that are the same color as the background (typically white for paper output, black for crt), and same hue as the boundary control points. This allows the highs and lows to be very easily distinguished.
Each control point must specify the position in cmap 1 as well as three coordinates in HLS or RGB space. The first point MUST correspond to position = 0, and the last to position = 1.
Every change in hue from one control point to the next can be linearly interpolated in two ways. The usual (alt_hue_path[i] false) method for the ith interval uses the dh = h[i+1] - h[i] interval for interpolation. The alternate (alt_hue_path true) method for the ith interval uses the dh = (h[i+1] - h[i]) - 360 if (h[i+1] - h[i]) is positive or dh = 360 - (h[i+1] - h[i]) if (h[i+1] - h[i]) is negative interval for the interpolation. Thus, alt_hue_path true interpolation intervals always include hue = 0. Specifying alt_hue_path=NULL is equivalent to setting alt_hue_path[]=false for every control point.
Bounds on RGB coordinates: R,G,B [0, 1] magnitude
Bounds on HLS coordinates: hue [0, 360] degrees lightness [0, 1] magnitude saturation [0, 1] magnitude
The inputs are:
itype | 0: HLS, 1: RGB |
npts | number of control points |
pos[] | position for each control point |
coord1[] | first coordinate for each control point |
coord2[] | second coordinate for each control point |
coord3[] | third coordinate for each control point |
alt_hue_path[] | if true, use alternative hue interpolation path for the associated interval. |
void c_plscmap1la | ( | PLINT | itype, |
PLINT | npts, | ||
const PLFLT * | pos, | ||
const PLFLT * | coord1, | ||
const PLFLT * | coord2, | ||
const PLFLT * | coord3, | ||
const PLFLT * | a, | ||
const PLINT * | alt_hue_path | ||
) |
This is the same as plscmap1l, but also allows alpha value interpolation.
itype | 0: HLS, 1: RGB |
npts | number of control points |
pos[] | position for each control point |
coord1[] | first coordinate for each control point |
coord2[] | second coordinate for each control point |
coord3[] | third coordinate for each control point |
a[] | alpha value for each control point |
alt_hue_path[] | if true, use alternative hue interpolation path for the associated interval. |
Set number of colors in cmap 1, (re-)allocate cmap 1, and set default values if this is the first allocation.
Note that the driver is allowed to disregard this number. In particular, most use fewer than we use internally.
ncol1 | The number of colors in cmap1. |
Set a given color from color map 0 by 8 bit RGB value Does not result in any additional cells to be allocated.
icol0 | index of the color to set (0 - plsc->ncol0) |
r | Red value of the color (0 - 255). |
g | Green value of the color (0 - 255). |
b | Blue value of the color (0 - 255). |
Set a given color from color map 0 by 8 bit RGB value and alpha value. Does not result in any additional cells to be allocated.
icol0 | index of the color to set (0 - plsc->ncol0) |
r | Red value of the color (0 - 255). |
g | Green value of the color (0 - 255). |
b | Blue value of the color (0 - 255). |
a | Alpha value of the color (0.0 - 1.0). |
Set the background color (cmap0[0]) by 8 bit RGB value and alpha value
r | Red value of the background color (0 - 255). |
g | Green value of the background color (0 - 255). |
b | Blue value of the background color (0 - 255). |
a | Alpha (transparency) value of the background color (0.0 - 1.0). |
void c_plseed | ( | unsigned int | s) |
void c_plspal0 | ( | const char * | filename) |
|
static |
Read and check r, g, b, a data from a cmap0*.pal format file. The caller must free the returned malloc'ed space for r, g, b, and a.
filename | name of the cmap0 palette file. |
number_colors | number of color found in the palette file. |
r | red value of each color in the palette file. |
g | green value of each color in the palette file. |
b | blue value of each color in the palette file. |
a | alpha value of each color in the palette file. |
void plabort | ( | const char * | errormsg) |
Much the same as plwarn(), but appends ", aborting operation" to the error message. Helps to keep source code uncluttered and provides a convention for error aborts.
If cleanup needs to be done in the main program, the user should write his/her own exit handler and pass it in via plsabort().
errormsg | The error message. |
|
static |
Initializes color map 1.
The default initialization uses 6 control points in HLS space, the inner ones being very close to one of the vertices of the HLS double cone. The vertex used (black or white) is chosen to be the closer to the background color. The 6 points were chosen over the older 4 points in order to make weaker structures more easily visible, and give more control through the palette editor. If you don't like these settings.. change them!
Initializes device cmap 1 entry by interpolation from pls->cmap1 entries. Returned PLColor is supposed to represent the i_th color out of a total of ncol colors in the current color scheme.
pls | A plot stream structure. |
newcolor | A color structure to store the color in. |
i | Index of the desired color. |
ncol | Total number of colors (supported by the device?). |
void plexit | ( | const char * | errormsg) |
In case of an abort this routine is called. It just prints out an error message and tries to clean up as much as possible. It's best to turn off pause and then restore previous setting before returning.
If cleanup needs to be done in the main program, the user should write his/her own exit handler and pass it in via plsexit(). This function should should either call plend() before exiting, or simply return.
errormsg | The error message. |
char* plFindCommand | ( | const char * | fn) |
Looks for the specified executable file. Search path: if command invoked in the build tree: build_tree/tk (plserver lies there - needed for the tk driver) source_tree/scripts (plpr lies there - needed for the tk driver) else PLPLOT_BIN_ENV = current directory PLPLOT_HOME_ENV/bin = /bin BIN_DIR
The caller must free the returned pointer (points to malloc'ed memory) when finished with it.
fn | Name of the executable(?). |
int plFindName | ( | char * | p) |
Authors: Paul Dubois (LLNL), others? This function is in the public domain.
Given a pathname, determine if it is a symbolic link. If so, continue searching to the ultimate terminus - there may be more than one link. Use the error value to determine when the terminus is reached, and to determine if the pathname really exists. Then stat it to determine whether it's executable. Return 0 for an executable, errno otherwise. Note that 'p' must have at least one '/' character - it does by construction in this program. The contents of the array pointed to by 'p' are changed to the actual pathname if findname is successful.
This function is only defined under Unix for now.
p | Name of the executable to find. |
Starts new member file of family file set if necessary.
Note each member file is a complete graphics file (can be printed individually), although 'plrender' will treat a family as a single logical file if given the family name instead of the member name.
pls | A plot stream structure. |
PLFLT plGetFlt | ( | const char * | s) |
PLINT plGetInt | ( | const char * | s) |
void plGetName | ( | const char * | dir, |
const char * | subdir, | ||
const char * | filename, | ||
char ** | filespec | ||
) |
Gets search name for file by concatenating the dir, subdir, and file name, allocating memory as needed. The appropriate delimiter is added after the dir specification as necessary. The caller is responsible for freeing the malloc'ed memory.
dir | The directory name. |
subdir | The sub-directory name. |
filename | The file name. |
filespec | The result of concatenating dir, subdir and filename. |
void plGinInit | ( | PLGraphicsIn * | gin) |
Just fills in the PLGraphicsIn with appropriate initial values.
gin | A plot graphics input (i.e. keypress or mouseclick) structure. |
FILE* plLibOpen | ( | const char * | fn) |
PDFstrm* plLibOpenPdfstrm | ( | const char * | fn) |
void plrestore_locale | ( | char * | saved_lc_numeric_locale) |
void plRotPhy | ( | PLINT | orient, |
PLINT | xmin, | ||
PLINT | ymin, | ||
PLINT | xmax, | ||
PLINT | ymax, | ||
PLINT * | px, | ||
PLINT * | py | ||
) |
Rotates physical coordinates if necessary for given orientation. Each time orient is incremented, the plot is rotated 90 deg clockwise. Note: this is now used only to rotate by 90 degrees for devices that expect portrait mode.
orient | New plot orientation (0-3) |
xmin | Current plot x minimum? |
ymin | Current plot y minimum? |
xmax | Current plot x maximum? |
ymax | Current plot y maximum? |
px | Old x coordinate mapped to new x coordinate. |
py | Old y coordinate mapped to new y coordinate. |
char* plsave_set_locale | ( | void | ) |
Save LC_NUMERIC locale in a string. The pointer to that string is returned. Then set LC_NUMERIC to "C" locale. n.b. plsave_set_locale and plrestore_locale should always be used as a pair to surround PLplot code that absolutely requires the LC_NUMERIC "C" locale to be in effect. It is one of plrestore_locale's responsibilities to free the memory allocated here for the locale string.
void plsexit | ( | int(*)(const char *) | handler) |
int plsnprintf | ( | char * | buffer, |
int | n, | ||
const char * | format, | ||
... | |||
) |
Dummy function for snprintf(). This function just calls the unsafe function ignoring the string size. This function will rarely be needed if ever.
buffer | String output buffer. |
n | Size of buffer. |
format | The format string. |
... | The values that go in the format string (...) |
int plsnscanf | ( | const char * | buffer, |
int | n, | ||
const char * | format, | ||
... | |||
) |
Dummy function for snscanf(). This function just calls the unsafe function ignoring the string size. This function will rarely be needed if ever.
buffer | String output buffer. |
n | Size of buffer. |
format | The format string. |
... | The values that go in the format string (...) |
char PLDLLIMPEXP* plstrdup | ( | const char * | src) |
void plwarn | ( | const char * | errormsg) |
|
static |
Read a complete line and fill the buffer with its contents up to capacity. Then sanitize the string - no control characters, no trailing blanks
buffer | storage for the line of text. |
length | size of the buffer. |
fp | open file pointer from which the line of text should be read. |
|
static |
|
static |
Auxiliary function used by c_plhlsrgb().
n1 | Lightness/saturation value 1. |
n2 | Lightness/saturation value 2. |
hue | hue (0.0 - 360.0). |
char PLDLLIMPEXP* plplotLibDir = 0 |