diff -ruN ../xbgi-3_02-20000526/cleanup ./cleanup --- ../xbgi-3_02-20000526/cleanup 1999-10-22 19:37:58.000000000 +0900 +++ ./cleanup 2009-03-16 20:53:27.000000000 +0900 @@ -3,13 +3,16 @@ find . -name X11 -print -exec rm -rf {} \; find . -name shared -print -exec rm -rf {} \; find . -name unshared -print -exec rm -rf {} \; +find . -name exports -print -exec rm -rf {} \; +find . -name 'lib*.a' -print -exec rm -rf {} \; +find . -name 'lib*.so*' -o -name 'lib*.dylib*' -print -exec rm -rf {} \; find . -name tmp -print -exec rm -rf {} \; -find . -name Makefile -print -exec rm -f {} \; -find . -name Makefile.bak -print -exec rm -f {} \; +find . -iname Makefile ! -path ./doc/makefile -print -exec rm -f {} \; find . -name MapfileName -print -exec rm -f {} \; find . -name '*.log' -print -exec rm -f {} \; -find . -name '*~' -print -exec rm -f {} \; +#find . -name '*~' -print -exec rm -f {} \; find . -name '*.bak' -print -exec rm -f {} \; +find . -name '*.o' -o -name '*.exe' -print -exec rm -f {} \; # let upcase for from dos find . -name imakefil -print -exec mv -f {} Imakefile \; #cp doc/readme.doc README diff -ruN ../xbgi-3_02-20000526/config.h ./config.h --- ../xbgi-3_02-20000526/config.h 1999-10-27 10:11:30.000000000 +0900 +++ ./config.h 2009-03-16 20:55:47.000000000 +0900 @@ -92,7 +92,8 @@ #undef BuildStandaloneLibs #endif #if defined(BuildConcatenatedLib) -XBGILIB = -lgraffit -lxbgi +GRAFFITLIB = -lgraffit +XBGILIB = -lxbgi #endif /* @@ -119,7 +120,8 @@ #endif #if defined(BuildStandaloneLibs) -XBGILIB = -lgraffit -lxbgi_$(DefaultStandaloneLib) -lxbgi_common -lxbgi_misc +GRAFFITLIB = -lgraffit +XBGILIB = -lxbgi_common -lxbgi_$(DefaultStandaloneLib) -lxbgi_misc #endif /* @@ -142,6 +144,7 @@ */ #ifndef DoSharedLib #define DoSharedLib (HasSharedLibraries && \ + !defined(cygwinArchitecture) && \ !(defined(SGIArchitecture) && !SystemV4)) #endif #ifndef DoNormalLib @@ -157,4 +160,4 @@ #else EXTRA_LOAD_FLAGS = -lm -L$(XBGILIBDIR) #endif -LOCAL_LIBRARIES = $(XBGILIB) $(XTOOLLIB) $(XPMLIB) $(XLIB) +LOCAL_LIBRARIES = $(GRAFFITLIB) $(XBGILIB) $(XTOOLLIB) $(XPMLIB) $(XLIB) diff -ruN ../xbgi-3_02-20000526/graffit/sources/Imakefile ./graffit/sources/Imakefile --- ../xbgi-3_02-20000526/graffit/sources/Imakefile 1999-10-22 19:29:02.000000000 +0900 +++ ./graffit/sources/Imakefile 2009-03-16 19:43:47.000000000 +0900 @@ -19,6 +19,9 @@ SRCS = $(GRAFFIT_SRCS) OBJS = $(GRAFFIT_OBJS) +#ifdef DarwinArchitecture +REQUIREDLIBS = -flat_namespace -undefined suppress +#endif #ifdef RsArchitecture REQUIREDLIBS = $(XTOOLLIB) $(XPMLIB) $(XLIB) -lm #endif diff -ruN ../xbgi-3_02-20000526/graffit/sources/coloring-19991015.c ./graffit/sources/coloring-19991015.c --- ../xbgi-3_02-20000526/graffit/sources/coloring-19991015.c 1970-01-01 09:00:00.000000000 +0900 +++ ./graffit/sources/coloring-19991015.c 1999-10-15 20:46:10.000000000 +0900 @@ -0,0 +1,227 @@ +/* + * Coloring interface in graffit library < coloring.c > + * + * Various Definitions of Color for Borland Graphics Interface + * + * Copyright (C) 1992-1994 Taiji Yamada, Tokyo Denki University + */ +#include +#include +#include +#ifdef _XBGI_ +#include "internal.h" +#include +#endif + +#if 0 /*defined(__cplusplus) || defined(c_plusplus)*/ +template +inline T max(T __a, T __b) +{ + return (__a>__b)?__a:__b; +} +template +inline T min(T __a, T __b) +{ + return (__a>__b)?__b:__a; +} +#else +#ifndef max +#define max(a,b) (((a)>(b))?(a):(b)) +#endif +#ifndef min +#define min(a,b) (((a)>(b))?(b):(a)) +#endif +#endif + +static int BASEC[8][3] = { +#if defined(_XBGI_)||defined(PC98)||defined(FMR_) + {0, 0, 0}, + {0, 0, 1}, + {0, 1, 0}, + {0, 1, 1}, + {1, 0, 0}, + {1, 0, 1}, + {1, 1, 0}, + {1, 1, 1}, +#else /* VGA, DOSVGA */ + {0, 0, 0}, + {0, 0, 4}, + {0, 4, 0}, + {0, 4, 4}, + {4, 0, 0}, + {4, 0, 4}, + {4, 4, 0}, + {4, 4, 4}, +#endif +}; + +#define co __CO + +struct coloringtype_ co = { + 0, 15, + 0, 15 +}; + +int coloringCCCD(int p1, int p2, int c1, int c2, int c3, double d) +{ + struct palettetype p; + int i, r, m; + + r = abs(p2-p1)+1; + m = getmaxcolor(); + d = 1.0/d; + if (r == 1) + return 0; + getpalette(&p); + for (i=0; igdriver == X11 && (XBGI->gmode != X11COLOR)) { + XBGIPixels[0] = WhitePixel(XBGIDisplay,XBGIScreen); + XBGIPixels[XBGI->palette.size-1] = BlackPixel(XBGIDisplay,XBGIScreen); + } + else if (XBGI->gdriver == PS) { + PSBGIRGB[0].red = 1; + PSBGIRGB[0].green = 1; + PSBGIRGB[0].blue = 1; + PSBGIRGB[XBGI->palette.size-1].red = 0; + PSBGIRGB[XBGI->palette.size-1].green = 0; + PSBGIRGB[XBGI->palette.size-1].blue = 0; + } /*else*/ +#endif + { + struct palettetype p; + int wk; + + getpalette(&p); + wk = p.colors[p1]; + p.colors[p1] = p.colors[p2]; + p.colors[p2] = wk; +/*#if !defined(_XBGI_)&&!defined(PC98)&&!defined(FMR_) + if (p1 == 0 || p2 == getmaxcolor()) + return; +#endif*/ + setallpalette(&p); + } +} + +void rotate_colors(int p1, int p2) +{ + struct palettetype p; + int i, wk, r; + + r = abs(p2-p1)+1; + getpalette(&p); + wk = p.colors[p2]; + for (i=r-2; i>=0; i--) + p.colors[p1+i+1] = p.colors[p1+i]; + p.colors[p1] = wk; + setallpalette(&p); +} + +#undef co diff -ruN ../xbgi-3_02-20000526/graffit/sources/coloring-19991015.h ./graffit/sources/coloring-19991015.h --- ../xbgi-3_02-20000526/graffit/sources/coloring-19991015.h 1970-01-01 09:00:00.000000000 +0900 +++ ./graffit/sources/coloring-19991015.h 1999-10-15 20:33:52.000000000 +0900 @@ -0,0 +1,251 @@ +/* + * Coloring interface in graffit library < coloring.h > + * + * Various Definitions of Color for Borland Graphics Interface + * + * Copyright (C) 1992-1994 Taiji Yamada, Tokyo Denki University + */ +#ifndef _COLORING_H_ +#define _COLORING_H_ +#include + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +/* + カラー定義(Coloring)パッケージ + + これはBGIに与えられているパレットに対して、グラデーションカラーなどを + 定義するためのルーチン集です。例えば4次元グラフィックスを描画する時に、 + 4次元目をグラデーションカラーに割り当てるためなどに使用できるでしょう。 + + このパッケージでは以下の列挙型を基本色としてアクセスします。 + + enum COLORS { + BLACK = 0, DARKGRAY = 8, + BLUE = 1, LIGHTBLUE = 9, + GREEN = 2, LIGHTGREEN = 10, + CYAN = 3, LIGHTCYAN = 11, + RED = 4, LIGHTRED = 12, + MAGENTA = 5, LIGHTMAGENTA = 13, + BROWN = 6, YELLOW = 14, + LIGHTGRAY = 7, WHITE = 15, + }; + + カラー定義のルーチンには以下の関数が用意されています。 + + ・RGB直線グラデーション + coloring(開始番号, 終了番号) + + ・2色直線グラデーション + coloring2(開始番号, 終了番号, 基本色1, 基本色2) + + ・3色平面グラデーション + coloring3(開始番号, 終了番号, 基本色1, 基本色2, 基本色3) + + ・N色串型グラデーション + coloringN(開始番号, 終了番号, 基本色数, *基本色配列) + + 開始番号と終了番号はパレット番号であり、0 から getmaxcolor() で返される + カラー数の範囲内で指定できます。基本色には列挙型 COLORS を指定します。 + これらは、いずれもカラーリングが行われた色数を返します。 + ただし、カラーリングに失敗した場合には 0 を返します。 + パレットの開始番号と終了番号が同一であってはなりません。 + + カラー定義のルーチンによって定義されたカラーを指定するには、 + 直接、パレット番号を指定する以外に、 + 浮動小数点による仮想的なカラー軸を指定し、 + 浮動小数点によってアクセスするための関数が用意されています。 + + ・直線グラデーション用 + co_coloring(開始番号, 終了番号, double r1, double r2) + int getcolor_(double r) + setcolor_(double r) + + ・直線グラデーション用、底が 10 のログスケーリング + co_coloring(開始番号, 終了番号, double r1, double r2) + int getlog10color_(double r) + setlog10color_(double r) + + (注) BGI では連続するパレット番号に既定色が割り当てられており、 + BLACK, BLUE, GREEN,... という配色が enum 型 COLORS で宣言されている。 + このヘッダファイルの目的はパレットの RGB 値を直接操作し、好みの色表 + 現を行うことであるので enum 型 COLORS で宣言されている BLUE, RED な + どの値は当然意味をなさなくなる。しかし、前景色、背景色に関してはパ + レット操作を行わないのが通例であろう。オリジナルの BGI では主に 16 + 色を前提に設計されているが、機種モードによっては 2,4,8 色などの色数 + を扱うこともある。また、拙作 X11 用 BGI では任意数のパレットを扱う + ことが可能である。XBGI では BGI のパレット定義の慣例として、パレッ + ト番号 0 に黒、パレット番号 getmaxcolor() に白が割り当てられている。 + この慣例を生かすことを考慮すると、上記の関数の推奨的な使い方は, 0 + と getmaxcolor() を除く連続したパレット番号に対してRGB定義を行うこ + とである。 + + (例) coloring(1, getmaxcolor()-1); + + もし 16 色モードなら 1 から 15 までがユーザーが利用するグラデーショ + ンとなり 0(=BLACK) と getmaxcolor(=WHITE) は保存される。 + */ + +struct coloringtype_ { + int p1, p2; + double r1, r2; +}; + +/* + [名前] + coloringCCCD --- 3色直線グラデーション + + [形式] + coloringCCCD(p1, p2, c1, c2, c3, d) + int p1, p2; パレット番号p1からp2まで + int c1, c2, c3; 3色の基本色 + double d; 混合率 + + [説明] + 指定された3色を基本として、 + c1 -> c2 -> c3 となるようなグラデーションカラーを定義します。 + d は混色率で大きければよく混ぜます。推奨値は0.7です。 + */ +extern int coloringCCCD(int p1, int p2, int c1, int c2, int c3, double d); + +/* + [名前] + coloring --- RGB直線グラデーション + + [形式] + coloring(p1, p2) + int p1, p2; パレット番号p1からp2まで + + [説明] + RGB(赤、緑、青)を基本として、 + 赤 -> 緑 -> 青 となるようなグラデーションカラーを定義します。 + */ +extern int coloring(int p1, int p2); + +/* + [名前] + coloring2 --- 2色直線グラデーション + + [形式] + coloring2(p1, p2, c1, c2) + int p1, p2; パレット番号p1からp2まで + int c1, c2; 2色の基本色 + * + [説明] + 指定された2色を基本として直線のグラデーションを定義します。 + */ +extern int coloring2(int p1, int p2, int c1, int c2); + +/* + [名前] + co_coloring --- 実数を直線グラデーションのパレット番号に対応 + getcolor_ --- 指定された実数が対応するパレットを返す + setcolor_ --- 指定された実数が対応するパレットで前景色をセット + getlog10color_ --- 指定された実数が対応するパレットを返す(対数) + setlog10color_ --- 指定された実数が対応するパレットで前景色をセット(対数) + + [形式] + co_coloring(int p1, int p2, double r1, double r2) + int getcolor_(double r) + setcolor_(double r) + int getlog10color_(double r) + setlog10color_(double r) + int p1, p2; パレット番号p1からp2まで + double r1, r2; 対応される実数領域r1からr2まで + double r; 実数領域内のある一点 + + [説明] + これらは、実数を直線グラデーションのパレット番号にアクセスするために + 使用します。例えば、以下のように使用します。 + + coloring(0, getmaxcolor()); RGBグラデーションを定義 + co_coloring(0, getmaxcolor(), 0.0, 1.0); カラーを実数[0,1]に写像 + c = getcolor_(0.1); 0.1に対応するパレットを取得 + putpixel(100, 100, c); 座標(100,100)に点を描画 + setcolor_(0.5); 0.5に対応するパレットを前景色に + line(100, 100, 200, 200); その色で線を描画 + + また、対数スケーリングの場合は以下のようにします。 + + coloring(0, getmaxcolor()); RGBグラデーションを定義 + co_coloring(0, getmaxcolor(), 0.001, 10.0); カラーを実数[0.001,10.0]に写像 + c = getlog10color_(1.0); 1.0に対応するパレットを取得 + putpixel(100, 100, c); 座標(100,100)に点を描画 + setlog10color_(0.5); 0.5に対応するパレットを前景色に + line(100, 100, 200, 200); その色で線を描画 + + */ +extern void co_coloring(int p1, int p2, double r1, double r2); +extern int getcolor_(double r); +extern void setcolor_(double r); + +extern int getlog10color_(double r); +extern void setlog10color_(double r); + +/* + [名前] + coloring3 --- 3色平面グラデーション + + [形式] + coloring3(p1, p2, c1, c2, c3) + int p1, p2; パレット番号p1からp2まで + int c1, c2, c3; 3色の基本色 + + [説明] + 指定された3色を基本として平面のグラデーションを定義します。 + */ +extern int coloring3(int p1, int p2, int c1, int c2, int c3); + +/* + [名前] + coloringN --- N色串型グラデーション + + [形式] + coloringN(p1, p2, n, cs) + int p1, p2; パレット番号p1からp2まで + int n; 基本色の数 + int *cs; 基本色の配列 + + [説明] + 指定されたN色を基本として串型のグラデーションを定義します。 + */ +extern int coloringN(int p1, int p2, int n, int *cs); + +/* + [名前] + swap_colors --- 2色p1とp2を入れ替えるルーチン + + [形式] + swap_colors(p1, p2) + int p1; パレット番号1 + int p2; パレット番号2 + + [説明] + 2色p1とp2を入れ替えます。 + */ +extern void swap_colors(int p1, int p2); + +/* + [名前] + rotate_colors --- p2-p1間のパレットを回転するルーチン + + [形式] + rotate_colors(p1, p2) + int p1; パレット番号1 + int p2; パレット番号2 + + [説明] + p2-p1間のパレットを回転します。 + */ +extern void rotate_colors(int p1, int p2); + +#if defined(__cplusplus) || defined(c_plusplus) +} +#endif + +#endif /* _COLORING_H_ */ + + + diff -ruN ../xbgi-3_02-20000526/graffit/sources/coloring.c ./graffit/sources/coloring.c --- ../xbgi-3_02-20000526/graffit/sources/coloring.c 1999-10-15 20:46:09.000000000 +0900 +++ ./graffit/sources/coloring.c 2000-12-19 20:25:46.000000000 +0900 @@ -4,6 +4,7 @@ * Various Definitions of Color for Borland Graphics Interface * * Copyright (C) 1992-1994 Taiji Yamada, Tokyo Denki University + * Copyright (C) 2000 Taiji Yamada, AIHARA Electrical Engineering Co., Ltd. */ #include #include @@ -33,64 +34,209 @@ #endif #endif -static int BASEC[8][3] = { #if defined(_XBGI_)||defined(PC98)||defined(FMR_) - {0, 0, 0}, - {0, 0, 1}, - {0, 1, 0}, - {0, 1, 1}, - {1, 0, 0}, - {1, 0, 1}, - {1, 1, 0}, - {1, 1, 1}, +#define BC(p,c) (((7&(p))&(1<<(c)))>>(c)) #else /* VGA, DOSVGA */ - {0, 0, 0}, - {0, 0, 4}, - {0, 4, 0}, - {0, 4, 4}, - {4, 0, 0}, - {4, 0, 4}, - {4, 4, 0}, - {4, 4, 4}, +#define BC(p,c) ((((7&(p))&(1<<(c)))>>(c))*4) #endif -}; #define co __CO struct coloringtype_ co = { 0, 15, - 0, 15 + 0, 15, + COLORING_RGB }; -int coloringCCCD(int p1, int p2, int c1, int c2, int c3, double d) +static int huffmand(unsigned int c1, unsigned int c2) +{ + unsigned x = c1^c2; + int d = 0; + while (x != 0) { + d += 1&x; + x >>= 1; + } + return d; +} +#define CB(c) (7&(c)) +#define CD(a,b) ((a==0||a==15||b==0||b==15)?1:huffmand(CB(a),CB(b))) +#define PV(v) max(0,v) + +int coloringNc(int p1, int p2, int n, int *C, double c) { struct palettetype p; int i, r, m; + double *D = NULL; r = abs(p2-p1)+1; m = getmaxcolor(); - d = 1.0/d; if (r == 1) return 0; + + if (0gdriver == X11 && (XBGI->gmode != X11COLOR)) { XBGIPixels[0] = WhitePixel(XBGIDisplay,XBGIScreen); XBGIPixels[XBGI->palette.size-1] = BlackPixel(XBGIDisplay,XBGIScreen); diff -ruN ../xbgi-3_02-20000526/graffit/sources/coloring.h ./graffit/sources/coloring.h --- ../xbgi-3_02-20000526/graffit/sources/coloring.h 1999-10-15 20:33:52.000000000 +0900 +++ ./graffit/sources/coloring.h 2000-12-19 20:28:10.000000000 +0900 @@ -4,6 +4,7 @@ * Various Definitions of Color for Borland Graphics Interface * * Copyright (C) 1992-1994 Taiji Yamada, Tokyo Denki University + * Copyright (C) 2000 Taiji Yamada, AIHARA Electrical Engineering Co., Ltd. */ #ifndef _COLORING_H_ #define _COLORING_H_ @@ -88,27 +89,80 @@ ンとなり 0(=BLACK) と getmaxcolor(=WHITE) は保存される。 */ +enum coloring_kinds { + COLORING_CMY, /*0.5*/ + COLORING_MRYWGCB, + /*COLORING_RGB,*/ + COLORING_RGB, /*0.7*/ + /*COLORING_RGBK,*/ /*0.8*/ + COLORING_RGBK, /*0.9*/ + /*COLORING_RGBW,*/ /*0.9*/ + COLORING_RYGCB, + /*COLORING_RYGCB,*/ /*0.9*/ + COLORING_RYGCBK, + COLORING_RYGCBM, + /*COLORING_RYGCMB,*/ /*-1*/ + /*COLORING_RYGCMB,*/ + /*COLORING_RYGKCBM,*/ + COLORING_WMRYGCBK, + /*COLORING_WRGB,*/ + /*COLORING_WRGB,*/ /*0.8*/ + COLORING_WRGB, /*0.9*/ + COLORING_WRYGCBK, + COLORING_WYGCBMRK, + COLORING_YMC, /*0.5*/ + COLORING_YRMKBCG, + N_COLORING, +}; +extern char *coloring_kind_name[]; + struct coloringtype_ { int p1, p2; double r1, r2; + enum coloring_kinds coloringkind; }; /* [名前] - coloringCCCD --- 3色直線グラデーション + coloring2c --- 2色直線グラデーション + coloring3c --- 3色直線グラデーション + coloring4c --- 4色直線グラデーション + coloring5c --- 5色直線グラデーション + coloring6c --- 6色直線グラデーション + coloring7c --- 7色直線グラデーション + coloring8c --- 8色直線グラデーション [形式] - coloringCCCD(p1, p2, c1, c2, c3, d) + coloring2c(p1, p2, c1, c2, c) + coloring3c(p1, p2, c1, c2, c3, c) + coloring4c(p1, p2, c1, c2, c3, c4, c) + coloring5c(p1, p2, c1, c2, c3, c4, c5, c) + coloring6c(p1, p2, c1, c2, c3, c4, c5, c6, c) + coloring7c(p1, p2, c1, c2, c3, c4, c5, c6, c7, c) + coloring8c(p1, p2, c1, c2, c3, c4, c5, c6, c7, c8, c) int p1, p2; パレット番号p1からp2まで + int c1, c2; 2色の基本色 int c1, c2, c3; 3色の基本色 - double d; 混合率 + int c1, c2, c3, c4; 4色の基本色 + int c1, c2, c3, c4, c5; 5色の基本色 + int c1, c2, c3, c4, c5, c6; 6色の基本色 + int c1, c2, c3, c4, c5, c6, c7; 7色の基本色 + int c1, c2, c3, c4, c5, c6, c7, c8; 8色の基本色 + double c; 混合率 [説明] - 指定された3色を基本として、 - c1 -> c2 -> c3 となるようなグラデーションカラーを定義します。 - d は混色率で大きければよく混ぜます。推奨値は0.7です。 + 指定されたN(=3)色を基本として、 + c1 -> c2 -> c3 -> ... となるようなグラデーションカラーを定義します。 + c は混色率で大きければよく混ぜます。 + c の推奨値はN=3のときは0.7|0.5、N=4のときは0.9、N=5..8のときは1です。 */ -extern int coloringCCCD(int p1, int p2, int c1, int c2, int c3, double d); +extern int coloring2c(int p1, int p2, int c1, int c2, double c); +extern int coloring3c(int p1, int p2, int c1, int c2, int c3, double c); +extern int coloring4c(int p1, int p2, int c1, int c2, int c3, int c4, double c); +extern int coloring5c(int p1, int p2, int c1, int c2, int c3, int c4, int c5, double c); +extern int coloring6c(int p1, int p2, int c1, int c2, int c3, int c4, int c5, int c6, double c); +extern int coloring7c(int p1, int p2, int c1, int c2, int c3, int c4, int c5, int c6, int c7, double c); +extern int coloring8c(int p1, int p2, int c1, int c2, int c3, int c4, int c5, int c6, int c7, int c8, double c); /* [名前] @@ -121,7 +175,14 @@ [説明] RGB(赤、緑、青)を基本として、 赤 -> 緑 -> 青 となるようなグラデーションカラーを定義します。 + + setcoloringtype(kind) + int kind; + + にenum coloring_kindsで定義される定数を指定することにより、 + さまざまなグラデーションカラーのバリエーションを選べます。 */ +extern void setcoloringtype(int kind); extern int coloring(int p1, int p2); /* @@ -203,15 +264,15 @@ coloringN --- N色串型グラデーション [形式] - coloringN(p1, p2, n, cs) + coloringN(p1, p2, n, C) int p1, p2; パレット番号p1からp2まで int n; 基本色の数 - int *cs; 基本色の配列 + int *C; 基本色の配列 [説明] 指定されたN色を基本として串型のグラデーションを定義します。 */ -extern int coloringN(int p1, int p2, int n, int *cs); +extern int coloringN(int p1, int p2, int n, int *C); /* [名前] diff -ruN ../xbgi-3_02-20000526/graffit/sources/grafplot-19991023.c ./graffit/sources/grafplot-19991023.c --- ../xbgi-3_02-20000526/graffit/sources/grafplot-19991023.c 1970-01-01 09:00:00.000000000 +0900 +++ ./graffit/sources/grafplot-19991023.c 1999-10-23 16:41:36.000000000 +0900 @@ -0,0 +1,3438 @@ +/* + * Graph plotting interface in graffit < grafplot.c > + * + * Graph-Plot Routines for Borland Graphics Interface + * + * Copyright (C) 1996-1999 Taiji Yamada, AIHARA Electrical Engineering Co.,Ltd. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef MAXDOUBLE +#include +#endif + +#define DEFAULT_LIMIT_PLOT_NUMBER 500 + +static int plotcolor_table[N_COLOR_KINDS] = { + LIGHTRED, + LIGHTGREEN, + LIGHTBLUE, + LIGHTMAGENTA, + YELLOW, + LIGHTCYAN, +}; +#define setplotcolor(colorkind) setcolor(\ + (getmaxcolor()!=1)?plotcolor_table[colorkind]:getcolor()) +#define getplotcolor(colorkind) (\ + (getmaxcolor()!=1)?plotcolor_table[colorkind]:getcolor()) + +#define setplotline(linekind) \ + do {if (!gp.color_kind_flag)setlinestyle(linekind,0,0);} while (0) + +#define setplotpoint(pointkind,c) setpointstyle(pointkind,c,getbkcolor(),6) + +#define OFFSET_BASE 5 + +/* + * 一本の軸の情報の初期化子 + */ +static struct plotaxistype plotaxis0 = { + NULL, /* char *title; */ + 0, 0, /* int x, y; */ + SCALE_DEC, /* int scale_type; */ + 0.0, /* Float from_range; */ + 0.0, /* Float to_range; */ + !0, /* int axis_flag; */ + !0, /* int tick_flag; */ + !0, /* int zero_flag; */ + 0.0, 0.0, /* Float from_tick, to_tick; */ + 1, /* int div_tick; */ + OFFSET_BASE, /* int tick_height; */ + OFFSET_BASE, /* int tick_offset; */ +}; +/* + * プロット対象のベクトルタイプの初期化子 + */ +static struct plotvectortype plotvector0 = { + NULL, /* char *title; */ + 0, 0, /* int x, y */ + 0,0, /* long nl, nh; */ + NULL, /* Float *data; */ + AXIS_C-1, /* int n_axes_are; */ + NULL, /* int *axes_are; */ + PLOT_LINE, /* unsigned long plotkind; */ + COLOR_BLUE, /* int colorkind; */ + LINE_SOLID, /* int linekind; */ + POINT_LOZENGE, /* int pointkind; */ + { 1, 1, 0, 0, }, /* int plotstep[4]; */ +}; +/* + * プロット対象のマトリックスタイプの初期化子 + */ +static struct plotmatrixtype plotmatrix0 = { + NULL, /* char *title; */ + 0, 0, /* int x, y; */ + 0,0,0,0, /* long nrl, nrh, ncl, nch; */ + NULL, /* Float **data; */ + AXIS_C-1, /* int n_axes_are; */ + NULL, /* int *axes_are; */ + PLOT_LINE, /* unsigned long plotkind; */ + COLOR_BLUE, /* int colorkind; */ + LINE_SOLID, /* int linekind; */ + POINT_LOZENGE, /* int pointkind; */ + { 1, 1, 0, 0, }, /* int plotstep[4]; */ +}; +/* + * プロット対象のマトリックスTタイプの初期化子 + */ +static struct plotmatrixTtype plotmatrixT0 = { + NULL, /* char *title; */ + 0, 0, /* int x, y; */ + 0,0,0,0, /* long nrl, nrh, ncl, nch; */ + NULL, /* Float **data; */ + AXIS_C-1, /* int n_axes_are; */ + NULL, /* int *axes_are; */ + PLOT_LINE, /* unsigned long plotkind; */ + COLOR_BLUE, /* int colorkind; */ + LINE_SOLID, /* int linekind; */ + POINT_LOZENGE, /* int pointkind; */ + { 1, 1, 0, 0, }, /* int plotstep[4]; */ +}; +/* + * グラフ全体の情報の初期化子 + */ +static struct plotgraphtype gp = { + NULL, /* char *title; */ + 0, -OFFSET_BASE, /* int x, y; */ + 0, /* int color_kind_flag; */ + 0, /* int color_axis_flag; */ + 0, 0, /* int palette_from, palette_to; */ + R3_PERSPECTIVE, /* int r3kind; */ + SMALL_FONT, 2, /* int tick_font, tick_fontsize; */ + AXIS_C-1, /* int n_axes; */ + NULL, /* struct plotaxistype *axes; */ + 0, /* int n_data; */ + 0, /* int n_vectors; */ + NULL, /* struct plotvectortype *vectors; */ + 0, /* int n_matrices; */ + NULL, /* struct plotmatrixtype *matrices; */ + 0, /* int n_matricesT; */ + NULL, /* struct plotmatrixTtype *matricesT; */ +}; +/* + * グラフ全体の設定関数 + */ +/* グラフプロットのタイトル */ +void set_plotgraph_title(char *title) +{ + if (title) { + gp.title = gp.title? + realloc(gp.title,sizeof(char)*(strlen(title)+1)): + malloc(sizeof(char)*(strlen(title)+1)); + strcpy(gp.title, title); + } + else { + if (gp.title) free(gp.title); + gp.title = NULL; + } +} +/* グラフプロットのタイトルと次元 */ +void set_plotgraph(char *title, int dimension) +{ + void set_plotgraph_n_axes(int n_axes); + + set_plotgraph_title(title); + set_plotgraph_n_axes(dimension); +} +/* グラフプロットでデータをカラーで区別するか */ +void set_plotgraph_color_kind(int color_kind_flag) +{ + gp.color_kind_flag = color_kind_flag; +} +/* グラフプロットでもう一次元をカラーで表現するか */ +void set_plotgraph_color_axis(int color_axis_flag) +{ + gp.color_axis_flag = color_axis_flag; +} +/* グラフプロットの2次元グラフの種類 */ +void set_plotgraph_r2kind(int r2kind) +{ + switch (r2kind) { + case R2_NORMAL: + set_x_plotaxis_scale_type(SCALE_DEC); + set_y_plotaxis_scale_type(SCALE_DEC); + break; + case R2_LOGX: + set_x_plotaxis_scale_type(SCALE_LOG10); + set_y_plotaxis_scale_type(SCALE_DEC); + break; + case R2_LOGY: + set_x_plotaxis_scale_type(SCALE_DEC); + set_y_plotaxis_scale_type(SCALE_LOG10); + break; + case R2_LOGLOG: + set_x_plotaxis_scale_type(SCALE_LOG10); + set_y_plotaxis_scale_type(SCALE_LOG10); + break; + } +} +/* グラフプロットの3次元グラフの種類 */ +void set_plotgraph_r3kind(int r3kind) +{ + gp.r3kind = r3kind; + if (r3kind == R3_STEREO) + setstereotype(ColorGlass); + else if (r3kind == R3_STEREO2) + setstereotype(DoubleImage); +} +/* グラフプロットのリセット */ +void reset_plotgraph(void) +{ + int i; + void reset_ith_plotaxis(int ith); + void reset_ith_plotvector(int ith); + void reset_ith_plotmatrix(int ith); + void reset_ith_plotmatrixT(int ith); + + for (i=AXIS_C; i<=gp.n_axes; i++) + reset_ith_plotaxis(i); + gp.axes = gp.axes?gp.axes+((AXIS_C-1)+1):NULL; + if (gp.axes) free(gp.axes); + gp.axes = NULL; + gp.n_axes = AXIS_C-1; + + for (i=1; i<=gp.n_vectors; i++) + reset_ith_plotvector(i); + if (gp.vectors) free(++gp.vectors); + gp.vectors = NULL; + gp.n_vectors = 0; + + for (i=1; i<=gp.n_matrices; i++) + reset_ith_plotmatrix(i); + if (gp.matrices) free(++gp.matrices); + gp.matrices = NULL; + gp.n_matrices = 0; + + for (i=1; i<=gp.n_matricesT; i++) + reset_ith_plotmatrixT(i); + if (gp.matricesT) free(++gp.matricesT); + gp.matricesT = NULL; + gp.n_matricesT = 0; + + gp.n_data = gp.n_vectors + gp.n_matrices + gp.n_matricesT; + + if (gp.title != NULL) + free(gp.title); + gp.title = NULL; + { + static struct plotgraphtype gp0 = { + NULL, /* char *title; */ + 0, -OFFSET_BASE, /* int x, y; */ + 0, /* int color_kind_flag; */ + 0, /* int color_axis_flag; */ + 0, 0, /* int palette_from, palette_to; */ + R3_PERSPECTIVE, /* int r3kind; */ + SMALL_FONT, 2, /* int tick_font, tick_fontsize; */ + AXIS_C-1, /* int n_axes; */ + NULL, /* struct plotaxistype *axes; */ + 0, /* int n_data; */ + 0, /* int n_vectors; */ + NULL, /* struct plotvectortype *vectors; */ + 0, /* int n_matrices; */ + NULL, /* struct plotmatrixtype *matrices; */ + 0, /* int n_matricesT; */ + NULL, /* struct plotmatrixTtype *matricesT; */ + }; + gp = gp0; + } +} +/* + * プロット軸に関する設定関数群 + */ +/* グラフプロットの次元 */ +void set_plotgraph_n_axes(int n_axes) +{ + int i; + + gp.axes = gp.axes?gp.axes-((AXIS_C-1)+1):NULL; + gp.axes = gp.axes? + realloc(gp.axes,sizeof(struct plotaxistype)*(n_axes-(AXIS_C-1))): + malloc(sizeof(struct plotaxistype)*(n_axes-(AXIS_C-1))); + gp.axes = gp.axes?gp.axes+((AXIS_C-1)+1):NULL; + for (i=gp.n_axes+1; i<=n_axes; i++) + gp.axes[i] = plotaxis0; + gp.n_axes = n_axes; +} +/* プロット軸のタイトルとスケーリングタイプ */ +void set_ith_plotaxis(int ith, char *title, int scale_type) +{ + void set_ith_plotaxis_title(int ith, char *title); + void set_ith_plotaxis_scale_type(int ith, int scale_type); + + set_ith_plotaxis_title(ith, title); + set_ith_plotaxis_scale_type(ith, scale_type); +} +/* プロット軸のタイトル */ +void set_ith_plotaxis_title(int ith, char *title) +{ + if (gp.n_axes < ith) + set_plotgraph_n_axes(ith); + if (title) { + gp.axes[ith].title = gp.axes[ith].title? + realloc(gp.axes[ith].title,sizeof(char)*(strlen(title)+1)): + malloc(sizeof(char)*(strlen(title)+1)); + strcpy(gp.axes[ith].title, title); + } + else { + if (gp.axes[ith].title) free(gp.axes[ith].title); + gp.axes[ith].title = NULL; + } + /* officious default settings */ + if (gp.n_axes == 2) { + if (ith == AXIS_X) { + gp.axes[ith].x = OFFSET_BASE*4; + gp.axes[ith].y = OFFSET_BASE*4; + } + else if (ith == AXIS_Y) { + gp.axes[ith].x = -OFFSET_BASE*4; + gp.axes[ith].y = -OFFSET_BASE*2; + } + } + if (ith == AXIS_C) { + gp.axes[ith].x = OFFSET_BASE*2; + gp.axes[ith].y = -OFFSET_BASE*2; + } +} +/* プロット軸のスケーリングタイプ */ +void set_ith_plotaxis_scale_type(int ith, int scale_type) +{ + if (gp.n_axes < ith) + set_plotgraph_n_axes(ith); + gp.axes[ith].scale_type = scale_type; +} +/* プロット軸のフラグ(主軸,チック,零軸を描くか否か) */ +void set_ith_plotaxis_flags(int ith, + int axis_flag, int tick_flag, int zero_flag) +{ + if (gp.n_axes < ith) + set_plotgraph_n_axes(ith); + gp.axes[ith].axis_flag = axis_flag; + gp.axes[ith].tick_flag = tick_flag; + gp.axes[ith].zero_flag = zero_flag; +} +/* 軸のレンジ */ +void set_ith_plotaxis_range(int ith, Float from_range, Float to_range) +{ + if (gp.n_axes < ith) + set_plotgraph_n_axes(ith); + gp.axes[ith].from_range = from_range; + gp.axes[ith].to_range = to_range; +} +/* 軸のチックの描く場所 */ +void set_ith_plotaxis_tick(int ith, + Float from_tick, Float to_tick, int div_tick) +{ + if (gp.n_axes < ith) + set_plotgraph_n_axes(ith); + gp.axes[ith].from_tick = from_tick; + gp.axes[ith].to_tick = to_tick; + gp.axes[ith].div_tick = div_tick; +} +/* プロット軸のリセット */ +void reset_ith_plotaxis(int ith) +{ + if (gp.axes[ith].title != NULL) + free(gp.axes[ith].title); + gp.axes[ith].title = NULL; +} +void reset_x_plotaxis(void) { reset_ith_plotaxis(AXIS_X); } +void reset_y_plotaxis(void) { reset_ith_plotaxis(AXIS_Y); } +void reset_z_plotaxis(void) { reset_ith_plotaxis(AXIS_Z); } +void reset_w_plotaxis(void) { reset_ith_plotaxis(AXIS_W); } +void reset_c_plotaxis(void) { reset_ith_plotaxis(AXIS_C); } +/* + * プロットベクトルに関する設定関数群 + */ +/* プロットベクトルの数 */ +void set_plotgraph_n_vectors(int n_vectors) +{ + int i; + + gp.vectors = gp.vectors? + realloc(++gp.vectors,sizeof(struct plotvectortype)*n_vectors): + malloc(sizeof(struct plotvectortype)*n_vectors); + gp.vectors--; + for (i=gp.n_vectors+1; i<=n_vectors; i++) + gp.vectors[i] = plotvector0; + gp.n_vectors = n_vectors; + gp.n_data = gp.n_vectors + gp.n_matrices + gp.n_matricesT; +} +/* プロットベクトルのタイトル */ +void set_ith_plotvector_title(int ith, char *title) +{ + if (gp.n_vectors < ith) + set_plotgraph_n_vectors(ith); + if (title) { + gp.vectors[ith].title = gp.vectors[ith].title? + realloc(gp.vectors[ith].title,sizeof(char)*(strlen(title)+1)): + malloc(sizeof(char)*(strlen(title)+1)); + strcpy(gp.vectors[ith].title, title); + } + else { + if (gp.vectors[ith].title) free(gp.vectors[ith].title); + gp.vectors[ith].title = NULL; + } + /* officious default settings */ + gp.vectors[ith].x = -OFFSET_BASE*6; + gp.vectors[ith].y = OFFSET_BASE*4 + OFFSET_BASE*4*(gp.n_data-1); +} +#define set_plotvector_title(title) \ + set_ith_plotvector_title(1,title) +/* プロットベクトルのデータ */ +void set_ith_plotvector_data(int ith, long nl, long nh, Float *data) +{ + void set_ith_plotvector_axis(int ith, int axis, int index); + void set_ith_plotvector_kinds(int ith, unsigned long plotkind, + int colorkind, int linekind, int pointkind); + + if (gp.n_vectors < ith) + set_plotgraph_n_vectors(ith); + gp.vectors[ith].nl = nl; + gp.vectors[ith].nh = nh; + gp.vectors[ith].data = data; + /* officious default settings */ + set_ith_plotvector_axis(ith, AXIS_X, 0); + set_ith_plotvector_axis(ith, AXIS_Y, 1); + set_ith_plotvector_kinds(ith, gp.vectors[ith].plotkind, + gp.n_data-1, gp.n_data-1, gp.n_data-1); +} +/* プロットベクトルのタイトルとデータ */ +void set_ith_plotvector(int ith, char *title, + long nl, long nh, Float *data) +{ + set_ith_plotvector_title(ith, title); + set_ith_plotvector_data(ith, nl, nh, data); +} +/* プロットベクトルの軸へ対応 */ +void set_ith_plotvector_axis(int ith, int axis, int index) +{ + if (gp.n_vectors < ith) + set_plotgraph_n_vectors(ith); + if (gp.vectors[ith].n_axes_are < gp.n_axes) { + int i; + + gp.vectors[ith].axes_are = gp.vectors[ith].axes_are? + gp.vectors[ith].axes_are+((AXIS_C-1)+1):NULL; + gp.vectors[ith].axes_are = gp.vectors[ith].axes_are? + realloc(gp.vectors[ith].axes_are,sizeof(int)*(gp.n_axes-(AXIS_C-1))): + malloc(sizeof(int)*(gp.n_axes-(AXIS_C-1))); + gp.vectors[ith].axes_are = gp.vectors[ith].axes_are? + gp.vectors[ith].axes_are-((AXIS_C-1)+1):NULL; + for (i=gp.vectors[ith].n_axes_are+1; i<=gp.n_axes; i++) + /* impossible -1, because 0 means index, 1 means data[](= data[1][]) */ + gp.vectors[ith].axes_are[i] = -1; + gp.vectors[ith].n_axes_are = gp.n_axes; + } + if (AXIS_C<=axis && axis<=gp.n_axes && -1<=index && index<=1) { + gp.vectors[ith].axes_are[axis] = index; + /* officious default settings */ + if (index==0 && gp.axes[axis].scale_type==SCALE_DEC) { + set_ith_plotaxis_range(axis, gp.vectors[ith].nl, gp.vectors[ith].nh); + } + } +} +/* プロットベクトルの値の取得 */ +Float ith_plotvector_axis_value(int ith_vector, + int ith_axis, int ith) +{ + Float value = 0.0; + + if (ith_vector <= gp.n_vectors) + if (gp.vectors[ith_vector].axes_are[ith_axis] == 1) { + if (gp.vectors[ith_vector].nl <= ith + && ith <= gp.vectors[ith_vector].nh) + value = gp.vectors[ith_vector].data[ith]; + } + else if (gp.vectors[ith_vector].axes_are[ith_axis] == 0) + value = (Float)ith; + return value; +} +/* プロットベクトルのプロット種類の設定 */ +void set_ith_plotvector_kinds(int ith, unsigned long plotkind, + int colorkind, int linekind, int pointkind) +{ + if (gp.n_vectors < ith) + set_plotgraph_n_vectors(ith); + gp.vectors[ith].plotkind = plotkind; + gp.vectors[ith].colorkind = colorkind%N_COLOR_KINDS; + gp.vectors[ith].linekind = linekind%N_LINE_KINDS; + gp.vectors[ith].pointkind = pointkind%N_POINT_KINDS; +} +/* プロットベクトルのプロット種におけるプロットステップ */ +void set_ith_plotvector_step(int ith, unsigned long plotkind, int plotstep) +{ + if (gp.n_vectors < ith) + set_plotgraph_n_vectors(ith); + if (plotkind & PLOT_LINE) + gp.vectors[ith].plotstep[0] = plotstep; + if (plotkind & PLOT_DOT) + gp.vectors[ith].plotstep[1] = plotstep; + if (plotkind & PLOT_POINT) + gp.vectors[ith].plotstep[2] = plotstep; + if (plotkind & PLOT_ERROR) + gp.vectors[ith].plotstep[3] = plotstep; +} +/* プロットベクトルのリセット */ +void reset_ith_plotvector(int ith) +{ + gp.vectors[ith].axes_are = gp.vectors[ith].axes_are? + gp.vectors[ith].axes_are+((AXIS_C-1)+1):NULL; + if (gp.vectors[ith].axes_are) free(gp.vectors[ith].axes_are); + gp.vectors[ith].axes_are = NULL; + gp.vectors[ith].n_axes_are = AXIS_C-1; + if (gp.vectors[ith].title) free(gp.vectors[ith].title); + gp.vectors[ith].title = NULL; +} +void reset_plotvector(void) { reset_ith_plotvector(1); } +/* + * プロットマトリックスに関する設定関数群 + */ +/* プロットマトリックスの数 */ +void set_plotgraph_n_matrices(int n_matrices) +{ + int i; + + gp.matrices = gp.matrices? + realloc(++gp.matrices,sizeof(struct plotmatrixtype)*n_matrices): + malloc(sizeof(struct plotmatrixtype)*n_matrices); + gp.matrices--; + for (i=gp.n_matrices+1; i<=n_matrices; i++) + gp.matrices[i] = plotmatrix0; + gp.n_matrices = n_matrices; + gp.n_data = gp.n_vectors + gp.n_matrices + gp.n_matricesT; +} +/* プロットマトリックスのタイトル */ +void set_ith_plotmatrix_title(int ith, char *title) +{ + if (gp.n_matrices < ith) + set_plotgraph_n_matrices(ith); + if (title) { + gp.matrices[ith].title = gp.matrices[ith].title? + realloc(gp.matrices[ith].title,sizeof(char)*(strlen(title)+1)): + malloc(sizeof(char)*(strlen(title)+1)); + strcpy(gp.matrices[ith].title, title); + } + else { + if (gp.matrices[ith].title) free(gp.matrices[ith].title); + gp.matrices[ith].title = NULL; + } + /* officious default settings */ + gp.matrices[ith].x = -OFFSET_BASE*6; + gp.matrices[ith].y = OFFSET_BASE*4 + OFFSET_BASE*4*(gp.n_data-1); +} +/* プロットマトリックスのデータ */ +void set_ith_plotmatrix_data(int ith, + long nrl, long nrh, long ncl, long nch, Float **data) +{ + int i; + void set_ith_plotmatrix_axis(int ith, int axis, int index); + void set_ith_plotmatrix_kinds(int ith, unsigned long plotkind, + int colorkind, int linekind, int pointkind); + + if (gp.n_matrices < ith) + set_plotgraph_n_matrices(ith); + gp.matrices[ith].nrl = nrl; + gp.matrices[ith].nrh = nrh; + gp.matrices[ith].ncl = ncl; + gp.matrices[ith].nch = nch; + gp.matrices[ith].data = data; + /* officious default settings */ + for (i=0; i<=min(gp.n_axes,nch-ncl+1); i++) + set_ith_plotmatrix_axis(ith, AXIS_X+i, ncl+i); + set_ith_plotmatrix_kinds(ith, PLOT_LINE, + gp.n_data-1, gp.n_data-1, gp.n_data-1); + if (gp.color_axis_flag && gp.n_axes == 2 && nch-ncl+1 > 2) + set_ith_plotmatrix_axis(ith, AXIS_C, ncl+2); + if (gp.color_axis_flag && gp.n_axes == 3 && nch-ncl+1 > 3) + set_ith_plotmatrix_axis(ith, AXIS_C, ncl+3); +} +/* プロットマトリックスのタイトルとデータ */ +void set_ith_plotmatrix(int ith, char *title, + long nrl, long nrh, long ncl, long nch, Float **data) +{ + set_ith_plotmatrix_title(ith, title); + set_ith_plotmatrix_data(ith, nrl, nrh, ncl, nch, data); +} +/* プロットマトリックスの軸へ対応 */ +void set_ith_plotmatrix_axis(int ith, int axis, int index) +{ + if (gp.n_matrices < ith) + set_plotgraph_n_matrices(ith); + if (gp.matrices[ith].n_axes_are < gp.n_axes) { + int i; + + gp.matrices[ith].axes_are = gp.matrices[ith].axes_are? + gp.matrices[ith].axes_are+((AXIS_C-1)+1):NULL; + gp.matrices[ith].axes_are = gp.matrices[ith].axes_are? + realloc(gp.matrices[ith].axes_are,sizeof(int)*(gp.n_axes-(AXIS_C-1))): + malloc(sizeof(int)*(gp.n_axes-(AXIS_C-1))); + gp.matrices[ith].axes_are = gp.matrices[ith].axes_are? + gp.matrices[ith].axes_are-((AXIS_C-1)+1):NULL; + for (i=gp.matrices[ith].n_axes_are+1; i<=gp.n_axes; i++) + /* ncl-2 means no-axis, for ncl-1 means index, ncl-nch means data[][] */ + gp.matrices[ith].axes_are[i] = gp.matrices[ith].ncl-2; + gp.matrices[ith].n_axes_are = gp.n_axes; + } + if (AXIS_C<=axis && axis<=gp.n_axes + && gp.matrices[ith].ncl-2<=index && index<=gp.matrices[ith].nch) { + gp.matrices[ith].axes_are[axis] = index; + /* officious default settings */ + if (index==gp.matrices[ith].ncl-1 + && gp.axes[axis].scale_type==SCALE_DEC) { + set_ith_plotaxis_range(axis, + gp.matrices[ith].nrl, gp.matrices[ith].nrh); + } + } +} +/* プロットマトリックスの値の取得 */ +Float ith_plotmatrix_axis_value(int ith_matrix, + int ith_axis, int ith) +{ + Float value = 0.0; + + if (ith_matrix <= gp.n_matrices) + if (gp.matrices[ith_matrix].ncl + <= gp.matrices[ith_matrix].axes_are[ith_axis] + && gp.matrices[ith_matrix].axes_are[ith_axis] + <= gp.matrices[ith_matrix].nch) { + if (gp.matrices[ith_matrix].nrl <= ith + && ith <= gp.matrices[ith_matrix].nrh) + value = gp.matrices[ith_matrix].data + [ith][gp.matrices[ith_matrix].axes_are[ith_axis]]; + } + else if (gp.matrices[ith_matrix].axes_are[ith_axis] == + gp.matrices[ith_matrix].ncl-1) + value = (Float)ith; + return value; +} +/* プロットマトリックスのプロット種類の設定 */ +void set_ith_plotmatrix_kinds(int ith, unsigned long plotkind, + int colorkind, int linekind, int pointkind) +{ + if (gp.n_matrices < ith) + set_plotgraph_n_matrices(ith); + gp.matrices[ith].plotkind = plotkind; + gp.matrices[ith].colorkind = colorkind%N_COLOR_KINDS; + gp.matrices[ith].linekind = linekind%N_LINE_KINDS; + gp.matrices[ith].pointkind = pointkind%N_POINT_KINDS; +} +/* プロットマトリックスのプロット種におけるプロットステップ */ +void set_ith_plotmatrix_step(int ith, unsigned long plotkind, int plotstep) +{ + if (gp.n_matrices < ith) + set_plotgraph_n_matrices(ith); + if (plotkind & PLOT_LINE) + gp.matrices[ith].plotstep[0] = plotstep; + if (plotkind & PLOT_DOT) + gp.matrices[ith].plotstep[1] = plotstep; + if (plotkind & PLOT_POINT) + gp.matrices[ith].plotstep[2] = plotstep; + if (plotkind & PLOT_ERROR) + gp.matrices[ith].plotstep[3] = plotstep; +} +/* プロットマトリックスのリセット */ +void reset_ith_plotmatrix(int ith) +{ + gp.matrices[ith].axes_are = gp.matrices[ith].axes_are? + gp.matrices[ith].axes_are+((AXIS_C-1)+1):NULL; + if (gp.matrices[ith].axes_are) free(gp.matrices[ith].axes_are); + gp.matrices[ith].axes_are = NULL; + gp.matrices[ith].n_axes_are = AXIS_C-1; + if (gp.matrices[ith].title) free(gp.matrices[ith].title); + gp.matrices[ith].title = NULL; +} +void reset_plotmatrix(void) { reset_ith_plotmatrix(1); } +/* + * プロットマトリックスTに関する設定関数群 + */ +/* プロットマトリックスTの数 */ +void set_plotgraph_n_matricesT(int n_matricesT) +{ + int i; + + gp.matricesT = gp.matricesT? + realloc(++gp.matricesT,sizeof(struct plotmatrixTtype)*n_matricesT): + malloc(sizeof(struct plotmatrixTtype)*n_matricesT); + gp.matricesT--; + for (i=gp.n_matricesT+1; i<=n_matricesT; i++) + gp.matricesT[i] = plotmatrixT0; + gp.n_matricesT = n_matricesT; + gp.n_data = gp.n_vectors + gp.n_matrices + gp.n_matricesT; +} +/* プロットマトリックスのタイトル */ +void set_ith_plotmatrixT_title(int ith, char *title) +{ + if (gp.n_matricesT < ith) + set_plotgraph_n_matricesT(ith); + if (title) { + gp.matricesT[ith].title = gp.matricesT[ith].title? + realloc(gp.matricesT[ith].title,sizeof(char)*(strlen(title)+1)): + malloc(sizeof(char)*(strlen(title)+1)); + strcpy(gp.matricesT[ith].title, title); + } + else { + if (gp.matricesT[ith].title) free(gp.matricesT[ith].title); + gp.matricesT[ith].title = NULL; + } + /* officious default settings */ + gp.matricesT[ith].x = -OFFSET_BASE*6; + gp.matricesT[ith].y = OFFSET_BASE*4 + OFFSET_BASE*4*(gp.n_data-1); +} +/* プロットマトリックスのデータ */ +void set_ith_plotmatrixT_data(int ith, + long nrl, long nrh, long ncl, long nch, + Float **data) +{ + int i; + void set_ith_plotmatrixT_axis(int ith, int axis, int index); + void set_ith_plotmatrixT_kinds(int ith, unsigned long plotkind, + int colorkind, int linekind, int pointkind); + + if (gp.n_matricesT < ith) + set_plotgraph_n_matricesT(ith); + gp.matricesT[ith].nrl = nrl; + gp.matricesT[ith].nrh = nrh; + gp.matricesT[ith].ncl = ncl; + gp.matricesT[ith].nch = nch; + gp.matricesT[ith].data = data; + /* officious default settings */ + for (i=0; i<=min(gp.n_axes,nrh-nrl+1); i++) + set_ith_plotmatrixT_axis(ith, AXIS_X+i, nrl+i); + set_ith_plotmatrixT_kinds(ith, PLOT_LINE, + gp.n_data-1, gp.n_data-1, gp.n_data-1); + if (gp.color_axis_flag && gp.n_axes == 2 && nch-ncl+1 > 2) + set_ith_plotmatrixT_axis(ith, AXIS_C, nrl+2); + if (gp.color_axis_flag && gp.n_axes == 3 && nch-ncl+1 > 3) + set_ith_plotmatrixT_axis(ith, AXIS_C, nrl+3); +} +/* プロットマトリックスのタイトルとデータ */ +void set_ith_plotmatrixT(int ith, char *title, + long nrl, long nrh, long ncl, long nch, Float **data) +{ + set_ith_plotmatrixT_title(ith, title); + set_ith_plotmatrixT_data(ith, nrl, nrh, ncl, nch, data); +} +/* プロットマトリックスTの軸へ対応 */ +void set_ith_plotmatrixT_axis(int ith, int axis, int index) +{ + if (gp.n_matricesT < ith) + set_plotgraph_n_matricesT(ith); + if (gp.matricesT[ith].n_axes_are < gp.n_axes) { + int i; + + gp.matricesT[ith].axes_are = gp.matricesT[ith].axes_are? + gp.matricesT[ith].axes_are+((AXIS_C-1)+1):NULL; + gp.matricesT[ith].axes_are = gp.matricesT[ith].axes_are? + realloc(gp.matricesT[ith].axes_are,sizeof(int)*(gp.n_axes+1)): + malloc(sizeof(int)*(gp.n_axes+1)); + gp.matricesT[ith].axes_are = gp.matricesT[ith].axes_are? + gp.matricesT[ith].axes_are-((AXIS_C-1)+1):NULL; + for (i=gp.matricesT[ith].n_axes_are+1; i<=gp.n_axes; i++) + /* nrl-2 means no-axis, for nrl-1 means index, nrl-nrh means data[][] */ + gp.matricesT[ith].axes_are[i] = gp.matricesT[ith].nrl-2; + gp.matricesT[ith].n_axes_are = gp.n_axes; + } + if (AXIS_C<=axis && axis<=gp.n_axes + && gp.matricesT[ith].nrl-2<=index && index<=gp.matricesT[ith].nrh) { + gp.matricesT[ith].axes_are[axis] = index; + /* officious default settings */ + if (index==gp.matricesT[ith].nrl-1 + && gp.axes[axis].scale_type==SCALE_DEC) { + set_ith_plotaxis_range(axis, + gp.matricesT[ith].ncl, gp.matricesT[ith].nch); + } + } +} +/* プロットマトリックスTの値の取得 */ +Float ith_plotmatrixT_axis_value(int ith_matrixT, + int ith_axis, int ith) +{ + Float value = 0.0; + + if (ith_matrixT <= gp.n_matricesT) + if (gp.matricesT[ith_matrixT].nrl + <= gp.matricesT[ith_matrixT].axes_are[ith_axis] + && gp.matricesT[ith_matrixT].axes_are[ith_axis] + <= gp.matricesT[ith_matrixT].nrh) { + if (gp.matricesT[ith_matrixT].ncl <= ith + && ith <= gp.matricesT[ith_matrixT].nch) + value = gp.matricesT[ith_matrixT].data + [gp.matricesT[ith_matrixT].axes_are[ith_axis]][ith]; + } + else if (gp.matricesT[ith_matrixT].axes_are[ith_axis] == + gp.matricesT[ith_matrixT].nrl-1) + value = (Float)ith; + return value; +} +/* プロットマトリックスTのプロット種類の設定 */ +void set_ith_plotmatrixT_kinds(int ith, unsigned long plotkind, + int colorkind, int linekind, int pointkind) +{ + if (gp.n_matricesT < ith) + set_plotgraph_n_matricesT(ith); + gp.matricesT[ith].plotkind = plotkind; + gp.matricesT[ith].colorkind = colorkind%N_COLOR_KINDS; + gp.matricesT[ith].linekind = linekind%N_LINE_KINDS; + gp.matricesT[ith].pointkind = pointkind%N_POINT_KINDS; +} +/* プロットマトリックスTのプロット種におけるプロットステップ */ +void set_ith_plotmatrixT_step(int ith, unsigned long plotkind, int plotstep) +{ + if (gp.n_matricesT < ith) + set_plotgraph_n_matricesT(ith); + if (plotkind & PLOT_LINE) + gp.matricesT[ith].plotstep[0] = plotstep; + if (plotkind & PLOT_DOT) + gp.matricesT[ith].plotstep[1] = plotstep; + if (plotkind & PLOT_POINT) + gp.matricesT[ith].plotstep[2] = plotstep; + if (plotkind & PLOT_ERROR) + gp.matricesT[ith].plotstep[3] = plotstep; +} +/* プロットマトリックスTのリセット */ +void reset_ith_plotmatrixT(int ith) +{ + gp.matricesT[ith].axes_are = gp.matricesT[ith].axes_are? + gp.matricesT[ith].axes_are+((AXIS_C-1)+1):NULL; + if (gp.matricesT[ith].axes_are) free(gp.matricesT[ith].axes_are); + gp.matricesT[ith].axes_are = NULL; + gp.matricesT[ith].n_axes_are = AXIS_C-1; + if (gp.matricesT[ith].title) free(gp.matricesT[ith].title); + gp.matricesT[ith].title = NULL; +} +void reset_plotmatrixT(void) { reset_ith_plotmatrixT(1); } +/* + * 描画関係の内部マクロ + */ +/* ログ座標軸のためのマクロ */ +#define l2(axis,value) \ + (log((value)/gp.axes[axis].from_range)\ + *(gp.axes[axis].to_range-gp.axes[axis].from_range)\ + /log(gp.axes[axis].to_range/gp.axes[axis].from_range)\ + +gp.axes[axis].from_range) +#define lga(axis,value) \ + ((gp.axes[axis].scale_type==SCALE_LOG10)?l2(axis,value):(value)) +#define lgavectors(ith,i,v) do {\ + int ith_axis; for (ith_axis=1;ith_axis<=gp.n_axes;ith_axis++) {\ + v[ith_axis-1]=((gp.axes[ith].scale_type==SCALE_LOG10)\ + ?l2(ith_axis,ith_plotvector_axis_value(ith,ith_axis,i))\ + :(ith_plotvector_axis_value(ith,ith_axis,i)));}} while (0) +#define lgamatrices(ith,i,v) do {\ + int ith_axis; for (ith_axis=1;ith_axis<=gp.n_axes;ith_axis++) {\ + v[ith_axis-1]=((gp.axes[ith].scale_type==SCALE_LOG10)\ + ?l2(ith_axis,ith_plotmatrix_axis_value(ith,ith_axis,i))\ + :(ith_plotmatrix_axis_value(ith,ith_axis,i)));}} while (0) +#define lgamatricesT(ith,i,v) do {\ + int ith_axis; for (ith_axis=1;ith_axis<=gp.n_axes;ith_axis++) {\ + v[ith_axis-1]=((gp.axes[ith].scale_type==SCALE_LOG10)\ + ?l2(ith_axis,ith_plotmatrixT_axis_value(ith,ith_axis,i))\ + :(ith_plotmatrixT_axis_value(ith,ith_axis,i)));}} while (0) +/* カラーのためのマクロ */ +#define wvcv(w) \ + (((w)-gp.axes[AXIS_C].from_range)*(vp.bottom-vp.top)\ + /(gp.axes[AXIS_C].to_range-gp.axes[AXIS_C].from_range)) +#define wvch(w) \ + (((w)-gp.axes[AXIS_C].from_range)*(vp.right-vp.left)\ + /(gp.axes[AXIS_C].to_range-gp.axes[AXIS_C].from_range)) +#define saxc(w) do {\ + if (gp.color_axis_flag)setcolor_(w);} while (0) +#define gaxc(w) \ + (gp.color_axis_flag?getcolor_(w):getcolor()) +#define spc(ith) do {\ + if (gp.color_kind_flag)setplotcolor(ith);} while (0) +#define gpc(ith) \ + (gp.color_kind_flag?getplotcolor(ith):getcolor()) +#define gaxpc(w,ith) \ + (gp.color_axis_flag?getcolor_(w):gp.color_kind_flag\ + ?getplotcolor(ith):getcolor()) +#define swap(a,b) do {Float tmp;tmp=b;b=a;a=tmp;} while (0) +#if 0 /* old, before version 3.02 generic 19991101 */ +/* 3次元描画のためのマクロ */ +#define r3_lines(n,p) \ + (gp.r3kind==R3_ROTATION)?linesr3_(n,p):\ + linesp3_(n,p) +#define r3_line(x0,y0,z0,x1,y1,z1) \ + (gp.r3kind==R3_ROTATION)?liner3_(x0,y0,z0,x1,y1,z1):\ + linep3_(x0,y0,z0,x1,y1,z1) +#define r3_lineto(x,y,z) \ + (gp.r3kind==R3_ROTATION)?linetor3_(x,y,z):\ + linetop3_(x,y,z) +#define r3_putpixels(n,p,c) \ + (gp.r3kind==R3_ROTATION)?putpixelsr3_(n,p,c):\ + putpixelsp3_(n,p,c) +#define r3_putpixel(x,y,z,c) \ + (gp.r3kind==R3_ROTATION)?putpixelr3_(x,y,z,c):\ + putpixelp3_(x,y,z,c) +#define r3_putpoints(n,p) \ + (gp.r3kind==R3_ROTATION)?putpointsr3_(n,p):\ + putpointsp3_(n,p) +#define r3_putpoint(x,y,z) \ + (gp.r3kind==R3_ROTATION)?putpointr3_(x,y,z):\ + putpointp3_(x,y,z) +#define r3_moveto(x,y,z) \ + (gp.r3kind==R3_ROTATION)?movetor3_(x,y,z):\ + movetop3_(x,y,z) +#define r3_outtextxy(x,y,z,s) \ + (gp.r3kind==R3_ROTATION)?outtextxyr3_(x,y,z,s):\ + outtextxyp3_(x,y,z,s) +/* n次元描画のためのマクロ */ +#define rn_lines(n,p) \ + (gp.r3kind==R3_ROTATION)?linesrn_(n,p):\ + linespn_(n,p) +#define rn_line(v0,v1) \ + (gp.r3kind==R3_ROTATION)?linern_(v0,v1):\ + linepn_(v0,v1) +#define rn_lineto(v) \ + (gp.r3kind==R3_ROTATION)?linetorn_(v):\ + linetopn_(v) +#define rn_putpixels(n,p,c) \ + (gp.r3kind==R3_ROTATION)?putpixelsrn_(n,p,c):\ + putpixelspn_(n,p,c) +#define rn_putpixel(v,c) \ + (gp.r3kind==R3_ROTATION)?putpixelrn_(v,c):\ + putpixelpn_(v,c) +#define rn_putpoints(n,p) \ + (gp.r3kind==R3_ROTATION)?putpointsrn_(n,p):\ + putpointspn_(n,p) +#define rn_putpoint(v) \ + (gp.r3kind==R3_ROTATION)?putpointrn_(v):\ + putpointpn_(v) +#define rn_moveto(v) \ + (gp.r3kind==R3_ROTATION)?movetorn_(v):\ + movetopn_(v) +#define rn_outtextxy(v,s) \ + (gp.r3kind==R3_ROTATION)?outtextxyrn_(v,s):\ + outtextxypn_(v,s) +#define rn_cube(v0,v,f) \ + (gp.r3kind==R3_ROTATION)?cubern_(v0,v,f):\ + cubepn_(v0,v,f) +#else /* since version 3.02 generic 19991101 */ +#if 0 /* following macros are very slowly to compile, so it's off */ +/* 3次元描画のためのマクロ */ +#define r3_lines(n,p) do {\ + if (gp.r3kind==R3_ROTATION) linesr3_(n,p);\ + else if (gp.r3kind==R3_PERSPECTIVE) linesp3_(n,p);\ + else liness3_(n,p); } while (0) +#define r3_line(x0,y0,z0,x1,y1,z1) do {\ + if (gp.r3kind==R3_ROTATION) liner3_(x0,y0,z0,x1,y1,z1);\ + else if (gp.r3kind==R3_PERSPECTIVE) linep3_(x0,y0,z0,x1,y1,z1);\ + else lines3_(x0,y0,z0,x1,y1,z1); } while (0) +#define r3_lineto(x,y,z) do {\ + if (gp.r3kind==R3_ROTATION) linetor3_(x,y,z);\ + else if (gp.r3kind==R3_PERSPECTIVE) linetop3_(x,y,z);\ + else linetos3_(x,y,z); } while (0) +#define r3_putpixels(n,p,c) do {\ + if (gp.r3kind==R3_ROTATION) putpixelsr3_(n,p,c);\ + else if (gp.r3kind==R3_PERSPECTIVE) putpixelsp3_(n,p,c);\ + else putpixelss3_(n,p,c); } while (0) +#define r3_putpixel(x,y,z,c) do {\ + if (gp.r3kind==R3_ROTATION) putpixelr3_(x,y,z,c);\ + else if (gp.r3kind==R3_PERSPECTIVE) putpixelp3_(x,y,z,c);\ + else putpixels3_(x,y,z,c); } while (0) +#define r3_putpoints(n,p) do {\ + if (gp.r3kind==R3_ROTATION) putpointsr3_(n,p);\ + else if (gp.r3kind==R3_PERSPECTIVE) putpointsp3_(n,p);\ + else putpointss3_(n,p); } while (0) +#define r3_putpoint(x,y,z) do {\ + if (gp.r3kind==R3_ROTATION) putpointr3_(x,y,z);\ + else if (gp.r3kind==R3_PERSPECTIVE) putpointp3_(x,y,z);\ + else putpoints3_(x,y,z); } while (0) +#define r3_moveto(x,y,z) do {\ + if (gp.r3kind==R3_ROTATION) movetor3_(x,y,z);\ + else if (gp.r3kind==R3_PERSPECTIVE) movetop3_(x,y,z);\ + else movetos3_(x,y,z); } while (0) +#define r3_outtextxy(x,y,z,s) do {\ + if (gp.r3kind==R3_ROTATION) outtextxyr3_(x,y,z,s);\ + else if (gp.r3kind==R3_PERSPECTIVE) outtextxyp3_(x,y,z,s);\ + else outtextxys3_(x,y,z,s); } while (0) +/* n次元描画のためのマクロ */ +#define rn_lines(n,p) do {\ + if (gp.r3kind==R3_ROTATION) linesrn_(n,p);\ + else if (gp.r3kind==R3_PERSPECTIVE) linespn_(n,p);\ + else linessn_(n,p); } while (0) +#define rn_line(v0,v1) do {\ + if (gp.r3kind==R3_ROTATION) linern_(v0,v1);\ + else if (gp.r3kind==R3_PERSPECTIVE) linepn_(v0,v1);\ + else linesn_(v0,v1); } while (0) +#define rn_lineto(v) do {\ + if (gp.r3kind==R3_ROTATION) linetorn_(v);\ + else if (gp.r3kind==R3_PERSPECTIVE) linetopn_(v);\ + else linetosn_(v); } while (0) +#define rn_putpixels(n,p,c) do {\ + if (gp.r3kind==R3_ROTATION) putpixelsrn_(n,p,c);\ + else if (gp.r3kind==R3_PERSPECTIVE) putpixelspn_(n,p,c);\ + else putpixelssn_(n,p,c); } while (0) +#define rn_putpixel(v,c) do {\ + if (gp.r3kind==R3_ROTATION) putpixelrn_(v,c);\ + else if (gp.r3kind==R3_PERSPECTIVE) putpixelpn_(v,c);\ + else putpixelsn_(v,c); } while (0) +#define rn_putpoints(n,p) do {\ + if (gp.r3kind==R3_ROTATION) putpointsrn_(n,p);\ + else if (gp.r3kind==R3_PERSPECTIVE) putpointspn_(n,p);\ + else putpointssn_(n,p); } while (0) +#define rn_putpoint(v) do {\ + if (gp.r3kind==R3_ROTATION) putpointrn_(v);\ + else if (gp.r3kind==R3_PERSPECTIVE) putpointpn_(v);\ + else putpointsn_(v); } while (0) +#define rn_moveto(v) do {\ + if (gp.r3kind==R3_ROTATION) movetorn_(v);\ + else if (gp.r3kind==R3_PERSPECTIVE) movetopn_(v);\ + else movetosn_(v); } while (0) +#define rn_outtextxy(v,s) do {\ + if (gp.r3kind==R3_ROTATION) outtextxyrn_(v,s);\ + else if (gp.r3kind==R3_PERSPECTIVE) outtextxypn_(v,s);\ + else outtextxysn_(v,s); } while (0) +#define rn_cube(v0,v,f) do {\ + if (gp.r3kind==R3_ROTATION) cubern_(v0,v,f);\ + else if (gp.r3kind==R3_PERSPECTIVE) cubepn_(v0,v,f);\ + else cubesn_(v0,v,f); } while (0) +#else +/* 3次元描画のための関数 */ +void r3_lines(int n,double *p) { + if (gp.r3kind==R3_ROTATION) linesr3_(n,p); + else if (gp.r3kind==R3_PERSPECTIVE) linesp3_(n,p); + else liness3_(n,p); } +void r3_line(double x0,double y0,double z0,double x1,double y1,double z1) { + if (gp.r3kind==R3_ROTATION) liner3_(x0,y0,z0,x1,y1,z1); + else if (gp.r3kind==R3_PERSPECTIVE) linep3_(x0,y0,z0,x1,y1,z1); + else lines3_(x0,y0,z0,x1,y1,z1); } +void r3_lineto(double x,double y,double z) { + if (gp.r3kind==R3_ROTATION) linetor3_(x,y,z); + else if (gp.r3kind==R3_PERSPECTIVE) linetop3_(x,y,z); + else linetos3_(x,y,z); } +void r3_putpixels(int n,double *p,int c) { + if (gp.r3kind==R3_ROTATION) putpixelsr3_(n,p,c); + else if (gp.r3kind==R3_PERSPECTIVE) putpixelsp3_(n,p,c); + else putpixelss3_(n,p,c); } +void r3_putpixel(double x,double y,double z,int c) { + if (gp.r3kind==R3_ROTATION) putpixelr3_(x,y,z,c); + else if (gp.r3kind==R3_PERSPECTIVE) putpixelp3_(x,y,z,c); + else putpixels3_(x,y,z,c); } +void r3_putpoints(int n,double *p) { + if (gp.r3kind==R3_ROTATION) putpointsr3_(n,p); + else if (gp.r3kind==R3_PERSPECTIVE) putpointsp3_(n,p); + else putpointss3_(n,p); } +void r3_putpoint(double x,double y,double z) { + if (gp.r3kind==R3_ROTATION) putpointr3_(x,y,z); + else if (gp.r3kind==R3_PERSPECTIVE) putpointp3_(x,y,z); + else putpoints3_(x,y,z); } +void r3_moveto(double x,double y,double z) { + if (gp.r3kind==R3_ROTATION) movetor3_(x,y,z); + else if (gp.r3kind==R3_PERSPECTIVE) movetop3_(x,y,z); + else movetos3_(x,y,z); } +void r3_outtextxy(double x,double y,double z,char *s) { + if (gp.r3kind==R3_ROTATION) outtextxyr3_(x,y,z,s); + else if (gp.r3kind==R3_PERSPECTIVE) outtextxyp3_(x,y,z,s); + else outtextxys3_(x,y,z,s); } +/* n次元描画のための関数 */ +void rn_lines(int n,double **p) { + if (gp.r3kind==R3_ROTATION) linesrn_(n,p); + else if (gp.r3kind==R3_PERSPECTIVE) linespn_(n,p); + else linessn_(n,p); } +void rn_line(double *v0,double *v1) { + if (gp.r3kind==R3_ROTATION) linern_(v0,v1); + else if (gp.r3kind==R3_PERSPECTIVE) linepn_(v0,v1); + else linesn_(v0,v1); } +void rn_lineto(double *v) { + if (gp.r3kind==R3_ROTATION) linetorn_(v); + else if (gp.r3kind==R3_PERSPECTIVE) linetopn_(v); + else linetosn_(v); } +void rn_putpixels(int n,double **p,int c) { + if (gp.r3kind==R3_ROTATION) putpixelsrn_(n,p,c); + else if (gp.r3kind==R3_PERSPECTIVE) putpixelspn_(n,p,c); + else putpixelssn_(n,p,c); } +void rn_putpixel(double *v,int c) { + if (gp.r3kind==R3_ROTATION) putpixelrn_(v,c); + else if (gp.r3kind==R3_PERSPECTIVE) putpixelpn_(v,c); + else putpixelsn_(v,c); } +void rn_putpoints(int n,double **p) { + if (gp.r3kind==R3_ROTATION) putpointsrn_(n,p); + else if (gp.r3kind==R3_PERSPECTIVE) putpointspn_(n,p); + else putpointssn_(n,p); } +void rn_putpoint(double *v) { + if (gp.r3kind==R3_ROTATION) putpointrn_(v); + else if (gp.r3kind==R3_PERSPECTIVE) putpointpn_(v); + else putpointsn_(v); } +void rn_moveto(double *v) { + if (gp.r3kind==R3_ROTATION) movetorn_(v); + else if (gp.r3kind==R3_PERSPECTIVE) movetopn_(v); + else movetosn_(v); } +void rn_outtextxy(double *v,char *s) { + if (gp.r3kind==R3_ROTATION) outtextxyrn_(v,s); + else if (gp.r3kind==R3_PERSPECTIVE) outtextxypn_(v,s); + else outtextxysn_(v,s); } +void rn_cube(double *v0,double *v,int f) { + if (gp.r3kind==R3_ROTATION) cubern_(v0,v,f); + else if (gp.r3kind==R3_PERSPECTIVE) cubepn_(v0,v,f); + else cubesn_(v0,v,f); } +#endif +#endif +/* + * 内部関数 + */ +static void cp_vec(long N, double a[], double b[]) +{ + long i; + + for (i=0; i 0) n++; + r2p = (double*)malloc(sizeof(double)*n*2); + spc(gp.vectors[ith].colorkind); + setplotline(gp.vectors[ith].linekind); + for (i0=i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) { + long j = (i-i0)/step; + + r2p[2*j+0]=lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)); + r2p[2*j+1]=lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i)); + } + lines_(n, r2p); + free(r2p); + } else +#endif + { + int step; + + step = gp.vectors[ith].plotstep[0]? + gp.vectors[ith].plotstep[0]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + spc(gp.vectors[ith].colorkind); + setplotline(gp.vectors[ith].linekind); + i = gp.vectors[ith].nl; + moveto_(lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i))); + for (i=gp.vectors[ith].nl+step; + i<=gp.vectors[ith].nh; i+=step) { + saxc(lga(AXIS_C,ith_plotvector_axis_value(ith,AXIS_C,i))); + lineto_(lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i))); + } + } + if (gp.color_axis_flag) setcolor(c); + /* データの線種を描く */ + if (gp.vectors[ith].title) { + spc(gp.vectors[ith].colorkind); + line((vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE, + gp.vectors[ith].y, + (vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE*4, + gp.vectors[ith].y); + } + if (gp.color_kind_flag||gp.color_axis_flag) setcolor(c); + } + if (gp.vectors[ith].plotkind & PLOT_DOT) { +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double *r2p; + int step; + + step = gp.vectors[ith].plotstep[1]? + gp.vectors[ith].plotstep[1]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.vectors[ith].nh-gp.vectors[ith].nl+1)/step; + m = (gp.vectors[ith].nh-gp.vectors[ith].nl+1)%step; + if (m > 0) n++; + r2p = (double*)malloc(sizeof(double)*n*2); + for (i0=i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) { + long j = (i-i0)/step; + + r2p[2*j+0]=lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)); + r2p[2*j+1]=lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i)); + } + putpixels_(n, r2p, + gaxpc(lga(AXIS_C, + ith_plotvector_axis_value(ith,AXIS_C,i)), + gp.vectors[ith].colorkind)); + free(r2p); + } else +#endif + { + int step; + + step = gp.vectors[ith].plotstep[1]? + gp.vectors[ith].plotstep[1]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) + putpixel_(lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i)), + gaxpc(lga(AXIS_C, + ith_plotvector_axis_value(ith,AXIS_C,i)), + gp.vectors[ith].colorkind)); + } + /* データのドット種を描く */ + if (gp.vectors[ith].title) + putpixel((vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE*5/2, + gp.vectors[ith].y, + gpc(gp.vectors[ith].colorkind)); + } + if (gp.vectors[ith].plotkind & PLOT_POINT) { + int step; + + step = gp.vectors[ith].plotstep[2]? + gp.vectors[ith].plotstep[2]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) { + setplotpoint(gp.vectors[ith].pointkind, + gaxpc(lga(AXIS_C, + ith_plotvector_axis_value(ith,AXIS_C,i)), + gp.vectors[ith].colorkind)); + putpoint_(lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i))); + } + /* データのポイント種を描く */ + if (gp.vectors[ith].title) { + setplotpoint(gp.vectors[ith].pointkind, + gpc(gp.vectors[ith].colorkind)); + putpoint((vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE*5/2, + gp.vectors[ith].y); + } + } + } + /* マトリックスタイプを描く */ + for (ith=1; ith<=gp.n_matrices; ith++) { + /* データのタイトルを描く */ + struct viewporttype vp; + struct textsettingstype ts; + + if (gp.matrices[ith].title) { + getviewsettings(&vp); + gettextsettings(&ts); + settextjustify(RIGHT_TEXT, CENTER_TEXT); + outtextxy((vp.right-vp.left)+gp.matrices[ith].x, + gp.matrices[ith].y, gp.matrices[ith].title); + settextjustify(ts.horiz, ts.vert); + } + if (gp.matrices[ith].plotkind & PLOT_LINE) { + int c = 0; + + if (gp.color_kind_flag||gp.color_axis_flag) c = getcolor(); +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double *r2p; + int step; + + step = gp.matrices[ith].plotstep[0]? + gp.matrices[ith].plotstep[0]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/step; + m = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)%step; + if (m > 0) n++; + r2p = (double*)malloc(sizeof(double)*n*2); + spc(gp.matrices[ith].colorkind); + setplotline(gp.matrices[ith].linekind); + for (i0=i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) { + long j = (i-i0)/step; + + r2p[2*j+0]=lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)); + r2p[2*j+1]=lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i)); + } + lines_(n, r2p); + free(r2p); + } else +#endif + { + int step; + + step = gp.matrices[ith].plotstep[0]? + gp.matrices[ith].plotstep[0]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + spc(gp.matrices[ith].colorkind); + setplotline(gp.matrices[ith].linekind); + i = gp.matrices[ith].nrl; + moveto_(lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i))); + for (i=gp.matrices[ith].nrl+step; + i<=gp.matrices[ith].nrh; i+=step) { + saxc(lga(AXIS_C,ith_plotmatrix_axis_value(ith,AXIS_C,i))); + lineto_(lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i))); + } + } + if (gp.color_axis_flag) setcolor(c); + /* データの線種を描く */ + if (gp.matrices[ith].title) { + spc(gp.matrices[ith].colorkind); + line((vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE, + gp.matrices[ith].y, + (vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE*4, + gp.matrices[ith].y); + } + if (gp.color_kind_flag||gp.color_axis_flag) setcolor(c); + } + if (gp.matrices[ith].plotkind & PLOT_DOT) { +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double *r2p; + int step; + + step = gp.matrices[ith].plotstep[1]? + gp.matrices[ith].plotstep[1]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/step; + m = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)%step; + if (m > 0) n++; + r2p = (double*)malloc(sizeof(double)*n*2); + for (i0=i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) { + long j = (i-i0)/step; + + r2p[2*j+0]=lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)); + r2p[2*j+1]=lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i)); + } + putpixels_(n, r2p, + gaxpc(lga(AXIS_C, + ith_plotmatrix_axis_value(ith,AXIS_C,i)), + gp.matrices[ith].colorkind)); + free(r2p); + } else +#endif + { + int step; + + step = gp.matrices[ith].plotstep[1]? + gp.matrices[ith].plotstep[1]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) + putpixel_(lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i)), + gaxpc(lga(AXIS_C, + ith_plotmatrix_axis_value(ith,AXIS_C,i)), + gp.matrices[ith].colorkind)); + } + /* データのドット種を描く */ + if (gp.matrices[ith].title) + putpixel((vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE*5/2, + gp.matrices[ith].y, + gpc(gp.matrices[ith].colorkind)); + } + if (gp.matrices[ith].plotkind & PLOT_POINT) { + int step; + + step = gp.matrices[ith].plotstep[2]? + gp.matrices[ith].plotstep[2]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) { + setplotpoint(gp.matrices[ith].pointkind, + gaxpc(lga(AXIS_C, + ith_plotmatrix_axis_value(ith,AXIS_C,i)), + gp.matrices[ith].colorkind)); + putpoint_(lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i))); + } + /* データのポイント種を描く */ + if (gp.matrices[ith].title) { + setplotpoint(gp.matrices[ith].pointkind, + gpc(gp.matrices[ith].colorkind)); + putpoint((vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE*5/2, + gp.matrices[ith].y); + } + } + } + /* マトリックスTタイプを描く */ + for (ith=1; ith<=gp.n_matricesT; ith++) { + /* データのタイトルを描く */ + struct viewporttype vp; + struct textsettingstype ts; + + if (gp.matricesT[ith].title) { + getviewsettings(&vp); + gettextsettings(&ts); + settextjustify(RIGHT_TEXT, CENTER_TEXT); + outtextxy((vp.right-vp.left)+gp.matricesT[ith].x, + gp.matricesT[ith].y, gp.matricesT[ith].title); + settextjustify(ts.horiz, ts.vert); + } + if (gp.matricesT[ith].plotkind & PLOT_LINE) { + int c = 0; + + if (gp.color_kind_flag||gp.color_axis_flag) c = getcolor(); +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double *r2p; + int step; + + step = gp.matricesT[ith].plotstep[0]? + gp.matricesT[ith].plotstep[0]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/step; + m = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)%step; + if (m > 0) n++; + r2p = (double*)malloc(sizeof(double)*n*2); + spc(gp.matricesT[ith].colorkind); + setplotline(gp.matricesT[ith].linekind); + for (i0=i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) { + long j = (i-i0)/step; + + r2p[2*j+0]=lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)); + r2p[2*j+1]=lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i)); + } + lines_(n, r2p); + free(r2p); + } else +#endif + { + int step; + + step = gp.matricesT[ith].plotstep[0]? + gp.matricesT[ith].plotstep[0]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + spc(gp.matricesT[ith].colorkind); + setplotline(gp.matricesT[ith].linekind); + i = gp.matricesT[ith].ncl; + moveto_(lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i))); + for (i=gp.matricesT[ith].ncl+step; + i<=gp.matricesT[ith].nch; i+=step) { + saxc(lga(AXIS_C,ith_plotmatrixT_axis_value(ith,AXIS_C,i))); + lineto_(lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i))); + } + } + if (gp.color_axis_flag) setcolor(c); + /* データの線種を描く */ + if (gp.matricesT[ith].title) { + spc(gp.matricesT[ith].colorkind); + line((vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE, + gp.matricesT[ith].y, + (vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE*4, + gp.matricesT[ith].y); + } + if (gp.color_kind_flag||gp.color_axis_flag) setcolor(c); + } + if (gp.matricesT[ith].plotkind & PLOT_DOT) { +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double *r2p; + int step; + + step = gp.matricesT[ith].plotstep[1]? + gp.matricesT[ith].plotstep[1]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/step; + m = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)%step; + if (m > 0) n++; + r2p = (double*)malloc(sizeof(double)*n*2); + for (i0=i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) { + long j = (i-i0)/step; + + r2p[2*j+0]=lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)); + r2p[2*j+1]=lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i)); + } + putpixels_(n, r2p, + gaxpc(lga(AXIS_C, + ith_plotmatrixT_axis_value(ith,AXIS_C,i)), + gp.matricesT[ith].colorkind)); + free(r2p); + } else +#endif + { + int step; + + step = gp.matricesT[ith].plotstep[1]? + gp.matricesT[ith].plotstep[1]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) + putpixel_(lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i)), + gaxpc(lga(AXIS_C, + ith_plotmatrixT_axis_value(ith,AXIS_C,i)), + gp.matricesT[ith].colorkind)); + } + /* データのドット種を描く */ + if (gp.matricesT[ith].title) + putpixel((vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE*5/2, + gp.matricesT[ith].y, + gpc(gp.matricesT[ith].colorkind)); + } + if (gp.matricesT[ith].plotkind & PLOT_POINT) { + int step; + + step = gp.matricesT[ith].plotstep[2]? + gp.matricesT[ith].plotstep[2]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) { + setplotpoint(gp.matricesT[ith].pointkind, + gaxpc(lga(AXIS_C, + ith_plotmatrixT_axis_value(ith,AXIS_C,i)), + gp.matricesT[ith].colorkind)); + putpoint_(lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)), + lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i))); + } + /* データのポイント種を描く */ + if (gp.matricesT[ith].title) { + setplotpoint(gp.matricesT[ith].pointkind, + gpc(gp.matricesT[ith].colorkind)); + putpoint((vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE*5/2, + gp.matricesT[ith].y); + } + } + } + setlinestyle(ls.linestyle, ls.upattern, ls.thickness); +} +/* 2次元グラフを描く */ +void plotgraph_2d(void) +{ + plotgraph_color_axis(); + plotgraph_2d_axes(); + plotgraph_2d_data(); +} +/* 3次元グラフの軸を描く */ +void plotgraph_3d_axes(void) +{ + int i; + int ith_axis; + char buf[256]; + + setrotationport_(gp.axes[AXIS_X].from_range, gp.axes[AXIS_Z].from_range, + gp.axes[AXIS_Y].from_range, gp.axes[AXIS_X].to_range, + gp.axes[AXIS_Z].to_range, gp.axes[AXIS_Y].to_range); + for (ith_axis=AXIS_X; ith_axis<=AXIS_Z; ith_axis++) { + if (gp.axes[ith_axis].title) { + /* 軸のタイトルを描く */ + Float x = 0.0, y = 0.0, z = 0.0; + struct viewporttype vp; + struct textsettingstype ts; + + getviewsettings(&vp); + gettextsettings(&ts); + settextjustify(CENTER_TEXT, CENTER_TEXT); + if (ith_axis == AXIS_X) { + x=(gp.axes[AXIS_X].from_range+gp.axes[AXIS_X].to_range)/2; + y=(gp.axes[AXIS_Y].from_range*12+gp.axes[AXIS_Y].to_range*(-2))/10; + z=gp.axes[AXIS_Z].from_range; + r3_outtextxy(x, z, y, gp.axes[ith_axis].title); + } + else if (ith_axis == AXIS_Y) { + x=(gp.axes[AXIS_X].from_range*(-2)+gp.axes[AXIS_X].to_range*12)/10; + y=(gp.axes[AXIS_Y].from_range+gp.axes[AXIS_Y].to_range)/2; + z=gp.axes[AXIS_Z].from_range; + r3_outtextxy(x, z, y, gp.axes[ith_axis].title); + } + else { + x=(gp.axes[AXIS_X].from_range*11+gp.axes[AXIS_X].to_range*(-1))/10; + y=(gp.axes[AXIS_Y].from_range*11+gp.axes[AXIS_Y].to_range*(-1))/10; + z=(gp.axes[AXIS_Z].from_range+gp.axes[AXIS_Z].to_range)/2; + r3_outtextxy(x, z, y, gp.axes[ith_axis].title); + } + settextjustify(ts.horiz, ts.vert); + } + if (gp.axes[ith_axis].axis_flag) { + /* 主軸を描く */ + struct linesettingstype ls; + + getlinesettings(&ls); + setlinestyle(SOLID_LINE, 0, 2); + if (ith_axis == AXIS_X) { + r3_line(gp.axes[AXIS_X].from_range, + gp.axes[AXIS_Z].from_range, + gp.axes[AXIS_Y].from_range, + gp.axes[AXIS_X].to_range, + gp.axes[AXIS_Z].from_range, + gp.axes[AXIS_Y].from_range); + r3_line(gp.axes[AXIS_X].from_range, + gp.axes[AXIS_Z].from_range, + gp.axes[AXIS_Y].to_range, + gp.axes[AXIS_X].to_range, + gp.axes[AXIS_Z].from_range, + gp.axes[AXIS_Y].to_range); + } + else if (ith_axis == AXIS_Z) + r3_line(gp.axes[AXIS_X].from_range, + gp.axes[AXIS_Z].from_range, + gp.axes[AXIS_Y].from_range, + gp.axes[AXIS_X].from_range, + gp.axes[AXIS_Z].to_range, + gp.axes[AXIS_Y].from_range); + else if (ith_axis == AXIS_Y) { + r3_line(gp.axes[AXIS_X].from_range, + gp.axes[AXIS_Z].from_range, + gp.axes[AXIS_Y].from_range, + gp.axes[AXIS_X].from_range, + gp.axes[AXIS_Z].from_range, + gp.axes[AXIS_Y].to_range); + r3_line(gp.axes[AXIS_X].to_range, + gp.axes[AXIS_Z].from_range, + gp.axes[AXIS_Y].from_range, + gp.axes[AXIS_X].to_range, + gp.axes[AXIS_Z].from_range, + gp.axes[AXIS_Y].to_range); + } + setlinestyle(ls.linestyle, ls.upattern, ls.thickness); + } + if (gp.axes[ith_axis].tick_flag + && (gp.axes[ith_axis].from_tick!=gp.axes[ith_axis].to_tick)) { + /* チックを描く */ + Float tick; + int tick_height, tick_offset; + Float x = 0.0, y = 0.0, z = 0.0; + struct viewporttype vp; + struct textsettingstype ts; + struct linesettingstype ls; + + getviewsettings(&vp); + gettextsettings(&ts); + getlinesettings(&ls); + settextstyle(gp.tick_font, HORIZ_DIR, gp.tick_fontsize); + setlinestyle(SOLID_LINE, 0, 1); + settextjustify(CENTER_TEXT, CENTER_TEXT); + for (i=0; i<=gp.axes[ith_axis].div_tick; i++) { + tick = (gp.axes[ith_axis].scale_type==SCALE_DEC)? + get_tick_axis(i,gp.axes[ith_axis].div_tick, + gp.axes[ith_axis].from_tick, + gp.axes[ith_axis].to_tick) + :get_tick_log10_axis(i,gp.axes[ith_axis].div_tick, + gp.axes[ith_axis].from_tick, + gp.axes[ith_axis].to_tick); + if (tick + 0) n++; + r3p = (double*)malloc(sizeof(double)*n*3); + spc(gp.vectors[ith].colorkind); + setplotline(gp.vectors[ith].linekind); + for (i0=i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) { + long j = (i-i0)/step; + + r3p[3*j+0]=lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)); + r3p[3*j+1]=lga(AXIS_Z,ith_plotvector_axis_value(ith,AXIS_Z,i)); + r3p[3*j+2]=lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i)); + } + r3_lines(n, r3p); + free(r3p); + } else +#endif + { + int step; + + step = gp.vectors[ith].plotstep[0]? + gp.vectors[ith].plotstep[0]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + spc(gp.vectors[ith].colorkind); + setplotline(gp.vectors[ith].linekind); + i = gp.vectors[ith].nl; + r3_moveto(lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotvector_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i))); + for (i=gp.vectors[ith].nl+step; + i<=gp.vectors[ith].nh; i+=step) { + saxc(lga(AXIS_C,ith_plotvector_axis_value(ith,AXIS_C,i))); + r3_lineto(lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotvector_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i))); + } + } + if (gp.color_axis_flag) setcolor(c); + /* データの線種を描く */ + if (gp.vectors[ith].title) { + spc(gp.vectors[ith].colorkind); + line((vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE, + gp.vectors[ith].y, + (vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE*4, + gp.vectors[ith].y); + } + if (gp.color_kind_flag||gp.color_axis_flag) setcolor(c); + } + if (gp.vectors[ith].plotkind & PLOT_DOT) { +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double *r3p; + int step; + + step = gp.vectors[ith].plotstep[1]? + gp.vectors[ith].plotstep[1]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.vectors[ith].nh-gp.vectors[ith].nl+1)/step; + m = (gp.vectors[ith].nh-gp.vectors[ith].nl+1)%step; + if (m > 0) n++; + r3p = (double*)malloc(sizeof(double)*n*3); + for (i0=i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) { + long j = (i-i0)/step; + + r3p[3*j+0]=lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)); + r3p[3*j+1]=lga(AXIS_Z,ith_plotvector_axis_value(ith,AXIS_Z,i)); + r3p[3*j+2]=lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i)); + } + r3_putpixels(n, r3p, + gaxpc(lga(AXIS_C, + ith_plotvector_axis_value(ith,AXIS_C,i)), + gp.vectors[ith].colorkind)); + free(r3p); + } else +#endif + { + int step; + + step = gp.vectors[ith].plotstep[1]? + gp.vectors[ith].plotstep[1]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) + r3_putpixel(lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotvector_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i)), + gaxpc(lga(AXIS_C, + ith_plotvector_axis_value(ith,AXIS_C,i)), + gp.vectors[ith].colorkind)); + } + /* データのドット種を描く */ + if (gp.vectors[ith].title) + putpixel((vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE*5/2, + gp.vectors[ith].y, + gpc(gp.vectors[ith].colorkind)); + } + if (gp.vectors[ith].plotkind & PLOT_POINT) { + int step; + + step = gp.vectors[ith].plotstep[2]? + gp.vectors[ith].plotstep[2]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) { + setplotpoint(gp.vectors[ith].pointkind, + gaxpc(lga(AXIS_C, + ith_plotvector_axis_value(ith,AXIS_C,i)), + gp.vectors[ith].colorkind)); + r3_putpoint(lga(AXIS_X,ith_plotvector_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotvector_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotvector_axis_value(ith,AXIS_Y,i))); + } + /* データのポイント種を描く */ + if (gp.vectors[ith].title) { + setplotpoint(gp.vectors[ith].pointkind, + gpc(gp.vectors[ith].colorkind)); + putpoint((vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE*5/2, + gp.vectors[ith].y); + } + } + } + /* マトリックスタイプを描く */ + for (ith=1; ith<=gp.n_matrices; ith++) { + /* データのタイトルを描く */ + struct viewporttype vp; + struct textsettingstype ts; + + if (gp.matrices[ith].title) { + getviewsettings(&vp); + gettextsettings(&ts); + settextjustify(RIGHT_TEXT, CENTER_TEXT); + outtextxy((vp.right-vp.left)+gp.matrices[ith].x, + gp.matrices[ith].y, gp.matrices[ith].title); + settextjustify(ts.horiz, ts.vert); + } + if (gp.matrices[ith].plotkind & PLOT_LINE) { + int c = 0; + + if (gp.color_kind_flag||gp.color_axis_flag) c = getcolor(); +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double *r3p; + int step; + + step = gp.matrices[ith].plotstep[0]? + gp.matrices[ith].plotstep[0]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/step; + m = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)%step; + if (m > 0) n++; + r3p = (double*)malloc(sizeof(double)*n*3); + spc(gp.matrices[ith].colorkind); + setplotline(gp.matrices[ith].linekind); + for (i0=i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) { + long j = (i-i0)/step; + + r3p[3*j+0]=lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)); + r3p[3*j+1]=lga(AXIS_Z,ith_plotmatrix_axis_value(ith,AXIS_Z,i)); + r3p[3*j+2]=lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i)); + } + r3_lines(n, r3p); + free(r3p); + } else +#endif + { + int step; + + step = gp.matrices[ith].plotstep[0]? + gp.matrices[ith].plotstep[0]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + spc(gp.matrices[ith].colorkind); + setplotline(gp.matrices[ith].linekind); + i = gp.matrices[ith].nrl; + r3_moveto(lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotmatrix_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i))); + for (i=gp.matrices[ith].nrl+step; + i<=gp.matrices[ith].nrh; i+=step) { + saxc(lga(AXIS_C,ith_plotmatrix_axis_value(ith,AXIS_C,i))); + r3_lineto(lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotmatrix_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i))); + } + } + if (gp.color_axis_flag) setcolor(c); + /* データの線種を描く */ + if (gp.matrices[ith].title) { + spc(gp.matrices[ith].colorkind); + line((vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE, + gp.matrices[ith].y, + (vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE*4, + gp.matrices[ith].y); + } + if (gp.color_kind_flag||gp.color_axis_flag) setcolor(c); + } + if (gp.matrices[ith].plotkind & PLOT_DOT) { +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double *r3p; + int step; + + step = gp.matrices[ith].plotstep[1]? + gp.matrices[ith].plotstep[1]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/step; + m = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)%step; + if (m > 0) n++; + r3p = (double*)malloc(sizeof(double)*n*3); + for (i0=i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) { + long j = (i-i0)/step; + + r3p[3*j+0]=lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)); + r3p[3*j+1]=lga(AXIS_Z,ith_plotmatrix_axis_value(ith,AXIS_Z,i)); + r3p[3*j+2]=lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i)); + } + r3_putpixels(n, r3p, + gaxpc(lga(AXIS_C, + ith_plotmatrix_axis_value(ith,AXIS_C,i)), + gp.matrices[ith].colorkind)); + free(r3p); + } else +#endif + { + int step; + + step = gp.matrices[ith].plotstep[1]? + gp.matrices[ith].plotstep[1]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) + r3_putpixel(lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotmatrix_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i)), + gaxpc(lga(AXIS_C, + ith_plotmatrix_axis_value(ith,AXIS_C,i)), + gp.matrices[ith].colorkind)); + } + /* データのドット種を描く */ + if (gp.matrices[ith].title) + putpixel((vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE*5/2, + gp.matrices[ith].y, + gpc(gp.matrices[ith].colorkind)); + } + if (gp.matrices[ith].plotkind & PLOT_POINT) { + int step; + + step = gp.matrices[ith].plotstep[2]? + gp.matrices[ith].plotstep[2]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) { + setplotpoint(gp.matrices[ith].pointkind, + gaxpc(lga(AXIS_C, + ith_plotmatrix_axis_value(ith,AXIS_C,i)), + gp.matrices[ith].colorkind)); + r3_putpoint(lga(AXIS_X,ith_plotmatrix_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotmatrix_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotmatrix_axis_value(ith,AXIS_Y,i))); + } + /* データのポイント種を描く */ + if (gp.matrices[ith].title) { + setplotpoint(gp.matrices[ith].pointkind, + gpc(gp.matrices[ith].colorkind)); + putpoint((vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE*5/2, + gp.matrices[ith].y); + } + } + } + /* マトリックスTタイプを描く */ + for (ith=1; ith<=gp.n_matricesT; ith++) { + /* データのタイトルを描く */ + struct viewporttype vp; + struct textsettingstype ts; + + if (gp.matricesT[ith].title) { + getviewsettings(&vp); + gettextsettings(&ts); + settextjustify(RIGHT_TEXT, CENTER_TEXT); + outtextxy((vp.right-vp.left)+gp.matricesT[ith].x, + gp.matricesT[ith].y, gp.matricesT[ith].title); + settextjustify(ts.horiz, ts.vert); + } + if (gp.matricesT[ith].plotkind & PLOT_LINE) { + int c = 0; + + if (gp.color_kind_flag||gp.color_axis_flag) c = getcolor(); +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double *r3p; + int step; + + step = gp.matricesT[ith].plotstep[0]? + gp.matricesT[ith].plotstep[0]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/step; + m = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)%step; + if (m > 0) n++; + r3p = (double*)malloc(sizeof(double)*n*3); + spc(gp.matricesT[ith].colorkind); + setplotline(gp.matricesT[ith].linekind); + for (i0=i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) { + long j = (i-i0)/step; + + r3p[3*j+0]=lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)); + r3p[3*j+1]=lga(AXIS_Z,ith_plotmatrixT_axis_value(ith,AXIS_Z,i)); + r3p[3*j+2]=lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i)); + } + r3_lines(n, r3p); + free(r3p); + } else +#endif + { + int step; + + step = gp.matricesT[ith].plotstep[0]? + gp.matricesT[ith].plotstep[0]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + spc(gp.matricesT[ith].colorkind); + setplotline(gp.matricesT[ith].linekind); + i = gp.matricesT[ith].ncl; + r3_moveto(lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotmatrixT_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i))); + for (i=gp.matricesT[ith].ncl+step; + i<=gp.matricesT[ith].nch; i+=step) { + saxc(lga(AXIS_C,ith_plotmatrixT_axis_value(ith,AXIS_C,i))); + r3_lineto(lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotmatrixT_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i))); + } + } + if (gp.color_axis_flag) setcolor(c); + /* データの線種を描く */ + if (gp.matricesT[ith].title) { + spc(gp.matricesT[ith].colorkind); + line((vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE, + gp.matricesT[ith].y, + (vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE*4, + gp.matricesT[ith].y); + } + if (gp.color_kind_flag||gp.color_axis_flag) setcolor(c); + } + if (gp.matricesT[ith].plotkind & PLOT_DOT) { +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double *r3p; + int step; + + step = gp.matricesT[ith].plotstep[1]? + gp.matricesT[ith].plotstep[1]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/step; + m = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)%step; + if (m > 0) n++; + r3p = (double*)malloc(sizeof(double)*n*3); + for (i0=i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) { + long j = (i-i0)/step; + + r3p[3*j+0]=lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)); + r3p[3*j+1]=lga(AXIS_Z,ith_plotmatrixT_axis_value(ith,AXIS_Z,i)); + r3p[3*j+2]=lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i)); + } + r3_putpixels(n, r3p, + gaxpc(lga(AXIS_C, + ith_plotmatrixT_axis_value(ith,AXIS_C,i)), + gp.matricesT[ith].colorkind)); + free(r3p); + } else +#endif + { + int step; + + step = gp.matricesT[ith].plotstep[1]? + gp.matricesT[ith].plotstep[1]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) + r3_putpixel(lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotmatrixT_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i)), + gaxpc(lga(AXIS_C, + ith_plotmatrixT_axis_value(ith,AXIS_C,i)), + gp.matricesT[ith].colorkind)); + } + /* データのドット種を描く */ + if (gp.matricesT[ith].title) + putpixel((vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE*5/2, + gp.matricesT[ith].y, + gpc(gp.matricesT[ith].colorkind)); + } + if (gp.matricesT[ith].plotkind & PLOT_POINT) { + int step; + + step = gp.matricesT[ith].plotstep[2]? + gp.matricesT[ith].plotstep[2]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) { + setplotpoint(gp.matricesT[ith].pointkind, + gaxpc(lga(AXIS_C, + ith_plotmatrixT_axis_value(ith,AXIS_C,i)), + gp.matricesT[ith].colorkind)); + r3_putpoint(lga(AXIS_X,ith_plotmatrixT_axis_value(ith,AXIS_X,i)), + lga(AXIS_Z,ith_plotmatrixT_axis_value(ith,AXIS_Z,i)), + lga(AXIS_Y,ith_plotmatrixT_axis_value(ith,AXIS_Y,i))); + } + /* データのポイント種を描く */ + if (gp.matricesT[ith].title) { + setplotpoint(gp.matricesT[ith].pointkind, + gpc(gp.matricesT[ith].colorkind)); + putpoint((vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE*5/2, + gp.matricesT[ith].y); + } + } + } + setlinestyle(ls.linestyle, ls.upattern, ls.thickness); +} +/* 3次元グラフを描く */ +void plotgraph_3d(void) +{ + plotgraph_color_axis(); + plotgraph_3d_axes(); + plotgraph_3d_data(); +} +/* n次元グラフの軸を描く */ +void plotgraph_nd_axes(void) +{ + int i; + int ith_axis; + char buf[256]; + double *v0, *v; + + v0 = malloc(sizeof(double)*gp.n_axes); + v = malloc(sizeof(double)*gp.n_axes); + for (i=0; i 0) n++; + rnp = mat(n,gp.n_axes); + spc(gp.vectors[ith].colorkind); + setplotline(gp.vectors[ith].linekind); + for (i0=i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) { + long j = (i-i0)/step; + + lgavectors(ith,i,v); + swap(v[1],v[2]); + cp_vec(gp.n_axes,v,rnp[j]); + } + rn_lines(n, rnp); + free_mat(rnp); + } else +#endif + { + int step; + + step = gp.vectors[ith].plotstep[0]? + gp.vectors[ith].plotstep[0]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + spc(gp.vectors[ith].colorkind); + setplotline(gp.vectors[ith].linekind); + i = gp.vectors[ith].nl; + lgavectors(ith,i,v); + swap(v[1],v[2]); + rn_moveto(v); + for (i=gp.vectors[ith].nl+step; + i<=gp.vectors[ith].nh; i+=step) { + saxc(lga(AXIS_C,ith_plotvector_axis_value(ith,AXIS_C,i))); + lgavectors(ith,i,v); + swap(v[1],v[2]); + rn_lineto(v); + } + } + if (gp.color_axis_flag) setcolor(c); + /* データの線種を描く */ + if (gp.vectors[ith].title) { + spc(gp.vectors[ith].colorkind); + line((vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE, + gp.vectors[ith].y, + (vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE*4, + gp.vectors[ith].y); + } + if (gp.color_kind_flag||gp.color_axis_flag) setcolor(c); + } + if (gp.vectors[ith].plotkind & PLOT_DOT) { +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double **rnp; + int step; + + step = gp.vectors[ith].plotstep[1]? + gp.vectors[ith].plotstep[1]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.vectors[ith].nh-gp.vectors[ith].nl+1)/step; + m = (gp.vectors[ith].nh-gp.vectors[ith].nl+1)%step; + if (m > 0) n++; + rnp = mat(n,gp.n_axes); + for (i0=i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) { + long j = (i-i0)/step; + + lgavectors(ith,i,v); + swap(v[1],v[2]); + cp_vec(gp.n_axes,v,rnp[j]); + } + rn_putpixels(n, rnp, + gaxpc(lga(AXIS_C, + ith_plotvector_axis_value(ith,AXIS_C,i)), + gp.vectors[ith].colorkind)); + free_mat(rnp); + } else +#endif + { + int step; + + step = gp.vectors[ith].plotstep[1]? + gp.vectors[ith].plotstep[1]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) { + lgavectors(ith,i,v); + swap(v[1],v[2]); + rn_putpixel(v, + gaxpc(lga(AXIS_C, + ith_plotvector_axis_value(ith,AXIS_C,i)), + gp.vectors[ith].colorkind)); + } + } + /* データのドット種を描く */ + if (gp.vectors[ith].title) + putpixel((vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE*5/2, + gp.vectors[ith].y, + gpc(gp.vectors[ith].colorkind)); + } + if (gp.vectors[ith].plotkind & PLOT_POINT) { + int step; + + step = gp.vectors[ith].plotstep[2]? + gp.vectors[ith].plotstep[2]: + max(1,(gp.vectors[ith].nh-gp.vectors[ith].nl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i+=step) { + lgavectors(ith,i,v); + swap(v[1],v[2]); + setplotpoint(gp.vectors[ith].pointkind, + gaxpc(lga(AXIS_C, + ith_plotvector_axis_value(ith,AXIS_C,i)), + gp.vectors[ith].colorkind)); + rn_putpoint(v); + } + /* データのポイント種を描く */ + if (gp.vectors[ith].title) { + setplotpoint(gp.vectors[ith].pointkind, + gpc(gp.vectors[ith].colorkind)); + putpoint((vp.right-vp.left)+gp.vectors[ith].x+OFFSET_BASE*5/2, + gp.vectors[ith].y); + } + } + } + /* マトリックスタイプを描く */ + for (ith=1; ith<=gp.n_matrices; ith++) { + /* データのタイトルを描く */ + struct viewporttype vp; + struct textsettingstype ts; + + if (gp.matrices[ith].title) { + getviewsettings(&vp); + gettextsettings(&ts); + settextjustify(RIGHT_TEXT, CENTER_TEXT); + outtextxy((vp.right-vp.left)+gp.matrices[ith].x, + gp.matrices[ith].y, gp.matrices[ith].title); + settextjustify(ts.horiz, ts.vert); + } + if (gp.matrices[ith].plotkind & PLOT_LINE) { + int c = 0; + + if (gp.color_kind_flag||gp.color_axis_flag) c = getcolor(); +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double **rnp; + int step; + + step = gp.matrices[ith].plotstep[0]? + gp.matrices[ith].plotstep[0]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/step; + m = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)%step; + if (m > 0) n++; + rnp = mat(n,gp.n_axes); + spc(gp.matrices[ith].colorkind); + setplotline(gp.matrices[ith].linekind); + for (i0=i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) { + long j = (i-i0)/step; + + lgamatrices(ith,i,v); + swap(v[1],v[2]); + cp_vec(gp.n_axes,v,rnp[j]); + } + rn_lines(n, rnp); + free_mat(rnp); + } else +#endif + { + int step; + + step = gp.matrices[ith].plotstep[0]? + gp.matrices[ith].plotstep[0]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + spc(gp.matrices[ith].colorkind); + setplotline(gp.matrices[ith].linekind); + i = gp.matrices[ith].nrl; + lgamatrices(ith,i,v); + swap(v[1],v[2]); + rn_moveto(v); + for (i=gp.matrices[ith].nrl+step; + i<=gp.matrices[ith].nrh; i+=step) { + saxc(lga(AXIS_C,ith_plotmatrix_axis_value(ith,AXIS_C,i))); + lgamatrices(ith,i,v); + swap(v[1],v[2]); + rn_lineto(v); + } + } + if (gp.color_axis_flag) setcolor(c); + /* データの線種を描く */ + if (gp.matrices[ith].title) { + spc(gp.matrices[ith].colorkind); + line((vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE, + gp.matrices[ith].y, + (vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE*4, + gp.matrices[ith].y); + } + if (gp.color_kind_flag||gp.color_axis_flag) setcolor(c); + } + if (gp.matrices[ith].plotkind & PLOT_DOT) { +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double **rnp; + int step; + + step = gp.matrices[ith].plotstep[1]? + gp.matrices[ith].plotstep[1]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/step; + m = (gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)%step; + if (m > 0) n++; + rnp = mat(n,gp.n_axes); + for (i0=i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) { + long j = (i-i0)/step; + + lgamatrices(ith,i,v); + swap(v[1],v[2]); + cp_vec(gp.n_axes,v,rnp[j]); + } + rn_putpixels(n, rnp, + gaxpc(lga(AXIS_C, + ith_plotmatrix_axis_value(ith,AXIS_C,i)), + gp.matrices[ith].colorkind)); + free_mat(rnp); + } else +#endif + { + int step; + + step = gp.matrices[ith].plotstep[1]? + gp.matrices[ith].plotstep[1]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) { + lgamatrices(ith,i,v); + swap(v[1],v[2]); + rn_putpixel(v, + gaxpc(lga(AXIS_C, + ith_plotmatrix_axis_value(ith,AXIS_C,i)), + gp.matrices[ith].colorkind)); + } + } + /* データのドット種を描く */ + if (gp.matrices[ith].title) + putpixel((vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE*5/2, + gp.matrices[ith].y, + gpc(gp.matrices[ith].colorkind)); + } + if (gp.matrices[ith].plotkind & PLOT_POINT) { + int step; + + step = gp.matrices[ith].plotstep[2]? + gp.matrices[ith].plotstep[2]: + max(1,(gp.matrices[ith].nrh-gp.matrices[ith].nrl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i+=step) { + lgamatrices(ith,i,v); + swap(v[1],v[2]); + setplotpoint(gp.matrices[ith].pointkind, + gaxpc(lga(AXIS_C, + ith_plotmatrix_axis_value(ith,AXIS_C,i)), + gp.matrices[ith].colorkind)); + rn_putpoint(v); + } + /* データのポイント種を描く */ + if (gp.matrices[ith].title) { + setplotpoint(gp.matrices[ith].pointkind, + gpc(gp.matrices[ith].colorkind)); + putpoint((vp.right-vp.left)+gp.matrices[ith].x+OFFSET_BASE*5/2, + gp.matrices[ith].y); + } + } + } + /* マトリックスTタイプを描く */ + for (ith=1; ith<=gp.n_matricesT; ith++) { + /* データのタイトルを描く */ + struct viewporttype vp; + struct textsettingstype ts; + + if (gp.matricesT[ith].title) { + getviewsettings(&vp); + gettextsettings(&ts); + settextjustify(RIGHT_TEXT, CENTER_TEXT); + outtextxy((vp.right-vp.left)+gp.matricesT[ith].x, + gp.matricesT[ith].y, gp.matricesT[ith].title); + settextjustify(ts.horiz, ts.vert); + } + if (gp.matricesT[ith].plotkind & PLOT_LINE) { + int c = 0; + + if (gp.color_kind_flag||gp.color_axis_flag) c = getcolor(); +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double **rnp; + int step; + + step = gp.matricesT[ith].plotstep[0]? + gp.matricesT[ith].plotstep[0]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/step; + m = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)%step; + if (m > 0) n++; + rnp = mat(n,gp.n_axes); + spc(gp.matricesT[ith].colorkind); + setplotline(gp.matricesT[ith].linekind); + for (i0=i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) { + long j = (i-i0)/step; + + lgamatricesT(ith,i,v); + swap(v[1],v[2]); + cp_vec(gp.n_axes,v,rnp[j]); + } + rn_lines(n, rnp); + free_mat(rnp); + } else +#endif + { + int step; + + step = gp.matricesT[ith].plotstep[0]? + gp.matricesT[ith].plotstep[0]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + spc(gp.matricesT[ith].colorkind); + setplotline(gp.matricesT[ith].linekind); + i = gp.matricesT[ith].ncl; + lgamatricesT(ith,i,v); + swap(v[1],v[2]); + rn_moveto(v); + for (i=gp.matricesT[ith].ncl+step; + i<=gp.matricesT[ith].nch; i+=step) { + saxc(lga(AXIS_C,ith_plotmatrixT_axis_value(ith,AXIS_C,i))); + lgamatricesT(ith,i,v); + swap(v[1],v[2]); + rn_lineto(v); + } + } + if (gp.color_axis_flag) setcolor(c); + /* データの線種を描く */ + if (gp.matricesT[ith].title) { + spc(gp.matricesT[ith].colorkind); + line((vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE, + gp.matricesT[ith].y, + (vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE*4, + gp.matricesT[ith].y); + } + if (gp.color_kind_flag||gp.color_axis_flag) setcolor(c); + } + if (gp.matricesT[ith].plotkind & PLOT_DOT) { +#if 1 /* safe since version 3.02 generic 19991101 */ + if (!gp.color_axis_flag) { + long n, m, i0; + double **rnp; + int step; + + step = gp.matricesT[ith].plotstep[1]? + gp.matricesT[ith].plotstep[1]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + n = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/step; + m = (gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)%step; + if (m > 0) n++; + rnp = mat(n,gp.n_axes); + for (i0=i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) { + long j = (i-i0)/step; + + lgamatricesT(ith,i,v); + swap(v[1],v[2]); + cp_vec(gp.n_axes,v,rnp[j]); + } + rn_putpixels(n, rnp, + gaxpc(lga(AXIS_C, + ith_plotmatrixT_axis_value(ith,AXIS_C,i)), + gp.matricesT[ith].colorkind)); + free_mat(rnp); + } else +#endif + { + int step; + + step = gp.matricesT[ith].plotstep[1]? + gp.matricesT[ith].plotstep[1]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) { + lgamatricesT(ith,i,v); + swap(v[1],v[2]); + rn_putpixel(v, + gaxpc(lga(AXIS_C, + ith_plotmatrixT_axis_value(ith,AXIS_C,i)), + gp.matricesT[ith].colorkind)); + } + } + /* データのドット種を描く */ + if (gp.matricesT[ith].title) + putpixel((vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE*5/2, + gp.matricesT[ith].y, + gpc(gp.matricesT[ith].colorkind)); + } + if (gp.matricesT[ith].plotkind & PLOT_POINT) { + int step; + + step = gp.matricesT[ith].plotstep[2]? + gp.matricesT[ith].plotstep[2]: + max(1,(gp.matricesT[ith].nch-gp.matricesT[ith].ncl+1)/ + DEFAULT_LIMIT_PLOT_NUMBER); + for (i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i+=step) { + lgamatricesT(ith,i,v); + swap(v[1],v[2]); + setplotpoint(gp.matricesT[ith].pointkind, + gaxpc(lga(AXIS_C, + ith_plotmatrixT_axis_value(ith,AXIS_C,i)), + gp.matricesT[ith].colorkind)); + rn_putpoint(v); + } + /* データのポイント種を描く */ + if (gp.matricesT[ith].title) { + setplotpoint(gp.matricesT[ith].pointkind, + gpc(gp.matricesT[ith].colorkind)); + putpoint((vp.right-vp.left)+gp.matricesT[ith].x+OFFSET_BASE*5/2, + gp.matricesT[ith].y); + } + } + } + setlinestyle(ls.linestyle, ls.upattern, ls.thickness); + free(v0); + free(v); +} +/* n次元グラフを描く */ +void plotgraph_nd(void) +{ + plotgraph_color_axis(); + plotgraph_nd_axes(); + plotgraph_nd_data(); +} +/* 設定された形式で描く */ +void plotgraph(void) +{ + long i; + int ith_axis, ith; + + /* + * タイトルを描く + */ + if (gp.title) { + struct viewporttype vp; + + getviewsettings(&vp); + settextjustify(CENTER_TEXT, BOTTOM_TEXT); + outtextxy((vp.right-vp.left)/2+gp.x, gp.y, gp.title); + } + for (ith_axis=gp.color_axis_flag?AXIS_C:AXIS_X; + ith_axis<=gp.n_axes; ith_axis++) { + if (gp.axes[ith_axis].from_range == gp.axes[ith_axis].to_range) { + /* + * レンジの自動スケール + */ + gp.axes[ith_axis].from_range = MAXDOUBLE; + gp.axes[ith_axis].to_range = -MAXDOUBLE; + /* ベクトルタイプを調べる */ + for (ith=1; ith<=gp.n_vectors; ith++) { + for (i=gp.vectors[ith].nl; + i<=gp.vectors[ith].nh; i++) { + gp.axes[ith_axis].from_range + = min(gp.axes[ith_axis].from_range, + ith_plotvector_axis_value(ith,ith_axis,i)); + gp.axes[ith_axis].to_range + = max(gp.axes[ith_axis].to_range, + ith_plotvector_axis_value(ith,ith_axis,i)); + } + } + /* マトリックスタイプを調べる */ + for (ith=1; ith<=gp.n_matrices; ith++) { + for (i=gp.matrices[ith].nrl; + i<=gp.matrices[ith].nrh; i++) { + gp.axes[ith_axis].from_range + = min(gp.axes[ith_axis].from_range, + ith_plotmatrix_axis_value(ith,ith_axis,i)); + gp.axes[ith_axis].to_range + = max(gp.axes[ith_axis].to_range, + ith_plotmatrix_axis_value(ith,ith_axis,i)); + } + } + /* マトリックスTタイプを調べる */ + for (ith=1; ith<=gp.n_matricesT; ith++) { + for (i=gp.matricesT[ith].ncl; + i<=gp.matricesT[ith].nch; i++) { + gp.axes[ith_axis].from_range + = min(gp.axes[ith_axis].from_range, + ith_plotmatrixT_axis_value(ith,ith_axis,i)); + gp.axes[ith_axis].to_range + = max(gp.axes[ith_axis].to_range, + ith_plotmatrixT_axis_value(ith,ith_axis,i)); + } + } + /* + * チックを設定する(レンジが自動設定の場合) + */ + if (gp.axes[ith_axis].from_tick == gp.axes[ith_axis].to_tick) { + if (gp.axes[ith_axis].scale_type == SCALE_DEC) + pretty_ticks_axis(gp.axes[ith_axis].from_range, + gp.axes[ith_axis].to_range, + &gp.axes[ith_axis].div_tick, + &gp.axes[ith_axis].from_tick, + &gp.axes[ith_axis].to_tick); + else + pretty_ticks_log10_axis(gp.axes[ith_axis].from_range, + gp.axes[ith_axis].to_range, + &gp.axes[ith_axis].div_tick, + &gp.axes[ith_axis].from_tick, + &gp.axes[ith_axis].to_tick); + gp.axes[ith_axis].from_range = gp.axes[ith_axis].from_tick; + gp.axes[ith_axis].to_range = gp.axes[ith_axis].to_tick; + } + } + else { + /* + * チックを設定する(レンジがユーザー定義の場合) + */ + if (gp.axes[ith_axis].from_tick == gp.axes[ith_axis].to_tick) { + if (gp.axes[ith_axis].scale_type == SCALE_DEC) + pretty_ticks_axis(gp.axes[ith_axis].from_range, + gp.axes[ith_axis].to_range, + &gp.axes[ith_axis].div_tick, + &gp.axes[ith_axis].from_tick, + &gp.axes[ith_axis].to_tick); + else + pretty_ticks_log10_axis(gp.axes[ith_axis].from_range, + gp.axes[ith_axis].to_range, + &gp.axes[ith_axis].div_tick, + &gp.axes[ith_axis].from_tick, + &gp.axes[ith_axis].to_tick); + } + } + } + + if (gp.n_axes == 2) + plotgraph_2d(); + else if (gp.n_axes == 3) + plotgraph_3d(); + else if (gp.n_axes > 3) + plotgraph_nd(); + + reset_plotgraph(); +} diff -ruN ../xbgi-3_02-20000526/graffit/sources/grafplot.c ./graffit/sources/grafplot.c --- ../xbgi-3_02-20000526/graffit/sources/grafplot.c 1999-10-23 16:41:35.000000000 +0900 +++ ./graffit/sources/grafplot.c 2009-03-16 20:51:12.000000000 +0900 @@ -24,8 +24,13 @@ #include #ifndef MAXDOUBLE +#if !defined(__CYGWIN__) && !defined(__DARWIN__) #include #endif +#if !defined(MAXDOUBLE) && defined(MAXFLOAT) +#define MAXDOUBLE MAXFLOAT +#endif +#endif #define DEFAULT_LIMIT_PLOT_NUMBER 500 @@ -45,7 +50,9 @@ #define setplotline(linekind) \ do {if (!gp.color_kind_flag)setlinestyle(linekind,0,0);} while (0) -#define setplotpoint(pointkind,c) setpointstyle(pointkind,c,getbkcolor(),6) +#define setplotpoint(pointkind,c) \ + do { struct pointsettingstype ps; getpointsettings(&ps);\ + setpointstyle(pointkind,c,getbkcolor(),ps.size); } while (0) #define OFFSET_BASE 5 diff -ruN ../xbgi-3_02-20000526/samples/Imakefile ./samples/Imakefile --- ../xbgi-3_02-20000526/samples/Imakefile 1999-10-13 19:05:53.000000000 +0900 +++ ./samples/Imakefile 2009-03-16 21:22:40.000000000 +0900 @@ -15,11 +15,11 @@ #if defined(UseInstalledXBGI) -LOCAL_LIBRARIES = $(XBGILIB) $(XTOOLLIB) $(XPMLIB) $(XLIB) +LOCAL_LIBRARIES = $(GRAFFITLIB) $(XBGILIB) $(XTOOLLIB) $(XPMLIB) $(XLIB) #else /* !defined(UseInstalledXBGI) */ -#if DoSharedLib && !defined(LinuxArchitecture) +#if DoSharedLib && !defined(LinuxArchitecture) && !defined(DarwinArchitecture) all:: libgraffit.so libxbgi.so @@ -37,7 +37,7 @@ $(RM) ./libgraffit.so* ./libxbgi.so* LOCAL_LDFLAGS = -L. -LOCAL_LIBRARIES = -lgraffit -lxbgi $(XTOOLLIB) $(XPMLIB) $(XLIB) +LOCAL_LIBRARIES = $(GRAFFITLIB) $(XBGILIB) $(XTOOLLIB) $(XPMLIB) $(XLIB) #else /* !DoSharedLib */ @@ -49,15 +49,19 @@ #else /* !defined(BuildConcatenatedLib) */ +#ifdef DarwinArchitecture +LOCAL_LDFLAGS = -undefined dynamic_lookup +#endif + #if defined(UseInstalledXBGI) -LOCAL_LIBRARIES = $(XBGILIB) $(XTOOLLIB) $(XPMLIB) $(XLIB) +LOCAL_LIBRARIES = $(GRAFFITLIB) $(XBGILIB) $(XTOOLLIB) $(XPMLIB) $(XLIB) #else /* !defined(UseInstalledXBGI) */ -#if DoSharedLib && !defined(LinuxArchitecture) +#if DoSharedLib && !defined(LinuxArchitecture) && !defined(DarwinArchitecture) -all:: libgraffit.so libxbgi_$(DefaultStandaloneLib).so libxbgi_common.so libxbgi_misc.so +all:: libgraffit.so libxbgi_common.so libxbgi_$(DefaultStandaloneLib).so libxbgi_misc.so libgraffit.so: $(RM) $@* @@ -83,11 +87,11 @@ $(RM) ./libxbgi_common.so* ./libxbgi_misc.so* LOCAL_LDFLAGS = -L. -LOCAL_LIBRARIES = -lgraffit -lxbgi_$(DefaultStandaloneLib) -lxbgi_common -lxbgi_misc $(XTOOLLIB) $(XPMLIB) $(XLIB) +LOCAL_LIBRARIES = $(GRAFFITLIB) $(XBGILIB) $(XTOOLLIB) $(XPMLIB) $(XLIB) #else /* !DoSharedLib */ -LOCAL_LIBRARIES = ../graffit/sources/libgraffit.a ../sources/$(DefaultStandaloneLib)/libxbgi_$(DefaultStandaloneLib).a ../sources/common/libxbgi_common.a ../sources/misc/libxbgi_misc.a $(XTOOLLIB) $(XPMLIB) $(XLIB) +LOCAL_LIBRARIES = ../graffit/sources/libgraffit.a ../sources/common/libxbgi_common.a ../sources/$(DefaultStandaloneLib)/libxbgi_$(DefaultStandaloneLib).a ../sources/misc/libxbgi_misc.a $(XTOOLLIB) $(XPMLIB) $(XLIB) #endif /* DoSharedLib */ diff -ruN ../xbgi-3_02-20000526/samples/Imakefile-19991013 ./samples/Imakefile-19991013 --- ../xbgi-3_02-20000526/samples/Imakefile-19991013 1970-01-01 09:00:00.000000000 +0900 +++ ./samples/Imakefile-19991013 1999-10-13 19:05:54.000000000 +0900 @@ -0,0 +1,158 @@ +/* + * Make makefile for sample programs + * + * Sample programs of xbgi + * + * Copyright (C) 1992-1994,1995 Taiji Yamada, Tokyo Denki University + * Copyright (C) 1995-1999 Taiji Yamada, AIHARA Electrical Engineering Co.,Ltd. + */ +.SUFFIXES: .cxx +#include "../config.h" + +EXTRA_INCLUDES = -I../sources/common -I../sources/x11 -I../sources/ps -I../sources/misc -I../graffit/sources + +#if defined(BuildConcatenatedLib) + +#if defined(UseInstalledXBGI) + +LOCAL_LIBRARIES = $(XBGILIB) $(XTOOLLIB) $(XPMLIB) $(XLIB) + +#else /* !defined(UseInstalledXBGI) */ + +#if DoSharedLib && !defined(LinuxArchitecture) + +all:: libgraffit.so libxbgi.so + +libgraffit.so: + $(RM) $@* + $(LN) ../graffit/sources/libgraffit.so* . + -if [ ! -f $@ ]; then $(LN) $@* $@; fi + +libxbgi.so: + $(RM) $@* + $(LN) ../sources/libxbgi.so* . + -if [ ! -f $@ ]; then $(LN) $@* $@; fi + +clean:: + $(RM) ./libgraffit.so* ./libxbgi.so* + +LOCAL_LDFLAGS = -L. +LOCAL_LIBRARIES = -lgraffit -lxbgi $(XTOOLLIB) $(XPMLIB) $(XLIB) + +#else /* !DoSharedLib */ + +LOCAL_LIBRARIES = ../graffit/sources/libgraffit.a ../sources/libxbgi.a $(XTOOLLIB) $(XPMLIB) $(XLIB) + +#endif /* DoSharedLib */ + +#endif /* defined(UseInstalledXBGI) */ + +#else /* !defined(BuildConcatenatedLib) */ + +#if defined(UseInstalledXBGI) + +LOCAL_LIBRARIES = $(XBGILIB) $(XTOOLLIB) $(XPMLIB) $(XLIB) + +#else /* !defined(UseInstalledXBGI) */ + +#if DoSharedLib && !defined(LinuxArchitecture) + +all:: libgraffit.so libxbgi_$(DefaultStandaloneLib).so libxbgi_common.so libxbgi_misc.so + +libgraffit.so: + $(RM) $@* + $(LN) ../graffit/sources/libgraffit.so* . + -if [ ! -f $@ ]; then $(LN) $@* $@; fi + +libxbgi_$(DefaultStandaloneLib).so: + $(RM) $@* + $(LN) ../sources/$(DefaultStandaloneLib)/libxbgi_$(DefaultStandaloneLib).so* . + -if [ ! -f $@ ]; then $(LN) $@* $@; fi + +libxbgi_common.so: + $(RM) $@* + $(LN) ../sources/common/libxbgi_common.so* . + -if [ ! -f $@ ]; then $(LN) $@* $@; fi + +libxbgi_misc.so: + $(RM) $@* + $(LN) ../sources/misc/libxbgi_misc.so* . + -if [ ! -f $@ ]; then $(LN) $@* $@; fi + +clean:: + $(RM) ./libxbgi_common.so* ./libxbgi_misc.so* + +LOCAL_LDFLAGS = -L. +LOCAL_LIBRARIES = -lgraffit -lxbgi_$(DefaultStandaloneLib) -lxbgi_common -lxbgi_misc $(XTOOLLIB) $(XPMLIB) $(XLIB) + +#else /* !DoSharedLib */ + +LOCAL_LIBRARIES = ../graffit/sources/libgraffit.a ../sources/$(DefaultStandaloneLib)/libxbgi_$(DefaultStandaloneLib).a ../sources/common/libxbgi_common.a ../sources/misc/libxbgi_misc.a $(XTOOLLIB) $(XPMLIB) $(XLIB) + +#endif /* DoSharedLib */ + +#endif /* defined(UseInstalledXBGI) */ + +#endif /* defined(BuildConcatenatedLib) */ + +.c: + $(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRA_INCLUDES) $(LDFLAGS) $(LOCAL_LDFLAGS) $< $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) -o $@ + +.cxx: + $(CXX) $(CFLAGS) $(CPPFLAGS) $(EXTRA_INCLUDES) $(LDFLAGS) $(LOCAL_LDFLAGS) $< $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) -o $@ + +TARGETS =\ + attract\ + attract2\ + axes\ + axes_\ + bgidemo\ + carpet\ + chaos\ + clock\ + colors\ + cubes\ + draw\ + hello\ + hello2\ + hello2-sj\ + hello2-jis\ + mandara\ + mandel\ + message\ + pages\ + pages2\ + pages3\ + pages4\ + penta\ + recurse\ + sponge\ + strange\ + strange2\ + texttest\ + points\ + graph + +TARGETS_CXX =\ + julia + +all:: hello2-sj.c hello2-jis.c $(TARGETS) $(TARGETS_CXX) + +clean:: + -$(RM) $(TARGETS) $(TARGETS_CXX) hello2-sj.c hello2-jis.c + +#if defined(SparcArchitecture) +EUCTOSJ = euctosj +EUCTOJIS = euctojis +#else +EUCTOSJ = nkf -s +EUCTOJIS = nkf -j +#endif + +hello2-sj.c: hello2.c + $(EUCTOSJ) $< > $@ + +hello2-jis.c: hello2.c + $(EUCTOJIS) $< > $@ + +depend:: diff -ruN ../xbgi-3_02-20000526/samples/graph-19991024.c ./samples/graph-19991024.c --- ../xbgi-3_02-20000526/samples/graph-19991024.c 1970-01-01 09:00:00.000000000 +0900 +++ ./samples/graph-19991024.c 1999-10-24 16:13:52.000000000 +0900 @@ -0,0 +1,573 @@ +/* + * Sample program for grafplot in graffit library < graph.c > + * + * XBGI の graffit ライブラリの grafplot.h の サンプル + * + * Copyright (C) 1995-1999 Taiji Yamada, AIHARA Electrical Engineering Co.,Ltd. + */ +#include +#include +#include +#include "mat.h" +#include "rk.h" + +#ifndef _XBGI_ +#define xbgiloop (void)getchar +#endif + +/* + * 0: vector in R^2 + * 1: matrix in R^2 + * 2: matrixT in R^2 + * 3: matrix in R^3 + * 4: matrixT in R^3 + * 5: matrix in R^N + * 6: matrixT in R^N + */ +int test_kind = 3; + +int width = 640, height = 480; +int reverse = 0; +int zero_axis_flag = !0; +unsigned long plotkind = PLOT_LINE; +int figure_dimension = 1; +int r3kind = R3_ROTATION; +double center_x = 0.0, center_y = 0.2; +double magnify = 1.2; +double distance_eyes = 0.1; +double deformation = 10.0; +double rotation_x = -45.0, rotation_y = 25.0, rotation_z = 0.0; +int color_kind_flag = 0; +int color_axis_flag = 0; + +/* + * Lorenz方程式 + */ +#define dxdt dXdt[0] +#define dydt dXdt[1] +#define dzdt dXdt[2] +#define x X[0] +#define y X[1] +#define z X[2] +void Lorenz(double t, double X[], double dXdt[]) +{ + double sigma = 10, b = 8.0/3, r = 28.0; + dxdt = -sigma*x + sigma*y; + dydt = -x*z + r*x - y; + dzdt = x*y - b*z; +} +#undef dxdt +#undef dydt +#undef dzdt +#undef x +#undef y +#undef z + +/* + * HyperRessler方程式 + */ +#define dxdt dXdt[0] +#define dydt dXdt[1] +#define dzdt dXdt[2] +#define dwdt dXdt[3] +#define x X[0] +#define y X[1] +#define z X[2] +#define w X[3] +void HyperRessler(double t, double X[], double dXdt[]) +{ + double a = 0.25, b = 2.2, c = 0.05, d = 0.5; + dxdt = -y - z; + dydt = x + a*y + w; + dzdt = b + x*z; + dwdt = c*w - d*z; +} +#undef dxdt +#undef dydt +#undef dzdt +#undef dwdt +#undef x +#undef y +#undef z +#undef w + +#define N_DATA 10000 +/*#define N_DATA 70000*/ +#define N_KIND 2 + +int expose(void) +{ + if (!reverse) { + setcolor(0); setbkcolor(getmaxcolor()); + } + else { + setcolor(getmaxcolor()); setbkcolor(0); + } + switch (test_kind) { + case 0: default: + { + static int first = !0; + long i; + int k; + static double data[N_KIND][N_DATA+1]; + char title[N_KIND][64]; + + if (first) { + first = 0; + for (k=0; k=0; --i) + for (j=figure_dimension-1; j>=0; --j) /* Thanks! Mr. Jun Takahashi */ if (i != j) hyperrotate_(i, j, RAD(-hd)); break; case '*': @@ -526,6 +530,7 @@ case 'n': test_kind = min(test_kind+1,6); break; } switch (key) { + case 'r': case 'R': case 'Z': case 'x': case 'e': case 's': case 'd': case 'c': diff -ruN ../xbgi-3_02-20000526/samples/julia.cxx ./samples/julia.cxx --- ../xbgi-3_02-20000526/samples/julia.cxx 1999-10-13 19:32:53.000000000 +0900 +++ ./samples/julia.cxx 2009-03-16 21:36:32.000000000 +0900 @@ -9,10 +9,11 @@ #include #include #include -#include -#include +#include +#include #include #include +using std::complex; #ifdef _XBGI_ #define PD "-title JuliaSet -geometry 500x500 -ncolor 100" @@ -43,18 +44,18 @@ */ int ITIME = 50; double CONVERGE = 1.0e-6; -complex A(1.0, 0.0); -complex *C = NULL; +complex A(1.0, 0.0); +complex *C = NULL; int N = 0, INDEX; -int julia(complex z0) +int julia(complex z0) { int i, j; - complex zn1, zn = z0; + complex zn1, zn = z0; if (abs(zn) == 0.0) return ITIME; for (i=0; i(3.0, 0.0) + A/zn/zn/complex(3.0, 0.0); if (abs(zn1-zn) < abs(zn)*CONVERGE) { for (j=0; j *)malloc(N*sizeof(complex)); else - C = (complex*)realloc(C, N*sizeof(complex)); + C = (complex *)realloc(C, N*sizeof(complex)); C[j] = zn1; INDEX = j; } @@ -85,7 +86,7 @@ * 現在塗りつぶしている物理座標を示している. */ int X, Y, SIZE, MAXCOLOR; -complex z1(-1.5, -1.5), z2(1.5, 1.5); +complex z1(-1.5, -1.5), z2(1.5, 1.5); #define VWX(x) ((double)(x)/SIZE*(real(z2)-real(z1))+real(z1)) #define VWY(y) ((double)(y)/SIZE*(imag(z2)-imag(z1))+imag(z1)) int divide, radius, draw_x, draw_y; @@ -95,7 +96,7 @@ if (radius == 0) return; - complex z(VWX(draw_x+radius/2), VWY(draw_y+radius/2)); + complex z(VWX(draw_x+radius/2), VWY(draw_y+radius/2)); int n = julia(z); setfillstyle(SOLID_FILL, (ITIME-n)%(MAXCOLOR-1)+1); bar(draw_x, draw_y, draw_x+radius-1, draw_y+radius-1); @@ -134,8 +135,8 @@ } else if (button == 2) if (prs_flag && rls_flag) { - z1 = complex(VWX(prs_x), VWY(prs_y)); - z2 = complex(VWX(rls_x), VWY(rls_y)); + z1 = complex(VWX(prs_x), VWY(prs_y)); + z2 = complex(VWX(rls_x), VWY(rls_y)); draw_x = 0; draw_y = 0; divide = 2; diff -ruN ../xbgi-3_02-20000526/samples/mandel-19991019.c ./samples/mandel-19991019.c --- ../xbgi-3_02-20000526/samples/mandel-19991019.c 1970-01-01 09:00:00.000000000 +0900 +++ ./samples/mandel-19991019.c 1999-10-19 19:09:58.000000000 +0900 @@ -0,0 +1,239 @@ +/* + * Sample program for event-driven programing < mandel.c > + * + * イベント駆動型プログラミングのためのサンプル + * + * Copyright (C) 1992-1994 Taiji Yamada, Tokyo Denki University + * Copyright (C) 1995-1999 Taiji Yamada, AIHARA Electrical Engineering Co.,Ltd. + */ +#include +#include +#include +#include +#include +#include + +#ifdef _XBGI_ +#define PD "-title MandelSet -geometry 500x500 -ncolor 100" +#else +#include +#define PD "c:/borlandc/bgi" +#endif + +/* + * マンデルブロ集合 + * + * \[f: C\to C\] において,\[f(z) = z^2 + a\] で表される \[a\in C\] について, + * 力学系 \[z_{n+1} = f(z_n) + a\] を考える. + * この力学系は \[z_0\] と \[a\] の値によって,その収束及び発散がきまる. + * ここでは \[z_0\] を原点 \[O\] にとって \[n = \infty\] においても \[z_n\] が + * 発散しない \[a\] の集合をマンデルブロ集合と呼ぶ. + * + * プログラム上では \[\infty\] を ITIME, + * 発散と見なす値を \[|z|=DIVERGE(=10.0)\] とする. + * また,求める \[a\] の定義域は \[Re(a) \in [r1,r2], Im(a) \in [i1,i2]\] + * とする. + */ + +/* + * \[Re(a)=x, Im(a)=y\] として \[z_n\] の力学系が + * 発散に至ったくり返し回数を求める. + * \[\infty\] と見なしている ITIME 以内に発散しなかった場合は,ITIME を返す. + */ +int ITIME = 100; +double DIVERGE = 10.0; +int mandel(double x, double y) +{ + int i; + double xs, ys, zx, zy; + + xs = 0.0; + ys = 0.0; + for (i=0; i DIVERGE) + break; + } + return i; +} + +/* + * SIZExSIZEの範囲の1画素をマンデルブロ集合の発散特性にしたがってペイントする. + * このルーチンは呼ばれるたびに描画密度が高くなっていく. + * X, Y はビューポートの始点.VWX, VWY は物理座標から論理座標へ変換するマクロ. + * divide, radius, draw_x, draw_y は順に領域分割数,分割領域の長さ, + * 現在塗りつぶしている物理座標を示している. + */ +int X, Y, SIZE, MAXCOLOR; +double r1 = -2.5, i1 = -1.5, r2 = 0.5, i2 = 1.5; +#define VWX(x) ((double)(x)/SIZE*(r2-r1)+r1) +#define VWY(y) ((double)(y)/SIZE*(i2-i1)+i1) +int divide, radius, draw_x, draw_y; +void drawing(void) +{ + double z_r, z_i; + int n; + + radius = SIZE/divide; + if (radius == 0) return; + + z_r = VWX(draw_x+radius/2); + z_i = VWY(draw_y+radius/2); + n = mandel(z_r, z_i); + if (MAXCOLOR>1) + setfillstyle(SOLID_FILL, (ITIME-n)%(MAXCOLOR-1)+1); + else + setfillstyle(SOLID_FILL, (ITIME-n)%(MAXCOLOR+1)); + bar(draw_x, draw_y, draw_x+radius-1, draw_y+radius-1); + + draw_x += radius; + if (draw_x > SIZE) { + draw_x = 0; + draw_y += radius; + if (draw_y > SIZE) { + draw_y = 0; + divide *= 2; + } + } +} + +/* + * マウスのボタン1押下で領域の始点を指定,ボタン1解放で領域が定まる. + * そしてマウスのボタン2で指定された領域の拡大を開始する. + * ESCキーで終了.'*'キーでパレットの回転. + * '1','2','3'でカラーの配色を換えることができる. + */ +int prs_x, prs_y, prs_flag = 0; +int rls_x, rls_y, rls_flag = 0; +int mov_x, mov_y, mov_flag = 0; + +int button_press(int button, int x, int y) +{ + if (button == 1) { + if (mov_flag) + rectangle(prs_x, prs_y, mov_x, mov_y); + prs_x = x - X; + prs_y = y - Y; + prs_flag = !0; + rls_flag = 0; + mov_flag = 0; + } + else if (button == 2) + if (prs_flag && rls_flag) { + r1 = VWX(prs_x); + i1 = VWY(prs_y); + r2 = VWX(rls_x); + i2 = VWY(rls_y); + draw_x = 0; + draw_y = 0; + divide = 2; + prs_flag = 0; + rls_flag = 0; + mov_flag = 0; + } + return !0; +} +int button_release(int button, int x, int y) +{ + if (button == 1 && prs_flag) { + if (prs_x != rls_x && prs_y != rls_y) { + rls_x = x - X; + rls_y = y - Y; + rls_flag = !0; + } + else { + prs_flag = 0; + mov_flag = 0; + } + } + else + prs_flag = 0; + return !0; +} +int mouse_motion(int button, int x, int y) +{ + if (button == 1 && prs_flag) { + if (!mov_flag) { + mov_x = prs_x; + mov_y = prs_y; + } + mov_flag = !0; + rectangle(prs_x, prs_y, mov_x, mov_y); + rectangle(prs_x, prs_y, x - X, y - Y); + mov_x = x - X; + mov_y = y - Y; + } + return !0; +} +int key_press(int c) +{ + switch (c) { + case '*': rotate_colors(1, MAXCOLOR-1); break; + case '1': coloring (1, MAXCOLOR-1); break; + case '2': coloring2(1, MAXCOLOR-1, WHITE, BLACK); break; + case '3': coloring3(1, MAXCOLOR-1, RED, GREEN, BLUE); break; + case 0x1b: return 0; + } + return !0; +} +int configure(void) +{ + static int size = 0; + + SIZE = min(getmaxx(),getmaxy()) + 1; + if (SIZE != size) { + setsizexy(getmaxx()+1,getmaxy()+1); + X = (getmaxx()+1)/2 - SIZE/2; + Y = (getmaxy()+1)/2 - SIZE/2; + setviewport(X, Y, X+SIZE-1, Y+SIZE-1, !0); + cleardevice(); + size = SIZE; + divide = 2; + draw_x = 0; + draw_y = 0; + } + MAXCOLOR = getmaxcolor(); + if (MAXCOLOR - 2 > ITIME) + ITIME = MAXCOLOR - 2; + setcolor(MAXCOLOR); + setwritemode(XOR_PUT); + prs_flag = 0; + rls_flag = 0; + mov_flag = 0; + draw_x = 0; + draw_y = 0; + return !0; +} +int noevent(void) +{ + if (!mov_flag) + drawing(); + return !0; +} + +/* + * メインでイベント手続きの設定を行う + */ +int main(void) +{ + int gd = DETECT, gm; + + initgraph(&gd, &gm, PD); + coloring(1, getmaxcolor()-1); + + set_button_press_handler(button_press); + set_button_release_handler(button_release); + set_mouse_motion_handler(mouse_motion); + set_key_press_handler(key_press); + set_configure_handler(configure); + set_noevent_handler(noevent); + + configure(); + xbgiloop(); /* イベントループ */ + + closegraph(); + return 0; +} diff -ruN ../xbgi-3_02-20000526/samples/mandel.c ./samples/mandel.c --- ../xbgi-3_02-20000526/samples/mandel.c 1999-10-19 19:09:58.000000000 +0900 +++ ./samples/mandel.c 2000-12-15 16:03:08.000000000 +0900 @@ -61,39 +61,40 @@ } /* - * SIZExSIZEの範囲の1画素をマンデルブロ集合の発散特性にしたがってペイントする. + * SIZE_XxSIZE_Yの範囲の1画素をマンデルブロ集合の発散特性に従ってペイントする. * このルーチンは呼ばれるたびに描画密度が高くなっていく. * X, Y はビューポートの始点.VWX, VWY は物理座標から論理座標へ変換するマクロ. - * divide, radius, draw_x, draw_y は順に領域分割数,分割領域の長さ, - * 現在塗りつぶしている物理座標を示している. + * divide, (radius_x, radius_y), (draw_x, draw_y) は順に領域分割数, + * 分割領域の長さ,現在塗りつぶしている物理座標を示している. */ -int X, Y, SIZE, MAXCOLOR; +int X, Y, SIZE_X, SIZE_Y, MAXCOLOR; double r1 = -2.5, i1 = -1.5, r2 = 0.5, i2 = 1.5; -#define VWX(x) ((double)(x)/SIZE*(r2-r1)+r1) -#define VWY(y) ((double)(y)/SIZE*(i2-i1)+i1) -int divide, radius, draw_x, draw_y; +#define VWX(x) ((double)(x)/SIZE_X*(r2-r1)+r1) +#define VWY(y) ((double)(y)/SIZE_Y*(i2-i1)+i1) +int divide, radius_x, radius_y, draw_x, draw_y; void drawing(void) { double z_r, z_i; int n; - radius = SIZE/divide; - if (radius == 0) return; + radius_x = SIZE_X/divide; + radius_y = SIZE_Y/divide; + if (radius_x == 0 && radius_y ==0) return; - z_r = VWX(draw_x+radius/2); - z_i = VWY(draw_y+radius/2); + z_r = VWX(draw_x+radius_x/2); + z_i = VWY(draw_y+radius_y/2); n = mandel(z_r, z_i); if (MAXCOLOR>1) setfillstyle(SOLID_FILL, (ITIME-n)%(MAXCOLOR-1)+1); else setfillstyle(SOLID_FILL, (ITIME-n)%(MAXCOLOR+1)); - bar(draw_x, draw_y, draw_x+radius-1, draw_y+radius-1); + bar(draw_x, draw_y, draw_x+radius_x-1, draw_y+radius_y-1); - draw_x += radius; - if (draw_x > SIZE) { + draw_x += radius_x; + if (draw_x > SIZE_X) { draw_x = 0; - draw_y += radius; - if (draw_y > SIZE) { + draw_y += radius_y; + if (draw_y > SIZE_Y) { draw_y = 0; divide *= 2; } @@ -106,65 +107,66 @@ * ESCキーで終了.'*'キーでパレットの回転. * '1','2','3'でカラーの配色を換えることができる. */ -int prs_x, prs_y, prs_flag = 0; -int rls_x, rls_y, rls_flag = 0; -int mov_x, mov_y, mov_flag = 0; +struct squeak { + int x, y; + int flag; +} press = {0,0,0}, release = {0,0,0}, motion = {0,0,0}; int button_press(int button, int x, int y) { if (button == 1) { - if (mov_flag) - rectangle(prs_x, prs_y, mov_x, mov_y); - prs_x = x - X; - prs_y = y - Y; - prs_flag = !0; - rls_flag = 0; - mov_flag = 0; + if (motion.flag) + rectangle(press.x, press.y, motion.x, motion.y); + press.x = x - X; + press.y = y - Y; + press.flag = !0; + release.flag = 0; + motion.flag = 0; } else if (button == 2) - if (prs_flag && rls_flag) { - r1 = VWX(prs_x); - i1 = VWY(prs_y); - r2 = VWX(rls_x); - i2 = VWY(rls_y); + if (press.flag && release.flag) { + r1 = VWX(press.x); + i1 = VWY(press.y); + r2 = VWX(release.x); + i2 = VWY(release.y); draw_x = 0; draw_y = 0; divide = 2; - prs_flag = 0; - rls_flag = 0; - mov_flag = 0; + press.flag = 0; + release.flag = 0; + motion.flag = 0; } return !0; } int button_release(int button, int x, int y) { - if (button == 1 && prs_flag) { - if (prs_x != rls_x && prs_y != rls_y) { - rls_x = x - X; - rls_y = y - Y; - rls_flag = !0; + if (button == 1 && press.flag) { + if (press.x != release.x && press.y != release.y) { + release.x = x - X; + release.y = y - Y; + release.flag = !0; } else { - prs_flag = 0; - mov_flag = 0; + press.flag = 0; + motion.flag = 0; } } else - prs_flag = 0; + press.flag = 0; return !0; } int mouse_motion(int button, int x, int y) { - if (button == 1 && prs_flag) { - if (!mov_flag) { - mov_x = prs_x; - mov_y = prs_y; - } - mov_flag = !0; - rectangle(prs_x, prs_y, mov_x, mov_y); - rectangle(prs_x, prs_y, x - X, y - Y); - mov_x = x - X; - mov_y = y - Y; + if (button == 1 && press.flag) { + if (!motion.flag) { + motion.x = press.x; + motion.y = press.y; + } + motion.flag = !0; + rectangle(press.x, press.y, motion.x, motion.y); + rectangle(press.x, press.y, x - X, y - Y); + motion.x = x - X; + motion.y = y - Y; } return !0; } @@ -172,6 +174,15 @@ { switch (c) { case '*': rotate_colors(1, MAXCOLOR-1); break; + case 'c': + { /* since 20001215 */ + static int coloringkind = COLORING_RGB; + + coloringkind = (coloringkind+1)%N_COLORING; + setcoloringtype(coloringkind); + } + coloring(1, MAXCOLOR-1); + break; case '1': coloring (1, MAXCOLOR-1); break; case '2': coloring2(1, MAXCOLOR-1, WHITE, BLACK); break; case '3': coloring3(1, MAXCOLOR-1, RED, GREEN, BLUE); break; @@ -181,16 +192,18 @@ } int configure(void) { - static int size = 0; + static int size_x = 0, size_y = 0; - SIZE = min(getmaxx(),getmaxy()) + 1; - if (SIZE != size) { + SIZE_X = getmaxx() + 1; + SIZE_Y = getmaxy() + 1; + if (SIZE_X != size_x || SIZE_Y != size_y) { setsizexy(getmaxx()+1,getmaxy()+1); - X = (getmaxx()+1)/2 - SIZE/2; - Y = (getmaxy()+1)/2 - SIZE/2; - setviewport(X, Y, X+SIZE-1, Y+SIZE-1, !0); + X = (getmaxx()+1)/2 - SIZE_X/2; + Y = (getmaxy()+1)/2 - SIZE_Y/2; + setviewport(X, Y, X+SIZE_X-1, Y+SIZE_Y-1, !0); cleardevice(); - size = SIZE; + size_x = SIZE_X; + size_y = SIZE_Y; divide = 2; draw_x = 0; draw_y = 0; @@ -200,16 +213,16 @@ ITIME = MAXCOLOR - 2; setcolor(MAXCOLOR); setwritemode(XOR_PUT); - prs_flag = 0; - rls_flag = 0; - mov_flag = 0; + press.flag = 0; + release.flag = 0; + motion.flag = 0; draw_x = 0; draw_y = 0; return !0; } int noevent(void) { - if (!mov_flag) + if (!motion.flag) drawing(); return !0; } diff -ruN ../xbgi-3_02-20000526/samples/xview/Imakefile ./samples/xview/Imakefile --- ../xbgi-3_02-20000526/samples/xview/Imakefile 1999-10-13 18:40:30.000000000 +0900 +++ ./samples/xview/Imakefile 2009-03-16 20:13:30.000000000 +0900 @@ -15,10 +15,11 @@ #if defined(UseInstalledXBGI) EXTRA_LOAD_FLAGS += -L/usr/openwin/lib -LOCAL_LIBRARIES = $(XBGILIB) $(XTOOLLIB) $(XPMLIB) -lxview -lolgx $(XLIB) +LOCAL_LIBRARIES = $(GRAFFITLIB) $(XBGILIB) $(XTOOLLIB) $(XPMLIB) -lxview -lolgx $(XLIB) #else /* !defined(UseInstalledXBGI) */ -#if DoSharedLib && !defined(LinuxArchitecture) + +#if DoSharedLib && !defined(LinuxArchitecture) && !defined(DarwinArchitecture) all:: libgraffit.so libxbgi.so @@ -37,29 +38,33 @@ LOCAL_LDFLAGS = -L. EXTRA_LOAD_FLAGS += -L/usr/openwin/lib -LOCAL_LIBRARIES = -lgraffit -lxbgi $(XTOOLLIB) $(XPMLIB) -lxview -lolgx $(XLIB) +LOCAL_LIBRARIES = $(GRAFFITLIB) $(XBGILIB) $(XTOOLLIB) $(XPMLIB) -lxview -lolgx $(XLIB) -#else /* !DoShareLib */ +#else /* !DoSharedLib */ EXTRA_LOAD_FLAGS += -L/usr/openwin/lib LOCAL_LIBRARIES = ../../graffit/sources/libgraffit.a ../../sources/libxbgi.a $(XTOOLLIB) $(XPMLIB) -lxview -lolgx $(XLIB) -#endif /* DoShareLib */ +#endif /* DoSharedLib */ #endif /* defined(UseInstalledXBGI) */ #else /* !defined(BuildConcatenatedLib) */ +#ifdef DarwinArchitecture +LOCAL_LDFLAGS = -undefined dynamic_lookup +#endif + #if defined(UseInstalledXBGI) EXTRA_LOAD_FLAGS += -L/usr/openwin/lib -LOCAL_LIBRARIES = $(XBGILIB) $(XTOOLLIB) $(XPMLIB) -lxview -lolgx $(XLIB) +LOCAL_LIBRARIES = $(GRAFFITLIB) $(XBGILIB) $(XTOOLLIB) $(XPMLIB) -lxview -lolgx $(XLIB) #else /* !defined(UseInstalledXBGI) */ -#if DoSharedLib && !defined(LinuxArchitecture) +#if DoSharedLib && !defined(LinuxArchitecture) && !defined(DarwinArchitecture) -all:: libgraffit.so libxbgi_$(DefaultStandaloneLib).so libxbgi_common.so libxbgi_misc.so +all:: libgraffit.so libxbgi_common.so libxbgi_$(DefaultStandaloneLib).so libxbgi_misc.so libgraffit.so: $(RM) $@* @@ -86,14 +91,14 @@ LOCAL_LDFLAGS = -L. EXTRA_LOAD_FLAGS += -L/usr/openwin/lib -LOCAL_LIBRARIES = -lgraffit -lxbgi_$(DefaultStandaloneLib) -lxbgi_common -lxbgi_misc $(XTOOLLIB) $(XPMLIB) -lxview -lolgx $(XLIB) +LOCAL_LIBRARIES = $(GRAFFITLIB) $(XBGILIB) $(XTOOLLIB) $(XPMLIB) -lxview -lolgx $(XLIB) -#else /* !DoShareLib */ +#else /* !DoSharedLib */ EXTRA_LOAD_FLAGS += -L/usr/openwin/lib -LOCAL_LIBRARIES = ../../graffit/sources/libgraffit.a ../../sources/$(DefaultStandaloneLib)/libxbgi_$(DefaultStandaloneLib).a ../../sources/common/libxbgi_common.a ../../sources/misc/libxbgi_misc.a $(XTOOLLIB) $(XPMLIB) -lxview -lolgx $(XLIB) +LOCAL_LIBRARIES = ../../graffit/sources/libgraffit.a ../../sources/common/libxbgi_common.a ../../sources/$(DefaultStandaloneLib)/libxbgi_$(DefaultStandaloneLib).a ../../sources/misc/libxbgi_misc.a $(XTOOLLIB) $(XPMLIB) -lxview -lolgx $(XLIB) -#endif /* DoShareLib */ +#endif /* DoSharedLib */ #endif /* defined(UseInstalledXBGI) */ diff -ruN ../xbgi-3_02-20000526/sources/Imakefile ./sources/Imakefile --- ../xbgi-3_02-20000526/sources/Imakefile 1999-10-22 19:16:18.000000000 +0900 +++ ./sources/Imakefile 2009-03-16 18:58:06.000000000 +0900 @@ -34,6 +34,9 @@ SRCS = $(COMMON_SRCS:%=common/%) $(X11_SRCS:%=x11/%) $(PS_SRCS:%=ps/%) $(MISC_SRCS:%=misc/%) OBJS = $(SRCS:.c=.o) +#ifdef DarwinArchitecture +REQUIREDLIBS = -L$(USRLIBDIR) $(XTOOLLIB) $(XPMLIB) $(XLIB) +#endif #ifdef RsArchitecture REQUIREDLIBS = $(XTOOLLIB) $(XPMLIB) $(XLIB) -lm #endif diff -ruN ../xbgi-3_02-20000526/sources/common/Imakefile ./sources/common/Imakefile --- ../xbgi-3_02-20000526/sources/common/Imakefile 1999-10-22 19:26:49.000000000 +0900 +++ ./sources/common/Imakefile 2009-03-16 19:10:06.000000000 +0900 @@ -19,6 +19,9 @@ SRCS = $(COMMON_SRCS) OBJS = $(COMMON_OBJS) +#ifdef DarwinArchitecture +REQUIREDLIBS = -flat_namespace -undefined suppress +#endif #ifdef RsArchitecture REQUIREDLIBS = $(XTOOLLIB) $(XPMLIB) $(XLIB) -lm #endif diff -ruN ../xbgi-3_02-20000526/sources/common/init.c ./sources/common/init.c --- ../xbgi-3_02-20000526/sources/common/init.c 1997-02-25 08:51:28.000000000 +0900 +++ ./sources/common/init.c 2009-03-16 20:52:13.000000000 +0900 @@ -36,8 +36,7 @@ setbkcolor( XBGI->bkcolor ); cleardevice(); } -#ifdef 0 - /* unknown bugs */ +#if 0 /* unknown bugs */ setvisualpage( XBGI->vpage ); setactivepage( XBGI->apage ); #else diff -ruN ../xbgi-3_02-20000526/sources/misc/Imakefile ./sources/misc/Imakefile --- ../xbgi-3_02-20000526/sources/misc/Imakefile 1999-10-22 19:23:20.000000000 +0900 +++ ./sources/misc/Imakefile 2009-03-16 19:42:57.000000000 +0900 @@ -19,6 +19,9 @@ SRCS = $(MISC_SRCS) OBJS = $(MISC_OBJS) +#ifdef DarwinArchitecture +REQUIREDLIBS = -flat_namespace -undefined suppress +#endif #ifdef RsArchitecture REQUIREDLIBS = $(XTOOLLIB) $(XPMLIB) $(XLIB) -lm #endif diff -ruN ../xbgi-3_02-20000526/sources/ps/Imakefile ./sources/ps/Imakefile --- ../xbgi-3_02-20000526/sources/ps/Imakefile 1999-10-22 19:18:39.000000000 +0900 +++ ./sources/ps/Imakefile 2009-03-16 19:09:51.000000000 +0900 @@ -19,6 +19,9 @@ SRCS = $(PS_SRCS) OBJS = $(PS_OBJS) +#ifdef DarwinArchitecture +REQUIREDLIBS = -flat_namespace -undefined suppress +#endif #ifdef RsArchitecture REQUIREDLIBS = $(XTOOLLIB) $(XPMLIB) $(XLIB) -lm #endif diff -ruN ../xbgi-3_02-20000526/sources/ps/script/prolog.def ./sources/ps/script/prolog.def --- ../xbgi-3_02-20000526/sources/ps/script/prolog.def 1999-04-27 15:04:26.000000000 +0900 +++ ./sources/ps/script/prolog.def 2000-12-15 16:22:46.000000000 +0900 @@ -344,7 +344,8 @@ "pointdict begin\n"\ "/y exch def\n"\ "/x exch def\n"\ -"/size 0.1 def\n"\ +"%%/size 0.1 def %% reported by Mr. Takashi TANAKA, thanks a lot!\n"\ +"/size 0.3 def %% dot size definition\n"\ "newpath\n"\ "x size 2 div sub y size 2 div add moveto\n"\ "x size 2 div add y size 2 div add lineto\n"\ diff -ruN ../xbgi-3_02-20000526/sources/ps/script/prolog.def-19990427 ./sources/ps/script/prolog.def-19990427 --- ../xbgi-3_02-20000526/sources/ps/script/prolog.def-19990427 1970-01-01 09:00:00.000000000 +0900 +++ ./sources/ps/script/prolog.def-19990427 1999-04-27 15:04:26.000000000 +0900 @@ -0,0 +1,359 @@ +/* prolog */ +#define PROLOG \ +"%%%%BeginProlog\n"\ +"/xbgidict 100 dict def\n"\ +"xbgidict begin\n"\ +"%%\n"\ +"%% box\n"\ +"%%\n"\ +"/boxdict 5 dict def\n"\ +"/box {\n"\ +"boxdict begin\n"\ +"/bottom exch def\n"\ +"/right exch def\n"\ +"/top exch def\n"\ +"/left exch def\n"\ +"left top moveto\n"\ +"right top lineto\n"\ +"right bottom lineto\n"\ +"left bottom lineto\n"\ +"left top lineto\n"\ +"closepath\n"\ +"end\n"\ +"} def\n"\ +"%%\n"\ +"%% ellipse\n"\ +"%%\n"\ +"/ellipsedict 8 dict def\n"\ +"ellipsedict /mtrx matrix put\n"\ +"/ellipse {\n"\ +"ellipsedict begin\n"\ +"/yradius exch def\n"\ +"/xradius exch def\n"\ +"/endangle exch def\n"\ +"/stangle exch def\n"\ +"/y exch def\n"\ +"/x exch def\n"\ +"/savematrix mtrx currentmatrix def\n"\ +"x y translate\n"\ +"xradius yradius scale\n"\ +"0 0 1 stangle endangle arc\n"\ +"savematrix setmatrix\n"\ +"end\n"\ +"} def\n"\ +"%%\n"\ +"%% patfill\n"\ +"%%\n"\ +"/patdict 10 dict def\n"\ +"/patbyte {\n"\ +"currentdict /retstr get exch\n"\ +"pat i cellsz mod get put\n"\ +"} def\n"\ +"/patproc {\n"\ +"0 1 widthlim {patbyte} for retstr\n"\ +"/i i 1 add def\n"\ +"} def\n"\ +"/patfill {\n"\ +"patdict begin\n"\ +"/h exch def\n"\ +"/w exch def\n"\ +"/lty exch def\n"\ +"/ltx exch def\n"\ +"/cellsz exch def\n"\ +"/pat exch def\n"\ +"/widthlim w cellsz div cvi 1 sub def\n"\ +"/retstr widthlim 1 add string def\n"\ +"/i 0 def\n"\ +"ltx lty translate\n"\ +"w h true [1 0 0 1 0 0] {patproc} imagemask\n"\ +"ltx neg lty neg translate\n"\ +"end\n"\ +"} def\n"\ +"%%\n"\ +"%% moveto ctext\n"\ +"%%\n"\ +"/ctext { dup stringwidth pop 2 div neg 0 rmoveto } bind def\n"\ +"%%\n"\ +"%% moveto rtext\n"\ +"%%\n"\ +"/rtext { dup stringwidth pop neg 0 rmoveto } bind def\n"\ +"%%\n"\ +"%% copyfont \n"\ +"%%\n"\ +"/copyfont {\n"\ +"dup maxlength 1 add dict begin {\n"\ +"1 index /FID ne 2 index /UniqueID ne and\n"\ +"{def} {pop pop} ifelse\n"\ +"} forall\n"\ +"currentdict\n"\ +"end\n"\ +"} bind def\n"\ +"%%\n"\ +"%% jaeucfont\n"\ +"%%\n"\ +"/jaeucfont {\n"\ +"12 dict begin\n"\ +"dup type /nametype eq { findfont } if\n"\ +"dup /WMode known {\n"\ +"dup /WMode get /WMode exch def\n"\ +"WMode 1 eq {\n"\ +"[0.0 1.0 -1.0 0.0 0.0 0.3] makefont\n"\ +"} if\n"\ +"} if\n"\ +"copyfont dup begin\n"\ +"/Encoding Encoding\n"\ +"FMapType dup 2 eq {\n"\ +"pop 128 128\n"\ +"} { 5 eq {\n"\ +"256 256\n"\ +"} {\n"\ +"/compositefont errordict /invalidfont get exec\n"\ +"} ifelse\n"\ +"} ifelse\n"\ +"getinterval def\n"\ +"end\n"\ +"/kanjifont exch definefont\n"\ +"exch\n"\ +"dup type /nametype eq { findfont } if\n"\ +"exch\n"\ +"/FDepVector [ 4 2 roll ] def\n"\ +"/FontType 0 def\n"\ +"/FMapType 4 def\n"\ +"/FontMatrix matrix def\n"\ +"/Encoding [ 0 1 ] def\n"\ +"/FontBBox {0 0 0 0} def\n"\ +"dup /FontName exch def\n"\ +"currentdict\n"\ +"end\n"\ +"definefont pop\n"\ +"} def\n"\ +"%%\n"\ +"%% special thanks to katayama@rd.nacsis.ac.jp for sh script, fixeucfont\n"\ +"%%\n"\ +"/eucfont {\n"\ +"userdict /fixeucfont_dict known not {\n"\ +"userdict begin\n"\ +"/fixeucfont_dict 2 dict begin\n"\ +"/UpperByteEncoding [\n"\ +"16#00 1 16#20 { pop 0 } for\n"\ +"16#21 1 16#28 { 16#20 sub } for\n"\ +"16#29 1 16#2F { pop 0 } for\n"\ +"16#30 1 16#74 { 16#27 sub } for\n"\ +"16#75 1 16#FF { pop 0 } for\n"\ +"] def\n"\ +"/LowerByteEncoding [\n"\ +"16#00 1 16#A0 { pop /.notdef } for\n"\ +"16#A1 1 16#FE { 16#80 sub 16 2 string cvrs\n"\ +"(cXX) dup 1 4 -1 roll\n"\ +"putinterval cvn } for\n"\ +"/.notdef\n"\ +"] def\n"\ +"currentdict\n"\ +"end def\n"\ +"end\n"\ +"} if\n"\ +"12 dict begin\n"\ +"dup type /nametype eq { findfont } if\n"\ +"dup /WMode known {\n"\ +"dup /WMode get /WMode exch def\n"\ +"WMode 1 eq {\n"\ +"[0.0 1.0 -1.0 0.0 0.0 0.3] makefont\n"\ +"} if\n"\ +"} if\n"\ +"%%\n"\ +"%% 7+8 bit EUC font\n"\ +"%%\n"\ +"12 dict begin\n"\ +"/EUCFont exch def\n"\ +"/FontInfo (7+8 bit EUC font) readonly def\n"\ +"/PaintType 0 def\n"\ +"/FontType 0 def\n"\ +"/FontMatrix matrix def\n"\ +"%% /FontName\n"\ +"/Encoding fixeucfont_dict /UpperByteEncoding get def\n"\ +"/FMapType 2 def\n"\ +"EUCFont /WMode known\n"\ +"{ EUCFont /WMode get /WMode exch def }\n"\ +"{ /WMode 0 def } ifelse\n"\ +"/FDepVector [\n"\ +"EUCFont /FDepVector get 0 get\n"\ +"[ 16#21 1 16#28 {} for 16#30 1 16#74 {} for ]\n"\ +"{\n"\ +"13 dict begin\n"\ +"/EUCFont EUCFont def\n"\ +"/UpperByte exch 16#80 add def\n"\ +"%% /FontName\n"\ +"/FontInfo (EUC lower byte font) readonly def\n"\ +"/PaintType 0 def\n"\ +"/FontType 3 def\n"\ +"/FontMatrix matrix def\n"\ +"/FontBBox {0 0 0 0} def\n"\ +"/Encoding fixeucfont_dict /LowerByteEncoding get def\n"\ +"%% /UniqueID\n"\ +"%% /WMode\n"\ +"/BuildChar {\n"\ +"gsave\n"\ +"exch dup /EUCFont get setfont\n"\ +"/UpperByte get\n"\ +"2 string\n"\ +"dup 0 4 -1 roll put\n"\ +"dup 1 4 -1 roll put\n"\ +"dup stringwidth setcharwidth\n"\ +"0 0 moveto show\n"\ +"grestore\n"\ +"} bind def\n"\ +"currentdict\n"\ +"end\n"\ +"/lowerbytefont exch definefont\n"\ +"} forall\n"\ +"] def\n"\ +"currentdict\n"\ +"end\n"\ +"/kanjifont exch definefont\n"\ +"exch\n"\ +"%%\n"\ +"dup type /nametype eq { findfont } if\n"\ +"exch\n"\ +"%%\n"\ +"/FDepVector [ 4 2 roll ] def\n"\ +"/FontType 0 def\n"\ +"/FMapType 4 def\n"\ +"/FontMatrix matrix def\n"\ +"/Encoding [ 0 1 ] def\n"\ +"/FontBBox {0 0 0 0} def\n"\ +"dup /FontName exch def\n"\ +"currentdict\n"\ +"end\n"\ +"definefont pop\n"\ +"} def\n"\ +"/pointdict 4 dict def\n"\ +"/lozengepoint {\n"\ +"pointdict begin\n"\ +"/size exch def\n"\ +"/y exch def\n"\ +"/x exch def\n"\ +"x y moveto\n"\ +"0 size 2 div rmoveto\n"\ +"size 2 div neg size 2 div neg rlineto\n"\ +"size 2 div size 2 div neg rlineto\n"\ +"size 2 div size 2 div rlineto\n"\ +"size 2 div neg size 2 div rlineto\n"\ +"closepath\n"\ +"end\n"\ +"} def\n"\ +"/crosspoint {\n"\ +"pointdict begin\n"\ +"/size exch def\n"\ +"/y exch def\n"\ +"/x exch def\n"\ +"x y moveto\n"\ +"0 size 2 div rmoveto\n"\ +"0 size neg rlineto\n"\ +"size 2 div neg size 2 div rmoveto\n"\ +"size 0 rlineto\n"\ +"closepath\n"\ +"end\n"\ +"} def\n"\ +"/squarepoint {\n"\ +"pointdict begin\n"\ +"/size exch def\n"\ +"/y exch def\n"\ +"/x exch def\n"\ +"x y moveto\n"\ +"0 size 2 div rmoveto\n"\ +"size 2 div neg 0 rmoveto\n"\ +"0 size neg rlineto\n"\ +"size 0 rlineto\n"\ +"0 size rlineto\n"\ +"size neg 0 rlineto\n"\ +"closepath\n"\ +"end\n"\ +"} def\n"\ +"/xcrosspoint {\n"\ +"pointdict begin\n"\ +"/size exch def\n"\ +"/y exch def\n"\ +"/x exch def\n"\ +"x y moveto\n"\ +"size 2 div neg size 2 div rmoveto\n"\ +"size size neg rlineto\n"\ +"x y moveto\n"\ +"size 2 div size 2 div rmoveto\n"\ +"size neg size neg rlineto\n"\ +"closepath\n"\ +"end\n"\ +"} def\n"\ +"/trianglepoint {\n"\ +"pointdict begin\n"\ +"/size exch def\n"\ +"/y exch def\n"\ +"/x exch def\n"\ +"x y moveto\n"\ +"0 size 3 sqrt 3 div mul rmoveto\n"\ +"size 2 div neg size 3 sqrt 2 div mul neg rlineto\n"\ +"size 0 rlineto\n"\ +"size 2 div neg size 3 sqrt 2 div mul rlineto\n"\ +"closepath\n"\ +"end\n"\ +"} def\n"\ +"/asteriskpoint {\n"\ +"pointdict begin\n"\ +"/size exch def\n"\ +"/y exch def\n"\ +"/x exch def\n"\ +"x y size crosspoint\n"\ +"x y size xcrosspoint\n"\ +"closepath\n"\ +"end\n"\ +"} def\n"\ +"/circlepoint {\n"\ +"pointdict begin\n"\ +"/size exch def\n"\ +"/y exch def\n"\ +"/x exch def\n"\ +"x y size 2 div 0 360 arc\n"\ +"closepath\n"\ +"end\n"\ +"} def\n"\ +"/checkmarkpoint {\n"\ +"pointdict begin\n"\ +"/size exch def\n"\ +"/y exch def\n"\ +"/x exch def\n"\ +"x y moveto\n"\ +"size 2 div neg 0 rmoveto\n"\ +"size 4 div size 2 div neg rlineto\n"\ +"size 4 div 3 mul size rlineto\n"\ +"end\n"\ +"} def\n"\ +"/putpixel {\n"\ +"pointdict begin\n"\ +"/y exch def\n"\ +"/x exch def\n"\ +"/size 1 def\n"\ +"newpath\n"\ +"x y moveto\n"\ +"x size add y lineto\n"\ +"x size add y size sub lineto\n"\ +"x y size sub lineto\n"\ +"x y lineto\n"\ +"closepath fill\n"\ +"end\n"\ +"} def\n"\ +"/putdot {\n"\ +"pointdict begin\n"\ +"/y exch def\n"\ +"/x exch def\n"\ +"/size 0.1 def\n"\ +"newpath\n"\ +"x size 2 div sub y size 2 div add moveto\n"\ +"x size 2 div add y size 2 div add lineto\n"\ +"x size 2 div add y size 2 div sub lineto\n"\ +"x size 2 div sub y size 2 div sub lineto\n"\ +"x size 2 div sub y size 2 div add lineto\n"\ +"closepath fill\n"\ +"end\n"\ +"} def\n"\ +ABBREV\ +"end\n"\ +"%%%%EndProlog\n" diff -ruN ../xbgi-3_02-20000526/sources/x11/Imakefile ./sources/x11/Imakefile --- ../xbgi-3_02-20000526/sources/x11/Imakefile 1999-10-22 19:19:07.000000000 +0900 +++ ./sources/x11/Imakefile 2009-03-16 19:09:38.000000000 +0900 @@ -19,6 +19,9 @@ SRCS = $(X11_SRCS) OBJS = $(X11_OBJS) +#ifdef DarwinArchitecture +REQUIREDLIBS = -flat_namespace -undefined suppress +#endif #ifdef RsArchitecture REQUIREDLIBS = $(XTOOLLIB) $(XPMLIB) $(XLIB) -lm #endif diff -ruN ../xbgi-3_02-20000526/sources/x11/event-19991027.c ./sources/x11/event-19991027.c --- ../xbgi-3_02-20000526/sources/x11/event-19991027.c 1970-01-01 09:00:00.000000000 +0900 +++ ./sources/x11/event-19991027.c 1999-10-27 10:19:46.000000000 +0900 @@ -0,0 +1,463 @@ +/* + * Source File < x11/event.c > + * + * Standard Functions: Borland Graphics Interface for Xlib + * + * Copyright (c) 1992-94,95 Tokyo Denki University, Taiji Yamada + */ +#include +#include +#include "x11_p.h" + +/* + * event loop with tools + */ +/* menu defined */ +enum MENU_ITEM { + NO_SELECT = -1, + SAVE_XBM, +#ifdef ENABLE_XPMLIB + SAVE_XPM, +#endif +#ifndef BUILD_STANDALONE + SAVE_PS, + SET_PS_OPTION, +#endif + QUIT, +}; +static char *MENU_TITLE = "menu"; +static int MENU_ITEMC = QUIT+1; +static int MENU_ITEMI = NO_SELECT; +static char *MENU_ITEMV[] = { + "save bitmap", +#ifdef ENABLE_XPMLIB + "save pixmap", +#endif +#ifndef BUILD_STANDALONE + "save ps", + "set ps option", +#endif + "quit (q)" +}; +/* about, info and help defined */ +#define ABOUT "xbgi\n"\ + "version 3.02\n"\ + "Borland Graphics Interface\n"\ + "for X11, PostScript, (PIX, VIX).\n"\ + "produced by Taiji Yamada, 1992-1999" +#define INFO "id %d\n"\ + "driver %s\n"\ + "mode %s\n"\ + "visual page %d\n"\ + "active page %d\n"\ + "pages %d\n"\ + "color %d\n"\ + "bkcolor %d\n"\ + "ncolor %d\n",\ + XBGI->id,\ + getdriversname(XBGI->gdriver),\ + getmodename(XBGI->gmode),\ + XBGI->apage,\ + XBGI->vpage,\ + XBGI->npage,\ + XBGI->color,\ + XBGI->bkcolor,\ + XBGI->ncolor +#define HELP "-gd driver Driver name X11, PS, (PIX, VIX).\n"\ + "-ncolor number The number of graphics color.\n"\ + "-color number Graphic forground color number.\n"\ + "-bkcolor number Graphic background color number.\n"\ + "-npage number The number of graphics page.\n"\ + "X11:\n"\ + "-gm mode Mode name X11MONO, X11COLOR etc.\n"\ + "-display display X display name.\n"\ + "-geometry geometry Window size and position.\n"\ + "-fn font Font of popup text.\n"\ + "-fg color Foreground color of popup text.\n"\ + "-bg color Background color of popup text.\n"\ + "-title string Title of graphics window.\n"\ + "-name name Resouce name of graphics window.\n"\ + "-icon file Icon bitmap filename.\n"\ + "-backing[-] Backing store on[off].\n"\ + "-colornames colorlist X named color list for graphics.\n"\ + "-l10n[-] Bi-or-Multilingual text off[on].\n"\ + "PS:\n"\ + "-gm mode Mode name PSMONO, PSGRAY, PSCOLOR.\n"\ + "-geometry geometry Graphics geometry size and position.\n"\ + "-interp Pipe open to PostScript interpreter.\n"\ + "-psfile name File to save PostScript code.\n"\ + "-eps Encapsuled PostScript mode.\n"\ + "-paper name Paper names letter, legal, a4 etc.\n"\ + "-portrait Portrait orientation mode.\n"\ + "-landscape Landscape orientation mode.\n"\ + "-title string Title of PostScript document.\n"\ + "-l10n[-] Bilingual text off[on].\n"\ + +/* + * default event procs + */ +int xbgi_button_press( int button, int x, int y ) +{ + static char xbmfilename[80], xbmfilenamebak[80] = "scratch.xbm"; + static char xpmfilename[80], xpmfilenamebak[80] = "scratch.xpm"; + static char epsfilename[80], epsfilenamebak[80] = "scratch.eps"; + static char psoption[64] = "-portrait -paper a4"; + int status; + + switch( button ){ + case 1: + break; + case 2: + bgimenu( MENU_TITLE, MENU_ITEMC, MENU_ITEMV, &MENU_ITEMI ); + switch( MENU_ITEMI ){ + case NO_SELECT: + break; + case SAVE_XBM: + strcpy( xbmfilename, xbmfilenamebak ); + bgigets( "XBM NAME", 80, xbmfilename ); + if ( strcmp(xbmfilename,"") != 0 ){ + status = savemonographtofile( xbmfilename, NULL ); + strcpy( xbmfilenamebak, xbmfilename ); + if ( !status ) + bgiprintf( "Error!", CENTER_TEXT, "saving bitmap is failed" ); + }else{ + strcpy( xbmfilename, xbmfilenamebak ); + } + break; +#ifdef ENABLE_XPMLIB + case SAVE_XPM: + strcpy( xpmfilename, xpmfilenamebak ); + bgigets( "XPM NAME", 80, xpmfilename ); + if ( strcmp(xpmfilename,"") != 0 ){ + status = savegraphtofile( xpmfilename, NULL ); + strcpy( xpmfilenamebak, xpmfilename ); + if ( !status ) + bgiprintf( "Error!", CENTER_TEXT, "saving pixmap is failed" ); + }else{ + strcpy( xpmfilename, xpmfilenamebak ); + } + break; +#endif +#ifndef BUILD_STANDALONE + case SAVE_PS: + if ( XBGI->inherit_procedures->expose_handler ){ + strcpy( epsfilename, epsfilenamebak ); + bgigets( "(E)PS NAME", 80, epsfilename ); + if ( strcmp(epsfilename,"") != 0 ){ + status = saveexposetofile( epsfilename, psoption ); + strcpy( epsfilenamebak, epsfilename ); + if ( !status ) + bgiprintf( "Error!", LEFT_TEXT, "saving ps is failed" ); + }else{ + strcpy( xpmfilename, xpmfilenamebak ); + } + }else{ + bgiprintf( "Error!", LEFT_TEXT, + "No expose procedure!\n" + "Please set expose procedure before xbgiloop,\n" + "if you want to save PostScript as follows: \n" + "--------------------------------------------\n" + " int my_expose( void )\n" + " {\n" + " /* your drawing code */\n" + " return !0;\n" + " }\n" + " int main( void )\n" + " {\n" + " :\n" + " set_expose_handler( my_expose );\n" + " xbgiloop();\n" + " :\n" + " }\n" ); + } + break; + case SET_PS_OPTION: + bgigets( "PS OPTION", 64, psoption ); + break; +#endif /* BUILD_STANDALONE */ + case QUIT: + return 0; + break; + } + break; + case 3: + return 0; + break; + } + return !0; +} +int xbgi_button_release( int button, int x, int y ) +{ + return !0; +} +int xbgi_mouse_motion( int button_state, int x, int y ) +{ + return !0; +} +int xbgi_page_enter( int page ) +{ + return !0; +} +int xbgi_page_leave( int page ) +{ + return !0; +} +int xbgi_key_press( int c ) +{ + int i; + char buf[1024]; + + switch( c ){ + case CTRL('a'): + bgiprintf( "about", CENTER_TEXT, ABOUT ); + break; + case CTRL('i'): + bgiprintf( "info.", LEFT_TEXT, INFO ); + break; + case CTRL('o'): + strcpy( buf, "" ); + for ( i=0; iargc; i++ ){ + if ( XBGI->argv[i][0] == '-' ) + strcat( buf, "\n" ); + strcat( buf, XBGI->argv[i] ); + if ( XBGI->argv[i][0] == '-' ) + strcat( buf, " " ); + } + bgiprintf( "options", LEFT_TEXT, "%s", buf ); + break; + case CTRL('h'): + bgiprintf( "help", LEFT_TEXT, HELP ); + break; + case 'n': case 'N': + setvisualpage( min( XBGI->vpage+1, XBGI->npage-1 ) ); + break; + case 'b': case 'B': + setvisualpage( XBGI->vpage-1 ); + break; + case CTRL('f'): + if ( XBGI->vpage != XBGI->npage ) + setvisualpage( XBGI->npage ); + else + setvisualpage( 0 ); + break; + case CTRL('c'): + exit( 0 ); + break; + case 'q': case 'Q': case 0x1b: + return 0; + break; + } + return !0; +} +int xbgi_configure( void ) +{ + return !0; +} +int xbgi_expose( void ) +{ + return !0; +} +int xbgi_noevent( void ) +{ + return !0; +} + +/* + * event looper for simple event programing + */ +#define SWITCH_EV(ev) do {\ +switch ( ev.type ){\ +case ButtonPress: /*fprintf(stderr, "ev: ButtonPress\n");*/\ + XBGIEvent = ev;\ + if ( XBGI->inherit_procedures->button_press_handler != NULL ){\ + switch( ev.xbutton.button ){\ + case Button1: b = 1; break;\ + case Button2: b = 2; break;\ + case Button3: b = 3; break;\ + }\ + ret = XBGI->inherit_procedures\ + ->button_press_handler( b, ev.xbutton.x, ev.xbutton.y );\ + }\ + break;\ +case ButtonRelease: /*fprintf(stderr, "ev: ButtonRelease\n");*/\ + XBGIEvent = ev;\ + if ( XBGI->inherit_procedures->button_release_handler != NULL ){\ + switch( ev.xbutton.button ){\ + case Button1: b = 1; break;\ + case Button2: b = 2; break;\ + case Button3: b = 3; break;\ + }\ + ret = XBGI->inherit_procedures\ + ->button_release_handler( b, ev.xbutton.x, ev.xbutton.y );\ + }\ + break;\ +case MotionNotify: /*fprintf(stderr, "ev: MotionNotify\n");*/\ + XBGIEvent = ev;\ + if ( XBGI->inherit_procedures->mouse_motion_handler != NULL ){\ + bs = 0;\ + if ( ev.xmotion.state & Button1Mask ) bs |= 1;\ + if ( ev.xmotion.state & Button2Mask ) bs |= 2;\ + if ( ev.xmotion.state & Button3Mask ) bs |= 4;\ + ret = XBGI->inherit_procedures\ + ->mouse_motion_handler( bs, ev.xbutton.x, ev.xbutton.y );\ + }\ + break;\ +case EnterNotify: /*fprintf(stderr, "ev: EnterNotify\n");*/\ + XBGIEvent = ev;\ + if ( XBGI->inherit_procedures->page_enter_handler != NULL ){\ + for ( p=0; pnpage; p++ )\ + if ( XBGIWins[p] == ev.xcrossing.window )\ + ret = XBGI->inherit_procedures->page_enter_handler( p );\ + }\ + break;\ +case LeaveNotify: /*fprintf(stderr, "ev: LeaveNotify\n");*/\ + XBGIEvent = ev;\ + if ( XBGI->inherit_procedures->page_leave_handler != NULL ){\ + for ( p=0; pnpage; p++ )\ + if ( XBGIWins[p] == ev.xcrossing.window )\ + ret = XBGI->inherit_procedures->page_leave_handler( p );\ + }\ + break;\ +case KeyPress: /*fprintf(stderr, "ev: KeyPress\n");*/\ + if ( XLookupString( (XKeyEvent*)&ev, &c, 1, NULL, NULL ) == 1 ){\ + XBGIEvent = ev;\ + if ( XBGI->inherit_procedures->key_press_handler != NULL )\ + ret = XBGI->inherit_procedures->key_press_handler( c );\ + }\ + break;\ +case ConfigureNotify: /*fprintf(stderr, "ev: ConfigureNotify\n");*/\ + XBGIEvent = ev;\ + if ( XBGI->inherit_procedures->configure_handler != NULL )\ + ret = XBGI->inherit_procedures->configure_handler();\ + break;\ +case Expose: /*fprintf(stderr, "ev: Expose\n");*/\ + XBGIEvent = ev;\ + if ( ev.xexpose.window == XBGIRoot ) /* since 3.02 generic 19991024 */\ + break;\ + while ( XEventsQueued(ev.xexpose.display,QueuedAfterReading) > 0 ){\ + XPeekEvent( ev.xexpose.display, &ahead );\ + if ( ahead.type != Expose )\ + break;\ + if ( ahead.xexpose.window != ev.xexpose.window )\ + break;\ + XNextEvent( ev.xexpose.display, &ev );\ + }\ + if ( XBGI->inherit_procedures->expose_handler != NULL )\ + ret = XBGI->inherit_procedures->expose_handler();\ + break;\ +}\ +} while (0); +void xbgiloop( void ) +{ + xbgi *ptr; + XEvent ev, ahead; + int b = 0, bs, p; + char c; + int ret; + /* + [References] + R. Kinoshita, H. Hideyuki, + ``X-Window Ver.11 Programing,'' + \S 119, + Nikkan Kougyou Shinbunsha, 1989. + + Oliver Jones, + ``Introduction to the X Window System,'' + \S 11.3, + M.I.T. Press., 1989. + + W. Richard Stevens, + ``Advanced Programming in the UNIX Environment,'' + \S 12.5.1, + Addison-Wesley Publishing Company, Inc. 1992. + */ + int nfds = 0; + fd_set fds, readfds, writefds, exceptfds; + struct timeval timeout; + + FD_ZERO(&fds); + /* + * flush all xbgi + */ + ptr = XBGIS; + while ( ptr != NULL ){ + if (ptr->gdriver == X11) { + int cn; + + XFlush( XBGIsDisplay(ptr) ); + cn = ConnectionNumber(XBGIsDisplay(ptr)); + FD_SET(cn, &fds); + nfds = max(nfds,cn+1); + } + ptr = ptr->next; + } + ptr = XBGI; + XBGI = XBGIS; + /* + * finite event roop + */ + ret = !0; +#if 1 /* event-wait loop, since version 3.02 generic 19991019 */ + timeout.tv_sec = 0; + timeout.tv_usec = 0; + while (ret) { + int has_bg_proc = 0, no_event = !0; + + while (XBGI != NULL) { + if (XBGI->gdriver == X11) { + if (XEventsQueued(XBGIDisplay, QueuedAfterReading) > 0) { + XNextEvent(XBGIDisplay, &ev); + SWITCH_EV(ev); + no_event = 0; + break; + } + else { + XFlush(XBGIDisplay); + if (XBGI->inherit_procedures->noevent_handler != NULL) { + has_bg_proc = !0; + ret = XBGI->inherit_procedures->noevent_handler(); + } + } + } + XBGI = XBGI->next; + } + if (no_event) { + FD_ZERO(&writefds), FD_ZERO(&exceptfds); + readfds = fds; + select(nfds, &readfds, &writefds, &exceptfds, has_bg_proc?&timeout:NULL); + } + if (XBGI == NULL) + XBGI = XBGIS; + } +#else /* event loop without select before 3.02, event-delay loop with select */ + timeout.tv_sec = 0; + timeout.tv_usec = 1000; + while (ret) { + if (XBGI == NULL) + XBGI = XBGIS; + if (XBGI->gdriver == X11) { + if (XEventsQueued(XBGIDisplay, QueuedAfterFlush) > 0) { + XNextEvent(XBGIDisplay, &ev); + SWITCH_EV(ev); + } + else { + if (XBGI->inherit_procedures->noevent_handler != NULL) + ret = XBGI->inherit_procedures->noevent_handler(); + select(0, NULL, NULL, NULL, &timeout); + } + } + XBGI = XBGI->next; + } +#endif + XBGI = ptr; +} +/* + * is event + */ +int isevent(void) +{ + if ( XEventsQueued( XBGIDisplay, QueuedAfterFlush ) > 0 ) + return !0; + else + return 0; +}