PLplot
5.13.0
|
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 |
Variables | |
char PLDLLIMPEXP * | plplotLibDir = 0 |
static int(* | exit_handler )(PLCHAR_VECTOR errormsg) |
static void(* | abort_handler )(PLCHAR_VECTOR errormsg) |
Part 1: Color map routines. Part 2: "A grab-bag of various control routines".
Definition in file plctrl.c.
#define color_def | ( | i, | |
r, | |||
g, | |||
b, | |||
a, | |||
n | |||
) | if ( i >= imin && i <= imax ) color_set( i, r, g, b, a, n ); |
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 |
void c_plcol0 | ( | PLINT | icol0 | ) |
void c_plcol1 | ( | PLFLT | col1 | ) |
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. |
alpha | 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. |
alpha | Current alpha value of the background color. |
PLINT c_plgdrawmode | ( | void | ) |
void c_plgra | ( | void | ) |
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 |
PLFLT c_plrandd | ( | void | ) |
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_plscmap0 | ( | PLINT_VECTOR | r, |
PLINT_VECTOR | g, | ||
PLINT_VECTOR | b, | ||
PLINT | ncol0 | ||
) |
void c_plscmap0a | ( | PLINT_VECTOR | r, |
PLINT_VECTOR | g, | ||
PLINT_VECTOR | b, | ||
PLFLT_VECTOR | alpha, | ||
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. |
alpha | Array of alpha values. |
ncol0 | Total number of RGBA values. |
void c_plscmap0n | ( | PLINT | ncol0 | ) |
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. |
void c_plscmap1 | ( | PLINT_VECTOR | r, |
PLINT_VECTOR | g, | ||
PLINT_VECTOR | b, | ||
PLINT | ncol1 | ||
) |
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_plscmap1a | ( | PLINT_VECTOR | r, |
PLINT_VECTOR | g, | ||
PLINT_VECTOR | b, | ||
PLFLT_VECTOR | alpha, | ||
PLINT | ncol1 | ||
) |
void c_plscmap1l | ( | PLINT | itype, |
PLINT | npts, | ||
PLFLT_VECTOR | intensity, | ||
PLFLT_VECTOR | coord1, | ||
PLFLT_VECTOR | coord2, | ||
PLFLT_VECTOR | coord3, | ||
PLINT_VECTOR | 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 |
intensity[] | intensity index 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, | ||
PLFLT_VECTOR | intensity, | ||
PLFLT_VECTOR | coord1, | ||
PLFLT_VECTOR | coord2, | ||
PLFLT_VECTOR | coord3, | ||
PLFLT_VECTOR | alpha, | ||
PLINT_VECTOR | 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 |
intensity[] | intensity index 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 |
alpha[] | alpha value for each control point |
alt_hue_path[] | if true, use alternative hue interpolation path for the associated interval. |
void c_plscmap1n | ( | PLINT | ncol1 | ) |
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). |
alpha | 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). |
alpha | Alpha (transparency) value of the background color (0.0 - 1.0). |
void c_plscolor | ( | PLINT | color | ) |
void c_plsdrawmode | ( | PLINT | mode | ) |
void c_plseed | ( | unsigned int | seed | ) |
void c_plspal0 | ( | PLCHAR_VECTOR | filename | ) |
void c_plspal1 | ( | PLCHAR_VECTOR | filename, |
PLBOOL | interpolate | ||
) |
|
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 pl_cmd | ( | PLINT | op, |
void * | ptr | ||
) |
void plabort | ( | PLCHAR_VECTOR | 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. |
void plCloseFile | ( | PLStream * | pls | ) |
|
static |
void plcmap1_calc | ( | void | ) |
|
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 | ( | PLCHAR_VECTOR | 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. |
void plFamInit | ( | PLStream * | pls | ) |
char* plFindCommand | ( | PLCHAR_VECTOR | 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(?). |
PLINT 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. |
void plGetFam | ( | PLStream * | pls | ) |
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 | ( | PLCHAR_VECTOR | s | ) |
PLINT plGetInt | ( | PLCHAR_VECTOR | s | ) |
void plGetName | ( | PLCHAR_VECTOR | dir, |
PLCHAR_VECTOR | subdir, | ||
PLCHAR_VECTOR | 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 | ( | PLCHAR_VECTOR | fn | ) |
PDFstrm* plLibOpenPdfstrm | ( | PLCHAR_VECTOR | fn | ) |
void plP_getmember | ( | PLStream * | pls | ) |
void plP_sfnam | ( | PLStream * | pls, |
PLCHAR_VECTOR | fnam | ||
) |
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. |
void plsabort | ( | void(*)(PLCHAR_VECTOR) | handler | ) |
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(*)(PLCHAR_VECTOR) | handler | ) |
int plsnprintf | ( | char * | buffer, |
int | n, | ||
PLCHAR_VECTOR | 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 | ( | PLCHAR_VECTOR | buffer, |
int | n, | ||
PLCHAR_VECTOR | 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 | ( | PLCHAR_VECTOR | src | ) |
void plwarn | ( | PLCHAR_VECTOR | 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). |
|
static |
|
static |
char PLDLLIMPEXP* plplotLibDir = 0 |