⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xpig.c

📁 Programs in the irregular grid design package described in this manual are used to carry out five ma
💻 C
📖 第 1 页 / 共 5 页
字号:
/*  * $Id: xpig.c,v 2.18 1995/10/30 21:18:19 adolling Exp adolling $ * * $Log: xpig.c,v $ * Revision 2.18  1995/10/30  21:18:19  adolling * After update from HP/ALPHA port (replacement by...) * * Revision 2.16  1995/10/16  17:35:28  adolling * Working version. Now about to suppress calls to callback functions * when a callback function is active. * * Revision 2.15  1995/10/13  17:07:35  adolling * Modified fortran / c interface to remove character*1 function definitions. All * character variable interactions now through the argument lists. This is to * simplify the portability between fortran and c compilers. * * Revision 2.14  1995/10/11  21:46:52  adolling * Version with both STEVE and non STEVE versions working. * * Revision 2.13  1995/10/11  19:01:50  adolling * After merge with steve's latest. If symbol STEVE is not defined, get original * this has been tested. About to add symbol STEVE, to check we get * Steve's version, prior to removing two versions of code. * * Revision 2.12  1995/10/11  18:31:44  adolling * Removed #ifdef and #ifndef steve from previous integration attempts. * * Revision 2.9  1995/10/05  19:32:31  adolling * After some changes to make code work on HP * * Revision 2.8  1995/09/28  20:13:19  adolling * New version, merged with steves work. If steve is NOT defined, get his code * where changed from 2.7 release. * * Revision 2.7  1995/09/27  21:45:40  adolling * Never used code stripped and message for 2.6 revision changed. * * 2.6 should have read : * removed some redundant and never used code and variables * * Revision 2.6  1995/09/27  21:42:21  adolling * Added steve's changes and rcslogging etc. in * * Revision 2.6  1995/09/27  21:42:21  adolling * Added steve's changes and rcslogging etc. in * * Revision 2.5  1995/09/27  21:02:32  adolling * Added rcs header back in * ---------------------------- * revision 2.4	locked by: adolling; * date: 1995/09/27 20:59:15;  author: adolling;  state: Exp;  lines: +19 -143 * After incorporating steve's changes from today (text extent mostly) * ---------------------------- * revision 2.3 * date: 1995/09/27 20:49:13;  author: adolling;  state: Exp;  lines: +1 -1 * Prior to merge with steves stuff from today * ---------------------------- * revision 2.2 * date: 1995/09/27 17:35:38;  author: adolling;  state: Exp;  lines: +94 -10 * Added in iXPigGetString from version 1.8 * ---------------------------- * revision 2.1 * date: 1995/09/27 17:21:30;  author: adolling;  state: Exp;  lines: +62 -24 * Captured improved file open, with reversion to getting a user prompted * string without the full file dialog until that is working properly. * ---------------------------- * revision 2.0 * date: 1995/09/25 18:39:42;  author: adolling;  state: Exp;  lines: +468 -377 * Version from steve that does most things. Needs to be compared with R1.8, * which is from previous work by me, and has some good things in. * ---------------------------- * revision 1.8 * date: 1995/09/25 15:00:23;  author: adolling;  state: Exp;  lines: +39 -0 * Added RCS log to top of file * ---------------------------- * revision 1.7 * date: 1995/09/25 14:55:11;  author: adolling;  state: Exp;  lines: +1851 -0 * Version 1.6 was empty by mistake. This is recovered version 1.5.1.1 * ---------------------------- * revision 1.6 * date: 1995/09/24 22:21:37;  author: adolling;  state: Exp;  lines: +0 -1866 * After merging with complex.c * ---------------------------- * revision 1.5 * date: 1995/09/24 22:21:01;  author: adolling;  state: Exp;  lines: +48 -42 * branches:  1.5.1; * Prior to merging with complex.c again * ---------------------------- * revision 1.4 * date: 1995/09/24 17:56:11;  author: adolling;  state: Exp;  lines: +92 -104 * After changing, but not compiling * ---------------------------- * revision 1.3 * date: 1995/09/24 17:35:30;  author: adolling;  state: Exp;  lines: +89 -0 * After integration of complex.c (but not fixing) * ---------------------------- * revision 1.2 * date: 1995/09/24 17:34:26;  author: adolling;  state: Exp;  lines: +57 -69 * Prior to integration with complex from Kimball. * ---------------------------- * revision 1.1 * date: 1995/09/24 14:31:02;  author: adolling;  state: Exp; * During final stage debugging. Most things working now. * ---------------------------- * revision 1.5.1.1 * date: 1995/09/25 14:49:38;  author: adolling;  state: Exp;  lines: +54 -69 * Version that does not work * ============================================================================= */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <unistd.h>#include <limits.h>#include <stdarg.h>#include <ulimit.h>#include <X11/Intrinsic.h>#include <X11/StringDefs.h>#include <Xm/Xm.h>#include <Xm/CascadeB.h>	/* Cascade button */#include <Xm/Label.h>		/* Label */#include <Xm/MainW.h>		/* Main window */#include <Xm/PushB.h>		/* Push button */#include <Xm/RowColumn.h>	/* Row column: menubar, menus */#include <Xm/Separator.h>	/* Menu separator */#include <Xm/FileSB.h>		/* File Box */#include <Xm/DrawingA.h>	/* Drawing Area */#include <Xm/SelectioB.h>	/* SelectionBox */#include <Xm/BulletinB.h>	/* BulletinBoard */#include <Xm/MessageB.h>	/* MessageBox */#include <Xm/TextF.h>	/* This was in the Black book - page 359 ???? */#include <Xm/ScrolledW.h>#include <Xm/Form.h>#include <Xm/Text.h>#include <Xm/Command.h>#include <Xm/List.h>static XtAppContext	context = NULL;static Widget		toplevel = NULL;static Widget		manager = NULL;static Widget		layout = NULL;static Widget		menu_bar = NULL;static Widget		ControlXCanvas = NULL;static Widget		ProfileXCanvas = NULL;static Widget		MainXCanvas = NULL;static Widget		CurrentXCanvas = NULL;static Widget		MessageWindow = NULL;static Widget		command_window = NULL;static Widget		command_window_history = NULL;static Boolean 	debug_state = False;#if defined(PROCESSOR)#if ((PROCESSOR == LINUX) || (PROCESSOR == ALPHA))#include <X11/Xmu/Editres.h> void _XEditResCheckMessages(); #endif#endif#include "xpig.h"/*---------------- VARIABLES - Global to XPig Modules -----------------*/static	Widget		temp_button;static	Widget		default_button;static	Widget		cur_parent_widget;static	Widget		cascade;static	GC		GraphicsContext;static	GC		Xor_gc;static  XGCValues	gcvals;static	XtGCMask	gcvals_mask;static	int		XSymbolNumber;static	double		XSymbolSize = 1;static	int		X_resolved_SymbolSize = 1;			/* must include first zero value because Fortran starts at 1, not 0 */static 	double		StdSymbolSize[8] = {0, 2.0, 2.0, 2.0, 4.0, 2.0, 2.0, 2.0};static WPigFuncPtrs FuncPtrs = {NULL, NULL, NULL, NULL};static	int		XFillColour, XForegrColour, XBackgrColour, 			XSymbolColour, XTextColour, XLineColour;static	double		WorldX1 = 0.; static	double		WorldX2 = 1.0; static	double		WorldY1 = 0.; static	double		WorldY2 = 1.0; static	double		ProfileX1 = 0, ProfileX2 = 1, ProfileY1 = 0 , ProfileY2 = 1; int		count;static	Widget          yesno_question_dialog;static	Widget          string_question_dialog;static  Widget		fatal_dialog;static  Widget		file_selection_dialog;static  Widget		selection_dialog;static  Widget		selection_list_widget;/* static	char		*selection_box_value; */	/* Zoom_flag is never used! agd */static	int		Zoom_flag;typedef enum garbage{xpACTIVE, xpCANCEL, xpOK, xpHELP} XPigCBReason;/* static	XPigCBReason	files_callback_reason; */typedef	struct dummy_struct_name{	char	*answer;	char	*name; 	XPigCBReason	reason;	}		XPigXCallback_data;static	XPigXCallback_data	callback_data; static	int		Vert_align, Horiz_align;static double	aspect = 1;typedef struct {	int	x1;	int	x2;	int	y1;	int	y2;	}		win_def_type;	static win_def_type	Xwindow[5];	static Long	current_pig_window = NULL_WIN;	static Long	last_ctrl_or_prfl = NULL_WIN;	static Long	last_mainw = NULL_WIN;	static Long	last_mainb;	static float	last_mainx;	static float	last_mainy;#define PIG_CONTROL_WIN_WIDTH	280/*---------------- 'iXPig' Functions - Local to XPig Modules -----------------*/static int iXPigDebug(const long level) /* must be before any PIGDBG macros */{	static first = TRUE;	static long active_level = 3;	if(first) {		FILE *tmp = NULL;		first = FALSE;		if( (tmp = fopen("PIGDEBUG.","rt") ) != NULL) {			fclose(tmp);			debug_state = TRUE;		} else			debug_state = FALSE;		active_level = level;	}	if(level < active_level) return FALSE;	return debug_state;}static Boolean debug(void){	return debug_state;}static void add_to_command_history(const char *message){/* Add the text of message to the command history */	if(command_window != NULL) {		int i;		for(i=0;i<strlen(message);i++)			if(message[i] != ' ')			{				XmString xmessage = XmStringCreateLocalized(message);				/* place in command line */				XmCommandSetValue(command_window, xmessage);				/* add to history list */				XmListAddItemUnselected(command_window_history, xmessage, 0);						XmListSetBottomItem(command_window_history, xmessage);				XmListSetBottomPos(command_window_history, 0);					XmStringFree(xmessage); 				break;			}	}}static void iXPigDBG(const char *fmt, ...){	va_list args;	char line[1024];	va_start(args, fmt);	vsprintf(line, fmt, args);	va_end(args);	fprintf(stderr, line);	add_to_command_history(line);	fflush(stderr);}/*----------------------------------------------------------------------------*/static void iWPigFatal(const char *message){	Arg      	args[20];	Cardinal 	n;	XmString	fatal_string;	fprintf(stderr, "\niWPigFatal(%s)\n",message);	PIGDBG4("iWPigFatal(%s)\n",message);	if(fatal_dialog != (Widget)NULL) {	        fatal_string = XmStringCreateSimple(message);	        n =  0;	        XtSetArg(args[n], XmNmessageString, fatal_string); n++;	        XtSetValues(fatal_dialog, args, n);	        XmStringFree(fatal_string);	        XtManageChild(fatal_dialog);		        callback_data.reason = xpACTIVE;	        callback_data.name = (char *)message;	        while(callback_data.reason == xpACTIVE) {	                XtAppProcessEvent(context, XtIMAll);	        }	        XtUnmanageChild(fatal_dialog);	}	exit(1);}static void iWPigVFatal(const char *filename, const long line, const char *fmt, ...){	static va_list args;	static char message[256];	va_start(args, fmt);	fprintf(stderr, "Fatal error in file %s at line %li\n", filename, line);		vfprintf(stderr, fmt, args);	vsprintf(message, fmt, args);	va_end(args);	iWPigFatal(message);}#define iWPigFatal(message) iWPigVFatal(__FILE__, __LINE__, message)/*----------------------------------------------------------------------------*/static Pixel GetNamedColor(Widget widget, String colorname)/*  * from: * Kimball, Paul E. The X Toolkit Cookbook. Prentice Hall.  * Englewood Cliffs, NJ, USA.  1995.  * p88. Code Fragment 5-11  */{	Display		*display;	Colormap	cmap;	XColor		alloc_color, exact_color;		display = XtDisplay(widget);	XtVaGetValues(widget, XtNcolormap, &cmap, NULL);		if ( XAllocNamedColor(			display,	/* Server connection				*/			cmap,		/* Colormap					*/			colorname,	/* color name - see /usr/lib/X11/rgb.txt	*/			&alloc_color,	/* returned RGB and pixel as allocated		*/			&exact_color)){	/* RGB as defined in server's database		*/		return alloc_color.pixel;	} else {		PIGDBG3("Can't allocate color \"%s\"!\n", colorname);		PIGDBG3("Please see /usr/lib/X11/rgb.txt for known colors.\n");		PIGDBG3("Using White instead.\n");		return GetNamedColor(widget, "White");	}}	void WPigSetRGBColour(const Long *NewColour, const Long *red, const Long *green, const Long *blue){	}void WPigGetRGBColour(const Long *NewColour, Long *red, Long *green, Long *blue){	}void WPigSetColourPixel(const Long *NewColour, const Long *pixelcolour){	}void WPigGetColourPixel(const Long *NewColour, Long *pixelcolour){	}/*----------------------------------------------------------------------------*/static Long get_client_data(Long *id){	return(*id);}/*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*/static void iXPigSetWindowRects(){        double MainWinSizeX, MainWinSizeY;	Dimension	height, width;	XtVaGetValues( ControlXCanvas, 		XtNheight, &height, 		XtNwidth, &width, 		NULL);PIGDBG2("**************ControlXCanvas: (%i x %i)\n", height, width);	Xwindow[PIG_CONTROL_WIN].x1 = 0;	Xwindow[PIG_CONTROL_WIN].x2 = (int) width - 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -