//=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // "flib.h" // Xfig 3.2 互換データ生成システム // Copyright(C) by Naoki Watanabe. // All rights reserved. // Last revised on Sep 7th, 1998. //=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* #ifndef __FLIB_H_INCLUDE #define __FLIB_H_INCLUDE #include #include #ifndef _XLIB_H_ #define CoordModeOrigin 0 #define CoordModePrevious 1 typedef struct _XDisplay{} Display; typedef struct { short x, y; } XPoint; #endif // _XLIB_H_ // font_noのシンボル #ifndef EFLIB_FONT_SYMBOLS #define EFLIB_FONT_SYMBOLS #define TIMES_ROMAN 0 #define TIMES_ITALIC 1 #define TIMES_BOLD 2 #define TIMES_BOLDITALIC 3 #define SYMBOL 4 #endif //EFLIB_FONT_SYMBOLS //=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // FIG用GCの制御機構の定義 //=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //---- Graphic Context 管理構造体 FIGGCValues struct FIGGCValues { int foreground; // foreground pixel [0--255] default 0 black int background; // background pixel [0--255] default 7 white int font_no; // font No default 0 "Times-Roman" int font_size; // font size default 12 }; //---- Graphic Context 管理構造体へのポインタ FIGGC typedef FIGGCValues *FIGGC; //---- FIG 管理構造体 FIGIDValues struct FIGIDValues { FILE* fptr; FIGGC cugc; double DOT2FU; inline int Fu( int dot ){ return( int(dot*DOT2FU) ); } }; //---- FIG 管理構造体へのポインタ FIGID typedef FIGIDValues *FIGID; FIGGC FCreateFIGGC( Display*, FIGID, u_long, FIGGCValues* ); //---- FIGGCを生成して初期化する関数 ------------- // Display* には NULLを与えてください。何も意味はありません。 // この関数は FIGGCValues構造体をmallocして初期値に // 設定して、そのアドレスを FIGGC型として返します。 //------------------------------------------------ void FFreeFIGGC( Display*, FIGGC fgc ); //---- FIGGCを解放する関数 ----------------------- // fgcの指すFIGGCValues構造体のメモリ領域を解放します。 //------------------------------------------------ void FSetForeground( Display*, FIGGC fgc, u_long _fg ); //---- FIGGCにForeground色を設定する関数 -------- // Xlibと同じようにpixel値を指定してください。 // 先にFDefineColor()でそのpixel値のRGB輝度を登録しておいてください。 //------------------------------------------------ void FSetFont( Display*, FIGGC fgc, int _font_no, int _font_size ); //---- FIGGCに fontを設定する関数 ---------------- // _font_noには先に定義したfont_noのシンボルのdefine定数を指定。 // _font_sizeはwindow dot単位で指定。 //------------------------------------------------ //=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // FIG描画関数の定義 //=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //***** [注意] ここの関数群の長さの変数の単位は window dot です。***** FIGID FCreateFile( Display*, const char* fname, u_int win_width, u_int win_height, u_int fig_width, u_int fig_height ); //---- FIGを開けて初期化する関数 ----------------- // win_* にはXlibの窓を想定してのその大きさをdot単位で指定。 // fig_* にはFIGの大きさを mm単位で指定。 // 2者が相似でない場合には fig_widthが優先される。 //------------------------------------------------ void FCloseFile( Display*, FIGID fig ); //---- FIGを閉じる関数 --------------------------- void FDrawFIGGC( FIGID fig, FIGGC fgc ); //---- FIGGCを出力する関数 ----------------------- void FDefineColor( FIGID fig, FIGGC fgc, u_long pixel, u_short red, u_short green, u_short blue ); //---- 色を登録する関数 void FDrawPoint( Display*, FIGID fig, FIGGC fgc, int _x, int _y ); //---- 点を描く関数 ------------------------------ void FDrawLine( Display*, FIGID fig, FIGGC fgc, int _x1, int _y1, int _x2, int _y2 ); //---- 線分を描く関数 ---------------------------- void FDrawRectangle( Display*, FIGID fig, FIGGC fgc, int _xo, int _yo, u_int _w, u_int _h ); void FFillRectangle( Display*, FIGID fig, FIGGC fgc, int _xo, int _yo, u_int _w, u_int _h ); //---- 長方形を描く/塗る関数 --------------------- // 長方形の左上の座標と縦横の長さを指定します。 //------------------------------------------------ void FDrawLines( Display*, FIGID fig, FIGGC fgc, XPoint _p[], int _np, int _mode ); void FDrawPolygon( Display*, FIGID fig, FIGGC fgc, XPoint p[], int np, int mode ); void FFillPolygon( Display*, FIGID fig, FIGGC fgc, XPoint _p[], int _np, int _shape, int _mode ); //---- 多角形を描く/塗る関数 --------------------- // XPoint型はXlibで定めるもの。_npは点の総数。 // 終点と始点が結ばれます。 // _shape は PolyConvexのみ。 // _modeは CoordModeOrigin, CoordModePrevious //------------------------------------------------ void FDrawArc( Display*, FIGID fig, FIGGC fgc, int _xo, int _yo, u_int _width, u_int _height, int _ang1, int _ang2 ); void FFillArc( Display*, FIGID fig, FIGGC fgc, int _xo, int _yo, u_int _width, u_int _height, int _ang1, int _ang2 ); //---- 円/楕円弧を描く/塗る関数 ------------------ // 楕円を納める長方形の左上の座標と縦横の長さを指定します。 // ang1, ang2は意味を持たず、真円、真楕円のみを描く //------------------------------------------------ void FDrawString( Display*, FIGID fig, FIGGC fgc, int _x, int _y, const char* _str, int _len ); //---- 文字を描く関数(英数字のみ) ---------------- // この関数を呼ぶ前には一度 FSetFont 関数で // fontを指定しておかなければなりません。 //------------------------------------------------ #endif // __FLIB_H_INCLUDE