1 #ifndef SUMA_DEFINE_INCLUDED
2 #define SUMA_DEFINE_INCLUDED
3 
4 
5 #define SUMA_DEF_GROUP_NAME "DefGroup"
6 #define SUMA_DEF_TOY_GROUP_NAME "DeDe"
7 #define SUMA_DEF_STATE_NAME "Default_state"
8 
9 #define SUMA_SUMA_NIML_DEBUG 0
10 #define SUMA_SEPARATE_SURF_CONTROLLERS 0 /*!< 0 if you want surfaces sharing the same LocalDomainParent
11                                                 to use the same controller.
12                                                 If you choose 1, then the controllers will not be linked
13                                                 and there will be no parameter update for that colorplane
14                                                 in the other controllers. The problem is that every little
15                                                 callback will have to make a call to SUMA_UpdateColPlaneShellAsNeeded
16                                                 and that's a pain, to say the least.*/
17 
18 #define ARRAY 1
19 #define STRAIGHT 2
20 #define TRIANGLES 1
21 #define POINTS 2
22 
23 #define DRAW_METHOD ARRAY
24 #define RENDER_METHOD TRIANGLES
25 #define DO_MESH
26 #define DO_MESH_AXIS
27 /*#define ZERO_CENTER*/
28 
29 #define SUMA_DOUBLE_CLICK_MAX_DELAY 250 /*!< Maximum delay in ms to consider a double click */
30 
31 #define NODE_COLOR_R 0.35
32 #define NODE_COLOR_G 0.35
33 #define NODE_COLOR_B 0.35
34 #define SUMA_GRAY_NODE_COLOR 0.30
35 #define SUMA_DIM_AFNI_COLOR_FACTOR 0.5 /*!< 0.4 works well, use higher factors for flashiness scaling factor (0..1) applied to afni's rgb colors, lower values help retain surface shape info */
36 #define SUMA_AFNI_COLORPLANE_OPACITY 1
37 #define SUMA_DIM_CONVEXITY_COLOR_FACTOR 0.5
38 #define SUMA_CONVEXITY_COLORPLANE_OPACITY 0.8
39 #define SUMA_BACKGROUND_MODULATION_FACTOR 3   /*!< 0 background does not modulate         foreground, Color = Fore * avg_Bright * AttenFactor (0 <= avg_Bright <=1)
40         a good setting is such that
41         SUMA_BACKGROUND_ATTENUATION_FACTOR * SUMA_DIM_AFNI_COLOR_FACTOR = 1
42         Watch for saturation effects!*/
43 
44 #define SUMA_MAT_SHININESS_INIT 0 /*!< Surface object shininess, 0 20, 50 .. 128*/
45 #define SUMA_MAT_SPECULAR_INIT    0.0, 0.0, 0.0, 1.0 /*!< The specular color of the material, keep this and the exponent (that's MAT_SHININESS) 0 to keep shininess down*/
46 #define SUMA_MAT_AMBIENT_INIT    0.2, 0.2, 0.2, 1.0 /*!< Fraction of Ambient light reflected.Ambient light has an undetermined direction and is scattered equally in all directions */
47 #define SUMA_MAT_DIFFUSE_INIT    0.8, 0.8, 0.8, 1.0 /*!<  Fraction of Diffuse light reflected.Diffuse light comes from one direction, but is scattered equally in all directions and appears equally bright no matter where the eye is located*/
48 #define SUMA_MAT_EMISSION_INIT    0.0, 0.0, 0.0, 1.0 /*!< Emissive color/light emanated from object.
49                                                            and unaffected by light sources.
50                                                            It adds no light to other objects in the scene */
51 
52 #define SUMA_LMODEL_AMBIENT_COLOR_R   1.0       /*!< keep the ambient light high */
53 #define SUMA_LMODEL_AMBIENT_COLOR_G   1.0
54 #define SUMA_LMODEL_AMBIENT_COLOR_B   1.0
55 #define SUMA_LMODEL_AMBIENT_COLOR_A   1.0
56 #define SUMA_LMODEL_AMBIENT       SUMA_LMODEL_AMBIENT_COLOR_R, SUMA_LMODEL_AMBIENT_COLOR_G, SUMA_LMODEL_AMBIENT_COLOR_B,  SUMA_LMODEL_AMBIENT_COLOR_A /*!< keep the ambient light high */
57 
58 #define SUMA_RED_GL 1.0, 0.0, 1.0, 1.0 /*!< red color */
59 #define SUMA_YELLOW_GL 0.0, 1.0, 1.0, 1.0 /*!< yellow color */
60 #define SUMA_BLUE_GL 0.0, 0.0, 1.0, 1.0 /*!< yellow color */
61 #define SUMA_GREEN_GL 0.0, 1.0, 0.0, 1.0 /*!< yellow color */
62 
63 #define SUMA_CLEAR_COLOR_R         0.0 /*!< clear color (viewer background) Red */
64 #define SUMA_CLEAR_COLOR_G         0.0 /*!< clear color (viewer background) Green */
65 #define SUMA_CLEAR_COLOR_B         0.0 /*!< clear color (viewer background) Blue */
66 #define SUMA_CLEAR_COLOR_A         0.0 /*!< clear color (viewer background) Alpha */
67 
68 
69 #define SUMA_BACKFACE_CULL 0 /*!< 1/0 flag for culling backface facesets */
70 #define SUMA_CHECK_WINDING 0 /*!< 1/0 flag for checking triangle winding */
71 
72 #define SUMA_LIGHT0_COLOR_R   1.0
73 #define SUMA_LIGHT0_COLOR_G   1.0
74 #define SUMA_LIGHT0_COLOR_B   1.0
75 #define SUMA_LIGHT0_COLOR_A   1.0
76 #define SUMA_LIGHT0_COLOR_INIT    SUMA_LIGHT0_COLOR_R, SUMA_LIGHT0_COLOR_G, SUMA_LIGHT0_COLOR_B,  SUMA_LIGHT0_COLOR_A
77 #define SUMA_INTITIAL_LIGHT0_SWITCH 1 /*!< -1 works well for SureFit Surfaces, 1 works well for iv and FreeSurfer surfaces */
78 #define SUMA_STDERR stderr
79 #define SUMA_STDOUT stdout
80 
81 #define SUMA_CROSS_HAIR_LINE_WIDTH 1.5
82 #define SUMA_CROSS_HAIR_RADIUS 6
83 #define SUMA_CROSS_HAIR_GAP 2
84 #define SUMA_CROSS_HAIR_SPHERE_RADIUS 0.5
85 #define SUMA_SELECTED_NODE_SPHERE_RADIUS 0.25
86 
87 #define SUMA_BEEP_LENGTH_MS 50 /*!< beep time in ms */
88 #define SUMA_XYZ_XFORM_BOXDIM_MM 5 /*!< search box width (in mm) used to change XYZ to the closest node index. Keep this one small, 5 mm works for me. Otherwise you may get thrown way off of where you should be. It is no guarantee that the closest node is part of the faceset you are looking at*/
89 #define SUMA_SELECTED_FACESET_LINE_WIDTH 2 /*!< Line Width of highlighting triangles */
90 #define SUMA_SELECTED_FACESET_OFFSET_FACTOR 0.01 /*!< highlighting is done by drawing two triangles at a fractional distance of the normal vector */
91 #define SUMA_SELECTED_FACESET_LINE_INTENSITY 0.75 /*!< line gray color intensity */
92 #define SUMA_NODE_ALPHA 1 /*!< Node Color Intensity 1, max intensity 0 min intensity*/
93 #define FOV_INITIAL 30.0  /*!< Leave this at 30 always, change defaults from .sumarc's SUMA_FOV_Original */
94 #define FOV_MIN 0.001
95 #define FOV_MAX 179
96 #define FOV_IN_FACT 1.05   /*!< Still used for colormap display,
97                            Obsolete for surface viewers, see sv->KeyZoomGain */
98 #define FOV_OUT_FACT 0.95  /*!< Still used for colormap display,
99                            Obsolete for surface viewers, see sv->KeyZoomGain */
100 #define MOUSE_ZOOM_FACT 30 /*!< The larger, the slower the gain on mouse movement */
101 #define TRANSLATE_GAIN 50 /*!< between 40 and 80 */
102 #define ARROW_TRANSLATE_DELTAX 30
103 #define ARROW_TRANSLATE_DELTAY 30
104 #define ARROW_ROTATION_ANGLE_DEG 15
105 #define SUMA_MAX_N_GROUPS 100 /*!< Maximum number of surface groups */
106 #define SUMA_MAX_MESSAGES 100 /*!< Maximum number of messages stored in list */
107 #define SUMA_MAX_MEMBER_FACE_SETS 110 /*!< Maximum number of facesets a node can
108                                           be part of. Used to be 60 but that was
109                                           not enough for a few
110                                           funky FS surfaces. ZSS Mon Mar 24
111                                           16:14:12 EST 2003*/
112 #define SUMA_MAX_FACESET_EDGE_NEIGHB 3 /*!< Maximum number of adjoining FaceSets
113                                             a triangular faceset can have.*/
114 #define SUMA_MAX_DISPLAYABLE_OBJECTS 1000 /*!< Max # of displayable Objects */
115 #define SUMA_MAX_SURF_VIEWERS 10 /*!< Maximum number of surface viewers allowed,
116                                      Javier needs 7 ! */
117 #define SUMA_SURF_CONT_SWITCH_LABEL_LENGTH 40
118 #define SUMA_DEFAULT_VIEW_FROM 300 /*!< default view from location on Z axis */
119 #define SUMA_MAX_FP_NAME_LENGTH ( SUMA_MAX_DIR_LENGTH + SUMA_MAX_NAME_LENGTH )
120 #define SUMA_MAX_COMMAND_LENGTH      2000 /*!< Maximum number of characters in a
121                                                command string */
122 #define SUMA_MAX_LABEL_LENGTH 300 /*!< Maximum number of characters for labeling
123                                        and naming suma fields and objects */
124 #define SUMA_MAX_STRING_LENGTH 1000 /*!< Max number of characters in a string */
125 #define SUMA_MAX_COLOR_NAME 50 /*!< Max. length of the name of a color */
126 #define SUMA_MAX_NUMBER_NODE_NEIGHB   100 /*!< Maximum number of neighbors any
127                                           one node can have.
128                                           Used to be 50 but that was not enough
129                                           for a few funky FS surfaces.
130                                           ZSS Mon Mar 24 16:14:12 EST 2003*/
131 #define SUMA_MAX_OVERLAYS 50 /*!< Maximum number of color overlay planes
132                                   allowed */
133 #define SUMA_COMMAND_DELIMITER '|'
134 #define SUMA_COMMAND_TERMINATOR '~'
135 #define SUMA_PERSPECTIVE_NEAR   1.0   /*!< Z Near, distance from the viewer to
136                                  the near clipping plane (for gluPerspective)*/
137 #define SUMA_PERSPECTIVE_FAR      900 /*!< Z Far, distance from the viewer to the
138                                  far clipping plane (for gluPerspective)*/
139 #define SUMA_TESSCON_TO_MM       319.7 /*!< The mysterious Tesscon units */
140 #define SUMA_TESSCON_DIFF_FLAG    1000 /*!< Apply scaling by SUMA_TESSCON_TO_MM
141                                  If aMaxDim - aMinDim > SUMA_TESSCON_DIFF_FLAG in
142                                  a .iv file */
143 
144 
145 #define SUMA_MAX_N_SURFACE_SPEC 1000/*!< Max # of surfs allowed in a spec file */
146 #define SUMA_MAX_N_DO_SPEC 100
147 
148 #define SUMA_MEMTRACE_BLOCK 10000 /*!< Number of elements to allocate for when
149                                        keeping track of allocated memory. If
150                                        needed more space is reallocated with
151                                        SUMA_MEMTRACE_BLOCK increments. */
152 #define SUMA_MEMTRACE_FLAG 1    /*!< Flag to turn on(1) or off (0) the
153                                      memory tracing capability */
154 #define SUMA_PI 3.141592653589793115997963
155 #define SUMA_EPSILON 0.000001
156 
157 #define SUMA_MAX_N_CLIP_PLANES 6 /*!< Limited by maximum nuber of clip planes allowed by OpenGL, assume min of 6*/
158 
159 /*!
160    Debugging flags
161 */
162 #define SUMA_NIML_WORKPROC_IO_NOTIFY 0  /*!< If set to 1 then SUMA_niml_workprocess will send a notification when InOut_Notify is ON
163                                           You should keep it off unless you suspect a problem in that function. Otherwise
164                                          you'll get many reports from the function making it difficult to see other messages. */
165 #define SUMA_WORKPROC_IO_NOTIFY 0  /*!< Same as above but for SUMA_workprocess */
166 
167 typedef enum { SUMA_VOX_NEIGHB_FACE, SUMA_VOX_NEIGHB_EDGE, SUMA_VOX_NEIGHB_CORNER } SUMA_VOX_NEIGHB_TYPES;
168 typedef enum { SUMA_DONT_KNOW = 0, SUMA_IN_TRIBOX_OUTSIDE = 1, SUMA_INTERSECTS_TRIANGLE_OUTSIDE,
169 SUMA_ON_NODE,
170 SUMA_INTERSECTS_TRIANGLE_INSIDE,
171 SUMA_IN_TRIBOX_INSIDE,
172 SUMA_INSIDE_SURFACE } SUMA_SURF_GRID_INTERSECT_OPTIONS;
173 
174 typedef enum { SUMA_GEOM_NOT_SET=-1, SUMA_GEOM_IRREGULAR = 0,
175                SUMA_GEOM_SPHERE = 1, SUMA_GEOM_ICOSAHEDRON,
176                SUMA_N_GEOM } SUMA_GEOM_TYPE;
177 
178 #define SUMA_IS_GEOM_SYMM(gt) ( ( (gt) == SUMA_GEOM_SPHERE || (gt) == SUMA_GEOM_ICOSAHEDRON ) ? 1:0 )
179 
180 typedef enum  { SUMA_NO_ANSWER, SUMA_YES, SUMA_NO, SUMA_HELP, SUMA_CANCEL, SUMA_YES_ALL, SUMA_NO_ALL, SUMA_WHAT_THE_HELL } SUMA_QUESTION_DIALOG_ANSWER; /* DO NOT CHANGE THE ORDER OF THE FIRST 4 */
181 
182 typedef enum  { SUMA_FT_ERROR = -1, SUMA_FT_NOT_SPECIFIED,
183                SUMA_FREE_SURFER, SUMA_FREE_SURFER_PATCH, SUMA_SUREFIT,
184                SUMA_INVENTOR_GENERIC, SUMA_PLY, SUMA_VEC, SUMA_CMAP_SO,
185                SUMA_BRAIN_VOYAGER ,
186                SUMA_OPENDX_MESH, SUMA_BYU, SUMA_GIFTI, SUMA_MNI_OBJ,
187                SUMA_PREDEFINED, SUMA_OBJ_MESH, SUMA_STL,
188                   SUMA_N_SO_FILE_TYPE} SUMA_SO_File_Type; /* add types always between SUMA_FT_NOT_SPECIFIED AND SUMA_N_SO_FILE_TYPE */
189 typedef enum { SUMA_FF_ERROR = -1, SUMA_FF_NOT_SPECIFIED, SUMA_ASCII, SUMA_BINARY, SUMA_BINARY_BE, SUMA_BINARY_LE, SUMA_XML_SURF, SUMA_XML_ASCII_SURF,  SUMA_XML_B64_SURF, SUMA_XML_B64GZ_SURF } SUMA_SO_File_Format;
190 
191 
192 typedef enum { SUMA_COORD_TYPE_ERROR=0,
193                   SUMA_SCREEN,
194                   SUMA_WORLD} SUMA_DO_CoordType; /*!< Coordinate system that
195                           Displayable object that is attached to SCREEN is for a
196                           fixed system, WORLD is for a mobile system, ie one
197                           that is rotated by the mouse movements */
198 typedef enum { SUMA_COORD_UNITS_ERROR=0,
199                SUMA_NORM_SCREEN_UNIT, /* XYZ coordinates between [0,1] relative
200                                        to the drawing screen X Y are the fixed
201                                        eye axes and Z is 1 closest to users and
202                                        Z = 0 is all the way back. Z=0.5 is where
203                                        the fixed eye axes lies. To display an
204                                        object at such a location, it needs to be
205                                        transformed to SUMA_WORLD_UNIT with the
206                                        function SUMA_NormScreenToWorld. If the
207                                        latter function is called with only the
208                                        projection matrix set, i.e. before the                                           rotation and translations are applied,
209                                        as is done when SUMA_DO_CoordType is set
210                                        to SUMA_SCREEN then the location does not
211                                        move with moving surface (mouse
212                                        movements). If SUMA_DO_CoordType is set
213                                        to SUMA_WORLD then the transformed
214                                        location will track moving surface
215                                        because rotation and translation matrices
216                                        are taken into account. */
217               SUMA_WORLD_UNIT }   SUMA_DO_CoordUnits;
218 
219 
220 typedef enum {SUMA_SOLID_LINE, SUMA_DASHED_LINE} SUMA_STIPPLE;
221 
222 typedef enum {SUMA_Button_12_Motion, SUMA_Button_2_Shift_Motion, SUMA_Button_1_Motion, SUMA_Button_2_Motion, SUMA_Button_3_Motion} SUMA_MOTION_TYPES; /*!< Types of mouse motion */
223 
224 typedef enum { SE_Empty,
225                SE_SetLookAt, SE_SetLookFrom, SE_Redisplay,
226                SE_Home, SE_SetNodeColor,
227                SE_FlipLight0Pos, SE_GetNearestNode, SE_SetLookAtNode,
228                SE_HighlightNodes, SE_SetRotMatrix,
229                SE_SetCrossHair, SE_ToggleCrossHair, SE_SetSelectedNode,
230                SE_ToggleShowSelectedNode, SE_SetSelectedFaceSet,
231                SE_ToggleShowSelectedFaceSet, SE_ToggleConnected,
232                SE_SetAfniCrossHair, SE_SetAfniSurf, SE_SetAfniSurfList,
233                SE_SetAfniThisSurf, SE_SetAfniMask,
234                SE_SetForceAfniSurf, SE_BindCrossHair, SE_ToggleForeground,
235                SE_ToggleBackground, SE_FOVreset, SE_CloseStream4All,
236                SE_Redisplay_AllVisible, SE_RedisplayNow, SE_ResetOpenGLState,
237                SE_LockCrossHair, SE_SetGICORnode,
238                SE_ToggleLockAllCrossHair, SE_SetLockAllCrossHair,
239                SE_ToggleLockView, SE_ToggleLockAllViews,
240                SE_Load_Group, SE_Home_AllVisible, SE_Help, SE_Help_Cmap,
241                SE_Help_Plot, SE_Help_Xform, SE_Whereami, SE_Log,
242                SE_UpdateLog, SE_SetRenderMode, SE_SetTransMode, SE_OpenDrawROI,
243                SE_RedisplayNow_AllVisible, SE_RedisplayNow_AllOtherVisible,
244                SE_SetLight0Pos, SE_OpenColFileSelection,
245                SE_SaveDrawnROIFileSelection, SE_OpenDrawnROIFileSelection,
246                SE_SaveXformOptsFileSelection, SE_OpenXformOrtFileFileSelection,
247                SE_SendColorMapToAfni, SE_SaveSOFileSelection,
248                SE_SetSOinFocus, SE_StartListening, SE_LoadViewFileSelection,
249                SE_SaveViewFileSelection, SE_LoadSegDO,
250                SE_OpenDsetFileSelection, SE_OpenCmapFileSelection, SE_SetClip,
251                SE_OpenDsetFile, SE_OpenColFile, SE_OneOnly, SE_OpenSurfCont,
252                SE_SetSurfCont, SE_SetObjectCont, SE_SetViewerCont,
253                SE_SetRecorderCont,
254                SE_SetDsetViewMode, SE_SetDsetFont, SE_SetDsetNodeRad,
255                SE_SetDsetThrough,
256                SE_SetDsetNodeCol, SE_SetDsetEdgeThick, SE_SetDsetEdgeStip,
257                SE_SetDsetGmatBord, SE_SetDsetTxtShad, SE_SetTractMask,
258                SE_SetDsetAlphaVal, SE_SetTractStyle, SE_SetATransMode,
259                SE_OpenMaskFileSelection, SE_SaveMaskFileSelection,
260                SE_OpenMaskFile,
261                SE_BadCode} SUMA_ENGINE_CODE;
262                         /* DO not forget to modify SUMA_CommandCode */
263 typedef enum { SE_niEmpty,
264                SE_niSetSurfCont, SE_niSetObjectCont, SE_niSetViewerCont,
265                SE_niSetRecorderCont,
266                SE_niKillSuma, SE_GetLabel,
267                SE_niBadCode} SUMA_NI_COMMAND_CODE;
268 
269 typedef enum { SEF_Empty,
270                SEF_fm, SEF_im, SEF_fv3, SEF_iv3, SEF_fv15,
271                SEF_iv15, SEF_i, SEF_f, SEF_s, SEF_vp,
272                SEF_cp, SEF_fp, SEF_ip, SEF_iv200, SEF_fv200,
273                SEF_ivec, SEF_fvec, SEF_ngr, SEF_nel,
274                SEF_BadCode} SUMA_ENGINE_FIELD_CODE;
275 
276 typedef enum { SES_Empty,
277                SES_Afni,  /*!< command from Afni directly which practically means                                that Srcp in EngineData is not SUMA_SurfaceViewer
278                                * . In the future, some Afni related pointer might                                get passed here. */
279                SES_Suma,  /*!< command from Suma, which means that Srcp is a
280                                SUMA_SurfaceViewer * to the viewer making the
281                                command. */
282                SES_SumaWidget,  /*!< command from a widget in Suma. Usually
283                                      means, do not try to update widget ... */
284                SES_SumaFromAfni,   /*!< command from Suma in response to a
285                                         request from Afni. Srcp is still a
286                                         SUMA_SurfaceViewer * but Afni, having
287                                         initiated the command should not receive
288                                         the command back from Suma. Think
289                                         cyclical cross hair setting... */
290                SES_SumaFromAny,  /*!< Same concept as SES_SumaFromAfni but from
291                                       generic program. */
292                SES_Unknown} SUMA_ENGINE_SOURCE;
293 
294 typedef enum { SEI_WTSDS,
295                SEI_Head, SEI_Tail, SEI_Before, SEI_After, SEI_In,
296                SEI_BadLoc } SUMA_ENGINE_INSERT_LOCATION;
297 
298 typedef enum {    SOPT_ibbb,  /*!< int, byte, byte, byte, null */
299                   SOPT_ifff   /*!< int, float, float, float, null */
300             } SUMA_OVERLAY_PLANE_TYPE; /*!< type of color plane data, letters
301                                code for index red green blue and alpha values */
302 
303 
304 
305 typedef enum { SW_File,
306                SW_FileOpen, SW_FileOpenSpec, SW_FileOpenSurf, SW_FileClose,
307                SW_FileSaveView, SW_FileLoadView,
308                SW_N_File } SUMA_WIDGET_INDEX_FILE;
309                      /*!< Indices to widgets under File menu.
310                           Make sure you begin with SW_File and end
311                                                       with SW_N_File */
312 typedef enum { SW_Tools,
313                SW_ToolsDrawROI,
314                SW_N_Tools } SUMA_WIDGET_INDEX_TOOLS;
315                      /*!< Indices to widgets under Tools menu.
316                           Make sure you begin with SW_Tools and end
317                                                       with  SW_N_Tools*/
318 typedef enum { SW_View,
319                SW_ViewSumaCont, SW_ViewSurfCont, SW_ViewViewCont,
320                SW_ViewSep1,
321                SW_ViewCrossHair, SW_ViewNodeInFocus, SW_ViewSelectedFaceset,
322                SW_N_View } SUMA_WIDGET_INDEX_VIEW;
323                      /*!< Indices to widgets under View menu.
324                           Make sure you begin with SW_View and end
325                                                       with SW_N_View */
326 typedef enum { SW_Help,
327                SW_HelpWeb,
328                SW_HelpUsage,  SW_HelpMessageLog, SW_HelpSep1,
329                SW_HelpSUMAGlobal, SW_HelpViewerStruct, SW_HelpSurfaceStruct,
330                SW_HelpSep2, SW_HelpIONotify, SW_HelpEchoKeyPress,
331                SW_HelpMemTrace,
332                SW_N_Help } SUMA_WIDGET_INDEX_HELP;
333                   /*!< Indices to widgets under Help menu.
334                        Make sure you begin with SW_View and end
335                                                          with SW_N_View */
336 typedef enum { SW_SurfCont_Render,
337                SW_SurfCont_RenderViewerDefault, SW_SurfCont_RenderFill,
338                SW_SurfCont_RenderLine, SW_SurfCont_RenderPoints,
339                SW_SurfCont_RenderHide,
340                SW_N_SurfCont_Render } SUMA_WIDGET_INDEX_SURFCONT_RENDER;
341                               /*!< Indices to widgets in SurfaceController under
342                                    RenderMode */
343 typedef enum { SW_SurfCont_Trans,
344                SW_SurfCont_TransViewerDefault,
345                SW_SurfCont_Trans0, SW_SurfCont_Trans1,
346                SW_SurfCont_Trans2, SW_SurfCont_Trans3, SW_SurfCont_Trans4,
347                SW_SurfCont_Trans5, SW_SurfCont_Trans6, SW_SurfCont_Trans7,
348                SW_SurfCont_Trans8, SW_SurfCont_Trans9, SW_SurfCont_Trans10,
349                SW_SurfCont_Trans11, SW_SurfCont_Trans12, SW_SurfCont_Trans13,
350                SW_SurfCont_Trans14,SW_SurfCont_Trans15, SW_SurfCont_Trans16,
351                SW_N_SurfCont_Trans } SUMA_WIDGET_INDEX_SURFCONT_TRANS;
352                               /*!< Indices to widgets in SurfaceController under
353                                    TransMode */
354 typedef enum { SW_SurfCont_ATrans,
355                SW_SurfCont_ATransViewerDefault, SW_SurfCont_Alpha,
356                SW_SurfCont_ATrans0, SW_SurfCont_ATrans1,
357                SW_SurfCont_ATrans2, SW_SurfCont_ATrans3, SW_SurfCont_ATrans4,
358                SW_SurfCont_ATrans5, SW_SurfCont_ATrans6, SW_SurfCont_ATrans7,
359                SW_SurfCont_ATrans8, SW_SurfCont_ATrans9, SW_SurfCont_ATrans10,
360                SW_SurfCont_ATrans11, SW_SurfCont_ATrans12, SW_SurfCont_ATrans13,
361                SW_SurfCont_ATrans14,SW_SurfCont_ATrans15, SW_SurfCont_ATrans16,
362                SW_N_SurfCont_ATrans } SUMA_WIDGET_INDEX_SURFCONT_ATRANS;
363                               /*!< Indices to widgets in SurfaceController under
364                                    TransMode, with alpha mode */
365 typedef enum { SW_SurfCont_DsetView,
366                SW_SurfCont_DsetViewCol,
367                SW_SurfCont_DsetViewCon,
368                SW_SurfCont_DsetViewCaC,
369                SW_SurfCont_DsetViewXXX,  /* do not show, keep it last in list */
370                SW_N_SurfCont_DsetView } SUMA_WIDGET_INDEX_SURFCONT_DSETVIEW;
371 
372 typedef enum { SW_SurfCont_DsetFont,
373                SW_SurfCont_DsetFont8,
374                SW_SurfCont_DsetFont9,
375                SW_SurfCont_DsetFontTR10,
376                SW_SurfCont_DsetFontHE10,
377                SW_SurfCont_DsetFontHE12,
378                SW_SurfCont_DsetFontHE18,
379                SW_SurfCont_DsetFontTR24,
380                SW_SurfCont_DsetFontXXX, /* do not show, keep it last in list */
381                SW_N_SurfCont_DsetFont } SUMA_WIDGET_INDEX_SURFCONT_DSETFONT;
382 
383 typedef enum { SW_SurfCont_DsetNodeCol,
384                SW_SurfCont_DsetNodeColWhite,
385                SW_SurfCont_DsetNodeColBlack,
386                SW_SurfCont_DsetNodeColRed,
387                SW_SurfCont_DsetNodeColGreen,
388                SW_SurfCont_DsetNodeColBlue,
389                SW_SurfCont_DsetNodeColYellow,
390                SW_SurfCont_DsetNodeColGray50,
391                SW_SurfCont_DsetNodeColVal,/* colorize based on data value */
392                SW_SurfCont_DsetNodeColGrp,/*  based on group membership */
393                SW_N_SurfCont_DsetNodeCol }
394                                           SUMA_WIDGET_INDEX_SURFCONT_DSETNODECOL;
395 
396 typedef enum { SW_SurfCont_DsetTxtShad,
397                SW_SurfCont_DsetTxtShad1,
398                SW_SurfCont_DsetTxtShad2,
399                SW_SurfCont_DsetTxtShad3,
400                SW_SurfCont_DsetTxtShad4,
401                SW_SurfCont_DsetTxtShad5,
402                SW_SurfCont_DsetTxtShad6,
403                SW_N_SurfCont_DsetTxtShad }
404                                           SUMA_WIDGET_INDEX_SURFCONT_DSETTXTSHAD;
405 
406 typedef enum { SW_SurfCont_DsetGmatBord,
407                SW_SurfCont_DsetGmatBord0,
408                SW_SurfCont_DsetGmatBord5,
409                SW_SurfCont_DsetGmatBord10,
410                SW_SurfCont_DsetGmatBord20,
411                SW_SurfCont_DsetGmatBord40,
412                SW_N_SurfCont_DsetGmatBord }
413                                          SUMA_WIDGET_INDEX_SURFCONT_DSETGMATBORD;
414 typedef enum { SW_SurfCont_DsetNodeRad,
415                SW_SurfCont_DsetNodeRadConst,
416                SW_SurfCont_DsetNodeRadVal,
417                SW_SurfCont_DsetNodeRadXXX,
418                SW_N_SurfCont_DsetNodeRad }
419                                           SUMA_WIDGET_INDEX_SURFCONT_DSETNODERAD;
420 
421 typedef enum { SW_SurfCont_DsetThrough,
422                SW_SurfCont_DsetThroughEdge,
423                SW_SurfCont_DsetThroughCol,
424                SW_SurfCont_DsetThroughRad,
425                SW_SurfCont_DsetThroughCaR,
426                SW_SurfCont_DsetThroughXXX,
427                SW_N_SurfCont_DsetThrough }
428                                           SUMA_WIDGET_INDEX_SURFCONT_DSETTHROUGH;
429 
430 typedef enum { SW_SurfCont_DsetEdgeThick,
431                SW_SurfCont_DsetEdgeThickConst,
432                SW_SurfCont_DsetEdgeThickVal,
433                SW_N_SurfCont_DsetEdgeThick }
434                                        SUMA_WIDGET_INDEX_SURFCONT_DSETEDGETHICK;
435 
436 typedef enum { SW_SurfCont_DsetEdgeStip,
437                SW_SurfCont_DsetEdgeStipXXX,
438                SW_SurfCont_DsetEdgeStipVal,
439                SW_SurfCont_DsetEdgeStip1,
440                SW_SurfCont_DsetEdgeStip2,
441                SW_SurfCont_DsetEdgeStip3,
442                SW_SurfCont_DsetEdgeStip4,
443                SW_SurfCont_DsetEdgeStip5,
444                SW_SurfCont_DsetEdgeStip6,
445                SW_SurfCont_DsetEdgeStip7,
446                SW_SurfCont_DsetEdgeStip8,
447                SW_SurfCont_DsetEdgeStip9,
448                SW_SurfCont_DsetEdgeStip10,
449                SW_SurfCont_DsetEdgeStip11,
450                SW_SurfCont_DsetEdgeStip12,
451                SW_SurfCont_DsetEdgeStip13,
452                SW_SurfCont_DsetEdgeStip14,
453                SW_SurfCont_DsetEdgeStip15,
454                SW_N_SurfCont_DsetEdgeStip }
455                                        SUMA_WIDGET_INDEX_SURFCONT_DSETEDGESTIP;
456 typedef enum { SW_SurfCont_TractStyle,
457                SW_SurfCont_TractStyleSOLID,
458                SW_SurfCont_TractStyleHIDE,
459                SW_SurfCont_TractStyleST1,
460                SW_SurfCont_TractStyleST2,
461                SW_SurfCont_TractStyleST3,
462                SW_SurfCont_TractStyleST4,
463                SW_SurfCont_TractStyleST5,
464                SW_SurfCont_TractStyleST6,
465                SW_SurfCont_TractStyleST7,
466                SW_SurfCont_TractStyleST8,
467                SW_SurfCont_TractStyleST9,
468                SW_SurfCont_TractStyleST10,
469                SW_SurfCont_TractStyleST11,
470                SW_SurfCont_TractStyleST12,
471                SW_SurfCont_TractStyleST13,
472                SW_SurfCont_TractStyleST14,
473                SW_SurfCont_TractStyleST15,
474                SW_N_SurfCont_TractStyle }
475                                        SUMA_WIDGET_INDEX_SURFCONT_TRACTSTYLE;
476 typedef enum { SW_SurfCont_DsetAlphaVal,
477                SW_SurfCont_DsetAlphaVal_Max,
478                SW_SurfCont_DsetAlphaVal_Avg,
479                SW_SurfCont_DsetAlphaVal_Min,
480                SW_SurfCont_DsetAlphaVal_I,
481                SW_SurfCont_DsetAlphaVal_T,
482                SW_SurfCont_DsetAlphaVal_B,
483                SW_SurfCont_DsetAlphaVal_XXX,
484                SW_N_SurfCont_DsetAlphaVal }
485                                        SUMA_WIDGET_INDEX_SURFCONT_DSETALPHAVAL;
486 
487 typedef enum { SW_SurfCont_TractMask,
488                SW_SurfCont_TractMaskHide,
489                SW_SurfCont_TractMaskGray,
490                SW_SurfCont_TractMaskDim,
491                SW_SurfCont_TractMaskHair,
492                SW_SurfCont_TractMaskIgnore,
493                SW_N_SurfCont_TractMask }
494                                        SUMA_WIDGET_INDEX_SURFCONT_TRACT_MASK;
495 
496 typedef enum { SW_DrawROI_SaveMode,
497                SW_DrawROI_SaveMode1D, SW_DrawROI_SaveModeNIML,
498                SW_N_DrawROI_SaveMode } SUMA_WIDGET_INDEX_DRAWROI_SAVEMODE;
499                            /*!< Indices to widgets in DrawROI under SavingMode */
500 typedef enum { SW_DrawROI_SaveWhat,
501                SW_DrawROI_SaveWhatThis, SW_DrawROI_SaveWhatRelated,
502                SW_N_DrawROI_SaveWhat } SUMA_WIDGET_INDEX_DRAWROI_SAVEWHAT; /*!< Indices to widgets in DrawROI under SavingWhat */
503 
504 typedef enum { SW_DrawROI_WhatDist,
505                SW_DrawROI_WhatDistNothing, SW_DrawROI_WhatDistTrace, SW_DrawROI_WhatDistAll,
506                SW_N_DrawROI_WhatDist } SUMA_WIDGET_INDEX_DRAWROI_WHATDIST; /*!< Indices to widgets in DrawROI under
507                                                                            WhatDist */
508 typedef enum { SUMA_NO_ORDER, SUMA_ROW_MAJOR, SUMA_COLUMN_MAJOR }  SUMA_INDEXING_ORDER;
509 
510 typedef enum { SW_CoordBias,
511                SW_CoordBias_None,
512                SW_CoordBias_X, SW_CoordBias_Y, SW_CoordBias_Z,
513                SW_CoordBias_N,
514                SW_N_CoordBias } SUMA_WIDGET_INDEX_COORDBIAS;
515 
516 typedef enum { SW_LinkMode,
517                SW_LinkMode_None,
518                SW_LinkMode_Pls1,
519                SW_LinkMode_Same,
520                SW_LinkMode_Stat,
521                SW_N_LinkMode } SUMA_WIDGET_LINK_MODE;
522 
523 typedef enum { SW_CmapMode,
524                   SW_Direct, SW_NN, SW_Interp,
525                   SW_N_CmapMode }
526                SUMA_WIDGET_CMAP_MODE;  /*keep parallel with enum of SUMA_COLORMAP_INTERP_MODE */
527 
528 typedef enum { SUMA_NO_CLIP_PLANE_TYPE, SUMA_SCREEN_CLIP, SUMA_ALL_OBJECT_CLIP} SUMA_CLIP_PLANE_TYPES;
529 
530 typedef enum {
531    SUMA_RDC_ERROR = -1,
532    SUMA_RDC_NOT_SET = 0,
533    SUMA_RDC_X_START, /*!< flag, Beginning of X reasons */
534    SUMA_RDC_X_EXPOSE,
535    SUMA_RDC_X_RESIZE,
536    SUMA_RDC_X_MAPSTATE,
537    SUMA_RDC_X_ENTER_WINDOW,
538    SUMA_RDC_X_END, /*!< flag, End of X reasons */
539    SUMA_RDC_NEW_CROSSHAIR,
540    SUMA_RDC_NEW_DATA,
541    SUMA_RDC_NEW_SHUTUP_AND_RECORD,
542 } SUMA_REDISPLAY_CAUSE; /*!< reasons for requesting a redisplay */
543 
544 typedef struct {
545    int *i;  /*!< node index */
546    float *r; /*!< node red */
547    float *g; /*!< node green */
548    float *b;/*!< node blue */
549    int N; /*!< number of elements */
550 }SUMA_IRGB; /*!< structure containing node colors */
551 
552 
553 typedef struct {
554    SUMA_OVERLAY_PLANE_TYPE Type; /*!< This variable determines the types
555                                       of the variables below */
556    SUMA_ENGINE_SOURCE Source; /*!< provenance of plane */
557    SUMA_DATUM_LEVEL dtlvl; /* What does node refer to? Data can be passed
558                               at multiple levels */
559    void *i; /*!< Node index */
560    void *r; /*!< Node red */
561    void *g; /*!< Node green */
562    void *b; /*!< Node blue */
563    void *a; /*!< Node alpha */
564    int N; /*!< number of elements in each vector above */
565    float DimFact; /*!< global factor applied to each color */
566    SUMA_Boolean Show; /*!< show plane ?*/
567    float GlobalOpacity; /*!< Global opacity factor */
568    SUMA_Boolean isBackGrnd; /*!< Brightness modulation */
569 }  SUMA_OVERLAY_PLANE_DATA; /*!< This is a conveninence structure
570                            meant to carry data required to fill a color plane.
571                                  \sa SUMA_OVERLAYS*/
572 
573 typedef enum { SUMA_CMAP_ERROR=-1, SUMA_CMAP_UNDEFINED,
574                            /* Begin adding colormaps next: */
575                SUMA_CMAP_RGYBR20,  SUMA_CMAP_nGRAY20,
576                SUMA_CMAP_GRAY02, SUMA_CMAP_flpGRAY02,
577                SUMA_CMAP_GRAY20, SUMA_CMAP_BW20, SUMA_CMAP_BGYR19,
578                SUMA_CMAP_MATLAB_DEF_BYR64, SUMA_CMAP_BGYR64,
579                SUMA_CMAP_ROI64, SUMA_CMAP_ROI128,
580                SUMA_CMAP_ROI256,
581                SUMA_CMAP_N_MAPS /* Don't add after this one */
582                } SUMA_STANDARD_CMAP; /*!< Names of standard colormaps.
583                   RGYBR20 reads Red, Green, Yellow, Blue, Red, 20 colors total */
584 
585 typedef enum { SUMA_ROI_InCreation, SUMA_ROI_Finished,
586                SUMA_ROI_InEdit} SUMA_ROI_DRAWING_STATUS;
587 
588 typedef enum { SUMA_ROI_OpenPath,   /*!< Topologically connected nodes*/
589                SUMA_ROI_ClosedPath, /*!< A closed OpenPath */
590                SUMA_ROI_FilledArea, /*!< A filled ClosePath */
591                                     /* Preserve the order of the above three */
592                SUMA_ROI_Collection  /*!< A collection of nodes */
593             } SUMA_ROI_DRAWING_TYPE;  /*!< an ROI created by drawing
594                                           (or other means)*/
595 
596 typedef enum { SUMA_BSA_Undefined, SUMA_BSA_AppendStroke, SUMA_BSA_AppendStrokeOrFill, SUMA_BSA_JoinEnds, SUMA_BSA_FillArea } SUMA_BRUSH_STROKE_ACTION;
597 
598 typedef enum { SUMA_ROI_Undefined,
599                SUMA_ROI_NodeGroup, /*!< A collection of nodes */
600                SUMA_ROI_EdgeGroup, /*!< A collection of edges */
601                SUMA_ROI_FaceGroup, /*!< A collection of Faces */
602                SUMA_ROI_NodeSegment /*!< A series of connected nodes */
603              } SUMA_ROI_TYPE; /* a generic types of ROI datums*/
604 
605 typedef enum { SXR_default, SXR_Euro, SXR_Afni , SXR_Bonaire, SXR_Print } SUMA_XRESOURCES;   /* flags for different X resources */
606 
607 typedef enum { SRM_ViewerDefault, SRM_Fill, SRM_Line, SRM_Points , SRM_Hide,
608                SRM_N_RenderModes} SUMA_RENDER_MODES; /*!< flags for various
609                                                             rendering modes */
610 
611 typedef enum { STM_ViewerDefault,
612                STM_0, STM_1, STM_2,STM_3,STM_4,STM_5,
613                STM_6, STM_7, STM_8, STM_9, STM_10, STM_11, STM_12, STM_13,
614                STM_14, STM_15, STM_16, STM_N_TransModes} SUMA_TRANS_MODES;
615                                  /*!< flags for various transparency values */
616 
617 typedef enum { SATM_ViewerDefault, SATM_ALPHA,
618                SATM_0, SATM_1, SATM_2,SATM_3,SATM_4,SATM_5,
619                SATM_6, SATM_7, SATM_8, SATM_9, SATM_10, SATM_11, SATM_12,
620                SATM_13, SATM_14, SATM_15, SATM_16,
621                                        SATM_N_TransModes} SUMA_ATRANS_MODES;
622                                  /*!< flags for various transparency values,
623                                     including Alpha mode */
624 
625 
626 typedef enum {
627                SDODM_Error=-1,
628                SDODM_All,
629                SDODM_n3CrossHair,
630                SDODM_n2CrossHair, SDODM_n1CrossHair, SDODM_n0CrossHair,
631                SDODM_Hide,
632                SDODM_N_DO_DrawMasks}  SUMA_DO_DRAW_MASK;
633 
634    /*!< number of useful views enumerated in SUMA_STANDARD_VIEWS */
635 typedef enum {    SUMA_2D_Z0, SUMA_2D_Z0L,
636                   SUMA_3D, SUMA_3D_Z0,
637                   SUMA_N_STANDARD_VIEWS } SUMA_STANDARD_VIEWS;
638                      /*!< Standard viewing modes. These are used to decide what
639                      viewing parameters to carry on when switching states
640                      SUMA_2D_Z0 2D views, with Z = 0 good for flat surfaces
641                      SUMA_2D_Z0L 2D views, with Z = 0
642                                           good for left hemi flat surfaces
643                      SUMA_3D standard 3D view
644                      SUMA_3D_Z0 straight down the Z, good for balls
645                      SUMA_N_STANDARD_VIEWS used to flag errors leave  at the end
646                      */
647 typedef enum {   SUMA_No_Lock, SUMA_I_Lock, SUMA_XYZ_Lock, SUMA_N_Lock_Types}  SUMA_LINK_TYPES; /*!< types of viewer linking. Keep SUMA_N_Lock_Types at the end, it is used to keep track of the number of types*/
648 
649 typedef enum {  SWP_DONT_CARE,
650                 SWP_TOP_RIGHT, /*!< Position to the top right of reference */
651                 SWP_BOTTOM_RIGHT_CORNER,
652                 SWP_STEP_DOWN_RIGHT,
653                 SWP_TOP_LEFT,
654                 SWP_POINTER, /*!< Position centered to the pointer */
655                 SWP_POINTER_OFF,
656                 SWP_POINTER_LEFT_BOTTOM,
657                 SWP_TOP_BEST /*!< Top right, else top left with no overlap */
658              } SUMA_WINDOW_POSITION; /*!< Types of relative window positions */
659 
660 typedef enum {    SAR_Undefined,
661                   SAR_Fail, /*!< Failed action */
662                   SAR_Succeed,
663                }  SUMA_ACTION_RESULT;
664 
665 typedef enum { SAP_Do,
666                SAP_Undo,
667                SAP_Redo,
668             } SUMA_ACTION_POLARITY;
669 
670 typedef enum { SUMA_NO_BLEND=0, SUMA_BLEND1, SUMA_BLEND2, SUMA_N_BLEND_MODES} SUMA_BLEND_MODES;
671 
672 typedef enum {
673    SUMA_ROI_FILL_TO_ALLROI, /*!< Fill until you encounter a node part of any ROI */
674    SUMA_ROI_FILL_TO_THISROI, /*!< Fill until you encounter a node part of this ROI */
675 }SUMA_ROI_FILL_MODES;
676 
677 typedef struct {
678    SUMA_ACTION_RESULT (*ActionFunction)(void *ActionData, SUMA_ACTION_POLARITY Pol); /*!< The function to call for performing the action */
679    void *ActionData; /*!< The data to be passed to the function performing the action */
680    void (*ActionDataDestructor)(void *Actiondata); /*!< The function to call that destroys ActionData */
681 } SUMA_ACTION_STACK_DATA; /*!< a structure containing the data to form the element of the Action Stack element*/
682 
683 /*! structure to keep track of allocate memory */
684 typedef struct {
685    void **Pointers; /*!< vector of pointers for which memory was allocated */
686    int *Size; /*!< vector of sizes of allocated memory blocks. Pointers[i] has Size[i] bytes allocated for it */
687    int N_alloc; /*!< number of meaningful entries in Pointers and Size */
688    int N_MaxPointers; /*!< Maximum number of elements allocated for in Pointers and Size */
689 } SUMA_MEMTRACE_STRUCT;
690 
691 /*! structure containing a data block information */
692 typedef struct {
693    void *data;   /*!< pointer to data location */
694    int N_link; /*!< number of links to data location */
695    char ParentIDcode[SUMA_IDCODE_LENGTH]; /* IDcode of the creator of data */
696 } SUMA_INODE;
697 
698 
699 /*! structure containing an ROI Plane's infor */
700 typedef struct {
701    char *name; /*!< name of plane and the indices of the ROIs that belong to it */
702    DList *ROI_index_lst;   /*!< list of indices (into SUMA_DO * SUMAg_DOv) of
703                                SUMA_DRAWN_ROI * objects that belong to a certain
704                                plane. That sounds confusing now, I'm sure it'll
705                                sound clear a year from now */
706 } SUMA_ROI_PLANE;
707 
708 typedef enum { SUMA_UNDEFINED_MODE,
709                SUMA_DIRECT, /*!< no interpolation on the colormap, node value is
710                                  typecast to int and directly used
711                                  to access color map */
712                SUMA_NO_INTERP,   /*!< no interpolation on the colormap
713                                      (like in afni with paned colormaps) but
714                                      ranging is applied */
715                SUMA_INTERP       /*!< interpolation on the colormap,
716                                       SUMA's default */
717             } SUMA_COLORMAP_INTERP_MODE; /* keep parallel with enums of
718                                             SUMA_WIDGET_CMAP_MODE */
719 
720 typedef enum {
721                SUMA_NOT_SET=-1,
722                SUMA_NO_THRESH,
723                SUMA_LESS_THAN,   /*!< Mask if T[i] < Opt->ThreshRange[0] */
724                SUMA_ABS_LESS_THAN, /*!< Mask if T[i] < Opt->ThreshRange[0] ||
725                                         T[i] > -Opt->ThreshRange[0] */
726                SUMA_THRESH_OUTSIDE_RANGE, /*!< Mask if T[i] < Opt->ThreshRange[0]
727                                                  || T[i] > Opt->ThreshRange[1] */
728                SUMA_THRESH_INSIDE_RANGE, /*!< Mask if T[i] >= Opt->ThreshRange[0]
729                                               && T[i] <= Opt->ThreshRange[1] */
730             }  SUMA_THRESH_MODE;
731 /*! a structure holding the options for the function SUMA_ScaleToMap
732 \sa SUMA_ScaleToMapOptInit to allocate and initialize such a structure
733 to free this structure use the free function
734 */
735 
736 typedef enum {
737    SUMA_BAD_MODE=-1,
738    SUMA_ORIG_MIX_MODE,  /*!< The original mode for color overlaying:
739                      if (Col1) Col = (1-opacity) Col1 + opacity Col2 */
740    SUMA_4AML,  /*!< A modified mixing mode to keep colors from getting dimmed
741                   (as with opacity of 0.5 on Col1 = 0.3 0 0 and Col2 = 0 0.3 0)
742                   resultant is a very dim yellow 0.15 0.15 0
743                   Named after the eminent A. M. L.*/
744    SUMA_MAX_MODES /*!< The limit, used for cycling */
745 } SUMA_COL_MIX_MODE;
746 
747 /*! structure containing the color mapping of a vector */
748 typedef struct {
749    /* float **cM; Prior to Mar 17 03*/
750             /*!< N_Node x 3 matrix containing the colors at each node*/
751    float *BiasCoordVec; /*!< A vector of coordinate bias */
752    float *cV; /*!< N_Node x 3 vector containing the colors at each node*/
753    int N_Node; /*!< obvious */
754    SUMA_Boolean *isMasked; /*!< if isMasked[i] then node i has a mask color
755                                 associated with it */
756    int N_VCont; /* Number of nodes not masked */
757    int *VCont; /* An N_VCont x 1 vector to hold a flag value to label this node*/
758 } SUMA_COLOR_SCALED_VECT;
759 
760 
761 
762 
763 /*! TRY TO MAKE DO WITHOUT THIS THING, IF POSSIBLE.
764 It is a pain to work with two types of ROI structues
765 structure to hold an ROI */
766 typedef struct {
767    SUMA_ROI_TYPE Type;   /*!< The type of ROI */
768 
769    char *idcode_str;    /*!< unique idcode for ROI */
770    char *Parent_idcode_str; /*!< idcode of parent surface */
771    char *Label; /*!< ascii label for ROI */
772 
773    int *ElInd; /*!< Pointer to vector containing indices into the parent
774                      surface (SO has Parent_idcode_str) of ROI elements.
775                     If Type is SUMA_ROI_NodeGroup then ElementIndex contains
776                      indices to SO->NodeList .
777                     If Type is SUMA_ROI_FaceGroup then ElementIndex contains
778                      indices to SO->FaceList.
779                     If Type is SUMA_ROI_EdgeGroup then ElementIndex contains
780                      indices to SO->EL->EL. */
781    int N_ElInd; /*!< Number of elements in ElementIndex */
782 } SUMA_ROI;
783 
784 
785 
786 typedef struct {
787    SUMA_ROI_TYPE Type; /*!< Type of ROI in datum */
788    int N_n; /*!< Number of elements in nPath */
789    int N_t; /*!< Number of elements in tPath */
790    int *nPath; /*!< Vector of N node indices. These nodes must be immediate
791                      (linked) neighbours of each other */
792    int *tPath; /*!< Vector of N triangle indices. These triangles must
793                      be connected to each other */
794    float tDistance; /*!< distance from the first node to the last
795                         taken along the surface (geodesic)*/
796    float nDistance; /*!< distance from the first node to the last by summing the
797                          length of segments between nodes */
798    SUMA_BRUSH_STROKE_ACTION action; /*!< a record of the action that went with
799             this datum.
800             This field is used to recreate the ROI drawing history from a saved
801             niml file */
802 } SUMA_ROI_DATUM; /*!< elementary datum of a drawn ROI */
803 
804 
805 #define SUMA_MAX_ROI_CTRL_NODES 100 /*!< Maximum number of control nodes in an ROI */
806 #define SUMA_MAX_ROI_CTRL_NODES3 300
807 #define SUMA_MAX_ROI_ON_SURFACE 100 /*!< Maximum number of ROIs Drawn on a surface */
808 
809 typedef struct {
810    int n1;  /*!<index of edge's first node */
811    int n2; /*!<index of edge's second node */
812 } SUMA_CONTOUR_EDGES; /*<! structure defining an edge by the nodes forming it*/
813 
814 /*! structure to hold the drawing of an ROI */
815 typedef struct {
816       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
817    SUMA_DO_Types do_type;
818    char *idcode_str;    /*!< unique idcode for ROI */
819    char *Label; /*!< ascii label for ROI */
820 
821       /* Begin specific fields */
822    SUMA_ROI_DRAWING_TYPE Type;   /*!< The type of ROI drawn,
823                               that would be closed path, etc, etc, */
824 
825    char *Parent_idcode_str; /*!< idcode of parent surface */
826    SUMA_SO_SIDE Parent_side; /*!< Hemisphere of parent.
827                   Comes in handy when trying to find parent if
828                   Parent_idcode_str does not work */
829    char *ColPlaneName;  /*!< Name of color plane that the ROI is painted in.
830                      If this field is set to NULL then the ROI will be painted
831                      in the generic ROI_Plane plane.
832                      For the moment, NULL is the only
833                      option */
834    float FillColor[4];  /*!< RGB fill color */
835    float EdgeColor[4];  /*!< RGB edge color */
836    int EdgeThickness;   /*!< thickness of edge */
837    int iLabel; /*!< An integer value, another way to represent a Label */
838    SUMA_Boolean ColorByLabel; /*!< flag indicating that ROI node colors should
839                                    be based on the value in iLabel and not the
840                                    one specified in FillColor */
841    SUMA_ROI_DRAWING_STATUS DrawStatus; /*!< Status of the ROI being drawn,
842                                  finished, being drawn, being edited, etc. */
843 
844    DList *ROIstrokelist;   /*!< a doubly linked list with the data element
845                                  being a (void *)SUMA_ROI_DATUM * */
846 
847    DList *ActionStack; /*!< a stack containing the various actions performed*/
848    DListElmt *StackPos; /*!< The element of ActionStack that represents
849                              the current position */
850 
851    int N_CE; /*!< number of contour edges */
852    SUMA_CONTOUR_EDGES *CE; /*!< a vector of edges that form the contour
853                                 of the ROI */
854 } SUMA_DRAWN_ROI;
855 
856 typedef struct {
857    int Type;         /*!< The final type of the DrawnROI,
858                            see SUMA_ROI_DRAWING_TYPE*/
859    char *idcode_str;
860    char *Parent_idcode_str;
861    SUMA_SO_SIDE Parent_side;
862    char *Label;
863    int *iNode; /*!< A node's index */
864    int *iLabel; /*!< A node's value */
865    int N; /*!< NUmber of elements in iNode and iLabel */
866 } SUMA_1D_DRAWN_ROI; /*!< a version of SUMA_DRAWN_ROI struct that can
867                      be used by 1D functions.
868                      Fields are a reflection of those in SUMA_DRAWN_ROI*/
869 
870 typedef struct {
871    SUMA_ROI_DATUM *ROId;
872    SUMA_DRAWN_ROI *DrawnROI;
873 } SUMA_ROI_ACTION_STRUCT;  /*!< a structure packaging data for the
874                                  routines acting on drawn ROIs */
875 
876 typedef enum { SUMA_SORT_CLUST_NOT_SET, SUMA_SORT_CLUST_NO_SORT, SUMA_SORT_CLUST_BY_NUMBER_NODES, SUMA_SORT_CLUST_BY_AREA } SUMA_SURF_CLUST_SORT_MODES;
877 
878 typedef struct {
879    char *in_name;
880    int nodecol;
881    int labelcol;
882    char *out_prefix;  /* this one's dynamically allocated so you'll have
883                          to free it yourself */
884    float DistLim;
885    float AreaLim;
886    int NodeLim;
887    SUMA_THRESH_MODE DoThreshold;
888    float ThreshR[2];
889    int tind;
890    float update;
891    int DoCentrality;
892    SUMA_Boolean OutROI;
893    SUMA_Boolean OutClustDset;
894    SUMA_Boolean WriteFile;
895    SUMA_SURF_CLUST_SORT_MODES SortMode;
896    SUMA_Boolean FullROIList;
897    SUMA_Boolean prepend_node_index;
898    SUMA_DSET_FORMAT oform;
899 
900 } SUMA_SURFCLUST_OPTIONS;
901 
902 
903 
904 typedef struct {
905    SUMA_Boolean ApplyMask; /*!< if YUP then values that fall in MaskRange
906                                  are assigned the color in MaskColor */
907    float MaskRange[2];     /*!< values between MaskRange[0] and
908                                 MaskRange[1] (inclusive) are assigned
909                                 MaskColor */
910    float MaskColor[4];     /*!<   color to assign to masked nodes */
911    SUMA_Boolean ApplyClip; /*!< if YUP then range clipping using Range
912                                  is applied */
913 
914    /* fields used in the _Interactive scale to map mode */
915    float BrightFact; /*!< a brightness factor to apply to the color map.
916                            This factor is applied to the colors in the
917                            colormap and the mask colors
918                            This overrides DimFact in SUMA_OVERLAYS*/
919    SUMA_Boolean MaskZero; /*!<   values equal to zero will be masked
920                                  no matter what */
921    double ThreshRange[2]; /*!< Thresholding range.  */
922    float ThreshStats[2]; /*!<  Thresholding statistics,
923                               ThreshStats[0] = p(ThreshRange[0])
924                               ThreshStats[1] = q(ThreshRange[0]) */
925    SUMA_NUMERICAL_UNITS RangeUnits;
926    double IntRange[2]; /*!< nodes with values <= Range[0] are
927                            given the first color in the color map,
928                            values >= Range[1] get the last color in the map
929                             (USED to be called ClipRange*/
930    double BrightRange[2]; /*!< Same as IntRange but for brightness
931                               modulating column */
932    float BrightMap[2]; /*!<   BrightRange[0] is mapped to BrightMap[0],
933                               BrightRange[1] is mapped to BrightMap[1] */
934    SUMA_Boolean alaAFNI; /*!< If yes, use ScaleToMap_alaAFNI, if NOPE,
935                               use ScaleToMap */
936    SUMA_COLORMAP_INTERP_MODE interpmode; /*!< see typedef.*/
937    int find;   /*!< index of function sub-brick */
938    int tind;   /*!< index of thresholf sub-brick */
939    int bind;   /*!< index of attenuation sub-brick */
940    SUMA_Boolean UseThr; /*!< use or ignore tind */
941    SUMA_THRESH_MODE ThrMode;  /*!< how to apply the thresholding */
942    SUMA_Boolean UseBrt; /*!< use or ignore bind */
943    SUMA_WIDGET_INDEX_COORDBIAS DoBias;  /*!< use coordinate bias */
944    double CoordBiasRange[2]; /*!< Same as IntRange but for brightness
945                                  modulating column */
946    float *BiasVect; /*!< A vector of values to add to the coordinates
947                          of the mesh */
948    int AutoIntRange;
949    int AutoBrtRange;
950    int ColsContMode; /*!< a flag to indicate what to do about contours */
951 
952    SUMA_SURFCLUST_OPTIONS *ClustOpt; /*!< Clusterizing options */
953    int Clusterize; /*!< If on, do some cluster business */
954    int RecomputeClust; /*!< 1 when clusters should be recomputed at
955                               recolorization */
956 
957 } SUMA_SCALE_TO_MAP_OPT;
958 
959 
960 /*! Structure containing one color overlay */
961 typedef struct {
962    SUMA_DO_Types do_type;  /*!< To check if this is a displayable object */
963    int LinkedPtrType; /*!< Indicates the type of linked pointer */
964    int N_links;   /*!< Number of links to this pointer */
965    char owner_id[SUMA_IDCODE_LENGTH];   /*!< The id of whoever created
966                                     that pointer. */
967 
968    SUMA_DATUM_LEVEL dtlvl; /* What does a 'node' refer to? Data can be passed
969                               at multiple levels */
970 
971    int ShowMode; /*!< negative do not show, postive,
972                   ShowMode can be +/-SW_SurfCont_DsetViewCol
973                   +/-SW_SurfCont_DsetViewCon, and +/-SW_SurfCont_DsetViewC&C
974                   It cannot be +/-SW_SurfCont_DsetViewXXX
975                   see SUMA_WIDGET_INDEX_SURFCONT_DSETVIEW */
976    int Font; /*!< negative do not show, postive,
977                   Font can be +/- most of SUMA_WIDGET_INDEX_SURFCONT_DSETFONT
978                   It cannot be +/-SW_SurfCont_DsetFontXXX
979                   see SUMA_WIDGET_INDEX_SURFCONT_DSETFONT */
980    int NodeRad; /*!< negative do not show, postive,
981                NodeRad can be +/- most of SUMA_WIDGET_INDEX_SURFCONT_DSETNODERAD
982                   It cannot be +/-SW_SurfCont_DsetNodeRadXXX
983                   see SUMA_WIDGET_INDEX_SURFCONT_DSETNODERAD */
984    int Through; /*!< negative do not show, postive,
985                Through can be +/- most of SUMA_WIDGET_INDEX_SURFCONT_DSETTHROUGH
986                   It cannot be +/-SW_SurfCont_DsetThroughXXX
987                   see SUMA_WIDGET_INDEX_SURFCONT_DSETTHROUGH */
988    float NodeRadGain;
989    int NodeCol; /*!< Node colors, either constant or from dset
990                   see SUMA_WIDGET_INDEX_SURFCONT_DSETNODECOL */
991    int BordFrac; /*!< Thinckness of border relative to cell width */
992    int TxtShad; /*!< Text shadowing, see SUMA_WIDGET_INDEX_SURFCONT_DSETTXTSHAD*/
993 
994    int EdgeThick; /* see SUMA_WIDGET_INDEX_SURFCONT_DSETEDGETHICK */
995    float EdgeThickGain;
996    int EdgeStip; /* see SUMA_WIDGET_INDEX_SURFCONT_DSETEDGESTIP,
997                         Also see  SUMA_WIDGET_INDEX_SURFCONT_TRACTSTYLE*/
998    int AlphaVal; /* see SUMA_WIDGET_INDEX_SURFCONT_DSETALPHAVAL */
999    char *Name; /*!<  name of ovelay, CONVEXITY or Functional or areal boundaries
1000                      perhaps. The Name can be a filename with path*/
1001    char *Label; /*!< Usually the same as Name without any existing path */
1002 
1003       /* These can't just come from dset_link because as you change the
1004          threshold, and other parameters, some nodes may not get colored so the
1005          NodeDef list will differ from that in dset.
1006          The macros COLP_NODEDEF, COLP_N_NODEDEF and COLP_N_ALLOC will be
1007          redefined to point to fields inside the overlays structure                           Mon Mar 29 15:11:01 EST 2004*/
1008    int *NodeDef; /*!< nodes over which the colors are defined*/
1009    int N_NodeDef; /*!< total number of nodes specified in NodeDef*/
1010    #if 0
1011       /* That one is still borrowed from dset structure */
1012    int N_Alloc; /*!< You'd think this should be equal to NodeDef, but in
1013                      instances where you may be receiving varying numbers of
1014                      colors to the same plane, it's a pain to have to free and
1015                      realloc space. So, while the juice is only up to N_NodeDef,
1016                      the allocation is for N_Alloc */
1017    #endif
1018    int FullList; /*!< if 1 then it indicates that a full listing of node
1019                      colors exists.
1020                      i.e. nodes need not be defined explicitly, in that case
1021                      NodeDef is still explicitly defined. I have my reasons.*/
1022 
1023    float *ColVec; /*!< N_NodeDef x 3 vector containing colors of nodes
1024                        specified in NodeDef, Replaces ColMat, Wed Mar 17 04*/
1025    byte *ColAlpha; /*!< Color Alpha obtained directly from the colors in ColVec,
1026                         or from the I,T,B. selectors in the data.
1027                         This Alpha is only used for Volume objects at the moment,
1028                         and is different from LocalOpacity in that this Alpha
1029                         does not enter into any of the SUMA controlled mixing
1030                         of color overlay planes. */
1031    int RemixOID;/*!< A number that changes each time ColVec content is changed */
1032 
1033    float *V; /*!< A copy of the dataset's column that produced the colors in
1034                       ColVec. */
1035    int N_V; /*!< Should be the same as SDSET_VECFILLED(Sover->dset_link),
1036                  But it is set when V is created to be safe */
1037    char V_identifier[32+SUMA_IDCODE_LENGTH];
1038    float *Vperc;
1039    int N_Vperc;
1040 
1041    float *T; /*!< A copy of the dataset's column that corresponds to
1042                   the threshold of V */
1043    int N_T; /*!< Should be the same as SDSET_VECFILLED(Sover->dset_link),
1044                  But it is set when V is created to be safe */
1045    char T_identifier[32+SUMA_IDCODE_LENGTH];
1046    float *Tperc;
1047    int N_Tperc;
1048 
1049 
1050    float GlobalOpacity; /*!< Opacity factor between 0 and 1 to apply to
1051                            all values in ColMat */
1052    float *LocalOpacity; /*!< Opacity factor vector between 0 and 1 to apply to
1053                              each individual node color */
1054    int PlaneOrder; /*!< Order of the overlay plane, 1st plane is 0 and is
1055                         farthest away from the top */
1056    SUMA_Boolean isBackGrnd; /*!< if YUP then colors overlaid on top of this plane
1057             have their brightness modulated by the average intensity of the
1058             colors in that plane see the function SUMA_Overlays_2_GLCOLAR4 for
1059             details.
1060             In other obscure words, if YUP then plane is part of background.*/
1061    float DimFact;    /*!< a scaling factor applied to the colors in ColVec
1062                            This is overriden by BrightFact in OptScl which is
1063                            defined for non-explicitly colored planes*/
1064    double ForceIntRange[2]; /*!< Use values here to set OptScl->IntRange instead
1065          of the true range of values in the dataset.
1066          The idea is to allow particular settings for the autoranging
1067          options that are not from the dset's min to max.
1068          Usually, this field is not used and both values are set to 0.0
1069                                  */
1070    /* New additions, Fri Feb 20 13:21:28 EST 2004 */
1071    SUMA_DSET *dset_link; /*!< A COPY OF THE POINTER to the dataset this plane is
1072                               attached to. DO NOT FREE THIS POINTER MANUALLY.
1073                               This is done in the functions for creating and
1074                               destroying
1075                               overlay planes */
1076    char *cmapname; /*!< name of colormap (must be in SUMAg_CF->scm)  */
1077    SUMA_SCALE_TO_MAP_OPT *OptScl;   /* Options for mapping values in
1078                                        dset to colormap */
1079    int SymIrange;
1080 
1081    MEM_topshell_data *rowgraph_mtd;
1082    int rowgraph_num;
1083 
1084    int N_Contours;            /* Number of contours ROIs*/
1085    SUMA_DRAWN_ROI **Contours; /* Using the ROI structure to store contours
1086                                  which can be displayed along with color blobs */
1087    SUMA_WIDGET_LINK_MODE LinkMode;          /* How to link I & T selectors */
1088 
1089    DList *ClustList; /*!< The list of clusters */
1090    byte *ClustOfNode; /*!< Tells which cluster a node belongs to, Should have
1091                            SO->N_Node values in it*/
1092    float AlphaThresh;
1093 } SUMA_OVERLAYS;
1094 
1095 
1096 /*!
1097 Stucture to hold the contents of the specs file
1098 */
1099 typedef struct {
1100    char **SurfaceType;    /*!< Type of surface loaded:
1101                                FreeSurfer, SureFit/Caret, 1D format,
1102                                inventor, Ply */
1103    char **SurfaceFormat;  /*!< ASCII or Binary */
1104    char **TopoFile; /*!< Surface Topology (mesh) file
1105                          renamed from SureFitTopo because 1D uses it too */
1106    char **CoordFile; /*!< Surface Coordinate (XYZ) file
1107                           renamed from SureFitCoord because 1D uses it too  */
1108    char **MappingRef; /*!< Becoming obsolete. Jan 2 03 */
1109    char **SureFitVolParam; /*!<  For SureFit only: Name of file containing
1110                                  anatomical coordinates modification. */
1111    char **SurfaceFile;  /*!< File containing topology and geometry of surface. */
1112    char **VolParName;   /*!< Now known as surface volume in the documentation
1113                              This is the volume from which the surface was
1114                              created, aligned to the experiment's data. Alignment                              transforms added by 3dVolreg or 3dAnatNudge that are                              stored in this volume ar applied to the surface.
1115                              Also, tlrc transforms of this volume can be applied
1116                              to the surface. */
1117    char **IDcode;      /*!< Unique identifier for the surface object */
1118    char **State;       /*!< Geometrical state of the surface. For example:
1119                             pial, white, inflated, spherical, etc... */
1120    char **LabelDset;    /*!< Name of a label dset, like the annotation file */
1121    char **Group;        /*!< Some identifier, best thought of as the name of
1122                              the subject */
1123    char **SurfaceLabel; /*!< A user defined "short" label to use in GUI */
1124    int *EmbedDim;       /*!< 2 for flat surfaces, 3 for 3D dwelling ones. */
1125 
1126    /* modifications to the lame MappingRef field */
1127    char **AnatCorrect;    /*!< Does surface geometry match the anatomy ?*/
1128    char **Hemisphere;     /*!< Left/Right */
1129    char **DomainGrandParentID;   /*!< Grandparent's mesh ID
1130                                     (icosahedron's for std-meshes) */
1131    char **OriginatorID;   /*!<  ID common to surfaces from one subject that are
1132                                  created at one point in time. Surfaces of the
1133                                  same subject, created at different points in
1134                                  time (like in a longitudinal study) will have
1135                                  differing OriginatorID fields */
1136    char **LocalCurvatureParent;   /*!<  Name of surface (in current spec file)
1137                       from which the curvature will be borrowed.
1138                       The LocalCurvatureParent must be isotopic to
1139                       the child surface. This Parent used to be
1140                       the MappingRef field*/
1141    char **LocalDomainParent;       /*!< Name of surface (in current spec file)
1142                        from which EdgeLists and other shared information                                 will be borrowed. This field used to be
1143                        the MappingRef field. Naturally, Parent and
1144                        Child must be isotopic.
1145                        You must have at least one of the surfaces loaded
1146                        into SUMA be the Parent. Use SAME for this field when
1147                        a surface is a LocalDomainParent.
1148                       */
1149    char **NodeMarker;  /*!< File containing node marker DO */
1150 
1151    int N_Surfs;         /*!< Number of surfaces, in the spec file */
1152    int N_States;
1153    int N_Groups;
1154 
1155    int N_DO;
1156    int *DO_type;
1157    char **DO_name;
1158 
1159    char *StateList;
1160    char *SpecFilePath;
1161    char *SpecFileName;
1162 } SUMA_SurfSpecFile;
1163 
1164 /*! structure that containing node's first order neighbors */
1165 typedef struct {
1166    SUMA_DO_Types do_type;  /*!< To check if this is a displayable object */
1167    int LinkedPtrType; /*!< Indicates the type of linked pointer */
1168    int N_links;   /*!< Number of links to this pointer */
1169    char owner_id[SUMA_IDCODE_LENGTH];   /*!< The id of whoever created that
1170                                        pointer. Might never get used.... */
1171 
1172 
1173    char *idcode_str; /*!< identifier of element containing node's first
1174                            order neighbors */
1175    int N_Node; /*!< Number of nodes whose neighbors are listed in this
1176                     structure */
1177    int *NodeId; /*!< Id of each node whose neighbors are listed in this structure
1178             *** WARNING: *** A lot of functions do not use this field and assume
1179             N_Node = number of nodes in the surface! */
1180    int **FirstNeighb; /*!< N_Node x N_Neighb_max matrix with each row specifying
1181                         the indices of neighboring nodes.
1182                        After Tue Jan  7 18:13:44 EST 2003: The nodes are now
1183                        ordered to form a path on the surface.
1184                    Note: There is no guarantee that the path is closed. */
1185    int *N_Neighb; /*!< maximum number of neighbors for a particular node */
1186    int N_Neighb_max; /*!< maximum number of neighbors of all nodes */
1187 } SUMA_NODE_FIRST_NEIGHB;
1188 
1189 /*! structure that contains faceset's first order neighbors */
1190 typedef struct {
1191    int N_FaceSet; /*!< Number of nodes whos neighbors are listed in
1192                        this structure */
1193    int **FirstNeighb; /*!< N_Node x N_Neighb_max matrix with each row
1194                         specifying the indices of neighboring facesets */
1195    int *N_Neighb; /*!< maximum number of neighbors for a particular faceset */
1196    int N_Neighb_max; /*!< maximum number of neighbors of all facesets */
1197    int N_Neighb_min; /*!< minimum number of neighbors of all facesets */
1198 } SUMA_FACESET_FIRST_EDGE_NEIGHB;
1199 
1200 /*!
1201    structure containing surface curvature parameters
1202 */
1203 typedef struct {
1204    int N_Node; /*!< Number of nodes in the surface */
1205    float **T1; /*!< N_Node x 3 matrix with each row specifying the
1206                      1st principal direction of the surface */
1207    float **T2; /*!< N_Node x 3 matrix with each row specifying the
1208                      2nd principal direction of the surface */
1209    float *Kp1; /*!< N_Node x 1 vector with each row specifying the
1210                      curvature along the 1st principal direction */
1211    float *Kp2; /*!< N_Node x 1 vector with each row specifying the
1212                      curvature along the 2nd principal direction */
1213    int N_SkipNode; /*!< number of nodes for which the curvature could
1214                         not be computed */
1215 } SUMA_SURFACE_CURVATURE;
1216 
1217 
1218 /*!
1219    structure containing the edges that make up a triangular faceset list
1220 
1221 */
1222 typedef struct {
1223    SUMA_DO_Types do_type;  /*!< To check if this is a displayable object */
1224    int LinkedPtrType; /*!< Indicates the type of linked pointer */
1225    int N_links;   /*!< Number of links to this pointer */
1226    char owner_id[SUMA_IDCODE_LENGTH];   /*!< The id of whoever created
1227                                  that pointer. Might never get used.... */
1228 
1229 
1230    char *idcode_str; /*!< ID of this particular edge list */
1231    int ** EL; /*!< pointer to where the Edge List ( N_EL x 2 ) will be placed
1232                         each row is an edge, i1 i2 where i1 is always <= i2
1233                         EL is sorted by row */
1234    int ** ELps; /*!< pointer to where the Edge List Property matrix
1235                      ( N_EL x 3 )will be placed
1236                   1st column, row i = 1 means edge i: i1,i2 was encountered as
1237                      i2->i1 in the triangle J (so it was flipped when stored in
1238                       EL) = -1 means edge i: i1,i2 was encountered as i1->i2 in
1239                       the triangle J (so no flipping was done to store it in EL)
1240                   2nd column, row i = J is the triangle ( FL[J] ) that the
1241                         segment belongs to.
1242                   3rd column, row i = Numer of triangles that contain this edge.
1243                      This number is positive for the first occurence
1244                      of the edge in EL, it is -1 afterwards. A decent edge has 2
1245                      hosting triangles, an edge edge
1246                      has 1 hosting triangle. Bad edges come in all other colors*/
1247 
1248    int *ELloc; /*!< N_ELloc x 1 vector that stores where each node's
1249                      listing begins.
1250                      ELloc is used to quickly find a certain edge in EL
1251                      to find the edge formed by nodes na-nb
1252                      find the minimum of na and nb (say it's nb)
1253                      the first reference of an edge containing nb
1254                      starts at EL(ELloc(nb),:)
1255                      NOTE: ELloc contains an entry for each node in
1256                       FaceSetList, except the
1257                      largest node index since that's never in the
1258                      first column of EL */
1259    int N_ELloc; /*! Contains the number of values in ELloc */
1260 
1261    int N_EL; /*!< Number of segments = 3 * N_Facesets */
1262    int N_Distinct_Edges; /*! Number of distinct edges
1263                               (no multiple counts as in N_EL) */
1264    int max_N_Hosts; /*!< Maximum number of triangle hosts any one edge has
1265                         (max ( ELps(:,2) != -1 ) )*/
1266    int  min_N_Hosts; /*!< Minimum version of max_N_Hosts */
1267 
1268    int **Tri_limb; /*!< each row j of Tri_limb contains the indices into EL
1269                         (and ELps) of the edges that make it up */
1270    float *Le; /*!< Vector N_EL elements long containing
1271                   the length of each edge in EL */
1272    float AvgLe; /*!< Average of Le (internodal distance).
1273                      This is an approximate average lenght,
1274                      since some edges may counted more than others  */
1275 } SUMA_EDGE_LIST;
1276 
1277 /*! structure that contains array pointers from function SUMA_isinbox */
1278 #define SUMA_isinbox_struct
1279 typedef struct {
1280    int *IsIn; /*!< Indices of nodes inside the box */
1281    int nIsIn; /*!< Number of nodes inside the box */
1282    float *d; /*!< Distance of each node to the center of the box */
1283    float **dXYZ; /*!< Not implemented */
1284 } SUMA_ISINBOX;
1285 
1286 /*! structure that contains array pointers from function isinsphere */
1287 #define SUMA_isinsphere_struct
1288 typedef struct {
1289    int *IsIn;  /*!< Indices of nodes inside the sphere */
1290    int nIsIn; /*!< Number of nodes inside the sphere */
1291    float *d;  /*!< Not implemented Distance of each node to the center
1292                    of the shpere */
1293    float **dXYZ; /*!< Not implemented */
1294 } SUMA_ISINSPHERE;
1295 
1296 typedef struct {  /* Any changes in this structure must be mirrored
1297                      in other DO structures. As a general rule,
1298                      don't mess with the order, append to the
1299                      bottom.
1300                      Fields prepended with private_ should not be
1301                      accessed outside of the accessor functions even
1302                      if they have the same offsets as their mirrors in
1303                      other DOs.
1304                      */
1305    SUMA_DO_Types do_type;  /* This should always remain on top.
1306                               Sync with SUMA_DSET struct */
1307    char *private_idcode_str; /* DO NOT ACCESS THIS POINTER directly from
1308                         any SUMA_ALL_DO pointer. Use SUMA_ADO_idcode()
1309                         instead */
1310    char *private_Label;      /* DO NOT ACCESS THIS POINTER directly from
1311                         any SUMA_ALL_DO pointer. Use SUMA_ADO_Label()
1312                         instead */
1313 } SUMA_ALL_DO; /* See SUMA_ADO_* functions and iDO_ macros for a variety
1314                   of utility functions */
1315 
1316 /*! Displayable Object Type */
1317 typedef struct {
1318    void *OP;   /*!< Object Pointer */
1319    SUMA_DO_Types ObjectType;
1320          /*!< Type of displayable object (redundant with OP->type) */
1321    SUMA_DO_CoordType CoordType;
1322       /*!< Type of coordinate system that the object is attached to
1323          This is used to determine whether the object is drawn before or
1324          or after the shift and rotation matrices are applied */
1325 } SUMA_DO;
1326 
1327 
1328 typedef struct {
1329    Widget toplevel;  /*!< toplevel widget of the text display window */
1330    Widget text_w; /*!<  text widget containing string to be displayed */
1331    Widget search_w;  /*!< widget of string search field */
1332    Widget text_output;  /*!< widget of search result field */
1333    SUMA_Boolean case_sensitive;  /*!< Case sensitive widget search */
1334    SUMA_Boolean allow_edit; /*!< allow editing of text displayed*/
1335    void (*OpenCallBack)(void *data); /*!< call back performed when
1336                               SUMA_CreateTextShell is entered */
1337    void * OpenData;  /*!< data sent along with OpenCallBack */
1338    char *OpenDataType; /* The type of data struct in OpenData_Type */
1339    void (*DestroyCallBack)(void *data);   /*!< call back performed when
1340                                  SUMA_DestroyTextShell is entered */
1341    void * DestroyData; /*!< data sent along with DestroyCallBack */
1342    SUMA_Boolean CursorAtBottom; /*!< If YUP then cursor is positioned at
1343                                        end of text field */
1344    char *title; /* the title string */
1345    char *weblink;
1346 } SUMA_CREATE_TEXT_SHELL_STRUCT; /*!< structure containing options and widgets
1347                                        for the text shell window */
1348 
1349 typedef enum {SUMA_OK_BUTTON, SUMA_APPLY_BUTTON,
1350                SUMA_CLEAR_BUTTON, SUMA_CANCEL_BUTTON,
1351                SUMA_HELP_BUTTON, SUMA_N_PROMPT_BUTTONS }SUMA_PROMPT_BUTTONS;
1352 
1353 typedef enum { SUMA_OK, SUMA_OK_HELP,
1354                SUMA_OK_CANCEL, SUMA_OK_CANCEL_HELP,
1355                SUMA_OK_CLEAR_CANCEL, SUMA_OK_CLEAR_CANCEL_HELP,
1356                SUMA_OK_APPLY_CANCEL, SUMA_OK_APPLY_CANCEL_HELP,
1357                SUMA_OK_APPLY_CLEAR_CANCEL, SUMA_OK_APPLY_CLEAR_CANCEL_HELP} SUMA_PROMPT_MODE;
1358 
1359 typedef enum {
1360    SUMA_LSP_SINGLE, SUMA_LSP_BROWSE, SUMA_LSP_MULTIPLE, SUMA_LSP_EXTENDED
1361 }  SUMA_ListSelectPolicy; /*!< Flags for motif list selection policy */
1362 
1363 typedef struct {
1364    char ** clist; /*!< strings displayed in the Scrolled list window */
1365    int N_clist; /*!< Number of strings in clist */
1366    void **oplist; /*!< list of pointers to objects in the scrolled list */
1367    char *content_id; /*!< A string identifier to indicate which object
1368                           provided the content of this list */
1369 } SUMA_ASSEMBLE_LIST_STRUCT;
1370 
1371 /*!
1372    Structure containing widgets and settings for a list widget
1373 */
1374 typedef struct {
1375    Widget toplevel; /*!< top level shell for list */
1376    Widget rc;  /*!< rowcolumn containing all the widgets of the scrolled list */
1377    Widget list; /*!< list widget */
1378 
1379    Widget PosRef; /*!< Widget relative to which list is positioned */
1380    SUMA_WINDOW_POSITION Pos; /*! Position of list relative to PosRef*/
1381    SUMA_ListSelectPolicy SelectPolicy; /*!< Sets the XmNselectionPolicy resource:
1382                           SUMA_LSP_SINGLE: XmSINGLE_SELECT,
1383                           SUMA_LSP_BROWSE: XmBROWSE_SELECT,
1384                           SUMA_LSP_MULTIPLE: XmMULTIPLE_SELECT,
1385                           SUMA_LSP_EXTENDED: XmEXTENDED_SELECT */
1386    SUMA_Boolean ShowSorted; /*!< Sort the list in alphabetical order */
1387    SUMA_Boolean RemoveDups; /*!< Remove duplicates in list */
1388    void (*Default_cb)(Widget w, XtPointer data, XtPointer calldata); /*!< callback to make when a default selection mode is made */
1389    void *Default_Data; /*!< pointer to data to go with Default_cb. If you pass NULL, the pointer to the List Widget is sent */
1390    void (*Select_cb)(Widget w, XtPointer data, XtPointer calldata); /*!< callback to make when a selection is made */
1391    void *Select_Data; /*!< pointer to data to go with Select_cb. If you pass NULL, the pointer to the List Widget is sent */
1392    void (*CloseList_cb)(Widget w, XtPointer data, XtPointer calldata); /*!< callbak to make when a selection is made */
1393    void *CloseList_Data; /*!< pointer to data to go with CloseList_cb. If you pass NULL, the pointer to the List Widget is sent */
1394    char *Label;
1395    SUMA_Boolean isShaded; /*!< YUP if the window is minimized or shaded, NOPE if you can see its contents */
1396 
1397    SUMA_ASSEMBLE_LIST_STRUCT *ALS; /*!< structure containing the list of strings shown in the widget and the pointers
1398                                        of the objects the list refers to*/
1399    int lastitempos;
1400 
1401    int width; /* initial width in pixels of list area (excluding margins) */
1402 } SUMA_LIST_WIDGET;
1403 
1404 /*! structure containing widgets for surface viewer controllers ViewCont */
1405 typedef struct {
1406    Widget TopLevelShell;/*!< Top level shell for a viewer's controller */
1407    Widget Mainform;
1408    Widget ViewerInfo_pb;
1409    Widget Info_lb;
1410    SUMA_LIST_WIDGET *SwitchGrouplst; /*!< a structure containing widgets
1411                                     and options for the switch Group list */
1412    SUMA_LIST_WIDGET *SwitchStatelst; /*!< a structure containing widgets
1413                                  and options for the switch State list */
1414    SUMA_CREATE_TEXT_SHELL_STRUCT * ViewerInfo_TextShell; /*!< structure
1415                   containing widgets and options of the viewer info text shell */
1416 }SUMA_X_ViewCont;
1417 
1418 typedef struct {
1419    SUMA_PROMPT_MODE Mode;
1420    SUMA_PROMPT_BUTTONS default_button; /*!< button to call when return key is hit in the text field.*/
1421    void (*SelectCallback)(char *selection, void *data); /*!< function called when a selection is made
1422                                             See note for Preserve field*/
1423    void *SelectData; /*!< data sent along to SelectCallback */
1424    void (*CancelCallback)(void *data); /*!< function called when cancel or kill is called */
1425    void *CancelData; /*!< data sent along to CancelCallback */
1426    void (*HelpCallback)(void *data);
1427    void (*HelpData);
1428    int (*VerifyFunction)(char *word, void *data);
1429    void (*VerifyData);
1430    Widget actionarea;
1431    Widget pane;
1432    Widget dialog; /*!< widget of dialog */
1433    Widget daddy; /*!< widget of parent */
1434    Widget text_w; /*!< Text entry widget */
1435    char *selection; /*!< What the lame user wrote */
1436    char *label; /*!< Label for the text field */
1437    SUMA_Boolean preserve;
1438 } SUMA_PROMPT_DIALOG_STRUCT; /*!< \sa similar fields in SUMA_SELECTION_DIALOG_STRUCT */
1439 
1440 typedef enum { SUMA_FILE_OPEN, SUMA_FILE_SAVE }
1441             SUMA_FILE_SELECT_MODE; /*!< mode of file selection dialog */
1442 
1443 typedef struct {
1444    SUMA_FILE_SELECT_MODE Mode;
1445    void (*SelectCallback)(char *filename, void *data); /*!< function called
1446                                     when a selection is made
1447                                     See note for Preserve field*/
1448    void *SelectData; /*!< data sent along to SelectCallback */
1449    void (*CancelCallback)(void *data); /*!< function called when cancel or
1450                                             kill is called */
1451    void *CancelData; /*!< data sent along to CancelCallback */
1452    Widget dlg_w; /*!< widget of dialog */
1453    Widget daddy; /*!< widget of parent */
1454    char *filename; /*!< selected filename.
1455                NOTE: This is only valid when a selection has been made */
1456    char *FilePattern; /*!< Pattern for filename filtering
1457                            Only relevant when window is opened */
1458    SUMA_Boolean preserve; /*!< If YUP, then widget is only unmanaged when
1459                      selection is made or cancel is pressed. In
1460                      this case, you should take care of dlg's safekeeping
1461                      and eventual destruction.
1462                      If Nope, then the widget is destroyed after selection
1463                      and/or cancel and the dlg structure is destroyed.
1464                      Be careful, if Preserve is NOPE, that your callbacks
1465                      do not return before being done with this structure*/
1466 } SUMA_SELECTION_DIALOG_STRUCT;
1467 
1468 /*!
1469    Structure containing widgets and settings of an arrow and or a text field
1470 
1471    - When adding fields to this stucture, make sure you initialize them
1472    appropriately in the functions SUMA_CreateTextField and SUMA_CreateArrowField
1473 */
1474 typedef struct {
1475    Widget rc;  /*!< rowcolumn containing all the widgets of the arrow field */
1476    Widget textfield;  /*! text label */
1477    Widget up;     /*!< up arrow */
1478    Widget down;   /*!< down arrow */
1479    Widget label;  /*!< label widget */
1480 
1481    float step; /*!< increment */
1482    float min;  /*!< minimum value */
1483    float max;  /*!< maximum value */
1484    SUMA_Boolean wrap; /*!< YUP: wrap value in min-max range, else clip it*/
1485    float value;   /*!< current value */
1486    int cwidth; /*!< charcter spaces to save for widget */
1487    SUMA_VARTYPE type; /*!< SUMA_int or SUMA_float or SUMA_string */
1488    int direction; /*!< +1 up, -1 down */
1489 
1490    XtIntervalId arrow_timer_id; /*!< time out process id */
1491 
1492    void (*NewValueCallback)(void *data); /*!< callback when a new value is set */
1493    void *NewValueCallbackData;
1494    SUMA_Boolean modified; /*!< set to YUP when user edits the value field */
1495    SUMA_Boolean arrow_action; /*!< set to YUP when user clicks one of the arrows */
1496 } SUMA_ARROW_TEXT_FIELD;
1497 
1498 typedef enum { SUMA_ERROR_CELL, SUMA_ROW_TIT_CELL, SUMA_COL_TIT_CELL, SUMA_ENTRY_CELL } SUMA_CELL_VARIETY;
1499 
1500 typedef struct{
1501    Widget rc;
1502    Widget rco;
1503    Widget *cells; /* table cells, Ncol x Nrow total */
1504    SUMA_Boolean HasColTit; /*!< YUP = table's 1st row is titles */
1505    SUMA_Boolean HasRowTit; /*!< YUP = table's 1st col is titles */
1506    int Ni;   /*!< Number of rows = Number of elements PER COLUMN (1st dim)*/
1507    int Nj;   /*!< Number of columns = Number of elements PER ROW (2nd dim)*/
1508    int *cwidth; /*!< charcter spaces to save for widget per column */
1509    byte *but_flag; /*!< Flags to indicate button status of a cell. That is
1510                         to allow the highjacking of text fields to make them
1511                         toggle buttons. This should normally be used for column
1512                         and row titles only. But you never know */
1513    float *num_value;   /*!< current value at each cell (for numeric cells)*/
1514    char **str_value;   /*!< current string at each cell (for string cells) */
1515    SUMA_Boolean editable;
1516    SUMA_VARTYPE type; /*!< SUMA_int or SUMA_float or SUMA_string */
1517    void (*NewValueCallback)(void *data); /*!< callback to make when
1518                                               a new value is set */
1519    void *NewValueCallbackData;
1520    void (*TitLabelEVHandler)( Widget w , XtPointer cd , XEvent *ev ,
1521                               Boolean *ctd);
1522    void *TitLabelEVHandlerData;
1523    void (*CellEVHandler)(Widget w , XtPointer cd , XEvent *ev , Boolean *ctd);
1524    void *CellEVHandlerData;
1525    int cell_modified; /*!< set to 1D index (column major) of cell_value edited,
1526                            i = cell_modified % Ni, j = cell_modified / Ni
1527                            cell_modified = j * Ni + i */
1528    SUMA_NUMERICAL_UNITS num_units;
1529    char **rowobject_id;
1530    char wname[64];
1531 } SUMA_TABLE_FIELD;
1532 
1533 typedef struct {
1534    Widget cmap_wid;  /*! GLXAREA widget for displaying colormap */
1535    int CrappyDrawable;
1536    float FOV;  /*! FOV for viewing colormap */
1537    GLXContext cmap_context;   /* graphic context for cmap */
1538    float translateVec[3];
1539 } SUMA_CMAP_RENDER_AREA;
1540 
1541 typedef struct {
1542    Widget *mw; /* MenuWidgets vector */
1543    int N_mw; /* number of widgets in MenuWidgets vector */
1544    SUMA_LIST_WIDGET *lw; /* list version of menu widgets */
1545    SUMA_ARROW_TEXT_FIELD *af; /* arrow field version of menu widgets*/
1546    int menu_type;
1547 } SUMA_MENU_WIDGET;
1548 
1549 typedef struct {
1550    Widget rc; /*! container row column */
1551    Widget lab; /*! Label */
1552    Widget sl;  /*! Slider widget */
1553    Widget tb;  /*! Toggle button for view slice */
1554    Widget text; /*! Text area where user enters slice number */
1555    Widget mont;  /* Text area where user enters montage */
1556    int Nslc;
1557    char *variant;
1558    char *slice_num_str;
1559    char *mont_str;
1560    float slice_num;
1561    float mont_num;
1562    float mont_inc;
1563    SUMA_NUMERICAL_UNITS slice_units;
1564    SUMA_NUMERICAL_UNITS mont_units;
1565    void (*NewValueCallback)(void *data); /*!< callback when a new value is set */
1566    void *NewValueCallbackData;
1567    SUMA_Boolean modified; /*!< set to YUP when user edits the value field */
1568    char wname[64];
1569 } SUMA_SLICE_FIELD;
1570 
1571 typedef struct {
1572    Widget rc; /*! container row column */
1573    Widget lab; /*! Label */
1574    Widget tb;  /*! Toggle button for view slice */
1575    Widget tbs;  /*! Toggle button for allow selection */
1576    Widget text; /*! Text area where user enters slice number */
1577    int Nslc;
1578    char *N_slice_num_str;
1579    float N_slice_num;
1580    SUMA_NUMERICAL_UNITS N_slice_units;
1581    void (*NewValueCallback)(void *data); /*!< callback when a new value is set */
1582    void *NewValueCallbackData;
1583    SUMA_Boolean modified; /*!< set to YUP when user edits the value field */
1584    char wname[64];
1585 } SUMA_VR_FIELD;
1586 
1587 
1588 /*! structure containing widgets for surface  controllers SurfCont */
1589 typedef struct {
1590    /* *** DO NOT ADD ANYTHING BEFORE THESE FIELDS
1591           DO NOT CHANGE THE ORDER OF THESE FIELDS
1592           These fields are use for tracking copies
1593           (links) to a pointer.
1594           ANY CHANGES HERE SHOULD BE REFLECTED IN
1595           SUMA_LinkedPtr structure
1596    */
1597    SUMA_DO_Types do_type;  /*!< To check if this is a displayable object */
1598    int LinkedPtrType; /*!< Indicates the type of linked pointer */
1599    int N_links;   /*!< Number of links to this pointer */
1600    char owner_id[SUMA_IDCODE_LENGTH];   /*!< The id of whoever created that
1601                                        pointer. Might never get used.... */
1602 
1603    int Open; /*!< Flag indicating that controller is open
1604                   This was introduced to help deal with crashes on
1605                   OS X 10.5 and 10.6*/
1606    Widget TLS;/*!< Top level shell for a Surface's controller */
1607    Widget PosRef; /*!< reference position widget */
1608    Widget Page; /*!< parent of Mainform, child of Notebook
1609                          if using one controller */
1610    Widget Mainform; /*!< main form, child of TopLevelShell, or NoteBook*/
1611    Widget SurfInfo_pb; /*!< More info push button */
1612    Widget SurfInfo_label; /*!< Le label */
1613    Widget Mask_pb; /*!< Mask push button */
1614    Widget VSliceAtXYZ_tb; /*!< Make slices jump to crosshair location */
1615    SUMA_CREATE_TEXT_SHELL_STRUCT * SurfInfo_TextShell; /*!< structure containing
1616                         widgets and options of the surface info text shell */
1617    SUMA_MENU_WIDGET *RenderModeMenu; /*!<[SW_N_SurfCont_Render] widgets
1618                                        controlling the rendering mode menu */
1619    SUMA_MENU_WIDGET *TransModeMenu; /*!<[SW_N_SurfCont_Trans] widgets
1620                                        controlling the transparency menu */
1621    SUMA_MENU_WIDGET *VTransModeMenu; /*!<[SW_N_SurfCont_Trans] widgets
1622                                     controlling the volume transparency menu */
1623    SUMA_MENU_WIDGET *DsetViewModeMenu; /*!<[SW_N_SurfCont_DsetView]  widgets
1624                                        controlling the dataset view mode menu */
1625    SUMA_MENU_WIDGET *DsetFontMenu; /*!<[SW_N_SurfCont_DsetFont] widgets                                   controlling the font displayed on graph nodes */
1626    SUMA_MENU_WIDGET *DsetNodeColMenu; /*!<[SW_N_SurfCont_DsetNodeCol] widgets                                   controlling the color mapping of graph nodes */
1627    SUMA_MENU_WIDGET *DsetTxtShadMenu; /*!<[SW_N_SurfCont_DsetTxtShad] widgets                                   controlling the shading/shadowing of txt */
1628    SUMA_MENU_WIDGET *DsetGmatBordMenu; /*!<[SW_N_SurfCont_DsetGmatBord] widgets                                   controlling the border thickness in GMATRIX */
1629    SUMA_MENU_WIDGET *DsetNodeRadMenu; /*!<[SW_N_SurfCont_DsetNodeRad] widgets                                   controlling the sizing of graph nodes */
1630    SUMA_MENU_WIDGET *DsetThroughMenu; /*!<[SW_N_SurfCont_DsetThrough] widgets                          controlling the way connections from a node are displayed */
1631    SUMA_MENU_WIDGET *DsetEdgeThickMenu; /*!<[SW_N_SurfCont_DsetEdgeThick] widgets                                   controlling the sizing of graph nodes */
1632    SUMA_MENU_WIDGET *DsetEdgeStipMenu; /*!<[SW_N_SurfCont_DsetEdgeStip] widgets                                   controlling the sizing of graph nodes */
1633    SUMA_MENU_WIDGET *TractStyleMenu; /*!<[SW_N_SurfCont_TractStyle] widgets                                   controlling the sizing of graph nodes */
1634    SUMA_MENU_WIDGET *DsetAlphaValMenu; /*!<[SW_N_SurfCont_DsetAlphaVal] widgets                                   controlling the sizing of graph nodes */
1635    SUMA_MENU_WIDGET *TractMaskMenu; /*!<[SW_N_SurfCont_TractMask] widgets
1636                                 controlling the masking method */
1637    Widget ColPlane_fr; /*!< the frame controlling the colorplanes */
1638    Widget Slice_fr;
1639    Widget DispFrame;
1640    Widget SurfFrame;
1641    Widget VR_fr;
1642    Widget DsetMap_fr; /*!< the frame for mapping Dset to colormap */
1643    Widget Xhair_fr; /*!< The frame for cross hair Info and controls */
1644    Widget SurfContPage_label; /*!< Le label */
1645    SUMA_ARROW_TEXT_FIELD *SurfContPage; /*!< arrow/text field
1646                                               controlling color plane order */
1647    SUMA_ARROW_TEXT_FIELD *NodeRadGainAF; /*!< arrow/text field
1648                                               controlling node radius gain */
1649    SUMA_ARROW_TEXT_FIELD *EdgeThickGainAF; /*!< arrow/text field
1650                                               controlling node radius gain */
1651    SUMA_ARROW_TEXT_FIELD *ColPlaneOrder; /*!< arrow/text field
1652                                               controlling color plane order */
1653    SUMA_ARROW_TEXT_FIELD *ColPlaneOpacity; /*!< arrow/text field
1654                                              controlling color plane opacity */
1655    SUMA_ARROW_TEXT_FIELD *ColPlaneDimFact; /*!< arrow/text field
1656                                              controlling color plane DimFact */
1657    SUMA_ARROW_TEXT_FIELD *ColPlaneAlphaThresh; /*!< arrow/text field
1658                                            controlling color plane AlphaThresh */
1659    SUMA_ARROW_TEXT_FIELD *TractMaskGray; /*!< arrow/text field
1660                                       controlling grayness of masked tracts */
1661    SUMA_TABLE_FIELD *SetRangeTable; /*!< structure for range setting table */
1662    SUMA_TABLE_FIELD *RangeTable; /*!< structure for range  table */
1663    SUMA_TABLE_FIELD *MaskTable;
1664    SUMA_TABLE_FIELD *MaskEvalTable;
1665    Widget MaskEval_tb;
1666    SUMA_Boolean UseMaskEval;
1667    SUMA_TABLE_FIELD *MaskLenTable;
1668    Widget MaskLen_tb;
1669    SUMA_TABLE_FIELD *XhairTable; /*!< structure for Cross hair  table */
1670    SUMA_TABLE_FIELD *NodeTable; /*!< structure for node index  table */
1671    SUMA_TABLE_FIELD *FaceTable;
1672    SUMA_TABLE_FIELD *DataTable;
1673    SUMA_TABLE_FIELD *LabelTable;
1674    SUMA_TABLE_FIELD *SetThrScaleTable;
1675    SUMA_TABLE_FIELD *SetClustTable; /*!< structure for clust setting table */
1676    /* Obsolete since Nov 09,
1677       Replaced with DsetViewModeMenu
1678       Widget ColPlaneShow_tb; *//*!< show/hide color plane */
1679    Widget ColPlaneShowOneFore_tb; /*!< show only one color plane at a time*/
1680    Widget GDSET_ShowBundles_tb; /*!< show bundles insted of edges*/
1681    Widget GDSET_ShowUncon_tb; /*!< show unconnected nodes */
1682    Widget SymIrange_tb; /*!< Symmetric intensity range */
1683    Widget AbsThresh_tb; /*!< absolute threshold */
1684    Widget ShowZero_tb; /*!< Show zero values */
1685    SUMA_LIST_WIDGET *SwitchDsetlst; /*!< a structure containing widgets and
1686                                     options for the switch color plane list */
1687    SUMA_TABLE_FIELD *ColPlaneLabelTable;
1688    SUMA_OVERLAYS *curColPlane; /*!< a copy of the pointer to the selected color
1689                                     plane */
1690    SUMA_Boolean ShowCurForeOnly; /*!< Show current plane only out of the entire
1691                                     stack */
1692    SUMA_Boolean GraphHidden; /*!< Graph update even in ShowCurForeOnly */
1693    void **prv_curDOp; /*!< copy of the pointer to the displayable object
1694                        for which the controller is open. Private field
1695                        only access with SUMA_SurfCont_GetcurDOp() and
1696                        SUMA_SurfCont_SetcurDOp()
1697                        This pointer should have some permanence, like a
1698                        surface object or a graph dataset - Note that
1699                        I don't handle replacement of graph dataset pointers
1700                        yet. This field would need attention when I reload
1701                        a graph dataset. */
1702    char *prv_variant; /*!< Rendering variant for pointer in prv_curDOp
1703                        This is needed because the same DO pointer can be
1704                        rendered in multiple ways. This field is also private
1705                        and is set at the same time as prv_curDOp */
1706    SUMA_CMAP_RENDER_AREA *cmp_ren;   /* data for cmap rendering zone */
1707    Widget thr_sc;   /*! scale for threshold data */
1708    Widget brt_sc;   /*! scale for brightness data */
1709    SUMA_VR_FIELD *VR_fld;
1710    SUMA_SLICE_FIELD *Ax_slc;
1711    SUMA_SLICE_FIELD *Sa_slc;
1712    SUMA_SLICE_FIELD *Co_slc;
1713    Widget thr_lb;  /*! threshold title
1714                         No longer used,
1715                         using SetThrScaleTable instead */
1716    Widget thrstat_lb;  /*! pvalue associated with threshold */
1717    Widget cmaptit_lb;  /*! title of cmap */
1718    Widget cmapswtch_pb; /*! button for switching color map */
1719    SUMA_MENU_WIDGET *SwitchIntMenu; /* vector of widgets controlling
1720                                        the switch intensity widgets */
1721    SUMA_MENU_WIDGET *SwitchThrMenu; /* vector of widgets controlling
1722                                        the switch threshold widgets */
1723    SUMA_MENU_WIDGET *SwitchBrtMenu; /* vector of widgets controlling
1724                                        the switch brightness widgets */
1725    #if 0 /* Now folded into SUMA_MENU_WIDGET struct */
1726    SUMA_ARROW_TEXT_FIELD *SwitchIntArrow;
1727    SUMA_ARROW_TEXT_FIELD *SwitchThrArrow;
1728    SUMA_ARROW_TEXT_FIELD *SwitchBrtArrow;
1729 
1730    SUMA_LIST_WIDGET *SwitchIntLst; /*!< list widget for switching intensity */
1731    SUMA_LIST_WIDGET *SwitchThrLst; /*!< list widget for switching intensity */
1732    SUMA_LIST_WIDGET *SwitchBrtLst; /*!< list widget for switching intensity */
1733    #endif
1734    SUMA_MENU_WIDGET *SwitchCmapMenu; /* vector of widgets controlling
1735                                         the switch cmap widgets */
1736    #if 0 /* Now inside SUMA_MENU_WIDGET */
1737    int N_CmapMenu; /* Number of widgets in SwitchCmapMenu */
1738    #endif
1739    Widget rc_CmapCont; /* rc container to contain Cmap menu */
1740    SUMA_MENU_WIDGET *CoordBiasMenu; /* [SW_N_CoordBias]vector of widgets
1741                                  controlling the coord bias widgets */
1742    SUMA_MENU_WIDGET *LinkModeMenu; /*[SW_N_LinkMode] vector of widgets
1743                                  controlling the linking of I, T widgets */
1744    SUMA_MENU_WIDGET *CmapModeMenu; /* [SW_N_CmapMode] */
1745    Widget opts_rc; /*!< rowcolumn for color map, color bar and switch buttons */
1746    Widget opts_form; /*!< rowcolumn containing all options for colormapping */
1747    Widget rcvo; /*!< vertical rowcol for colormapping options */
1748    Widget rcsw; /*!<  rowcol for switching intensity, threshold and brightness */
1749    Widget rcsw_v1;/*!< rowcol containing Menu for Int. Thr. and Brt. */
1750    Widget rcsw_v2;/*!< rowcol containing toggle buttons for Int. Thr. and Brt. */
1751    Widget rcswr;  /*!< horizontal rowcol for Intensity column range label */
1752    Widget rccm;  /*!< rowcol containing colormap selectors and ranging options */
1753    Widget rccm_swcmap;
1754    Widget IntRange_lb; /*!< label widget containing range values */
1755    Widget Int_tb;/* Toggle buttons for intensity, threshold & brightness toys */
1756    Widget Thr_tb;
1757    Widget Brt_tb;
1758    Widget CmapLoad_pb;
1759    Widget Fake_pbar;
1760    int IntRangeLocked;
1761    int BrtRangeLocked;
1762    Widget rcclust; /*!< rowcol holding clusterizing options */
1763    Widget DeleteMask_pb;
1764    int DeleteMask_first;
1765    int DeleteMask_row;
1766    float tract_length_mask[2];
1767    int UseMaskLen;
1768 }SUMA_X_SurfCont;
1769 
1770 typedef struct {
1771    int N_rb_group; /*!< number of radio buttons in group */
1772    int N_but; /*!< number of buttons per radio button group */
1773    Widget *tb; /*!< vector of N_rb_group * N_but toggle button widgets */
1774    Widget *rb; /*!< vetor of N_rb_group radio box widget */
1775    Widget arb; /*!< widget of radiobox for all lock buttons */
1776    Widget *atb; /*!< widget of toggle buttons in arb */
1777 }SUMA_rb_group;
1778 
1779 /*! structure containing widgets for Suma's controller SumaCont */
1780 typedef struct {
1781    Widget AppShell; /*!< AppShell widget for Suma's controller */
1782    Widget form;
1783    Widget LockFrame;
1784    Widget AppFrame;
1785    Widget quit_pb; /*!< quit push button */
1786    SUMA_Boolean quit_first;   /*!< flag indicating first press of done button */
1787    SUMA_rb_group *Lock_rbg; /*!< pointer to structure contining N radio
1788                                  button groups */
1789    Widget *LockView_tbg;   /*!< vector of toggleview buttons */
1790    Widget LockAllView_tb;  /*!< widget of toggleAllview button */
1791    SUMA_CREATE_TEXT_SHELL_STRUCT *SumaInfo_TextShell;
1792 }SUMA_X_SumaCont;
1793 
1794 
1795 /*! structure containing widgets and data for the DrawROI window*/
1796 typedef struct {
1797    Widget AppShell; /*!< AppShell widget for the DrawROI window*/
1798    Widget DrawROImode_tb; /*!< widget for toggling draw ROI mode */
1799    Widget ContROImode_tb;
1800    Widget form;
1801    Widget frame;
1802    Widget Penmode_tb;   /*!< widget for toggling draw with Pen mode */
1803    Widget AfniLink_tb; /*!< widget for toggling link to Afni */
1804    Widget ParentLabel_lb; /*!< widget for specifying a label for
1805                               the parent surface */
1806    Widget Redo_pb;
1807    Widget Undo_pb;
1808    Widget Save_pb;
1809    Widget Load_pb;
1810    Widget Close_pb;
1811    Widget Finish_pb;
1812    Widget Join_pb;
1813    Widget Delete_pb;
1814    SUMA_Boolean Delete_first; /*! Flag indicating putton has been
1815                                  pressed for the first time */
1816    SUMA_ARROW_TEXT_FIELD *ROIval; /*!< pointer to arrow field */
1817    SUMA_ARROW_TEXT_FIELD *ROIlbl; /*!< pointer to text field */
1818    SUMA_DRAWN_ROI *curDrawnROI; /*!< A pointer to the DrawnROI structure
1819                                     currently in use by window.
1820                                     This is a copy of another pointer,
1821                                     NEVER FREE IT*/
1822    SUMA_LIST_WIDGET *SwitchROIlst; /*!< a structure containing widgets and
1823                                     options for the switch ROI list */
1824    int SaveWhat;  /*!< option for determining what ROI to save, acceptable values
1825                      are in SUMA_WIDGET_INDEX_DRAWROI_SAVEWHAT */
1826    int SaveMode;  /*!< option for determining format of ROI to save, acceptable
1827                      values are in SUMA_WIDGET_INDEX_DRAWROI_SAVEMODE */
1828    int WhatDist;  /*!< option for determining format of ROI to save, acceptable
1829                         values are in SUMA_WIDGET_INDEX_DRAWROI_SAVEMODE */
1830    SUMA_MENU_WIDGET *SaveModeMenu; /*!<[SW_N_DrawROI_SaveMode] set of
1831                            widgets for SaveMode menu */
1832    SUMA_MENU_WIDGET *SaveWhatMenu; /*!<[SW_N_DrawROI_SaveWhat] set of
1833                            widgets for SaveWhat menu */
1834    SUMA_MENU_WIDGET *WhatDistMenu; /*!<[SW_N_DrawROI_WhatDist] set of
1835                            widgets for SaveWhat menu */
1836 } SUMA_X_DrawROI;
1837 
1838 
1839 typedef struct {
1840    GLXContext last_context;
1841    Display *last_context_DPY;
1842    Window last_context_WDW;
1843    char setting_function[64];
1844    char widget_label[64];
1845 } SUMA_GLCONTEXT_RECORD;
1846 
1847 /*! structure containg X vars for surface viewers*/
1848 typedef struct {
1849    Display *DPY; /*!< display of toplevel widget */
1850    Widget TOPLEVEL, FORM, FRAME, GLXAREA;
1851    XVisualInfo *VISINFO;
1852    GLXContext GLXCONTEXT;
1853    Colormap CMAP;
1854    Bool DOUBLEBUFFER;
1855    char *Title;
1856    int REDISPLAYPENDING, CrappyDrawable;
1857    int aWIDTH, aHEIGHT; /* These are the widths and heights of the drawing area,
1858                          rather than the whole window */
1859    XtWorkProcId REDISPLAYID;
1860    XtIntervalId MOMENTUMID;
1861    GC gc;
1862    SUMA_X_ViewCont *ViewCont; /*!< pointer to structure containing viewer
1863                                     controller widget structure */
1864    Widget ToggleCrossHair_View_tglbtn; /*!< OBSOLETE Toggle button in
1865                                              View-> menu */
1866    SUMA_MENU_WIDGET *FileMenu; /*!<[SW_N_File] File Menu Vector of widgets */
1867    SUMA_MENU_WIDGET *ToolsMenu; /*!<[SW_N_Tools]of widgets tools menu */
1868    SUMA_MENU_WIDGET *ViewMenu; /*!< [SW_N_View]Vector of widgets  View Menu */
1869    SUMA_MENU_WIDGET *HelpMenu; /*!< [SW_N_Help]Vector of widgets  Help Menu */
1870    SUMA_PROMPT_DIALOG_STRUCT *LookAt_prmpt; /*!< structure for LookAt dialog */
1871    SUMA_PROMPT_DIALOG_STRUCT *SetRot_prmpt; /*!< structure for set rotation
1872                                                 dialog */
1873    SUMA_PROMPT_DIALOG_STRUCT *JumpIndex_prmpt; /*!< structure for the
1874                                                    Jump To Index dialog */
1875    SUMA_PROMPT_DIALOG_STRUCT *JumpXYZ_prmpt; /*!< structure for the
1876                                                    Jump To XYZ dialog */
1877    SUMA_PROMPT_DIALOG_STRUCT *JumpFocusNode_prmpt; /*!< structure for setting                                                   Focus Node dialog */
1878    SUMA_PROMPT_DIALOG_STRUCT *JumpFocusFace_prmpt; /*!< structure for setting                                                   Focus FaceSet dialog */
1879    SUMA_PROMPT_DIALOG_STRUCT *HighlightBox_prmpt; /*!<  structure for
1880                                              highlighting nodes in Box dialog */
1881    SUMA_PROMPT_DIALOG_STRUCT *SetRenderOrder_prmpt;
1882 }SUMA_X;
1883 
1884 /*! structure containg X vars common to all viewers */
1885 typedef struct {
1886    SUMA_X_SumaCont *SumaCont; /*!< structure containing widgets
1887                                     for Suma's controller */
1888    SUMA_X_DrawROI *DrawROI; /*!< structure containing widgets for
1889                                  DrawROI window */
1890    XtAppContext App; /*!< Application Context for SUMA */
1891    Display *DPY_controller1; /*!< Display of 1st controller's top level shell */
1892    SUMA_XRESOURCES X_Resources; /*!< flag specifying the types of
1893                                     resources to use */
1894    SUMA_CREATE_TEXT_SHELL_STRUCT *Help_TextShell; /*!< structure containing
1895                                     widgets and options of SUMA_help window */
1896    SUMA_CREATE_TEXT_SHELL_STRUCT *Help_Cmap_TextShell; /*!< structure containing
1897                                  widgets and options of colormap help window */
1898    SUMA_CREATE_TEXT_SHELL_STRUCT *Help_Plot_TextShell;
1899    SUMA_CREATE_TEXT_SHELL_STRUCT *Whereami_TextShell;
1900    SUMA_CREATE_TEXT_SHELL_STRUCT *Log_TextShell; /*!<  structure containing
1901                                        widgets and options of SUMA_log window */
1902    SUMA_SELECTION_DIALOG_STRUCT *FileSelectDlg; /*!< structure containing widgets
1903                               and options of a generic file selection dialog */
1904    SUMA_PROMPT_DIALOG_STRUCT *N_ForeSmooth_prmpt; /*!< structure for the number
1905                            of foreground smoothing dialog */
1906    SUMA_PROMPT_DIALOG_STRUCT *N_FinalSmooth_prmpt; /*!< structure for the number
1907                            of final smoothing dialog */
1908    int NumForeSmoothing;   /*!< Number of steps for smoothing the foreground
1909                                 colors prior to mixing with background. Default
1910                                 is set by environment variable
1911                                 SUMA_NumForeSmoothing which
1912                                 is set to 0 (No smoothing). */
1913    int NumFinalSmoothing;   /*!< Number of steps for smoothing the blended
1914                                 colors (after foreground is mixed with
1915                                 background). Default
1916                                 is set by environment variable
1917                                 SUMA_NumFinalSmoothing which
1918                                 is set to 0 (No smoothing). */
1919    SUMA_Boolean WarnClose; /*!< Pops up a window to double check
1920                                  before SUMA quits */
1921    SUMA_LIST_WIDGET *SwitchCmapLst; /*!< list widget for switching colormaps */
1922    SUMA_PROMPT_DIALOG_STRUCT *Clip_prmpt; /*!< structure for clipping dialog */
1923    SUMA_PROMPT_DIALOG_STRUCT *ClipObj_prmpt; /*!< structure for clip obj dialg */
1924 
1925    XmFontList TableTextFontList; /*! Font list for table's text fields */
1926 
1927    SUMA_Boolean UseSameSurfCont; /* Use one surface controller for all surfs? */
1928    SUMA_Boolean SameSurfContOpen;
1929    Widget CommonSurfContTLW; /* If not null, then surface controller will
1930                                    all be sharing this top level widget */
1931    Widget SC_Notebook;  /* Surface Controllers Notebook */
1932    int ButtonDown; /* Is mouse button pressed? */
1933 
1934    int roffx; /* relative offset of widget in window */
1935    int roffy;
1936 
1937    SUMA_GLCONTEXT_RECORD *Cr;
1938 
1939    SUMA_X_SurfCont *AllMaskCont;
1940    int MaskStateID; /* A flag that is updated anytime masks are modified
1941                        requiring a new computation of intersections */
1942 }SUMA_X_AllView;
1943 
1944 /*! structure defining a cross hair */
1945 typedef struct {
1946    GLfloat XaxisColor[4] ;
1947    GLfloat YaxisColor[4] ;
1948    GLfloat ZaxisColor[4] ;
1949 
1950    GLfloat LineWidth;
1951    SUMA_STIPPLE Stipple; /*!< dashed or solid line */
1952 
1953    GLfloat c[3]; /*!< Cross Hair center */
1954    float c_noVisX[3]; /*!< Cross Hair center without VisX transforms */
1955    GLfloat r; /*!< Cross Hair radius */
1956    GLfloat g; /*!< 1/2 of gap between center and ray
1957                   (should be less than radius/2) */
1958 
1959    SUMA_Boolean ShowSphere; /*!< YUP/NOPE, starting to regret this. */
1960    GLUquadricObj *sphobj; /*!< quadric object, representing central sphere */
1961    GLfloat sphcol[4]; /*!< Sphere color */
1962    GLdouble sphrad; /*!< Sphere radius */
1963    GLint slices; /*!< think pizza */
1964    GLint stacks; /*!< think lattitudes */
1965 
1966    int adoID; /*!<  If the cross hair is tied to a surface/DO, adoID
1967                         contains the index into SUMAg_DOv of that surface.
1968                         -1 if that cross hair is wild and loose */
1969    int datumID; /*!< a node/datum from adoID can be associated with the cross
1970                      hair (-1 for nothing) */
1971    int secID;   /*!< a secondary selection like FaceSet or Node of a graph. */
1972    GLUquadricObj *sphobjCmax; /*!< quadric object, representing Max cluster */
1973    GLfloat sphcolCmax[4]; /*!< Sphere color */
1974 }SUMA_CrossHair;
1975 
1976 typedef struct {
1977    GLUquadricObj *sphobj; /*!< quadric object, representing central sphere */
1978    GLfloat sphcol[4]; /*!< Sphere color */
1979    GLdouble sphrad; /*!< Sphere radius */
1980    GLint slices; /*!< think pizza */
1981    GLint stacks; /*!< think lattitudes */
1982    GLfloat c[3]; /*!< center of Sphere Marker */
1983 }SUMA_SphereMarker;
1984 
1985 typedef struct {
1986    GLfloat n0[3]; /*!< Node 1 XYZ*/
1987    GLfloat n1[3]; /*!< Node 2 XYZ*/
1988    GLfloat n2[3]; /*!< Node 3 XYZ*/
1989    GLfloat LineWidth; /*!< LineWidth of Edge*/
1990    GLfloat LineCol[4]; /*!< LineColor of Edge*/
1991    GLfloat NormVect[3]; /*!< normal vector of faceset, two triangles are drawn at a small distance from the selected FaceSet */
1992 }SUMA_FaceSetMarker;
1993 
1994 
1995 
1996 /*!
1997    Structure containg a bunch of segments defined between n0 and n1
1998 */
1999 typedef struct {
2000       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
2001    SUMA_DO_Types do_type;
2002    char *idcode_str;    /*!< unique idcode for DO */
2003    char *Label; /*!< ascii label for DO */
2004 
2005       /* These next three are to follow their equivalent is in SUMA_NB_DO */
2006    int NodeBased; /*!< flag: 1 if segments are formed by vectors at surface
2007                              nodes */
2008    char *Parent_idcode_str; /*!< Parent surface's id
2009                                  (only used if NodeBased = 1)*/
2010    int *NodeID; /*!< ID of the node at which the vector is represented
2011                      NULL if NodeBased = 0 */
2012 
2013       /* Begin specific fields */
2014    SUMA_DO_Types Parent_do_type;
2015    char *DrawnDO_variant;
2016    int *NodeID1; /*!< Used to define the 2 node of vectors that are fully
2017                       nodebased */
2018 
2019    GLfloat *n0; /*!< vector containing XYZ of nodes 1 (3*N_n elements long)
2020                      NULL if NodeBased*/
2021    GLfloat *n1; /*!< vector containing XYZ of nodes 2 (3*N_n elements long)*/
2022 
2023    GLUquadricObj *topobj; /*!< quadric object, representing n1 */
2024    GLUquadricObj *botobj; /*!< quadric object, representing n0 */
2025 
2026    int N_n; /*!< Number of elements in n0 and n1 */
2027 
2028    GLfloat LineWidth; /*!< Common LineWidth of all segment*/
2029    GLfloat LineCol[4]; /*!< Common LineColor of all segments*/
2030    GLfloat *colv; /*!< Vector of segment colors, 4 elements per segment.
2031                         NULL if using LineCol */
2032    GLfloat *thickv; /*!< Vector of segment thincknesses,
2033                          1 elements per segment. NULL if using LineWidth */
2034    SUMA_STIPPLE Stipple; /*!< dashed or solid line */
2035    GLushort *stipv;  /* stippling pattern for each seg. */
2036    int Mstip;
2037    GLushort stip;    /* common stippling pattern */
2038 
2039    int N_SegNodes; /* Number of unique nodes that are used to form the segments
2040                       That is the number of elements in the set formed by NodeID1
2041                       and NodeID, -1 if it is not set */
2042    int N_AllNodes; /* All defined nodes in parent set */
2043 } SUMA_SegmentDO;
2044 
2045 typedef struct {
2046    char *parent_ID;
2047    DList *Edges;
2048    DList *Points;
2049    DList *Nodes;
2050    DList *Triangles;
2051 } SUMA_STRIP;
2052 
2053 /*!
2054    Structure containg a bunch of spheres
2055 */
2056 typedef struct {
2057       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
2058    SUMA_DO_Types do_type;
2059    char *idcode_str;    /*!< unique idcode for DO */
2060    char *Label; /*!< ascii label for DO */
2061 
2062       /* These next three are to follow their equivalent is in SUMA_NB_DO */
2063    int NodeBased; /*!< flag: 1 if segments are formed by vectors at nodes */
2064    char *Parent_idcode_str; /*!< Parent surface's id
2065                                  (only used if NodeBased = 1
2066                                  NULL if NodeBased)*/
2067    int *NodeID; /*!< ID of the node at which the vector is represented
2068                      NULL if NodeBased = 0 */
2069 
2070 
2071        /* Begin specific fields */
2072    GLfloat *cxyz; /*!< vector containing XYZ of centers (3*N_n elements long)*/
2073    GLUquadricObj *sphobj; /*!< quadric object, representing central sphere */
2074    int N_n; /*!< Number of spheres */
2075    GLfloat LineWidth; /*!< LineWidth*/
2076    GLfloat CommonRad; /*!< common radius */
2077    GLfloat CommonCol[4]; /*!< common colors */
2078    GLint CommonSlices; /*!< think pizza */
2079    GLint CommonStacks; /*!< think lattitudes */
2080    GLfloat *radv; /*!< Vector of sphere radii, 1 elements per sphere.
2081                         NULL if using CommonRad */
2082    GLfloat *colv; /*!< Vector of sphere colors, 4 elements per sphere.
2083                         NULL if using CommonCol */
2084    GLenum CommonStyle; /*!< Common sphere drawing style.
2085             Choose from: GLU_FILL, GLU_LINE, GLU_SILHOUETTE, GLU_POINT */
2086    GLenum *stylev; /*!< Vector of sphere styles */
2087 
2088 }SUMA_SphereDO;
2089 
2090 /* A structure to hold tract masking results with boolean expressions */
2091 typedef struct {
2092    int N_vals;          /* Number of vals (tracts) in DO to be intersected */
2093    byte varcol[26*4];   /* RGB colors associated with each of the 26 variables
2094                            'a' to 'z' */
2095    byte varsused[26];   /* varsused[k] = 1 --> variable 'a'+k is in 'expr' */
2096    char varsmdo[26][1+SUMA_IDCODE_LENGTH]; /* varsmdo[k] contains the IDcode
2097                                              of the object (MaskDO) corresponding
2098                                              to variable 'a'+k */
2099    char mdoused[26*(1+SUMA_IDCODE_LENGTH)]; /* A brute catenation of IDcodes
2100                                          of DOs referenced by the variables */
2101    char allvarsineq[27]; /* A catenation of all variables in 'expr' */
2102    byte **marr;          /* a pointer to 26 (byte *) pointers to arrays of
2103                           N_vals bytes each. marr[k] is NULL is varsused[k]=0 */
2104    char *expr;    /* The boolean expression */
2105 } SUMA_MASK_EVAL_PARAMS;
2106 
2107 typedef struct {
2108       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
2109    SUMA_DO_Types do_type;
2110    char *idcode_str;
2111    char *Label;
2112 
2113       /* Not sure whether or not these things need to be moved into
2114          the common stuff in SUMA_ALL_DO yet ... */
2115    void *Saux; /* A pointer to a structure for SUMA's use */
2116    void (*FreeSaux)(void *Saux); /* Function to free Saux */
2117    int N_datum; /* Here number of control points forming tracts */
2118 
2119       /* Begin specific fields */
2120    char *Parent_idcode_str;
2121 
2122    TAYLOR_NETWORK *net;
2123 
2124    GLfloat LineWidth; /*!< Common LineWidth of all segment*/
2125    GLfloat LineCol[4]; /*!< Common LineColor of all segments*/
2126    GLfloat *colv; /*!< Vector of segment colors, 4 elements per segment.
2127                         NULL if using LineCol */
2128    GLfloat *thickv; /*!< Vector of segment thincknesses,
2129                          1 elements per segment. NULL if using LineWidth */
2130    SUMA_STIPPLE Stipple; /*!< dashed or solid line */
2131 
2132    SUMA_MASK_EVAL_PARAMS *mep;
2133 
2134    byte *tmask;
2135    int N_tmask;
2136    int MaskStateID;
2137    byte *tcols;
2138    byte usetcols;
2139 } SUMA_TractDO;
2140 
2141 typedef struct {
2142       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
2143    SUMA_DO_Types do_type;
2144    char *idcode_str;
2145    char *Label;
2146 
2147       /* Begin specific fields */
2148    char *Parent_idcode_str;
2149    char *variant;
2150 } SUMA_GraphLinkDO;
2151 
2152 typedef struct {
2153       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
2154    SUMA_DO_Types do_type;
2155    char *idcode_str;    /*!< unique idcode for DO */
2156    char *Label; /*!< ascii label for DO */
2157 
2158       /* Any change below should be reflected in all stucts that
2159          can get typecast to SUMA_NB_DO */
2160    int NodeBased; /*!< flag: 1 if segments are formed by
2161                         vectors at surface nodes */
2162    char *Parent_idcode_str; /*!< Parent surface's id
2163                                  (only used if NodeBased = 1
2164                                  NULL if NodeBased)*/
2165    int *NodeID; /*!< ID of the node at which the vector is represented
2166                      NULL if NodeBased = 0 */
2167 
2168 } SUMA_NB_DO; /*!< generic struct for common fields to Node-Based DOs */
2169 
2170 /*!
2171    Structure containg a bunch of planes
2172 */
2173 typedef struct {
2174       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
2175    SUMA_DO_Types do_type;
2176    char *idcode_str;    /*!< unique idcode for DO */
2177    char *Label; /*!< ascii label for DO */
2178 
2179       /* Begin specific fields */
2180    GLfloat *cxyz; /*!< vector containing XYZ of centers (3*N_n elements long)*/
2181    GLfloat *pleq; /*!< plane equations 4*N_n elements long */
2182    int N_n; /*!< Number of planes */
2183    GLfloat LineWidth; /*!< LineWidth*/
2184    GLfloat CommonBoxDims[3] ; /*!< common dimensions of box containing
2185                                     plane (centered on cxyz) */
2186    GLfloat CommonCol[4]; /*!< common colors */
2187    GLfloat *boxdimv; /*!< Vector of box dimensions radii,
2188                           3 elements per plane. NULL if using CommonBoxDims */
2189    GLfloat *colv; /*!< Vector of plane colors, 4 elements per plane.
2190                         NULL if using CommonCol */
2191    GLfloat *NodeList;
2192    GLint *FaceSetList;
2193    GLfloat *nodecol;
2194    GLfloat *NodeNormList;
2195    int N_Node;
2196    int N_FaceSet;
2197    SUMA_RENDER_MODES PolyMode; /*!< polygon viewing mode, SRM_Fill,
2198                                     SRM_Line, SRM_Points */
2199    SUMA_TRANS_MODES TransMode; /*!< polygon transparency  */
2200 }SUMA_PlaneDO;
2201 
2202 
2203 /*! Structure containing the communication info and status with AFNI */
2204 typedef struct {
2205    SUMA_Boolean Connected;   /*!< flag indicating connection state */
2206    int ConSock;
2207 
2208 } SUMA_AfniCom;
2209 
2210 /* structure defining the former state of a surface viewer window */
2211 typedef struct {
2212    float ViewFrom[3]; /*!< Location of observer's eyes */
2213    float ViewFromOrig[3]; /*!< Original Location of observer's eyes */
2214    float ViewCenter[3];   /*!< Center of observer's gaze */
2215    float ViewCenterOrig[3];   /*!< Original Center of observer's gaze */
2216    float ViewCamUp[3];   /*!< Camera Up direction vector */
2217    float ViewDistance; /*!< Viewing distance */
2218    float FOV; /*!< Field of View (affects zoom level)*/
2219    float Aspect;   /*!< Aspect ratio of the viewer*/
2220 } SUMA_ViewState_Hist;
2221 
2222 /* A structure to quickly locate DO in DOv
2223    Originally, the structure was nothing but an integer.
2224    But this integer becomes useless when SUMAg_DOv gets
2225    scrambled, mostly when certain objects get deleted.
2226    The more reliable string ID is now included along
2227    with a bunch of Refresh functions to reset the dov_ind
2228    via idcode_str directly */
2229 typedef struct {
2230    int dov_ind; /* index of object into SUMAg_DOv */
2231    char idcode_str[SUMA_IDCODE_LENGTH]; /* id of object in question */
2232 } SUMA_DO_LOCATOR;
2233 
2234 /*! structure defining the viewing state of the viewer window */
2235 typedef struct {
2236    char *Name; /*!< The name of the viewing state, fiducial, inflated, etc .. */
2237    SUMA_Boolean AnatCorrect; /* is this state anatomically correct? */
2238    char *Group; /*!< The group to which the viewing state belongs. */
2239    SUMA_DO_LOCATOR *MembDO;
2240    int N_MembDO; /*!< Number of members in MembDO.
2241                      Only SOs that are in MembDO can
2242                      be placed into RegisteredDO of the viewer in a particular
2243                      viewing state.*/
2244    SUMA_ViewState_Hist *Hist; /*!< Pointer to structure containing various
2245                                    parameter settings for that viewing state */
2246 } SUMA_ViewState;
2247 
2248 /*! structure containing the geometric settings for viewing the surface */
2249 typedef struct {
2250    float DimSclFac;
2251    float ViewFrom[3]; /*!< Location of observer's eyes */
2252    float ViewFromOrig[3]; /*!< Original Location of observer's eyes */
2253    float ViewCenter[3];   /*!< Center of observer's gaze */
2254    float ViewCenterOrig[3];   /*!< Original Center of observer's gaze */
2255    float ViewCamUp[3];   /*!< Camera Up direction vector */
2256    float ViewDistance; /*!< Viewing distance */
2257 
2258    float translateBeginX; /*!< User Input (mouse) X axis current position
2259                                for translation */
2260    float translateBeginY; /*!< User Input (mouse) Y axis current position
2261                                for translation */
2262    float translateDeltaX;   /*!< User Input (mouse) X axis position increment
2263                                  for translation */
2264    float translateDeltaY;   /*!< User Input (mouse) Y axis position increment
2265                                  for translation */
2266    float TranslateGain;   /*!< gain applied to mouse movement */
2267    float ArrowtranslateDeltaX;   /*!< User Input (Keyboard) X axis position
2268                                       increment for translation */
2269    float ArrowtranslateDeltaY;   /*!< User Input (Keyboard) X axis position
2270                                       increment for translation */
2271    GLfloat translateVec[3];      /*!< translation vector, in screen coordinates,
2272                                  equal to [translateDeltaX translateDeltaY].
2273                                  The third translation (Z dimension) is 0.0*/
2274    GLfloat RotaCenter[3];   /*!<Center of Rotation */
2275    float zoomDelta;       /*!< Zoom increment */
2276    float zoomBegin;    /*!< Current zoom level*/
2277    float spinDeltaX;   /*!< User Input (mouse) X axis position increment
2278                             for spinning*/
2279    float spinDeltaY;   /*!< User Input (mouse) Y axis position increment
2280                             for spinning*/
2281    float spinBeginX;  /*!< User Input (mouse) X axis current position
2282                            for spinning */
2283    float spinBeginY;  /*!< User Input (mouse) Y axis current position for
2284                            spinning */
2285    int MinIdleDelta;  /*!< minimum spinDeltaX or spinDeltaY to initiate momentum
2286                            rotation */
2287    float deltaQuat[4];   /*!< Quaternion increment */
2288    float currentQuat[4]; /*!< Current quaternion */
2289    float lastQuat[4]; /*!< Quaternion last time we displayed*/
2290    Boolean ApplyMomentum;   /*!< Turn momentum ON/OFF */
2291    Boolean ClippingPlane;   /*!< Turn clipping plane ON/OFF */
2292 
2293    float vLHpry[3];
2294    float vLHpry0[3];
2295    int LHlol;           /*!< if 1 then the left hemi starts up displayed
2296                              on the left side of the screen.
2297                              if -1 then left starts on the right.
2298                              This flag is only set when both left and
2299                              right surfaces are present */
2300 } SUMA_GEOMVIEW_STRUCT; /* DO NOT ADD POINTERS TO THIS STRUCT, otherwise you
2301                            need to change SUMA_CopyGeomViewStruct() and maybe
2302                            SUMA_DiffGeomViewStruct() */
2303 
2304 /*! structure holding the pointer the node color assignment and a bit more */
2305 typedef struct {
2306    SUMA_DO_Types do_type;  /*!< To check if this is a displayable object */
2307    int LinkedPtrType; /*!< Indicates the type of linked pointer */
2308    int N_links;   /*!< Number of links to this pointer */
2309    char owner_id[SUMA_IDCODE_LENGTH];   /*!< The id of whoever created that
2310                                        pointer. Might never get used.... */
2311 
2312    GLfloat *glar_ColorList_private; /*!< pointer to the 1D ColorList array */
2313    int N_glar_ColorList; /*!< Number of elements in glar_ColorList 4xNumber
2314                               of nodes in the surface or edges in a graph */
2315    char *idcode_str; /*!< string containing the idcode of the surface/object to
2316                          which glar_ColorList belongs*/
2317    SUMA_Boolean Remix; /*!< flag indicating that colors need to be remixed */
2318    int RemixID; /*!< An id of sorts updated each time remix is done */
2319    int per_sv_extra[SUMA_MAX_SURF_VIEWERS]; /* Some flags needed to perform extra
2320                                     tasks (binding textures) without needing to
2321                                     do the whole remix thing. This is needed when
2322                                     ColList is shared amongst multiple viewers to
2323                                     save memory */
2324 } SUMA_COLORLIST_STRUCT;
2325 
2326 typedef enum { SUMA_STD_ZERO_CENTERED, SUMA_SCALE_BOX } SUMA_AxisType;
2327 
2328 /*! structure defining an axis object */
2329 typedef struct {
2330       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
2331    SUMA_DO_Types do_type;
2332    char *idcode_str; /*! idcode of axis */
2333    char *Label;
2334 
2335       /* Begin specific fields */
2336    SUMA_AxisType atype;
2337    GLfloat XaxisColor[4] ;
2338    GLfloat YaxisColor[4] ;
2339    GLfloat ZaxisColor[4] ;
2340 
2341    GLfloat LineWidth;
2342    SUMA_STIPPLE Stipple; /*!< dashed or solid line */
2343 
2344    GLfloat XYZspan[3]; /*!< the axis will span +/- span[i]
2345                             in the three dimensions */
2346    GLfloat Center[3]; /*!< origin of axis */
2347    GLfloat BR[3][2]; /*!< Box Range values */
2348    double MTspace;   /*!< Major tick spacing */
2349    double MTsize;    /*!< Major tick size */
2350    double mTspace;   /*!< Minor tick spacing */
2351    double mTsize;    /*!< Minor tick size */
2352    int DoCross;      /*!< if 1 then ticks are centered on line.
2353                          (total length is same as *Tsize value)*/
2354 }SUMA_Axis;
2355 
2356 typedef struct {
2357    int N;   /*!< Number of points in vectors x and y */
2358    int Nalloc; /*!< Number of elements allocated for in x and y */
2359    int *x;  /*!< vector containing x coordinates */
2360    int *y;  /*!< vector containing y coordinates */
2361    float *NPv; /*!< vector containing x y z triplets of near plane selection points */
2362    float *FPv; /*!< vector containing x y z triplets of far plane selection points */
2363    int *SurfNodes; /*!< vector containing indices of nodes corresponding to the
2364                         intersection between line [ NPv[j] FPv[j] ] and surface object */
2365    int *SurfTri; /*!< vector containing indices of triangles corresponding to the
2366                         intersection between line [ NPv[j] FPv[j] ] and surface object */
2367    int *ProjectionOf; /*!< if ProjectionOf[31] = 78; it means SurfNodes[31]
2368                            is the intersection between line [ NPv[78] FPv[78] ] and the surface object. */
2369    int N_SurfNodes;  /*!< NUmber of SurfNodes in SurfNodes (always <= N) */
2370 
2371 } SUMA_OLD_BRUSH_STROKE; /*!< Structure containing the path of the mouse in the viewer window.
2372                         See functions SUMA_CreateBrushStroke(), SUMA_AddToBrushStroke(),
2373                         SUMA_ClearBrushStroke(), SUMA_ShowBrushStroke()*/
2374 
2375 
2376 typedef struct {
2377    float x; /*!< x screen coordinate. This is typically an integer value except in places of interpolation*/
2378    float y; /*!< y screen coordinate. This is typically an integer value except in places of interpolation*/
2379 
2380    float NP[3];   /*!< x y z triplet of near plane selection point */
2381    float FP[3];   /*!< x y z triplet of far plane selection point */
2382 
2383    int SurfNode;  /*!< index of node corresponding to the
2384                         intersection between line [NP FP] and surface object.
2385                         initialized to -1 */
2386    int SurfTri;   /*!< index of triangle corresponding to the
2387                         intersection between line [NP FP] and surface object.
2388                         initialized to -1 */
2389    SUMA_Boolean Decimated; /*!< Flag to indicate if datum was obtained by a mouse trace (NOPE)
2390                                or through decimation (YUP)*/
2391 } SUMA_BRUSH_STROKE_DATUM; /*!< Data structure for the doubly linked version of brushstroke.  */
2392 
2393 typedef enum {  SUMA_NO_WAX, SUMA_THREE_WAX, SUMA_THREE_TEXT_WAX, SUMA_BOX_WAX, SUMA_BOX_TEXT_WAX, SUMA_N_WAX_OPTIONS } SUMA_WORLD_AXIS_TOGGLE_METHODS;
2394 /*! structure defining the state of a viewer window */
2395 
2396 typedef struct {
2397    char Label[256];
2398    int ALPHA_TEST;
2399    int DEPTH_TEST;
2400    int COLOR_MATERIAL;
2401    int TEXTURE_2D;
2402    int TEXTURE_3D_EXT;
2403    int TEXTURE_3D;
2404    int TEXTURE_GEN_S;
2405    int TEXTURE_GEN_T;
2406    int TEXTURE_GEN_R;
2407    int CLIP_PLANE0;
2408    int CLIP_PLANE1;
2409    int CLIP_PLANE2;
2410    int CLIP_PLANE3;
2411    int CLIP_PLANE4;
2412    int CLIP_PLANE5;
2413    int LIGHTING;
2414    int LIGHT0;
2415    int LIGHT1;
2416    int LIGHT2;
2417    int BLEND;
2418    int LINE_SMOOTH;
2419    int ColMatParam;
2420    int ColMatFace;
2421    GLfloat CurCol[4];
2422 } SUMA_EnablingRecord;
2423 
2424 /* a structure for the list of pickable objects (excluding surfaces) */
2425 typedef struct {
2426    SUMA_DO_Types ref_do_type;
2427    char *ref_idcode_str;
2428    char *idcode_str;
2429 
2430    char *primitive;
2431    char *variant;
2432    char *Label;
2433    long int i0;
2434    long int i1;
2435    long int idatum;
2436 } SUMA_COLID_OFFSET_DATUM;
2437 
2438 #define SUMA_NET_BUN          0  /* selectedNetworkBundle */
2439 #define SUMA_VOL_I            0  /* selectedVoxelI */
2440 #define SUMA_SURF_TRI         0  /* selected triangle */
2441 #define SUMA_ENODE_0          0  /* 1st point/node forming edge */
2442 
2443 #define SUMA_BUN_TRC          1  /* selectedBundleTract */
2444 #define SUMA_VOL_J            1  /* selectedVoxelJ */
2445 #define SUMA_ENODE_1          1  /* 2st point/node forming edge */
2446 
2447 #define SUMA_TRC_PNT          2  /* selectedTractPoint */
2448 #define SUMA_VOL_K            2  /* selectedVoxelK */
2449 
2450 #define SUMA_NET_TRC          3  /* selectedNetworkTract */
2451 #define SUMA_VOL_IJK          3  /* selectedVoxelIJK, 1D index */
2452 
2453 #define SUMA_VOL_SLC_NUM      4  /* selected slice, 1D index */
2454 #define SUMA_VOL_SLC_VARIANT  5  /* selected slice, 1D index */
2455 
2456 #define SUMA_N_IALTSEL_TYPES  6 /* If this goes over 15, make sure you
2457                                  start using something bigger than
2458                                  iv15 in SUMA_Engine Calls */
2459 
2460 #define SUMA_VOL_SLC_EQ0 0 /* 1st coefficient of plane equation */
2461 
2462 #define SUMA_VOL_SLC_EQ1 1 /* 2nd coefficient of plane equation */
2463 
2464 #define SUMA_VOL_SLC_EQ2 2 /* 3rd coefficient of plane equation */
2465 
2466 #define SUMA_VOL_SLC_EQ3 3 /* 4th coefficient of plane equation */
2467 
2468 #define SUMA_N_DALTSEL_TYPES 4 /* If this goes over 15, make sure you
2469                                  start using something bigger than
2470                                  fv15 in SUMA_Engine Calls */
2471 
2472 /*
2473    *************** Convolution utilities ***************
2474    based on example in glut's convolve.c by
2475    Tom McReynolds, SGI
2476    *****************************************************
2477 */
2478 /* convolution choices */
2479 typedef enum {
2480       SUMA_CONV_NONE,
2481       SUMA_CONV_BOX_3X3,
2482       SUMA_CONV_BOX_5X5,
2483       SUMA_CONV_SOBEL_X,
2484       SUMA_CONV_LAPLACE,
2485       SUMA_N_CONV_MODES,
2486 } SUMA_CONV_MODES;
2487 
2488 /* Filter contents and size */
2489 typedef struct {
2490   GLfloat scale; /* 1/scale applied to image to prevent overflow */
2491   GLfloat bias; /* for biasing images */
2492   int rows;
2493   int cols;
2494   GLfloat *array;
2495 } SUMA_C_FILTER;
2496 
2497 /* *************** End Convolution utilities *************** */
2498 
2499 typedef struct {
2500       /* variables copied from the event structs */
2501    int ktype;         /* Event type (Kev.type) */
2502    int kstate;        /* Event state (Kev.state) */
2503    char transl[16];  /* Translated event characters (buffer) */
2504    KeySym keysym;       /* key symbol (keysym) */
2505    int mtype;         /* Event type (Mev.type) */
2506    int mstate;        /* Event state (Mev.state) */
2507    int bButton;      /* (Bev.button) */
2508    int mButton;      /* (Mev.button) */
2509    Time bTime;       /* (Bev.time) */
2510    Time mTime;       /* (Mev.time) */
2511    int mX;
2512    int mY;
2513    int bX;
2514    int bY;
2515       /* inferred variables */
2516    int set;
2517    byte b1;
2518    byte b2;
2519    byte b3;
2520    byte b4;
2521    byte b5;
2522    byte b6;
2523    byte b7;
2524    byte b1m;
2525    byte b2m;
2526    byte b3m;
2527    byte b4m;
2528    byte b5m;
2529    byte Shift;
2530    byte Control;
2531    byte Mod1;
2532    byte Mod2;
2533    byte Mod3;
2534    byte Mod4;
2535    byte Mod5;
2536    byte AppleAltOpt;
2537    byte DoubleClick;
2538    Time mDelta;
2539    int mDeltaX;
2540    int mDeltaY;
2541    int bDeltaX;
2542    int bDeltaY;
2543 } SUMA_EVENT; /* A record of last event sent to SUMA_input.
2544                  comments in () above refer to equiv. variables
2545                  in SUMA_input() function */
2546 
2547 typedef struct {
2548    char *ado_idcode_str;   /* id of ado that was picked */
2549    char *primitive;        /* Type of object selected, for graphs, for
2550                               example, it could be an edge, or a node
2551                               Not all primitives carry data*/
2552    long int primitive_index;
2553    long int datum_index;   /* If intersection is found for something
2554                               that carries an elementary data
2555                               then this value is set.*/
2556    int ignore_same_datum;
2557 
2558    float PickXYZ[3]; /* Location of index */
2559 
2560    long int  iAltSel[SUMA_N_IALTSEL_TYPES];
2561    double    dAltSel[SUMA_N_DALTSEL_TYPES];
2562 
2563    char *dset_idcode_str; /* ID of volume where selection was made,
2564                       if a volume was selected */
2565    SUMA_EVENT *evr; /* A record of the pick event at the time PR was created */
2566 } SUMA_PICK_RESULT; /* Structure holding results of pointer selection*/
2567 
2568 
2569 typedef struct {
2570    int N_DO;   /*!< Total number of surface objects registered with the viewer */
2571    SUMA_DO_LOCATOR *RegistDO;
2572    #if 0 /* Replaced with SUMA_DO_LOCATOR above*/
2573    int *RegisteredDO;    /*!< RegisteredDO[i] (i=0..N_DO) contains Object indices
2574                               into DOv for DOs visible in the surface viewer*/
2575    char **RegisteredDOid; /*!< A more reliable version of RegisteredDO.
2576                               RegisteredDO starts to fail miserably when objects
2577                               are deleted from SUMAg_DOv thereby altering the
2578                               order of objects inside SUMAg_DOv.
2579                               The same problem needs to be dealt with in MembDO*/
2580    #endif
2581 
2582 
2583    SUMA_Boolean Record; /*!< Set record mode */
2584    SUMA_Boolean ShowLeft; /*!< Show left side surfaces */
2585    SUMA_Boolean ShowRight; /*!< Show right side surfaces */
2586 
2587    SUMA_COLORLIST_STRUCT **ColList; /*!< pointer to structures containing
2588                         NodeColorLists for surfaces listed in RegisteredDO */
2589    int N_ColList; /*!< Number of structures in ColList */
2590 
2591    SUMA_STANDARD_VIEWS StdView; /*!< viewing mode, for 2D or 3D */
2592    SUMA_GEOMVIEW_STRUCT *GVS; /*! pointer to structures containing
2593                                   geometric viewing settings */
2594    int N_GVS; /*!< Number of different geometric viewing structures */
2595    SUMA_GEOMVIEW_STRUCT *GVS_last_PickMode;
2596                /*! A snapshot of GVS the last time display was done
2597                    in DO_PickMode */
2598    short verbose;   /*!< Verbosity of viewer */
2599 
2600    SUMA_X *X; /*!< structure containing X widget midgets */
2601 
2602    DList *SelAdo; /* A list of DOs intersected by selection line */
2603    char *LastSel_ado_idcode_str;
2604 
2605    int ShowSelectedDatum;
2606    int ShowSelectedFaceSet;
2607    int ShowSelectedEdge;
2608    int ortho; /*!< Orthographic (1) or perspective (0, default) projection */
2609    int ShowLabelAtXhair; /*!< Show label at location of cross hair */
2610    float Aspect;   /*!< Aspect ratio of the viewer*/
2611    int wWindWidth;   /*!< Width of whole window */
2612    int wWindHeight;   /*!< Height of whole window */
2613    int DrawAreaHeightOffset; /*!< Offset of GLX draw area height from enclosing
2614                                   window */
2615    int DrawAreaWidthOffset; /*!< Offset of GLX draw area width from enclosing
2616                                   window */
2617    float ZoomCompensate; /*!< Compensate mouse movements by zoom factor */
2618    float *FOV; /*!< Field of View (affects zoom level, there is a
2619                     separate FOV for each ViewState)*/
2620    float *auto_FOV_val; /*!< Field of view computed on selectable content */
2621    float *FOV_last_PickMode; /*!< FOV last time we picked a DO */
2622    float FOV_original; /*!< Original field of view of viewer */
2623    float ArrowRotationAngle; /*!< Angle to rotate surface by when arrows
2624                                  are used.
2625                                  Units are in radians */
2626    float KeyZoomGain; /*!< gain for zooming in and out with the 'z' and 'Z' keys.
2627                            Typical range from 0 to 0.5. Must be < 1*/
2628    float KeyNodeJump; /*!< Number of node jumps to do in response to 'alt+arrow'
2629                            clicks. Default is 1 */
2630    byte BF_Cull; /*!< flag for backface culling */
2631    SUMA_RENDER_MODES PolyMode; /*!< polygon viewing mode, SRM_Fill,
2632             SRM_Line, SRM_Points
2633             There is a similar field for each surface object to
2634             allow independent control for each surface. If the rendering mode
2635             is specified for a certain surface, it takes precedence over the
2636             one specified here*/
2637    SUMA_TRANS_MODES TransMode;
2638    SUMA_DO_DRAW_MASK DO_DrawMask; /*!< What to draw of displayable objects */
2639    int MouseMode; /* Behavior when mouse gets busy */
2640    char *MouseMode_ado_idcode_str;
2641 
2642    float Back_Modfact; /*!< Factor to apply when modulating foreground
2643                color with background intensity
2644                background does not modulate foreground,
2645                Color = Fore * avg_Bright * AttenFactor; (w/ 0 <= avg_Bright <=1)
2646                a good setting is such that
2647       SUMA_BACKGROUND_ATTENUATION_FACTOR * SUMA_DIM_AFNI_COLOR_FACTOR = 1
2648                Watch for saturation effects!  */
2649 
2650    float ContThick;  /*!< Thickness of contours drawn on datasets */
2651    int lit_for;   /*! 1 = lit for surfaces of normdir = 1, -1 for normdir = -1,
2652                       0 for not set. */
2653    GLfloat light0_position[4]; /*!< Light 0 position:
2654                                     1st 3 vals --> direction of light .
2655                                     Last value is 0 -->  directional light*/
2656    GLfloat light1_position[4]; /*!< Light 1 position */
2657    GLfloat light0_color[4];   /*!< Light 0 color */
2658    GLfloat lmodel_ambient[4]; /*!< ambient light model */
2659 
2660    GLfloat dim_spe;  /*!< Color dimming factors for light properties */
2661    GLfloat dim_dif;
2662    GLfloat dim_emi;
2663    GLfloat dim_amb;
2664 
2665    GLfloat clear_color[4]; /*!< viewer background color */
2666 
2667    SUMA_Boolean Open; /*! Viewer visible to the human eye */
2668    int ShowEyeAxis ; /*!< ShowEyeAxis */
2669    int ShowMeshAxis; /*!< ShowMeshAxis (attached to each surface)*/
2670    int ShowWorldAxis; /*!< ShowWorldAxis */
2671    SUMA_Axis *WorldAxis;   /*!< pointer to world coordinate axis  */
2672    int ShowCrossHair; /*!< ShowCrossHair */
2673    SUMA_Boolean ShowForeground;    /*!< Flag for showing/not showing
2674                                         foreground colors */
2675    SUMA_Boolean ShowBackground; /*!< Flag for showing/not showing
2676                                      background colors */
2677    SUMA_Boolean UsePatchDims; /*!< Flag for using patch based dimensions
2678                                    (rather than entire nodelist) */
2679 
2680    #if 0 /* considering rendering this obsolete */
2681    int Focus_SO_ID; /*!< index into SUMAg_DOv of the surface currently in focus,
2682                         -1 for nothing*/
2683    #endif
2684    int Focus_DO_ID; /*!< index into SUMAg_DOv of the Displayable Object
2685                            currently in focus -1 for nothing*/
2686 
2687    int PickPix[2]; /*!< Location of click in pixel buffer */
2688    GLdouble Pick0[3];   /*!< Click location in World coordinates, at z = 0
2689                            (near clip plane)*/
2690    GLdouble Pick1[3];   /*!< Click location in World coordinates,
2691                               at z = 1.0 (far clip plane)*/
2692    GLdouble Pcenter_close[3];  /*!< Center of screen in World coordinates ,
2693                                     at z = 0 (near clip plane)*/
2694    GLdouble Pcenter_far[3];    /*!< Center of screen in World coordinates ,
2695                                     at z = 1 (near far plane)*/
2696    GLdouble Plist_close[3];   /*!< lists of points on screen in world coordinates
2697                   at z = 0.
2698                   it holds N/3 points where N is the array length
2699                   At the moment, all I need is one point, the lower left
2700                   Should more be needed, I will add them to the list and
2701                   document them here.*/
2702    SUMA_CrossHair *Ch; /*!< Pointer to Cross Hair structure */
2703    SUMA_Axis *WAx;  /*!< Pointer to world axis */
2704 
2705    SUMA_ViewState *VSv; /*!< Vector of Viewing State Structures */
2706    int N_VSv; /*!< Number of Viewing State structures */
2707    char *State; /*!< The current state of the viewer.
2708       This variable should no be freed since it points to locations within VSv*/
2709    int iState; /*!< index into VSv corresponding to State */
2710    int LastNonMapStateID; /*!< Index into the state in VSv from which a
2711                               toggle to the mappable state was initiated */
2712 
2713    SUMA_Boolean isShaded; /*!< YUP if the window is minimized or shaded,
2714                               NOPE if you can see its contents */
2715 
2716    SUMA_Boolean LinkAfniCrossHair; /*!< YUP if the cross hair location is to be
2717                         sent (and accepted from AFNI, when the stream is open) */
2718    SUMA_Boolean ResetGLStateVariables; /*!< YUP if you need to run the function
2719             that resets the Eye Axis before display.
2720             see functions SUMA_display and SUMA_OpenGLStateReset for more info */
2721    SUMA_Boolean NewGeom; /*!< YUP if viewer has new geometry in it and
2722                            needs to have its default viewing settings updated */
2723    DList *BS; /*!< The new version of BrushStroke, in doubly linked list form */
2724 
2725    char *CurGroupName; /*!< current name of group */
2726    int iCurGroup; /*!< index into GroupList (stored in SUMAg_CF)
2727                         of current group of Surface Viewer */
2728    SUMA_REDISPLAY_CAUSE rdc;  /*!< Why has a redisplay been requested */
2729    SUMA_BLEND_MODES Blend_Mode; /*!< blending mode */
2730    int FreezeZoomXstates; /*!< if 1, keep zoom constant across states */
2731 
2732    int Do_3Drender;
2733    SUMA_EnablingRecord SER;
2734 
2735    int DO_PickMode; /*! Picking mode for selecting non-surface objects */
2736    DList *pick_colid_list;
2737    GLubyte *pickrenpix4; /*! An array holding the RGBA rendering buffer */
2738 
2739    int LoadedTextures[SUMA_MAX_DISPLAYABLE_OBJECTS+1];
2740 
2741    SUMA_C_FILTER *C_filter;
2742    SUMA_CONV_MODES C_mode;
2743 
2744    int otseq[N_DO_TYPES]; /* Object type sequence
2745                              This is used to control the order in which
2746                              different object types are rendered.
2747                              Default is: VO_type, SO_type, GRAPH_LINK_type*/
2748    int N_otseq;           /* Number of types specified in otseq,
2749                              Default is 3 types*/
2750    int PryAx;             /* Prying axis. 3 == Z axis, 2 == Y axis */
2751 
2752    float clippingPlaneIncrement; // PDL
2753 
2754 } SUMA_SurfaceViewer;
2755 
2756 /*! structure defining an EngineData structure */
2757 typedef struct {
2758    SUMA_ENGINE_CODE CommandCode; /*!< Code of command to be executed by
2759          SUMA_Engine function,
2760          this is the same as the _Dest fields for each variable type.
2761          However, the _Dest fields are left as a way to make sure that
2762          the user has correctly initialized EngineData for a certain command.*/
2763 
2764    void *Srcp; /*!<  Pointer to data structure of the calling source,
2765                      typically, a typecast version of SUMA_SurfaceViewer * */
2766    SUMA_ENGINE_SOURCE Src; /*!<  Source of command. This replaces the _Source
2767                                  fields in the older version of the structure */
2768 
2769    float fv3[3]; /*!< Float vector, 3 values */
2770    SUMA_ENGINE_CODE fv3_Dest; /*!<  float3 vector destination */
2771    SUMA_ENGINE_SOURCE fv3_Source; /*!< OBSOLETE float3 vector source */
2772 
2773    int iv3[3];      /*!< Integer vector, 3 values */
2774    SUMA_ENGINE_CODE iv3_Dest;  /*!<  Integer3 vector destination */
2775    SUMA_ENGINE_SOURCE iv3_Source;  /*!<OBSOLETE  Integer3 vector source */
2776 
2777    float fv15[15]; /*!< Float vector, 15 values */
2778    SUMA_ENGINE_CODE fv15_Dest; /*!<  float15 vector destination */
2779    SUMA_ENGINE_SOURCE fv15_Source; /*!< OBSOLETE float15 vector source */
2780 
2781    float fv200[200]; /*!< Float vector, 200 values */
2782    SUMA_ENGINE_CODE fv200_Dest; /*!<  float200 vector destination */
2783    SUMA_ENGINE_SOURCE fv200_Source; /*!< OBSOLETE float15 vector source */
2784 
2785    int iv15[15];/*!< Integer vector, 15 values */
2786    SUMA_ENGINE_CODE iv15_Dest;/*!<  Integer15 vector destination */
2787    SUMA_ENGINE_SOURCE iv15_Source; /*!< OBSOLETE Integer15 vector source */
2788 
2789    int iv200[200];/*!< Integer vector, 200 values */
2790    SUMA_ENGINE_CODE iv200_Dest;/*!<  Integer200 vector destination */
2791    SUMA_ENGINE_SOURCE iv200_Source; /*!< OBSOLETE Integer200 vector source */
2792 
2793    int i;      /*!< integer */
2794    SUMA_ENGINE_CODE i_Dest;   /*!<  integer destination */
2795    SUMA_ENGINE_SOURCE i_Source; /*!< OBSOLETE integer source */
2796 
2797    float f; /*!< float, ingenious ain't it! */
2798    SUMA_ENGINE_CODE f_Dest; /*!<  float destination */
2799    SUMA_ENGINE_SOURCE f_Source; /*!< OBSOLETE float source */
2800 
2801    char s[SUMA_MAX_STRING_LENGTH]; /*!< string */
2802    SUMA_ENGINE_CODE s_Dest; /*!<  string destination */
2803    SUMA_ENGINE_SOURCE s_Source; /*!< OBSOLETE string source */
2804 
2805    int *ip; /*!< integer pointer */
2806    SUMA_ENGINE_CODE ip_Dest; /*!<  integer pointer destination */
2807 
2808    float *fp; /*!< float pointer */
2809    SUMA_ENGINE_CODE fp_Dest; /*!< float pointer destination */
2810 
2811    char *cp; /*!< char pointer */
2812    SUMA_ENGINE_CODE cp_Dest; /*!< character pointer destination */
2813 
2814    float **fm; /*!< float matrix pointer */
2815    SUMA_Boolean fm_LocalAlloc; /*!< Locally allocated matrix pointer ?
2816                   (if it is then it is freed in SUMA_ReleaseEngineData ) */
2817    SUMA_ENGINE_CODE fm_Dest; /*!<  destination of fm */
2818    SUMA_ENGINE_SOURCE fm_Source; /*!< OBSOLETE source of fm*/
2819 
2820    int **im; /*!< Same dance as fm but for integers */
2821    SUMA_Boolean im_LocalAlloc;
2822    SUMA_ENGINE_CODE im_Dest; /*!<  destination of im */
2823    SUMA_ENGINE_SOURCE im_Source; /*!< OBSOLETE source of im */
2824 
2825    SUMA_IVEC *ivec; /*!< Same dance as fm but for integers */
2826    SUMA_Boolean ivec_LocalAlloc;
2827    SUMA_ENGINE_CODE ivec_Dest; /*!<  destination of im */
2828    SUMA_ENGINE_SOURCE ivec_Source; /*!< OBSOLETE source of im */
2829 
2830    SUMA_FVEC *fvec; /*!< Same dance as fm but for integers */
2831    SUMA_Boolean fvec_LocalAlloc;
2832    SUMA_ENGINE_CODE fvec_Dest; /*!<  destination of im */
2833    SUMA_ENGINE_SOURCE fvec_Source; /*!< OBSOLETE source of im */
2834 
2835    void *vp; /*!< pointer to void */
2836    SUMA_ENGINE_CODE vp_Dest; /*!<  destination of fm */
2837    SUMA_ENGINE_SOURCE vp_Source; /*!< OBSOLETE source of fm*/
2838 
2839    int N_rows; /*!< Number of rows in fm or im */
2840    int N_cols; /*!< Number of colums in fm or im */
2841 
2842    NI_group *ngr;
2843    SUMA_ENGINE_CODE ngr_Dest; /*!<  destination of ngr */
2844    SUMA_ENGINE_SOURCE ngr_Source; /*!< OBSOLETE source of ngr*/
2845 
2846    NI_element *nel;
2847    SUMA_ENGINE_CODE nel_Dest; /*!<  destination of nel */
2848    SUMA_ENGINE_SOURCE nel_Source; /*!< OBSOLETE source of nel*/
2849 
2850 } SUMA_EngineData;
2851 
2852 
2853 
2854 /*! structure that contains the output of SurfNorm function */
2855 #define SUMA_SurfNorm_struct
2856 typedef struct {
2857    int N_Node; /*!< Number of nodes, 1st dim of NodeNormList*/
2858    int N_Face;/*!< Number of facesets, 1st dim of FaceNormList*/
2859    float *FaceNormList ; /*!< N_Face x 3 vector (was matrix prior to SUMA 1.2)
2860             containing normalized normal vectors for each triangular faceset*/
2861    float *NodeNormList ; /*!< N_Node x 3 vector (was matrix prior to SUMA 1.2)
2862             containing normalized normal vectors for each node*/
2863 } SUMA_SURF_NORM; /*!< structure that contains the output of SurfNorm function */
2864 
2865 /*! structure that contains the output of SUMA_MemberFaceSets function */
2866 #define SUMA_MemberFaceSets_struct
2867 typedef struct {
2868    SUMA_DO_Types do_type;  /*!< To check if this is a displayable object */
2869    int LinkedPtrType; /*!< Indicates the type of linked pointer */
2870    int N_links;   /*!< Number of links to this pointer */
2871    char owner_id[SUMA_IDCODE_LENGTH];   /*!< The id of whoever created
2872                                  that pointer.*/
2873 
2874    byte *nodemask; /*! Pointer to  nodes in the mask */
2875    int N_nz_nodemask; /*! number of non-zero values in mask */
2876    DList *DrwPtchs; /*! Pointer to a list of drawing patches */
2877    int PatchRegenID; /*! An integer that gets incremented anytime you want
2878                          the drawing patches to get regenerated. */
2879    int PatchGenID; /*! if != PatchRegenID then regenerate patches and set
2880                          to PatchRegenID */
2881    char *user_exp; /*!< User masking expression */
2882    char *cmask_exp; /*!< User expression, preppred for cmask evaluation */
2883    char *last_cmask_exp; /*!< Last expression evaluated to form nodemask */
2884 } SUMA_DRAW_MASKS; /*!< Drawing masks formed on the fly */
2885 
2886 typedef struct {
2887    SUMA_DO_Types do_type;  /*!< To check if this is a displayable object */
2888    int LinkedPtrType; /*!< Indicates the type of linked pointer */
2889    int N_links;   /*!< Number of links to this pointer */
2890    char owner_id[SUMA_IDCODE_LENGTH];   /*!< The id of whoever created
2891                                  that pointer. Might never get used.... */
2892 
2893    char *idcode_str;
2894    int N_Memb_max;/*!< Maximum number of Facesets any node belonged to*/
2895    int Nnode; /*! Total number of nodes examined (0..Nnode-1) */
2896    int **NodeMemberOfFaceSet ; /*!< Nnode x N_Memb_max matrix containing
2897                                     for each row i, the indices of the
2898                                     facesets containing node i*/
2899    int *N_Memb ; /*!< Nnode x 1 vetor containing for each node i,
2900                       the number of facesets that contain it*/
2901 } SUMA_MEMBER_FACE_SETS; /*!< structure that contains the output of
2902                               SurfNorm function */
2903 
2904 
2905 /*! structure containing results of intersection of a ray with triangles */
2906 typedef struct {
2907    int N_el; /*!< Number of elements in each vector */
2908    SUMA_Boolean *isHit;   /*!< Is the triangle hit ? */
2909    float *t;   /*!< SIGNED Distance from ray source to triangle */
2910    float *u;   /*!< location of intersection in triangle in
2911                    Barycentric coordinates, V0P = u V0V1 + vV0V2*/
2912    float *v;   /*!< location of intersection in triangle */
2913    int ifacemin; /*!< index of the faceset closest (NOT SIGNED, abs(t))
2914                       to the ray's origin */
2915    int ifacemax; /*!< index of the faceset farthest (NOT SIGNED, abs(t))
2916                       from the ray's origin */
2917    int N_hits; /*!< Number of intersections between ray and surface */
2918    int N_poshits; /*!< Number of intersections such that t is positive */
2919    float P[3]; /*!< XYZ of intersection with ifacemin */
2920    float d; /*!< Distance from the closest node in ifacemin to P */
2921    int inodemin; /*!< node index (into NodeList)that is closest to P  */
2922    int inodeminlocal; /*!< node in FaceSet[ifacemin] that is closest to P ,
2923                   inodemin = FaceSet[ifacemin][inodeminlocal]*/
2924 } SUMA_MT_INTERSECT_TRIANGLE;
2925 
2926 typedef enum { BAD_WARP=-1, NO_WARP, ROTATE_WARP, VOLREG_WARP,
2927                TAGALIGN_WARP,  WARPDRIVE_WARP, ALLINEATE_WARP,
2928                N_WARP_TYPES } SUMA_WARP_TYPES;
2929 
2930 /*! Structure defining the surface's volume parent info */
2931 typedef struct {
2932    char *idcode_str; /*!< the id of the vol par element */
2933    int isanat; /*!< 1 if parent volume is of type anat */
2934    int nx, ny, nz; /*!< number of voxels in the three dimensions */
2935    float dx, dy, dz; /*!< delta x, y, z in mm */
2936    float xorg, yorg, zorg; /*!< voxel origin in three dimensions */
2937    char *prefix; /*!< parent volume prefix */
2938    char *headname;
2939    char *filecode; /*!< parent volume prefix + view */
2940    char *dirname; /*!< parent volume directory name */
2941    char *vol_idcode_str; /*!< idcode string OF parent volume*/
2942    char *vol_idcode_date; /*!< idcode date */
2943    int xxorient, yyorient, zzorient; /*!< orientation of three dimensions*/
2944    double *CENTER_OLD; /*!< pointer to the named attribute (3x1) in the
2945                            .HEAD file of the experiment-aligned Parent Volume */
2946    double *CENTER_BASE; /*!< pointer to the named attribute (3x1) in the
2947                            .HEAD file of the experiment-aligned Parent Volume */
2948    double *MATVEC; /*!< pointer to the warp attribute (12x1) in the .HEAD file
2949                         of the experiment-aligned Parent Volume */
2950    SUMA_WARP_TYPES MATVEC_source;
2951 #if 0
2952    float *VOLREG_MATVEC; /*!< pointer to the named attribute (12x1) in the
2953                            .HEAD file of the experiment-aligned Parent Volume */
2954    float *TAGALIGN_MATVEC; /*!< pointer to the named attribute (12x1) in the
2955                            .HEAD file of the tag aligned Parent Volume */
2956    float *WARPDRIVE_MATVEC; /*!< pointer to the named attribute (12x1) in the
2957                            .HEAD file of the warpdrive aligned Parent Volume */
2958    float *ALLINEATE_MATVEC; /*!< pointer to the named attribute (12x1) in the
2959                            .HEAD file of the warpdrive aligned Parent Volume */
2960    float *ROTATE_MATVEC; /*!< pointer to the named attribute (12x1) in the
2961                            .HEAD file of the rotate aligned Parent Volume */
2962 #endif
2963    int Hand; /*!< Handedness of axis 1 RH, -1 LH*/
2964 } SUMA_VOLPAR;
2965 
2966 typedef struct {
2967    SUMA_OVERLAYS *Overlay; /*!< pointer to color overlay structures */
2968 } SUMA_OVERLAY_LIST_DATUM;   /*!< a structure used to create linked lists
2969                                   of SO->Overlays and co */
2970 
2971 typedef enum {  ADD_BEFORE=-1, ADD_NOT=0, ADD_AFTER=1 } SUMA_VISX_ADD_POSITIONS;
2972 typedef enum {  UNDO_XFORM=0, FORWARD_XFORM=1 } SUMA_VISX_XFORM_DIRECTIONS;
2973 typedef enum {  ID=0, SHIFT=1, AFFINE=2, DISP=3 } SUMA_VISX_XFORM_TYPE;
2974 
2975 typedef struct {
2976    SUMA_VISX_XFORM_TYPE XformType;
2977                      /*!< Is it identity (0), shift (1), or affine (2),
2978                         (3) displacement field*/
2979    double Xform[4][4]; /*!< The augmented affine transform */
2980    float *dxyz;   /* displacement field, only set with XformType == 4 */
2981    char label[64]; /* some string identifier */
2982 } SUMA_VIS_XFORM_DATUM;
2983 
2984 /*! Structure for defining spatial transformations for visualization purposes */
2985 typedef struct {
2986    DList *Xchain;
2987    int Applied; /*!< Xform has been applied to coords */
2988    float *XformedCoords; /*!< Tranformed coords. If NULL and XformApplied,
2989                               it means the results of the transform have
2990                               been stored in the surface's NodeList */
2991 } SUMA_VIS_XFORM;
2992 
2993 /*! structure defining a Surface Object */
2994 typedef struct {
2995       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
2996    SUMA_DO_Types do_type;
2997    char *idcode_str; /*!< string containing the idcode of the surface */
2998    char *Label; /*!< string containing a label for the surface.
2999                      Used for window titles and saved image names */
3000 
3001 
3002    /* Begin by fields that are generic
3003                   and need to be accessed from AFNI
3004                   Keep in sync with AFNI_SurfaceObject STRUCT
3005                   AND function SUMA_MergeAfniSO_In_SumaSO
3006    **********  BEGIN KEEP THIS SECTION TIGHT
3007                WITH AFNI_SURFACEOBJECT STRUCT ***********
3008    */
3009    int N_Node; /*!< Number of nodes in the SO */
3010    int NodeDim; /*!< Dimension of Node coordinates 3 for 3D only 3
3011                      is used for now, with flat surfaces having z = 0*/
3012    int EmbedDim; /*!<   Embedding dimension of the surface,
3013                         2 for flat surfaces 3 for ones with non zero
3014                         curvature. */
3015    float *NodeList; /*!< N_Node x 3 vector containing the XYZ node coordinates.
3016                         If NodeDim is 2 then the third column is all zeros
3017                         Prior to SUMA  1.2 this used to be a 2D matrix
3018                         (a vector of vectors) */
3019 
3020    int N_FaceSet; /*!< Number of polygons defining the surface  */
3021    int FaceSetDim; /*!< Number of sides on the polygon */
3022    int *FaceSetList; /*!<  N_FaceSetList x FaceSetDim vector describing
3023                            the polygon set that makes up the SO.
3024                            Each row contains the indices (into NodeList) of
3025                            the nodes that make up a polygon
3026                            Prior to SUMA  1.2 this used to be a 2D matrix
3027                            (a vector of vectors) */
3028    /*
3029    **********  END KEEP THIS SECTION TIGHT
3030                WITH AFNI_SurfaceObject STRUCT
3031                in suma_datasets.h     ***********
3032    */
3033 
3034    /* Include also AFNI_SurfaceObject which would contain GIFTI's information
3035    with pointers stolen for list above set to NULL
3036       (see SUMA_MergeAfniSO_In_SumaSO)  */
3037    NI_group *aSO;
3038 
3039    SUMA_SO_File_Type FileType; /*!< Type of Surface file */
3040    SUMA_SO_File_Format FileFormat; /*!< Format of Surface file ascii or binary*/
3041    SUMA_FileName Name; /*!< Directory and Name of surface object file (SO) */
3042    SUMA_FileName Name_coord; /*!< Directory and Name of surface coordinate
3043                                  file (for SureFit files) */
3044    SUMA_FileName Name_topo; /*!< Directory and Name of surface topology file
3045                                 (for SureFit files)*/
3046    SUMA_FileName SpecFile; /*!< To be added for use in AFNI's
3047                                  mapping interface*/
3048 
3049    char *parent_vol_idcode_str; /*!< IDcode of the volume from which the surface
3050                                      was created.
3051                                      Called SurfVol (NOT SurfVol_AlndExp)
3052                                     That ID does not usually refer to the volume
3053                                     from which VolPar is created.
3054                                     Except in the case
3055                                     where you are viewing the surfaces on
3056                                     the orignal volume (SurfVol) then this
3057                                     field and
3058                                     SurfVol (afni dset *) ->idcode.str and
3059                                     VolPar->vol_idcode_str should be identical*/
3060    char *facesetlist_idcode_str;   /*!< ID of facesets element */
3061    char *nodelist_idcode_str; /*!< ID of nodelist element */
3062    char *facenormals_idcode_str; /*!< ID of facenormals element */
3063    char *nodenormals_idcode_str; /*!< ID of nodenormals element */
3064    char *polyarea_idcode_str; /*!< ID of polygon areas element */
3065    char *Name_NodeParent; /*!<   Node parent of the SO.
3066                                  Node Indices of SO are into NodeList
3067                                  matrix of the NodeParent SO*/
3068    char *Group_idcode_str;  /*!< IDcode of group */
3069    char *Group;   /*!<  Group the surface belongs to,
3070                         like Simpsons H. (aka. SubjectLabel)*/
3071    char *State; /*!< State of SO (like inflated, bloated, exploded) */
3072 
3073    SUMA_SO_SIDE Side; /*!< Left/right */
3074    SUMA_GEOM_TYPE isSphere;  /*!< yes/no */
3075    float SphereRadius; /*!< If a sphere, then this is its radius */
3076    float SphereCenter[3]; /*!< If a sphere, then this it is center */
3077    SUMA_Boolean AnatCorrect;    /*!<   Does surface geometry match
3078                                        anatomy ? (YUP/NOPE)*/
3079    char *DomainGrandParentID;        /*!< Grandparent's mesh ID
3080                                           (icosahedron's for std-meshes) */
3081    char *OriginatorID;          /*!<   ID common for surfaces from one subject
3082                                        that are created
3083                                        at one point in time. Surfaces of the
3084                                        same subject,
3085                                       created at different points in time
3086                                       (like in a longitudinal
3087                                       study) will have differing
3088                                       OriginatorID fields (aka InstanceID)*/
3089    char *OriginatorLabel;        /*!< aka InstanceLabel */
3090    char *LocalCurvatureParent;   /*!< \sa same field in SUMA_SurfSpecFile
3091                                        structure */
3092    char *LocalCurvatureParentID;     /*!< \sa   idcode_str of
3093                                                 LocalCurvatureParent*/
3094    char *LocalDomainParent;   /*!< \sa same field in SUMA_SurfSpecFile
3095                                        structure */
3096    char *LocalDomainParentID;      /*!< \sa idcode_str of LocalDomainParent */
3097 
3098    SUMA_Boolean SUMA_VolPar_Aligned; /*!< Surface aligned to Parent Volume
3099                                           data sets ?*/
3100    SUMA_WARP_TYPES APPLIED_A2Exp_XFORM; /*! Type of warp applied
3101                                             to bring SurfVol into alignment
3102                                             with ExpVol
3103                                           Replaces VOLREG_APPLIED,
3104                                                    TAGALIGN_APPLIED,
3105                                                    ROTATE_APPLIED,
3106                                                    etc*/
3107    void *Saux; /* A pointer to a structure for SUMA's use
3108                   For now this is mostly for accessing the
3109                   pick result structure.
3110                   In the future, all selections currently
3111                   under SO-> should move to SO->Saux->PR
3112                   sane for overlays, etc. This would make
3113                   SOs behave more like the other displayable
3114                   objects. All in good time */
3115    void (*FreeSaux)(void *Saux); /* Function to free Saux */
3116 
3117    SUMA_Boolean SentToAfni; /*!< YUP if the surface has been
3118                                  niml-sent to AFNI */
3119    SUMA_Boolean Show; /*!< YUP then the surface is visible in the viewer.
3120                            Used in conjunction with PolyMode*/
3121    SUMA_RENDER_MODES PolyMode; /*!< polygon viewing mode, SRM_Fill,
3122                                     SRM_Line, SRM_Points */
3123    SUMA_TRANS_MODES TransMode; /*!< transprency */
3124 
3125    float *NodeNormList ; /*!< N_Node x 3 vector (used to be matrix prior
3126                               to SUMA 1.2) containing normalized normal
3127                               vectors for each node*/
3128    float *FaceNormList ; /*!< N_FaceSet x 3 vector (used to be matrix prior
3129                               to SUMA 1.2) containing normalized normal vectors
3130                               for each polygon*/
3131    int normdir;        ; /*!< direction of normals, 0 not known.
3132                               1 outwards, -1 inwards */
3133 
3134    float Center[3];       /*!< The centroid of the surface
3135                               (using all the nodes in NodeList)*/
3136    float MaxDims[3];      /*!< The maximum along each of the XYZ dimensions */
3137    float MinDims[3];      /*!< The minimum along each of the XYZ dimensions */
3138    float aMinDims;      /*!< The maximum across all dimensions*/
3139    float aMaxDims;      /*!< The minimum across all dimensions*/
3140 
3141    float MaxCentDist;   /* Maximal node distance from center */
3142    int MaxCentDistNode; /* Node which has maximal node distance from center */
3143    float MinCentDist;   /* Minimal node distance from center */
3144    int MinCentDistNode; /* Node which has minimal node distance from center */
3145 
3146 
3147    int N_patchNode; /*!<   Number of nodes used in the mesh.
3148                            For patches, this number is < SO->N_Node */
3149    byte *patchNodeMask; /*!< if not NULL, then if patchNodeMask[i] then
3150                               that node is part of the patch. Else it is not.
3151                               i goes from 0 to SO->N_Node */
3152    float patchCenter[3];  /*!< The centroid of the surface
3153                               (using all the nodes in FaceSetList)*/
3154    float patchMaxDims[3];      /*!< The maximum along each of the XYZ dimensions
3155                                     (using all the nodes in FaceSetList)*/
3156    float patchMinDims[3];      /*!< The minimum along each of the XYZ dimensions
3157                                     (using all the nodes in FaceSetList)*/
3158    float patchaMinDims;      /*!<   The maximum across all dimensions(using all
3159                                     the nodes in FaceSetList)*/
3160    float patchaMaxDims;      /*!<   The minimum across all dimensions(using all
3161                                     the nodes in FaceSetList)*/
3162 
3163    int RotationWeight; /*!<   Contribution to center of rotation calculation.
3164                               set to 0 if not contributing.
3165                               set to N_Node to have the number of nodes weigh
3166                               into the center's location, center of mass effect
3167                               set to 1 to give each object equal weight */
3168    int ViewCenterWeight; /*!< Contribution to center of gaze and
3169                               viewfrom location */
3170 
3171 
3172    GLfloat *glar_NodeList;         /*!< pointer to the 1D NodeList array
3173                                     - DO NOT FREE IT,
3174                                     it is a pointer copy of NodeList*/
3175    GLint  *glar_FaceSetList;      /*!< pointer to the 1D FaceSetList array
3176                                     - DO NOT FREE IT,
3177                                     it is a pointer copy of FaceSetList*/
3178    GLfloat *glar_FaceNormList;    /*!< pointer to the 1D FaceNormList array
3179                                     - DO NOT FREE IT,
3180                                     it is a pointer copy of NodeNormList*/
3181    GLfloat *PermCol; /*!< pointer to a 1D ColorList array.
3182                          If this vector is not null then it specifies the colors
3183                          of the nodes on the surface.
3184                          It is illegal to have this if Overlays != NULL */
3185    GLfloat *glar_NodeNormList;    /*!< pointer to the 1D NodeNormList array
3186                                        - DO NOT FREE IT,
3187                                        it is a pointer copy of NodeNormList*/
3188 
3189    int ShowMeshAxis; /*!< flag to show Mesh Axis if it is created */
3190    SUMA_Axis *MeshAxis;   /*!< pointer to XYZ axis  */
3191 
3192    SUMA_MEMBER_FACE_SETS *MF; /*!<  structure containing the facesets
3193                                     containing each node */
3194    SUMA_NODE_FIRST_NEIGHB *FN; /*!< structure containing the first order
3195                                     neighbors of each node */
3196    SUMA_EDGE_LIST *EL; /*!< structure containing the edge list */
3197    float *PolyArea; /*!< N_FaceSet x 1 vector containing the area of
3198                          each polygon in FaceSetList */
3199    SUMA_SURFACE_CURVATURE *SC; /*!< Structure containing the surface
3200                                     curvature info */
3201 
3202 
3203    /* selection stuff */
3204    int SelectedNode; /*!< index of one selected node,
3205                            -1 if no node is selected */
3206    SUMA_SphereMarker *NodeMarker; /*!< Node Marker object structure*/
3207 
3208    int SelectedFaceSet; /*!< index of one selected faceset,
3209                               -1 if no faceset is selected */
3210    SUMA_FaceSetMarker *FaceSetMarker; /*!< Aha, I hear ya */
3211 
3212    SUMA_VOLPAR *VolPar; /*!< Parent Volume structure */
3213 
3214    SUMA_OVERLAYS **Overlays; /*!< vector of pointers to color overlay
3215                                   structures */
3216    int N_Overlays; /*!< number of pointers to overlay structures */
3217 
3218    SUMA_X_SurfCont *SurfCont;/*!< pointer to structure containing surface
3219                                   controller widget structure */
3220 
3221    SUMA_DO *CommonNodeObject; /*!< a node marker which can be any of the
3222                             node-based displayable objects.
3223                             The DO is for one node only,
3224                             something like a sphere say.
3225                             At load time, the marker is replicated
3226                             to form a DO that covers all the nodes. */
3227    SUMA_DO *NodeObjects;   /*!< a replication of CommonNodeObject where
3228                            each node gets a shape defined by CommonNodeObject */
3229    SUMA_NIDO **NodeNIDOObjects;   /*!< a more flexible replication of NIDO
3230                            CommonNodeObject where */
3231 
3232    float *NodeAreas; /*!< A way to keep node areas around */
3233 
3234    SUMA_VIS_XFORM VisX0; /*!< a coordinate transform applied at the moment
3235                               the surface is loaded and the resultant
3236                               coordinates are to be stored in the the
3237                               surface's NodeList */
3238    SUMA_VIS_XFORM VisX; /*!< a coordinate transform generated from interactive
3239                               vicissitudes */
3240 
3241    float *NodeList_swp; /*!< A temporary pointer copy for swapping NodeList with
3242                              VisX's transformed coordinates. Use sparingly */
3243    float PointSize; /*! Set to negative to make it so it has no effect */
3244 
3245    SUMA_DRAW_MASKS *DW; /*!< A structure containing node masking information
3246                              for on the fly masking */
3247 } SUMA_SurfaceObject; /*!< \sa Alloc_SurfObject_Struct in SUMA_DOmanip.c
3248                      \sa SUMA_Free_Surface_Object in SUMA_Load_Surface_Object.c
3249                      \sa SUMA_Print_Surface_Object in SUMA_Load_Surface_Object.c
3250                      \sa SUMA_Load_Surface_Object in SUMA_Load_Surface_Object.c
3251                */
3252 
3253 typedef struct {
3254    SUMA_Boolean FreeFaceSetList; /*! Set to YUP if FaceSetList is not a
3255                                      pointer copy */
3256    int *FaceSetList;            /*! A subset of the parent surface's triangles
3257                                    to be drawn */
3258    int N_FaceSet;
3259 
3260 
3261    /* See SUMA_SurfaceObject for interpretation of the following parameters */
3262    SUMA_Boolean Show;
3263    SUMA_RENDER_MODES PolyMode;
3264    SUMA_TRANS_MODES TransMode;
3265 }  SUMA_DrawPatch; /* Surfaces can be drawn in patches for nefarious reasons. */
3266 
3267 typedef struct {
3268       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
3269    SUMA_DO_Types do_type;
3270    char *idcode_str;
3271    char *Label;
3272 
3273       /* Not sure whether or not these things need to be moved into
3274          the common stuff in SUMA_ALL_DO yet ... */
3275    void *Saux; /* A pointer to a structure for SUMA's use */
3276    void (*FreeSaux)(void *Saux); /* Function to free Saux */
3277    int N_datum; /* Here number of control points forming tracts */
3278 
3279       /* Begin specific fields */
3280    char *Parent_idcode_str;   /* Object a mask is attached to (positioned on)*/
3281    int Parent_datum_index;    /* Datum index a mask is attached to */
3282 
3283    char mtype[64]; /* A string defining mask subtypes
3284                       cube --> box
3285                       ball --> sphere
3286                       surface --> surface of generic shape
3287                       volume --> volume of generic shape */
3288    int N_obj;
3289    float *cen; /* Center of mask */
3290    float *hdim; /* XYZ half dims of mask */
3291 
3292    float *init_cen; /* Initial centers */
3293    float *init_hdim; /* Initial dims */
3294 
3295    SUMA_SurfaceObject *SO; /* Surface defining mask shape */
3296 
3297    float *init_col;
3298    float dim;
3299 
3300    GLfloat *dcolv;
3301 
3302    char varname[3];
3303    SUMA_TRANS_MODES trans;
3304 
3305    float dopxyz[3];
3306    int dodop;
3307 } SUMA_MaskDO;
3308 
3309 
3310 typedef struct {
3311    /* *** DO NOT ADD ANYTHING BEFORE THESE FIELDS
3312           DO NOT CHANGE THE ORDER OF THESE FIELDS
3313           ANY CHANGES HERE SHOULD BE REFLECTED IN
3314           SUMA_LinkedPtr structure
3315    */
3316    SUMA_DO_Types do_type;  /*!< To check if this is a displayable object */
3317    int LinkedPtrType; /*!< Indicates the type of linked pointer */
3318    int N_links;   /*!< Number of links to this pointer */
3319    char owner_id[SUMA_IDCODE_LENGTH];   /*!< The id of whoever created
3320                                  that pointer. Might never get used.... */
3321    SUMA_GRAPH *gr;
3322 } SUMA_GRAPH_DO;     /* A graph displayable object */
3323 
3324 
3325 #define SUMA_MAX_N_VE 5
3326 typedef struct {
3327    char *dset_idcode_str;
3328 
3329    GLubyte *texvec;  /* vector of voxel textures */
3330    GLuint *texName;
3331 
3332    int Ni;
3333    int Nj;
3334    int Nk;
3335 
3336    float I2X[4][4];  /* ijk to dicom real */
3337    float X2I[4][4];  /* dicom real to ijk */
3338    float X2T[4][4];  /* dicom real to texture */
3339    float T2X[4][4];  /* texture to dicom real */
3340    float bcorners[24];/* box corners (outer edges) */
3341    float vcorners[24];/* vox corners (voxel centers) */
3342 
3343    float vo0[3];  /* coordinates of 1st voxel */
3344    float voN[3];  /* coordinates of last voxel */
3345    float bo0[3];  /* coordinates of 1st box corner */
3346    float boN[3];  /* coordinates of last box corner */
3347 } SUMA_VolumeElement;
3348 
3349 typedef struct {
3350       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
3351    SUMA_DO_Types do_type;
3352    char *idcode_str;
3353    char *Label;
3354 
3355       /* Begin specific fields */
3356    SUMA_VolumeElement **VE;
3357    GLfloat TexEnvMode;
3358 
3359    void *Saux; /* A pointer to a structure for SUMA's use */
3360    void (*FreeSaux)(void *Saux); /* Function to free Saux */
3361 
3362    GLdouble CutPlane[6][4];
3363    byte UseCutPlane[6];
3364    int SelectedCutPlane;
3365    SUMA_SurfaceObject **SOcut;
3366 
3367    void *VoxelMarker; /* a TBD structure to hold object used to
3368                         highlight a selected voxel */
3369    int SelectedVoxel;
3370    byte ShowSelectedVoxel;
3371 
3372    byte Show;
3373 
3374 } SUMA_VolumeObject; /*! \sa SUMA_CreateVolumeObject */
3375 
3376 typedef struct {
3377       /* FIRST VARIABLES MUST RETAIN THEIR ORDER and follow SUMA_ALL_DO */
3378    SUMA_DO_Types do_type;
3379    char *idcode_str;
3380    char *Label;
3381 
3382       /* Begin specific fields */
3383    int N_subdoms; /* Number of sub objects defining domain */
3384    char **subdoms_id; /* Collection of sub-domains */
3385 
3386    void *Saux; /* A pointer to a structure for SUMA's use */
3387    void (*FreeSaux)(void *Saux); /* Function to free Saux */
3388 
3389    int SelectedDatum;
3390    int SelectedSubAdo;
3391 
3392    byte Show;
3393 
3394 } SUMA_CIFTI_DO; /*! \sa SUMA_CreateCIFTIObject */
3395 
3396 
3397 /*! Structure for creating a hash of color ids */
3398 typedef struct {
3399     int id;    /* keep it named 'id' to facilitate use of convenience
3400                   macros in uthash . The integer id of a color*/
3401     int colmapindex; /* the index into the colormap of id */
3402     UT_hash_handle hh;  /* keep it named 'hh' for same reasons  */
3403 }  SUMA_COLOR_MAP_HASH_DATUM;
3404 
3405 /* Structure keeping track of what was selected in a surface viewer*/
3406 typedef struct {
3407    char *ado_idcode_str;
3408    char *variant;
3409    SUMA_PICK_RESULT *PR;
3410 } SUMA_SEL_ADO_DATUM;
3411 
3412 /*! Structure containing a color map */
3413 typedef struct {
3414    float ** M; /*!< N_Col x 3 matrix of R G B values (0..1) */
3415    char **cname; /*!< N_Col pointers to strings containing name of
3416                        each color. This can be NULL when no names are
3417                        assigned*/
3418    int N_M[2]; /*!< number of colors in the color map x number of columns in M
3419                      Used to be N_Col, now N_Col = N_M[0] and the
3420                      number of columns in M is N_M[1] */
3421    float *frac; /*!< N_col x 1 vector containing the fraction of scale
3422                      assigned to each color, these are
3423                      the values shown on the right of the colorbar in
3424                      AFNI.
3425                      This field is NULL if the map is linear*/
3426    float top_frac; /* Not all afni maps end with 1 as the top fraction.
3427                       For equivalent mapping in AFNI, the range needs
3428                       to be multiplied by this factor, set to 0 if not
3429                       in use */
3430    int Sgn; /*!         +1  colormap is positive ranging (a la afni)
3431                          0  field is not set
3432                          -1 colormap is negative ranging (a la afni)*/
3433    char *Name; /*!< Name of colormap */
3434 
3435    SUMA_SurfaceObject *SO;    /*!< Surface object used to represent map */
3436 
3437    float M0[4];   /*!< The very first color at Map creation, needed to reset
3438                       when rotations are performed*/
3439    byte flipped;  /*!< if the colormap is flipped */
3440 
3441    /* Hashing needs */
3442    int *idvec; /*!< N_Col vector containing the id of each of the colors in M
3443                      This vector is redundant if chd is used, but it is kept */
3444    SUMA_COLOR_MAP_HASH_DATUM *chd;  /* This is a pointer to the hash table, and
3445                                        can always change during hash table
3446                                        operations*/
3447 } SUMA_COLOR_MAP;
3448 
3449 /*! structure containing a mapping of one surface to another*/
3450 typedef struct {
3451    float *NewNodeList; /*!< N_Node x 3 vector containing new mapping
3452                            of node coordinates */
3453    int N_Node; /*!< Number of nodes in NodeList */
3454    float *NodeVal;
3455    float *NodeCol;
3456    float *NodeDisp;
3457 } SUMA_SO_map;
3458 
3459 /*! structure containing SureFit Surface*/
3460 typedef struct {
3461    /* coord files */
3462    char name_coord[SUMA_MAX_NAME_LENGTH];
3463    int N_Node; /*!< Number of nodes */
3464    float *NodeList; /*!< N_Node x 3 vector containing node coordinates */
3465    int *NodeId; /*!< Node ID, that's normaly from 0..N_Nodes-1 but
3466                     since it's in .coord file, I keep it anyway */
3467    byte *allzerocoord;
3468    char encoding_coord[100];
3469    char configuration_id[100];
3470    char coordframe_id[100];
3471    /* Topo files */
3472    char name_topo[SUMA_MAX_NAME_LENGTH];
3473    char encoding_topo[100];
3474    char date[100];
3475    char perimeter_id[100];
3476    int N_Node_Specs; /*!< Number of nodes with listed node specs */
3477    int **Specs_mat; /*!< Node Specs matrix. Columns appear to be
3478                          arraged as such NodeId #Neighbors ? ? NodeId ? */
3479    SUMA_NODE_FIRST_NEIGHB FN; /*!< First order neighbor structure */
3480    int N_FaceSet; /*!< Number of polygons making up surface */
3481    int *FaceSetList; /*!< definition of polygons. Became a vector in SUMA 1.2*/
3482    /* Param Files */
3483    char name_param[SUMA_MAX_NAME_LENGTH];
3484    float AC_WholeVolume[3]; /*!< XYZ (from .Orient.params file)
3485                                of Anterior Comissure of whole volume */
3486    float AC[3]; /*!< XYZ of Anterior Comissure of cropped volume */
3487    float CropMin[3];
3488    float CropMax[3];
3489    float tag_version;
3490    float caret_version;
3491 } SUMA_SureFit_struct;
3492 
3493 /* structure containing FreeSurfer Surface */
3494 typedef struct {
3495    char name[SUMA_MAX_NAME_LENGTH];
3496    int N_Node; /*!< Number of nodes */
3497    int *NodeId; /*!< Node ID, that's normaly from 0..N_Nodes-1 unless the surface is a patch of another surface see FaceSetIndexInParent*/
3498    float *NodeList; /*!< N_Node x 3 vector containing node coordinates */
3499    int N_FaceSet; /*!< Number of polygons making up surface */
3500    int *FaceSetList; /*!< definition of polygons. For a complete surface, these are indices into NodeList's rows
3501                            For a patch, these are indices into NodeList of the parent surface.
3502                         Became a vector in SUMA 1.2*/
3503    char comment[SUMA_MAX_STRING_LENGTH]; /*!< comment at beginning of patch or surface */
3504    SUMA_Boolean isPatch; /*!< is the surface a patch of another ? */
3505    int *FaceSetIndexInParent; /*!< for a FaceSet in patch, this represents its index in FaceSetList of the parent surface.
3506                                     This is the FaceSet equivalent of NodeId*/
3507 } SUMA_FreeSurfer_struct;
3508 
3509 /* structure containing SureFit name*/
3510 typedef struct {
3511    char name_coord[SUMA_MAX_FILENAME_LENGTH];
3512    char name_topo[SUMA_MAX_FILENAME_LENGTH];
3513    char name_param[SUMA_MAX_FILENAME_LENGTH];
3514 } SUMA_SFname;
3515 
3516 typedef enum {    SMT_Nothing,
3517                   SMT_Notice, SMT_Warning, SMT_Error, SMT_Critical, SMT_Text,
3518                   SMT_N }  SUMA_MESSAGE_TYPES; /*!< different types of messages */
3519 
3520 typedef enum {    SMA_Nothing,
3521                   SMA_Log, SMA_LogAndPopup,
3522                   SMA_N }  SUMA_MESSAGE_ACTION; /*!< different actions to perform with messages */
3523 
3524 
3525 
3526 /*! structure containing a SUMA Message structure */
3527 typedef struct {
3528    SUMA_MESSAGE_TYPES Type;   /*!< type of message */
3529    SUMA_MESSAGE_ACTION  Action; /*!< what to do with message*/
3530    char *Message; /*!< null terminated message string */
3531    char *Source;  /*!< source of message, usually calling function */
3532 }  SUMA_MessageData;
3533 
3534 
3535 
3536 /*! structure containing a surface patch */
3537 typedef struct {
3538    int N_FaceSet;    /*!< Number of Facesets forming patch */
3539    int *FaceSetList; /*!< vector (was a matrix prior to SUMA 1.2) (N_FaceSet x 3)                           containing indices of nodes forming triangles making up                           the patch */
3540    int *FaceSetIndex; /*!< vector (N_FaceSet x 1) containing indices of triangles                            in FaceSetList in the FaceSetList of the surface that
3541                            the patch was taken from */
3542    int *nHits; /*!< (N_FaceSet x 1) If patch is created from a set of nodes,
3543                      nHits[i] is the number of nodes refering to this Faceset */
3544 } SUMA_PATCH; /*!< A surface patch, typically created from a set of nodes */
3545 
3546 /*! structure containing ClientData
3547 This remains to be used somewhere ... */
3548 typedef struct {
3549    SUMA_SurfaceViewer *sv; /*!< pointer to surface viewer from which the
3550                                  callback was made */
3551    int svi; /*!< index of sv into SUMAg_SVv */
3552 }SUMA_CLIENT_DATA;
3553 
3554 /*! Maximum nuber of branches that can be found in the intersection
3555    of a plane with the surface model */
3556 #define SUMA_BRANCHMAX 500
3557 
3558 /*! Maximum nuber of nodes that can form one branch */
3559 #define SUMA_NODEINLISTMAX 500
3560 
3561 /*!
3562 \brief Structure forming a branch
3563 
3564 A branch is a protruded part of a tree often resulting in chainsaw accidents.
3565 It is used in determining the intersection of a plane with a surface
3566 */
3567 typedef struct {
3568    int begin, start;   /*!< first node of the branch */
3569    int last;   /*!< last node of the branch */
3570    int closed; /*!< flag. 0--> open, 1--> closed */
3571    int list[SUMA_NODEINLISTMAX]; /*!< list of nodes per branch */
3572    int listsz; /*!< Number of nodes in list*/
3573 } SUMA_BRANCH;
3574 
3575 /*!
3576 \brief Structure forming a triangle branch
3577 
3578 A Tiangle branch represents a strip of connected triangles.
3579 
3580 */
3581 typedef struct {
3582    int begin, start;   /*!< first node of the branch */
3583    int last;   /*!< last node of the branch */
3584    int iBranch; /*!< index identifying branch */
3585    SUMA_Boolean closed; /*!< flag. 0--> open, 1--> closed */
3586    int * list; /*!< list of nodes per branch */
3587    int N_list; /*!< Number of nodes in list*/
3588 } SUMA_TRI_BRANCH;
3589 
3590 /*!
3591 \brief Structure defining the intersection of a surface with a plane
3592 */
3593 typedef struct {
3594    int N_IntersEdges; /*!< Number of edges intersected by the plane */
3595    int *IntersEdges;  /*!< Vector containing indices of edges intersected by the plane. The indices
3596                         are into SO->EL->EL matrix. The space allocate for this vector is SO->EL->N_EL
3597                         But that is way more than ususally needed. For this vector and others in
3598                         this structure, reallocation is not done to save time. Useful values for IntersEdges
3599                         are between IntersEdges[0]  and IntersEdges[N_IntersEdges-1]*/
3600    SUMA_Boolean *isEdgeInters; /*!< Vector specifying if an edge i (index into SO->EL->EL) was intersected. */
3601    #if 0
3602    /* old way, less memory usage, slower access - pre Wed Dec  4 16:57:03 EST 2002*/
3603    float *IntersNodes;  /*!< Vector containing XYZ coordinates of the intersection point on each
3604                            intersected segment. Allocated space is for 3*SO->EL->N_EL, useful space is
3605                            between IntersNodes[0] and IntersNodes[3*(N_IntersEdges-1) + 2]. Intersection point
3606                            of edge IntersEdges[k] has  X = IntersNodes[3*k], Y = IntersNodes[3*k+1] and
3607                            Z = IntersNodes[3*k+2] */
3608    #endif
3609    float *IntersNodes;  /*!< Vector containing XYZ coordinates of the intersection point on each
3610                            intersected segment. Allocated space is for 3*SO->EL->N_EL, meaningful values are
3611                            for intersected segments only. Intersection point
3612                            of edge SO->EL->EL[k][:] has  X = IntersNodes[3*k], Y = IntersNodes[3*k+1] and
3613                            Z = IntersNodes[3*k+2] */
3614    int *IntersTri; /*!< Vector containing indices of triangles intersected by the plane (i.e. containing
3615                         and edge that was intersected. Allocation is done for SO->N_FaceSet.
3616                         But meaningful values are between IntersETri[0] and IntersTri[N_IntersTri-1]. */
3617    int N_IntersTri; /*!< Number of intersected triangles. */
3618    SUMA_Boolean *isNodeInMesh;   /*!< Vector of SO->N_Node elements indicating whether a certain node
3619                                     belongs to an intersected seqment or not */
3620    int N_NodesInMesh;  /*!< Total number of nodes belonging to intersected segments */
3621 
3622    SUMA_Boolean *isTriHit; /*!< Vector of SO->N_FaceSet elements indicating whether a triangle was intersected by the plane.
3623                      if isTriHit[j] then triangle SO->FaceSetList[3*j], [3*j+1], [3*j+2] was intersected. You should
3624                      have a total of N_IntersTri YUP values in this vector*/
3625 
3626 } SUMA_SURF_PLANE_INTERSECT;
3627 
3628 
3629 
3630 
3631 /*!
3632    Structure for passing info to function SUMA_SaveSOascii
3633 */
3634 typedef struct {
3635    SUMA_SurfaceObject *SO;
3636    SUMA_SurfaceViewer *sv;
3637 } SUMA_SAVESO_STRUCT;
3638 
3639 /*!
3640    Structure containing a named color
3641 */
3642 typedef struct {
3643    float r;
3644    float g;
3645    float b;
3646    float a;
3647    char Name[SUMA_MAX_COLOR_NAME];
3648 } SUMA_RGB_NAME;
3649 
3650 /*!
3651    Structure containing the colormaps used by AFNI
3652 */
3653 typedef struct {
3654    SUMA_COLOR_MAP **CMv;   /* a vector of pointers to colormap structures */
3655    int N_maps;             /* the number of colormaps in CMv */
3656    SUMA_RGB_NAME *Cv;      /* a vector of RGB_Name structures containing the named colors used by AFNI */
3657    int N_cols;             /* the number of defined colors in Cv */
3658 } SUMA_AFNI_COLORS;
3659 
3660 typedef struct {
3661    int N_Neighb;           /*!< Number of neighbors for a particular node */
3662    int *Neighb_ind;        /*!< N_Neighb x 1 vector containing  nodes neighboring node i */
3663    float *Neighb_dist;     /*!< N_Neighb x 1 vector containing node distances from node i.
3664                                These are the shortes distances ON THE GRAPH. */
3665    float *Neighb_PropLoc;  /*!< N_Neighb x 3 vector containing XYZ of estimated node propagation
3666                                 from one layer to the next. */
3667 } SUMA_OFFSET_STRUCT;      /*!< The structure returned by SUMA_FormNeighbOffset */
3668 
3669 typedef struct {
3670    int *NodesInLayer;   /*!< Vector containing nodes that are neighbors to node n
3671                             (Vector contains N_NodesInLayer useful values but has
3672                              N_AllocNodesInLayer allocated spots)
3673                             Those neighbors can be of any order (see below and
3674                              structure SUMA_GET_OFFSET_STRUCT) */
3675    int N_NodesInLayer;     /*!< Number of nodes in this layer */
3676    int N_AllocNodesInLayer;   /*!< Number of nodes allocated for in this layer.
3677                                  Allocation is done in chunks of 200 at a time */
3678 } SUMA_NODE_NEIGHB_LAYER;  /*!< Structure containing the layers neighboring
3679                                  a node n.
3680                                 The 0th order layer contain n only
3681                                 The 1st order layer contains the first
3682                                 order neighbors of n
3683                                 etc.. */
3684 
3685 typedef struct {
3686    int N_layers;    /*!< Number of node neighborhoods of a certain node n.
3687                     The 0th order layer contain n only.
3688                     The 1st order layer contains the first order neighbors of n.
3689                                 etc.. */
3690    SUMA_NODE_NEIGHB_LAYER *layers;  /*!<  layers[0] is the zeroth order layer
3691                                           layers[1] is the 1st order layer, etc.
3692                                           See  SUMA_NODE_NEIGHB_LAYER */
3693 
3694    int N_Nodes;            /*!< Number of nodes in mesh */
3695    int *LayerVect;         /*!< vector containing the neighborhood layer of a
3696                                 certain node from node n.
3697               LayerVect[5] = 2; means node 5 is a 2nd order neighbor to node n.
3698               LayerVect[5] = -1; means node 5 is not within the limit distance
3699                                  from node n.
3700               All values in LayerVect are initialized to -1 */
3701    float *OffVect;         /*!< vector containing the distance of nodes in the
3702                                  mesh from node n.
3703                 d = OffVect[5]; is the geodesic distance of node 5 from node n.
3704                 OffVect is N_Nodes long.
3705                 OffVect[k] is meaningless if LayerVect[k] < 0 */
3706 } SUMA_GET_OFFSET_STRUCT;  /*!< Structure containing nodes that are within a
3707                certain geodesic distance (lim) from a certain node n. */
3708 
3709 typedef struct {
3710    int talk_suma;
3711    int comm_NI_mode;
3712    float rps;
3713    float nelps;  /*!<   number of NI elements to send per second
3714                         -1 for going as fast as possible */
3715    int TrackID;            /*!<  ID of next element to be sent
3716                                  NI_element StartTracking has an ID of 1 */
3717    SUMA_Boolean GoneBad;   /*!< Flag indicating that stream went bad */
3718    SUMA_Boolean Send;      /*!< Flag indicating that elements should be sent
3719                                 As long as GoneBad is NOPE */
3720    SUMA_Boolean afni_GoneBad;
3721    SUMA_Boolean afni_Send;
3722    int istream; /*!< index of the stream used in SUMAg_CF->ns_v */
3723    int afni_istream; /*!< index of stream used to connect to afni */
3724    char *suma_host_name;
3725    char *afni_host_name;
3726    int ElInd[SUMA_N_DSET_TYPES]; /* index of elements of a certain type
3727                                     to be sent to SUMA */
3728    int kth;    /* send kth element to SUMA */
3729    int Feed2Afni;
3730 } SUMA_COMM_STRUCT;
3731 
3732 typedef enum {
3733    SUMA_DOMAINS_ERROR = -1,
3734    SUMA_DOMAINS_NOT_RELATED = 0,  /*!< Surfaces are not related
3735                                        Above that flag, surfaces are related*/
3736    SUMA_SO1_is_SO2,           /*!< Surface1 is the same as Surface2 */
3737    SUMA_SO1_is_LDPSO2,        /*!< SO1 is the local domain parent of SO2 */
3738    SUMA_SO2_is_LDPSO1,        /*!< SO2 is the local domain parent of SO1 */
3739    SUMA_LDPSO1_is_LDPSO2,   /*!< SO1 and SO2 have the same local domain parent */
3740    SUMA_NUCELAR_FAMILY,       /*!< A flag to indicate limit of immediate kinship
3741                                   (Don't blame me, official syntax in use)
3742                                   Above that flag, kinship is distant */
3743    SUMA_SO1_is_GPSO2,         /*!< SO1 is the granddaddy of SO2 */
3744    SUMA_SO2_is_GPSO1,         /*!< SO2 is the granddaddy of SO1 */
3745    SUMA_GPSO1_is_GPSO2,     /*!< SO1 and SO2 have the same  granddaddy*/
3746 
3747    SUMA_N_NODE_SAME,        /*! SO1 and SO2 have the same number of nodes */
3748 } SUMA_DOMAIN_KINSHIPS; /*!< The type of relationships between surfaces, modify
3749                               function SUMA_DomainKinships_String; */
3750 typedef struct {
3751    char name[100];
3752    double lastcall;
3753    struct timeval tt;
3754 } SUMA_TIMER;
3755 
3756 #define SUMA_MAX_N_TIMER 50
3757 
3758 /*! structure containing information global to all surface viewers */
3759 typedef struct {
3760    SUMA_Boolean Dev; /*!< Flag for developer option
3761                      (allows the use of confusing or kludge options) */
3762    SUMA_Boolean Fake_Cmap; /*!< Flag to create X11 cmap for the purpose of
3763                               automated picture taking. It should not be set
3764                               on for any other reason. */
3765    SUMA_Boolean InOut_Notify; /*!< prints to STDERR a notice when a function
3766                                  is entered or exited */
3767    SUMA_Boolean Echo_KeyPress; /*!< prints to STDERR a notice when a function
3768                                  is entered or exited */
3769    int InOut_Level; /*!< level of nested function calls */
3770    int PointerSize; /*!< size of void * */
3771    int N_OpenSV; /*!< Number of open (visible) surface viewers.
3772                      Do not confuse this with the number of surface viewers
3773                      created (SUMAg_N_SVv)*/
3774 
3775    SUMA_MEMTRACE_STRUCT *Mem; /*!< structure used to keep track of
3776                                     memory usage */
3777    SUMA_Boolean MemTrace; /*!< Flag for keeping track of memory usage
3778                               (must also set SUMA_MEMTRACE_FLAG ) */
3779 
3780    char HostName_v[SUMA_MAX_STREAMS][SUMA_MAX_NAME_LENGTH];
3781          /*!<  name or ipaddress of hosts maximum allowed name is 20
3782              chars less than allocated for, see SUMA_Assign_AfniHostName
3783              *** Dec. 19 03: This field used to be called AfniHostName
3784              It is now a vector of hostnmes allowing for multiple
3785              connections.
3786              AfniHostName = HostName_v[SUMA_AFNI_STREAM_INDEX]*/
3787    char NimlStream_v[SUMA_MAX_STREAMS][SUMA_MAX_NAME_LENGTH];
3788          /*!< niml stream name for communicating with other programs
3789            *** Dec. 19 03: This field used to be called AfniNimlStream
3790            AfniNimlStream = NimlStream_v[SUMA_AFNI_STREAM_INDEX]*/
3791    NI_stream ns_v[SUMA_MAX_STREAMS]; /*!<
3792                      *** Pre: Dec 19 03:
3793                      Stream used to communicate with AFNI.
3794                      It is null when no communication stream is open.
3795                      The stream can be open with Connected set to NOPE.
3796                      In that case no communication between the two programs
3797                      but resuming communication is easy since surfaces need
3798                      not be sent to AFNI again as would be the case if the stream
3799                      was completely closed
3800                      *** Dec. 19 03
3801                      Used to be called ns for connecting to AFNI.
3802                      ns = ns_v[SUMA_AFNI_STREAM_INDEX]*/
3803    int ns_to[SUMA_MAX_STREAMS];
3804    int ns_toc[SUMA_MAX_STREAMS];
3805    int ns_flags_v[SUMA_MAX_STREAMS];
3806    int TCP_port[SUMA_MAX_STREAMS];
3807    int TalkMode[SUMA_MAX_STREAMS];  /* Talk text or talk binary? */
3808    SUMA_Boolean Connected_v[SUMA_MAX_STREAMS];
3809      /*!< YUP/NOPE, if SUMA is sending (or accepting) communication from AFNI
3810          *** Dec. 19 03
3811          Vectorized Connected like fields above*/
3812    int TrackingId_v[SUMA_MAX_STREAMS];
3813       /*!<  for keeping track of serial number of incoming nels
3814             0 if not keeping track. So start numbering at 1*/
3815 
3816 
3817    SUMA_Boolean Listening; /*!< SUMA is listening for connections */
3818    SUMA_Boolean niml_work_on; /*!< Flag indicating that niml workprocess is ON */
3819    SUMA_LINK_TYPES Locked[SUMA_MAX_SURF_VIEWERS];
3820          /*!< All viewers i such that Locked[i] != SUMA_No_Lock
3821                have their cross hair locked together */
3822    SUMA_Boolean ViewLocked[SUMA_MAX_SURF_VIEWERS];
3823          /*!< All viewers i such that ViewLocked[i] = YUP
3824                have their view point locked together */
3825    SUMA_Boolean SwapButtons_1_3;
3826          /*!< YUP/NOPE, if functions of mouse buttons 1 and 3 are swapped */
3827    SUMA_X_AllView *X;
3828          /*!< structure containing widgets and other X related
3829                variables that are common to all viewers */
3830    DList *MessageList;
3831       /*!< a doubly linked list with data elements
3832            containing notices, warnings and error messages*/
3833    SUMA_Boolean ROI_mode;
3834       /*!< Flag specifying that SUMA is in ROI drawing mode */
3835    SUMA_Boolean ROI_contmode;
3836       /*!< Flag specifying that ROI contours should be drawn
3837             This field and Pen_mode and perhaps ROI_CM should
3838             be inside SUMA_X_DrawROI, not here!*/
3839    SUMA_Boolean Pen_mode;
3840       /*!< Flag specifying that a pen is being used for drawing */
3841    SUMA_COLOR_MAP *ROI_CM;
3842       /*!< Color map used to map an ROI's index to a color */
3843    SUMA_ROI_FILL_MODES ROI_FillMode;
3844       /*!< flag indicating how to fill a closed contour */
3845    SUMA_COL_MIX_MODE ColMixMode;
3846       /*!< controls the way colors from multiple planes are mixed together */
3847    SUMA_Boolean ROI2afni; /*!< Send ROIs to afni as you draw them*/
3848    int nimlROI_Datum_type; /*!< the code for nimlROI_Datum_type */
3849 
3850    char **GroupList; /*!< Names of surface groups */
3851    int N_Group;   /*!< number of groups  available */
3852 
3853    SUMA_AFNI_COLORS *scm;
3854       /*!< a structure containing all the colormaps available to SUMA */
3855    DList *DsetList;  /*!< List containing datasets */
3856    SUMA_Boolean Allow_Dset_Replace;
3857       /*!< Allow replacement of old dset with new dset having same id */
3858    SUMA_Boolean Home_After_Prying;
3859       /*!< Call 'Home' callback as prying is applied */
3860    int SUMA_ThrScalePowerBias;
3861    int SUMA_SnapshotOverSampling;
3862    SUMA_Boolean IgnoreVolreg;
3863       /*!< if YUP then ignore any Volreg or TagAlign
3864          transform in the header of the surface volume */
3865    SUMA_Boolean isGraphical;
3866       /*!<if YUP then Named afni colors will
3867           get resolved when creating color maps.
3868           Otherwise they are set to gray.
3869           Only suma and ScaleToMap will need to set
3870           this variable to YUP, for the moment June 3 05 */
3871 
3872    int N_ClipPlanes;
3873       /*!< Number of screen clipping planes, 3 max allowed */
3874    GLdouble ClipPlanes[4*SUMA_MAX_N_CLIP_PLANES];
3875       /*!< Equations of  clipping planes */
3876    SUMA_CLIP_PLANE_TYPES ClipPlaneType[SUMA_MAX_N_CLIP_PLANES];
3877       /*!< Screen clipping, object clipping, etc. */
3878    char ClipPlanesLabels[SUMA_MAX_N_CLIP_PLANES][9];
3879 
3880    int NoDuplicatesInRecorder;
3881    int N_Timer;
3882    SUMA_TIMER Timer[SUMA_MAX_N_TIMER];
3883 
3884    char *cwd;
3885 
3886    float CmapRotaFrac; /*!< fraction by which to rotate colormap */
3887    int   TransModeStep; /*!< levels to jump when changing transparency*/
3888    DList *xforms;    /*!<  List of transforms that apply to certain dsets
3889                            or surfaces */
3890    DList *callbacks; /*!< List of callbacks that apply to certain dsets or
3891                           surfaces */
3892 
3893    SUMA_Boolean HoldClickCallbacks;
3894    int PointerLastInViewer; /* index of latest viewer visited by mouse pointer
3895                            -1 if unknown */
3896 
3897    GICOR_setup *giset; /*!< parameters for group icorr setup */
3898    INSTA_TRACT_SETUP *ITset; /*!< parameters for instatract setup */
3899 
3900    SUMA_PARSED_NAME *autorecord; /*!< Autorecord prefix */
3901 
3902    DList *SaveList; /*!< List of objects set to be saved when user chooses to */
3903 
3904    SUMA_Boolean YokeIntToNode;
3905 
3906    SUMA_EVENT *lev; /*!< A record of the last input event */
3907 
3908    char **dcom;
3909    int N_dcom;
3910 
3911    Boolean clippingPlaneVerbose;
3912    int clippingPlaneVerbosityLevel;
3913 
3914 } SUMA_CommonFields;
3915 
3916 
3917 typedef enum { SUMA_NO_SORT, SUMA_BY_PLANE_DISTANCE, SUMA_BY_SEGMENT_DISTANCE, SUMA_SORT_BY_LLC_DISTANCE, SUMA_SORT_BY_LL_QUAD } SUMA_SORT_BOX_AXIS_OPTION;
3918 typedef enum { SUMA_LOWER_LEFT_SCREEN, SUMA_UPPER_LEFT_SCREEN, SUMA_UPPER_RIGHT_SCREEN, SUMA_LOWER_RIGHT_SCREEN } SUMA_SCREEN_CORNERS;
3919 typedef struct {
3920    double world_length;
3921    double ScreenProj[3];
3922    double ScreenProj_xy_length;
3923    double P1[3];
3924    double P2[3];
3925    int SegIndex;
3926    int PointIndex[2];
3927    int FaceIndex[2];
3928    int Quad[2];
3929    double tick1_dir[3];
3930    double tick2_dir[3];
3931    double MidFaceDist;
3932    double MidSegDist;
3933    int AxisDim;
3934    int LLCclosestPoint;
3935    double LLCclosestDist;
3936    double TxOff[3];
3937 }  SUMA_AxisSegmentInfo;
3938 
3939 
3940 
3941 
3942 typedef struct {
3943    char *master;
3944    char *mask;
3945    char *prefix;
3946    char *prefix_path;
3947    char *orcode;
3948    int do_ijk;
3949    int dimen_ii;
3950    int dimen_jj;
3951    int dimen_kk;
3952    int datum;
3953    float dval;
3954    float fval;
3955    byte *mmask;
3956    int full_list;
3957    THD_3dim_dataset *mset;
3958    int exists;
3959    int coorder_xyz;
3960 }  SUMA_FORM_AFNI_DSET_STRUCT;
3961 
3962 extern SUMA_SurfaceViewer *SUMAg_cSV; /*!< Global pointer to current Surface Viewer structure*/
3963 extern SUMA_SurfaceViewer *SUMAg_SVv; /*!< Global pointer to the vector containing the various Surface Viewer Structures */
3964 extern int SUMAg_N_SVv; /*!< Number of SVs stored in SVv */
3965 extern SUMA_DO *SUMAg_DOv;	/*!< Global pointer to Displayable Object structure vector*/
3966 extern int SUMAg_N_DOv; /*!< Number of DOs stored in DOv */
3967 extern SUMA_CommonFields *SUMAg_CF; /*!< Global pointer to structure containing info common to all viewers */
3968 
3969 // char *clippingPlaneFile;   // PDL
3970 
3971 
3972 #endif
3973