home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
forum23.lzh
/
f23b
/
SOFTWARE
/
PDRAW
/
plotX.c
< prev
next >
Wrap
Text File
|
1992-01-15
|
29KB
|
843 lines
/* plotX.c - all the X10 routines ***/
#include <X/Xlib.h>
#include <X/Xkeyboard.h>
#include <stdio.h>
#include <strings.h>
#include <math.h>
#include "header.h"
#include "Xdefs.h"
#include "icon.ic"
#include "iconMask.ic"
#define LEFT 0
#define RIGHT 1
#define BACK 2
#define FRONT 3
#define X_DIM 600
#define Y_DIM 600
#define BDR_DIM 100
#define VIEW_X_ORIGIN 0
#define VIEW_Y_ORIGIN 0
#define VIEW_X_DIM 1000
#define VIEW_Y_DIM 1000
#define NLINES 2
#define DEFAULT_BORDER_WIDTH 3
#define DEFAULT_FONT "helv12b"
#define DEFAULT_POSITION "=%dx%d+0+0" /* upper left hand corner */
#define DEFAULT_BORDER_COLOR "Blue"
#define DEFAULT_BACK_COLOR "DarkBlue"
#define DEFAULT_FORE_COLOR "White"
#define DEFAULT_MOUSE_COLOR "White"
#define DEFAULT_ICON_COLOR "Red"
#define Long_Dotted XMakePattern(0x0101,16,1) /* Line type */
#define Dashed_1 XMakePattern(0x3f3f,16,1) /* Line type */
#define Dashed_2 XMakePattern(0x0707,16,1) /* Line type */
#define Dashed_3 XMakePattern(0x6666,16,1) /* Line type */
#define KC_A 0302 /* interesting letter keycodes */
#define KC_B 0331
#define KC_C 0316
#define KC_D 0315
#define KC_E 0314
#define KC_F 0322
#define KC_G 0330
#define KC_H 0335
#define KC_I 0346
#define KC_J 0342
#define KC_K 0347
#define KC_L 0354
#define KC_M 0343
#define KC_N 0336
#define KC_O 0353
#define KC_P 0360
#define KC_Q 0301
#define KC_R 0321
#define KC_S 0307
#define KC_T 0327
#define KC_U 0341
#define KC_V 0323
#define KC_W 0306
#define KC_X 0310
#define KC_Y 0334
#define KC_Z 0303
#define KC_DEL 0274
#define KC_BAR 0324
/* events */
#define EVENT_A 1 /* user pressed "A" */
#define EVENT_B 2 /* user pressed "B" */
#define EVENT_C 3 /* user pressed "C" */
#define EVENT_D 4 /* user pressed "D" */
#define EVENT_E 5 /* user pressed "E" */
#define EVENT_F 6 /* user pressed "F" */
#define EVENT_G 7 /* user pressed "G" */
#define EVENT_H 8 /* user pressed "H" */
#define EVENT_I 9 /* user pressed "I" */
#define EVENT_J 10 /* user pressed "J" */
#define EVENT_K 11 /* user pressed "K" */
#define EVENT_L 12 /* user pressed "L" */
#define EVENT_M 13 /* user pressed "M" */
#define EVENT_N 14 /* user pressed "N" */
#define EVENT_O 15 /* user pressed "O" */
#define EVENT_P 16 /* user pressed "P" */
#define EVENT_Q 17 /* user pressed "Q" */
#define EVENT_R 18 /* user pressed "R" */
#define EVENT_S 19 /* user pressed "S" */
#define EVENT_T 20 /* user pressed "T" */
#define EVENT_U 21 /* user pressed "U" */
#define EVENT_V 22 /* user pressed "V" */
#define EVENT_W 23 /* user pressed "W" */
#define EVENT_X 24 /* user pressed "X" */
#define EVENT_Y 25 /* user pressed "Y" */
#define EVENT_Z 26 /* user pressed "Z" */
#define EVENT_BAR 27 /* user pressed space bar */
#define EVENT_LEFT_D 28 /* user pressed left mouse button */
#define EVENT_LEFT_U 29 /* user released l.m.b */
#define EVENT_MIDDLE_D 30 /* user pressed middle button */
#define EVENT_RIGHT_D 31 /* user pressed right button */
#define EVENT_RIGHT_U 32 /* user released r.m.b */
#define EVENT_NETWORK 33 /* incoming network packet */
#define EVENT_INT 34 /* user pressed interrupt key */
#define EVENT_TIMEOUT 35 /* nothing happened! */
int background; /* color of background */
int foreground; /* color of lines and such */
int color1; /* color of 1st line */
int color2; /* color of 2nd line */
int color3; /* color of 3rd line */
int color4; /* color of 4th line */
int color5; /* color of 5th line */
int iconFore; /* icon foreground */
int iconBack; /* icon background */
int mouseground; /* mouse cursor color */
int highlight; /* flash colors */
Window mwWindow; /* parent window */
OpaqueFrame mwWin; /* frame for the window */
Window viewWindow; /* view window */
Window iconWindow; /* icon window */
Bitmap iconMask; /* mask for the icon outline */
Pixmap border_pixmap; /* Pixmap for the border */
Pixmap icon_border_pixmap; /* Pixmap for the icon border */
FontInfo *fontInfo; /* font information */
short gray_bits[16] = {
0xaaaa, 0x5555, 0xaaaa, 0x5555,
0xaaaa, 0x5555, 0xaaaa, 0x5555,
0xaaaa, 0x5555, 0xaaaa, 0x5555,
0xaaaa, 0x5555, 0xaaaa, 0x5555};
InitWindow(argc,argv)
int argc;
char **argv;
{
char *sprintf();
WindowInfo mwInfo;
int defwidth, defheight;
char def[128];
/* Open display first */
if (!XOpenDisplay(display_name)){
fprintf(stderr,"%s:Could not open display %s\n",
progname,display_name);
exit(1);
}
/* Merge Options */
Merge_Options();
/* Allocate colors */
Alloc_Colors();
/* Find a font */
if (!(fontInfo = XOpenFont(font_name))){
fprintf(stderr,"%s:Could not open font %s\n",progname,font_name);
exit(1);
}
/* set up the main window */
mwWin.bdrwidth = border_width;
mwWin.border = border_pixmap;
mwWin.background = XMakeTile(background);
defwidth = X_DIM;
defheight= Y_DIM + fontInfo->height * (NLINES + 1);
sprintf(def,"=$dx%d+300+300",defwidth, defheight);
mwWindow = XCreate("Kenny_Plotter",progname,geometry,def,&mwWin,
defwidth,defheight);
if (!mwWindow) {
fprintf(stderr,"XCreateWindow failed");
exit(1);
}
/* set up a subwindow */
viewWindow = XCreateTransparency(mwWindow,VIEW_X_ORIGIN,VIEW_Y_ORIGIN,
VIEW_X_DIM,VIEW_Y_DIM);
/* set up the icon */
XQueryWindow(mwWindow, &mwInfo);
iconWindow = XCreateWindow(RootWindow,
mwInfo.x + (mwInfo.width - icon_width) /2,
mwInfo.y + (mwInfo.height - icon_height) /2,
icon_width, icon_height, 3, icon_border_pixmap, 0);
XTileRelative(iconWindow);
XSetIconWindow(mwWindow, iconWindow);
iconMask = XStoreBitmap(icon_mask_width, icon_mask_height,
icon_mask_bits);
/* XSelectInput(mwWindow,ExposeWindow | UnmapWindow); */
XSelectInput(iconWindow,ExposeWindow | UnmapWindow);
iconFore = foreground;
iconBack = background;
XSelectInput(mwWindow,
KeyPressed|ButtonPressed|ButtonReleased|
EnterWindow|LeaveWindow|ExposeWindow|UnmapWindow);
XMapWindow(viewWindow);
XMapWindow(mwWindow);
}
/* Initialize and merge the various options */
Merge_Options()
{
char *option;
if (reverse < 0) {
if ((option = XGetDefault(progname,"ReverseVideo")) != NULL)
if (strcmp(option,"on")) reverse = 1;
}
if (!geometry) {
option = XGetDefault(progname,"Geometry");
geometry = option ? option : "=+5+5";
}
if (!font_name) {
/* option = XGetDefault(progname,"BodyFont"); */
font_name = DEFAULT_FONT;
}
if (!border_color) {
option = XGetDefault(progname,"Border");
border_color = option ? option : DEFAULT_BORDER_COLOR;
}
if (!back_color) {
option = XGetDefault(progname,"Background");
back_color = option ? option : DEFAULT_BACK_COLOR;
}
if (!fore_color) {
option = XGetDefault(progname,"Foreground");
fore_color = option ? option : DEFAULT_FORE_COLOR;
}
if (!mouse_color) {
option = XGetDefault(progname,"Mouse");
mouse_color = option ? option : DEFAULT_MOUSE_COLOR;
}
if (!icon_color) {
option = XGetDefault(progname,"Icon");
icon_color = option ? option : DEFAULT_ICON_COLOR;
}
if (border_width <= 0) {
option = XGetDefault(progname,"BorderWidth");
border_width = option ? atoi(option) : DEFAULT_BORDER_WIDTH;
}
}
/* Allocate colors */
Alloc_Colors()
{
Color cdef;
/*if DisplayCells are less or equal to 2, then on monochrome display */
if (DisplayCells() <= 2) {
background = BlackPixel;
foreground = WhitePixel;
mouseground = WhitePixel;
color1 = foreground;
color2 = foreground;
color3 = foreground;
color4 = foreground;
color5 = foreground;
border_pixmap = XMakePixmap(XStoreBitmap(16,16,gray_bits),
BlackPixel,WhitePixel);
icon_border_pixmap = border_pixmap;
} else if (DisplayCells() > 2) {
/*if DisplayCells are greater than 2, then on color display */
if (XParseColor(back_color,&cdef) && XGetHardwareColor(&cdef))
background = cdef.pixel;
if (XParseColor(fore_color,&cdef) && XGetHardwareColor(&cdef))
foreground = cdef.pixel;
if (XParseColor(mouse_color,&cdef)&&XGetHardwareColor(&cdef))
mouseground = cdef.pixel;
if (XParseColor("yellow",&cdef)&&XGetHardwareColor(&cdef))
color1 = cdef.pixel;
if (XParseColor("cyan",&cdef)&&XGetHardwareColor(&cdef))
color2 = cdef.pixel;
if (XParseColor("green",&cdef)&&XGetHardwareColor(&cdef))
color3 = cdef.pixel;
if (XParseColor("red",&cdef)&&XGetHardwareColor(&cdef))
color4 = cdef.pixel;
if (XParseColor("blue",&cdef)&&XGetHardwareColor(&cdef))
color5 = cdef.pixel;
if (XParseColor(border_color,&cdef)&& XGetHardwareColor(&cdef))
border_pixmap = XMakeTile(cdef.pixel);
if (XParseColor(icon_color,&cdef) && XGetHardwareColor(&cdef))
icon_border_pixmap = XMakeTile(cdef.pixel);
}
if (reverse) {
highlight = background;
background = foreground;
foreground = highlight;
if (mouseground == background) mouseground = foreground;
color1 = foreground;
color2 = foreground;
color3 = foreground;
color4 = foreground;
color5 = foreground;
} else
highlight = foreground;
}
/*
* Event handling. Presents a uniform event interface, and
* handles all other events in here. Only sees the events
* that affect it directly. They are:
*
* keypresses
* mouse button clicks
*
* All other events should be swallowed by this routine.
*/
NextEvent()
{
XEvent xEvent;
int event;
while (1) {
if (XPending()) {
XNextEvent(&xEvent);
switch (xEvent.type) {
case KeyPressed:
event = 0;
switch(((XKeyEvent *) &xEvent)->detail&0xff) {
case KC_A:
case KC_KEYPAD_4: event = EVENT_A; return(event);
case KC_S:
case KC_KEYPAD_5: event = EVENT_S; return(event);
case KC_D:
case KC_KEYPAD_6: event = EVENT_D; return(event);
case KC_F:
case KC_KEYPAD_COMMA: event = EVENT_F; return(event);
case KC_BAR:
case KC_CURSOR_RIGHT: event = EVENT_BAR; return(event);
case KC_B: event = EVENT_B; return(event);
case KC_C: event = EVENT_C; return(event);
case KC_E: event = EVENT_E; return(event);
case KC_G: event = EVENT_G; return(event);
case KC_H: event = EVENT_H; return(event);
case KC_I: event = EVENT_I; return(event);
case KC_J: event = EVENT_J; return(event);
case KC_K: event = EVENT_K; return(event);
case KC_L: event = EVENT_L; return(event);
case KC_M: event = EVENT_M; return(event);
case KC_N: event = EVENT_N; return(event);
case KC_O: event = EVENT_O; return(event);
case KC_P: event = EVENT_P; return(event);
case KC_R: event = EVENT_R; return(event);
case KC_T: event = EVENT_T; return(event);
case KC_U: event = EVENT_U; return(event);
case KC_V: event = EVENT_V; return(event);
case KC_W: event = EVENT_W; return(event);
case KC_X: event = EVENT_X; return(event);
case KC_Y: event = EVENT_Y; return(event);
case KC_Z: event = EVENT_Z; return(event);
case KC_Q:
case KC_DEL: event = EVENT_INT; return(event);
}
break;
#define RightButton 0
#define MiddleButton 1
#define LeftButton 2
case ButtonPressed:
event = 0;
switch(((XButtonPressedEvent *) &xEvent)->detail&0xff) {
case RightButton: event = EVENT_RIGHT_D; return(event);
case MiddleButton: event = EVENT_MIDDLE_D; return(event);
case LeftButton: event = EVENT_LEFT_D; return(event);
}
break;
case ButtonReleased:
event = 0;
switch(((XButtonReleasedEvent *) &xEvent)->detail&0xff) {
case RightButton: event = EVENT_RIGHT_U; return(event);
case LeftButton: event = EVENT_LEFT_U; return(event);
}
break;
case EnterWindow:
break;
case LeaveWindow:
break;
case ExposeWindow:
if (((XExposeWindowEvent *)&xEvent)->window == iconWindow) {
repaintIcon();
break;
}
repaintWindow();
break;
case UnmapWindow:
break;
}
}
}
}
/* Actually put up the pictures on the screen */
repaintWindow()
{
/* graphics routine */
ShowView();
}
repaintIcon()
{
XBitmapBitsPut(iconWindow, 0, 0, icon_width, icon_height, icon_bits,
iconFore, iconBack, iconMask, GXcopy, AllPlanes);
}
RunOps()
{
int event;
double theta = 0.0;
double phi = 0.0;
double conv;
conv = 3.14159/180.0;
while(1) {
event = NextEvent();
switch (event) {
case EVENT_LEFT_D :
case EVENT_RIGHT_D :
case EVENT_MIDDLE_D :
case EVENT_INT : XDestroyWindow(mwWindow);
XFlush();
return; break;
case EVENT_L : theta = theta + 10*conv;
read_view(theta,phi);
ShowView();
break;
case EVENT_J : phi = phi - 10*conv;
read_view(theta,phi);
ShowView();
break;
case EVENT_K : phi = phi + 10*conv;
read_view(theta,phi);
ShowView();
break;
case EVENT_H : theta = theta - 10*conv;
read_view(theta,phi);
ShowView();
break;
case EVENT_O : theta = 0.0; phi = 0.0;
read_view(theta,phi);
ShowView();
break;
case EVENT_F : theta = theta + 90*conv;
read_view(theta,phi);
ShowView();
break;
case EVENT_S : phi = phi - 90*conv;
read_view(theta,phi);
ShowView();
break;
case EVENT_D : phi = phi + 90*conv;
read_view(theta,phi);
ShowView();
break;
case EVENT_A : theta = theta - 90*conv;
read_view(theta,phi);
ShowView();
break;
case EVENT_BAR:
default : break;
}
}
}
ShowView()
{
char *text;
int text_len, width;
XClear(viewWindow);
text = "Type 'q' or 'Q' to quit";
text_len = strlen(text);
width = XStringWidth(text,fontInfo,0,0);
XText(mwWindow,(X_DIM-width)/2,5,text,text_len,
fontInfo->id,foreground,background);
axesX();
plotX();
}
axesX()
{
xyzdata midpoint();
char *sprintf(), *strcpy();
extern double xmin, ymin, zmin, xmax, ymax, zmax;
int text_len, text_width, char_width;
int posx, posy, i;
double xtmp, ytmp, ztmp, dl, ratio, vallbl;
xyzdata mpt;
char text[100];
char_width = XStringWidth("a",fontInfo,0,0);
/* Draw the axes - parallel to X */
draw_Xline(xmin,ymin,zmin,xmax,ymin,zmin,1);
draw_Xline(xmin,ymax,zmin,xmax,ymax,zmin,2);
draw_Xline(xmin,ymin,zmax,xmax,ymin,zmax,1);
draw_Xline(xmin,ymax,zmax,xmax,ymax,zmax,1);
/* Draw the axes - parallel to Y */
draw_Xline(xmin,ymin,zmin,xmin,ymax,zmin,1);
draw_Xline(xmax,ymin,zmin,xmax,ymax,zmin,2);
draw_Xline(xmin,ymin,zmax,xmin,ymax,zmax,1);
draw_Xline(xmax,ymin,zmax,xmax,ymax,zmax,1);
/* Draw the axes - parallel to Z */
draw_Xline(xmin,ymin,zmin,xmin,ymin,zmax,1);
draw_Xline(xmax,ymin,zmin,xmax,ymin,zmax,2);
draw_Xline(xmin,ymax,zmin,xmin,ymax,zmax,1);
draw_Xline(xmax,ymax,zmin,xmax,ymax,zmax,1);
/* Find midpoints of lines */
mpt = midpoint(xmin,ymax,zmin,xmax,ymax,zmin,0.5);
/* X-Axis Label */
strcpy(text,"X");
text_len = strlen(text);
text_width = XStringWidth(text,fontInfo,0,0);
posx = (int)(mpt.x) - char_width/2;
posy = Y_DIM - (int)(mpt.y) + char_width;
XText(viewWindow,posx,posy,text,text_len,
fontInfo->id,foreground,background);
/* Find midpoints of lines */
mpt = midpoint(xmax,ymin,zmin,xmax,ymax,zmin,0.5);
/* Y-Axis Label */
strcpy(text,"Y");
text_len = strlen(text);
text_width = XStringWidth(text,fontInfo,0,0);
posx = (int)(mpt.x) - char_width/2;
posy = Y_DIM - (int)(mpt.y) + char_width;
XText(viewWindow,posx,posy,text,text_len,
fontInfo->id,foreground,background);
/* Find midpoints of lines */
mpt = midpoint(xmax,ymin,zmin,xmax,ymin,zmax,0.5);
/* Z-Axis Label */
strcpy(text,"Z");
text_len = strlen(text);
text_width = XStringWidth(text,fontInfo,0,0);
posx = (int)(mpt.x) - 2*char_width;
posy = Y_DIM - (int)(mpt.y) + char_width;
XText(viewWindow,posx,posy,text,text_len,
fontInfo->id,foreground,background);
/* Draw the tick marks */
dl = 0.1*(xmax-xmin);
for (i=0; i<=xticks; i++) {
ratio = i/(double)xticks;
xtmp = xmin + (xmax-xmin)*ratio;
draw_Xline(xtmp,ymax,zmin,xtmp,ymax+dl,zmin,2);
mpt = midpoint(xmin,ymax,zmin,xmax,ymax,zmin,ratio);
vallbl = xtmp;
sprintf(text,"%6.2f",vallbl);
text_len = strlen(text);
text_width = XStringWidth(text,fontInfo,0,0);
posx = (int)(mpt.x) + 8;
posy = Y_DIM - (int)(mpt.y)+10;
XText(viewWindow,posx,posy,text,text_len,
fontInfo->id,foreground,background);
}
for (i=0; i<=yticks; i++) {
ratio = i/(double)yticks;
ytmp = ymin + (ymax-ymin)*ratio;
draw_Xline(xmax,ytmp,zmin,xmax+dl,ytmp,zmin,2);
mpt = midpoint(xmax,ymin,zmin,xmax,ymax,zmin,ratio);
vallbl = ytmp;
sprintf(text,"%6.2f",vallbl);
text_len = strlen(text);
text_width = XStringWidth(text,fontInfo,0,0);
posx = (int)(mpt.x) - (int)(1.5*text_width);
posy = Y_DIM - (int)(mpt.y) + 10;
XText(viewWindow,posx,posy,text,text_len,
fontInfo->id,foreground,background);
}
for (i=0; i<=zticks; i++) {
ratio = i/(double)zticks;
ztmp = zmin + (zmax-zmin)*ratio;
draw_Xline(xmax,ymin,ztmp,xmax,ymin-dl,ztmp,2);
mpt = midpoint(xmax,ymin,zmin,xmax,ymin,zmax,ratio);
vallbl = ztmp;
sprintf(text,"%6.2f",vallbl);
text_len = strlen(text);
text_width = XStringWidth(text,fontInfo,0,0);
posx = (int)(mpt.x) - (int)(1.5*text_width);
posy = Y_DIM - (int)(mpt.y) - 20;
XText(viewWindow,posx,posy,text,text_len,
fontInfo->id,foreground,background);
}
}
draw_Xline(x1, y1, z1, x2, y2, z2, ithk)
double x1, y1, z1, x2, y2, z2;
int ithk;
{
xyzdata point1, point2, newpt1, newpt2;
xyzdata transform_point();
int ix1, iy1, ix2, iy2;
point1.x = x1;
point1.y = y1;
point1.z = z1;
point2.x = x2;
point2.y = y2;
point2.z = z2;
newpt1 = transform_point(point1,view_transfo);
newpt2 = transform_point(point2,view_transfo);
ix1 = (int)newpt1.x;
iy1 = Y_DIM-(int)newpt1.y;
ix2 = (int)newpt2.x;
iy2 = Y_DIM-(int)newpt2.y;
/* draw the line */
XLine(viewWindow,ix1,iy1,ix2,iy2,
ithk,ithk,foreground,GXcopy,AllPlanes);
}
plotX()
{
xyzdata transform_point();
extern double xmin, ymin, zmin, xmax, ymax, zmax;
extern int line, linechange;
extern int marker, markerchange;
extern int linetyp[MAXTYPE],markertype[MAXTYPE];
extern int hiddenline, quick_sort;
extern segmptr segmhead;
Vertex vlist[MAXPTS];
segmptr S;
nodeptr Nd;
int kl, km;
int j,npts,linepattern;
xyzdata point, newpt;
if (hiddenline==ON) {
/* sort the mesh */
if (quick_sort)
do_quick_sort();
else
bubble_sort();
}
kl = linetype[0];
km = markertype[0];
S = segmhead;
for ( ; S!=NULL; S=S->next) {
/* rescale points */
j = 0;
for (Nd=S->head; Nd!=NULL; Nd=Nd->next) {
point.x = Nd->x;
point.y = Nd->y;
point.z = Nd->z;
newpt = transform_point(point,view_transfo);
vlist[j].x = (int)newpt.x;
vlist[j].y = Y_DIM - (int)newpt.y;
vlist[j].flags = 0;
j++;
}
npts = j;
/* plot the points */
if (line == ON) {
linepattern = linetypX(kl);
if (hiddenline == ON)
XDrawFilled(viewWindow,vlist,npts,color2,GXcopy,AllPlanes);
XDrawDashed(viewWindow,vlist,npts,1,1,
color1,linepattern,GXcopy,AllPlanes);
}
if (marker == ON) {
km = km % 5;
switch (km) {
case 0 : for (j=0; j < npts; j++)
XLine(viewWindow,
vlist[j].x,vlist[j].y,vlist[j].x,vlist[j].y,
1,1,foreground,GXcopy,AllPlanes);
break;
case 1 : for (j=0; j < npts; j++)
XLine(viewWindow,
vlist[j].x-1,vlist[j].y-1,vlist[j].x-1,vlist[j].y-1,
3,3,foreground,GXcopy,AllPlanes);
break;
case 2 : for (j=0; j < npts; j++) {
XLine(viewWindow,
vlist[j].x-2,vlist[j].y-2,vlist[j].x+2,vlist[j].y+2,
1,1,foreground,GXcopy,AllPlanes);
XLine(viewWindow,
vlist[j].x+2,vlist[j].y-2,vlist[j].x-2,vlist[j].y+2,
1,1,foreground,GXcopy,AllPlanes);
}
break;
case 3 : for (j=0; j < npts; j++) {
XLine(viewWindow,
vlist[j].x-2,vlist[j].y-2,vlist[j].x-2,vlist[j].y+2,
1,1,foreground,GXcopy,AllPlanes);
XLine(viewWindow,
vlist[j].x-2,vlist[j].y+2,vlist[j].x+2,vlist[j].y+2,
1,1,foreground,GXcopy,AllPlanes);
XLine(viewWindow,
vlist[j].x+2,vlist[j].y+2,vlist[j].x+2,vlist[j].y-2,
1,1,foreground,GXcopy,AllPlanes);
XLine(viewWindow,
vlist[j].x+2,vlist[j].y-2,vlist[j].x-2,vlist[j].y-2,
1,1,foreground,GXcopy,AllPlanes);
}
break;
case 4 : for (j=0; j < npts; j++) {
XLine(viewWindow,
vlist[j].x ,vlist[j].y-2,vlist[j].x+2,vlist[j].y ,
1,1,foreground,GXcopy,AllPlanes);
XLine(viewWindow,
vlist[j].x+2,vlist[j].y ,vlist[j].x ,vlist[j].y+2,
1,1,foreground,GXcopy,AllPlanes);
XLine(viewWindow,
vlist[j].x ,vlist[j].y+2,vlist[j].x-2,vlist[j].y ,
1,1,foreground,GXcopy,AllPlanes);
XLine(viewWindow,
vlist[j].x-2,vlist[j].y ,vlist[j].x ,vlist[j].y-2,
1,1,foreground,GXcopy,AllPlanes);
}
break;
}
}
if (linechange == ON) kl++;
if (markerchange == ON) km++;
}
/* redraw some of the axes */
if (hiddenline==ON) redraw_axesX();
}
/* redraw some of the axes, depending on which corner is closest */
redraw_axesX()
{
xyzdata transform_point();
extern double xmin, ymin, zmin, xmax, ymax, zmax;
xyzdata point;
double maxz;
int maxpt=0,i,j,k;
maxz = -1.0e10;
/* find the i,j,k of the closest corner */
for (i=0; i<2; i++)
for (j=0; j<2; j++)
for (k=0; k<2; k++) {
point.x = xmin + i*(xmax-xmin);
point.y = ymin + j*(ymax-ymin);
point.z = zmin + k*(zmax-zmin);
point = transform_point(point,view_transfo);
if (point.z > maxz) {
maxz = point.z;
maxpt = i+2*j+4*k;
}
}
/* find the corresponding point */
switch (maxpt) {
case 0 : /* printf("xmin ymin zmin\n"); */
draw_Xline(xmin,ymin,zmin,xmax,ymin,zmin,1);
draw_Xline(xmin,ymin,zmin,xmin,ymax,zmin,1);
draw_Xline(xmin,ymin,zmin,xmin,ymin,zmax,1);
break;
case 1 : /* printf("xmax ymin zmin\n");*/
draw_Xline(xmax,ymin,zmin,xmin,ymin,zmin,1);
draw_Xline(xmax,ymin,zmin,xmax,ymax,zmin,2);
draw_Xline(xmax,ymin,zmin,xmax,ymin,zmax,2);
break;
case 2 : /* printf("xmin ymax zmin\n"); */
draw_Xline(xmin,ymax,zmin,xmax,ymax,zmin,2);
draw_Xline(xmin,ymax,zmin,xmin,ymin,zmin,1);
draw_Xline(xmin,ymax,zmin,xmin,ymax,zmax,1);
break;
case 3 : /* printf("xmax ymax zmin\n"); */
draw_Xline(xmax,ymax,zmin,xmin,ymax,zmin,2);
draw_Xline(xmax,ymax,zmin,xmax,ymin,zmin,2);
draw_Xline(xmax,ymax,zmin,xmax,ymax,zmax,1);
break;
case 4 : /* printf("xmin ymin zmax\n"); */
draw_Xline(xmin,ymin,zmax,xmax,ymin,zmax,1);
draw_Xline(xmin,ymin,zmax,xmin,ymax,zmax,1);
draw_Xline(xmin,ymin,zmax,xmin,ymin,zmin,1);
break;
case 5 : /* printf("xmax ymin zmax\n"); */
draw_Xline(xmax,ymin,zmax,xmin,ymin,zmax,1);
draw_Xline(xmax,ymin,zmax,xmax,ymax,zmax,1);
draw_Xline(xmax,ymin,zmax,xmax,ymin,zmin,2);
break;
case 6 : /* printf("xmin ymax zmax\n"); */
draw_Xline(xmin,ymax,zmax,xmax,ymax,zmax,1);
draw_Xline(xmin,ymax,zmax,xmin,ymin,zmax,1);
draw_Xline(xmin,ymax,zmax,xmin,ymax,zmin,1);
break;
case 7 : /* printf("xmax ymax zmax\n"); */
draw_Xline(xmin,ymax,zmax,xmax,ymax,zmax,1);
draw_Xline(xmax,ymin,zmax,xmax,ymax,zmax,1);
draw_Xline(xmax,ymax,zmin,xmax,ymax,zmax,1);
break;
default: break;
}
}
linetypX(linetyp)
int linetyp;
{
int linepat;
linetyp = linetyp % 7;
switch (linetyp) {
case 0 : linepat = SolidLine; break;
case 1 : linepat = DashedLine; break;
case 2 : linepat = DottedLine; break;
case 3 : linepat = DotDashLine; break;
case 4 : linepat = Dashed_1; break;
case 5 : linepat = Dashed_2; break;
case 6 : linepat = Dashed_3; break;
}
return(linepat);
}