|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/vibrant/shim3d.h |
source navigation diff markup identifier search freetext search file search |
1 /* shim3d.h
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information (NCBI)
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government do not place any restriction on its use or reproduction.
13 * We would, however, appreciate having the NCBI and the author cited in
14 * any work or product based on this material
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * ===========================================================================
25 *
26 * File Name: shim3d.h
27 *
28 * Author: Lewis Geer
29 *
30 * Version Creation Date: 1/29/99
31 *
32 * $Revision: 6.37 $
33 *
34 * File Description:
35 * header file for shims to replace Viewer3D with OpenGL
36 *
37 * Modifications:
38 * --------------------------------------------------------------------------
39 * $Log: shim3d.h,v $
40 * Revision 6.37 2000/07/28 21:05:54 lewisg
41 * more c++ fixes
42 *
43 * Revision 6.36 2000/07/27 16:34:46 lewisg
44 * more c++ fixes
45 *
46 * Revision 6.35 2000/07/27 13:37:31 lewisg
47 * more c++ fixes
48 *
49 * Revision 6.34 2000/07/24 22:31:22 thiessen
50 * fix header conflict
51 *
52 * Revision 6.33 2000/07/22 20:13:42 thiessen
53 * fix header conflict
54 *
55 * Revision 6.32 2000/07/21 18:55:58 thiessen
56 * allow dynamic slave->master transformation
57 *
58 * Revision 6.31 2000/07/08 20:44:14 vakatov
59 * Get all "#include" out of the 'extern "C" { }' scope; other cleanup...
60 *
61 * Revision 6.30 2000/05/16 17:38:44 thiessen
62 * do glGenLists after context init on X11 - for Mesa 3.2
63 *
64 * Revision 6.29 2000/04/17 15:54:27 thiessen
65 * add cylinder arrows; misc graphics tweaks
66 *
67 * Revision 6.28 2000/04/03 18:23:47 thiessen
68 * add arrowheads to strand bricks
69 *
70 * Revision 6.27 2000/03/24 20:35:00 lewisg
71 * add blast from file, bug fixes, get rid of redundant code, etc.
72 *
73 * Revision 6.26 2000/03/22 23:42:22 lewisg
74 * timing loop for animation
75 *
76 * Revision 6.25 2000/03/09 17:55:18 thiessen
77 * changes to palette handling for 8-bit OpenGL
78 *
79 * Revision 6.24 2000/03/08 21:46:13 lewisg
80 * cn3d saves viewport, misc bugs
81 *
82 * Revision 6.23 2000/02/26 13:30:41 thiessen
83 * capped cylinders and worms for visible ends
84 *
85 * Revision 6.22 2000/02/10 18:18:23 lewisg
86 * add proto for ZoomOut
87 *
88 * Revision 6.21 2000/01/14 21:40:39 lewisg
89 * add translucent spheres, ion labels, new cpk, fix misc bugs
90 *
91 * Revision 6.20 2000/01/07 00:22:46 thiessen
92 * fixes for LessTif and OpenGL X visual selection
93 *
94 * Revision 6.19 2000/01/06 17:23:36 thiessen
95 * various OpenGL improvements
96 *
97 * Revision 6.18 2000/01/06 00:04:41 lewisg
98 * selection bug fixes, update message outbound, animation APIs moved to vibrant
99 *
100 * Revision 6.17 1999/12/17 20:25:01 thiessen
101 * put in preliminary PNG output (for Cn3D)
102 *
103 * Revision 6.16 1999/12/15 19:18:49 thiessen
104 * bug fix for previous revision
105 *
106 * Revision 6.14 1999/12/08 22:58:00 thiessen
107 * added quality settings for OpenGL rendering
108 *
109 * Revision 6.13 1999/11/23 19:24:16 thiessen
110 * better solution to OpenGL render rect setting on Mac
111 *
112 * Revision 6.12 1999/11/19 18:07:24 thiessen
113 * added label capability for OpenGL version on Mac and Motif
114 *
115 * Revision 6.11 1999/11/08 16:43:21 thiessen
116 * major rearrangement of OpenGL color/material/lighting; also added 3-d (thick) brick
117 *
118 * Revision 6.10 1999/10/31 22:39:34 thiessen
119 * added wifreframe worm capability to viewer3d
120 *
121 * Revision 6.9 1999/10/15 17:37:44 thiessen
122 * put in splined 'worm' model for virtual BB
123 *
124 * Revision 6.8 1999/09/22 14:59:21 thiessen
125 * another minor fix of forward decl. for SGI
126 *
127 * Revision 6.7 1999/09/22 14:22:49 lewisg
128 * fixed forward declaration of TOGL_Layers to compile on SGI
129 *
130 * Revision 6.6 1999/09/21 14:11:22 thiessen
131 * added #include <GL/gl.h>
132 *
133 * Revision 6.5 1999/09/21 13:45:31 thiessen
134 * port of Lewis's OpenGL code to X/Motif
135 *
136 * Revision 6.4 1999/09/20 20:12:56 lewisg
137 * change typedefs for a colorcell, add triangle generator, fix incorrect return values
138 *
139 * Revision 6.3 1999/06/14 23:15:11 lewisg
140 * moved useful helper functions out of the ifdef
141 *
142 * Revision 6.2 1999/04/06 17:17:17 lewisg
143 * fix typo
144 *
145 * Revision 6.1 1999/04/06 14:23:29 lewisg
146 * add opengl replacement for viewer3d
147 * ==========================================================================
148 */
149
150 #ifndef _SHIM3D_
151 #define _SHIM3D_
152
153 #include <ncbilcl.h>
154 #include <ncbistd.h>
155 #include <vibmouse.h>
156 #include <ddvcolor.h>
157
158 #ifndef _OPENGL
159 #include <pictur3d.h>
160 #endif
161
162 /*
163
164 Do not include gl.h here. On Windows, gl.h is dependent on windows.h.
165 However, some functions in vibrant have the same name as some of the
166 functions in windows.h, so files that include both can have conflicts.
167
168 */
169
170
171 #ifdef __cplusplus
172 extern "C" {
173 #endif
174
175 void OGL_CreateCTransform(Nlm_FloatHi x1, Nlm_FloatHi y1, Nlm_FloatHi z1,
176 Nlm_FloatHi x2, Nlm_FloatHi y2, Nlm_FloatHi z2,
177 Nlm_FloatHi * Rotate, Nlm_FloatHi * Translate,
178 Nlm_FloatHi * length);
179
180 extern Nlm_FloatHi *OGL_CrossProduct(Nlm_FloatHi * v1, Nlm_FloatHi * v2);
181
182 #define OGL_SQR(oglx) ((oglx)*(oglx))
183
184
185 /* viewer3d version of this function */
186 #ifndef _OPENGL
187 extern void Nlm_AddHalfWorm3D(Nlm_Picture3D pic,
188 Nlm_Segment3D segment, BigScalar userData,
189 Uint1 layer, Uint1 color,
190 Nlm_FloatHi x0, Nlm_FloatHi y0, Nlm_FloatHi z0,
191 Nlm_FloatHi x1, Nlm_FloatHi y1, Nlm_FloatHi z1,
192 Nlm_FloatHi x2, Nlm_FloatHi y2, Nlm_FloatHi z2,
193 Nlm_FloatHi x3, Nlm_FloatHi y3, Nlm_FloatHi z3,
194 Nlm_FloatHi radius, Nlm_Int4 segments);
195 #endif
196
197
198
199
200 #ifdef _OPENGL
201
202 /*
203 * the following 2 includes are a subset of vibrant.h, since vibdefns.h
204 * and vibforms.h confict with windows.h
205 */
206
207 #ifdef __cplusplus
208 } /* extern "C" */
209 #endif
210
211 #include <vibtypes.h>
212 #include <vibprocs.h>
213
214 #ifdef __cplusplus
215 extern "C" {
216 #endif
217
218
219 /* defines */
220
221 #define OGL_DEFAULT_SIZE 5.0
222
223 #define OGLTEXT3D_MIDDLE 0x20
224 #define OGLTEXT3D_CENTER 0x2
225
226 #ifndef X_ROTATE_SBAR
227 #define X_ROTATE_SBAR 0x1
228 #endif
229
230 #ifndef Y_ROTATE_SBAR
231 #define Y_ROTATE_SBAR 0x2
232 #endif
233
234 #ifndef Z_ROTATE_SBAR
235 #define Z_ROTATE_SBAR 0x4
236 #endif
237
238 #define OGLMAXLAYERS 128
239 #define OGLFONTBASE 1000
240 #define OGLSELECTBUFFER 1000
241
242 typedef enum {
243 MouseOGL_DoNothing = 0,
244 MouseOGL_RotateYX,
245 MouseOGL_RotateZX,
246 MouseOGL_RotateYZ,
247 MouseOGL_Move,
248 MouseOGL_Zoom,
249 MouseOGL_NumStd
250 } Nlm_enumStdMAOGL;
251
252 typedef Boolean(*Nlm_MAInitOGLFunc) (MAPtr ma, Nlm_VoidPtr data);
253
254
255 typedef struct _OGL_BoundBox
256 /* bounds a volume */
257 {
258 Nlm_FloatLo x[2];
259 Nlm_FloatLo y[2];
260 Nlm_FloatLo z[2];
261 Nlm_Boolean set;
262 } TOGL_BoundBox;
263
264
265 typedef struct _OGL_PaletteIndex
266 /* points into the palette created for OpenGL running in Index color mode */
267 {
268 DDV_ColorCell ColorCell; /* the color */
269 Nlm_Int4 Begin; /* the beginning index into the palette */
270 Nlm_Int4 End; /* the end of the pallette */
271 } TOGL_PaletteIndex;
272
273 struct _TOGL_Layers;
274
275 typedef struct _TOGL_Layers TOGL_Layers_;
276
277
278 typedef struct _OGL_Data
279 /* general runtime information */
280 {
281 /* the current viewpoint. used for zoom and move */
282 Nlm_FloatLo CameraDistance; /* distance (on Z-axis) from origin */
283 Nlm_FloatLo CameraAngle; /* in radians */
284 Nlm_FloatLo CameraDirection[2]; /* point in Z=0 plane camera points at */
285 Nlm_Boolean NeedCameraSetup; /* flag to tell redrawer that camera has changed */
286
287 Nlm_FloatLo MaxSize; /* biggest side of the bound box */
288 TOGL_BoundBox BoundBox; /* the containing box of the molecule */
289 Nlm_WindoW ParentWindow;
290 Nlm_PaneL Panel; /* needed to set palette */
291 ValNodePtr PaletteExpanded; /* the palette itself */
292 ValNodePtr PaletteIndex; /* palette index. type is TOGL_PaletteIndex */
293 Nlm_BaR Z_rotate; /* z rotation scroll bar */
294 MAPtr ma;
295 MA_GroupPtr ma_std_group[MouseOGL_NumStd];
296 Nlm_VoidPtr ModelMatrix; /* temporary copy of modelview matrix */
297 Nlm_Boolean IsPlaying; /* is the animation running? */
298 Nlm_FloatHi Tick; /* number of seconds per image in animation */
299 TOGL_Layers_ *Layers; /* the layers and their state */
300 Nlm_Int4 SpaceWidth; /* width of space character */
301 Nlm_Int4 SpaceHeight; /* height of space character */
302 Nlm_Boolean IndexMode; /* number of bits per pixel. If < 16, used color index mode */
303 DDV_ColorCell Background; /* background color */
304 /* note that the highlight color is the responsibility of the application */
305 Nlm_Boolean SelectMode; /* are we doing a selection? */
306 Nlm_VoidPtr SelectBuffer; /* buffer where the selection are dumped */
307 Nlm_PoinT SelectPoint; /* the point on the screen that was clicked for selection */
308 Nlm_Uint4 SelectHits; /* the number of hits */
309
310 /* various info on X stuff related to OpenGL rendering context */
311 /* these are void pointers, because including the X headers above this
312 causes all sorts of name conflicts in various modules. Big pain! */
313 void *display; /* is actually a Display* */
314 void *visinfo; /* is actually an XVisualInfo* */
315
316 } TOGL_Data;
317
318
319 extern void OGL_PushTransformation(ValNodePtr transforms);
320 extern void OGL_PopTransformation(void);
321
322 extern void Nlm_AddHalfWorm3D(TOGL_Data * OGL_Data, DDV_ColorCell * color,
323 Nlm_FloatHi x0, Nlm_FloatHi y0, Nlm_FloatHi z0,
324 Nlm_FloatHi x1, Nlm_FloatHi y1, Nlm_FloatHi z1,
325 Nlm_FloatHi x2, Nlm_FloatHi y2, Nlm_FloatHi z2,
326 Nlm_FloatHi x3, Nlm_FloatHi y3, Nlm_FloatHi z3,
327 Nlm_Boolean cap1, Nlm_Boolean cap2,
328 Nlm_FloatHi radius, Nlm_Int4 segments, Nlm_Int4 sides);
329
330 extern void OGL_Normalize(Nlm_FloatHi * v);
331 extern Nlm_FloatHi *OGL_MakeNormal(Nlm_FloatHi * origin, Nlm_FloatHi * v1,
332 Nlm_FloatHi * v2);
333 extern void OGL_Reset(TOGL_Data * OGL_Data);
334 extern void OGL_AddQuad3D(TOGL_Data * OGL_Data, DDV_ColorCell * color,
335 Nlm_FloatHi * v1, Nlm_FloatHi * v2,
336 Nlm_FloatHi * v3, Nlm_FloatHi * v4);
337 extern void OGL_AddBrick3D(TOGL_Data * OGL_Data, DDV_ColorCell * color,
338 Nlm_FloatHi * Nterm, Nlm_FloatHi * Cterm,
339 Nlm_FloatHi * norm, Nlm_FloatHi width,
340 Nlm_FloatHi thickness, Nlm_Boolean doArrow);
341 extern void OGL_AddTri3D(TOGL_Data * OGL_Data, DDV_ColorCell * color,
342 Nlm_FloatHi * v1, Nlm_FloatHi * v2,
343 Nlm_FloatHi * v3, Nlm_FloatHi * Normal);
344 NLM_EXTERN void OGL_ZoomOut(TOGL_Data *OGL_Data);
345 NLM_EXTERN void OGL_ZoomIn(TOGL_Data *OGL_Data);
346
347 extern void OGL_ClearBoundBox(TOGL_BoundBox *);
348 extern void OGL_ClearOGL_Data(TOGL_Data *);
349 extern void OGL_DrawViewer3D(TOGL_Data *);
350 extern void OGL_AddCylinder3D(TOGL_Data * OGL_Data, DDV_ColorCell * color,
351 Nlm_FloatHi x1, Nlm_FloatHi y1, Nlm_FloatHi z1,
352 Nlm_Boolean cap1,
353 Nlm_FloatHi x2, Nlm_FloatHi y2, Nlm_FloatHi z2,
354 Nlm_Boolean cap2, Nlm_FloatHi radius,
355 Nlm_Int4 sides, Nlm_Boolean doArrow);
356 extern void OGL_AddLine3D(TOGL_Data * OGL_Data, DDV_ColorCell * color,
357 Nlm_FloatHi x1, Nlm_FloatHi y1, Nlm_FloatHi z1,
358 Nlm_FloatHi x2, Nlm_FloatHi y2, Nlm_FloatHi z2);
359 extern void OGL_AddSphere3D(TOGL_Data * OGL_Data, DDV_ColorCell * color,
360 Nlm_FloatHi x, Nlm_FloatHi y, Nlm_FloatHi z,
361 Nlm_FloatHi radius, Nlm_Int4 slices,
362 Nlm_Int4 stacks, Nlm_FloatHi alpha,
363 ValNodePtr transforms);
364 extern void OGL_AddText3D(TOGL_Data * OGL_Data, DDV_ColorCell * color,
365 Nlm_CharPtr string, Nlm_FloatHi x, Nlm_FloatHi y,
366 Nlm_FloatHi z, Nlm_Int2 flags);
367 extern Nlm_Boolean OGL_SetPosition3D(TOGL_Data * OGL_Data,
368 Nlm_RectPtr rect);
369 extern void OGL_DataFromBound(TOGL_Data * OGL_Data);
370 extern void OGL_Start(TOGL_Data * OGL_Data, Nlm_Int1 List);
371 extern void OGL_End();
372 extern void OGL_SetLayers(TOGL_Data * OGL_Data, Nlm_Boolean status);
373 extern void OGL_SetLayer(TOGL_Data * OGL_Data, Nlm_Int4 i,
374 Nlm_Boolean status);
375 extern Nlm_Boolean OGL_GetLayer(TOGL_Data * OGL_Data, Nlm_Int4 i);
376 extern void OGL_SetLayerTop3D(TOGL_Data * OGL_Data, Nlm_Int4 TopLayer);
377 extern void OGL_AllLayerOnProc(TOGL_Data * OGL_Data);
378 extern void OGL_RewindLayerProc(TOGL_Data * OGL_Data);
379 extern void OGL_PrevLayerProc(TOGL_Data * OGL_Data);
380 extern void OGL_NextLayerProc(TOGL_Data * OGL_Data);
381 extern void OGL_Play(TOGL_Data * OGL_Data);
382 extern ValNodePtr OGL_SearchPaletteIndex(ValNodePtr PaletteIndex,
383 DDV_ColorCell * ColorCell);
384 extern TOGL_Data *OGL_CreateViewer(Nlm_GrouP prnt, Nlm_Uint2Ptr width,
385 Nlm_Uint2 height, Nlm_Int4 flags,
386 Nlm_MenU ma_group_menu,
387 Nlm_MenU ma_action_menu,
388 Nlm_MAInitOGLFunc ma_init_func,
389 Nlm_VoidPtr ma_init_data);
390 extern void OGL_InitializeLists(TOGL_Data * OGL_Data);
391 extern void OGL_LoadName(Nlm_VoidPtr PtrValue);
392 extern Nlm_VoidPtr OGL_Hit(TOGL_Data * OGL_Data);
393 extern void OGL_Select(TOGL_Data * OGL_Data, Nlm_Boolean SelectMode);
394 extern void OGL_SetSelectPoint(TOGL_Data * OGL_Data, Nlm_PoinT Point);
395 NLM_EXTERN Nlm_Boolean OGL_IsPlaying(TOGL_Data *pOGL_Data);
396 NLM_EXTERN void OGL_StopPlaying(TOGL_Data *pOGL_Data);
397 NLM_EXTERN void OGL_StartPlaying(TOGL_Data *pOGL_Data);
398 NLM_EXTERN void OGL_DrawLogo(TOGL_Data *OGL_Data);
399 NLM_EXTERN void OGL_ClearTransparentSpheres(void);
400 NLM_EXTERN void SetOGLFont(TOGL_Data *OGL_Data, Nlm_Int2 fontNameIndex, Nlm_Int2 fontSize,
401 Nlm_Boolean isBold, Nlm_Boolean isItalic, Nlm_Boolean isUnderlined);
402 NLM_EXTERN void Nlm_FindAvailableFonts(Nlm_PopuP pupmenu);
403
404
405 #ifdef _PNG
406 void Nlm_SaveImagePNG(Nlm_Char *defname); /* for PNG export */
407 #endif /* _PNG */
408
409 #endif /* _OPENGL */
410
411 #ifdef __cplusplus
412 }
413 #endif
414
415 #endif
416 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |