UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Zgraph.h
1 #if !defined(ZGRAPH_H_)
2 #define ZGRAPH_H_
3 
4 #include <stdlib.h>
5 #include <math.h>
6 #include <string.h>
7 #include <malloc.h>
8 #include <X11/Xlib.h>
9 #include <X11/Xutil.h>
10 #include <X11/Intrinsic.h>
11 
12 typedef unsigned int Zuint;
13 typedef unsigned char Zind;
14 typedef unsigned char Uchar;
15 /*
16 typedef unsigned short Zdepth;
17 typedef unsigned short ZRdepth;
18 */
19 typedef float Zdepth;
20 typedef float ZRdepth;
21 
22 #ifndef MIN_MAX_
23 #define MIN_MAX_
24 #define MIN_(x,a) if(x > (a)) x = a
25 #define MAX_(x,a) if(x < (a)) x = a
26 #define Swap(x,y) (x ^= (y ^= (x ^= y)))
27 #define FtoI(a) ((a < 0) ? a-0.5 : a+0.5)
28 #define Zabs(a) ((a < 0) ? -a : a)
29 #define Sign(a) ((a < 0) ? -1 : 1)
30 #define max(a,b) (((a) > (b)) ? (a) : (b))
31 #define min(a,b) (((a) < (b)) ? (a) : (b))
32 #endif
33 
34 #ifndef YTimeOut
35 #define YTimeOut 0x4014
36 #endif
37 
38 #ifndef MEMCPDEF
39 #define MEMCPDEF
40 #define memcpy_(a,b,c) memcpy((char *)(a),(char *)(b),c)
41 #define memcmp_(a,b,c) memcmp((char *)(a),(char *)(b),c)
42 #define memset_(a,b,c) memset((char *)(a),b,c)
43 #endif
44 typedef int (*DrawFunction4D)();
45 typedef int (*SelectFunction)();
46 typedef int (*PutUserPixmap)();
47 typedef int (*SetUserData)();
48 typedef int (*ZDrawS4DLine)();
49 typedef float (*SelectObjF)(double x,double y);
50 typedef struct {
51  float x,y,z,f;
52  } Vector4D;
53 typedef struct {
54  float m[4];
55  } Vector4Dm;
56 
57 typedef struct {
58  float x,y,z;
59  } Vector3D;
60 typedef struct {
61  float m[3];
62  } Vector3Dm;
63 
64 typedef struct {
65  Vector3D v;
66  Vector3D n;
67  } Vector4DN;
68 typedef struct {
69  int i;
70  Vector4DN* v1;
71  Vector4DN* v2;
72  Vector4DN* v3;
73  } Triangle4DN;
74 
75 typedef struct {
76  Vector4D v1;
77  Vector4D v2;
78  Vector4D v3;
79  } Triangle4D;
80 
81 typedef struct {
82  Vector4D s1;
83  Vector4D s2;
84  Vector4D s3;
85  Vector4D s4;
86  } Rectangle4D;
87 
88 typedef struct {
89  Zind* ind;
90  int mind;
91  float* alt;
92  float minalt,maxalt;
93  int* colors;
94  int nc;
95  } ColorInd;
96 #define DRAW_FLAG 1
97 #define DRAW_NO_DEPTH 2
98 #define DRAW_ONLY_PIXMAP 4
99 #define DRAW_ONLY_WINDOW 8
100 typedef struct ORool_
101  {
102  char* name;
103  struct ORool_* prev;
104  struct ORool_* next;
105  void* usr;
106  DrawFunction4D DrawF;
107  SelectFunction DrawS;
108  ColorInd* ci;
109  int fg,bg;
110  char AllocMem,FlDraw,Draw1,Draw2;
111  void* d;
112  } ORool;
113 typedef struct {
114  float m[9],m_[9],d[3],d_[3],scale[3],scale_[3],
115  center[3],center_[3],shadow[3],ray[3];
116  } Place3D;
117 typedef struct {
118  Display* dpy;
119  Window win;
120  Pixmap pix;
121  GC gc;
122  Colormap cmp;
123  XImage* imag;
124  Uchar* MImagData;
125  Uchar** dataPtr;
126  Zdepth* depth;
127  Zdepth** depthPtr;
128  ColorInd* ci;
129  int fg,bg,noc;
130  int (*ZSet4DVector)();
131  int (*ZSet4DVector_)();
132  int (*ZSet3DVector)();
133  int (*ZSet3DVector_)();
134  int (*ZSet2DVector)();
135  int (*ZSet2DVector_)();
136  int x1,y1,x2,y2;
137  int z1,z2;
138  int height,width,Lwidth,CgmW,CgmH;
139  float selZ1,selZ2;
140  float m[9],m_[9],d[3],d_[3],scale[3],scale_[3],
141  center[3],center_[3],shadow[3],ray[3];
142  float rx1,rx2,ry1,ry2,rz1,rz2;
143  float SpeedRotor;
144  float selX,selY,selZ;
145  Font fnt;
146  XImage* Fimag;
147  XFontStruct* font_struct;
148  char fontwidth[256];
149  short ch_h,ch_w,a1,a2;
150  PutUserPixmap ucb;
151  void* usrd;
152  char OnlyShadow,OnlyRay,FLine,FTriangle,HCopy,cpl[3];
153  } WIN3D;
154 /*#define Z_DEPTH*/
155 #define Zframe 1
156 #define ZboxFrame 2
157 #define ZcolorFrame 4
158 /* --------------------------------------------------------- */
159 typedef struct {
160  int nn;
161  Triangle4DN* t;
162  void* adr;
163  char Fill,Frame,CFrame;
164  } TriangleCData; /* ----------------- */
165 typedef struct {
166  int nn;
167  Triangle4D* t;
168  char Fill,Frame,CFrame;
169  } TriangleData; /* ----------------- */
170 typedef struct {
171  int nn;
172  int width;
173  int fg,afg;
174  void* usr;
175  Vector3D* v;
176  } Line3Data; /* ----------------- */
177 typedef struct {
178  int nn;
179  int width;
180  int fg,afg;
181  void* usr;
182  Vector4D* v;
183  } Line4Data; /* ----------------- */
184 extern char CubePlanes[]; /* ----------------- */
185 typedef struct {
186  float lx,ly,lz;
187  Vector3D v0,v[8];
188  char plane[8],Calculate;
189  int pl;
190  Vector3D ca,cv;
191  int fg[3],fg_[3];
192  } BrickData; /* ----------------- */
193 typedef struct {
194  BrickData* brick;
195  int x1,x2,y1,y2,z1,z2;
196  int nx,ny,nz;
197  int idx,idy,idz;
198  float ldx,ldy,ldz;
199  float surfx,surfy,surfz;
200  Uchar* c;
201  float* buf;
202  } DVData; /* ----------------- */
203 
204 typedef struct {
205  Vector3D v; /* need to set */
206  float ind1,ind2; /* need to set */
207  int idn,n; /* need to set */
208  } SliceVector;
209 typedef struct {
210  Vector3D vz;
211  Vector3D v1,v2;
212  double XX,YY,ZZ,Rz,dxR,dyR,dzR,n0z,dxz,dyz;
213  } InitGridS;
214 typedef struct { /* ----------------- */
215  DVData* DV; /* need to set */
216  Vector3D v0;
217  SliceVector sv[2];
218  Vector4D* buf;
219  float* f;
220  int x1,y1,x2,y2;
221  float zmin,zcoef,raycoef;
222  float CoordC;
223  int CoordN;
224  SetUserData uset;
225  Vector4D* fv;
226  char* DrawVertex;
227  char NoDepth,Fill,Frame,Ray,DataType,FastGrid,Surf;
228  } GridData; /* ----------------- */
229 
230 typedef struct {
231  float kx,ky,kz;
232  int mi,ni,XorY,n;
233  } SVector;
234 typedef struct {
235  double kx,ky,kz1,kz2,fx,fy,fz,dxy;
236  double ind1,ind2,id1,id2;
237  int idn1,idn2;
238  int n1,n2;
239  int mi,ni;
240  int dlx,dly;
241  int fast;
242  } InitSVector; /* ----------------- */
243 typedef struct {
244  DVData* DV; /* need to set */
245  Vector3D v0;
246  SliceVector sv[2];
247  float* buf;
248  float* f;
249  int x1,y1,x2,y2;
250  float zmin,zcoef,raycoef;
251  float CoordC;
252  int CoordN;
253  SetUserData uset;
254  float* fbuf;
255  char* DrawVertex;
256  char NoDepth,Fill,Frame,Ray,DataType,FastGrid,Surf;
257  } SliceData; /* ----------------- */
258 
259 typedef struct {
260  DVData* DV;
261  int idx,idy;
262  int i1,i2;
263  Vector3D v0,v1,p1,p2;
264  float ind11,ind21;
265  float id1,id2;
266  float* f,cf;
267  float x1,y1,x2,y2,x3,y3,x4,y4;
268  float z1;
269  int dlx,dly;
270  float dxy,lx0,ly0;
271  int mx1,ni1;
272  float kx1,ky1,kz1,kz2;
273  char NoDepth,Film,Frame,Ray;
274  } StickData; /* ----------------- */
275 /*typedef struct {
276  Vector3D* v;
277  float l,rl; /* l length,ls real length
278  } StickVector;*/
279 typedef struct {
280  int i,nn,plane;
281  Vector4D* v; /* v.f is real length */
282  } DVSticksData;
283 
284 
285 /* ---------------------------------------------------------------------- */
286 int ZDraw2DLine(WIN3D* w,Vector3D* v1,Vector3D* v2);
287 int ZDraw3DLine(WIN3D* w,Vector4D* v1,Vector4D* v2);
288 int ZDraw3DLineD(WIN3D* w,Vector4D* v1,Vector4D* v2);
289 int ZDraw4DLine(WIN3D* w,Vector4D* v1,Vector4D* v2);
290 int ZDrawSLine(WIN3D* w,Vector4D* v1,Vector4D* v2,ZDrawS4DLine D);
291 int ZDrawLineSelect(WIN3D* w,Vector4D* v1,Vector4D* v2);
292 int ZDraw4DTriangle(WIN3D* w,Vector4D* v1,Vector4D* v2,Vector4D* v3);
293 int ZDraw3DTriangle(WIN3D* w,Vector4D* v1,Vector4D* v2,Vector4D* v3);
294 int ZDrawTriangleSelect(WIN3D* w,Vector4D* v1,Vector4D* v2,Vector4D* v3);
295 int ZDrawRDTriangle(WIN3D* w,Vector4D* v1,Vector4D* v2,Vector4D* v3);
296 
297 int ZPutImage3D(WIN3D* w);
298 int ZSet4DVector(WIN3D* w,Vector4D* s,Vector4D* v_);
299 int ZSet4DVector_(WIN3D* w,Vector4D* s,Vector4D* v_);
300 int ZSet3DVector(WIN3D* w,Vector3D* v,Vector3D* v_);
301 int ZSet3DVector_(WIN3D* w,Vector3D* v,Vector3D* v_);
302 int ZSet4DTriangle(WIN3D* w,Triangle4D *t,Triangle4D *t_);
303 int ZSet3DVectorP(Place3D* w,double x, double y,double z,Vector3D* v_);
304 int ZInv3DVectorP(Place3D* w,double *x, double *y,double *z,Vector3D* v_);
305 int ZSet3DVectorXYZ(WIN3D* w,double x, double y,double z,Vector3D* v_);
306 int ZInv3DVectorXYZ(WIN3D* w,double *x, double *y,double *z,Vector3D* v_);
307 Vector3D* ZSum3DVector(Vector3D* v1,Vector3D* v2,Vector3D* v);
308 Vector3D* ZSub3DVector(Vector3D* v1,Vector3D* v2,Vector3D* v);
309 Vector3D* ZSign3DVector(Vector3D* v);
310 Vector3D* ZMlt3DVector(Vector3D* v1,Vector3D* v2,double coef);
311 Vector3D* ZRot3DVectors(Vector3D* v1,Vector3D* v2,Vector3D* v);
312 double ZScl3DVectors(Vector3D* v1,Vector3D* v2);
313 double ZGet3DVectorLenth(Vector3D* v);
314 int ZInitMxyz(WIN3D* w);
315 int ZRotMxyz(WIN3D* w,int a,double fi);
316 int ZRotMxyzI(WIN3D* w,int a,double fi);
317 int ZRotMShadow(WIN3D* w,double f0,double f1);
318 int ZSetCenter3D(WIN3D* w,double fx,double fy,double fz);
319 int ZInitShift3D(WIN3D* w,double x,double y,double z);
320 int ZShift3D(WIN3D* w,double fx,double fy,double fz);
321 int ZInitScale3D(WIN3D* w,double fx,double fy,double fz);
322 int ZScale3D(WIN3D* w,double fx,double fy,double fz);
323 int ZRoom3D(WIN3D* w,double rx1,double ry1,double rz1,
324  double rx2,double ry2,double rz2);
325 int ZSet4DColor(ColorInd* ci,int* clr,int nc);
326 int ZClear3Depth(WIN3D* w);
327 int ZSet3DWindowClip(WIN3D* w);
328 int ZInitColorInd(ColorInd* ci,int nind,int* colors,int nc);
329 int ZInitColorAlt(ColorInd* ci);
330 ORool* ZGetFirstObject(ORool* o);
331 int ZGetNObject(ORool* o);
332 ORool* ZAlloc4DObject(WIN3D* w,ORool* o0,void* o,char* name);
333 ORool* ZAdd4DObject(WIN3D* w,ORool* o0,ORool* o,void* d,char* name);
334 ORool* ZInsert4DObject(WIN3D* w,ORool* o0,void* o,char* name);
335 ORool* ZoDraw4DObject(WIN3D* w,ORool* o,int q,int cl,int pt);
336 ORool* ZDeleteObject(ORool* o);
337 ORool* ZGetLastObject(ORool* o);
338 int ZSetMaxImage(WIN3D* w);
339 int ZSetImageSize(WIN3D* w,int x1,int y1,int x2,int y2);
340 int ZDeleteObjectsByName(ORool* o,char* name);
341 int ZoDraw4DObjects(WIN3D* w,ORool* o,int q,int cl,int pt);
342 int ZoDraw4DTriangles(WIN3D* w,TriangleData* d,int q);
343 int ZoDraw3DLine(WIN3D* w,Line3Data* d,int q);
344 int ZoDraw4DLine(WIN3D* w,Line4Data* d,int q);
345 int ZoDrawGrid(WIN3D* w,GridData* d,int q);
346 int ZoDrawBrick(WIN3D* w,BrickData* d,int q);
347 int ZSetSlice(WIN3D* w,SliceData* s,InitSVector* isv);
348 int ZoDraw3DSlice(WIN3D* w,SliceData* o,int q);
349 int ZoDraw3DSliceU(WIN3D* w,SliceData* o,int q);
350 int ZDraw2DSlice(WIN3D* w,SliceData* s,InitSVector* sv);
351 int ZDraw3DSlice(WIN3D* w,SliceData* s,InitSVector* sv);
352 int ZDraw3DSliceU(WIN3D* w,SliceData* s,InitSVector* sv);
353 int ZDraw3DSliceD(WIN3D* w,SliceData* s,InitSVector* sv);
354 int ZDraw3DSliceDU(WIN3D* w,SliceData* s,InitSVector* sv);
355 int ZDraw3DSliceB(WIN3D* w,SliceData* s,InitSVector* sv);
356 int ZDraw3DSliceX(WIN3D* w,SliceData* s,InitSVector* sv);
357 int ZDraw3DSliceY(WIN3D* w,SliceData* s,InitSVector* sv);
358 int ZDraw4DStick(WIN3D* w,StickData* s);
359 int ZDrawSticks(WIN3D* w,StickData* s,DVSticksData* d);
360 int Z2DrawSticks(WIN3D* w,StickData* s,DVSticksData* d,
361  WIN3D* w2,int ix1,int iy1,int ix2,int iy2,int xy);
362 double ZGetDepth(WIN3D* w,int x,int y);
363 double ZglDepth(WIN3D* w,int x,int y);
364 double ZGetDepth(WIN3D* w,int x,int y);
365 double ZDrawTriangleGetDepth(WIN3D* w,double x,double y,
366 Vector4D* v1,Vector4D* v2,Vector4D* v3);
367 int ZSetGridRay(GridData* d,InitGridS* s,float* f1_,float* f2_,char* vr);
368 int GetCubeValue(DVData* d,double x,double y,double z,double* v);
369 
370 int YtMalloc(void *m,long n);
371 void* YtFree(void *m);
372 
373 extern Uchar gl_colors[128];
374 extern ColorInd* gl_CInd[128];
375 extern int Ngl_CInd;
376 extern Uchar my_rgb[256][3];
377 extern XEvent ZEvent;
378 extern XtAppContext Zapp_context; /* Application Context */
379 
380 
381 #endif
Definition: Zgraph.h:165
Definition: Zgraph.h:185
Definition: Zgraph.h:113
Definition: Zgraph.h:193
Definition: Zgraph.h:259
Definition: Zgraph.h:170
Definition: Zgraph.h:57
Definition: Zgraph.h:214
Definition: Zgraph.h:81
Definition: Zgraph.h:50
Definition: Zgraph.h:279
Definition: Zgraph.h:75
Definition: Zgraph.h:88
Definition: Zgraph.h:234
Definition: rays.H:81
Definition: Zgraph.h:204
Definition: Zgraph.h:243
Definition: Zgraph.h:209
Definition: Zgraph.h:159
Definition: Zgraph.h:60
Definition: Zgraph.h:53
Definition: Zgraph.h:68
Definition: Zgraph.h:230
Definition: Zgraph.h:117
Definition: Zgraph.h:64
Definition: Zgraph.h:177
Definition: Zgraph.h:100