1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* (C) Copyright IBM Corp. 1989,1999                                   */
4 /* ALL RIGHTS RESERVED                                                 */
5 /* This code licensed under the                                        */
6 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
7 /***********************************************************************/
8 
9 #include <dxconfig.h>
10 
11 
12 
13 
14 #ifndef _Picture_h
15 #define _Picture_h
16 
17 #include <Xm/DrawingA.h>
18 #include <Xm/DrawingAP.h>
19 #include <Xm/Label.h>
20 #include <Xm/LabelP.h>
21 #include <Xm/PushB.h>
22 #include <Xm/PushBP.h>
23 #include "Image.h"
24 #include "ImageP.h"
25 #include "Picture.h"
26 
27 /*  New fields for the Picture widget class record  */
28 
29 typedef struct
30 {
31    XtPointer none;   /* No new procedures */
32 } XmPictureClassPart;
33 
34 
35 /* Full class record declaration */
36 
37 typedef struct _XmPictureClassRec
38 {
39 	CoreClassPart		core_class;
40 	CompositeClassPart	composite_class;
41 	ConstraintClassPart	constraint_class;
42 	XmManagerClassPart	manager_class;
43 	XmDrawingAreaClassPart	drawing_area_class;
44 	XmImageClassPart	image_class;
45 	XmPictureClassPart	picture_class;
46 } XmPictureClassRec;
47 
48 extern XmPictureClassRec xmPictureClassRec;
49 
50 
51 #define Z_LEVELS 16		/* Number of levels for depth cueing */
52 #define UNDO_STACK_DEPTH 10
53 
54 
55 struct point
56 {
57 	double    xcoor;
58 	double    ycoor;
59 	double    zcoor;
60 
61 
62 	double    txcoor;
63 	double    tycoor;
64 	double    tzcoor;
65 
66   	int       sxcoor;
67 	int 	  sycoor;
68 	int       szcoor;
69 
70 	short     visible;
71 };
72 
73 struct line
74 {
75   	int       x1;
76 	int 	  y1;
77 	int       x2;
78 	int       y2;
79 
80 	Boolean   rejected;
81 	Boolean   dotted;
82 	Boolean   greyed;
83 };
84 
85 
86 #define   EQNUM     10
87 #define   ORBNUM    7
88 
89 struct globe
90 {
91 	int       x;
92 	int       y;
93 
94 	double	  first_x;	/* The x position of the cursor at selection*/
95 	double	  first_y;	/* The y position of the cursor at selection*/
96 	double	  first_z;
97 
98 	double	  last_x;	/* The prev x position of the cursor */
99 	double	  last_y;	/* The prev y position of the cursor */
100 	double	  last_l;
101 
102 	int       px;
103 	int       py;
104 	double    pt;
105 
106 	double	  paz;	/* prev angle about the Z axis */
107 
108 	double    xcoor;
109 	double    ycoor;
110 	double    zcoor;
111 
112 	double    radi;
113 
114 	struct point      equator[EQNUM][ORBNUM];
115 	struct point      orbit[ORBNUM][EQNUM];
116 
117 	struct point      tequator[EQNUM][ORBNUM];
118 	struct point      torbit[ORBNUM][EQNUM];
119 
120 	int               visible[EQNUM][ORBNUM];
121 	double            Wtrans[4][4];
122 	Boolean		  on_sphere;
123 	double		  circumference;
124         Pixmap  	  pixmap;
125 };
126 
127 
128 
129 #define  SHADES     50
130 typedef struct _XmPicturePart
131 {
132     /*  Public (resource accessable)  */
133     Boolean 		display_globe;
134     int 		mode;
135     Pixmap 		pixmap,  marker;
136     XmBasis		basis;
137     int			globe_radius;
138     Boolean		show_rotating_bbox;
139     Window		overlay_wid;
140     Boolean		overlay_exposure;
141     int			cursor_size;
142     int			cursor_speed;
143     int			constrain_cursor;
144     Boolean		new_image;
145     int			translate_speed_factor;
146     int			rotate_speed_factor;
147     int			navigate_direction;
148     int			look_at_direction;
149     double		look_at_angle;
150 
151     XtCallbackList 	pick_callback;
152     XtCallbackList 	cursor_callback;
153     XtCallbackList 	rotation_callback;
154     XtCallbackList 	zoom_callback;
155     XtCallbackList 	roam_callback;
156     XtCallbackList 	navigate_callback;
157     XtCallbackList 	client_message_callback;
158     XtCallbackList 	property_notify_callback;
159     XtCallbackList 	mode_callback;
160     XtCallbackList 	undo_callback;
161     XtCallbackList 	key_callback;
162 
163     /*  Private (local use)  */
164     Time last_time;
165 
166     XColor		box_grey;
167     XColor		selected_in_cursor_color;
168     XColor		selected_out_cursor_color;
169     XColor		unselected_in_cursor_color;
170     XColor		unselected_out_cursor_color;
171 
172 /* Stuff to make the 3D cursor work */
173 
174     Pixel	white;
175     Pixel	black;
176     double	DW;
177     double	DH;
178     double	zscale_width;
179     double	zscale_height;
180     double	view_angle;
181     int		projection;
182 
183 
184     int		undo_stk_ptr;
185     int		redo_stk_ptr;
186     int		undo_count;
187     int		redo_count;
188     struct _undo_stk
189     {
190 	double	up_x;
191 	double	up_y;
192 	double	up_z;
193 	double	from_x;
194 	double	from_y;
195 	double	from_z;
196 	double	to_x;
197 	double	to_y;
198 	double	to_z;
199 	double	width;
200 	double	view_angle;
201 	int	projection;
202     } undo_stack[UNDO_STACK_DEPTH], redo_stack[UNDO_STACK_DEPTH];
203 
204     Boolean	camera_defined;
205     Boolean	first_step;
206     int		button_pressed;
207     int         grab_keyboard_count;
208     KeySym	keysym;
209     double	arrow_roam_x;
210     double	arrow_roam_y;
211     double	arrow_roam_z;
212     int		old_x;
213     int		old_y;
214     Boolean	first_key_press;
215     int		ignore_new_camera;
216     Boolean	double_click;
217     Boolean	good_at_select;
218     Boolean	disable_temp;
219     double	navigate_to_x;	/* Navigate parameters	*/
220     double	navigate_to_y;	/* Navigate parameters	*/
221     double	navigate_to_z;	/* Navigate parameters	*/
222     double	navigate_from_x;/* Navigate parameters	*/
223     double	navigate_from_y;/* Navigate parameters	*/
224     double	navigate_from_z;/* Navigate parameters	*/
225     double	navigate_up_x;	/* Navigate parameters	*/
226     double	navigate_up_y;	/* Navigate parameters	*/
227     double	navigate_up_z;	/* Navigate parameters	*/
228     double	to_x;		/* Autocamera parameters	*/
229     double	to_y;		/* Autocamera parameters	*/
230     double	to_z;		/* Autocamera parameters	*/
231     double	from_x;		/* Autocamera parameters	*/
232     double	from_y;		/* Autocamera parameters	*/
233     double	from_z;		/* Autocamera parameters	*/
234     double	up_x;		/* Autocamera parameters	*/
235     double	up_y;		/* Autocamera parameters	*/
236     double	up_z;		/* Autocamera parameters	*/
237     int		image_width;	/* Autocamera parameters	*/
238     int		image_height;	/* Autocamera parameters	*/
239     double	autocamera_width;/* Autocamera parameters	*/
240     Boolean	autoaxis_enabled;/* Autocamera parameters	*/
241     int		n_cursors;
242     XmPushButtonWidget	pb;
243     Widget	popup;
244     Boolean 	popped_up;
245     XFontStruct *font;
246     GC		fontgc;
247     XtIntervalId tid;
248     XtIntervalId key_tid;
249     int		cursor_num;
250     int 	PIXMAPWIDTH,
251 		PIXMAPHEIGHT;
252     short 	i_pixmap[20][20];
253     float  	z_pixmap[20][20] ;
254     double 	X,
255 		Y,
256 		Z;		/* Current (X,Y,Z) of the 3D cursor */
257     int 	K;			/* Length of pointer history buffer */
258     int 	px,
259 		py; 		/* Pointer history "buffer" */
260     int		ppx,
261 		ppy; 		/* Pointer history "buffer" */
262     int		pppx,
263 		pppy; 		/* Pointer history "buffer" */
264     int 	pcx,
265 		pcy;		/* last active cursor location */
266     int 	iMark,
267 		piMark;
268     double   	Wtrans[4][4];
269     double	WItrans[4][4];
270     double   	PureWtrans[4][4];
271     double	PureWItrans[4][4];
272     double 	Xmark[3],
273 		Ymark[3],
274 		Zmark[3],
275 		pXmark[3],
276 		pYmark[3],
277 		pZmark[3];
278     struct point Face1[4],
279 		Face2[4];
280     double	Zmax;
281     struct line box_line[12];
282     double	Zmin;
283     double	FacetXmax;
284     double	FacetYmax;
285     double	FacetZmax;
286     double	FacetXmin;
287     double	FacetYmin;
288     double	FacetZmin;
289     Boolean 	CursorBlank;
290     Cursor	cursor;
291     int 	FirstTime;
292     int		FirstTimeMotion;
293     double 	Ox;
294     double	Oy;
295     double	Oz;
296     double	zangle;
297     double	xangle;
298     double	yangle;
299     int		*xbuff;
300     int		*ybuff;
301     double 	*zbuff;
302     double	*cxbuff; /* Cursor positions in canonical form */
303     double	*cybuff;
304     double 	*czbuff;
305     int		*selected;
306     int		roam_xbuff;	/* Roam cursor info */
307     int		roam_ybuff;
308     double 	roam_zbuff;
309     double	roam_cxbuff;
310     double	roam_cybuff;
311     double 	roam_czbuff;
312     int		roam_selected;
313     int    	cursor_shape;
314     double	angle_posx;
315     double	angle_posy;
316     double	angle_posz;
317     double	angle_negx;
318     double	angle_negy;
319     double	angle_negz;
320     Boolean	x_movement_allowed; /* Used in XmCURSOR_MODE2 */
321     Boolean	y_movement_allowed;
322     Boolean	z_movement_allowed;
323 
324    GC  		gc;
325    GC		gcovl;			/* GC for the overlay window */
326    GC  		gc_dash;
327    GC		gcovl_dash;			/* GC for the overlay window */
328    Pixmap  	ActiveSquareCursor[Z_LEVELS];
329    Pixmap	PassiveSquareCursor[Z_LEVELS];
330    struct globe	*globe;
331 
332    int		gnomon_center_x;
333    int		gnomon_center_y;
334    int		gnomon_xaxis_x;
335    int		gnomon_xaxis_y;
336    int		gnomon_yaxis_x;
337    int		gnomon_yaxis_y;
338    int		gnomon_zaxis_x;
339    int		gnomon_zaxis_y;
340    int		gnomon_xaxis_label_x;
341    int		gnomon_xaxis_label_y;
342    int		gnomon_yaxis_label_x;
343    int		gnomon_yaxis_label_y;
344    int		gnomon_zaxis_label_x;
345    int		gnomon_zaxis_label_y;
346 
347    struct
348    {
349    int		old_x;
350    int		old_y;
351    int		old_center_x;
352    int		old_center_y;
353    int		old_width;
354    int		old_height;
355    GC		gc;
356    int		center_x;
357    int		center_y;
358    double	aspect;			/* aspect ratio of the window */
359    }		rubber_band;
360 
361 } XmPicturePart;
362 
363 
364 typedef struct _XmPictureRec
365 {
366 	CorePart		core;
367 	CompositePart		composite;
368 	ConstraintPart		constraint;
369 	XmManagerPart		manager;
370 	XmDrawingAreaPart	drawing_area;
371 	XmImagePart		image;
372 	XmPicturePart		picture;
373 } XmPictureRec;
374 
375 #endif
376