next up previous contents
Next: Gathering Performance Data Up: MPE Graphics Previous: Overview

Details on some MPE Graphics Routines

MPE_Open_graphics (MPE_XGraph *window, MPI_Comm comm, char *display, int x,int y,
int width, int height, int is_collective);

Open a window at x, y of size width, height. If you pass -1 for x and y, the user will be required to position the window. If NULL is passed for display, then the display will be configured automatically. Always pass 0 for is_collective. MPE_Open_graphics must be called on all nodes in comm. Don't forget to pass the address of your window!

MPE_Close_graphics (MPE_XGraph *window);

Close the window associated with window. All processes must call this routine. Once any process has called MPE_Close_graphics, no process can call any other MPE routine. Don't forget to pass the address of your window!

MPE_Draw_point (MPE_XGraph window, int x, int y, MPE_Color color);

Draw a pixel at (x, y). Initially, MPE_Color can be one of: MPE_WHITE, MPE_BLACK, MPE_RED, MPE_YELLOW, MPE_GREEN, MPE_CYAN, and MPE_BLUE. You may change the available colors using MPE_Make_color_array and MPE_Add_RGB_color (see these routines' man pages). Note that the point may not actually be drawn until you call MPE_Update.

MPE_Draw_points (MPE_XGraph window, const MPE_Point *points, int npoints);

Draws a series of points at once. points should point to an array of MPE_Point structures. Here's the form of an MPE_Point:

  typedef struct {     
    int x, y;
    MPE_Color c;   
  } MPE_Point;

npoints should contain the number of points that are in the array pointed to by points. Note that the points may not actually be drawn until you call MPE_Update.

MPE_Draw_line (MPE_XGraph window, int x1, int y1, int x2, int y2, MPE_Color
color);

Draw a line from (x1, y1) to (x2, y2).

MPE_Fill_rectangle (MPE_XGraph window, int x, int y, int width, int height,
MPE_Color color);

Fill a rectangle with upper-left corner at (x, y) of size width, height, in pixels.

MPE_Update (MPE_XGraph window);

The MPE graphics library buffers the drawing commands that you execute, so that they can be sent to the X server all at once. MPE_Update sends the contents of the buffer. You should call MPE_Update whenever your process may be idle for a while (so that the window is not partially drawn).

MPE_Get_mouse_press (MPE_XGraph window, int *x, int *y, int *button);

Blocks until a mouse button is pressed in window. Then, the mouse position (relative to the upper-left corner of the window) is returned in x and y. The number of the button that was pressed is returned in button.

MPE_Get_mouse_status (MPE_XGraph window, int *x, int *y, int *button, int
*wasPressed);
/* in mouse_status.h. */

Does exactly the same thing as MPE_Get_mouse_press, buy returns immediately even if no button is pressed. will be non-zero if any button was pressed at the time of the call.

MPE_Drag_square (MPE_XGraph window, int *startx, int *starty, int *endx,
int *endy);
/* In mouse_status.h. */

Wait for the user to drag out a square on the screen. It is OK if a button is already pressed when you call MPE_Drag_square; for instance, you might call MPE_Get_mouse_press to wait for a mouse press, and then call MPE_Drag_square only if a certain button was pressed. If the button is already pressed when you call MPE_Drag_square, *startx and *starty should contain the point at which the mouse was pressed. *endx and *endy will always be greater than *startx and *starty, even if the user drags the square from right to left.

MPE_Make_color_array (MPE_XGraph window, int ncolors, MPE_Color *colors);

This function creates a nice rainbow spectrum of ncolors colors. It places these colors into the array pointed to by colors; this array should have at least ncolors elements. If not enough colors are available, then some of the returned colors will be random. Mosaic and Netscape tend to hog the colormap, so you might want to quit them before running your program to get the correct colors. The maximum value for ncolors is 254. The new colors replace all the standard MPE colors except MPE_BLACK and MPE_WHITE. You should call MPE_Make_color_array from all the nodes that you plan to draw from.

Remember that most of these functions also have man pages.



next up previous contents
Next: Gathering Performance Data Up: MPE Graphics Previous: Overview



Lori Pollock
Wed Feb 4 14:18:58 EST 1998