1 /*****************************************************************************
2    Major portions of this software are copyrighted by the Medical College
3    of Wisconsin, 1994-2000, and are released under the Gnu General Public
4    License, Version 2.  See the file README.Copyright for details.
5 ******************************************************************************/
6 
7 #include "afni.h"
8 #include "afni_plugout.h"
9 #include "thd_ttatlas_query.h"
10 
11 extern SUMA_Boolean SUMA_Register_Widget_Help(Widget w, int type, char *name,
12                                               char *hint, char *help) ;
13 
14 #undef  USE_QQQQ  /* for testing TCSV */
15 #ifdef  USE_QQQQ
16 /*--------------------------------------------------------------------*/
17 
AFNI_qqqq_CB(Widget w,XtPointer cd,XtPointer cbd)18 static void AFNI_qqqq_CB( Widget w , XtPointer cd , XtPointer cbd )
19 {
20    Three_D_View *im3d = (Three_D_View *)cd ;
21 
22    MCW_choose_tcsv( im3d->vwid->imag->topper ,
23                     "Choose .tsv or .csv file" ,
24                     GLOBAL_library.tcsv_data , -1 ,
25                     NULL , NULL ) ;
26    return ;
27 }
28 #endif
29 
30 /*---------------------------------------------------------------*/
31 /*------------ Stuff for logos and pixmap definitions -----------*/
32 #undef MAIN
33 #define WANT_LOGO_BITMAP
34 #define WANT_AFNI_BITMAP
35 #undef  USE_IMPIX
36 
37 #include "logo.h"              /* declares global pixmap variables */
38 
39 #ifdef WANT_AFNI_BITMAP        /* used for various icons          */
40 #  include "afni48.xbm"        /* iconified controller window     */
41 #  include "afni48cor.xbm"     /* iconified coronal image window  */
42 #  include "afni48axi.xbm"     /* iconified axial image window    */
43 #  include "afni48sag.xbm"     /* iconified sagittal image window */
44 #  include "afni48gra.xbm"     /* no longer used                  */
45 #  include "afni48gracor.xbm"  /* iconified coronal graph window  */
46 #  include "afni48grasag.xbm"  /* iconified sagittal graph window */
47 #  include "afni48graaxi.xbm"  /* iconified axial graph window    */
48 #  include "afni16.xbm"        /* used for 'AFNI' form background */
49 #endif /* WANT_AFNI_BITMAP */
50 
51 #ifdef WANT_LOGO_BITMAP        /* now only used for PseudoColor */
52 #ifdef USE_MCWLOGO             /* for TrueColor, the color logo */
53 #  include "mcw.xbm"           /* in "lll.h" is used instead.   */
54 #elif defined(USE_RWCLOGO)
55 #  include "rwc.xbm"
56 #else
57 #  include "nih.xbm"
58 #endif
59 #endif /* WANT_LOGO_BITMAP */
60 /*---------------------------------------------------------------*/
61 
62 /** if USE_OPTMENUS is defined, then option menus will
63     be used in place of MCW_arrowvals wherever possible **/
64 
65 #ifndef DONT_USE_OPTMENUS
66 #  ifndef USE_OPTMENUS
67 #    define USE_OPTMENUS
68 #  endif
69 #endif
70 #define COLSIZE AV_colsize()
71 
72 #ifdef USE_OPTMENUS
73 #  define AVOPT_STYLE MCW_AV_optmenu
74 #else
75 #  define AVOPT_STYLE MCW_AV_downup
76 #endif
77 
78 #ifdef AFNI_DEBUG
79 #  define REPORT_PROGRESS(str)  /* nada */
80 #else
81 #  define REPORT_PROGRESS(str)  \
82     do{ if(AFNI_VERBOSE){printf(str);fflush(stdout);} } while(0)
83 #endif
84 
85 static int num_entry = 0 ;  /* 31 Aug 1999 */
86 
87 #define REFRESH         \
88   if( num_entry == 1 ){ \
89      XmUpdateDisplay(im3d->vwid->top_shell); REPORT_PROGRESS("."); }
90 
91 /*---------------------------------------------------------------------
92    Make all the rest of the widgets for a Three_D_View
93    (after the toplevel shell has been created)
94 -----------------------------------------------------------------------*/
95 
96 static char *AFNI_dummy_av_label[2] = { "Nothing 1" , "Nothing 2" } ;
97 
98 static char *AFNI_crosshair_av_label[9] = {  /* modified 31 Dec 1998 */
99     "Off"   , "Single" , "Multi" ,
100     " LR+AP", " LR+IS" , " AP+IS",
101     "  LR"  , "  AP"   , "  IS"    } ;
102 
103 static char *AFNI_see_marks_bbox_label[1] = { "See Markers" } ;
104 
105 static char *AFNI_see_func_bbox_label[1] = { "See OverLay" } ;
106 
107 static char *AFNI_wrap_bbox_label[1] = {"Wrap"} ;
108 static char *AFNI_xhall_bbox_label[1] = {"X+"} ;
109 
110 static char *AFNI_marks_edits_bbox_label[1] = { "Allow edits" } ;
111 
112 static char *AFNI_range_bbox_label[1] = { "autoRange:xxxxxxxxx" } ;
113 static char *AFNI_perc_bbox_label[1] = { "%" } ;
114 
115 static char *AFNI_inten_bbox_label[1] = { "Pos?" } ;
116 
117 static char *AFNI_tlrc_big_bbox_label[1] = { "Big Talairach Box?" } ;
118 
119 #define AFNI_tlrc_big_bbox_help                                       \
120    "pressed IN:  Uses a larger 'bounding box' when creating\n"        \
121    "             the Talairach view; this extends 10 mm more\n"       \
122    "             inferior than the old box, which will encompass\n"   \
123    "             all of the cerebellum and more of the brainstem.\n"  \
124    "\n"                                                               \
125    "pressed OUT: Uses the old 'bounding box' size when creating\n"    \
126    "             the Talairach view; this is for compatibility\n"     \
127    "             with BRIKs created with older versions of AFNI.\n"   \
128    "\n"                                                               \
129    "Nota Bene:   The state of this button is only used by AFNI at\n"  \
130    "             moment the 'Transform Data' button is used to\n"     \
131    "             transform from the AC-PC aligned view to the\n"      \
132    "             Talairach view."
133 
134 static char *AFNI_anatmode_bbox_label[2] =
135    { "View ULay Data Brick" , "Warp ULay on Demand" } ;
136 
137 static char *AFNI_funcmode_bbox_label[2] =
138    { "View OLay Data Brick" , "Warp OLay on Demand" } ;
139 
140 #define AFNI_see_marks_bbox_help                       \
141    "pressed IN:  markers for this view will display\n" \
142    "pressed OUT: markers for this view won't display\n"\
143    "\n"                                                \
144    "Markers are used to specify anatomical locations\n"\
145    "required for transformation of coordinates.\n"     \
146    "\n"                                                \
147    "Oct 1998: Also controls the display of dataset\n"  \
148    "          'tags' -- see the 'Edit Tagset' plugin."
149 
150 #define AFNI_see_func_bbox_help                        \
151    "pressed IN:  overlay dataset will display\n"       \
152    "pressed OUT: overlay dataset won't display"        \
153    "\n"                                                \
154    "This is useful for seeing what anatomical\n"       \
155    "features are 'under' a particular overlay color."
156 
157 #define AFNI_marks_edits_bbox_help                            \
158    "pressed IN:  you are allowed to change the markers\n"     \
159    "pressed OUT: you aren't allowed to change the markers\n\n"\
160    "WARNING: if you previously executed a geometric\n"        \
161    "transformation, and then re-execute it with\n"            \
162    "altered markers, you will re-write the old transformed\n" \
163    "dataset, AND also destroy any 'downstream' transformed\n" \
164    "datasets -- for example, re-doing a AC-PC aligned view\n" \
165    "will destroy the Talairach view (if any) that follows it"
166 
167 #define AFNI_crosshair_av_help                   \
168    "Off:    no display of crosshairs\n"          \
169    "Single: display of single crosshairs\n"      \
170    "Multi:  display of crosshairs for each\n"    \
171    "         slice in the 'montage' layouts\n"   \
172    "LR+AP:  display crosshairs only parallel\n"  \
173    "         to the L-R and A-P axes [etc.]\n\n" \
174    "N.B.: When a slice has an image viewer\n"    \
175    " and a grapher open at the same time,\n"     \
176    " then a 'frame' will be drawn around\n"      \
177    " the voxels being graphed.  In Single\n"     \
178    " crosshair mode, only this frame will\n"     \
179    " be drawn.  In Multi mode, the actual\n"     \
180    " crosshairs will also be drawn.\n"           \
181    "N.B.: You can set AFNI_CROSSHAIR_LINES\n"    \
182    " in Datamode->Misc->Edit Environment\n"      \
183    " to have crosshairs drawn as thin lines\n"   \
184    " rather than as overlaid voxels."
185 
186 #define AFNI_crosshair_color_help \
187    "Controls the\n"               \
188    "crosshair color\n"            \
189    "in the image\n"               \
190    "viewing windows."
191 
192 #define AFNI_crosshair_gap_help  \
193    "Controls the crosshair\n"    \
194    "gap (in voxels).\n\n"        \
195    "N.B.: When a grapher is\n"   \
196    "  opened with an image\n"    \
197    "  viewer, then the gap\n"    \
198    "  in that viewer will\n"     \
199    "  be replaced by a\n"        \
200    "  frame drawn around the\n"  \
201    "  voxels being graphed."
202 
203 #define AFNI_crosshair_label_help      \
204    "Displays coordinates of\n"         \
205    "the crosshair point in the\n"      \
206    "DICOM coordinates (3D input)\n"    \
207    "or voxel indices (image input)\n"  \
208    "The * indicates that you are  \n"  \
209    "viewing an oblique dataset and\n"  \
210    "voxel coordinates are those of\n"  \
211    "closest cardinal orientation.\n"   \
212    "\n"                                \
213    "A Button-3 popup menu lets you\n"  \
214    "change coordinate display order."
215 
216 #define AFNI_view_help                            \
217    "Normal:   button opens viewing window\n"      \
218    "Inverted: button raises opened window\n"      \
219    "     * Right-click on inverted button\n"      \
220    "       'fetches' image/graph window\n\n"      \
221    "N.B.: AFNI does not read datasets from\n"     \
222    "      disk until a window is opened.\n"       \
223    "      This can make opening the first\n"      \
224    "      viewing window be quite slow.\n"        \
225    "\n"                                           \
226    "The Graph buttons are only enabled for\n"     \
227    "datasets that are viewing their data files\n" \
228    "directly (NOT warping on demand -- see the\n" \
229    "top of the 'Define Datamode' control panel)"
230 
231 #define AFNI_disp_pcolor_help  \
232    "Controls the color used\n" \
233    "to display the selected\n" \
234    "marker (the 'primary').\n" \
235    "\n"                        \
236    "Oct 1998: Also controls\n" \
237    "   the color for 'tags'."
238 
239 #define AFNI_disp_scolor_help   \
240    "Controls the color used\n"  \
241    "to display non-selected\n"  \
242    "markers (the 'secondaries')"
243 
244 #define AFNI_disp_size_help   \
245    "Controls the size\n"      \
246    "of the markers on\n"      \
247    "the screen (pixels)"
248 
249 #define AFNI_disp_gap_help    \
250    "Controls the gap\n"       \
251    "in the markers'\n"        \
252    "cross (in pixels)"
253 
254 #define AFNI_marks_set_help    \
255    "Use this button to\n"      \
256    "set or reset the chosen\n" \
257    "marker point"
258 
259 #define AFNI_marks_clear_help   \
260    "Use this button to\n"       \
261    "clear (unset) the chosen\n" \
262    "marker point"
263 
264 #define AFNI_marks_quality_help     \
265  "Use this button to run quality\n" \
266  "checks on the marker set\n"       \
267  "after all markers are defined\n"  \
268  "and to enable the transformation"
269 
270 #define AFNI_help_help \
271    "Click the hand\n"   \
272    "on any button to\n"  \
273    "get a little help\n"  \
274    " ----- OR -----\n"     \
275    "Use the Motif Help\n"   \
276    "key (usually F1) if\n"   \
277    "the cursor is over\n"     \
278    "a button."
279 
280 #define AFNI_quit_help     \
281    "  Press (twice) to\n"  \
282    "  close this AFNI\n"   \
283    "  control window.\n\n" \
284    "N.B.: when the last\n" \
285    "  control window is\n" \
286    "  closed, AFNI will\n" \
287    "  quit.\n\n"            \
288    "Pressing this button\n"  \
289    "with the Shift or Ctrl\n" \
290    "keys, or with the other\n" \
291    "mouse buttons also down,\n" \
292    "will also make AFNI quit."
293 
294 #define AFNI_marks_transform_help                             \
295    "Use this button to execute the geometric\n"               \
296    "transformation when all the marker points\n"              \
297    "have been properly defined.\n\n"                          \
298    "WARNING: if you previously executed a geometric\n"        \
299    "transformation, and then re-execute it with\n"            \
300    "altered markers, you will re-write the old transformed\n" \
301    "dataset, AND also destroy any 'downstream' transformed\n" \
302    "datasets -- for example, re-doing a AC-PC aligned view\n" \
303    "will destroy the Talairach view (if any) that follows it"
304 
305 #define AFNI_disp_resam_vox_help            \
306    "Use the arrows (or type) to set the\n"  \
307    "(cubical) voxel dimensions for the\n"   \
308    "data resampling"
309 
310 #define PVALUE_COLOR "#002244"
311 
312 /************* data for all widget create sub-functions ***************/
313 
314 /*** this is needed because of memory problems with the HP compiler ***/
315 #ifdef HP
316 #pragma OPT_LEVEL 1
317 #endif
318 
319 static   AFNI_widget_set       *vwid  ;
320 static   AFNI_imaging_widgets  *imag  ;
321 static   AFNI_viewing_widgets  *view  ;
322 static   AFNI_marks_widgets    *marks ;
323 static   AFNI_function_widgets *func  ;
324 static   AFNI_program_widgets  *prog  ;
325 static   AFNI_datamode_widgets *dmode ;
326 
327 static   XmString   xstr ;
328 static   XmFontList xflist=(XmFontList)NULL ;
329 static   int        id , npane , last_color ,
330                     view_count , view_height , sel_height ;
331 
332 static int FIRST_widcall = 1 ;  /* 22 Dec 2009 */
333 
334 void AFNI_make_wid1 (Three_D_View *) ;
335 void AFNI_make_wid2 (Three_D_View *) ;
336 void AFNI_make_wid3 (Three_D_View *) ;
337 
338 static Widget wtemp ;
339 static char jumpstring[128];                  /* 13 Jun 2014 */
340 
341 /*--------------------------------------------------------------------*/
342 
AFNI_make_widgets(Three_D_View * im3d)343 void AFNI_make_widgets( Three_D_View *im3d )
344 {
345    char *s=NULL;
346 
347 ENTRY("AFNI_make_widgets") ;
348 
349    /*---- initialize -----*/
350 
351    if( ! IM3D_VALID(im3d) )   /* should never happen! */
352      ERROR_exit("illegal call to AFNI_make_widgets") ;
353 
354    if( num_entry == 0 && GLOBAL_browser == NULL ) /* 16 May 2019 */
355      GLOBAL_browser = GetAfniWebBrowser();
356 
357    num_entry++ ;
358 
359    last_color = im3d->dc->ovc->ncol_ov - 1 ;
360 
361    vwid         = im3d->vwid ;
362    vwid->parent = im3d ;
363 
364    vwid->butx = vwid->buty = 9 ; /* 17 May 2005 */
365 
366 #ifdef USING_LESSTIF
367    /* In Lesstif, using form spacing, shifts the
368    top left corner in unsightly ways. Little
369    spacing looks better    Lesstif Patrol Jan 09*/
370    #define AFNI_FORM_SPACING 1
371 #else
372    #define AFNI_FORM_SPACING 9
373 #endif
374 STATUS("creating top_form") ;
375 
376    vwid->top_form =
377       XtVaCreateWidget(
378          "dialog" , xmFormWidgetClass , vwid->top_shell ,
379             XmNborderWidth , 0 ,
380             XmNmarginHeight , AFNI_FORM_SPACING ,
381             XmNmarginWidth  , AFNI_FORM_SPACING ,
382             XmNtraversalOn , True  ,
383             XmNinitialResourcesPersistent , False ,
384          NULL ) ;
385 
386    s = SUMA_append_string(AFNI_tophelp,
387          ":SPX:\n\n"
388          "   .. figure:: media/AfniCont.auto.jpg\n"
389          "      :name: media/AfniCont.auto.jpg\n"
390          "      :align: center\n\n"
391          "      :ref: `(link)<media/AfniCont.auto.jpg>`\n"
392          "\n"
393          ":SPX:") ;
394    SUMA_Register_Widget_Help( vwid->top_form, 0, "AfniCont",
395                               NULL, s); s = NULL; /* Do not free s */
396    vwid->file_dialog = NULL ; /* Mar 1997 */
397 
398    /* create pixmaps, if desired */
399 
400 #if defined(WANT_LOGO_BITMAP) || defined(WANT_AFNI_BITMAP)
401    {  Pixel bg_pix=0  , fg_pix  ;  /* colors: from control window */
402       Pixel bot_pix=0 , top_pix ;  /* colors: from image windows  */
403 
404 #ifdef USE_IMPIX              /** which colors to use for program icons **/
405 #  define ICON_bg bot_pix     /* use image display pixels */
406 #  define ICON_fg top_pix
407 #else
408 #  define ICON_bg bg_pix      /* use widget pixels (e.g., FALLback in afni.h) */
409 #  define ICON_fg fg_pix
410 #endif
411 
412       XtVaGetValues( vwid->top_form ,
413                        XmNforeground , &bg_pix ,  /* note reversal of roles here! */
414                        XmNbackground , &fg_pix ,
415                       NULL ) ;
416 
417       bot_pix = im3d->dc->pix_im[0] ;
418       top_pix = im3d->dc->pix_im[im3d->dc->ncol_im-1] ;
419 
420 #ifdef WANT_LOGO_BITMAP
421 STATUS("WANT_LOGO_BITMAP") ;
422       if( logo_pixmap == XmUNSPECIFIED_PIXMAP ){
423 
424 #ifndef NO_FRIVOLITIES
425 #include "lll.h"  /* contains the colorized image logos used below */
426 
427 #define RGB_TO_PIXMAP(data,pnam)                                           \
428  do{ mri_fix_data_pointer( data , bim ) ;                                  \
429      STATUS("RGB_TO_PIXMAP") ;                                             \
430      pnam = XCreatePixmap( im3d->dc->display ,                             \
431                            RootWindowOfScreen(im3d->dc->screen) ,          \
432                            lll_width , lll_height , im3d->dc->planes ) ;   \
433      xim = rgb_to_XImage( im3d->dc , bim ) ;                               \
434      if( xim != NULL ) XPutImage( im3d->dc->display , pnam ,               \
435                                   im3d->dc->origGC ,                       \
436                                   xim , 0,0, 0,0, lll_width,lll_height ) ; \
437      MCW_kill_XImage( xim );                                               \
438  } while(0)
439 
440         if( im3d->dc->visual_class == TrueColor ){  /* 23 Sep 2001 */
441           MRI_IMAGE *bim ; XImage *xim ;
442           bim = mri_new_vol_empty( lll_width,lll_height,1 , MRI_rgb ) ;
443 
444           /*** to find places where these logos are used, try this:
445                  grep PICTUR af*.[ch]                               ***/
446 
447           /* AFNI sunburst logo */
448 
449           RGB_TO_PIXMAP(lll_rgb    ,logo_pixmap   ) ;
450 
451           /* version warning logo */
452 
453           RGB_TO_PIXMAP(vvv_rgb    ,vers_pixmap   ) ;  /* 08 Aug 2005 */
454 
455           /* these logos are what vary by controller index */
456 
457           RGB_TO_PIXMAP(rhdda_rgb  ,pict_pixmap[0]) ;  /* 19 Oct 2007 */
458           RGB_TO_PIXMAP(sbuck_rgb  ,pict_pixmap[1]) ;  /* 18 Oct 2007 */
459           RGB_TO_PIXMAP(sscc_rgb   ,pict_pixmap[2]) ;  /* 22 Oct 2007 */
460           RGB_TO_PIXMAP(earth_rgb  ,pict_pixmap[3]) ;  /* 22 Oct 2007 */
461           RGB_TO_PIXMAP(nih_rgb    ,pict_pixmap[4]) ;  /* 25 Oct 2007 */
462           RGB_TO_PIXMAP(burst_rgb  ,pict_pixmap[5]) ;  /* 18 Oct 2007 */
463           RGB_TO_PIXMAP(nih2012_rgb,pict_pixmap[6]) ;  /* 07 Dec 2012 */
464 
465           mri_clear_data_pointer(bim); mri_free(bim);
466         }
467 #endif
468 
469         if( logo_pixmap == XmUNSPECIFIED_PIXMAP )         /* original code */
470           logo_pixmap = XCreatePixmapFromBitmapData(      /* B&W pixmap logo */
471                           XtDisplay(vwid->top_shell) ,
472                           RootWindowOfScreen(XtScreen(vwid->top_shell)) ,
473                           logo_bits , logo_width , logo_height ,
474                           fg_pix , bg_pix ,
475                           DefaultDepthOfScreen(XtScreen(vwid->top_shell)) ) ;
476       }
477 #endif
478 
479 #ifdef WANT_AFNI_BITMAP
480 STATUS("WANT_AFNI_BITMAP") ;
481       if( afni48_pixmap == XmUNSPECIFIED_PIXMAP )
482         afni48_pixmap = XCreatePixmapFromBitmapData(
483                          XtDisplay(vwid->top_shell) ,
484                          RootWindowOfScreen(XtScreen(vwid->top_shell)) ,
485                          afni48_bits , afni48_width , afni48_height ,
486                          ICON_fg , ICON_bg ,
487                          DefaultDepthOfScreen(XtScreen(vwid->top_shell)) ) ;
488 
489       if( afni48cor_pixmap == XmUNSPECIFIED_PIXMAP )
490         afni48cor_pixmap = XCreatePixmapFromBitmapData(
491                          XtDisplay(vwid->top_shell) ,
492                          RootWindowOfScreen(XtScreen(vwid->top_shell)) ,
493                          afni48cor_bits , afni48cor_width , afni48cor_height ,
494                          ICON_fg , ICON_bg ,
495                          DefaultDepthOfScreen(XtScreen(vwid->top_shell)) ) ;
496 
497       if( afni48sag_pixmap == XmUNSPECIFIED_PIXMAP )
498         afni48sag_pixmap = XCreatePixmapFromBitmapData(
499                          XtDisplay(vwid->top_shell) ,
500                          RootWindowOfScreen(XtScreen(vwid->top_shell)) ,
501                          afni48sag_bits , afni48sag_width , afni48sag_height ,
502                          ICON_fg , ICON_bg ,
503                          DefaultDepthOfScreen(XtScreen(vwid->top_shell)) ) ;
504 
505       if( afni48axi_pixmap == XmUNSPECIFIED_PIXMAP )
506         afni48axi_pixmap = XCreatePixmapFromBitmapData(
507                          XtDisplay(vwid->top_shell) ,
508                          RootWindowOfScreen(XtScreen(vwid->top_shell)) ,
509                          afni48axi_bits , afni48axi_width , afni48axi_height ,
510                          ICON_fg , ICON_bg ,
511                          DefaultDepthOfScreen(XtScreen(vwid->top_shell)) ) ;
512 
513       if( afni48gra_pixmap == XmUNSPECIFIED_PIXMAP )
514         afni48gra_pixmap = XCreatePixmapFromBitmapData(
515                          XtDisplay(vwid->top_shell) ,
516                          RootWindowOfScreen(XtScreen(vwid->top_shell)) ,
517                          afni48gra_bits , afni48gra_width , afni48gra_height ,
518                          ICON_fg , ICON_bg ,
519                          DefaultDepthOfScreen(XtScreen(vwid->top_shell)) ) ;
520 
521       if( afni48graaxi_pixmap == XmUNSPECIFIED_PIXMAP )
522         afni48graaxi_pixmap = XCreatePixmapFromBitmapData(
523                          XtDisplay(vwid->top_shell) ,
524                          RootWindowOfScreen(XtScreen(vwid->top_shell)) ,
525                          afni48graaxi_bits , afni48graaxi_width , afni48graaxi_height ,
526                          ICON_fg , ICON_bg ,
527                          DefaultDepthOfScreen(XtScreen(vwid->top_shell)) ) ;
528 
529       if( afni48grasag_pixmap == XmUNSPECIFIED_PIXMAP )
530         afni48grasag_pixmap = XCreatePixmapFromBitmapData(
531                          XtDisplay(vwid->top_shell) ,
532                          RootWindowOfScreen(XtScreen(vwid->top_shell)) ,
533                          afni48grasag_bits , afni48grasag_width , afni48grasag_height ,
534                          ICON_fg , ICON_bg ,
535                          DefaultDepthOfScreen(XtScreen(vwid->top_shell)) ) ;
536 
537       if( afni48gracor_pixmap == XmUNSPECIFIED_PIXMAP )
538         afni48gracor_pixmap = XCreatePixmapFromBitmapData(
539                          XtDisplay(vwid->top_shell) ,
540                          RootWindowOfScreen(XtScreen(vwid->top_shell)) ,
541                          afni48gracor_bits , afni48gracor_width , afni48gracor_height ,
542                          ICON_fg , ICON_bg ,
543                          DefaultDepthOfScreen(XtScreen(vwid->top_shell)) ) ;
544 
545       /* 28 Jan 2004: just for fun, background pixmaps for top forms */
546 
547       if( im3d->dc->visual_class == TrueColor &&
548           AFNI_yesenv("AFNI_LOGO16")          &&
549           afni16_pixmap[num_entry-1] == XmUNSPECIFIED_PIXMAP ){
550 
551         MRI_IMAGE *bim ; XImage *xim ; char ename[32], *ept ;
552         sprintf(ename,"AFNI_LOGO16_IMAGE_%c" , 'A'+num_entry-1 ) ;
553         ept = getenv(ename) ;
554         if( ept == NULL ) ept = getenv( "AFNI_LOGO16_IMAGE" ) ;
555         if( ept != NULL ){
556           bim = mri_read_just_one( ept ) ;
557           if( bim != NULL ){
558             if( bim->kind == MRI_rgb ){
559               xim = rgb_to_XImage( im3d->dc , bim ) ;
560               if( xim != NULL ){
561                 afni16_pixmap[num_entry-1] = XCreatePixmap( im3d->dc->display ,
562                                                  RootWindowOfScreen(im3d->dc->screen) ,
563                                                  bim->nx , bim->ny , im3d->dc->planes ) ;
564                 STATUS("XPutImage(background pixmap [LOGO16])") ;
565                 XPutImage( im3d->dc->display , afni16_pixmap[num_entry-1] ,
566                            im3d->dc->origGC , xim , 0,0 , 0,0 , bim->nx , bim->ny ) ;
567                 MCW_kill_XImage( xim ) ;
568               }
569             }
570             mri_free(bim) ;
571           }
572         }
573       }
574 
575       if( AFNI_yesenv("AFNI_COLORIZE_CONTROLLER") &&
576           im3d->dc->visual_class     == TrueColor &&
577           afni16_pixmap[num_entry-1] == XmUNSPECIFIED_PIXMAP ){ /* 17 Oct 2007 */
578 
579         MRI_IMAGE *bim ; XImage *xim ;
580         rgbyte ccc[3]={ {0,0,66}, {55,0,0}, {0,44,0} } , col[4] ;
581 
582         col[0] = ccc[ (num_entry-1)%4 ]; col[1] = ccc[ (num_entry+0)%4 ];
583         col[2] = ccc[ (num_entry+1)%4 ]; col[3] = col[0] ;
584         bim = mri_make_rainbow( 4 , 3*im3d->dc->height/4 , 4 , col ) ;
585         xim = rgb_to_XImage( im3d->dc , bim ) ;
586         afni16_pixmap[num_entry-1] = XCreatePixmap( im3d->dc->display ,
587                                       RootWindowOfScreen(im3d->dc->screen) ,
588                                       bim->nx , bim->ny , im3d->dc->planes ) ;
589         STATUS("XPutImage(background pixmap [RAINBOW])") ;
590         XPutImage( im3d->dc->display , afni16_pixmap[num_entry-1] ,
591                    im3d->dc->origGC , xim , 0,0 , 0,0 , bim->nx , bim->ny ) ;
592         MCW_kill_XImage( xim ) ;
593         mri_free(bim) ;
594       }
595 
596 #if 0
597       if( afni16_pixmap[num_entry-1] == XmUNSPECIFIED_PIXMAP && AFNI_yesenv("AFNI_LOGO16") ){
598         Pixel fg16=ICON_bg, bg16=ICON_fg ; int ic ; char ename[32] ;
599         char *fgn[7] = { "red", "blue-cyan", "green", "violet", "orange", "gray70", "yellow" };
600 
601         sprintf(ename,"AFNI_LOGO16_FOREGROUND_%c" , 'A'+num_entry-1 ) ;
602                      ic = DC_find_closest_overlay_color(im3d->dc, getenv(ename) ) ;
603         if( ic < 0 ) ic = DC_find_closest_overlay_color(im3d->dc, getenv("AFNI_LOGO16_FOREGROUND")) ;
604         if( ic < 0 ) ic = DC_find_closest_overlay_color(im3d->dc, fgn[(num_entry-1)%7] ) ;
605         if( ic >= 0 ) fg16 = im3d->dc->ovc->pix_ov[ic] ;
606 
607         sprintf(ename,"AFNI_LOGO16_BACKGROUND_%c" , 'A'+num_entry-1 ) ;
608                      ic = DC_find_closest_overlay_color(im3d->dc, getenv(ename) ) ;
609         if( ic < 0 ) ic = DC_find_closest_overlay_color(im3d->dc, getenv("AFNI_LOGO16_BACKGROUND")) ;
610 #if 0
611         if( ic < 0 ) ic = im3d->dc->ovc->ov_darkest ;
612 #endif
613         if( ic >= 0 ) bg16 = im3d->dc->ovc->pix_ov[ic] ;
614 
615         afni16_pixmap[num_entry-1] = XCreatePixmapFromBitmapData(
616                                       XtDisplay(vwid->top_shell) ,
617                                       RootWindowOfScreen(XtScreen(vwid->top_shell)) ,
618                                       afni16_bits , afni16_width , afni16_height ,
619                                       fg16 , bg16 ,
620                                       DefaultDepthOfScreen(XtScreen(vwid->top_shell)) ) ;
621       }
622 #endif
623 
624 #endif  /* WANT_AFNI_BITMAP */
625    }
626 #endif  /* if WANT any of the BITMAPs */
627 
628    if( afni16_pixmap[num_entry-1] != XmUNSPECIFIED_PIXMAP )
629      XtVaSetValues( vwid->top_form , XmNbackgroundPixmap,afni16_pixmap[num_entry-1] , NULL ) ;
630 
631    /* create each control panel, and a container frame for each */
632 
633 STATUS("creating control panels") ;
634 
635    imag =vwid->imag = myXtNew(AFNI_imaging_widgets) ;ADDTO_KILL(im3d->kl,imag);
636    view =vwid->view = myXtNew(AFNI_viewing_widgets) ;ADDTO_KILL(im3d->kl,view);
637    marks=vwid->marks= myXtNew(AFNI_marks_widgets)   ;ADDTO_KILL(im3d->kl,marks);
638    func =vwid->func = myXtNew(AFNI_function_widgets);ADDTO_KILL(im3d->kl,func);
639    prog =vwid->prog = myXtNew(AFNI_program_widgets) ;ADDTO_KILL(im3d->kl,prog);
640    dmode=vwid->dmode= myXtNew(AFNI_datamode_widgets);ADDTO_KILL(im3d->kl,dmode);
641 
642    imag->frame =
643       XtVaCreateWidget(
644          "dialog" , xmFrameWidgetClass , vwid->top_form ,
645             XmNleftAttachment , XmATTACH_FORM ,
646             XmNtopAttachment  , XmATTACH_FORM ,
647             XmNleftOffset     , AFNI_FORM_SPACING ,
648             XmNtopOffset      , AFNI_FORM_SPACING ,
649             XmNshadowType , XmSHADOW_ETCHED_IN ,
650             XmNshadowThickness , 5 ,
651             XmNtraversalOn , True  ,
652             XmNinitialResourcesPersistent , False ,
653          NULL ) ;
654 
655    view->frame =
656       XtVaCreateWidget(
657          "dialog" , xmFrameWidgetClass , vwid->top_form ,
658             XmNleftAttachment , XmATTACH_WIDGET ,
659             XmNleftWidget     , imag->frame ,
660             XmNtopAttachment  , XmATTACH_FORM ,
661 #ifdef USING_LESSTIF
662             XmNleftOffset     , 9 ,
663 #else
664             XmNleftOffset     , AFNI_FORM_SPACING ,
665 #endif
666             XmNtopOffset      , AFNI_FORM_SPACING ,
667             XmNshadowType , XmSHADOW_ETCHED_IN ,
668             XmNshadowThickness , 5 ,
669             XmNtraversalOn , True  ,
670             XmNinitialResourcesPersistent , False ,
671          NULL ) ;
672 
673    marks->frame =
674       XtVaCreateWidget(
675          "dialog" , xmFrameWidgetClass , vwid->top_form ,
676             XmNleftAttachment , XmATTACH_WIDGET ,
677             XmNleftWidget     , view->frame ,
678             XmNtopAttachment  , XmATTACH_FORM ,
679             XmNleftOffset     , AFNI_FORM_SPACING ,
680             XmNtopOffset      , AFNI_FORM_SPACING ,
681             XmNshadowType , XmSHADOW_ETCHED_IN ,
682             XmNshadowThickness , 5 ,
683             XmNtraversalOn , True  ,
684             XmNinitialResourcesPersistent , False ,
685          NULL ) ;
686 
687    func->frame =
688       XtVaCreateWidget(
689          "dialog" , xmFrameWidgetClass , vwid->top_form ,
690             XmNleftAttachment , XmATTACH_WIDGET ,
691             XmNleftWidget     , view->frame ,
692             XmNtopAttachment  , XmATTACH_FORM ,
693             XmNleftOffset     , AFNI_FORM_SPACING ,
694             XmNtopOffset      , AFNI_FORM_SPACING ,
695             XmNshadowType , XmSHADOW_ETCHED_IN ,
696             XmNshadowThickness , 5 ,
697             XmNtraversalOn , True  ,
698             XmNinitialResourcesPersistent , False ,
699          NULL ) ;
700 
701    dmode->frame =
702       XtVaCreateWidget(
703          "dialog" , xmFrameWidgetClass , vwid->top_form ,
704             XmNleftAttachment   , XmATTACH_WIDGET ,
705             XmNleftWidget       , view->frame ,
706             XmNtopAttachment    , XmATTACH_FORM ,
707             XmNleftOffset       , AFNI_FORM_SPACING ,
708             XmNtopOffset        , AFNI_FORM_SPACING ,
709             XmNshadowType , XmSHADOW_ETCHED_IN ,
710             XmNshadowThickness , 5 ,
711             XmNtraversalOn , True  ,
712             XmNinitialResourcesPersistent , False ,
713          NULL ) ;
714 
715    prog->frame =
716       XtVaCreateWidget(
717          "dialog" , xmFrameWidgetClass , vwid->top_form ,
718             XmNtopAttachment    , XmATTACH_WIDGET ,
719             XmNtopWidget        , imag->frame ,
720             XmNleftAttachment   , XmATTACH_FORM ,
721             XmNleftOffset     , AFNI_FORM_SPACING ,
722             XmNtopOffset      , AFNI_FORM_SPACING ,
723             XmNshadowType , XmSHADOW_ETCHED_IN ,
724             XmNshadowThickness , 5 ,
725             XmNtraversalOn , True  ,
726             XmNinitialResourcesPersistent , False ,
727          NULL ) ;
728 
729    /************* call other routines to create rest of widgets  *************/
730 
731                             REFRESH ;
732    AFNI_make_wid1( im3d ) ; REFRESH ;
733    AFNI_make_wid2( im3d ) ; REFRESH ;
734    AFNI_make_wid3( im3d ) ; REFRESH ;
735 
736 #ifdef ALLOW_PLUGINS
737    im3d->vwid->nplugbut = 0 ;
738    AFNI_plugin_button( im3d ) ; /* 07 Oct 1996 */
739 #endif
740 
741    /*---------------------------------------------------*/
742    /**************  finish up widgets *******************/
743    /*---------------------------------------------------*/
744 
745    XtManageChild( imag->frame ) ;
746    if( im3d->type == AFNI_3DDATA_VIEW ){
747       XtManageChild( view->frame ) ;
748    }
749    XtManageChild( prog->frame ) ;
750 
751    XtManageChild( vwid->top_form ) ;
752 
753    FIRST_widcall = 0 ;  /* 22 Dec 2009 */
754    EXRETURN ;
755 }
756 
757 /*------------------------------------------------------------------*/
758 
AFNI_raiseup_CB(Widget w,XtPointer cd,XtPointer cb)759 void AFNI_raiseup_CB( Widget w , XtPointer cd , XtPointer cb )
760 {
761    XMapRaised( XtDisplay(w) , XtWindow(XtParent(w)) ) ;
762 }
763 
764 /*--------------------------------------------------------------------*/
765 
AFNI_make_wid1(Three_D_View * im3d)766 void AFNI_make_wid1( Three_D_View *im3d )
767 {
768    int ii ;
769    int show_markers = AFNI_yesenv("AFNI_ENABLE_MARKERS") ;  /* 28 Apr 2010 */
770 
771 ENTRY("AFNI_make_wid1") ;
772 
773    /*----------------------------------------------------------*/
774    /***************** imaging controls *************************/
775    /*----------------------------------------------------------*/
776 
777    /*--- vertical rowcol to hold all imaging stuff ---*/
778 
779 STATUS("making imag->rowcol") ;
780 
781    imag->rowcol =
782       XtVaCreateWidget(
783          "dialog" , xmRowColumnWidgetClass , imag->frame ,
784             XmNpacking      , XmPACK_TIGHT ,
785             XmNorientation  , XmVERTICAL   ,
786             XmNtraversalOn , True  ,
787             XmNinitialResourcesPersistent , False ,
788          NULL ) ;
789 
790    /*--- popup menu to handle special imaging concerns ---*/
791 
792    imag->topper =           /* invisible widget to be parent of popup */
793       XtVaCreateManagedWidget(
794          "dialog" , xmSeparatorWidgetClass , imag->rowcol ,
795             XmNseparatorType , XmNO_LINE ,
796          NULL ) ;
797 
798 #ifdef BAD_BUTTON3_POPUPS   /* 21 Jul 2003 */
799    imag->popmenu =
800       XmCreatePopupMenu( vwid->top_form, "menu" , NULL , 0 ) ;
801 #else
802    imag->popmenu =
803       XmCreatePopupMenu( imag->topper  , "menu" , NULL , 0 ) ;
804 #endif
805 
806    SAVEUNDERIZE(XtParent(imag->popmenu)) ; /* 27 Feb 2001 */
807 
808    VISIBILIZE_WHEN_MAPPED(imag->popmenu) ;
809 #if 0
810     if( !AFNI_yesenv("AFNI_DISABLE_TEAROFF") ) TEAROFFIZE(imag->popmenu) ;
811 #endif
812 
813 /***
814    XtAddCallback( imag->popmenu ,
815                   XmNunmapCallback , AFNI_imag_pop_CB , im3d ) ;
816 ***/
817 
818    XtVaSetValues( imag->popmenu ,
819                      XmNradioBehavior , True ,
820                      XmNradioAlwaysOne , True  ,
821                      XmNspacing      , 1 ,
822                      XmNmarginHeight , 0 ,
823                      XmNmarginWidth  , 0 ,
824                   NULL ) ;
825 
826    /*--- instacorr set button in menu [06 May 2009] ---*/
827 
828    if( im3d->type == AFNI_3DDATA_VIEW ){
829       static char *bbox_label[1] = { "GIC: Apair MirrorLR" } ;
830 
831    /*---*/
832 
833       imag->pop_instacorr_pb =
834          XtVaCreateManagedWidget(
835             "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
836                LABEL_ARG("InstaCorr Set") ,
837                XmNmarginHeight , 0 ,
838                XmNtraversalOn , True  ,
839                XmNinitialResourcesPersistent , False ,
840             NULL ) ;
841       XtAddCallback( imag->pop_instacorr_pb , XmNactivateCallback ,
842                      AFNI_imag_pop_CB , im3d ) ;
843       XtSetSensitive( imag->pop_instacorr_pb , False ) ;
844 
845    /*---*/
846 
847       imag->pop_icorrapair_pb =  /* Apr 2013: for 3dGroupInCorr */
848          XtVaCreateWidget(       /* note is not managed now */
849             "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
850                LABEL_ARG("GIC: Apair Set") ,
851                XmNmarginHeight , 0 ,
852                XmNtraversalOn , True  ,
853                XmNinitialResourcesPersistent , False ,
854             NULL ) ;
855       XtAddCallback( imag->pop_icorrapair_pb , XmNactivateCallback ,
856                      AFNI_imag_pop_CB , im3d ) ;
857 
858    /*---*/
859 
860       imag->pop_icorramirr_pb =  /* note is not managed now */
861          XtVaCreateWidget(
862             "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
863                LABEL_ARG("GIC: Apair MirrorOFF") ,
864                XmNmarginHeight , 0 ,
865                XmNtraversalOn , True  ,
866                XmNinitialResourcesPersistent , False ,
867             NULL ) ;
868       XtAddCallback( imag->pop_icorramirr_pb , XmNactivateCallback ,
869                      AFNI_imag_pop_CB , im3d ) ;
870 
871    /*---*/
872 
873       imag->pop_icorrjump_pb =
874          XtVaCreateManagedWidget(
875             "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
876                LABEL_ARG("InstaCorr SeedJump") ,
877                XmNmarginHeight , 0 ,
878                XmNtraversalOn , True  ,
879                XmNinitialResourcesPersistent , False ,
880             NULL ) ;
881       XtAddCallback( imag->pop_icorrjump_pb , XmNactivateCallback ,
882                      AFNI_imag_pop_CB , im3d ) ;
883       XtSetSensitive( imag->pop_icorrjump_pb , False ) ;
884 
885       (void) XtVaCreateManagedWidget(  /* Apr 2013 */
886                "dialog" , xmSeparatorWidgetClass , imag->popmenu ,
887                           XmNseparatorType , XmSINGLE_LINE ,
888                NULL ) ;
889    } else {
890       imag->pop_instacorr_pb   = NULL ;
891       imag->pop_icorrjump_pb   = NULL ;
892       imag->pop_icorrapair_pb  = NULL ;  /* Apr 2013 */
893       imag->pop_icorramirr_pb  = NULL ;
894    }
895 
896    /*--- jumpback button in menu ---*/
897 
898    imag->pop_jumpback_pb =
899       XtVaCreateManagedWidget(
900          "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
901             LABEL_ARG("Jumpback") ,
902             XmNmarginHeight , 0 ,
903             XmNtraversalOn , True  ,
904             XmNinitialResourcesPersistent , False ,
905          NULL ) ;
906    XtAddCallback( imag->pop_jumpback_pb , XmNactivateCallback ,
907                   AFNI_imag_pop_CB , im3d ) ;
908 
909    /*--- jumpto button in menu ---*/
910 
911    if( im3d->type == AFNI_3DDATA_VIEW ){
912       imag->pop_jumpto_pb =
913          XtVaCreateManagedWidget(
914             "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
915                LABEL_ARG("Jump to (xyz)") ,
916                XmNmarginHeight , 0 ,
917                XmNtraversalOn , True  ,
918                XmNinitialResourcesPersistent , False ,
919             NULL ) ;
920       XtAddCallback( imag->pop_jumpto_pb , XmNactivateCallback ,
921                      AFNI_imag_pop_CB , im3d ) ;
922    } else {
923       imag->pop_jumpto_pb = NULL ;
924    }
925 
926    if( im3d->type == AFNI_3DDATA_VIEW ){
927       imag->pop_jumpto_ijk_pb =
928          XtVaCreateManagedWidget(
929             "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
930                LABEL_ARG("Jump to (ijk UL)") ,
931                XmNmarginHeight , 0 ,
932                XmNtraversalOn , True  ,
933                XmNinitialResourcesPersistent , False ,
934             NULL ) ;
935       XtAddCallback( imag->pop_jumpto_ijk_pb , XmNactivateCallback ,
936                      AFNI_imag_pop_CB , im3d ) ;
937 
938       imag->pop_jumpto_ijk_olay_pb =  /* 20 Apr 2016 */
939          XtVaCreateManagedWidget(
940             "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
941                LABEL_ARG("Jump to (ijk OL)") ,
942                XmNmarginHeight , 0 ,
943                XmNtraversalOn , True  ,
944                XmNinitialResourcesPersistent , False ,
945             NULL ) ;
946       XtAddCallback( imag->pop_jumpto_ijk_olay_pb , XmNactivateCallback ,
947                      AFNI_imag_pop_CB , im3d ) ;
948    } else {
949       imag->pop_jumpto_ijk_pb      = NULL ;
950       imag->pop_jumpto_ijk_olay_pb = NULL ;
951    }
952 
953    /*--- mnito button in menu [01 May 2002] ---*/
954 
955    if( im3d->type == AFNI_3DDATA_VIEW ){
956       sprintf(jumpstring, "Jump to (%s)", get_jump_space());
957       imag->pop_mnito_pb =
958          XtVaCreateManagedWidget(
959             "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
960                LABEL_ARG(jumpstring) ,
961                XmNmarginHeight , 0 ,
962                XmNtraversalOn , True  ,
963                XmNinitialResourcesPersistent , False ,
964             NULL ) ;
965       XtAddCallback( imag->pop_mnito_pb , XmNactivateCallback ,
966                      AFNI_imag_pop_CB , im3d ) ;
967    } else {
968       imag->pop_mnito_pb = NULL ;
969    }
970 
971    /*--- Jump to cluster button in menu [19 Oct 2012] ---*/
972 
973    if( im3d->type == AFNI_3DDATA_VIEW ){
974       imag->pop_jumpto_clus_pb =
975          XtVaCreateManagedWidget(
976             "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
977                LABEL_ARG("Jump to (Cluster)") ,
978                XmNmarginHeight , 0 ,
979                XmNtraversalOn , True  ,
980                XmNinitialResourcesPersistent , False ,
981             NULL ) ;
982       XtAddCallback( imag->pop_jumpto_clus_pb , XmNactivateCallback ,
983                      AFNI_imag_pop_CB , im3d ) ;
984       SENSITIZE(imag->pop_jumpto_clus_pb,False) ;
985    } else {
986       imag->pop_jumpto_clus_pb = NULL ;
987    }
988 
989    /*--- sumato button in menu ---*/
990 
991    if( im3d->type == AFNI_3DDATA_VIEW ){
992       imag->pop_sumato_pb =
993          XtVaCreateManagedWidget(
994             "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
995                LABEL_ARG("SUMA to (node)") ,
996                XmNmarginHeight , 0 ,
997                XmNtraversalOn , True  ,
998                XmNinitialResourcesPersistent , False ,
999             NULL ) ;
1000       XtAddCallback( imag->pop_sumato_pb , XmNactivateCallback ,
1001                      AFNI_imag_pop_CB , im3d ) ;
1002    } else {
1003       imag->pop_sumato_pb = NULL ;
1004    }
1005 
1006    /*--- create button to Move crosshairs to position in atlas,
1007            formerly "Talairach to" ---*/
1008 
1009    if( im3d->type == AFNI_3DDATA_VIEW ){
1010       imag->pop_talto_pb =
1011          XtVaCreateManagedWidget(
1012             "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
1013                LABEL_ARG("-Go to atlas location") ,
1014                XmNmarginHeight , 0 ,
1015                XmNtraversalOn , True  ,
1016                XmNinitialResourcesPersistent , False ,
1017             NULL ) ;
1018       XtAddCallback( imag->pop_talto_pb , XmNactivateCallback ,
1019                      AFNI_imag_pop_CB , im3d ) ;
1020       if( TT_retrieve_atlas_dset("TT_Daemon",0) ){
1021          imag->pop_whereami_pb =        /* 10 Jul 2001 */
1022             XtVaCreateManagedWidget(
1023                "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
1024                   LABEL_ARG("-Where Am I?") ,
1025                   XmNmarginHeight , 0 ,
1026                   XmNtraversalOn , True  ,
1027                   XmNinitialResourcesPersistent , False ,
1028                NULL ) ;
1029          XtAddCallback( imag->pop_whereami_pb , XmNactivateCallback ,
1030                         AFNI_imag_pop_CB , im3d ) ;
1031 
1032          imag->pop_ttren_pb =
1033             XtVaCreateManagedWidget(
1034                "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
1035                   LABEL_ARG("-Atlas Colors") ,
1036                   XmNmarginHeight , 0 ,
1037                   XmNtraversalOn , True  ,
1038                   XmNinitialResourcesPersistent , False ,
1039                NULL ) ;
1040          XtAddCallback( imag->pop_ttren_pb , XmNactivateCallback ,
1041                         AFNI_imag_pop_CB , im3d ) ;
1042 
1043       } else {
1044         static int first=1 ;
1045         imag->pop_ttren_pb = imag->pop_whereami_pb = NULL ;
1046         if( first ){
1047           first = 0 ;
1048           fprintf(stderr,
1049            "\n++ WARNING: Can't find TTatlas+tlrc or TTatlas.nii.gz dataset for 'whereami'!\n"
1050              "++--------- See https://afni.nimh.nih.gov/pub/dist/data/\n" ) ;
1051         }
1052       }
1053       imag->pop_whereami_twin = NULL ;
1054       imag->pop_whereami_htmlwin = NULL;
1055    } else {
1056       imag->pop_talto_pb = NULL ;
1057       imag->pop_ttren_pb = imag->pop_whereami_pb = NULL ; /* 10 Jul 2001 */
1058       imag->pop_whereami_twin = NULL ;
1059       imag->pop_whereami_htmlwin = NULL;
1060    }
1061 
1062    /*-- separator --*/
1063 
1064    (void) XtVaCreateManagedWidget(  /* Apr 2013 */
1065             "dialog" , xmSeparatorWidgetClass , imag->popmenu ,
1066                        XmNseparatorType , XmSINGLE_LINE ,
1067             NULL ) ;
1068 
1069    /*--- imageonly button in menu ---*/
1070 
1071    imag->pop_imageonly_pb =
1072       XtVaCreateManagedWidget(
1073          "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
1074             LABEL_ARG("Image display") ,
1075             XmNmarginHeight , 0 ,
1076             XmNtraversalOn , True  ,
1077             XmNinitialResourcesPersistent , False ,
1078          NULL ) ;
1079    XtAddCallback( imag->pop_imageonly_pb , XmNactivateCallback ,
1080                   AFNI_imag_pop_CB , im3d ) ;
1081 
1082    /*--- environment button in menu [05 Nov 2003] ---*/
1083 
1084 #ifdef ALLOW_PLUGINS
1085    imag->pop_environment_pb =
1086       XtVaCreateManagedWidget(
1087          "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
1088             LABEL_ARG("Edit Environment") ,
1089             XmNmarginHeight , 0 ,
1090             XmNtraversalOn , True  ,
1091             XmNinitialResourcesPersistent , False ,
1092          NULL ) ;
1093    XtAddCallback( imag->pop_environment_pb , XmNactivateCallback ,
1094                   AFNI_imag_pop_CB , im3d ) ;
1095 
1096    /*---*/
1097 
1098    imag->pop_drawdataset_pb =
1099       XtVaCreateManagedWidget(
1100          "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
1101             LABEL_ARG("Draw ROI plugin") ,
1102             XmNmarginHeight , 0 ,
1103             XmNtraversalOn , True  ,
1104             XmNinitialResourcesPersistent , False ,
1105          NULL ) ;
1106    XtAddCallback( imag->pop_drawdataset_pb , XmNactivateCallback ,
1107                   AFNI_imag_pop_CB , im3d ) ;
1108 #else
1109    imag->pop_environment_pb = NULL ;
1110    imag->pop_drawdataset_pb = NULL ;
1111 #endif
1112 
1113    /*--- frame to hold all crosshair stuff ---*/
1114 
1115    imag->crosshair_frame =
1116       XtVaCreateManagedWidget(
1117          "dialog" , xmFrameWidgetClass , imag->rowcol ,
1118             XmNshadowType , XmSHADOW_ETCHED_IN ,
1119             XmNshadowThickness , 2 ,
1120             XmNtraversalOn , True  ,
1121             XmNinitialResourcesPersistent , False ,
1122          NULL ) ;
1123 
1124    /*--- rowcol to manage crosshair stuff ---*/
1125 
1126    imag->crosshair_rowcol =
1127       XtVaCreateWidget(
1128          "dialog" , xmRowColumnWidgetClass , imag->crosshair_frame ,
1129             XmNpacking      , XmPACK_TIGHT ,
1130             XmNorientation  , XmVERTICAL   ,
1131             XmNtraversalOn , True  ,
1132             XmNinitialResourcesPersistent , False ,
1133          NULL ) ;
1134 
1135    /*--- label to display the crosshair location ---*/
1136 
1137    im3d->vinfo->old_crosshair_label = xstr = AFNI_crosshair_label( im3d ) ;
1138 
1139    im3d->vinfo->view_setter = -1 ;  /* 20 Feb 2003 */
1140 
1141    imag->crosshair_label =
1142       XtVaCreateManagedWidget(
1143          "dialog" , xmLabelWidgetClass , imag->crosshair_rowcol ,
1144             XmNrecomputeSize , False ,
1145             XmNlabelString , xstr ,
1146             XmNtraversalOn , True  ,
1147             XmNinitialResourcesPersistent , False ,
1148          NULL ) ;
1149    LABELIZE(imag->crosshair_label) ;
1150    MCW_register_help( imag->crosshair_label , AFNI_crosshair_label_help ) ;
1151    MCW_register_hint( imag->crosshair_label ,
1152                "Coordinates of crosshair point. * indicates oblique dataset." ) ;
1153 
1154    /*--- 12 Mar 2004: coordinate order popup menu ---*/
1155 
1156    if( im3d->type == AFNI_3DDATA_VIEW ){
1157     imag->crosshair_menu =
1158       XmCreatePopupMenu( imag->crosshair_label  , "menu" , NULL , 0 ) ;
1159 
1160     SAVEUNDERIZE(XtParent(imag->crosshair_menu)) ;
1161     VISIBILIZE_WHEN_MAPPED(imag->crosshair_menu) ;
1162 #if 0
1163     if( !AFNI_yesenv("AFNI_DISABLE_TEAROFF") ) TEAROFFIZE(imag->crosshair_menu) ;
1164 #endif
1165 
1166     XtInsertEventHandler( imag->crosshair_label , /* handle events in label */
1167                              ButtonPressMask ,    /* button presses */
1168                              FALSE ,              /* nonmaskable events? */
1169                              AFNI_crosshair_EV ,  /* handler */
1170                              (XtPointer) im3d ,   /* client data */
1171                              XtListTail           /* last in queue */
1172                          ) ;
1173 
1174     (void) XtVaCreateManagedWidget(
1175              "menu" , xmLabelWidgetClass , imag->crosshair_menu ,
1176                 LABEL_ARG("-Set Coord Order-") ,
1177                 XmNrecomputeSize , False ,
1178                 XmNinitialResourcesPersistent , False ,
1179              NULL ) ;
1180 
1181     (void) XtVaCreateManagedWidget(
1182              "menu" , xmSeparatorWidgetClass , imag->crosshair_menu ,
1183               XmNseparatorType , XmSINGLE_LINE , NULL ) ;
1184 
1185    /*---*/
1186 
1187     imag->crosshair_dicom_pb =
1188        XtVaCreateManagedWidget(
1189           "menu" , xmPushButtonWidgetClass , imag->crosshair_menu ,
1190              LABEL_ARG(" RAI=DICOM order") ,
1191              XmNmarginHeight , 0 ,
1192              XmNtraversalOn , True  ,
1193              XmNinitialResourcesPersistent , False ,
1194           NULL ) ;
1195     XtAddCallback( imag->crosshair_dicom_pb , XmNactivateCallback ,
1196                    AFNI_crosshair_pop_CB , im3d ) ;
1197     MCW_register_hint( imag->crosshair_dicom_pb ,
1198                        "Show xyz coordinates in DICOM order" ) ;
1199 
1200    /*---*/
1201 
1202     imag->crosshair_spm_pb =
1203        XtVaCreateManagedWidget(
1204           "menu" , xmPushButtonWidgetClass , imag->crosshair_menu ,
1205              LABEL_ARG(" LPI=SPM order") ,
1206              XmNmarginHeight , 0 ,
1207              XmNtraversalOn , True  ,
1208              XmNinitialResourcesPersistent , False ,
1209           NULL ) ;
1210     XtAddCallback( imag->crosshair_spm_pb , XmNactivateCallback ,
1211                    AFNI_crosshair_pop_CB , im3d ) ;
1212     MCW_register_hint( imag->crosshair_spm_pb ,
1213                        "Show xyz coordinates in SPM/FSL order" ) ;
1214 
1215    /*---*/
1216 
1217     imag->crosshair_ijk_pb =      /* 04 Oct 2010 */
1218        XtVaCreateManagedWidget(
1219           "menu" , xmPushButtonWidgetClass , imag->crosshair_menu ,
1220              LABEL_ARG(" Voxel Indexes") ,
1221              XmNmarginHeight , 0 ,
1222              XmNtraversalOn , True  ,
1223              XmNinitialResourcesPersistent , False ,
1224           NULL ) ;
1225     XtAddCallback( imag->crosshair_ijk_pb , XmNactivateCallback ,
1226                    AFNI_crosshair_pop_CB , im3d ) ;
1227     MCW_register_hint( imag->crosshair_ijk_pb ,
1228                        "Show 3D voxel indexes (ijk) instead of xyz" ) ;
1229 
1230    /*---*/
1231 
1232     imag->crosshair_jtxyz_pb =      /* 01 Aug 2011 */
1233        XtVaCreateManagedWidget(
1234           "menu" , xmPushButtonWidgetClass , imag->crosshair_menu ,
1235              LABEL_ARG("Jump to (xyz)") ,
1236              XmNmarginHeight , 0 ,
1237              XmNtraversalOn , True  ,
1238              XmNinitialResourcesPersistent , False ,
1239           NULL ) ;
1240     XtAddCallback( imag->crosshair_jtxyz_pb , XmNactivateCallback ,
1241                    AFNI_crosshair_pop_CB , im3d ) ;
1242     MCW_register_hint( imag->crosshair_jtxyz_pb ,
1243                        "Jump crosshairs to these xyz coordinates" ) ;
1244 
1245    /*---*/
1246 
1247     imag->crosshair_jtijk_pb =      /* 01 Aug 2011 */
1248        XtVaCreateManagedWidget(
1249           "menu" , xmPushButtonWidgetClass , imag->crosshair_menu ,
1250              LABEL_ARG("Jump to (ijk UL)") ,
1251              XmNmarginHeight , 0 ,
1252              XmNtraversalOn , True  ,
1253              XmNinitialResourcesPersistent , False ,
1254           NULL ) ;
1255     XtAddCallback( imag->crosshair_jtijk_pb , XmNactivateCallback ,
1256                    AFNI_crosshair_pop_CB , im3d ) ;
1257     MCW_register_hint( imag->crosshair_jtijk_pb ,
1258                        "Jump to 3D ijk index (UnderLay)" ) ;
1259 
1260    /*---*/
1261 
1262     imag->crosshair_jtijk_olay_pb =  /* 20 Apr 2016 */
1263        XtVaCreateManagedWidget(
1264           "menu" , xmPushButtonWidgetClass , imag->crosshair_menu ,
1265              LABEL_ARG("Jump to (ijk OL)") ,
1266              XmNmarginHeight , 0 ,
1267              XmNtraversalOn , True  ,
1268              XmNinitialResourcesPersistent , False ,
1269           NULL ) ;
1270     XtAddCallback( imag->crosshair_jtijk_olay_pb , XmNactivateCallback ,
1271                    AFNI_crosshair_pop_CB , im3d ) ;
1272     MCW_register_hint( imag->crosshair_jtijk_olay_pb ,
1273                        "Jump to 3D ijk index (OverLay)" ) ;
1274 
1275    } /*- end of crosshair_label popup menu -*/
1276 
1277    /*--- 01 Jan 1997: horizontal rowcol for crosshair stuff ---*/
1278 
1279 STATUS("making imag->xhair_rowcol") ;
1280 
1281      imag->xhair_rowcol =
1282         XtVaCreateWidget(
1283          "dialog" , xmRowColumnWidgetClass , imag->crosshair_rowcol ,
1284             XmNpacking     , XmPACK_TIGHT ,
1285             XmNorientation , XmHORIZONTAL ,
1286             XmNmarginHeight, 0 ,
1287             XmNmarginWidth , 0 ,
1288             XmNtraversalOn , True  ,
1289             XmNinitialResourcesPersistent , False ,
1290          NULL ) ;
1291 
1292    /*--- arrowval to control crosshair visibility ---*/
1293 
1294    if( AFNI_yesenv("AFNI_CROSSHAIRS_OFF") )
1295      im3d->vinfo->crosshair_visible = False ;
1296 
1297    if( im3d->vinfo->crosshair_visible )
1298       ii = (im3d->vinfo->xhairs_show_montage) ? AFNI_XHAIRS_MULTI
1299                                               : AFNI_XHAIRS_SINGLE ;
1300    else
1301       ii = AFNI_XHAIRS_OFF ;
1302 
1303    im3d->vinfo->xhairs_orimask = ORIMASK_ALL ;  /* 31 Dec 1998 */
1304 
1305 STATUS("making imag->crosshair_av") ;
1306 
1307    imag->crosshair_av = new_MCW_arrowval(
1308                           imag->xhair_rowcol ,        /* parent Widget */
1309                           "Xhairs" ,                  /* label */
1310                           AVOPT_STYLE ,               /* option menu style */
1311                           AFNI_XHAIRS_OFF ,           /* first option */
1312                           AFNI_XHAIRS_LASTOPTION ,    /* last option */
1313                           ii ,                        /* initial selection */
1314                           MCW_AV_readtext ,           /* ignored but needed */
1315                           0 ,                         /* ditto */
1316                           AFNI_crosshair_visible_CB , /* callback when changed */
1317                           (XtPointer) im3d ,          /* data for above */
1318                           MCW_av_substring_CB ,       /* text creation routine */
1319                           AFNI_crosshair_av_label     /* data for above */
1320                         ) ;
1321 
1322    if( AVOPT_STYLE == MCW_AV_optmenu )
1323      AVOPT_columnize( imag->crosshair_av , 3 ) ;
1324 
1325    imag->crosshair_av->parent     = (XtPointer) im3d ;
1326    imag->crosshair_av->allow_wrap = True ;
1327 
1328    MCW_reghelp_children( imag->crosshair_av->wrowcol , AFNI_crosshair_av_help ) ;
1329    MCW_reghint_children( imag->crosshair_av->wrowcol , "Crosshairs style" ) ;
1330 
1331    ADDTO_KILL(im3d->kl,imag->crosshair_av) ;
1332 
1333    /*--- 01 Jan 1997: buttonbox to control "all" or "one" xhairs in montage ---*/
1334 
1335 STATUS("making imag->xhall_bbox") ;
1336 
1337    imag->xhall_bbox = new_MCW_bbox( imag->xhair_rowcol ,
1338                                      1 , AFNI_xhall_bbox_label ,
1339                                      MCW_BB_check ,
1340                                      MCW_BB_noframe ,
1341                                      AFNI_xhall_bbox_CB , (XtPointer) im3d ) ;
1342 
1343    MCW_set_bbox( imag->xhall_bbox , im3d->vinfo->xhairs_all ? 1 : 0 ) ;
1344 
1345    ADDTO_KILL(im3d->kl , imag->xhall_bbox) ;
1346 
1347    MCW_reghelp_children( imag->xhall_bbox->wrowcol ,
1348       "IN:  Montage will show crosshairs in all slices\n"
1349       "OUT: Montage will show crosshairs in one slice"
1350    ) ;
1351    MCW_reghint_children( imag->xhall_bbox->wrowcol ,
1352                          "All-or-One Montage crosshairs" ) ;
1353 
1354 STATUS("managing imag->xhair_rowcol") ;
1355 
1356    XtManageChild( imag->xhair_rowcol ) ;
1357 
1358    /*--- arrowval to control crosshair color ---*/
1359 
1360    ii = AVOPT_STYLE ;
1361 
1362 STATUS("making imag->crosshair_color_av") ;
1363 
1364    if( ii == MCW_AV_downup ){
1365       imag->crosshair_color_av =
1366          new_MCW_arrowval( imag->crosshair_rowcol ,        /* parent */
1367                            "Color " ,                      /* label */
1368                            MCW_AV_downup ,                 /* arrow directions */
1369                            1 ,                             /* min value */
1370                            last_color ,                    /* max value */
1371                            im3d->vinfo->crosshair_ovcolor ,/* init value */
1372                            MCW_AV_readtext ,               /* readonly text */
1373                            0 ,                             /* 0 decimal shift */
1374                            AFNI_crosshair_color_CB ,       /* click routine */
1375                            (XtPointer) im3d ,              /* data for above */
1376                            MCW_DC_ovcolor_text ,           /* text routine */
1377                            (XtPointer) im3d->dc            /* data for text */
1378                          ) ;
1379 
1380       (void) MCW_DC_ovcolor_text( imag->crosshair_color_av ,
1381                                   im3d->dc ) ;    /* set color now! */
1382 
1383       imag->crosshair_color_av->fastdelay  = 333 ;  /* slow down repeat action */
1384       imag->crosshair_color_av->allow_wrap = 1 ;
1385 
1386    } else {
1387       imag->crosshair_color_av =
1388          new_MCW_colormenu( imag->crosshair_rowcol , "Color " , im3d->dc ,
1389                             1 , last_color , im3d->vinfo->crosshair_ovcolor ,
1390                             AFNI_crosshair_color_CB , (XtPointer) im3d ) ;
1391    }
1392 
1393    imag->crosshair_color_av->parent     = (XtPointer) im3d ;
1394    imag->crosshair_color_av->fastdelay  = 333 ;  /* slow down repeat action */
1395    imag->crosshair_color_av->allow_wrap = 1 ;
1396 
1397    MCW_reghelp_children( imag->crosshair_color_av->wrowcol ,
1398                          AFNI_crosshair_color_help ) ;
1399    MCW_reghint_children( imag->crosshair_color_av->wrowcol , "Crosshairs color" ) ;
1400 
1401    ADDTO_KILL(im3d->kl,imag->crosshair_color_av) ;
1402 
1403    /**** 1 Aug 1996:
1404          put crosshair gap into a horizontal rowcol so
1405          can attach a toggle for periodic montages here, too ****/
1406 
1407 STATUS("making imag->gap_wrap_rowcol") ;
1408 
1409    imag->gap_wrap_rowcol =
1410       XtVaCreateWidget(
1411          "dialog" , xmRowColumnWidgetClass , imag->crosshair_rowcol ,
1412             XmNpacking     , XmPACK_TIGHT ,
1413             XmNorientation , XmHORIZONTAL ,
1414             XmNmarginHeight, 0 ,
1415             XmNmarginWidth , 0 ,
1416             XmNtraversalOn , True  ,
1417             XmNinitialResourcesPersistent , False ,
1418          NULL ) ;
1419 
1420    /*--- arrowval to control crosshair gap ---*/
1421 
1422 STATUS("making imag->crosshair_gap_av") ;
1423 
1424    imag->crosshair_gap_av =
1425       new_MCW_arrowval( imag->gap_wrap_rowcol ,      /* parent */
1426                         "Gap   " ,                   /* label */
1427                         AVOPT_STYLE ,                /* arrow directions */
1428                         -1  ,                        /* min value */
1429                         MAXOVSIZE ,                  /* max value */
1430                         im3d->vinfo->crosshair_gap , /* init value */
1431                         MCW_AV_editext ,             /* input/output text */
1432                         0 ,                          /* 0 decimal shift */
1433                         AFNI_crosshair_gap_CB ,      /* click routine */
1434                         (XtPointer) im3d ,           /* data */
1435                         NULL , NULL
1436                       ) ;
1437 
1438    if( AVOPT_STYLE == MCW_AV_optmenu && MAXOVSIZE >= COLSIZE )
1439       AVOPT_columnize( imag->crosshair_gap_av , 1+(MAXOVSIZE+1)/COLSIZE ) ;
1440 
1441    imag->crosshair_gap_av->parent    = (XtPointer) im3d ;
1442    imag->crosshair_gap_av->fastdelay = 333 ;  /* slow down repeat action */
1443 
1444    MCW_reghelp_children( imag->crosshair_gap_av->wrowcol ,
1445                          AFNI_crosshair_gap_help ) ;
1446    MCW_reghint_children( imag->crosshair_gap_av->wrowcol ,
1447                          "Gap in crosshairs" ) ;
1448 
1449    ADDTO_KILL(im3d->kl,imag->crosshair_gap_av) ;
1450 
1451    /*--- 1 Aug 1996:
1452          toggle button box to control periodic montages ---*/
1453 
1454 STATUS("making imag->wrap_bbox") ;
1455 
1456    imag->wrap_bbox = new_MCW_bbox( imag->gap_wrap_rowcol ,
1457                                      1 , AFNI_wrap_bbox_label ,
1458                                      MCW_BB_check ,
1459                                      MCW_BB_noframe ,
1460                                      AFNI_wrap_bbox_CB , (XtPointer) im3d ) ;
1461 
1462    MCW_set_bbox( imag->wrap_bbox , im3d->vinfo->xhairs_periodic ? 1 : 0 ) ;
1463 
1464    ADDTO_KILL(im3d->kl , imag->wrap_bbox) ;
1465 
1466    MCW_reghelp_children( imag->wrap_bbox->wrowcol ,
1467       "IN:  Montage layout wraps around when slices\n"
1468       "       go past an edge of the dataset.\n"
1469       "OUT: Montage layout shows blanks for slices\n"
1470       "       past an edge of the dataset."
1471    ) ;
1472    MCW_reghint_children( imag->wrap_bbox->wrowcol ,
1473                          "Wrap montage past edge of volume?" ) ;
1474 
1475 STATUS("managing imag->gap_wrap_rowcol") ;
1476 
1477    XtManageChild( imag->gap_wrap_rowcol ) ;
1478 
1479    /*--- arrowval to control time index we are viewing ---*/
1480 
1481 STATUS("making imag->time_index_av") ;
1482 
1483    imag->time_index_av =
1484       new_MCW_arrowval( imag->crosshair_rowcol ,     /* parent */
1485                         "Index " ,                   /* label */
1486                         MCW_AV_downup ,              /* arrow directions */
1487                         0  ,                         /* min value */
1488                         im3d->vinfo->top_index ,     /* max value */
1489                         im3d->vinfo->time_index ,    /* init value */
1490                         MCW_AV_editext ,             /* input/output text */
1491                         0 ,                          /* 0 decimal shift */
1492                         AFNI_time_index_CB ,         /* click routine */
1493                         (XtPointer) im3d ,           /* data */
1494                         NULL , NULL
1495                       ) ;
1496    imag->time_index_av->parent     = (XtPointer) im3d ;
1497    imag->time_index_av->allow_wrap = 1 ;
1498 
1499    MCW_reghelp_children( imag->time_index_av->wrowcol ,
1500                          "* Controls the time index\n"
1501                          "  of the images being viewed.\n"
1502                          "* Right click on 'Index' for\n"
1503                          "  a menu of extra options." ) ;
1504    MCW_reghint_children( imag->time_index_av->wrowcol ,
1505                          "Set index in time" ) ;
1506 
1507    ADDTO_KILL(im3d->kl,imag->time_index_av) ;
1508 
1509    /* [24 Feb 2014] Right-click event handler for Index label */
1510 
1511    XtInsertEventHandler( imag->time_index_av->wlabel ,
1512                            ButtonPressMask , FALSE ,
1513                            AFNI_time_index_EV , (XtPointer)im3d , XtListTail ) ;
1514 
1515    /*--- frame to hold all viewing control stuff ---*/
1516 
1517 STATUS("imag->view_frame") ;
1518 
1519    imag->view_frame =
1520       XtVaCreateManagedWidget(
1521          "dialog" , xmFrameWidgetClass , imag->rowcol ,
1522             XmNshadowType , XmSHADOW_ETCHED_IN ,
1523             XmNshadowThickness , 2 ,
1524             XmNinitialResourcesPersistent , False ,
1525          NULL ) ;
1526 
1527    /*--- rowcol to manage viewing control stuff ---*/
1528 
1529    imag->view_rowcol =
1530       XtVaCreateWidget(
1531          "dialog" , xmRowColumnWidgetClass , imag->view_frame ,
1532             XmNpacking     , XmPACK_TIGHT ,
1533             XmNorientation , XmVERTICAL   ,
1534             XmNtraversalOn , True  ,
1535             XmNinitialResourcesPersistent , False ,
1536          NULL ) ;
1537 
1538    /*--- pushbuttons to turn different views on ---*/
1539 
1540 #define xyz_3DIM "Axial   "
1541 #define yzx_3DIM "Sagittal"
1542 #define zxy_3DIM "Coronal "
1543 
1544    /*--------------------------------------------------------------*/
1545    imag->xyz_rowcol =
1546       XtVaCreateWidget(
1547          "dialog" , xmRowColumnWidgetClass , imag->view_rowcol ,
1548             XmNpacking     , XmPACK_TIGHT ,
1549             XmNorientation , XmHORIZONTAL ,
1550             XmNmarginHeight, 0 ,
1551             XmNmarginWidth , 0 ,
1552             XmNtraversalOn , True  ,
1553             XmNinitialResourcesPersistent , False ,
1554          NULL ) ;
1555 
1556    /*---*/
1557 
1558    imag->name_xyz_lab =
1559       XtVaCreateManagedWidget(
1560          "dialog" , xmLabelWidgetClass , imag->xyz_rowcol ,
1561             LABEL_ARG( xyz_3DIM ) ,
1562             XmNmarginHeight, 0 ,
1563             XmNmarginWidth , 0 ,
1564             XmNrecomputeSize , False ,
1565             XmNtraversalOn   , True  ,
1566             XmNinitialResourcesPersistent , False ,
1567          NULL ) ;
1568    LABELIZE(imag->name_xyz_lab) ;
1569 
1570    /*---*/
1571 
1572    imag->image_xyz_pb =
1573       XtVaCreateManagedWidget(
1574          "dialog" , xmPushButtonWidgetClass , imag->xyz_rowcol ,
1575             LABEL_ARG("Image") ,
1576             XmNmarginHeight, 0 ,
1577             XmNmarginWidth , 0 ,
1578             XmNrecomputeSize , False ,
1579             XmNtraversalOn   , True  ,
1580             XmNinitialResourcesPersistent , False ,
1581          NULL ) ;
1582 
1583    /*---*/
1584 
1585    imag->graph_xyz_pb =
1586       XtVaCreateManagedWidget(
1587          "dialog" , xmPushButtonWidgetClass , imag->xyz_rowcol ,
1588             LABEL_ARG("Graph") ,
1589             XmNmarginHeight, 0 ,
1590             XmNmarginWidth , 0 ,
1591             XmNrecomputeSize , False ,
1592             XmNtraversalOn   , True  ,
1593             XmNinitialResourcesPersistent , False ,
1594          NULL ) ;
1595 
1596    XtManageChild( imag->xyz_rowcol ) ;
1597    /*----------------------------------------------------------------*/
1598 
1599    /*--------------------------------------------------------------*/
1600    imag->yzx_rowcol =
1601       XtVaCreateWidget(
1602          "dialog" , xmRowColumnWidgetClass , imag->view_rowcol ,
1603             XmNpacking     , XmPACK_TIGHT ,
1604             XmNorientation , XmHORIZONTAL ,
1605             XmNmarginHeight, 0 ,
1606             XmNmarginWidth , 0 ,
1607             XmNtraversalOn , True  ,
1608             XmNinitialResourcesPersistent , False ,
1609          NULL ) ;
1610 
1611    /*---*/
1612 
1613    imag->name_yzx_lab =
1614       XtVaCreateManagedWidget(
1615          "dialog" , xmLabelWidgetClass , imag->yzx_rowcol ,
1616             LABEL_ARG( yzx_3DIM ) ,
1617             XmNmarginHeight, 0 ,
1618             XmNmarginWidth , 0 ,
1619             XmNrecomputeSize , False ,
1620             XmNtraversalOn   , True  ,
1621             XmNinitialResourcesPersistent , False ,
1622          NULL ) ;
1623    LABELIZE(imag->name_yzx_lab) ;
1624 
1625    /*---*/
1626 
1627    imag->image_yzx_pb =
1628       XtVaCreateManagedWidget(
1629          "dialog" , xmPushButtonWidgetClass , imag->yzx_rowcol ,
1630             LABEL_ARG("Image") ,
1631             XmNmarginHeight, 0 ,
1632             XmNmarginWidth , 0 ,
1633             XmNrecomputeSize , False ,
1634             XmNtraversalOn   , True  ,
1635             XmNinitialResourcesPersistent , False ,
1636          NULL ) ;
1637 
1638    /*---*/
1639 
1640    imag->graph_yzx_pb =
1641       XtVaCreateManagedWidget(
1642          "dialog" , xmPushButtonWidgetClass , imag->yzx_rowcol ,
1643             LABEL_ARG("Graph") ,
1644             XmNmarginHeight, 0 ,
1645             XmNmarginWidth , 0 ,
1646             XmNrecomputeSize , False ,
1647             XmNtraversalOn   , True  ,
1648             XmNinitialResourcesPersistent , False ,
1649          NULL ) ;
1650 
1651    XtManageChild( imag->yzx_rowcol ) ;
1652    /*----------------------------------------------------------------*/
1653 
1654    /*--------------------------------------------------------------*/
1655    imag->zxy_rowcol =
1656       XtVaCreateWidget(
1657          "dialog" , xmRowColumnWidgetClass , imag->view_rowcol ,
1658             XmNpacking     , XmPACK_TIGHT ,
1659             XmNorientation , XmHORIZONTAL ,
1660             XmNmarginHeight, 0 ,
1661             XmNmarginWidth , 0 ,
1662             XmNtraversalOn , True  ,
1663             XmNinitialResourcesPersistent , False ,
1664    /*---*/
1665 
1666          NULL ) ;
1667 
1668    imag->name_zxy_lab =
1669       XtVaCreateManagedWidget(
1670          "dialog" , xmLabelWidgetClass , imag->zxy_rowcol ,
1671             LABEL_ARG( zxy_3DIM ) ,
1672             XmNmarginHeight, 0 ,
1673             XmNmarginWidth , 0 ,
1674             XmNrecomputeSize , False ,
1675             XmNtraversalOn   , True  ,
1676             XmNinitialResourcesPersistent , False ,
1677          NULL ) ;
1678    LABELIZE(imag->name_zxy_lab) ;
1679 
1680    /*---*/
1681 
1682    imag->image_zxy_pb =
1683       XtVaCreateManagedWidget(
1684          "dialog" , xmPushButtonWidgetClass , imag->zxy_rowcol ,
1685             LABEL_ARG("Image") ,
1686             XmNmarginHeight, 0 ,
1687             XmNmarginWidth , 0 ,
1688             XmNrecomputeSize , False ,
1689             XmNtraversalOn   , True  ,
1690             XmNinitialResourcesPersistent , False ,
1691          NULL ) ;
1692 
1693    /*---*/
1694 
1695    imag->graph_zxy_pb =
1696       XtVaCreateManagedWidget(
1697          "dialog" , xmPushButtonWidgetClass , imag->zxy_rowcol ,
1698             LABEL_ARG("Graph") ,
1699             XmNmarginHeight, 0 ,
1700             XmNmarginWidth , 0 ,
1701             XmNrecomputeSize , False ,
1702             XmNtraversalOn   , True  ,
1703             XmNinitialResourcesPersistent , False ,
1704          NULL ) ;
1705 
1706    XtManageChild( imag->zxy_rowcol ) ;
1707    /*----------------------------------------------------------------*/
1708 
1709    XtAddCallback( imag->image_xyz_pb , XmNactivateCallback ,
1710                   AFNI_view_xyz_CB , im3d ) ;
1711 
1712    XtAddCallback( imag->image_yzx_pb , XmNactivateCallback ,
1713                   AFNI_view_xyz_CB , im3d ) ;
1714 
1715    XtAddCallback( imag->image_zxy_pb , XmNactivateCallback ,
1716                   AFNI_view_xyz_CB , im3d ) ;
1717 
1718    XtAddCallback( imag->graph_xyz_pb , XmNactivateCallback ,
1719                   AFNI_view_xyz_CB , im3d ) ;
1720 
1721    XtAddCallback( imag->graph_yzx_pb , XmNactivateCallback ,
1722                   AFNI_view_xyz_CB , im3d ) ;
1723 
1724    XtAddCallback( imag->graph_zxy_pb , XmNactivateCallback ,
1725                   AFNI_view_xyz_CB , im3d ) ;
1726 
1727    MCW_reghelp_children( imag->xyz_rowcol , AFNI_view_help ) ;
1728    MCW_reghelp_children( imag->yzx_rowcol , AFNI_view_help ) ;
1729    MCW_reghelp_children( imag->zxy_rowcol , AFNI_view_help ) ;
1730 
1731    MCW_reghint_children( imag->xyz_rowcol , "Open/raise viewing window" ) ;
1732    MCW_reghint_children( imag->yzx_rowcol , "Open/raise viewing window" ) ;
1733    MCW_reghint_children( imag->zxy_rowcol , "Open/raise viewing window" ) ;
1734 
1735    XtInsertEventHandler( imag->image_xyz_pb ,
1736                            ButtonPressMask , FALSE ,
1737                            AFNI_viewbut_EV , (XtPointer)im3d , XtListTail ) ;
1738    XtInsertEventHandler( imag->graph_xyz_pb ,
1739                            ButtonPressMask , FALSE ,
1740                            AFNI_viewbut_EV , (XtPointer)im3d , XtListTail ) ;
1741    XtInsertEventHandler( imag->image_yzx_pb ,
1742                            ButtonPressMask , FALSE ,
1743                            AFNI_viewbut_EV , (XtPointer)im3d , XtListTail ) ;
1744    XtInsertEventHandler( imag->graph_yzx_pb ,
1745                            ButtonPressMask , FALSE ,
1746                            AFNI_viewbut_EV , (XtPointer)im3d , XtListTail ) ;
1747    XtInsertEventHandler( imag->image_zxy_pb ,
1748                            ButtonPressMask , FALSE ,
1749                            AFNI_viewbut_EV , (XtPointer)im3d , XtListTail ) ;
1750    XtInsertEventHandler( imag->graph_zxy_pb ,
1751                            ButtonPressMask , FALSE ,
1752                            AFNI_viewbut_EV , (XtPointer)im3d , XtListTail ) ;
1753 
1754    /* imaging column finished, so manage its pieces */
1755 
1756    XtManageChild( imag->crosshair_rowcol ) ;
1757    XtManageChild( imag->view_rowcol ) ;
1758    XtManageChild( imag->rowcol ) ;
1759 
1760    /*-------------------------------------------------------*/
1761    /************ Controls for which view we see *************/
1762    /*-------------------------------------------------------*/
1763 
1764    marks->ov_visible = marks->tag_visible = False ;
1765 
1766    /*--- vertical rowcol to hold all viewing controls stuff ---*/
1767 
1768 STATUS("making view->rowcol") ;
1769 
1770    view->rowcol =
1771       XtVaCreateWidget(
1772          "dialog" , xmRowColumnWidgetClass , view->frame ,
1773             XmNpacking     , XmPACK_TIGHT ,
1774             XmNorientation , XmVERTICAL   ,
1775             XmNisAligned   , False ,
1776             XmNtraversalOn , True  ,
1777             XmNinitialResourcesPersistent , False ,
1778          NULL ) ;
1779 
1780    view_count = 0 ;  /* count of widgets in this column */
1781 
1782    /*--- radio box to control which view we see ---*/
1783 
1784    view->view_bbox =
1785       new_MCW_bbox( view->rowcol ,
1786                     LAST_VIEW_TYPE+1 ,
1787                     VIEW_typestr ,
1788                     MCW_BB_radio_one ,
1789                     MCW_BB_frame ,
1790                     AFNI_switchview_CB , (XtPointer) im3d ) ;
1791 
1792    for( id=0 ; id <= LAST_VIEW_TYPE ; id++ ){
1793      if( im3d->anat_dset[id] == NULL )
1794        XtSetSensitive( view->view_bbox->wbut[id] , False ) ;
1795    }
1796 
1797    MCW_set_bbox( view->view_bbox , 1 << im3d->vinfo->view_type ) ;
1798 
1799    ADDTO_KILL(im3d->kl,view->view_bbox) ;
1800 
1801    MCW_reghelp_children( view->view_bbox->wrowcol ,
1802       "Use these to select the\n"
1803       "type of view for your data" ) ;
1804 
1805    { char *hh[] = { "View data in original coordinates" ,
1806                      "View data in AC-PC aligned coordinates" ,
1807                      "View data in Talairach coordinates" } ;
1808      MCW_bbox_hints( view->view_bbox , 3 , hh ) ;
1809    }
1810 
1811    view_count += LAST_VIEW_TYPE+1 ;
1812 
1813    /*--- frame for marks buttons ---*/
1814 
1815    view->marks_frame =
1816       XtVaCreateManagedWidget(
1817          "dialog" , xmFrameWidgetClass , view->rowcol ,
1818             XmNshadowType , XmSHADOW_ETCHED_IN ,
1819             XmNshadowThickness , 2 ,
1820             XmNtraversalOn , True  ,
1821             XmNinitialResourcesPersistent , False ,
1822          NULL ) ;
1823 
1824    view->marks_rowcol =
1825       XtVaCreateWidget(
1826          "dialog" , xmRowColumnWidgetClass , view->marks_frame ,
1827             XmNpacking     , XmPACK_TIGHT ,
1828             XmNorientation , XmVERTICAL   ,
1829             XmNisAligned   , False ,
1830             XmNtraversalOn , True  ,
1831             XmNinitialResourcesPersistent , False ,
1832          NULL ) ;
1833 
1834    /*--- pushbutton to allow user to define marks ---*/
1835 
1836    view->define_marks_pb =
1837       XtVaCreateManagedWidget(
1838          "dialog" , xmPushButtonWidgetClass , view->marks_rowcol ,
1839             LABEL_ARG("Define Markers ->") ,
1840             XmNmarginHeight , 1 ,
1841             XmNtraversalOn , True  ,
1842             XmNalignment , XmALIGNMENT_CENTER ,
1843             XmNinitialResourcesPersistent , False ,
1844          NULL ) ;
1845 
1846    view->marks_pb_inverted = False ;
1847 
1848    XtAddCallback( view->define_marks_pb , XmNactivateCallback ,
1849                   AFNI_define_CB , im3d ) ;
1850 
1851    MCW_register_help( view->define_marks_pb ,
1852       "Use this to allow you to define\n"
1853       "the markers for this view type" ) ;
1854    MCW_register_hint( view->define_marks_pb ,
1855                       "Open/close Talairach markers control panel" ) ;
1856 
1857    view_count ++ ;
1858 
1859    /*--- bbox to allow the user to turn marks off and on ---*/
1860 
1861    view->see_marks_bbox =
1862       new_MCW_bbox( view->marks_rowcol ,
1863                     1 , AFNI_see_marks_bbox_label ,
1864                     MCW_BB_check ,
1865                     MCW_BB_noframe ,
1866                     AFNI_see_marks_CB , (XtPointer) im3d ) ;
1867 
1868    view->see_marks_bbox->parent = (XtPointer) im3d ;
1869 
1870    MCW_set_bbox( view->see_marks_bbox , (marks->ov_visible) ? 0 : 1 ) ;
1871 
1872    MCW_reghelp_children( view->see_marks_bbox->wrowcol ,
1873                          AFNI_see_marks_bbox_help ) ;
1874    MCW_reghint_children( view->see_marks_bbox->wrowcol ,
1875                          "Visibility of Talairach markers and Tags" ) ;
1876 
1877    ADDTO_KILL(im3d->kl,view->see_marks_bbox) ;
1878 
1879    view_count ++ ;
1880 
1881    /*--- frame for func buttons ---*/
1882 
1883    im3d->vinfo->func_visible = False ;
1884    if( AFNI_yesenv("AFNI_SEE_OVERLAY") ) im3d->vinfo->func_visible = True ;
1885    im3d->vinfo->func_visible_count  = 0 ;
1886    im3d->vinfo->func_init_subbricks = 0 ;
1887 
1888    view->func_frame =
1889       XtVaCreateManagedWidget(
1890          "dialog" , xmFrameWidgetClass , view->rowcol ,
1891             XmNshadowType , XmSHADOW_ETCHED_IN ,
1892             XmNshadowThickness , 2 ,
1893             XmNtraversalOn , True  ,
1894             XmNinitialResourcesPersistent , False ,
1895          NULL ) ;
1896 
1897    view->func_rowcol =
1898       XtVaCreateWidget(
1899          "dialog" , xmRowColumnWidgetClass , view->func_frame ,
1900             XmNpacking     , XmPACK_TIGHT ,
1901             XmNorientation , XmVERTICAL   ,
1902             XmNisAligned   , False ,
1903             XmNtraversalOn , True  ,
1904             XmNinitialResourcesPersistent , False ,
1905          NULL ) ;
1906 
1907    /*--- pushbutton to allow user to define functions ---*/
1908 
1909    view->define_func_pb =
1910       XtVaCreateManagedWidget(
1911          "dialog" , xmPushButtonWidgetClass , view->func_rowcol ,
1912             LABEL_ARG("Define OverLay ->") ,
1913             XmNmarginHeight , 1 ,
1914             XmNtraversalOn , True  ,
1915             XmNalignment , XmALIGNMENT_CENTER ,
1916             XmNinitialResourcesPersistent , False ,
1917          NULL ) ;
1918 
1919    view->func_pb_inverted = False ;
1920 
1921    XtAddCallback( view->define_func_pb , XmNactivateCallback ,
1922                   AFNI_define_CB , im3d ) ;
1923 
1924    MCW_register_help( view->define_func_pb ,
1925      "Use this to control the thresholds,\n"
1926       "colors, etc. for overlays" ) ;
1927    MCW_register_hint( view->define_func_pb ,
1928                       "Open/close overlay control panel" ) ;
1929 
1930    view_count ++ ;
1931 
1932    /*--- bbox to allow the user to turn function overlay off and on ---*/
1933 
1934    view->see_func_bbox =
1935       new_MCW_bbox( view->func_rowcol ,
1936                     1 , AFNI_see_func_bbox_label ,
1937                     MCW_BB_check ,
1938                     MCW_BB_noframe ,
1939                     AFNI_see_func_CB , (XtPointer) im3d ) ;
1940 
1941    view->see_func_bbox->parent = (XtPointer) im3d ;
1942 
1943    MCW_set_bbox( view->see_func_bbox , (im3d->vinfo->func_visible) ? 1 : 0 ) ;
1944 
1945    MCW_reghelp_children( view->see_func_bbox->wrowcol ,
1946                          AFNI_see_func_bbox_help ) ;
1947    MCW_reghint_children( view->see_func_bbox->wrowcol ,
1948                          "Visibility of color overlay" ) ;
1949 
1950    ADDTO_KILL(im3d->kl,view->see_func_bbox) ;
1951 
1952    view_count ++ ;
1953 
1954    /*--- pushbutton to allow user to define datamode ---*/
1955 
1956    view->define_dmode_pb =
1957       XtVaCreateManagedWidget(
1958          "dialog" , xmPushButtonWidgetClass , view->rowcol ,
1959             LABEL_ARG("Define Datamode ->") ,
1960             XmNmarginHeight , 1 ,
1961             XmNtraversalOn , True  ,
1962             XmNalignment , XmALIGNMENT_CENTER ,
1963             XmNinitialResourcesPersistent , False ,
1964          NULL ) ;
1965 
1966    view->dmode_pb_inverted = False ;
1967 
1968    XtAddCallback( view->define_dmode_pb , XmNactivateCallback ,
1969                   AFNI_define_CB , im3d ) ;
1970 
1971    MCW_register_help( view->define_dmode_pb ,
1972      "Use this to control the mode in which\n"
1973      "the underlay data is viewed, and also\n"
1974      "to save 3D datasets to disk" ) ;
1975    MCW_register_hint( view->define_dmode_pb ,
1976                       "Open/close data manipulation control panel" ) ;
1977 
1978    view_count ++ ;
1979 
1980    /*--- frame for dataset choosers ---*/
1981 
1982    view->dataset_frame =
1983       XtVaCreateManagedWidget(
1984          "dialog" , xmFrameWidgetClass , view->rowcol ,
1985             XmNshadowType , XmSHADOW_ETCHED_IN ,
1986             XmNshadowThickness , 2 ,
1987             XmNtraversalOn , True  ,
1988             XmNinitialResourcesPersistent , False ,
1989          NULL ) ;
1990 
1991    view->dataset_rowcol =
1992       XtVaCreateWidget(
1993          "dialog" , xmRowColumnWidgetClass , view->dataset_frame ,
1994             XmNpacking     , XmPACK_TIGHT ,
1995             XmNorientation , XmVERTICAL   ,
1996             XmNisAligned   , False ,
1997             XmNtraversalOn , True  ,
1998             XmNinitialResourcesPersistent , False ,
1999          NULL ) ;
2000 
2001    /*-- 03 Dec 2009: move Session change stuff to a private rowcol --*/
2002 
2003  {
2004 #if 0
2005   int horz = show_markers ;
2006 #else
2007   int horz = 1 ;
2008 #endif
2009    char *hstr ;
2010 
2011    view->session_horz = horz ;
2012    view->session_rowcol =
2013       XtVaCreateWidget(
2014          "dialog" , xmRowColumnWidgetClass , view->dataset_rowcol ,
2015             XmNpacking      , XmPACK_TIGHT ,
2016             XmNorientation  , (horz) ? XmHORIZONTAL : XmVERTICAL ,
2017             XmNtraversalOn  , True  ,
2018             XmNmarginHeight , (horz) ? 0 : 2 ,
2019             XmNmarginWidth  , (horz) ? 0 : 2 ,
2020             XmNspacing      , (horz) ? 0 : 2 ,
2021             XmNadjustLast   , False ,
2022             XmNisAligned    , False ,
2023             XmNentryAlignment , XmALIGNMENT_CENTER ,
2024             XmNinitialResourcesPersistent , False ,
2025          NULL ) ;
2026 
2027    /*--- pushbuttons for session choice ---*/
2028 
2029    hstr = (horz) ? "DataDir" : "Data Directory" ;
2030    xstr = XmStringCreateLtoR(hstr,XmFONTLIST_DEFAULT_TAG);
2031    view->sess_lab =
2032       XtVaCreateManagedWidget(
2033          "dialog" , xmLabelWidgetClass , view->session_rowcol ,
2034             XmNrecomputeSize , False ,
2035             XmNlabelString , xstr ,
2036             XmNtraversalOn , True  ,
2037             XmNmarginHeight , (horz) ? 0 : 2 ,
2038             XmNmarginWidth  , (horz) ? 0 : 2 ,
2039             XmNadjustMargin , False ,
2040             XmNinitialResourcesPersistent , False ,
2041          NULL ) ;
2042    XmStringFree( xstr ) ;
2043 #if 0
2044    MCW_register_hint( view->sess_lab ,
2045     "Switch = change dataset directory; Read = open a new dataset directory" ) ;
2046 #endif
2047    XtInsertEventHandler( view->sess_lab ,         /* handle events in label */
2048                              ButtonPressMask ,    /* button presses */
2049                              FALSE ,              /* nonmaskable events? */
2050                              AFNI_sesslab_EV ,    /* handler */
2051                              (XtPointer)im3d ,    /* client data */
2052                              XtListTail           /* last in queue */
2053                          ) ;
2054    MCW_set_widget_bg( view->sess_lab , BROWN_COLOR , 0 ) ;
2055 
2056    /*---*/
2057 
2058    hstr = (horz) ? "Switch" : "Switch Directory" ;
2059    view->choose_sess_pb =
2060       XtVaCreateManagedWidget(
2061          "dialog" , xmPushButtonWidgetClass , view->session_rowcol ,
2062             LABEL_ARG(hstr) ,
2063             XmNmarginHeight , (horz) ? 0 : 2 ,
2064             XmNmarginWidth  , 1 ,
2065             XmNtraversalOn , True  ,
2066             XmNalignment , XmALIGNMENT_CENTER ,
2067             XmNinitialResourcesPersistent , False ,
2068          NULL ) ;
2069    XtAddCallback( view->choose_sess_pb , XmNactivateCallback ,
2070                   AFNI_choose_dataset_CB , im3d ) ;
2071    MCW_register_help( view->choose_sess_pb ,
2072      "Use this to choose from which\n"
2073      "session 3D datasets may be viewed." ) ;
2074    MCW_register_hint( view->choose_sess_pb ,
2075                       "Switch between session directories" ) ;
2076    BLACK_AND_WHITE_WIDGET( view->choose_sess_pb ) ;
2077 
2078    /*---*/
2079 
2080    hstr = (horz) ? "Read" : "Read New Directory" ;
2081    view->read_sess_pb =
2082       XtVaCreateManagedWidget(
2083          "dialog" , xmPushButtonWidgetClass , view->session_rowcol ,
2084             LABEL_ARG(hstr) ,
2085             XmNmarginHeight , 0 ,
2086             XmNmarginWidth  , 0 ,
2087             XmNmarginLeft   , 0 ,
2088             XmNmarginRight  , 0 ,
2089             XmNtraversalOn , True  ,
2090             XmNinitialResourcesPersistent , False ,
2091          NULL ) ;
2092    XtAddCallback( view->read_sess_pb , XmNactivateCallback ,
2093                   AFNI_read_sess_CB , im3d ) ;
2094    MCW_register_hint( view->read_sess_pb ,
2095                       "Read in a new session directory" ) ;
2096    MCW_register_help( view->read_sess_pb ,
2097                       "Click this button to get\n"
2098                       "a 'chooser' dialog window\n"
2099                       "to select a new directory\n"
2100                       "from which to read datasets." ) ;
2101    MCW_set_widget_bg( view->read_sess_pb , "#ffddaa" , 0 ) ;
2102 
2103    view_count ++ ;
2104 
2105    (void) XtVaCreateManagedWidget(
2106             "dialog" , xmSeparatorWidgetClass , view->dataset_rowcol ,
2107                 XmNseparatorType , XmSHADOW_ETCHED_IN ,
2108             NULL ) ;
2109  }
2110 
2111    /*-- 02 Feb 2007: move Underlay and Overlay choosers into a rowcol --*/
2112 
2113    view->choose_rowcol =
2114       XtVaCreateWidget(
2115          "dialog" , xmRowColumnWidgetClass , view->dataset_rowcol ,
2116             XmNpacking      , XmPACK_COLUMN ,
2117             XmNnumColumns   , 2 ,
2118             XmNorientation  , XmVERTICAL   ,
2119             XmNtraversalOn  , True  ,
2120             XmNmarginHeight , 0 ,
2121             XmNmarginWidth  , 0 ,
2122             XmNspacing      , 0 ,
2123             XmNadjustLast   , False ,
2124             XmNentryAlignment , XmALIGNMENT_CENTER ,
2125             XmNinitialResourcesPersistent , False ,
2126          NULL ) ;
2127 
2128 #define UNDERLAY_BUTTON                                             \
2129  do{                                                                \
2130    view->choose_anat_pb =                                           \
2131       XtVaCreateManagedWidget(                                      \
2132          "dialog" , xmPushButtonWidgetClass , view->choose_rowcol , \
2133             LABEL_ARG("UnderLay") ,                                 \
2134             XmNmarginHeight , 1 ,                                   \
2135             XmNtraversalOn , True  ,                                \
2136             XmNinitialResourcesPersistent , False ,                 \
2137          NULL ) ;                                                   \
2138    XtAddCallback( view->choose_anat_pb , XmNactivateCallback ,      \
2139                   AFNI_choose_dataset_CB , im3d ) ;                 \
2140    MCW_register_help( view->choose_anat_pb ,                        \
2141         "Use this to choose which 3D\n"                             \
2142         "dataset to view as the underlay\n"                         \
2143         "(from the current session).\n\n"                           \
2144         "N.B.: Datasets which can be\n"                             \
2145         "  graphed are marked with a\n"                             \
2146         "  '*' after their names.\n"                                \
2147         "  Datasets that are compressed\n"                          \
2148         "  have 'z' after their names."                             \
2149    ) ;                                                              \
2150    MCW_register_hint( view->choose_anat_pb ,                        \
2151                       "Switch datasets for underlay/graphs" ) ;     \
2152    BLACK_AND_WHITE_WIDGET(view->choose_anat_pb) ;                   \
2153    view_count ++ ;                                                  \
2154  } while(0)
2155 
2156 #define OVERLAY_BUTTON                                              \
2157  do{                                                                \
2158    view->choose_func_pb =                                           \
2159       XtVaCreateManagedWidget(                                      \
2160          "dialog" , xmPushButtonWidgetClass , view->choose_rowcol , \
2161             LABEL_ARG("OverLay") ,                                  \
2162             XmNmarginHeight , 1 ,                                   \
2163             XmNtraversalOn , True  ,                                \
2164             XmNinitialResourcesPersistent , False ,                 \
2165          NULL ) ;                                                   \
2166    XtAddCallback( view->choose_func_pb , XmNactivateCallback ,      \
2167                   AFNI_choose_dataset_CB , im3d ) ;                 \
2168    MCW_register_help( view->choose_func_pb ,                        \
2169      "Use this to choose which\n"                                   \
2170      "overlay 3D dataset to view\n"                                 \
2171      "(from the current session).\n"                                \
2172      "N.B.: Datasets that are compressed\n"                         \
2173      "  have 'z' after their names."                                \
2174     ) ;                                                             \
2175    MCW_register_hint( view->choose_func_pb ,                        \
2176                       "Switch datasets for color overlay" ) ;       \
2177    MCW_set_widget_bg( view->choose_func_pb , "#ffddaa" , 0 ) ;      \
2178    view_count ++ ;                                                  \
2179  } while(0)
2180 
2181    if( AFNI_yesenv("AFNI_OVERLAY_ONTOP") ){  /* 05 Feb 2007 */
2182      OVERLAY_BUTTON  ;
2183      UNDERLAY_BUTTON ;
2184    } else {
2185      UNDERLAY_BUTTON ;
2186      OVERLAY_BUTTON  ;
2187    }
2188 
2189    /* 02 Feb 2007: new Rescan This button here */
2190 
2191    if( !AFNI_yesenv("AFNI_RESCAN_AT_SWITCH") ){
2192      view->rescan_pb =
2193         XtVaCreateManagedWidget(
2194            "dialog" , xmPushButtonWidgetClass , view->choose_rowcol ,
2195               LABEL_ARG("RescanTh") ,
2196               XmNmarginHeight , 1 ,
2197               XmNtraversalOn , True  ,
2198               XmNinitialResourcesPersistent , False ,
2199            NULL ) ;
2200      XtAddCallback( view->rescan_pb , XmNactivateCallback ,
2201                     AFNI_rescan_CB , im3d ) ;
2202      MCW_register_hint( view->rescan_pb ,
2203                         "Read current session again" ) ;
2204      MCW_register_help( view->rescan_pb ,
2205                         "Read current session again\n"
2206                         "to see if new datasets were\n"
2207                         "added.  Exactly the same as\n"
2208                         " Define Datamode->Rescan This\n"
2209                         "Can also set (in .afnirc)\n"
2210                         " AFNI_RESCAN_AT_SWITCH = YES\n"
2211                         "to rescan each time you hit\n"
2212                         "'Overlay' or 'Underlay'."     ) ;
2213    } else {
2214      view->rescan_pb =              /* 23 Feb 2007 */
2215         XtVaCreateManagedWidget(
2216            "dialog" , xmPushButtonWidgetClass , view->choose_rowcol ,
2217               LABEL_ARG("EditEnv") ,
2218               XmNmarginHeight , 1 ,
2219               XmNtraversalOn , True  ,
2220               XmNinitialResourcesPersistent , False ,
2221            NULL ) ;
2222      XtAddCallback( view->rescan_pb , XmNactivateCallback ,
2223                     AFNI_editenv_CB , im3d ) ;
2224      MCW_register_hint( view->rescan_pb ,
2225                         "open Edit Environment controls" ) ;
2226    }
2227 
2228    /* NIML+PO button here -- 02 Feb 2007 */
2229    /* Set label to match current status of 01 Feb 2008 */
2230 
2231    { char *label ; int have_po , have_ni ;
2232      have_po = !GLOBAL_argopt.noplugouts || AFNI_have_plugouts() ;
2233      have_ni =  GLOBAL_argopt.yes_niml   || AFNI_have_niml() ;
2234           if( have_po == have_ni ) label = "NIML+PO" ;
2235      else if( have_po )            label = "NIML"    ;
2236      else if( have_ni )            label = "Plgouts" ;
2237      else                          label = "WTF?"    ;  /* should not happen */
2238      view->nimlpo_pb =
2239         XtVaCreateManagedWidget(
2240            "dialog" , xmPushButtonWidgetClass , view->choose_rowcol ,
2241               LABEL_ARG(label) ,
2242               XmNmarginHeight , 1 ,
2243               XmNtraversalOn , True  ,
2244               XmNinitialResourcesPersistent , False ,
2245            NULL ) ;
2246    }
2247    XtAddCallback( view->nimlpo_pb , XmNactivateCallback ,
2248                   AFNI_nimlpo_CB , im3d ) ;
2249    if( AFNI_have_niml() && AFNI_have_plugouts() ){
2250      XtSetSensitive(view->nimlpo_pb,False) ;
2251    } else {
2252      MCW_register_hint( view->nimlpo_pb ,
2253                         "Start NIML and Plugout TCP/IP sockets") ;
2254      MCW_register_help( view->nimlpo_pb ,
2255                         "Start listening for NIML\n"
2256                         "and Plugout TCP/IP sockets.\n"
2257                         "If you forgot to use options\n"
2258                         "'-niml' and '-yesplugouts'\n"
2259                         "on the command line, and\n"
2260                         "are expecting AFNI to talk\n"
2261                         "SUMA and/or plugout_drive."  ) ;
2262    }
2263 
2264    /* 19 Aug 2002: Surface chooser! */
2265 
2266    view->choose_surf_pb =
2267       XtVaCreateManagedWidget(
2268          "dialog" , xmPushButtonWidgetClass , view->dataset_rowcol ,
2269             LABEL_ARG("Control Surface") ,
2270             XmNmarginHeight , 1 ,
2271             XmNtraversalOn , True  ,
2272             XmNalignment , XmALIGNMENT_CENTER ,
2273             XmNinitialResourcesPersistent , False ,
2274          NULL ) ;
2275    XtSetSensitive( view->choose_surf_pb , False ) ;
2276    XtAddCallback( view->choose_surf_pb , XmNactivateCallback ,
2277                   AFNI_choose_surface_CB , im3d ) ;
2278 
2279    MCW_register_help( view->choose_surf_pb ,
2280                        "Use this to control the display of\n"
2281                        "overlaid surfaces in image viewers:\n"
2282                        "\n"
2283                        "Surface nodes will have little boxes\n"
2284                        "  drawn, when they appear inside a slice.\n"
2285                        "Surface triangles will have line segments\n"
2286                        "  drawn, where they intersect a slice\n"
2287                        "  center-plane."
2288                     ) ;
2289    MCW_register_hint( view->choose_surf_pb ,
2290                       "Control surface overlay" ) ;
2291 
2292    view->swid = NULL ;   /* no widgets for surface yet */
2293 
2294    view_count ++ ;
2295 
2296 #ifdef POPUP_CHOOSERS
2297    (void) XtVaCreateManagedWidget(
2298             "dialog" , xmSeparatorWidgetClass , imag->popmenu ,
2299                 XmNseparatorType , XmDOUBLE_LINE ,
2300             NULL ) ;
2301 
2302    /*---*/
2303 
2304    view->popchoose_sess_pb =
2305       XtVaCreateManagedWidget(
2306          "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
2307             LABEL_ARG("Switch Session") ,
2308             XmNmarginHeight , 0 ,
2309             XmNtraversalOn , True  ,
2310             XmNinitialResourcesPersistent , False ,
2311          NULL ) ;
2312 
2313    XtAddCallback( view->popchoose_sess_pb , XmNactivateCallback ,
2314                   AFNI_choose_dataset_CB , im3d ) ;
2315 
2316    /*---*/
2317 
2318    view->popchoose_anat_pb =
2319       XtVaCreateManagedWidget(
2320          "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
2321             LABEL_ARG("Switch UnderLay") ,
2322             XmNmarginHeight , 0 ,
2323             XmNtraversalOn , True  ,
2324             XmNinitialResourcesPersistent , False ,
2325          NULL ) ;
2326 
2327    XtAddCallback( view->popchoose_anat_pb , XmNactivateCallback ,
2328                   AFNI_choose_dataset_CB , im3d ) ;
2329 
2330    /*---*/
2331 
2332    view->popchoose_func_pb =
2333       XtVaCreateManagedWidget(
2334          "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
2335             LABEL_ARG("Switch OverLay") ,
2336             XmNmarginHeight , 0 ,
2337             XmNtraversalOn , True  ,
2338             XmNinitialResourcesPersistent , False ,
2339          NULL ) ;
2340 
2341    XtAddCallback( view->popchoose_func_pb , XmNactivateCallback ,
2342                   AFNI_choose_dataset_CB , im3d ) ;
2343 
2344    if( im3d->type == AFNI_IMAGES_VIEW ){
2345       XtUnmanageChild( view->popchoose_func_pb ) ;
2346       XtUnmanageChild( view->popchoose_anat_pb ) ;
2347       XtUnmanageChild( view->popchoose_sess_pb ) ;
2348    }
2349 
2350 #else  /* don't POPUP_CHOOSERS */
2351 
2352    view->popchoose_func_pb =
2353      view->popchoose_anat_pb =
2354        view->popchoose_sess_pb = NULL ;
2355 
2356 #endif /* POPUP_CHOOSERS*/
2357 
2358    /*--- all view controls made, now manage them ---*/
2359 
2360    if( show_markers ){  /* 28 Apr 2010 */
2361      XtManageChild( view->marks_rowcol ) ;
2362      XtManageChild( view->marks_frame ) ;
2363      view->marks_enabled = 1 ;
2364    } else {
2365      XtUnmanageChild( view->marks_rowcol ) ;
2366      XtUnmanageChild( view->marks_frame ) ;
2367      view->marks_enabled = 0 ;
2368    }
2369    XtManageChild( view->func_rowcol ) ;
2370    XtManageChild( view->session_rowcol ) ;
2371    XtManageChild( view->choose_rowcol ) ;
2372    XtManageChild( view->dataset_rowcol ) ;
2373    XtManageChild( view->rowcol ) ;
2374 
2375    /** compute height of widgets in the view-> column **/
2376 
2377    xstr = XmStringCreateLtoR("(y[M",XmFONTLIST_DEFAULT_TAG );
2378    XtVaGetValues( view->choose_func_pb , XmNfontList , &xflist , NULL ) ;
2379    view_height = (10 + XmStringHeight(xflist,xstr)) * view_count ;
2380    XmStringFree( xstr ) ;
2381 
2382    EXRETURN ;
2383 }
2384 
2385 /*--------------------------------------------------------------------*/
2386 
AFNI_make_wid2(Three_D_View * im3d)2387 void AFNI_make_wid2( Three_D_View *im3d )
2388 {
2389    int ii ;
2390    Widget hrc ;  /* 30 Mar 2001 */
2391    Widget qsep=NULL ;
2392 
2393 ENTRY("AFNI_make_wid2") ;
2394 
2395    /*-------------------------------------------------------*/
2396    /************  Marker controls (lots of them) ************/
2397    /*-------------------------------------------------------*/
2398 
2399    /*----- horizontal rowcol to hold the two columns of controls -----*/
2400 
2401 STATUS("making marks->rowcol") ;
2402 
2403    marks->rowcol =
2404       XtVaCreateWidget(
2405          "dialog" , xmRowColumnWidgetClass , marks->frame ,
2406             XmNpacking     , XmPACK_TIGHT ,
2407             XmNorientation , XmHORIZONTAL ,
2408             XmNtraversalOn , True  ,
2409             XmNinitialResourcesPersistent , False ,
2410          NULL ) ;
2411 
2412    /*---------------------------------------------------------------*/
2413    /*----- COLUMN 1: the toggle switches for selecting markers -----*/
2414    /*---------------------------------------------------------------*/
2415 
2416    marks->tog_frame =
2417       XtVaCreateManagedWidget(
2418          "dialog" , xmFrameWidgetClass , marks->rowcol ,
2419             XmNshadowType , XmSHADOW_ETCHED_IN ,
2420             XmNshadowThickness , 2 ,
2421             XmNinitialResourcesPersistent , False ,
2422          NULL ) ;
2423 
2424    /*--- rowcol to manage toggle buttons stuff ---*/
2425 
2426    marks->tog_rowcol =
2427       XtVaCreateWidget(
2428          "dialog" , xmRowColumnWidgetClass , marks->tog_frame ,
2429             XmNpacking     , XmPACK_TIGHT ,
2430             XmNorientation , XmVERTICAL   ,
2431             XmNtraversalOn , True  ,
2432             XmNinitialResourcesPersistent , False ,
2433          NULL ) ;
2434 
2435    /*----- create radio buttons in pairs,
2436            one in the rowcol and one in the popmenu;
2437            N.B.: they are created unmanaged and will be managed
2438                  later, depending on defined marks for the view -----*/
2439 
2440    XtVaSetValues( marks->tog_rowcol ,
2441                      XmNradioBehavior , True ,
2442                      XmNradioAlwaysOne , True  ,
2443                      XmNspacing      , 1 ,
2444                      XmNmarginHeight , 0 ,
2445                      XmNmarginWidth  , 0 ,
2446                   NULL ) ;
2447 
2448    marks->num_sometimes_popup = 0 ;
2449    marks->num_always_popup    = 0 ;
2450 
2451    marks->always_popup[(marks->num_always_popup)++] =
2452       XtVaCreateWidget(
2453          "dialog" , xmSeparatorWidgetClass , imag->popmenu ,
2454              XmNseparatorType , XmDOUBLE_LINE ,
2455          NULL ) ;
2456 
2457    { int ib ;
2458      Dimension isiz=0 ;
2459      Pixel  fg_pix=0 ;
2460 
2461      XtVaGetValues( marks->tog_rowcol , XmNforeground , &fg_pix , NULL ) ;
2462 
2463      for( ib=0 ; ib < MARKS_MAXNUM ; ib++ ){
2464 
2465         marks->tog[ib] =
2466            XtVaCreateWidget(
2467               "dialog" , xmToggleButtonWidgetClass , marks->tog_rowcol ,
2468                  XmNvisibleWhenOff , True ,
2469                  XmNmarginHeight , 0 ,
2470                  XmNmarginWidth  , 0 ,
2471                  XmNselectColor  , fg_pix ,
2472                  XmNtraversalOn  , True  ,
2473                  XmNinitialResourcesPersistent , False ,
2474               NULL ) ;
2475 
2476      /* we set XmNindicatorSize resource for the popup to same as the
2477         menu above, since menu default size is tiny and looks bad! */
2478 
2479         if( ib==0 )
2480            XtVaGetValues( marks->tog[0],XmNindicatorSize,&isiz,NULL ) ;
2481 
2482         MCW_register_help( marks->tog[ib],&(marks->tog_help[ib][0]) ) ;
2483 
2484         XtAddCallback( marks->tog[ib] ,
2485                        XmNdisarmCallback ,
2486                        AFNI_marktog_CB , im3d ) ;
2487 
2488 #ifdef POPTOG
2489         marks->sometimes_popup[(marks->num_sometimes_popup)++] =
2490         marks->poptog[ib] =
2491            XtVaCreateWidget(
2492               "dialog" , xmToggleButtonWidgetClass , imag->popmenu ,
2493                  XmNindicatorSize , isiz ,
2494                  XmNvisibleWhenOff , True ,
2495                  XmNmarginHeight , 0 ,
2496                  XmNmarginWidth  , 0 ,
2497                  XmNselectColor  , fg_pix ,
2498                  XmNtraversalOn  , True  ,
2499                  XmNinitialResourcesPersistent , False ,
2500               NULL ) ;
2501 
2502         XtAddCallback( marks->poptog[ib] ,
2503                        XmNvalueChangedCallback ,
2504                        AFNI_marktog_CB , im3d ) ;
2505 #endif
2506 
2507         marks->inverted[ib] = False ;
2508      }  /* end of loop creating toggle buttons */
2509    }  /* end of radio toggle creation */
2510 
2511    /*----------------------------------------------------*/
2512    /*----- COLUMN 2: controls to manage the markers -----*/
2513    /*----------------------------------------------------*/
2514 
2515    marks->control_frame =
2516       XtVaCreateManagedWidget(
2517          "dialog" , xmFrameWidgetClass , marks->rowcol ,
2518             XmNshadowType , XmSHADOW_ETCHED_IN ,
2519             XmNshadowThickness , 2 ,
2520             XmNinitialResourcesPersistent , False ,
2521          NULL ) ;
2522 
2523    /*--- rowcol to manage marker control stuff ---*/
2524 
2525    marks->control_rowcol =
2526       XtVaCreateWidget(
2527          "dialog" , xmRowColumnWidgetClass , marks->control_frame ,
2528             XmNpacking     , XmPACK_TIGHT ,
2529             XmNorientation , XmVERTICAL   ,
2530             XmNtraversalOn , True  ,
2531             XmNinitialResourcesPersistent , False ,
2532          NULL ) ;
2533 
2534    /*--- bbox to control editability of marks ---*/
2535 
2536    marks->edits_bbox =
2537       new_MCW_bbox( marks->control_rowcol ,
2538                     1 , AFNI_marks_edits_bbox_label ,
2539                     MCW_BB_check ,
2540                     MCW_BB_noframe ,
2541                     AFNI_marks_edits_CB , (XtPointer) im3d ) ;
2542 
2543    marks->edits_bbox->parent = (XtPointer) im3d ;
2544 
2545    MCW_reghelp_children( marks->edits_bbox->wrowcol ,
2546                          AFNI_marks_edits_bbox_help ) ;
2547    MCW_reghint_children( marks->edits_bbox->wrowcol ,
2548                          "Press IN to allow changes to markers" ) ;
2549 
2550    ADDTO_KILL(im3d->kl,marks->edits_bbox) ;
2551 
2552    /*----- frame to hold markers display stuff -----*/
2553 
2554    marks->disp_frame =
2555       XtVaCreateManagedWidget(
2556          "frame" , xmFrameWidgetClass , marks->control_rowcol ,
2557             XmNshadowType , XmSHADOW_ETCHED_IN ,
2558             XmNshadowThickness , 2 ,
2559             XmNinitialResourcesPersistent , False ,
2560          NULL ) ;
2561 
2562    /*----- rowcol to hold markers display stuff -----*/
2563 
2564    marks->disp_rowcol =
2565       XtVaCreateWidget(
2566          "dialog" , xmRowColumnWidgetClass , marks->disp_frame ,
2567             XmNpacking      , XmPACK_TIGHT ,
2568             XmNorientation  , XmVERTICAL   ,
2569             XmNtraversalOn , True  ,
2570             XmNinitialResourcesPersistent , False ,
2571          NULL ) ;
2572 
2573    /*--- arrowval to control primary color ---*/
2574 
2575    marks->ov_pcolor = MIN(last_color,INIT_marks1_color) ;
2576    marks->ov_scolor = MIN(last_color,INIT_marks2_color) ;
2577 
2578    ii = AVOPT_STYLE ;
2579 
2580    if( ii == MCW_AV_downup ){
2581       marks->disp_pcolor_av =
2582          new_MCW_arrowval(
2583             marks->disp_rowcol ,    /* parent */
2584             "Pcolor" ,              /* label */
2585             MCW_AV_downup ,         /* arrow directions */
2586             0 ,                     /* min value */
2587             last_color ,            /* max value */
2588             marks->ov_pcolor ,      /* init value */
2589             MCW_AV_readtext ,       /* readonly text display */
2590             0 ,                     /* 0 decimal shift */
2591             AFNI_marks_disp_av_CB , /* click routine */
2592             (XtPointer) im3d ,      /* data */
2593             MCW_DC_ovcolor_text ,   /* text routine */
2594             (XtPointer) im3d->dc    /* data */
2595           ) ;
2596       marks->disp_pcolor_av->fastdelay  = 333 ;  /* slow down repeat action */
2597       marks->disp_pcolor_av->allow_wrap = 1 ;
2598       (void) MCW_DC_ovcolor_text( marks->disp_pcolor_av ,
2599                                   im3d->dc               ) ;  /* set color! */
2600    } else {
2601       marks->disp_pcolor_av =
2602          new_MCW_colormenu( marks->disp_rowcol , "Pcolor" , im3d->dc ,
2603                             0 , last_color , marks->ov_pcolor ,
2604                             AFNI_marks_disp_av_CB , (XtPointer) im3d ) ;
2605    }
2606 
2607    marks->disp_pcolor_av->parent = (XtPointer) im3d ;
2608 
2609    MCW_reghelp_children( marks->disp_pcolor_av->wrowcol ,
2610                          AFNI_disp_pcolor_help ) ;
2611    MCW_reghint_children( marks->disp_pcolor_av->wrowcol ,
2612                          "Color of primary marker" ) ;
2613 
2614    ADDTO_KILL(im3d->kl,marks->disp_pcolor_av) ;
2615 
2616    /*--- arrowval to control secondary color ---*/
2617 
2618    if( ii == MCW_AV_downup ){
2619       marks->disp_scolor_av =
2620          new_MCW_arrowval(
2621             marks->disp_rowcol ,    /* parent */
2622             "Scolor" ,              /* label */
2623             MCW_AV_downup ,         /* arrow directions */
2624             0 ,                     /* min value */
2625             last_color ,            /* max value */
2626             marks->ov_scolor ,      /* init value */
2627             MCW_AV_readtext ,       /* readonly text display */
2628             0 ,                     /* 0 decimal shift */
2629             AFNI_marks_disp_av_CB , /* click routine */
2630             (XtPointer) im3d ,      /* data */
2631             MCW_DC_ovcolor_text ,   /* text routine */
2632             (XtPointer) im3d->dc    /* data */
2633           ) ;
2634       marks->disp_scolor_av->fastdelay  = 333 ;  /* slow down repeat action */
2635       marks->disp_scolor_av->allow_wrap = 1 ;
2636       (void) MCW_DC_ovcolor_text( marks->disp_scolor_av ,
2637                                   im3d->dc               ) ;  /* set color! */
2638    } else {
2639       marks->disp_scolor_av =
2640          new_MCW_colormenu( marks->disp_rowcol , "Scolor" , im3d->dc ,
2641                             0 , last_color , marks->ov_scolor ,
2642                             AFNI_marks_disp_av_CB , (XtPointer) im3d ) ;
2643    }
2644 
2645    marks->disp_scolor_av->parent = (XtPointer) im3d ;
2646 
2647    MCW_reghelp_children( marks->disp_scolor_av->wrowcol ,
2648                          AFNI_disp_scolor_help ) ;
2649    MCW_reghint_children( marks->disp_scolor_av->wrowcol ,
2650                          "Color of secondary markers" ) ;
2651 
2652    ADDTO_KILL(im3d->kl,marks->disp_scolor_av) ;
2653 
2654    /*--- arrowval to control point size  ---*/
2655 
2656    marks->ov_size = INIT_marks_size ;  /* initialize overlay mask */
2657    marks->ov_gap  = INIT_marks_gap ;
2658    AFNI_make_ptmask( marks->ov_size , marks->ov_gap , &(marks->ov_mask) ) ;
2659 
2660    marks->disp_size_av =
2661       new_MCW_arrowval(
2662          marks->disp_rowcol ,    /* parent */
2663          "Size  " ,              /* label */
2664          AVOPT_STYLE ,           /* arrow directions */
2665          1  ,                    /* min value */
2666          MAXOVSIZE ,             /* max value */
2667          marks->ov_size ,        /* init value */
2668          MCW_AV_editext ,        /* input/output text display */
2669          0 ,                     /* 0 decimal shift */
2670          AFNI_marks_disp_av_CB , /* routine to call after click */
2671          (XtPointer) im3d ,      /* data to pass */
2672          NULL ,                  /* routine to call for text display */
2673          NULL                    /* data for text display routine */
2674       ) ;
2675 
2676    if( AVOPT_STYLE == MCW_AV_optmenu && MAXOVSIZE >= COLSIZE )
2677       AVOPT_columnize( marks->disp_size_av , 1+(MAXOVSIZE+1)/COLSIZE ) ;
2678 
2679    marks->disp_size_av->parent    = (XtPointer) im3d ;
2680    marks->disp_size_av->fastdelay = 333 ;  /* slow down repeat action */
2681 
2682    MCW_reghelp_children( marks->disp_size_av->wrowcol ,
2683                          AFNI_disp_size_help ) ;
2684    MCW_reghint_children( marks->disp_size_av->wrowcol ,
2685                          "Size of markers" ) ;
2686 
2687    ADDTO_KILL(im3d->kl,marks->disp_size_av) ;
2688 
2689    /*--- arrowval to control point gap  ---*/
2690 
2691    marks->disp_gap_av =
2692       new_MCW_arrowval(
2693          marks->disp_rowcol ,    /* parent */
2694          "Gap   " ,              /* label */
2695          AVOPT_STYLE ,           /* arrow directions */
2696          1  ,                    /* min value */
2697          MAXOVSIZE ,             /* max value */
2698          marks->ov_gap ,         /* init value */
2699          MCW_AV_editext ,        /* input/output text display */
2700          0 ,                     /* 0 decimal shift */
2701          AFNI_marks_disp_av_CB , /* routine to call after click */
2702          (XtPointer) im3d ,      /* data to pass */
2703          NULL ,                  /* routine to call for text display */
2704          NULL                    /* data for text display routine */
2705       ) ;
2706 
2707    if( AVOPT_STYLE == MCW_AV_optmenu && MAXOVSIZE >= COLSIZE )
2708       AVOPT_columnize( marks->disp_gap_av , 1+(MAXOVSIZE+1)/COLSIZE ) ;
2709 
2710    marks->disp_size_av->parent    = (XtPointer) im3d ;
2711    marks->disp_size_av->fastdelay = 333 ;  /* slow down repeat action */
2712 
2713    MCW_reghelp_children( marks->disp_gap_av->wrowcol ,
2714                          AFNI_disp_gap_help ) ;
2715    MCW_reghint_children( marks->disp_gap_av->wrowcol ,
2716                          "Size of gap in markers" ) ;
2717 
2718    ADDTO_KILL(im3d->kl,marks->disp_size_av) ;
2719 
2720    /*----- rowcol to hold action pushbuttons -----*/
2721 
2722    marks->action_rowcol =
2723       XtVaCreateWidget(
2724          "dialog" , xmRowColumnWidgetClass , marks->control_rowcol ,
2725             XmNorientation  , XmHORIZONTAL ,
2726             XmNtraversalOn , True  ,
2727             XmNinitialResourcesPersistent , False ,
2728          NULL ) ;
2729 
2730    /*----- set point pushbutton -----*/
2731 
2732    marks->action_set_pb =
2733       XtVaCreateManagedWidget(
2734          "dialog" , xmPushButtonWidgetClass , marks->action_rowcol ,
2735             LABEL_ARG("Set") ,
2736             XmNtraversalOn , True  ,
2737             XmNinitialResourcesPersistent , False ,
2738          NULL ) ;
2739 
2740    XtAddCallback( marks->action_set_pb , XmNactivateCallback ,
2741                   AFNI_marks_action_CB , im3d ) ;
2742 
2743    MCW_register_help( marks->action_set_pb , AFNI_marks_set_help ) ;
2744    MCW_register_hint( marks->action_set_pb , "Set marker at crosshairs" ) ;
2745 
2746    /*----- clear point pushbutton -----*/
2747 
2748    marks->action_clear_pb =
2749       XtVaCreateManagedWidget(
2750          "dialog" , xmPushButtonWidgetClass , marks->action_rowcol ,
2751             LABEL_ARG("Clear") ,
2752             XmNtraversalOn , True  ,
2753             XmNinitialResourcesPersistent , False ,
2754          NULL ) ;
2755 
2756    XtAddCallback( marks->action_clear_pb , XmNactivateCallback ,
2757                   AFNI_marks_action_CB , im3d ) ;
2758 
2759    MCW_register_help( marks->action_clear_pb , AFNI_marks_clear_help ) ;
2760    MCW_register_hint( marks->action_clear_pb , "Un-set primary marker" ) ;
2761 
2762    /*----- copies of these pushbuttons on the popup menu -----*/
2763 
2764 #ifdef POPTOG
2765    marks->always_popup[(marks->num_always_popup)++] =
2766       XtVaCreateManagedWidget(
2767              "dialog" , xmSeparatorWidgetClass , imag->popmenu ,
2768                  XmNseparatorType , XmDOUBLE_LINE ,
2769              NULL ) ;
2770 
2771    /*---*/
2772 
2773    marks->always_popup[(marks->num_always_popup)++] =
2774    marks->pop_set_pb =
2775       XtVaCreateWidget(
2776          "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
2777             LABEL_ARG("Set") ,
2778             XmNmarginHeight , 0 ,
2779             XmNtraversalOn , True  ,
2780             XmNinitialResourcesPersistent , False ,
2781          NULL ) ;
2782 
2783    XtAddCallback( marks->pop_set_pb , XmNactivateCallback ,
2784                   AFNI_marks_action_CB , im3d ) ;
2785 
2786    /*---*/
2787 
2788    marks->always_popup[(marks->num_always_popup)++] =
2789    marks->pop_clear_pb =
2790       XtVaCreateWidget(
2791          "dialog" , xmPushButtonWidgetClass , imag->popmenu ,
2792             LABEL_ARG("Clear") ,
2793             XmNmarginHeight , 0 ,
2794             XmNtraversalOn , True  ,
2795             XmNinitialResourcesPersistent , False ,
2796          NULL ) ;
2797 
2798    XtAddCallback( marks->pop_clear_pb , XmNactivateCallback ,
2799                   AFNI_marks_action_CB , im3d ) ;
2800 #endif
2801 
2802    /*----- a "quality" button (not on the popup menu) -----*/
2803 
2804    marks->action_quality_pb =
2805       XtVaCreateManagedWidget(
2806          "dialog" , xmPushButtonWidgetClass , marks->action_rowcol ,
2807             LABEL_ARG("Quality?") ,
2808             XmNtraversalOn , True  ,
2809             XmNinitialResourcesPersistent , False ,
2810          NULL ) ;
2811 
2812    XtAddCallback( marks->action_quality_pb , XmNactivateCallback ,
2813                   AFNI_marks_action_CB , im3d ) ;
2814 
2815    MCW_register_help( marks->action_quality_pb , AFNI_marks_quality_help ) ;
2816    MCW_register_hint( marks->action_quality_pb , "Check markers for consistency" ) ;
2817 
2818    /*----- below the line, put the transformation controls -----*/
2819 
2820    (void) XtVaCreateManagedWidget(
2821              "dialog" , xmSeparatorWidgetClass , marks->control_rowcol ,
2822                  XmNseparatorType , XmDOUBLE_LINE ,
2823              NULL ) ;
2824 
2825    /*----- the transformation control -----*/
2826 
2827    marks->transform_pb =
2828       XtVaCreateManagedWidget(
2829          "dialog" , xmPushButtonWidgetClass , marks->control_rowcol ,
2830             LABEL_ARG("Transform Data") ,
2831             XmNtraversalOn , True  ,
2832             XmNinitialResourcesPersistent , False ,
2833          NULL ) ;
2834 
2835    XtAddCallback( marks->transform_pb , XmNactivateCallback ,
2836                   AFNI_marks_transform_CB , im3d ) ;
2837 
2838    MCW_register_help( marks->transform_pb , AFNI_marks_transform_help ) ;
2839    MCW_register_hint( marks->transform_pb , "Compute transformation from markers" ) ;
2840 
2841    /*----- 3/06/96: the "big Talairach box" button -----*/
2842 
2843    marks->tlrc_big_bbox =
2844       new_MCW_bbox( marks->control_rowcol ,
2845                     1 , AFNI_tlrc_big_bbox_label ,
2846                     MCW_BB_check , MCW_BB_noframe ,
2847                     NULL , NULL                    ) ;    /* no callback */
2848 
2849    marks->tlrc_big_bbox->parent = (XtPointer) im3d ;
2850 
2851    MCW_reghelp_children( marks->tlrc_big_bbox->wrowcol ,
2852                          AFNI_tlrc_big_bbox_help ) ;
2853    MCW_reghint_children( marks->tlrc_big_bbox->wrowcol ,
2854                          "Use 'big' Talairach bounding box" ) ;
2855 
2856    ADDTO_KILL(im3d->kl,marks->tlrc_big_bbox) ;
2857 
2858    if( GLOBAL_argopt.tlrc_big )
2859       MCW_set_bbox( marks->tlrc_big_bbox , 1 ) ;
2860 
2861    /*----- manage the managers -----*/
2862 
2863    XtManageChild( marks->tog_rowcol ) ;
2864    XtManageChild( marks->disp_rowcol ) ;
2865    XtManageChild( marks->action_rowcol ) ;
2866    XtManageChild( marks->control_rowcol ) ;
2867    XtManageChild( marks->rowcol ) ;
2868 
2869    /*-----------------------------------------------------*/
2870    /**************** Function controls ********************/
2871    /*-----------------------------------------------------*/
2872 
2873 /** old hard-wired definition */
2874 #define SELECTOR_HEIGHT 240
2875 
2876    sel_height = view_height - 39 ;
2877 
2878    func->do_setup = 1 ;   /* 24 May 2019 */
2879 
2880 STATUS("making func->rowcol") ;
2881 
2882    func->rowcol =
2883       XtVaCreateWidget(
2884          "dialog" , xmRowColumnWidgetClass , func->frame ,
2885             XmNorientation , XmHORIZONTAL ,
2886             XmNpacking , XmPACK_TIGHT ,
2887             XmNtraversalOn , True  ,
2888             XmNinitialResourcesPersistent , False ,
2889          NULL ) ;
2890 
2891    /*-- threshold stuff --*/
2892 
2893    func->thr_rowcol =
2894       XtVaCreateWidget(
2895          "dialog" , xmRowColumnWidgetClass , func->rowcol ,
2896             XmNorientation , XmVERTICAL ,
2897             XmNpacking , XmPACK_TIGHT ,
2898             XmNmarginHeight, 0 ,
2899             XmNmarginWidth , 0 ,
2900             XmNtraversalOn , True  ,
2901             XmNinitialResourcesPersistent , False ,
2902          NULL ) ;
2903 
2904    func->thrtop_rowcol =
2905       XtVaCreateWidget(
2906          "dialog" , xmRowColumnWidgetClass , func->thr_rowcol ,
2907             XmNorientation , XmHORIZONTAL ,
2908             XmNpacking , XmPACK_TIGHT ,
2909             XmNmarginHeight, 0 ,
2910             XmNmarginWidth , 0 ,
2911             XmNspacing     , 1 ,
2912             XmNtraversalOn , True  ,
2913             XmNinitialResourcesPersistent , False ,
2914          NULL ) ;
2915 
2916    func->thr_label =
2917       XtVaCreateManagedWidget(
2918          "dialog" , xmLabelWidgetClass , func->thrtop_rowcol ,
2919             LABEL_ARG("Thr") ,
2920             XmNrecomputeSize , False ,
2921             XmNinitialResourcesPersistent , False ,
2922          NULL ) ;
2923    LABELIZE(func->thr_label) ;
2924    MCW_set_widget_bg( func->thr_label , "#080808" , 0 ) ;
2925    MCW_set_widget_fg( func->thr_label , "#ffeedd" ) ;
2926    MCW_register_hint( func->thr_label ,
2927                       "Left click = fix slider size ; Right click = popup menu" ) ;
2928 
2929    /*--- A(lpha) and B(oxed) buttons atop threshold slider [02 Nov 2018] ---*/
2930 
2931    func->thrtop_alpha_pb =
2932       XtVaCreateManagedWidget(
2933          "font8" , xmPushButtonWidgetClass , func->thrtop_rowcol ,
2934             LABEL_ARG("A") ,
2935             XmNmarginWidth  , 2 ,
2936             XmNmarginHeight , 0 ,
2937             XmNspacing      , 0 ,
2938             XmNborderWidth  , 0 ,
2939             XmNtraversalOn , True  ,
2940             XmNinitialResourcesPersistent , False ,
2941          NULL ) ;
2942    XtAddCallback( func->thrtop_alpha_pb , XmNactivateCallback ,
2943                   AFNI_func_thrtop_CB , im3d ) ;
2944    MCW_register_hint( func->thrtop_alpha_pb ,
2945                       "Turn on/off alpha fading for below threshold voxels" ) ;
2946    BLACK_AND_WHITE_WIDGET(func->thrtop_alpha_pb) ;
2947 
2948    if( AFNI_yesenv("AFNI_FUNC_ALPHA") ){
2949      im3d->vinfo->thr_use_alpha = 1 ;
2950      MCW_invert_widget(func->thrtop_alpha_pb) ;
2951    } else {
2952      im3d->vinfo->thr_use_alpha = 0 ;
2953    }
2954 
2955    /*---*/
2956 
2957    func->thrtop_boxed_pb =
2958       XtVaCreateManagedWidget(
2959          "font8" , xmPushButtonWidgetClass , func->thrtop_rowcol ,
2960             LABEL_ARG("B") ,
2961             XmNmarginWidth  , 2 ,
2962             XmNmarginHeight , 0 ,
2963             XmNspacing      , 0 ,
2964             XmNborderWidth  , 0 ,
2965             XmNtraversalOn , True  ,
2966             XmNinitialResourcesPersistent , False ,
2967          NULL ) ;
2968    XtAddCallback( func->thrtop_boxed_pb , XmNactivateCallback ,
2969                   AFNI_func_thrtop_CB , im3d ) ;
2970    MCW_register_hint( func->thrtop_boxed_pb ,
2971                       "Turn on/off boxes around above threshold voxel clusters" ) ;
2972    BLACK_AND_WHITE_WIDGET(func->thrtop_boxed_pb) ;
2973 
2974    if( AFNI_yesenv("AFNI_FUNC_BOXED") ){
2975      im3d->vinfo->thr_use_boxed = 1 ;
2976      MCW_invert_widget(func->thrtop_boxed_pb) ;
2977    } else {
2978      im3d->vinfo->thr_use_boxed = 0 ;
2979    }
2980 
2981    /*-------------------------------------------------------------------------*/
2982 
2983 #ifdef FIX_SCALE_VALUE_PROBLEM
2984    MCW_register_help( func->thr_label ,
2985       "This version of AFNI has been\n"
2986       "compiled to show the slider value\n"
2987       "here, since there is a bug in the\n"
2988       "Motif library for this computer system."
2989    ) ;
2990 #else
2991 #if 0
2992    MCW_register_help( func->thr_label ,
2993       "Shows the type of threshold\n"
2994       "statistic that is available\n"
2995       "at this moment.  Names mean:\n\n"
2996       FUNC_THR_LABEL " = " FUNC_THR_DESCRIPTOR "\n"
2997       FUNC_COR_LABEL " = " FUNC_COR_DESCRIPTOR "\n"
2998       FUNC_TT_LABEL  " = " FUNC_TT_DESCRIPTOR  "\n"
2999       FUNC_FT_LABEL  " = " FUNC_FT_DESCRIPTOR  "\n"
3000       FUNC_ZT_LABEL  " = " FUNC_ZT_DESCRIPTOR  "\n"
3001       FUNC_CT_LABEL  " = " FUNC_CT_DESCRIPTOR  "\n"
3002       FUNC_BT_LABEL  " = " FUNC_BT_DESCRIPTOR  "\n"
3003       FUNC_BN_LABEL  " = " FUNC_BN_DESCRIPTOR  "\n"
3004       FUNC_GT_LABEL  " = " FUNC_GT_DESCRIPTOR  "\n"
3005       FUNC_PT_LABEL  " = " FUNC_PT_DESCRIPTOR  "\n"
3006    ) ;
3007    MCW_register_hint( func->thr_label , "Type of threshold statistic" ) ;
3008 #endif
3009 #endif
3010 
3011    /**--------- 05 Sep 2006: create menu hidden on the thr_label ---------**/
3012 
3013    { static char *onofflabel[]    = { "Use Threshold?" } ;
3014      static char *throlayxlabel[] = { "Thr = OLay ?" , "Thr = Olay+1 ?" } ;
3015      char *eee ;
3016 
3017 #ifdef BAD_BUTTON3_POPUPS
3018    func->thr_menu = XmCreatePopupMenu( func->thr_rowcol, "menu", NULL, 0 ) ;
3019 #else
3020    func->thr_menu = XmCreatePopupMenu( func->thr_label , "menu", NULL, 0 ) ;
3021 #endif
3022 
3023    SAVEUNDERIZE(XtParent(func->thr_menu)) ;
3024    VISIBILIZE_WHEN_MAPPED(func->thr_menu) ;
3025 #if 0
3026    if( !AFNI_yesenv("AFNI_DISABLE_TEAROFF") ) TEAROFFIZE(func->thr_menu) ;
3027 #endif
3028 
3029    XtInsertEventHandler( func->thr_label ,       /* handle events in label */
3030 
3031                                0
3032                              | ButtonPressMask   /* button presses */
3033                             ,
3034                             FALSE ,              /* nonmaskable events? */
3035                             AFNI_thr_EV ,        /* handler */
3036                             (XtPointer) im3d ,   /* client data */
3037                             XtListTail           /* last in queue */
3038                           ) ;
3039 
3040    /* This --- Cancel --- label does not cause the hangup, so it is
3041    left alone. See related comments in afni_graph.c
3042                            LessTif patrol, Jan 07 09 */
3043    wtemp = XtVaCreateManagedWidget(
3044             "dialog" , xmLabelWidgetClass , func->thr_menu ,
3045                LABEL_ARG("--- Cancel ---") ,
3046                XmNrecomputeSize , False ,
3047                XmNinitialResourcesPersistent , False ,
3048             NULL ) ; LABELIZE(wtemp) ;
3049 
3050    (void) XtVaCreateManagedWidget(
3051             "dialog" , xmSeparatorWidgetClass , func->thr_menu ,
3052              XmNseparatorType , XmSINGLE_LINE , NULL ) ;
3053 
3054    /*-- Threshold on/off? button --*/
3055 
3056    func->thr_onoff_bbox = new_MCW_bbox( func->thr_menu ,
3057                                         1 , onofflabel ,
3058                                         MCW_BB_check , MCW_BB_noframe ,
3059                                         AFNI_thronoff_change_CB ,
3060                                         (XtPointer)im3d ) ;
3061    im3d->vinfo->thr_onoff = 1 ;
3062    MCW_set_bbox( func->thr_onoff_bbox , 1 ) ;
3063    MCW_reghint_children( func->thr_onoff_bbox->wrowcol ,
3064                          "Temporarily ignore threshold?" ) ;
3065 
3066    /*-- Thr=OLay+1? button [13 Aug 2010] -- modified 24 Jun 2013 --*/
3067 
3068    (void) XtVaCreateManagedWidget(
3069             "dialog" , xmSeparatorWidgetClass , func->thr_menu ,
3070              XmNseparatorType , XmSINGLE_LINE , NULL ) ;
3071 
3072    func->thr_olayx_bbox = new_MCW_bbox( func->thr_menu ,
3073                                         2 , throlayxlabel ,
3074                                         MCW_BB_radio_zero , MCW_BB_noframe ,
3075                                         AFNI_throlayx_change_CB ,
3076                                         (XtPointer)im3d ) ;
3077    im3d->vinfo->thr_olayx = 0 ;
3078    eee = getenv("AFNI_SLAVE_THROLAY") ;
3079    if( eee != NULL && *eee != '\0' ){
3080      if( *eee == '0' || strcasecmp(eee,"OLay")   == 0 || strcasecmp(eee,"==") == 0 )
3081        im3d->vinfo->thr_olayx = 1 ;
3082      if( *eee == '1' || strcasecmp(eee,"OLay+1") == 0 || strcasecmp(eee,"+1") == 0 )
3083        im3d->vinfo->thr_olayx = 2 ;
3084    }
3085    MCW_set_bbox( func->thr_olayx_bbox , im3d->vinfo->thr_olayx ) ;
3086    MCW_reghint_children( func->thr_olayx_bbox->wrowcol ,
3087                          "Lock Thr to depend on OLay sub-brick?" ) ;
3088 
3089    (void) XtVaCreateManagedWidget(
3090             "dialog" , xmSeparatorWidgetClass , func->thr_menu ,
3091              XmNseparatorType , XmSINGLE_LINE , NULL ) ;
3092 
3093    /*-- AutoThreshold button --*/
3094 
3095    func->thr_autothresh_pb =
3096       XtVaCreateManagedWidget(
3097          "dialog" , xmPushButtonWidgetClass , func->thr_menu ,
3098             LABEL_ARG("AutoThreshold") ,
3099             XmNtraversalOn , True  ,
3100             XmNinitialResourcesPersistent , False ,
3101          NULL ) ;
3102    XtAddCallback( func->thr_autothresh_pb , XmNactivateCallback ,
3103                   AFNI_func_autothresh_CB , im3d ) ;
3104    MCW_register_hint( func->thr_autothresh_pb ,
3105                       "Compute ad hoc threshold automatically NOW" ) ;
3106 
3107    /*-- Set threshold button [16 Jul 2020] discoraj --*/
3108 
3109    func->thr_setthresh_pb =
3110       XtVaCreateManagedWidget(
3111          "dialog" , xmPushButtonWidgetClass , func->thr_menu ,
3112             LABEL_ARG("Set threshold") ,
3113             XmNtraversalOn , True  ,
3114             XmNinitialResourcesPersistent , False ,
3115          NULL ) ;
3116    XtAddCallback( func->thr_setthresh_pb , XmNactivateCallback ,
3117                   AFNI_func_setthresh_CB , im3d ) ;
3118    MCW_register_hint( func->thr_setthresh_pb ,
3119                       "Enter value to set threshold" ) ;
3120 
3121    /*-- Set pval button [03 Dec 2013] --*/
3122 
3123    func->thr_setpval_pb =
3124       XtVaCreateManagedWidget(
3125          "dialog" , xmPushButtonWidgetClass , func->thr_menu ,
3126             LABEL_ARG("Set p-value") ,
3127             XmNtraversalOn , True  ,
3128             XmNinitialResourcesPersistent , False ,
3129          NULL ) ;
3130    XtAddCallback( func->thr_setpval_pb , XmNactivateCallback ,
3131                   AFNI_func_setpval_CB , im3d ) ;
3132    MCW_register_hint( func->thr_setpval_pb ,
3133                       "Enter p-value to set threshold" ) ;
3134 
3135    /*-- Set qval button [26 Feb 2014] --*/
3136 
3137    func->thr_setqval_pb =
3138       XtVaCreateManagedWidget(
3139          "dialog" , xmPushButtonWidgetClass , func->thr_menu ,
3140             LABEL_ARG("Set q-value") ,
3141             XmNtraversalOn , True  ,
3142             XmNinitialResourcesPersistent , False ,
3143          NULL ) ;
3144    XtAddCallback( func->thr_setqval_pb , XmNactivateCallback ,
3145                   AFNI_func_setqval_CB , im3d ) ;
3146    MCW_register_hint( func->thr_setqval_pb ,
3147                       "Enter q-value to set threshold" ) ;
3148 
3149    im3d->vinfo->fix_pval   = im3d->vinfo->fix_qval   = 0    ; /* 27 Feb 2014 */
3150    im3d->vinfo->fixed_pval = im3d->vinfo->fixed_qval = 0.0f ;
3151 
3152    /*-- Set pval = 0.001 button [05 Nov 2018] --*/
3153 
3154    func->thr_setpval_001_pb =
3155       XtVaCreateManagedWidget(
3156          "dialog" , xmPushButtonWidgetClass , func->thr_menu ,
3157             LABEL_ARG("Set p=0.001") ,
3158             XmNtraversalOn , True  ,
3159             XmNinitialResourcesPersistent , False ,
3160          NULL ) ;
3161    XtAddCallback( func->thr_setpval_001_pb , XmNactivateCallback ,
3162                   AFNI_func_setpval_001_CB , im3d ) ;
3163    MCW_register_hint( func->thr_setpval_001_pb , "Set p-value to 0.001" ) ;
3164 
3165    /* Threshold sign arrowval [08 Aug 2007] */
3166 
3167    { static char *thr_sign_label[3] = { "Pos & Neg",
3168                                         "Pos only" ,
3169                                         "Neg only"  } ;
3170      im3d->vinfo->thr_sign = 0 ;  /* default = "Pos & Neg" */
3171      func->thr_sign_av =
3172         new_MCW_arrowval(
3173            func->thr_menu ,        /* parent */
3174            "Sign " ,               /* label */
3175            AVOPT_STYLE ,           /* arrow directions */
3176            0  ,                    /* min value */
3177            2  ,                    /* max value */
3178            im3d->vinfo->thr_sign , /* init value */
3179            MCW_AV_editext ,        /* input/output text display */
3180            0 ,                     /* 0 decimal shift */
3181            AFNI_func_thrsign_CB ,  /* routine to call after click */
3182            (XtPointer) im3d ,      /* data to pass */
3183            MCW_av_substring_CB ,   /* text creation routine */
3184            thr_sign_label          /* data for above */
3185         ) ;
3186       MCW_reghint_children( func->thr_sign_av->wrowcol ,
3187                             "show Positives, Negatives, or Both?" ) ;
3188     }
3189 
3190 #if 1 /* disabled 02 Nov 2018 */   /* re-enabled 28 Jun 2021 */
3191    /* Threshold use alpha arrowval [08 Dec 2014] */
3192 
3193    { static char *thr_alpha_label[2] = { "Linear" , "Quadratic"} ;
3194      char *cpt = getenv("AFNI_FUNC_ALPHA") ; int mm=2 ;
3195      if( cpt != NULL && toupper(*cpt) == 'L' ) mm = 1 ;
3196      func->thr_alpha_av =
3197         new_MCW_arrowval(
3198            func->thr_menu ,             /* parent */
3199            "Alpha" ,                    /* label */
3200            AVOPT_STYLE ,                /* arrow directions */
3201            0  ,                         /* min value */
3202            1  ,                         /* max value */
3203            mm             ,             /* init value */
3204            MCW_AV_editext ,             /* input/output text display */
3205            0 ,                          /* 0 decimal shift */
3206            AFNI_func_alpha_CB ,         /* routine to call after click */
3207            (XtPointer) im3d ,           /* data to pass (viewer) */
3208            MCW_av_substring_CB ,        /* text creation routine */
3209            thr_alpha_label              /* data for above */
3210         ) ;
3211       MCW_reghint_children( func->thr_alpha_av->wrowcol ,
3212                             "'A' color fading method"    ) ;
3213     }
3214 #endif
3215 
3216 #if 0  /* disabled 02 Nov 2018 */
3217    /* Threshold alpha floor arrowval [09 Dec 2014] */
3218 
3219    { static char *thr_floor_label[5] = { " 0.0 " , " 0.2 " , " 0.4 " , " 0.6 " , " 0.8 " } ;
3220      im3d->vinfo->thr_alpha_floor = 0.0f ;
3221      func->thr_floor_av =
3222         new_MCW_arrowval(
3223            func->thr_menu ,             /* parent */
3224            "Floor" ,                    /* label */
3225            AVOPT_STYLE ,                /* arrow directions */
3226            0  ,                         /* min value */
3227            4  ,                         /* max value */
3228            0                          , /* init value */
3229            MCW_AV_editext ,             /* input/output text display */
3230            0 ,                          /* 0 decimal shift */
3231            AFNI_func_floor_CB ,         /* routine to call after click */
3232            (XtPointer)im3d ,            /* data to pass */
3233            MCW_av_substring_CB ,        /* text creation routine */
3234            thr_floor_label              /* data for above */
3235         ) ;
3236       MCW_reghint_children( func->thr_floor_av->wrowcol ,
3237                             "Minimum value for Alpha (fading factor)" ) ;
3238     }
3239 #endif
3240 
3241    /* FDR button */
3242 
3243    func->thr_fdr_pb =
3244       XtVaCreateManagedWidget(
3245          "dialog" , xmPushButtonWidgetClass , func->thr_menu ,
3246             LABEL_ARG("Add FDR Curves") ,
3247             XmNtraversalOn , True  ,
3248             XmNinitialResourcesPersistent , False ,
3249          NULL ) ;
3250    XtAddCallback( func->thr_fdr_pb , XmNactivateCallback ,
3251                   AFNI_func_fdr_CB , im3d ) ;
3252    MCW_register_hint( func->thr_fdr_pb ,
3253                       "Compute FDR curves for OLay statistical sub-bricks" ) ;
3254 
3255    /* p-value stuff button [06 Mar 2014] */
3256 
3257    (void) XtVaCreateManagedWidget(
3258             "dialog" , xmSeparatorWidgetClass , func->thr_menu ,
3259              XmNseparatorType , XmSINGLE_LINE , NULL ) ;
3260 
3261    func->thr_pvalue_pb =
3262          XtVaCreateManagedWidget(
3263             "dialog" , xmPushButtonWidgetClass , func->thr_menu ,
3264                LABEL_ARG("Meaning of p-values") ,
3265                XmNmarginHeight , 0 ,
3266                XmNtraversalOn , True  ,
3267                XmNinitialResourcesPersistent , False ,
3268             NULL ) ;
3269    XtAddCallback( func->thr_pvalue_pb , XmNactivateCallback ,
3270                   AFNI_pvalue_CB , im3d ) ;
3271    MCW_register_hint( func->thr_pvalue_pb,"How to think about p-values" );
3272    MCW_set_widget_bg( func->thr_pvalue_pb,PVALUE_COLOR,0) ;
3273 
3274    } /*---- end of thr_menu creation for top of threshold slider ----*/
3275 
3276    FIX_SCALE_VALUE(im3d) ;  /* just in case */
3277 
3278 #define SCALE_EXTRA 66
3279 
3280   {Widget qqq ; int iqqq ;
3281    char thr_str[] = "-----------" ;
3282    char zork[2] ;
3283 
3284    int smax , stop , decim , sstep ;                  /* 30 Nov 1997:       */
3285    decim = THR_top_expon ;                            /* compute parameters */
3286    smax  = (int)( pow(10.0,decim) + 0.001 ) ;         /* for scale display. */
3287    stop  = smax - 1 ;
3288    sstep = smax / 1000 ;
3289    { char *eee = getenv("AFNI_THRESH_BIGSTEP") ;      /* 09 May 2003 */
3290      if( eee != NULL ){ iqqq=strtol(eee,NULL,10); if(iqqq > 0) sstep=iqqq; }
3291    }
3292    if( sstep < 1 ) sstep = 1 ; else if( sstep > (smax/10) ) sstep = (smax/10) ;
3293 
3294 #ifdef BOXUP_SCALE
3295    qqq = XtVaCreateManagedWidget(
3296            "dialog" , xmFrameWidgetClass , func->thr_rowcol ,
3297             XmNshadowType , XmSHADOW_ETCHED_IN ,
3298             XmNtraversalOn , True  ,
3299             XmNinitialResourcesPersistent , False ,
3300          NULL ) ;
3301 #else
3302    qqq = func->thr_rowcol ;
3303 #endif
3304 
3305    func->thr_scale =
3306       XtVaCreateManagedWidget(
3307          "scale" , xmScaleWidgetClass , qqq ,
3308             XmNminimum , 0 ,             /* 30 Nov 1997: changed */
3309             XmNmaximum , stop ,          /* range to be computed */
3310             XmNscaleMultiple , sstep ,
3311             XmNdecimalPoints , decim ,
3312 #ifdef FIX_SCALE_VALUE_PROBLEM
3313             XmNshowValue , False ,
3314 #else
3315             XmNshowValue , True ,
3316 #endif
3317             XmNvalue , (int)(smax*im3d->vinfo->func_threshold) ,
3318             XmNorientation , XmVERTICAL ,
3319             XmNheight , sel_height ,
3320             XmNborderWidth , 0 ,
3321             XmNtraversalOn , True  ,
3322             XmNinitialResourcesPersistent , False ,
3323          NULL ) ;
3324 
3325          XtVaSetValues( func->thr_scale ,
3326                           XmNuserData , (XtPointer)ITOP(sel_height) ,
3327                         NULL ) ;
3328 
3329 #ifdef USING_LESSTIF
3330    XtVaSetValues( func->thr_scale , XmNscaleWidth,24 , NULL ) ;
3331 #endif
3332 
3333 #ifdef FIX_SCALE_VALUE_PROBLEM
3334    for( iqqq=0 ; iqqq < strlen(thr_str) ; iqqq++ ){
3335       zork[0] = thr_str[iqqq] ; zork[1] = '\0' ;
3336       XtVaCreateManagedWidget( zork,xmLabelWidgetClass,func->thr_scale,NULL ) ;
3337    }
3338 #endif
3339   }
3340 
3341    XtAddCallback( func->thr_scale , XmNvalueChangedCallback ,
3342                   AFNI_thr_scale_CB , im3d ) ;
3343 
3344    XtAddCallback( func->thr_scale , XmNdragCallback ,
3345                   AFNI_thr_scale_drag_CB , im3d ) ;
3346 
3347    MCW_reghelp_children( func->thr_scale ,
3348       "Drag the slider bar to\n"
3349       "adjust the threshold\n"
3350       "for overlay display.\n\n"
3351       "* Threshold doesn't apply\n"
3352       "  if dataset is RGB-format.\n"
3353       "* Threshold applies to 'Thr'\n"
3354       "  sub-brick.\n"
3355     ) ;
3356 #if 0
3357    MCW_register_hint( func->thr_scale , "Threshold for color overlay" ) ;
3358 #endif
3359 
3360    /** Mar 1996: label for computed p-value, under scale **/
3361 
3362    func->thr_pval_label =
3363       XtVaCreateManagedWidget(
3364          "font8" , xmLabelWidgetClass , func->thr_rowcol ,
3365             LABEL_ARG( "p=N/A   \nq=N/A   " ) ,
3366             XmNrecomputeSize , False ,
3367             XmNinitialResourcesPersistent , False ,
3368          NULL ) ;
3369    LABELIZE(func->thr_pval_label) ;
3370 
3371    MCW_register_help( func->thr_pval_label ,
3372       " \n"
3373       "* Shows the estimated significance (p-value) of the threshold\n"
3374       "   slider if possible.  This is the 'uncorrected' or per-voxel\n"
3375       "   value of 'p'.\n"
3376       "* If not possible, will display as '[N/A]' instead.\n"
3377       "* p's that display as 1.2-7 mean 1.2 x 10^(-7).\n"
3378       "* alpha(p) = approximate likelihood that the p-value shown\n"
3379       "   results from the null hypothesis, not the alternative.\n"
3380       "   (Shown in the hint for the label below the slider.)\n"
3381       "* If FDR curves are pre-computed in the dataset header,\n"
3382       "   then the False Discovery Rate q-value will also be shown.\n"
3383       "* You can add FDR curves to a dataset with '3drefit -addFDR'\n"
3384       "   or by using the 'Add FDR Curves' button on the right-click\n"
3385       "   popup menu on the label atop the threshold slider.\n"
3386       "* FDR q = estimate of the fraction of above-threshold voxels\n"
3387       "   that are false detections ('false positives').\n"
3388       "* MDF = CRUDE estimate of fraction of true positive voxels that\n"
3389       "   are below the current threshold ('false negatives').\n"
3390       "* MDF is shown in the hint for the label below the slider.\n "
3391    ) ;
3392    MCW_register_hint( func->thr_pval_label , "Nominal p-value per voxel; FDR q-value" ) ;
3393 
3394 #define PVAL_POPUP
3395 #ifdef  PVAL_POPUP
3396    /* 05 Sep 2006: duplicate popup menu from thr_label */
3397 
3398    XtInsertEventHandler( func->thr_pval_label ,  /* handle events in label */
3399 
3400                                0
3401                              | ButtonPressMask   /* button presses */
3402                             ,
3403                             FALSE ,              /* nonmaskable events? */
3404                             AFNI_thr_EV ,        /* handler */
3405                             (XtPointer)im3d ,    /* client data */
3406                             XtListTail           /* last in queue */
3407                           ) ;
3408 #endif
3409 
3410    /** Jul 1997: optmenu to choose top value for scale **/
3411 
3412    BBOX_set_wsubtype("font8") ;
3413    func->thr_top_av = new_MCW_arrowval( func->thr_rowcol ,
3414                                         "10^" ,
3415                                         AVOPT_STYLE ,
3416                                         0,THR_top_expon,0 ,
3417                                         MCW_AV_notext , 0 ,
3418                                         AFNI_thresh_top_CB , (XtPointer)im3d ,
3419                                         AFNI_thresh_tlabel_CB , NULL ) ;
3420    BBOX_set_wsubtype(NULL) ;
3421 
3422    im3d->vinfo->func_thresh_top = 1.0 ;
3423 
3424    MCW_reghelp_children( func->thr_top_av->wrowcol ,
3425                            "Use this to set\n"
3426                            "the power-of-10\n"
3427                            "range of the\n"
3428                            "threshold slider\n"
3429                            "above."
3430                        ) ;
3431 
3432    MCW_reghint_children( func->thr_top_av->wrowcol ,
3433                          "Power-of-10 range of slider" ) ;
3434 
3435    sel_height -= (10+view_height/view_count) * 0.5 ;
3436 
3437    /*-- intensity threshold stuff --*/
3438 
3439    func->inten_rowcol =
3440       XtVaCreateWidget(
3441          "dialog" , xmRowColumnWidgetClass , func->rowcol ,
3442             XmNorientation , XmVERTICAL ,
3443             XmNmarginHeight, 0 ,
3444             XmNmarginWidth , 0 ,
3445             XmNpacking , XmPACK_TIGHT ,
3446             XmNtraversalOn , True  ,
3447             XmNinitialResourcesPersistent , False ,
3448          NULL ) ;
3449 
3450    func->inten_label =
3451       XtVaCreateManagedWidget(
3452          "dialog" , xmLabelWidgetClass , func->inten_rowcol ,
3453             LABEL_ARG("OLay ") ,
3454             XmNinitialResourcesPersistent , False ,
3455          NULL ) ;
3456    LABELIZE(func->inten_label) ;
3457 
3458    /**-- 17 Dec 1997: pbar menu hidden on the inten_label --**/
3459 
3460 #ifdef BAD_BUTTON3_POPUPS   /* 21 Jul 2003 */
3461    func->pbar_menu = XmCreatePopupMenu( func->inten_rowcol, "menu", NULL, 0 ) ;
3462 #else
3463    func->pbar_menu = XmCreatePopupMenu( func->inten_label , "menu", NULL, 0 ) ;
3464 #endif
3465 
3466    SAVEUNDERIZE(XtParent(func->pbar_menu)) ; /* 27 Feb 2001 */
3467    VISIBILIZE_WHEN_MAPPED(func->pbar_menu) ;
3468    if( !AFNI_yesenv("AFNI_DISABLE_TEAROFF") ) TEAROFFIZE(func->pbar_menu) ;
3469 
3470    XtInsertEventHandler( func->inten_label ,      /* handle events in label */
3471                                0
3472                              | ButtonPressMask   /* button presses */
3473                             ,
3474                             FALSE ,              /* nonmaskable events? */
3475                             AFNI_pbar_EV ,       /* handler */
3476                             (XtPointer)im3d ,    /* client data */
3477                             XtListTail           /* last in queue */
3478                           ) ;
3479 
3480 #if 0
3481    allow_MCW_optmenu_popup(0) ;  /* 12 Dec 2001 */
3482 #endif
3483 
3484    /* This --- Cancel --- label does not cause the hangup, so it is
3485    left alone. See related comments in afni_graph.c
3486                            LessTif patrol, Jan 07 09 */
3487    wtemp = XtVaCreateManagedWidget(
3488             "dialog" , xmLabelWidgetClass , func->pbar_menu ,
3489                LABEL_ARG("--- Cancel ---") ,
3490                XmNrecomputeSize , False ,
3491                XmNinitialResourcesPersistent , False ,
3492             NULL ) ; LABELIZE(wtemp) ;
3493 
3494    (void) XtVaCreateManagedWidget(
3495             "dialog" , xmSeparatorWidgetClass , func->pbar_menu ,
3496              XmNseparatorType , XmSINGLE_LINE , NULL ) ;
3497 
3498    /*--- environment button in menu [10 Feb 2004] ---*/
3499 
3500 #if 0 && defined(ALLOW_PLUGINS)
3501    func->pbar_environment_pb =
3502       XtVaCreateManagedWidget(
3503          "dialog" , xmPushButtonWidgetClass , func->pbar_menu ,
3504             LABEL_ARG("Edit Environment") ,
3505             XmNmarginHeight , 0 ,
3506             XmNtraversalOn , True  ,
3507             XmNinitialResourcesPersistent , False ,
3508          NULL ) ;
3509    XtAddCallback( func->pbar_environment_pb , XmNactivateCallback ,
3510                   AFNI_pbar_CB , im3d ) ;
3511 #else
3512    func->pbar_environment_pb = NULL ;
3513 #endif
3514 
3515    /*---*/
3516 
3517    func->pbar_setrange_1_pb =
3518       XtVaCreateManagedWidget(
3519          "dialog" , xmPushButtonWidgetClass , func->pbar_menu ,
3520             LABEL_ARG("Set OLay range = 1") ,
3521             XmNmarginHeight , 0 ,
3522             XmNtraversalOn , True  ,
3523             XmNinitialResourcesPersistent , False ,
3524          NULL ) ;
3525    XtAddCallback( func->pbar_setrange_1_pb , XmNactivateCallback ,
3526                   AFNI_pbar_CB , im3d ) ;
3527 
3528    MCW_register_hint( func->pbar_setrange_1_pb , "Set Overlay range to 1" ) ;
3529 
3530    /*---*/
3531 
3532    func->pbar_equalize_pb =      /* 16 Nov 2018 */
3533       XtVaCreateManagedWidget(
3534          "dialog" , xmPushButtonWidgetClass , func->pbar_menu ,
3535             LABEL_ARG("Equalize Spacing") ,
3536             XmNmarginHeight , 0 ,
3537             XmNtraversalOn , True  ,
3538             XmNinitialResourcesPersistent , False ,
3539          NULL ) ;
3540    XtAddCallback( func->pbar_equalize_pb , XmNactivateCallback ,
3541                   AFNI_pbar_CB , im3d ) ;
3542    MCW_register_hint( func->pbar_equalize_pb , "Space separators equally" ) ;
3543 
3544    /*---*/
3545 
3546    if( !PBAR_FULLRANGE ){
3547      func->pbar_settop_pb =
3548         XtVaCreateManagedWidget(
3549            "dialog" , xmPushButtonWidgetClass , func->pbar_menu ,
3550               LABEL_ARG("Set Top Value") ,
3551               XmNmarginHeight , 0 ,
3552               XmNtraversalOn , True  ,
3553               XmNinitialResourcesPersistent , False ,
3554            NULL ) ;
3555      XtAddCallback( func->pbar_settop_pb , XmNactivateCallback ,
3556                     AFNI_pbar_CB , im3d ) ;
3557      MCW_register_hint( func->pbar_settop_pb , "Is scaled by 'range' controls" ) ;
3558      /*** XtSetSensitive( func->pbar_settop_pb , !PBAR_FULLRANGE ) ; ***/
3559    } else {
3560      func->pbar_settop_pb = NULL ; /* 16 Nov 2018 */
3561    }
3562 
3563    /*---*/
3564 
3565    func->pbar_flip_pb =
3566       XtVaCreateManagedWidget(
3567          "dialog" , xmPushButtonWidgetClass , func->pbar_menu ,
3568             LABEL_ARG("Flip Colors") ,
3569             XmNmarginHeight , 0 ,
3570             XmNtraversalOn , True  ,
3571             XmNinitialResourcesPersistent , False ,
3572          NULL ) ;
3573    XtAddCallback( func->pbar_flip_pb , XmNactivateCallback ,
3574                   AFNI_pbar_CB , im3d ) ;
3575    MCW_register_hint( func->pbar_flip_pb , "Top-to-Bottom color inversion" ) ;
3576 
3577    (void) XtVaCreateManagedWidget(
3578             "dialog" , xmSeparatorWidgetClass , func->pbar_menu ,
3579              XmNseparatorType , XmSINGLE_LINE , NULL ) ;
3580 
3581    /*---*/
3582 
3583    func->pbar_jumpto_thmax_pb =
3584       XtVaCreateManagedWidget(
3585          "dialog" , xmPushButtonWidgetClass , func->pbar_menu ,
3586             LABEL_ARG("Jumpto OLay Max @Thr") ,
3587             XmNmarginHeight , 0 ,
3588             XmNtraversalOn , True  ,
3589             XmNinitialResourcesPersistent , False ,
3590          NULL ) ;
3591    XtAddCallback( func->pbar_jumpto_thmax_pb , XmNactivateCallback ,
3592                   AFNI_jumpto_thminmax_CB , im3d ) ;
3593    MCW_register_hint( func->pbar_jumpto_thmax_pb , "Jumpto OLay thresholded maximum" ) ;
3594    XtSetSensitive( func->pbar_jumpto_thmax_pb , False ) ;
3595    MCW_set_widget_bg( func->pbar_jumpto_thmax_pb , "black" , 0 ) ;
3596 
3597    /*---*/
3598 
3599    func->pbar_jumpto_thmin_pb =
3600       XtVaCreateManagedWidget(
3601          "dialog" , xmPushButtonWidgetClass , func->pbar_menu ,
3602             LABEL_ARG("Jumpto OLay Min @Thr") ,
3603             XmNmarginHeight , 0 ,
3604             XmNtraversalOn , True  ,
3605             XmNinitialResourcesPersistent , False ,
3606          NULL ) ;
3607    XtAddCallback( func->pbar_jumpto_thmin_pb , XmNactivateCallback ,
3608                   AFNI_jumpto_thminmax_CB , im3d ) ;
3609    MCW_register_hint( func->pbar_jumpto_thmin_pb , "Jumpto OLay thresholded minimum" ) ;
3610    XtSetSensitive( func->pbar_jumpto_thmin_pb , False ) ;
3611    MCW_set_widget_bg( func->pbar_jumpto_thmin_pb , "black" , 0 ) ;
3612 
3613    (void) XtVaCreateManagedWidget(
3614             "dialog" , xmSeparatorWidgetClass , func->pbar_menu ,
3615              XmNseparatorType , XmSINGLE_LINE , NULL ) ;
3616 
3617    /* 15 Jun 2000: image save button */
3618 
3619    func->pbar_saveim_pb =
3620       XtVaCreateManagedWidget(
3621          "dialog" , xmPushButtonWidgetClass , func->pbar_menu ,
3622             LABEL_ARG("Save pbar to image") ,
3623             XmNmarginHeight , 0 ,
3624             XmNtraversalOn , True  ,
3625             XmNinitialResourcesPersistent , False ,
3626          NULL ) ;
3627 
3628    MCW_register_hint( func->pbar_saveim_pb ,
3629                       "Write color bar out as image file" );
3630 
3631    XtAddCallback( func->pbar_saveim_pb , XmNactivateCallback ,
3632                   AFNI_pbar_CB , im3d ) ;
3633 
3634    /*---*/
3635 
3636    func->pbar_readin_pb =
3637       XtVaCreateManagedWidget(
3638          "dialog" , xmPushButtonWidgetClass , func->pbar_menu ,
3639             LABEL_ARG("Read in palette") ,
3640             XmNmarginHeight , 0 ,
3641             XmNtraversalOn , True  ,
3642             XmNinitialResourcesPersistent , False ,
3643          NULL ) ;
3644 
3645    MCW_register_hint( func->pbar_readin_pb , "Read in a palette file" ) ;
3646 
3647    XtAddCallback( func->pbar_readin_pb , XmNactivateCallback ,
3648                   AFNI_pbar_CB , im3d ) ;
3649 
3650    /*---*/
3651 
3652    func->pbar_writeout_pb =
3653       XtVaCreateManagedWidget(
3654          "dialog" , xmPushButtonWidgetClass , func->pbar_menu ,
3655             LABEL_ARG("Write out palette") ,
3656             XmNmarginHeight , 0 ,
3657             XmNtraversalOn , True  ,
3658             XmNinitialResourcesPersistent , False ,
3659          NULL ) ;
3660 
3661    MCW_register_hint( func->pbar_writeout_pb ,
3662                       "Write out a palette file" ) ;
3663 
3664    XtAddCallback( func->pbar_writeout_pb , XmNactivateCallback ,
3665                   AFNI_pbar_CB , im3d ) ;
3666 
3667    /* Show table button */
3668 
3669    func->pbar_showtable_pb =
3670       XtVaCreateManagedWidget(
3671          "dialog" , xmPushButtonWidgetClass , func->pbar_menu ,
3672             LABEL_ARG("Show Palette Table") ,
3673             XmNmarginHeight , 0 ,
3674             XmNtraversalOn , True  ,
3675             XmNinitialResourcesPersistent , False ,
3676          NULL ) ;
3677 
3678    XtAddCallback( func->pbar_showtable_pb , XmNactivateCallback ,
3679                   AFNI_pbar_CB , im3d ) ;
3680 
3681    MCW_register_hint( func->pbar_showtable_pb , "Will popup a listing window" ) ;
3682 
3683    (void) XtVaCreateManagedWidget(
3684             "dialog" , xmSeparatorWidgetClass , func->pbar_menu ,
3685              XmNseparatorType , XmSINGLE_LINE , NULL ) ;
3686 
3687    func->pbar_palette_av = new_MCW_arrowval(
3688                              func->pbar_menu ,     /* parent Widget */
3689                              "Set Pal " ,          /* label */
3690                              MCW_AV_optmenu ,      /* option menu style */
3691                              0 ,                   /* first option */
3692                              1 ,                   /* last option */
3693                              0 ,                   /* initial selection */
3694                              MCW_AV_readtext ,     /* ignored but needed */
3695                              0 ,                   /* ditto */
3696                              AFNI_palette_av_CB ,  /* callback when changed */
3697                              (XtPointer)im3d ,     /* data for above */
3698                              MCW_av_substring_CB , /* text creation routine */
3699                              AFNI_dummy_av_label   /* data for above */
3700                            ) ;
3701 
3702    MCW_reghint_children( func->pbar_palette_av->wrowcol , "Choose a palette" ) ;
3703 
3704    if( GPT != NULL && PALTAB_NUM(GPT) > 0 ){
3705       refit_MCW_optmenu( func->pbar_palette_av ,
3706                            0 ,                     /* new minval */
3707                            PALTAB_NUM(GPT)-1 ,     /* new maxval */
3708                            0 ,                     /* new inival */
3709                            0 ,                     /* new decim? */
3710                            AFNI_palette_label_CB , /* text routine */
3711                            NULL                    /* text data */
3712                         ) ;
3713    } else {
3714       XtUnmanageChild( func->pbar_palette_av->wrowcol ) ;
3715    }
3716 
3717    /*-- 15 Jun 2000: 0D func list --*/
3718 
3719    (void) XtVaCreateManagedWidget(
3720             "dialog" , xmSeparatorWidgetClass , func->pbar_menu ,
3721              XmNseparatorType , XmSINGLE_LINE , NULL ) ;
3722 
3723    func->pbar_transform0D_av = new_MCW_arrowval(
3724                              func->pbar_menu ,     /* parent Widget */
3725                              "Tran 0D " ,          /* label */
3726                              MCW_AV_optmenu ,      /* option menu style */
3727                              0 ,                   /* first option */
3728                              1 ,                   /* last option */
3729                              0 ,                   /* initial selection */
3730                              MCW_AV_readtext ,     /* ignored but needed */
3731                              0 ,                   /* ditto */
3732                              AFNI_palette_tran_CB, /* callback when changed */
3733                              (XtPointer)im3d ,     /* data for above */
3734                              MCW_av_substring_CB , /* text creation routine */
3735                              AFNI_dummy_av_label   /* data for above */
3736                            ) ;
3737 
3738    MCW_reghint_children( func->pbar_transform0D_av->wrowcol ,
3739                          "Transform overlay image values" ) ;
3740    XtUnmanageChild( func->pbar_transform0D_av->wrowcol ) ;
3741    func->pbar_transform0D_index = 0 ;
3742    func->pbar_transform0D_func  = NULL ;
3743 
3744    /*-- 16 Jun 2000: 2D func list --*/
3745 
3746    (void) XtVaCreateManagedWidget(
3747             "dialog" , xmSeparatorWidgetClass , func->pbar_menu ,
3748              XmNseparatorType , XmSINGLE_LINE , NULL ) ;
3749 
3750    func->pbar_transform2D_av = new_MCW_arrowval(
3751                              func->pbar_menu ,     /* parent Widget */
3752                              "Tran 2D " ,          /* label */
3753                              MCW_AV_optmenu ,      /* option menu style */
3754                              0 ,                   /* first option */
3755                              1 ,                   /* last option */
3756                              0 ,                   /* initial selection */
3757                              MCW_AV_readtext ,     /* ignored but needed */
3758                              0 ,                   /* ditto */
3759                              AFNI_palette_tran_CB, /* callback when changed */
3760                              (XtPointer)im3d ,     /* data for above */
3761                              MCW_av_substring_CB , /* text creation routine */
3762                              AFNI_dummy_av_label   /* data for above */
3763                            ) ;
3764 
3765    MCW_reghint_children( func->pbar_transform2D_av->wrowcol ,
3766                          "Transform overlay image values" ) ;
3767    XtUnmanageChild( func->pbar_transform2D_av->wrowcol ) ;
3768    func->pbar_transform2D_index = 0 ;
3769    func->pbar_transform2D_func  = NULL ;
3770 
3771 #if 0
3772    allow_MCW_optmenu_popup(1) ;  /* 12 Dec 2001 */
3773 #endif
3774 
3775    /**-- Color pbar to control intensity-to-color mapping --**/
3776 
3777    { float pmin , pmax ;  /* posfunc added 3/21/95 */
3778 
3779      pmax  = 1.0 ;
3780      pmin  = (im3d->vinfo->use_posfunc) ? (0.0) : (-1.0) ;
3781      npane = (im3d->vinfo->use_posfunc) ? INIT_panes_pos
3782                                         : INIT_panes_sgn ;
3783 
3784      func->inten_pbar = new_MCW_pbar(
3785                           func->inten_rowcol ,        /* parent */
3786                           im3d->dc ,                  /* display */
3787                           npane ,                     /* number panes */
3788                           sel_height / npane ,        /* init pane height */
3789                           pmin , pmax ,               /* value range */
3790                           AFNI_inten_pbar_CB ,        /* callback */
3791                           (XtPointer)im3d ,           /* callback data */
3792                           AFNI_yesenv("AFNI_PBAR_THREE") ) ; /* bigthree mode? */
3793 
3794      /* 04 Feb 2002: colorscale-ize? */
3795 
3796      if( im3d->dc->visual_class == TrueColor ){
3797        char *eee = getenv("AFNI_COLORSCALE_DEFAULT") ;
3798        if( eee == NULL ) eee = getenv("AFNI_COLOR_SCALE_DEFAULT") ;
3799        if( eee == NULL || strcmp(eee,"NO") != 0 ){
3800          PBAR_set_bigmode( func->inten_pbar , 1 , pmin,pmax ) ;
3801          PBAR_set_bigmap( func->inten_pbar , eee , 0) ;
3802          im3d->cont_pbar_index = func->inten_pbar->bigmap_index;
3803          im3d->int_pbar_index = PBAR_get_bigmap_index("ROI_i256");
3804        }
3805      }
3806    }
3807 
3808    func->inten_pbar->parent       = (XtPointer)im3d ;
3809    func->inten_pbar->mode         = (im3d->vinfo->use_posfunc) ? (1) : (0) ;
3810    func->inten_pbar->npan_save[0] = INIT_panes_sgn ;
3811    func->inten_pbar->npan_save[1] = INIT_panes_pos ;
3812    func->inten_pbar->hide_changes = INIT_panes_hide ;
3813 
3814    AFNI_setup_inten_pbar( func->inten_pbar ) ;  /* other setup stuff (afni_func.c) */
3815 
3816    MCW_reghelp_children( func->inten_pbar->panew ,
3817       "Drag the separator bars to alter the thresholds.\n"
3818       "Click in a pane to alter the color for that range.\n\n"
3819       "The overlay dataset value that maps to 1.0 is\n"
3820       "determined by the 'autoRange' controls to the right.\n"
3821       "\n"
3822       "In 'continuous' colorscale mode, Button-1 click flips\n"
3823       "colors top-to-bottom;  Button-3 click shows a menu of\n"
3824       "available colorscales.\n"
3825    ) ;
3826 
3827    MCW_reghelp_children( func->inten_pbar->top ,
3828       "Drag the separator bars to alter the thresholds.\n"
3829       "Click in a pane to alter the color for that range.\n\n"
3830       "The overlay dataset value that maps to 1.0 is\n"
3831       "determined by the 'autoRange' controls to the right.\n"
3832       "\n"
3833       "In 'continuous' colorscale mode, Button-1 click flips\n"
3834       "colors top-to-bottom;  Button-3 click shows a menu of\n"
3835       "available colorscales.\n"
3836    ) ;
3837 
3838    MCW_register_help( func->inten_label ,
3839       "Drag the separator bars to alter the thresholds.\n"
3840       "Click in a pane to alter the color for that range.\n\n"
3841       "The overlay dataset value that maps to 1.0 is\n"
3842       "determined by the 'autoRange' controls to the right.\n\n"
3843       "N.B.: A popup menu to control the palette\n"
3844       "      setup is 'hidden' under this label."
3845    ) ;
3846 
3847    MCW_register_hint( func->inten_label ,
3848                       "Control overlay colors" ) ;
3849    qsep = XtVaCreateManagedWidget(
3850             "dialog" , xmSeparatorWidgetClass , func->inten_rowcol ,
3851               XmNseparatorType , XmSINGLE_LINE ,
3852             NULL ) ;
3853 
3854    BBOX_set_wsubtype("font8") ;
3855    func->inten_av = new_MCW_arrowval(
3856                        func->inten_rowcol ,
3857                         "#" ,
3858                         AVOPT_STYLE ,
3859                         NPANE_MIN , NPANE_MAX+1 ,
3860                         (func->inten_pbar->bigmode) ? NPANE_MAX+1 : npane ,
3861                         MCW_AV_notext , 0 ,
3862                         AFNI_inten_av_CB , func->inten_pbar ,
3863                         AFNI_inten_av_texter,NULL ) ;
3864 
3865    if( AVOPT_STYLE == MCW_AV_optmenu )
3866       AVOPT_columnize( func->inten_av , 2 ) ;
3867 
3868    func->inten_av->fastdelay  = 4000 ;  /* slow down repeat action */
3869    func->inten_av->parent     = im3d ;  /* Daddy! */
3870    func->inten_av->allow_wrap = 1 ;
3871 
3872    MCW_reghelp_children( func->inten_av->wrowcol ,
3873      "Controls the number of panes\n"
3874      "in the intensity color/threshold\n"
3875      "selector above (the 'pbar')"
3876    ) ;
3877    MCW_reghint_children( func->inten_av->wrowcol ,
3878                          "Number of color panes" ) ;
3879 
3880    /*--- toggle button to control posfunc option for pbar ---*/
3881 
3882    func->inten_bbox =
3883       new_MCW_bbox( func->inten_rowcol ,
3884                     1 , AFNI_inten_bbox_label ,
3885                     MCW_BB_check ,
3886                     MCW_BB_noframe ,
3887                     AFNI_inten_bbox_CB , (XtPointer)im3d ) ;
3888 
3889    BBOX_set_wsubtype(NULL) ;
3890 
3891    func->inten_bbox->parent = (XtPointer)im3d ;
3892 
3893    MCW_set_bbox( func->inten_bbox ,
3894                  (im3d->vinfo->use_posfunc) ? (1) : (0) ) ;
3895 
3896    MCW_reghelp_children( func->inten_bbox->wrowcol ,
3897                          "Pressed In: Displays only positive overlay\n"
3898                          "            values in the 'pbar' above and\n"
3899                          "            in the color overlays.\n"
3900                          "       Out: Displays positive and negative\n"
3901                          "            overlay values.\n\n"
3902                          "N.B.: Zero overlay values are never overlaid." ) ;
3903    MCW_reghint_children( func->inten_bbox->wrowcol ,
3904                          "Use positive-only or signed overlay values" ) ;
3905 
3906    ADDTO_KILL(im3d->kl,func->inten_bbox) ;
3907 
3908    /*-- options controls --*/
3909 
3910    func->options_rowcol =
3911       XtVaCreateWidget(
3912          "dialog" , xmRowColumnWidgetClass , func->rowcol ,
3913             XmNorientation , XmVERTICAL ,
3914             XmNpacking , XmPACK_TIGHT ,
3915             XmNmarginHeight, 0 ,
3916             XmNmarginWidth , 0 ,
3917             XmNtraversalOn , True  ,
3918             XmNinitialResourcesPersistent , False ,
3919          NULL ) ;
3920 
3921    func->options_top_rowcol =
3922       XtVaCreateWidget(
3923          "dialog" , xmRowColumnWidgetClass , func->options_rowcol ,
3924             XmNorientation , XmHORIZONTAL ,
3925             XmNpacking , XmPACK_TIGHT ,
3926             XmNmarginHeight, 0 ,
3927             XmNmarginWidth , 0 ,
3928             XmNspacing     , 5 ,
3929             XmNtraversalOn , True  ,
3930             XmNinitialResourcesPersistent , False ,
3931          NULL ) ;
3932 
3933    func->options_label =
3934       XtVaCreateManagedWidget(
3935          "dialog" , xmLabelWidgetClass , func->options_top_rowcol ,
3936             LABEL_ARG("Edit OLay  ") ,
3937             XmNinitialResourcesPersistent , False ,
3938          NULL ) ;
3939    LABELIZE(func->options_label) ;
3940 
3941    XtInsertEventHandler( func->options_label ,      /* handle events in label */
3942                                0
3943                              | ButtonPressMask   /* button presses */
3944                             ,
3945                             FALSE ,              /* nonmaskable events? */
3946                             AFNI_pbar_EV ,       /* handler */
3947                             (XtPointer)im3d ,    /* client data */
3948                             XtListTail           /* last in queue */
3949                           ) ;
3950 
3951 #define VEDIT_COLOR_A "#000066"
3952 #define VEDIT_COLOR_B "#004466"
3953 #define VEDIT_NOPT    (VEDIT_LAST_VALUE+1)
3954    { static char *options_vedit_label[] =
3955        { "InstaCorr" , "InstaCalc" , "3dTstat" , "GrpInCorr" } ;
3956      int nopt = (num_entry==1) ? VEDIT_NOPT : VEDIT_NOPT-1 ;  /* no GrpInCorr after [A] */
3957      int ibut ;
3958      func->options_vedit_av = new_MCW_arrowval(
3959                                func->options_top_rowcol , /* parent Widget */
3960                                NULL ,                     /* label */
3961                                MCW_AV_optmenu ,           /* option menu style */
3962                                0 ,                        /* first option */
3963                                nopt - 1 ,                 /* last option */
3964                                0 ,                        /* initial selection */
3965                                MCW_AV_readtext ,          /* ignored but needed */
3966                                0 ,                        /* ditto */
3967                                AFNI_vedit_CB  ,           /* callback when changed */
3968                                (XtPointer)im3d ,          /* data for above */
3969                                MCW_av_substring_CB ,      /* text creation routine */
3970                                options_vedit_label        /* data for above */
3971                              ) ;
3972      for( ibut=0 ; ibut < nopt ; ibut++ )
3973        colorize_MCW_optmenu( func->options_vedit_av ,
3974                              (ibut%2==0) ? VEDIT_COLOR_A : VEDIT_COLOR_B  , ibut ) ;
3975    }
3976    func->options_vedit_av->parent = (XtPointer)im3d ;
3977    MCW_reghelp_children( func->options_vedit_av->wrowcol ,
3978                          "Choose which set of controls\n"
3979                          "for on-the-fly functional\n"
3980                          "overlay editing are visible\n"
3981                          "directly below this menu."     ) ;
3982    MCW_reghint_children( func->options_vedit_av->wrowcol ,
3983                          "On-the-fly overlay editing control choice") ;
3984    ADDTO_KILL(im3d->kl,func->options_vedit_av) ;
3985 
3986    XtManageChild( func->options_top_rowcol ) ;
3987 
3988    func->cwid = NULL;
3989    func->clu_rep = NULL; func->clu_list = NULL; func->clu_index = -1;
3990    func->clu_det = NULL; func->clu_num  = 0 ;
3991 
3992    func->clu_tabNN1_1sid = func->clu_tabNN2_1sid = func->clu_tabNN3_1sid = NULL; /* Jan 2015 */
3993    func->clu_tabNN1_2sid = func->clu_tabNN2_2sid = func->clu_tabNN3_2sid = NULL;
3994    func->clu_tabNN1_bsid = func->clu_tabNN2_bsid = func->clu_tabNN3_bsid = NULL;
3995    func->clu_mask = NULL ;
3996 
3997    func->iwid = NULL ;    /* 17 Sep 2009 */
3998 
3999    /*-- 26 Mar 2007: rowcol for clustering stuff --*/
4000 
4001    func->ulaclu_rowcol =
4002       XtVaCreateWidget(
4003          "dialog" , xmRowColumnWidgetClass , func->options_rowcol ,
4004             XmNorientation , XmHORIZONTAL ,
4005             XmNpacking , XmPACK_TIGHT ,
4006             XmNmarginHeight, 0 ,
4007             XmNmarginWidth , 0 ,
4008             XmNspacing     , 5 ,
4009             XmNtraversalOn , True  ,
4010             XmNinitialResourcesPersistent , False ,
4011          NULL ) ;
4012 
4013    /*--- underlay type [now available only via 'u' keypress: 18 Jun 2014] ---*/
4014 
4015 #ifdef USE_UNDERLAY_BBOX  /* don't reactivate this code without deep thought */
4016    func->underlay_bbox =
4017       new_MCW_bbox( func->ulaclu_rowcol ,
4018                     LAST_UNDERLAY_TYPE+1 , UNDERLAY_typestr ,
4019                     MCW_BB_radio_one ,
4020                     MCW_BB_frame ,
4021                     AFNI_underlay_CB , (XtPointer)im3d ) ;
4022    func->underlay_bbox->parent = (XtPointer)im3d ;
4023    MCW_set_bbox( func->underlay_bbox , 1 << im3d->vinfo->underlay_type ) ;
4024    MCW_reghelp_children( func->underlay_bbox->wrowcol ,
4025       "Use these buttons to choose\n"
4026       "whether the underlay or\n"
4027       "overlay images appear\n"
4028       "as the background display" ) ;
4029    ADDTO_KILL(im3d->kl,func->underlay_bbox) ;
4030 
4031    { static char *hh[] = { "Use underlay dataset for background" ,
4032                            "Use overlay dataset for background" ,
4033                            "Use thresholded overlay dataset for background" } ;
4034      MCW_bbox_hints( func->underlay_bbox , 3 , hh ) ;
4035    }
4036 #else
4037    func->underlay_bbox = NULL ;
4038 #endif
4039 
4040    /*--- 18 Jun 2014: Clusterize separated to be where underlay_bbox used to live ---*/
4041 
4042    func->clu_rowcol =
4043       XtVaCreateManagedWidget(
4044          "dialog" , xmRowColumnWidgetClass , func->ulaclu_rowcol ,
4045             XmNorientation , XmVERTICAL ,
4046             XmNpacking , XmPACK_TIGHT ,
4047             XmNmarginHeight, 0 ,
4048             XmNmarginWidth , 0 ,
4049             XmNspacing     , 0 ,
4050             XmNtraversalOn , True  ,
4051             XmNinitialResourcesPersistent , False ,
4052          NULL ) ;
4053    im3d->vedset.code = 0 ; im3d->vedset.ival = -1 ;
4054    im3d->vedskip     = 0 ; /* 20 Dec 2007 */
4055    im3d->vednomask   = 0 ; /* 01 Aug 2011 */
4056 
4057    /*---*/
4058 
4059    func->clu_cluster_pb =
4060       XtVaCreateManagedWidget(
4061          "dialog" , xmPushButtonWidgetClass , func->clu_rowcol ,
4062             LABEL_ARG("Clusterize ") ,
4063             XmNmarginHeight, 0 ,
4064             XmNtraversalOn , True  ,
4065             XmNinitialResourcesPersistent , False ,
4066          NULL ) ;
4067    MCW_set_widget_bg( func->clu_cluster_pb , VEDIT_COLOR_A , 0 ) ;
4068    XtAddCallback( func->clu_cluster_pb , XmNactivateCallback ,
4069                   AFNI_clu_CB , im3d ) ;
4070    MCW_register_hint( func->clu_cluster_pb , "Set clustering parameters" ) ;
4071    MCW_register_help( func->clu_cluster_pb ,
4072                         "Cluster editing parameters:\n"
4073                         "NN level = how to decide if two above-threshold\n"
4074                         "           voxels are neighbors to be put in\n"
4075                         "           the same cluster\n"
4076                         "Voxels   = minimum cluster size to be shown\n"
4077                         "           in the Rpt table\n\n"
4078                         "** Clustering is done at the overlay dataset\n"
4079                         "    voxel resolution, NOT at the underlay\n"
4080                         "    dataset's resolution.\n\n"
4081                         "** Clustering cannot be done if the overlay\n"
4082                         "    dataset does not have a stored volume\n"
4083                         "    (e.g., is 'warp-on-demand' only)."
4084                      ) ;
4085 
4086    im3d->vinfo->clusterize_nnlev = 2 ;  /* 02 Nov 2018 */
4087    im3d->vinfo->clusterize_size  = 40 ; /* defaults for Clusterize */
4088    im3d->vinfo->clusterize_bisid = 1 ;
4089 
4090    hrc = XtVaCreateWidget(
4091          "dialog" , xmRowColumnWidgetClass , func->clu_rowcol ,
4092             XmNorientation , XmHORIZONTAL ,
4093             XmNpacking , XmPACK_TIGHT ,
4094             XmNmarginHeight, 0 ,
4095             XmNmarginWidth , 0 ,
4096             XmNspacing     , 0 ,
4097             XmNtraversalOn , True  ,
4098             XmNinitialResourcesPersistent , False ,
4099          NULL ) ;
4100 
4101    /*---*/
4102 
4103    func->clu_clear_pb =
4104       XtVaCreateManagedWidget(
4105          "dialog" , xmPushButtonWidgetClass , hrc ,
4106             LABEL_ARG("*Clear") ,
4107             XmNmarginHeight, 0 ,
4108             XmNtraversalOn , True  ,
4109             XmNinitialResourcesPersistent , False ,
4110          NULL ) ;
4111    XtAddCallback( func->clu_clear_pb , XmNactivateCallback ,
4112                   AFNI_clu_CB , im3d ) ;
4113    MCW_register_hint( func->clu_clear_pb , "Turn off Cluster Edit" ) ;
4114    MCW_register_help( func->clu_clear_pb , "Disable on-the-fly\n"
4115                                            "clustering of the\n"
4116                                            "thresholded overlay\n"
4117                                            "volume." ) ;
4118    /*---*/
4119 
4120    func->clu_report_pb =
4121       XtVaCreateManagedWidget(
4122          "dialog" , xmPushButtonWidgetClass , hrc ,
4123             LABEL_ARG("Rpt") ,
4124             XmNmarginHeight, 0 ,
4125             XmNtraversalOn , True  ,
4126             XmNinitialResourcesPersistent , False ,
4127          NULL ) ;
4128    XtAddCallback( func->clu_report_pb , XmNactivateCallback ,
4129                   AFNI_clu_CB , im3d ) ;
4130    MCW_register_hint( func->clu_report_pb , "Open cluster report window" ) ;
4131    XtManageChild( hrc ) ;
4132 
4133    /*--- 26 Mar 2007: other Insta stuff moved here [18 Jun 2014: clustering moved above] ---*/
4134 
4135    func->vedit_frame = XtVaCreateManagedWidget(
4136            "dialog" , xmFrameWidgetClass , func->ulaclu_rowcol ,
4137               XmNshadowType , XmSHADOW_ETCHED_IN ,
4138               XmNshadowThickness , 2 ,
4139               XmNinitialResourcesPersistent , False ,
4140            NULL ) ;
4141 
4142    /*--- 05 May 2009: InstaCorr stuff ---*/
4143 
4144    func->icor_rowcol =
4145       XtVaCreateManagedWidget(
4146          "dialog" , xmRowColumnWidgetClass , func->vedit_frame ,
4147             XmNorientation , XmVERTICAL ,
4148             XmNpacking , XmPACK_TIGHT ,
4149             XmNmarginHeight, 0 ,
4150             XmNmarginWidth , 0 ,
4151             XmNspacing     , 0 ,
4152             XmNtraversalOn , True  ,
4153             XmNinitialResourcesPersistent , False ,
4154          NULL ) ;
4155 
4156    /*---*/
4157 
4158    func->icor_pb =
4159          XtVaCreateManagedWidget(
4160             "dialog" , xmPushButtonWidgetClass , func->icor_rowcol ,
4161                LABEL_ARG("Setup ICorr") ,
4162                XmNmarginHeight , 0 ,
4163                XmNtraversalOn , True  ,
4164                XmNinitialResourcesPersistent , False ,
4165             NULL ) ;
4166    MCW_set_widget_bg( func->icor_pb , VEDIT_COLOR_B , 0 ) ;
4167    XtAddCallback( func->icor_pb , XmNactivateCallback , AFNI_misc_CB , im3d ) ;
4168    MCW_register_hint( func->icor_pb , "Control InstaCorr calculations" ) ;
4169 
4170    xstr = XmStringCreateLtoR( "*NOT Ready* " , XmFONTLIST_DEFAULT_TAG ) ;
4171    func->icor_label =
4172       XtVaCreateManagedWidget(
4173          "dialog" , xmLabelWidgetClass , func->icor_rowcol ,
4174             XmNrecomputeSize , False ,
4175             XmNlabelString , xstr ,
4176             XmNalignment , XmALIGNMENT_CENTER ,
4177             XmNtraversalOn , True  ,
4178             XmNinitialResourcesPersistent , False ,
4179          NULL ) ;
4180    XmStringFree(xstr) ;
4181    MCW_set_widget_bg(func->icor_label,STOP_COLOR,0) ;
4182 
4183    im3d->iset = NULL ;
4184 
4185    /*--- 18 Sep 2009: InstaCalc stuff ---*/
4186 
4187    func->icalc_rowcol =
4188       XtVaCreateWidget(
4189          "dialog" , xmRowColumnWidgetClass , func->vedit_frame ,
4190             XmNorientation , XmVERTICAL ,
4191             XmNpacking , XmPACK_TIGHT ,
4192             XmNmarginHeight, 0 ,
4193             XmNmarginWidth , 0 ,
4194             XmNspacing     , 0 ,
4195             XmNtraversalOn , True  ,
4196             XmNinitialResourcesPersistent , False ,
4197          NULL ) ;
4198 
4199    /*---*/
4200 
4201    func->icalc_pb =
4202          XtVaCreateManagedWidget(
4203             "dialog" , xmPushButtonWidgetClass , func->icalc_rowcol ,
4204                LABEL_ARG("Setup ICalc") ,
4205                XmNmarginHeight , 0 ,
4206                XmNtraversalOn , True  ,
4207                XmNinitialResourcesPersistent , False ,
4208             NULL ) ;
4209    MCW_set_widget_bg( func->icalc_pb , VEDIT_COLOR_A , 0 ) ;
4210    XtAddCallback( func->icalc_pb , XmNactivateCallback , AFNI_misc_CB , im3d ) ;
4211    MCW_register_hint( func->icalc_pb , "Control InstaCalc calculations" ) ;
4212 
4213    xstr = XmStringCreateLtoR( "*NOT Ready* " , XmFONTLIST_DEFAULT_TAG ) ;
4214    func->icalc_label =
4215       XtVaCreateManagedWidget(
4216          "dialog" , xmLabelWidgetClass , func->icalc_rowcol ,
4217             XmNrecomputeSize , False ,
4218             XmNlabelString , xstr ,
4219             XmNalignment , XmALIGNMENT_CENTER ,
4220             XmNtraversalOn , True  ,
4221             XmNinitialResourcesPersistent , False ,
4222          NULL ) ;
4223    XmStringFree(xstr) ;
4224    MCW_set_widget_bg(func->icalc_label,STOP_COLOR,0) ;
4225 
4226    im3d->icalc_setup = NULL ;
4227 
4228    /*--- 22 Mar 2018: Tstat stuff ---*/
4229 
4230    func->tstat_rowcol =
4231       XtVaCreateWidget(
4232          "dialog" , xmRowColumnWidgetClass , func->vedit_frame ,
4233             XmNorientation , XmVERTICAL ,
4234             XmNpacking , XmPACK_TIGHT ,
4235             XmNmarginHeight, 0 ,
4236             XmNmarginWidth , 0 ,
4237             XmNspacing     , 0 ,
4238             XmNtraversalOn , True  ,
4239             XmNinitialResourcesPersistent , False ,
4240          NULL ) ;
4241 
4242    /*---*/
4243 
4244    func->tstat_pb =
4245          XtVaCreateManagedWidget(
4246             "dialog" , xmPushButtonWidgetClass , func->tstat_rowcol ,
4247                LABEL_ARG("Setup Tstat") ,
4248                XmNmarginHeight , 0 ,
4249                XmNtraversalOn , True  ,
4250                XmNinitialResourcesPersistent , False ,
4251             NULL ) ;
4252    MCW_set_widget_bg( func->tstat_pb , VEDIT_COLOR_B , 0 ) ;
4253    XtAddCallback( func->tstat_pb , XmNactivateCallback , AFNI_misc_CB , im3d ) ;
4254    MCW_register_hint( func->tstat_pb , "Control Tstat calculations" ) ;
4255 
4256    xstr = XmStringCreateLtoR( "*NOT Ready* " , XmFONTLIST_DEFAULT_TAG ) ;
4257    func->tstat_label =
4258       XtVaCreateManagedWidget(
4259          "dialog" , xmLabelWidgetClass , func->tstat_rowcol ,
4260             XmNrecomputeSize , False ,
4261             XmNlabelString , xstr ,
4262             XmNalignment , XmALIGNMENT_CENTER ,
4263             XmNtraversalOn , True  ,
4264             XmNinitialResourcesPersistent , False ,
4265          NULL ) ;
4266    XmStringFree(xstr) ;
4267    MCW_set_widget_bg(func->tstat_label,STOP_COLOR,0) ;
4268 
4269 
4270    /*--- 22 Dec 2009: Group InstaCorr stuff ---*/
4271 
4272    if( num_entry == 1 ){  /* only in controller A */
4273 
4274      func->gicor_rowcol =
4275         XtVaCreateWidget(
4276            "dialog" , xmRowColumnWidgetClass , func->vedit_frame ,
4277               XmNorientation , XmVERTICAL ,
4278               XmNpacking , XmPACK_TIGHT ,
4279               XmNmarginHeight, 0 ,
4280               XmNmarginWidth , 0 ,
4281               XmNspacing     , 0 ,
4282               XmNtraversalOn , True  ,
4283               XmNinitialResourcesPersistent , False ,
4284            NULL ) ;
4285 
4286    /*---*/
4287 
4288      func->gicor_pb =
4289            XtVaCreateManagedWidget(
4290               "dialog" , xmPushButtonWidgetClass , func->gicor_rowcol ,
4291                  LABEL_ARG("Setup GICor") ,
4292                  XmNmarginHeight , 0 ,
4293                  XmNtraversalOn , True  ,
4294                  XmNinitialResourcesPersistent , False ,
4295               NULL ) ;
4296      MCW_set_widget_bg( func->gicor_pb , VEDIT_COLOR_A , 0 ) ;
4297      XtAddCallback( func->gicor_pb , XmNactivateCallback , AFNI_misc_CB , im3d ) ;
4298      MCW_register_hint( func->gicor_pb , "Control 3dGroupInCorr calculations" ) ;
4299 
4300      xstr = XmStringCreateLtoR( "*NOT Ready* " , XmFONTLIST_DEFAULT_TAG ) ;
4301      func->gicor_label =
4302         XtVaCreateManagedWidget(
4303            "dialog" , xmLabelWidgetClass , func->gicor_rowcol ,
4304               XmNrecomputeSize , False ,
4305               XmNlabelString , xstr ,
4306               XmNalignment , XmALIGNMENT_CENTER ,
4307               XmNtraversalOn , True  ,
4308               XmNinitialResourcesPersistent , False ,
4309            NULL ) ;
4310      XmStringFree(xstr) ;
4311      MCW_set_widget_bg(func->gicor_label,STOP_COLOR,0) ;
4312      MCW_register_hint(func->gicor_label,"Will be ** Ready ** when 3dGroupInCorr is running");
4313 
4314    } else {
4315 
4316      func->gicor_rowcol = func->gicor_pb = func->gicor_label = NULL ;
4317 
4318    }
4319 
4320    im3d->giset = NULL ;
4321 
4322    /*--- 30 Nov 1997: bucket managers ---*/
4323 
4324    func->buck_frame =
4325       XtVaCreateWidget(
4326          "dialog" , xmFrameWidgetClass , func->options_rowcol ,
4327             XmNshadowType , XmSHADOW_ETCHED_IN ,
4328             XmNshadowThickness , 2 ,
4329             XmNtraversalOn , True  ,
4330             XmNinitialResourcesPersistent , False ,
4331          NULL ) ;
4332 
4333    func->buck_rowcol =
4334       XtVaCreateWidget(
4335          "dialog" , xmRowColumnWidgetClass , func->buck_frame ,
4336             XmNorientation , XmVERTICAL ,
4337             XmNpacking , XmPACK_TIGHT ,
4338             XmNtraversalOn , True  ,
4339             XmNinitialResourcesPersistent , False ,
4340          NULL ) ;
4341 
4342    /*--- 30 Nov 1997: anatomy bucket arrowval ---*/
4343    /*    (Actual labels are set when used)       */
4344 
4345    func->anat_buck_av = new_MCW_arrowval(
4346                           func->buck_rowcol    ,  /* parent Widget */
4347                           "ULay" ,                /* label */
4348                           MCW_AV_optmenu ,        /* option menu style */
4349                           0 ,                     /* first option */
4350                           1 ,                     /* last option */
4351                           0 ,                     /* initial selection */
4352                           MCW_AV_readtext ,       /* ignored but needed */
4353                           0 ,                     /* ditto */
4354                           AFNI_bucket_CB ,        /* callback when changed */
4355                           (XtPointer)im3d ,       /* data for above */
4356                           MCW_av_substring_CB ,   /* text creation routine */
4357                           AFNI_dummy_av_label     /* data for above */
4358                         ) ;
4359 
4360    func->anat_buck_av->parent     = (XtPointer)im3d ;
4361    func->anat_buck_av->allow_wrap = True ;
4362 
4363    MCW_reghelp_children( func->anat_buck_av->wrowcol ,
4364                          "Use this to choose which\n"
4365                          "sub-brick of the overlay\n"
4366                          "dataset to display (='ULay').\n"
4367                          "(The sub-brick labels are\n"
4368                          " assigned when the dataset\n"
4369                          " is created.  The [index]\n"
4370                          " values show the numerical\n"
4371                          " location of the sub-brick\n"
4372                          " in the dataset.)"           ) ;
4373    MCW_reghint_children( func->anat_buck_av->wrowcol ,
4374                          "Choose UnderLay sub-brick" ) ;
4375 
4376    ADDTO_KILL(im3d->kl,func->anat_buck_av) ;
4377 
4378    XtUnmanageChild( func->anat_buck_av->wrowcol ) ;
4379 
4380    /*--- 30 Nov 1997: function bucket arrowval ---*/
4381 
4382    func->fim_buck_av = new_MCW_arrowval(
4383                           func->buck_rowcol    ,  /* parent Widget */
4384                           "OLay" ,                /* label */
4385                           MCW_AV_optmenu ,        /* option menu style */
4386                           0 ,                     /* first option */
4387                           1 ,                     /* last option */
4388                           0 ,                     /* initial selection */
4389                           MCW_AV_readtext ,       /* ignored but needed */
4390                           0 ,                     /* ditto */
4391                           AFNI_bucket_CB ,        /* callback when changed */
4392                           (XtPointer)im3d ,       /* data for above */
4393                           MCW_av_substring_CB ,   /* text creation routine */
4394                           AFNI_dummy_av_label     /* data for above */
4395                         ) ;
4396 
4397    func->fim_buck_av->parent     = (XtPointer)im3d ;
4398    func->fim_buck_av->allow_wrap = True ;
4399 
4400    MCW_reghelp_children( func->fim_buck_av->wrowcol ,
4401                          "Use this to choose which\n"
4402                          "sub-brick of the overlay\n"
4403                          "dataset to display (='OLay').\n"
4404                          "(The sub-brick labels are\n"
4405                          " assigned when the dataset\n"
4406                          " is created.  The [index]\n"
4407                          " values show the numerical\n"
4408                          " location of the sub-brick\n"
4409                          " in the dataset.)"           ) ;
4410    MCW_reghint_children( func->fim_buck_av->wrowcol ,
4411                          "Choose overlay sub-brick" ) ;
4412 
4413    ADDTO_KILL(im3d->kl,func->fim_buck_av) ;
4414 
4415    XtUnmanageChild( func->fim_buck_av->wrowcol ) ;
4416 
4417    /*--- 30 Nov 1997: threshold bucket arrowval ---*/
4418 
4419    func->thr_buck_av = new_MCW_arrowval(
4420                           func->buck_rowcol    ,  /* parent Widget */
4421                           "Thr " ,                /* label */
4422                           MCW_AV_optmenu ,        /* option menu style */
4423                           0 ,                     /* first option */
4424                           1 ,                     /* last option */
4425                           0 ,                     /* initial selection */
4426                           MCW_AV_readtext ,       /* ignored but needed */
4427                           0 ,                     /* ditto */
4428                           AFNI_bucket_CB ,        /* callback when changed */
4429                           (XtPointer)im3d ,       /* data for above */
4430                           MCW_av_substring_CB ,   /* text creation routine */
4431                           AFNI_dummy_av_label     /* data for above */
4432                         ) ;
4433 
4434    func->thr_buck_av->parent     = (XtPointer)im3d ;
4435    func->thr_buck_av->allow_wrap = True ;
4436 
4437    MCW_reghelp_children( func->thr_buck_av->wrowcol ,
4438                          "Use this to choose which\n"
4439                          "sub-brick of the overlay\n"
4440                          "dataset with which to threshold\n"
4441                          "the OLay sub-brick (='Thr').\n"
4442                          "(The sub-brick labels are\n"
4443                          " assigned when the dataset\n"
4444                          " is created.  The [index]\n"
4445                          " values show the numerical\n"
4446                          " location of the sub-brick\n"
4447                          " in the dataset.)"           ) ;
4448    MCW_reghint_children( func->thr_buck_av->wrowcol ,
4449                          "Choose Thr sub-brick" ) ;
4450 
4451    ADDTO_KILL(im3d->kl,func->thr_buck_av) ;
4452 
4453    XtUnmanageChild( func->thr_buck_av->wrowcol ) ;
4454 
4455    /*--- range controls ---*/
4456 
4457    func->range_frame =
4458       XtVaCreateManagedWidget(
4459          "dialog" , xmFrameWidgetClass , func->options_rowcol ,
4460             XmNshadowType , XmSHADOW_ETCHED_IN ,
4461             XmNshadowThickness , 2 ,
4462             XmNtraversalOn , True  ,
4463             XmNinitialResourcesPersistent , False ,
4464          NULL ) ;
4465 
4466    func->range_rowcol =
4467       XtVaCreateWidget(
4468          "dialog" , xmRowColumnWidgetClass , func->range_frame ,
4469             XmNorientation , XmVERTICAL ,
4470             XmNpacking , XmPACK_TIGHT ,
4471             XmNtraversalOn , True  ,
4472             XmNinitialResourcesPersistent , False ,
4473          NULL ) ;
4474 
4475    /*--- label to show the ranges ---*/
4476 
4477    im3d->vinfo->old_range_label = xstr = AFNI_range_label( NULL ) ;
4478 
4479    func->range_label =
4480       XtVaCreateManagedWidget(
4481          "dialog" , xmLabelWidgetClass , func->range_rowcol ,
4482             XmNrecomputeSize , False ,
4483             XmNlabelString , xstr ,
4484             XmNtraversalOn , True  ,
4485             XmNinitialResourcesPersistent , False ,
4486          NULL ) ;
4487    LABELIZE(func->range_label) ;
4488    MCW_register_help( func->range_label ,
4489                         "These are the range of values in the\n"
4490                         "UnderLay and OverLay 3D datasets.\n"
4491                         "The overlay values may be useful\n"
4492                         "for choosing the Range for the pbar.\n"
4493                         "[If a dataset is warped from a\n"
4494                         " 'parent', these statistics are\n"
4495                         " taken from the parent dataset.]"   ) ;
4496 
4497    MCW_register_hint( func->range_label , "Ranges of dataset values" ) ;
4498 
4499    XtInsertEventHandler( func->range_label ,      /* handle events in label */
4500                                0
4501                              | ButtonPressMask   /* button presses */
4502                             ,
4503                             FALSE ,              /* nonmaskable events? */
4504                             AFNI_pbar_EV ,       /* handler */
4505                             (XtPointer)im3d ,    /* client data */
4506                             XtListTail           /* last in queue */
4507                           ) ;
4508 
4509    /*--- toggle button to control automatic range scaling for pbar ---*/
4510    /*--- ZSS: Add percentile button, put both in horiz rowcol 27 Apr 2012 ---*/
4511 
4512    hrc = XtVaCreateWidget(
4513          "dialog" , xmRowColumnWidgetClass , func->range_rowcol ,
4514             XmNorientation , XmHORIZONTAL ,
4515             XmNpacking , XmPACK_TIGHT ,
4516             XmNtraversalOn , True  ,
4517             XmNinitialResourcesPersistent , False ,
4518          NULL ) ;
4519 
4520    im3d->vinfo->autorange_label =
4521       XmStringCreateLtoR( AFNI_range_bbox_label[0] , XmFONTLIST_DEFAULT_TAG ) ;
4522 
4523    func->range_bbox =
4524       new_MCW_bbox( hrc ,
4525                     1 , AFNI_range_bbox_label ,
4526                     MCW_BB_check ,
4527                     MCW_BB_noframe ,
4528                     AFNI_range_bbox_CB , (XtPointer)im3d ) ;
4529 
4530    func->range_bbox->parent = (XtPointer) im3d ;
4531 
4532    MCW_set_bbox( func->range_bbox ,
4533                  (im3d->vinfo->use_autorange) ? (1) : (0) ) ;
4534 
4535    MCW_reghelp_children( func->range_bbox->wrowcol ,
4536                          "This button determines whether the program\n"
4537                          "or the user sets the OLay value that maps\n"
4538                          "to the color pbar level 1.0:\n\n"
4539                          "Pressed In: use 'autoRange' value for pbar 1.0\n"
4540                          "       Out: user controls Range value (below)"
4541                        ) ;
4542    MCW_reghint_children( func->range_bbox->wrowcol ,
4543                          "Automatic or user-controlled color range scaling" ) ;
4544    ADDTO_KILL(im3d->kl,func->range_bbox) ;
4545 
4546    func->perc_bbox =
4547       new_MCW_bbox( hrc ,
4548                     1 , AFNI_perc_bbox_label,
4549                     MCW_BB_check ,
4550                     MCW_BB_noframe ,
4551                     AFNI_perc_bbox_CB , (XtPointer)im3d ) ;
4552 
4553    func->perc_bbox->parent = (XtPointer) im3d ;
4554 
4555    MCW_set_bbox( func->perc_bbox ,
4556                  (im3d->cont_perc_thr) ? (1) : (0) ) ;
4557 
4558    MCW_reghelp_children( func->perc_bbox->wrowcol ,
4559                          " \n"
4560                          " This button determines whether the slider sets\n"
4561                          " the threshold based on percentile, rather than\n"
4562                          " value. At 0.75, you threshold away the bottom 75%\n"
4563                          " of the voxels that would be displayed with no\n"
4564                          " thresholding at all. At 0.5 you see the top half.\n"
4565                          " The slider power is ignored in percentile\n"
4566                          " mode, so 0.5 is the same as 5, 50, etc.\n"
4567                          " Zero voxels are not considered. Only positive\n"
4568                          " voxels are considered if 'Pos?' is set; otherwise,\n"
4569                          " the cumulative distribution percentages come from\n"
4570                          " the absolute value of the voxel values.\n "
4571                        ) ;
4572    MCW_reghint_children( func->perc_bbox->wrowcol ,
4573                          "Percentile Thresholding" ) ;
4574 
4575    ADDTO_KILL(im3d->kl,func->perc_bbox) ;
4576    XtManageChild( hrc ) ;
4577 
4578    /*--- 30 Mar 2001: put the next 2 things in a horizontal rowcol ---*/
4579 
4580    hrc = XtVaCreateWidget(
4581          "dialog" , xmRowColumnWidgetClass , func->range_rowcol ,
4582             XmNorientation , XmHORIZONTAL ,
4583             XmNpacking , XmPACK_TIGHT ,
4584             XmNtraversalOn , True  ,
4585             XmNinitialResourcesPersistent , False ,
4586          NULL ) ;
4587 
4588    /*--- arrowval to provide user control for pbar scaling ---*/
4589 
4590    func->range_av =
4591       new_MCW_arrowval(
4592          hrc ,                             /* parent */
4593          NULL ,                            /* label */
4594          MCW_AV_downup ,                   /* arrow directions */
4595          0  ,                              /* min value */
4596          9999999 ,                         /* max value */
4597          (int) (im3d->vinfo->fim_range) ,  /* init value */
4598          MCW_AV_editext ,                  /* input/output text display */
4599          0 ,                               /* decimal shift */
4600          AFNI_range_av_CB ,                /* routine to call when button */
4601          (XtPointer) im3d ,                /* is pressed, and its data */
4602          NULL,NULL                         /* no special display */
4603       ) ;
4604    XtVaSetValues( func->range_av->wtext, XmNcolumns, 8, NULL ); /* 13 Nov 2018 */
4605 
4606    func->range_av->parent = (XtPointer) im3d ;
4607 
4608    MCW_reghelp_children( func->range_av->wrowcol ,
4609                          "When the autoRange button above is Out, this\n"
4610                          "selector is used to set the OLay level which\n"
4611                          "maps to 1.0 on the color pbar."
4612                        ) ;
4613    MCW_reghint_children( func->range_av->wrowcol ,
4614                          "OLay value that maps to 1.0 for color overlay" ) ;
4615 
4616    ADDTO_KILL(im3d->kl,func->range_av) ;
4617 
4618    AV_SENSITIZE( func->range_av , ! im3d->vinfo->use_autorange ) ;
4619 
4620    /*--- 30 Mar 2001: rotate pbar ---*/
4621 
4622    func->range_rotate_av = new_MCW_arrowval(
4623                              hrc , "Rota" ,
4624                              MCW_AV_downup , 0,0,0 ,
4625                              MCW_AV_notext , 0 ,
4626                              AFNI_range_rotate_av_CB , (XtPointer) func->inten_pbar ,
4627                              NULL,NULL ) ;
4628    func->range_rotate_av->parent = (XtPointer) im3d ;
4629    MCW_reghelp_children( func->range_rotate_av->wrowcol ,
4630                          "Rotate the colors on\n"
4631                          "the 'pbar' up or down.\n"
4632                          "[Press with Shift  to]\n"
4633                          "[rotate in steps of 4]"  ) ;
4634    MCW_reghint_children( func->range_rotate_av->wrowcol ,
4635                          "Rotate pbar colors" ) ;
4636    ADDTO_KILL(im3d->kl,func->range_rotate_av) ;
4637 
4638    func->pbar_flip_pb2 =
4639       XtVaCreateManagedWidget(
4640          "dialog" , xmPushButtonWidgetClass , hrc ,
4641             LABEL_ARG("F") ,
4642             XmNmarginWidth  , 2 ,
4643             XmNmarginHeight , 0 ,
4644             XmNspacing      , 2 ,
4645             XmNborderWidth  , 0 ,
4646             XmNtraversalOn , True  ,
4647             XmNinitialResourcesPersistent , False ,
4648          NULL ) ;
4649    XtAddCallback( func->pbar_flip_pb2 , XmNactivateCallback ,
4650                   AFNI_pbar_CB , im3d ) ;
4651    MCW_register_hint( func->pbar_flip_pb2 , "Top-to-Bottom color inversion" ) ;
4652    MCW_register_help( func->pbar_flip_pb2 ,
4653                         "Flip the color bar Top-to-Bottom.\n"
4654                         "Works for the continuous colorscale\n"
4655                         "and discretely paned color bars."     ) ;
4656 
4657    XtManageChild( hrc ) ;
4658 
4659 #ifdef USE_FUNC_FIM
4660    /*--- fim execution controls ---*/
4661 
4662    func->fim_frame =
4663       XtVaCreateManagedWidget(
4664          "dialog" , xmFrameWidgetClass , func->options_rowcol ,
4665             XmNshadowType , XmSHADOW_ETCHED_IN ,
4666             XmNshadowThickness , 2 ,
4667             XmNtraversalOn , True  ,
4668             XmNinitialResourcesPersistent , False ,
4669          NULL ) ;
4670 
4671    func->fim_rowcol =
4672       XtVaCreateWidget(
4673          "dialog" , xmRowColumnWidgetClass , func->fim_frame ,
4674             XmNorientation , XmHORIZONTAL ,
4675             XmNpacking , XmPACK_TIGHT ,
4676             XmNtraversalOn , True  ,
4677             XmNinitialResourcesPersistent , False ,
4678          NULL ) ;
4679 
4680    func->fim_mbar =
4681          XmCreateMenuBar( func->fim_rowcol, "dialog" , NULL,0 ) ;
4682    XtVaSetValues( func->fim_mbar ,
4683                      XmNmarginWidth  , 0 ,
4684                      XmNmarginHeight , 0 ,
4685                      XmNspacing      , 3 ,
4686                      XmNborderWidth  , 0 ,
4687                      XmNtraversalOn  , True  ,
4688                   NULL ) ;
4689    XtManageChild( func->fim_mbar ) ;
4690 
4691    func->fim_menu = AFNI_new_fim_menu( func->fim_mbar , AFNI_fimmer_menu_CB , 0 ) ;
4692    func->fim_menu->parent = (XtPointer) im3d ;
4693 
4694    xstr = XmStringCreateLtoR("1234567890123456789",XmFONTLIST_DEFAULT_TAG );
4695    func->fim_dset_label =
4696       XtVaCreateManagedWidget(
4697          "dialog" , xmLabelWidgetClass , func->fim_rowcol ,
4698             XmNrecomputeSize , False ,
4699             XmNlabelString , xstr ,
4700             XmNtraversalOn , True  ,
4701             XmNinitialResourcesPersistent , False ,
4702          NULL ) ;
4703    XmStringFree(xstr) ; LABELIZE(func->fim_dset_label) ;
4704    MCW_register_help( func->fim_dset_label ,
4705          "Shows the name of the\n"
4706          "dataset for which FIM\n"
4707          "is currently set up."
4708    ) ;
4709    MCW_register_hint( func->fim_dset_label , "Dataset to be FIM-ed") ;
4710 #endif
4711 
4712    /* 25 Jul 2001: a toggle box to show the TT Atlas */
4713 
4714    { char *see_ttatlas_label[1] = { "See TT Atlas Regions" } ;
4715      func->see_ttatlas_bbox =
4716       new_MCW_bbox( func->options_rowcol ,
4717                     1 , see_ttatlas_label ,
4718                     MCW_BB_check ,
4719                     MCW_BB_frame ,
4720                     AFNI_see_ttatlas_CB , (XtPointer) im3d ) ;
4721 
4722      func->see_ttatlas_bbox->parent = (XtPointer) im3d ;
4723 
4724      MCW_set_bbox( func->see_ttatlas_bbox ,
4725                    (im3d->vinfo->see_ttatlas) ? (1) : (0) ) ;
4726 
4727      MCW_reghelp_children( func->see_ttatlas_bbox->wrowcol ,
4728                            "This button determines whether to show\n"
4729                            "the Talairach-Tournoux Atlas regions,\n"
4730                            "which are controlled by the 'Atlas Colors'\n"
4731                            "item on the image viewing window popup menu."
4732                          ) ;
4733      MCW_reghint_children( func->see_ttatlas_bbox->wrowcol ,
4734                            "Use 'Atlas Colors' from image popup menu" ) ;
4735 
4736      ADDTO_KILL(im3d->kl,func->see_ttatlas_bbox) ;
4737    }
4738 
4739    xstr = XmStringCreateLtoR( "ULay = xxxxxxxxxxxxxxxx\n"
4740                               "OLay = xxxxxxxxxxxxxxxx\n"
4741                               "Thr  = xxxxxxxxxxxxxxxx" ,
4742                             XmFONTLIST_DEFAULT_TAG ) ;
4743 
4744    func->bkgd_lab =
4745       XtVaCreateWidget(
4746          "font7" , xmLabelWidgetClass , func->options_rowcol ,
4747             XmNrecomputeSize , False ,
4748             XmNlabelString , xstr ,
4749             XmNmarginHeight, 0 ,
4750             XmNtraversalOn , True  ,
4751             XmNinitialResourcesPersistent , False ,
4752          NULL ) ;
4753    XmStringFree( xstr ) ; LABELIZE(func->bkgd_lab) ;
4754 
4755    im3d->vinfo->anat_val[0] =
4756     im3d->vinfo->func_val[0] =
4757      im3d->vinfo->thr_val[0]  = '\0' ;
4758 
4759    MCW_register_help( func->bkgd_lab ,
4760                       "Shows the values at the\n"
4761                       "current crosshair voxel.\n"
4762                       "\n"
4763                       "N.B.: Is only active when\n"
4764                       " all 3 image windows are\n"
4765                       " open!"
4766                     ) ;
4767    MCW_register_hint( func->bkgd_lab , "Values at crosshairs voxel" ) ;
4768 
4769    /*-- manage the managers --*/
4770 
4771    XtManageChild( func->thrtop_rowcol ) ;
4772    XtManageChild( func->thr_rowcol ) ;
4773    XtManageChild( func->inten_rowcol ) ;
4774    XtManageChild( func->range_rowcol ) ;
4775    XtManageChild( func->clu_rowcol ) ;
4776    XtManageChild( func->icor_rowcol ) ;
4777    XtManageChild( func->vedit_frame ) ;
4778    XtManageChild( func->ulaclu_rowcol ) ;
4779    XtManageChild( func->options_rowcol ) ;
4780 #ifdef USE_FUNC_FIM
4781    XtManageChild( func->fim_rowcol ) ;
4782 #endif
4783    XtManageChild( func->rowcol ) ;
4784 
4785 #if 0
4786    { Widget qwid[2] ; Window qwin[2] ;
4787      qwid[0] = func->inten_pbar->top ;
4788      qwid[1] = qsep ;
4789      qwin[0] = XtWindow(qwid[0]) ;
4790      qwin[1] = XtWindow(qwid[1]) ;
4791      XRestackWindows( XtDisplay(qwid[0]) , qwin , 2 ) ;
4792    }
4793 #endif
4794 
4795    EXRETURN ;
4796 }
4797 
4798 /*--------------------------------------------------------------------*/
4799 
AFNI_make_wid3(Three_D_View * im3d)4800 void AFNI_make_wid3( Three_D_View *im3d )
4801 {
4802 
4803 ENTRY("AFNI_make_wid3") ;
4804 
4805    /*-----------------------------------------------------*/
4806    /**************** Datamode controls ********************/
4807    /*-----------------------------------------------------*/
4808 
4809 STATUS("making dmode->rowcol") ;
4810 
4811    dmode->rowcol =
4812       XtVaCreateWidget(
4813          "dialog" , xmRowColumnWidgetClass , dmode->frame ,
4814             XmNorientation , XmVERTICAL ,
4815             XmNpacking , XmPACK_TIGHT ,
4816             XmNtraversalOn , True  ,
4817             XmNmarginHeight, 0 ,
4818             XmNspacing , 1 ,
4819             XmNinitialResourcesPersistent , False ,
4820          NULL ) ;
4821 
4822    /*--- bbox to control how we see the anat data ---*/
4823 
4824    dmode->anatmode_bbox =
4825       new_MCW_bbox( dmode->rowcol ,
4826                     2 , AFNI_anatmode_bbox_label ,
4827                     MCW_BB_radio_one ,
4828                     MCW_BB_frame ,
4829                     AFNI_anatmode_CB , (XtPointer) im3d ) ;
4830 
4831    dmode->anatmode_bbox->parent = (XtPointer) im3d ;
4832 
4833    MCW_reghelp_children( dmode->anatmode_bbox->wrowcol ,
4834      "View ULay Data Brick ==> data from underlay file is displayed\n"
4835      "                   (will be grayed-out if data is not available)\n"
4836      "Warp ULay on Demand  ==> data is resampled as needed for display" ) ;
4837 
4838    { char *hh[] = { "View data direct from brick" ,
4839                      "View data resampled to new grid" } ;
4840      MCW_bbox_hints( dmode->anatmode_bbox , 2 , hh ) ;
4841    }
4842 
4843    ADDTO_KILL(im3d->kl,dmode->anatmode_bbox) ;
4844 
4845    /*-- resampling control: anat mode --*/
4846 
4847    dmode->anat_resam_av = new_MCW_arrowval(
4848                              dmode->rowcol ,
4849                              "ULay Resam mode" ,
4850                              AVOPT_STYLE ,
4851                              FIRST_RESAM_TYPE ,
4852                              LAST_RESAM_TYPE ,
4853                              im3d->vinfo->anat_resam_mode ,
4854                              MCW_AV_readtext , 0 ,
4855                              AFNI_resam_av_CB , (XtPointer) im3d ,
4856                              AFNI_resam_texter , NULL ) ;
4857 
4858    dmode->anat_resam_av->parent     = (XtPointer) im3d ;
4859    dmode->anat_resam_av->allow_wrap = 1 ;         /* wrap values */
4860    dmode->anat_resam_av->fastdelay  = 1000 ;      /* slow it down */
4861 
4862 #ifndef USE_OPTMENUS
4863    XtVaSetValues( dmode->anat_resam_av->wtext ,
4864                      XmNcolumns   , NSTR_SHORT_RESAM ,
4865                      XmNmaxLength , NSTR_SHORT_RESAM ,
4866                   NULL ) ;
4867 #endif
4868 
4869    MCW_reghelp_children( dmode->anat_resam_av->wrowcol ,
4870      "This controls the resampling mode for\n"
4871      "underlay data (for display and writing):\n\n"
4872      "NN = nearest neighbor resampling [fastest]\n"
4873      "Li = linear interpolation        [OK]\n"
4874      "Cu = cubic interpolation         [nice but slow]\n"
4875      "Bk = blocky interpolation        [between NN & Li]"  ) ;
4876    MCW_reghint_children( dmode->anat_resam_av->wrowcol , "Resampling method" ) ;
4877 
4878    ADDTO_KILL(im3d->kl,dmode->anat_resam_av) ;
4879 
4880    /*----- resampling: voxel size -----*/
4881 
4882    dmode->resam_vox_av =
4883       new_MCW_arrowval(
4884          dmode->rowcol ,                  /* parent */
4885          "Resam (mm)" ,                   /* label */
4886          MCW_AV_downup ,                  /* arrow directions */
4887          1  ,                             /* min value (0.1 mm from decim) */
4888          40 ,                             /* max value (4.0 mm) */
4889          (int)(10*INIT_resam_vox) ,       /* init value */
4890          MCW_AV_editext ,                 /* input/output text display */
4891          1 ,                              /* decimal shift */
4892          AFNI_resam_vox_av_CB ,           /* routine to call when button */
4893          (XtPointer) im3d ,               /* is pressed, and its data */
4894          NULL,NULL                        /* no special display */
4895       ) ;
4896 
4897    XtVaSetValues( dmode->resam_vox_av->wtext , XmNcolumns , 7 , NULL ) ;
4898 
4899    dmode->resam_vox_av->parent = (XtPointer) im3d ;
4900 
4901    MCW_reghelp_children( dmode->resam_vox_av->wrowcol ,
4902                          AFNI_disp_resam_vox_help ) ;
4903    MCW_reghint_children( dmode->resam_vox_av->wrowcol ,
4904                          "Resampled voxel size" ) ;
4905 
4906    ADDTO_KILL(im3d->kl,dmode->resam_vox_av) ;
4907 
4908    /*--- separator between anat and func stuff ---*/
4909 
4910    (void) XtVaCreateManagedWidget(
4911             "dialog" , xmSeparatorWidgetClass , dmode->rowcol ,
4912                 XmNseparatorType , XmSINGLE_LINE ,
4913             NULL ) ;
4914 
4915    /*--- bbox to control how we see the func data ---*/
4916 
4917    dmode->funcmode_bbox =
4918       new_MCW_bbox( dmode->rowcol ,
4919                     2 , AFNI_funcmode_bbox_label ,
4920                     MCW_BB_radio_one ,
4921                     MCW_BB_frame ,
4922                     AFNI_funcmode_CB , (XtPointer) im3d ) ;
4923 
4924    dmode->funcmode_bbox->parent = (XtPointer) im3d ;
4925 
4926    MCW_reghelp_children( dmode->funcmode_bbox->wrowcol ,
4927      "View OLay Data Brick ==> data from overlay file is displayed\n"
4928      "                   (will be grayed-out if data is not available)\n"
4929      "Warp OLay on Demand  ==> data is resampled as needed for display\n\n"
4930      "N.B.: Overlay data is always on top of underlay data.\n"
4931      "  To be displayed directly from the overlay data brick,\n"
4932      "  this brick must conform in dimensions to the underlay\n"
4933      "  data being displayed.  Even if the overlay brick exists,\n"
4934      "  if its dimensions do not correspond to the underlay brick\n"
4935      "  or the resampling dimension (below), then the overlay data\n"
4936      "  being displayed will be 'warped-on-demand'.  Such warping\n"
4937      "  always occurs from the 'most original' source.  For example,\n"
4938      "  if a Talairach view brick is altered (via a plugin, or another\n"
4939      "  external editing program), then viewing the brick may be quite\n"
4940      "  different from viewing the warped data, which will be recomputed\n"
4941      "  from the Original view brick (if available), without reference\n"
4942      "  to whatever alterations may have been made in the Talairach view."
4943    ) ;
4944 
4945    { char *hh[] = { "View data direct from brick" ,
4946                     "View data resampled to new grid" } ;
4947      MCW_bbox_hints( dmode->funcmode_bbox , 2 , hh ) ;
4948    }
4949 
4950    ADDTO_KILL(im3d->kl,dmode->funcmode_bbox) ;
4951 
4952    /*-- func resampling control (moved here 03 Nov 1996) --*/
4953 
4954    dmode->func_resam_av = new_MCW_arrowval(
4955                              dmode->rowcol ,
4956 #ifdef USE_OPTMENUS
4957                              "OLay Resam mode" ,
4958 #else
4959                              "OLay mode " ,
4960 #endif
4961                              AVOPT_STYLE ,
4962                              FIRST_RESAM_TYPE ,
4963                              LAST_RESAM_TYPE ,
4964                              im3d->vinfo->func_resam_mode ,
4965                              MCW_AV_readtext , 0 ,
4966                              AFNI_resam_av_CB , (XtPointer) im3d ,
4967                              AFNI_resam_texter , NULL ) ;
4968 
4969    dmode->func_resam_av->parent     = (XtPointer) im3d ;
4970    dmode->func_resam_av->allow_wrap = 1 ;       /* wrap values */
4971    dmode->func_resam_av->fastdelay  = 1000 ;    /* slow it down */
4972 
4973 #ifndef USE_OPTMENUS
4974    XtVaSetValues( dmode->func_resam_av->wtext ,
4975                      XmNcolumns   , NSTR_SHORT_RESAM ,
4976                      XmNmaxLength , NSTR_SHORT_RESAM ,
4977                   NULL ) ;
4978 #endif
4979 
4980    MCW_reghelp_children( dmode->func_resam_av->wrowcol ,
4981      "This controls the resampling mode for\n"
4982      "overlay data (display and writing):\n\n"
4983      "NN = nearest neighbor resampling [fastest]\n"
4984      "Li = linear interpolation        [OK]\n"
4985      "Cu = cubic interpolation         [nice but slow]\n"
4986      "Bk = blocky interpolation        [between NN & Li]\n\n"
4987      "N.B.: Dataset sub-bricks without statistical\n"
4988      "  parameters attached will be interpolated using\n"
4989      "  this method.  Those with statistical parameters\n"
4990      "  will be interpolated using the method chosen below." ) ;
4991 
4992    MCW_reghint_children( dmode->func_resam_av->wrowcol , "Resampling method" ) ;
4993 
4994    /*-- thr resampling control (09 Dec 1997) --*/
4995 
4996    dmode->thr_resam_av = new_MCW_arrowval(
4997                              dmode->rowcol ,
4998 #ifdef USE_OPTMENUS
4999                              "Stat Resam mode" ,
5000 #else
5001                              "Stat mode " ,
5002 #endif
5003                              AVOPT_STYLE ,
5004                              FIRST_RESAM_TYPE ,
5005                              LAST_RESAM_TYPE ,
5006                              im3d->vinfo->thr_resam_mode ,
5007                              MCW_AV_readtext , 0 ,
5008                              AFNI_resam_av_CB , (XtPointer) im3d ,
5009                              AFNI_resam_texter , NULL ) ;
5010 
5011    dmode->thr_resam_av->parent     = (XtPointer) im3d ;
5012    dmode->thr_resam_av->allow_wrap = 1 ;       /* wrap values */
5013    dmode->thr_resam_av->fastdelay  = 1000 ;    /* slow it down */
5014 
5015 #ifndef USE_OPTMENUS
5016    XtVaSetValues( dmode->thr_resam_av->wtext ,
5017                      XmNcolumns   , NSTR_SHORT_RESAM ,
5018                      XmNmaxLength , NSTR_SHORT_RESAM ,
5019                   NULL ) ;
5020 #endif
5021 
5022    MCW_reghelp_children( dmode->thr_resam_av->wrowcol ,
5023      "This controls the resampling mode for\n"
5024      "overlay data (statistics sub-bricks only):\n\n"
5025      "NN = nearest neighbor resampling [fastest]\n"
5026      "Li = linear interpolation        [OK]\n"
5027      "Cu = cubic interpolation         [nice but slow]\n"
5028      "Bk = blocky interpolation        [between NN & Li]\n\n"
5029      "N.B.: Dataset sub-bricks without statistical\n"
5030      "  parameters attached will be interpolated using\n"
5031      "  the method chosen above.  Those with statistical\n"
5032      "   parameters will be interpolated using this method." ) ;
5033 
5034    MCW_reghint_children( dmode->thr_resam_av->wrowcol , "Resampling method" ) ;
5035 
5036    /*--- separator between func stuff and write buttons ---*/
5037 
5038    (void) XtVaCreateManagedWidget(
5039             "dialog" , xmSeparatorWidgetClass , dmode->rowcol ,
5040                 XmNseparatorType , XmSINGLE_LINE ,
5041             NULL ) ;
5042 
5043    /*---- 23 Nov 1996: rowcol for Write buttons ----*/
5044 
5045    dmode->write_rowcol =
5046         XtVaCreateWidget(
5047            "dialog" , xmRowColumnWidgetClass , dmode->rowcol ,
5048               XmNorientation , XmHORIZONTAL ,
5049               XmNpacking , XmPACK_TIGHT ,
5050               XmNmarginHeight , 0 ,
5051               XmNmarginWidth  , 0 ,
5052               XmNspacing      , 1 ,
5053               XmNtraversalOn , True  ,
5054               XmNinitialResourcesPersistent , False ,
5055            NULL ) ;
5056 
5057    /*-- 23 Nov 1996: label at left --*/
5058 
5059    wtemp = XtVaCreateManagedWidget(
5060          "dialog" , xmLabelWidgetClass , dmode->write_rowcol ,
5061             LABEL_ARG("Resamp") ,
5062             XmNalignment , XmALIGNMENT_BEGINNING ,
5063             XmNrecomputeSize , False ,
5064             XmNtraversalOn , True  ,
5065             XmNinitialResourcesPersistent , False ,
5066          NULL ) ; LABELIZE(wtemp) ;
5067 
5068    /*--- write pushbuttons ---*/
5069 
5070    dmode->write_anat_pb =
5071       XtVaCreateManagedWidget(
5072          "dialog" , xmPushButtonWidgetClass , dmode->write_rowcol ,
5073             LABEL_ARG("ULay") ,
5074             XmNtraversalOn , True  ,
5075             XmNinitialResourcesPersistent , False ,
5076          NULL ) ;
5077 
5078    XtAddCallback( dmode->write_anat_pb , XmNactivateCallback ,
5079                   AFNI_write_dataset_CB , im3d ) ;
5080 
5081    MCW_register_hint( dmode->write_anat_pb ,
5082                       "Write current underlay to disk at resampling resolution" ) ;
5083 
5084    /*---*/
5085 
5086    dmode->write_func_pb =
5087       XtVaCreateManagedWidget(
5088          "dialog" , xmPushButtonWidgetClass , dmode->write_rowcol ,
5089             LABEL_ARG("OLay") ,
5090             XmNtraversalOn , True  ,
5091             XmNinitialResourcesPersistent , False ,
5092          NULL ) ;
5093 
5094    XtAddCallback( dmode->write_func_pb , XmNactivateCallback ,
5095                   AFNI_write_dataset_CB , im3d ) ;
5096 
5097    MCW_register_hint( dmode->write_func_pb ,
5098                       "Write current overlay dataset to disk at resampling resolution" ) ;
5099 
5100    /*---*/
5101 
5102    dmode->write_many_pb =
5103       XtVaCreateManagedWidget(
5104          "dialog" , xmPushButtonWidgetClass , dmode->write_rowcol ,
5105             LABEL_ARG("Many") ,
5106             XmNtraversalOn , True  ,
5107             XmNinitialResourcesPersistent , False ,
5108          NULL ) ;
5109 
5110    XtAddCallback( dmode->write_many_pb , XmNactivateCallback ,
5111                   AFNI_write_many_dataset_CB , im3d ) ;
5112 
5113    MCW_register_hint( dmode->write_many_pb ,
5114                       "Write multiple datasets to disk at resampling resolution" ) ;
5115 
5116    MCW_reghelp_children( dmode->write_rowcol ,
5117         "The purpose of the 'Resamp' buttons is to recompute\n"
5118         "entire dataset bricks in the current coordinate\n"
5119         "system ('view') and write them to disk.\n"
5120         "\n"
5121         "The various 'Resam' controls (above) determine the\n"
5122         "resolution and interpolation method used in creating\n"
5123         "the new bricks.\n"
5124         "\n"
5125         "  ULay --> write current underlay dataset brick\n"
5126         "  OLay --> write current overlay dataset brick\n"
5127         "  Many --> select one or more datasets from a list\n"
5128         "\n"
5129         "N.B.:\n"
5130         " + Only dataset bricks that are warped from a\n"
5131         "     'parent' dataset can be written out.\n"
5132         " + 'Resamp' will not destroy original data (I hope).\n"
5133         " + This operation might be very time-consuming,\n"
5134         "    especially for big 3D+time datasets!\n"
5135         " + Resampling a big 3D+time dataset to 1 mm grid\n"
5136         "    size is usually pointless and will use up a\n"
5137         "    LOT of disk space.\n"
5138         " + You can write a dataset to disk under a new name\n"
5139         "    (but not resampled) using the 'SaveAs' buttons."
5140       ) ;
5141 
5142    /*---- 18 Oct 2010: rowcol for SaveAs buttons ----*/
5143 
5144    dmode->saveas_rowcol =
5145         XtVaCreateWidget(
5146            "dialog" , xmRowColumnWidgetClass , dmode->rowcol ,
5147               XmNorientation , XmHORIZONTAL ,
5148               XmNpacking , XmPACK_TIGHT ,
5149               XmNmarginHeight , 0 ,
5150               XmNmarginWidth  , 0 ,
5151               XmNspacing      , 1 ,
5152               XmNtraversalOn , True  ,
5153               XmNinitialResourcesPersistent , False ,
5154            NULL ) ;
5155 
5156    /*-- label at left --*/
5157 
5158    wtemp = XtVaCreateManagedWidget(
5159          "dialog" , xmLabelWidgetClass , dmode->saveas_rowcol ,
5160             LABEL_ARG("SaveAs") ,
5161             XmNalignment , XmALIGNMENT_BEGINNING ,
5162             XmNrecomputeSize , False ,
5163             XmNtraversalOn , True  ,
5164             XmNinitialResourcesPersistent , False ,
5165          NULL ) ; LABELIZE(wtemp) ;
5166 
5167    /*--- SaveAs pushbuttons ---*/
5168 
5169    dmode->saveas_anat_pb =
5170       XtVaCreateManagedWidget(
5171          "dialog" , xmPushButtonWidgetClass , dmode->saveas_rowcol ,
5172             LABEL_ARG("ULay") ,
5173             XmNtraversalOn , True  ,
5174             XmNinitialResourcesPersistent , False ,
5175          NULL ) ;
5176    XtAddCallback( dmode->saveas_anat_pb , XmNactivateCallback ,
5177                   AFNI_saveas_dataset_CB , im3d ) ;
5178    MCW_register_hint( dmode->saveas_anat_pb ,
5179                       "Write current underlay to disk at its internal resolution" ) ;
5180 
5181    /*---*/
5182 
5183    dmode->saveas_func_pb =
5184       XtVaCreateManagedWidget(
5185          "dialog" , xmPushButtonWidgetClass , dmode->saveas_rowcol ,
5186             LABEL_ARG("OLay") ,
5187             XmNtraversalOn , True  ,
5188             XmNinitialResourcesPersistent , False ,
5189          NULL ) ;
5190    XtAddCallback( dmode->saveas_func_pb , XmNactivateCallback ,
5191                   AFNI_saveas_dataset_CB , im3d ) ;
5192    MCW_register_hint( dmode->saveas_func_pb ,
5193                       "Write current overlay to disk at its internal resolution" ) ;
5194 
5195    MCW_reghelp_children( dmode->saveas_rowcol ,
5196                          "The 'SaveAs' buttons let you write out one\n"
5197                          "of the current datasets (UnderLay or OverLay)\n"
5198                          "under a new name.  These datasets will be\n"
5199                          "written at the spatial resolution they are\n"
5200                          "stored in -- they won't be resampled.\n\n"
5201                          "* Datasets that are 'warp-on-demand' (don't\n"
5202                          "   have their own data) cannot be 'SaveAs'-ed!\n"
5203                          "* It is possible to over-write an existing\n"
5204                          "   dataset with 'SaveAs' -- but this is\n"
5205                          "   usually NOT advisable, unless you are\n"
5206                          "   going to quit AFNI almost immediately."
5207                        ) ;
5208 
5209    /*---- 23 Nov 1996: Row of Buttons for Rescan Session ----*/
5210 
5211    dmode->rescan_rowcol =
5212         XtVaCreateWidget(
5213            "dialog" , xmRowColumnWidgetClass , dmode->rowcol ,
5214               XmNorientation , XmHORIZONTAL ,
5215               XmNpacking , XmPACK_TIGHT ,
5216               XmNmarginHeight , 0 ,
5217               XmNmarginWidth  , 0 ,
5218               XmNspacing      , 1 ,
5219               XmNtraversalOn , True  ,
5220               XmNinitialResourcesPersistent , False ,
5221            NULL ) ;
5222 
5223    /*-- 23 Nov 1996: label at left --*/
5224 
5225    wtemp = XtVaCreateManagedWidget(
5226          "dialog" , xmLabelWidgetClass , dmode->rescan_rowcol ,
5227             LABEL_ARG("Rescan") ,
5228             XmNalignment , XmALIGNMENT_BEGINNING ,
5229             XmNrecomputeSize , False ,
5230             XmNtraversalOn , True  ,
5231             XmNinitialResourcesPersistent , False ,
5232          NULL ) ; LABELIZE(wtemp) ;
5233 
5234    /*-- pushbutton for one session rescan --*/
5235 
5236    dmode->rescan_pb =
5237       XtVaCreateManagedWidget(
5238          "dialog" , xmPushButtonWidgetClass , dmode->rescan_rowcol ,
5239             LABEL_ARG("This") ,
5240             XmNmarginHeight , 0 ,
5241             XmNtraversalOn , True  ,
5242             XmNinitialResourcesPersistent , False ,
5243          NULL ) ;
5244    XtAddCallback( dmode->rescan_pb , XmNactivateCallback ,
5245                   AFNI_rescan_CB , im3d ) ;
5246    MCW_register_hint( dmode->rescan_pb ,
5247                       "Read current session again" ) ;
5248 
5249    /*-- 23 Nov 1996: pushbutton for all session rescan --*/
5250 
5251    dmode->rescan_all_pb =
5252       XtVaCreateManagedWidget(
5253          "dialog" , xmPushButtonWidgetClass , dmode->rescan_rowcol ,
5254             LABEL_ARG("All ") ,
5255             XmNmarginHeight , 0 ,
5256             XmNtraversalOn , True  ,
5257             XmNinitialResourcesPersistent , False ,
5258          NULL ) ;
5259 
5260    XtAddCallback( dmode->rescan_all_pb , XmNactivateCallback ,
5261                   AFNI_rescan_all_CB , im3d ) ;
5262 
5263    MCW_register_hint( dmode->rescan_all_pb ,
5264                       "Read all sessions again" ) ;
5265 
5266    /*---*/
5267 
5268    dmode->rescan_timeseries_pb =
5269       XtVaCreateManagedWidget(
5270          "dialog" , xmPushButtonWidgetClass , dmode->rescan_rowcol ,
5271             LABEL_ARG("*.1D") ,
5272             XmNmarginHeight , 0 ,
5273             XmNtraversalOn , True  ,
5274             XmNinitialResourcesPersistent , False ,
5275          NULL ) ;
5276 
5277    XtAddCallback( dmode->rescan_timeseries_pb , XmNactivateCallback ,
5278                   AFNI_rescan_timeseries_CB , im3d ) ;
5279 
5280    MCW_register_hint( dmode->rescan_timeseries_pb ,
5281                       "Read directories for new time series files" ) ;
5282 
5283    MCW_reghelp_children( dmode->rescan_rowcol ,
5284          "The purpose of the 'Rescan' buttons is to read\n"
5285          "the contents of session directories again in\n"
5286          "order to make newly created datasets (e.g., from\n"
5287          "the 3dmerge program) available for AFNI viewing.\n"
5288          "\n"
5289          "This --> rescan just the current session.\n"
5290          "All  --> rescan all session directories.\n"
5291          "*.1D --> rescan for timeseries files instead\n"
5292          "         of AFNI datasets.  Note that the program\n"
5293          "         won't re-read a filename that has already\n"
5294          "         been read in.  This means that if you change\n"
5295          "         the contents of a .1D file, AFNI will not\n"
5296          "         be aware of that fact even after this rescan\n"
5297          "         operation."
5298       ) ;
5299 
5300    /*---- 04 Mar 1997: Row of Buttons for Reading ----*/
5301 
5302    dmode->read_rowcol =
5303         XtVaCreateWidget(
5304            "dialog" , xmRowColumnWidgetClass , dmode->rowcol ,
5305               XmNorientation , XmHORIZONTAL ,
5306               XmNpacking , XmPACK_TIGHT ,
5307               XmNmarginHeight , 0 ,
5308               XmNmarginWidth  , 0 ,
5309               XmNspacing      , 1 ,
5310               XmNtraversalOn , True  ,
5311               XmNinitialResourcesPersistent , False ,
5312            NULL ) ;
5313 
5314    /*-- label at left --*/
5315 
5316    wtemp = XtVaCreateManagedWidget(
5317          "dialog" , xmLabelWidgetClass , dmode->read_rowcol ,
5318             LABEL_ARG("Read  ") ,
5319             XmNalignment , XmALIGNMENT_BEGINNING ,
5320             XmNrecomputeSize , False ,
5321             XmNtraversalOn , True  ,
5322             XmNinitialResourcesPersistent , False ,
5323          NULL ) ; LABELIZE(wtemp) ;
5324 
5325    /*-- pushbutton for session input --*/
5326 
5327    dmode->read_sess_pb =
5328       XtVaCreateManagedWidget(
5329          "dialog" , xmPushButtonWidgetClass , dmode->read_rowcol ,
5330             LABEL_ARG("Sess") ,
5331             XmNmarginHeight , 0 ,
5332             XmNtraversalOn , True  ,
5333             XmNinitialResourcesPersistent , False ,
5334          NULL ) ;
5335    XtAddCallback( dmode->read_sess_pb , XmNactivateCallback ,
5336                   AFNI_read_sess_CB , im3d ) ;
5337    MCW_register_hint( dmode->read_sess_pb ,
5338                       "Read in a new session directory" ) ;
5339 
5340    /*-- pushbutton for timeseries input --*/
5341 
5342    dmode->read_1D_pb =
5343       XtVaCreateManagedWidget(
5344          "dialog" , xmPushButtonWidgetClass , dmode->read_rowcol ,
5345             LABEL_ARG(" 1D ") ,
5346             XmNmarginHeight , 0 ,
5347             XmNtraversalOn , True  ,
5348             XmNinitialResourcesPersistent , False ,
5349          NULL ) ;
5350 
5351    XtAddCallback( dmode->read_1D_pb , XmNactivateCallback ,
5352                   AFNI_read_1D_CB , im3d ) ;
5353 
5354    MCW_register_hint( dmode->read_1D_pb ,
5355                       "Read in a new time series file" ) ;
5356 
5357    /*-- pushbutton for Web input --*/
5358 
5359    dmode->read_Web_pb =
5360       XtVaCreateManagedWidget(
5361          "dialog" , xmPushButtonWidgetClass , dmode->read_rowcol ,
5362             LABEL_ARG("Web ") ,
5363             XmNmarginHeight , 0 ,
5364             XmNtraversalOn , True  ,
5365             XmNinitialResourcesPersistent , False ,
5366          NULL ) ;
5367 
5368    XtAddCallback( dmode->read_Web_pb , XmNactivateCallback ,
5369                   AFNI_read_Web_CB , im3d ) ;
5370 
5371    MCW_register_hint( dmode->read_Web_pb ,
5372                       "Read dataset via http:// or ftp://" ) ;
5373 
5374    MCW_reghelp_children( dmode->read_rowcol ,
5375          "The purpose of the 'Read' buttons is to read\n"
5376          "in new data.  (The 'Rescan' buttons are to\n"
5377          "re-read data from old directories.)\n"
5378          "\n"
5379          "Sess --> Read a new session directory.\n\n"
5380          "1D   --> Read a new timeseries file.\n\n"
5381          "Web  --> Read datasets from the Web:\n"
5382          "   e.g., http://some.place/dir/anat+orig\n"
5383          "         ftp://some.place/dir/func+orig\n"
5384          "   or    http://some.place/dir/AFNILIST\n"
5385          "   where AFNILIST is a text file with one\n"
5386          "         dataset name per line (will be\n"
5387          "         fetched from same Web directory;\n"
5388          "         do NOT put ftp:// or http:// in\n"
5389          "         the AFNILIST file!)."
5390       ) ;
5391 
5392    /*---- 04 Nov 1996: a place to put menubars ----*/
5393 
5394    dmode->mbar_rowcol =
5395         XtVaCreateWidget(
5396            "dialog" , xmRowColumnWidgetClass , dmode->rowcol ,
5397               XmNorientation , XmHORIZONTAL ,
5398               XmNpacking , XmPACK_TIGHT ,
5399               XmNmarginHeight , 0 ,
5400               XmNmarginWidth  , 0 ,
5401               XmNspacing      , 1 ,
5402               XmNtraversalOn , True  ,
5403               XmNinitialResourcesPersistent , False ,
5404            NULL ) ;
5405 
5406    /* 04 Nov 1996: make the "Lock" menubar */
5407 
5408    AFNI_lock_button( im3d ) ;
5409 
5410    /* 30 Oct 1996: make the "Misc" menubar */
5411 
5412    AFNI_misc_button( im3d ) ;
5413 
5414    /*-- manage the managers --*/
5415 
5416    XtManageChild( dmode->write_rowcol ) ;
5417    XtManageChild( dmode->saveas_rowcol ) ;
5418    XtManageChild( dmode->rescan_rowcol ) ;
5419    XtManageChild( dmode->read_rowcol ) ;
5420    XtManageChild( dmode->mbar_rowcol ) ;
5421    XtManageChild( dmode->rowcol ) ;
5422 
5423    /*--------------------------------------------------*/
5424    /*************** Program controls *******************/
5425    /*--------------------------------------------------*/
5426 
5427    /*----- rowcol to hold all program controls stuff -----*/
5428 
5429 STATUS("making prog->rowcol") ;
5430    SUMA_Register_Widget_Help( prog->frame, 0, "AfniCont->ProgCont",
5431                              "rowcol to hold all program controls stuff",
5432                              "Here is where the help would go."
5433 ":SPX:\n\n"
5434 "Although this image is in the string used by BHelp, it only seen "
5435 "by the Sphinx.\n\n"
5436 "   .. figure:: media/william-shakespeare.jpg\n"
5437 "      :align: center\n"
5438 "      :figwidth: 50%\n"
5439 "      :name: Bill\n"
5440 "      :target: http://www.poetryfoundation.org/bio/william-shakespeare\n"
5441 "\n"
5442 "      :ref:`Frequent contributor<Bill>`\n"
5443 ":SPX:\n\n");
5444 
5445    prog->rowcol =
5446       XtVaCreateWidget(
5447          "dialog" , xmRowColumnWidgetClass , prog->frame ,
5448             XmNpacking     , XmPACK_TIGHT ,
5449             XmNorientation , XmVERTICAL ,
5450             XmNtraversalOn , True  ,
5451             XmNinitialResourcesPersistent , False ,
5452          NULL ) ;
5453 
5454    if( im3d->type == AFNI_3DDATA_VIEW ){
5455       prog->rc_top =
5456          XtVaCreateWidget(
5457             "dialog" , xmRowColumnWidgetClass , prog->rowcol ,
5458                XmNpacking     , XmPACK_TIGHT ,
5459                XmNorientation , XmHORIZONTAL ,
5460                XmNspacing     , 1 ,
5461                XmNmarginHeight, 0 ,
5462                XmNmarginWidth , 0 ,
5463                XmNtraversalOn , True  ,
5464                XmNinitialResourcesPersistent , False ,
5465             NULL ) ;
5466 
5467       if( MAX_CONTROLLERS > 1 ){
5468          prog->clone_pb =
5469             XtVaCreateManagedWidget(
5470                "dialog" , xmPushButtonWidgetClass , prog->rc_top ,
5471                  LABEL_ARG("New  ") ,
5472                  XmNtraversalOn , True  ,
5473                  XmNalignment   , XmALIGNMENT_CENTER ,
5474                  XmNinitialResourcesPersistent , False ,
5475                NULL ) ;
5476          XtAddCallback( prog->clone_pb , XmNactivateCallback ,
5477                         AFNI_clone_controller_CB , im3d ) ;
5478          MCW_register_help( prog->clone_pb ,
5479                             "Use this to open\n"
5480                             "a new AFNI control\n"
5481                             "window."
5482                           ) ;
5483          MCW_register_hint( prog->clone_pb ,
5484                             "Open a new AFNI controller window" ) ;
5485          MCW_set_widget_bg( prog->clone_pb , "black" , 0 ) ;
5486       } else {
5487           prog->clone_pb = NULL ;
5488       }
5489 
5490       prog->panel_pb =
5491          XtVaCreateManagedWidget(
5492             "dialog" , xmPushButtonWidgetClass , prog->rc_top ,
5493               LABEL_ARG("Etc->") ,
5494               XmNtraversalOn , True  ,
5495               XmNalignment   , XmALIGNMENT_CENTER ,
5496               XmNinitialResourcesPersistent , False ,
5497             NULL ) ;
5498 
5499       prog->panel_pb_inverted = True ;
5500       MCW_invert_widget( prog->panel_pb ) ;
5501 
5502       MCW_register_help( prog->panel_pb ,
5503                          "Use this to close and open\n"
5504                          "the viewing control panel\n"
5505                          "located to the right."
5506                        ) ;
5507       MCW_register_hint( prog->panel_pb ,
5508                          "Open/close control panel to right" ) ;
5509 
5510       XtAddCallback( prog->panel_pb , XmNactivateCallback ,
5511                      AFNI_controller_panel_CB , im3d ) ;
5512 
5513    } else {
5514       prog->rc_top = prog->clone_pb = prog->panel_pb = NULL ;
5515    }
5516 
5517    /*----- pushbutton: button help -----*/
5518 
5519    prog->rc_bot =
5520       XtVaCreateWidget(
5521          "dialog" , xmRowColumnWidgetClass , prog->rowcol ,
5522             XmNpacking     , XmPACK_TIGHT ,
5523             XmNorientation , XmHORIZONTAL ,
5524             XmNspacing     , 1 ,
5525             XmNmarginHeight, 0 ,
5526             XmNmarginWidth , 0 ,
5527             XmNtraversalOn , True  ,
5528             XmNinitialResourcesPersistent , False ,
5529          NULL ) ;
5530 
5531    /*---*/
5532 
5533    prog->button_help_pb =
5534       XtVaCreateManagedWidget(
5535          "dialog" , xmPushButtonWidgetClass , prog->rc_bot ,
5536            LABEL_ARG("BHelp") ,
5537            XmNtraversalOn , True  ,
5538            XmNalignment   , XmALIGNMENT_CENTER ,
5539            XmNinitialResourcesPersistent , False ,
5540          NULL ) ;
5541 
5542    XtAddCallback( prog->button_help_pb , XmNactivateCallback ,
5543                   MCW_click_help_CB , im3d ) ;
5544 
5545    MCW_register_help( prog->button_help_pb , AFNI_help_help ) ;
5546    MCW_register_hint( prog->button_help_pb , "Gets more help for a button" ) ;
5547 
5548    /*----- pushbutton: quit -----*/
5549 
5550    prog->quit_pb =
5551       XtVaCreateManagedWidget(
5552          "dialog" , xmPushButtonWidgetClass , prog->rc_bot ,
5553             LABEL_ARG("done ") ,
5554             XmNrecomputeSize , False ,
5555             XmNtraversalOn , True  ,
5556             XmNalignment   , XmALIGNMENT_CENTER ,
5557             XmNinitialResourcesPersistent , False ,
5558             XmNuserData , (XtPointer) im3d ,
5559          NULL ) ;
5560 
5561    MCW_set_widget_bg( prog->quit_pb , MCW_hotcolor(prog->quit_pb) , 0 ) ;
5562 
5563    XtAddCallback( prog->quit_pb , XmNactivateCallback ,
5564                   AFNI_quit_CB , im3d ) ;
5565    /* check for -disable_done                21 Aug 2008 [rickr] */
5566    XtSetSensitive( prog->quit_pb, GLOBAL_argopt.disable_done == 0 ) ;
5567 
5568    #if 0
5569    MCW_register_help( prog->quit_pb , AFNI_quit_help ) ;
5570    MCW_register_hint( prog->quit_pb , "Click twice to close window" ) ;
5571    #else
5572    SUMA_Register_Widget_Help(prog->quit_pb, 1, "AfniCont->ProgCont->done",
5573                              "Click twice to close window", AFNI_quit_help);
5574    #endif
5575    prog->quit_first = True ;  /* mark this button as not pressed yet */
5576 
5577    /*----- manage the managers -----*/
5578 
5579    if( prog->rc_top != NULL ) XtManageChild( prog->rc_top ) ;
5580    XtManageChild( prog->rc_bot ) ;
5581    XtManageChild( prog->rowcol ) ;
5582 
5583    /*----------------------------------------*/
5584    /*  for the overlapping panels, make the  */
5585    /*  help callback raise them to the top   */
5586    /*----------------------------------------*/
5587 
5588 #if 0
5589    XtAddCallback( marks->rowcol , XmNhelpCallback , AFNI_raiseup_CB , NULL ) ;
5590    XtAddCallback( func->rowcol  , XmNhelpCallback , AFNI_raiseup_CB , NULL ) ;
5591    XtAddCallback( dmode->rowcol , XmNhelpCallback , AFNI_raiseup_CB , NULL ) ;
5592 #endif
5593 
5594    /*-------------------------------------------------------------*/
5595    /*----- stuff here that goes below all else on popup menu -----*/
5596    /*-------------------------------------------------------------*/
5597 
5598    (void) XtVaCreateManagedWidget(
5599             "dialog" , xmSeparatorWidgetClass , imag->popmenu ,
5600                 XmNseparatorType , XmDOUBLE_LINE ,
5601             NULL ) ;
5602 
5603    /*--- label for background pixel ---*/
5604 
5605    imag->pop_bkgd_lab =
5606       XtVaCreateWidget(
5607          "dialog" , xmLabelWidgetClass , imag->popmenu ,
5608             LABEL_ARG("   bkgd =xxxxxx") ,
5609             XmNalignment , XmALIGNMENT_BEGINNING ,
5610             XmNrecomputeSize , True ,
5611             XmNtraversalOn , True  ,
5612             XmNinitialResourcesPersistent , False ,
5613          NULL ) ;
5614    LABELIZE(imag->pop_bkgd_lab) ;
5615    imag->do_bkgd_lab = False ;
5616 
5617    /*----------------------------------------------*/
5618    /**************  make a picture  ****************/
5619    /*----------------------------------------------*/
5620 
5621    vwid->picture       = NULL ;  /* default ==> no picture */
5622    vwid->picture_index = 0 ;
5623    vwid->tips_pb       = NULL ;  /* not always created */
5624    vwid->news_pb       = NULL ;  /* 15 May 2019 */
5625    vwid->forum_pb      = NULL ;  /* 17 May 2019 */
5626    vwid->ytube_pb      = NULL ;  /* 28 Apr 2020 discoraj */
5627 
5628 #ifdef WANT_LOGO_BITMAP
5629    if( im3d->type == AFNI_3DDATA_VIEW ){
5630       vwid->picture =
5631           XtVaCreateManagedWidget(
5632              "dialog" , xmLabelWidgetClass , vwid->top_form ,
5633                  XmNtopAttachment    , XmATTACH_WIDGET ,
5634                  XmNtopWidget        , imag->frame ,
5635                  XmNtopOffset        , 0 ,
5636                  XmNleftAttachment   , XmATTACH_WIDGET ,
5637                  XmNleftWidget       , prog->frame ,
5638                  XmNleftOffset       , 0 ,
5639                  XmNlabelType        , XmPIXMAP ,
5640                  XmNalignment        , XmALIGNMENT_CENTER ,
5641                  XmNwidth            , logo_width ,
5642                  XmNheight           , logo_height ,
5643                  XmNmarginWidth      , 0 ,
5644                  XmNmarginHeight     , 0 ,
5645                  XmNrecomputeSize    , False ,
5646                  XmNtraversalOn      , True  ,
5647                  XmNinitialResourcesPersistent , False ,
5648              NULL ) ;
5649       MCW_register_help( vwid->picture , AFNI_abohelp ) ;
5650 
5651       if( num_entry == 1 && !ALLOW_realtime ){
5652         vwid->tips_pb =
5653            XtVaCreateManagedWidget(
5654               "font8" , xmPushButtonWidgetClass , vwid->top_form ,
5655                  LABEL_ARG("Tips") ,
5656                  XmNleftAttachment   , XmATTACH_WIDGET ,
5657                  XmNleftWidget       , vwid->picture ,
5658                  XmNleftOffset       , TIPS_PLUS_SHIFT ,
5659                  XmNbottomAttachment , XmATTACH_OPPOSITE_WIDGET ,
5660                  XmNbottomWidget     , vwid->picture ,
5661                  XmNbottomOffset     , 2 ,
5662                  XmNshadowThickness  , 3 ,
5663                  XmNtraversalOn      , True  ,
5664                  XmNinitialResourcesPersistent , False ,
5665               NULL ) ;
5666         MCW_register_help( vwid->tips_pb , "Gives some help about\n"
5667                                            "parts of the AFNI GUI\n"
5668                                            "that are hard to find." ) ;
5669         MCW_register_hint( vwid->tips_pb , "Tips about AFNI interface" ) ;
5670         XtAddCallback( vwid->tips_pb , XmNactivateCallback ,
5671                        AFNI_tips_CB , im3d ) ;
5672         MCW_set_widget_bg( vwid->tips_pb , "#000044" , 0 ) ;
5673         MCW_set_widget_fg( vwid->tips_pb , "#ffddaa" ) ;
5674 
5675         /* ------------------ news -------------------------- */
5676         vwid->news_pb =                /* 15 May 2019 */
5677            XtVaCreateManagedWidget(
5678               "font8" , xmPushButtonWidgetClass , vwid->top_form ,
5679                  LABEL_ARG("News") ,
5680                  XmNleftAttachment   , XmATTACH_WIDGET ,
5681                  XmNleftWidget       , vwid->picture ,
5682                  XmNleftOffset       , TIPS_PLUS_SHIFT ,
5683                  XmNbottomAttachment , XmATTACH_WIDGET ,
5684                  XmNbottomWidget     , vwid->tips_pb ,
5685                  XmNbottomOffset     , 2 ,
5686                  XmNshadowThickness  , 3 ,
5687                  XmNtraversalOn      , True  ,
5688                  XmNinitialResourcesPersistent , False ,
5689               NULL ) ;
5690         MCW_register_help( vwid->news_pb , "Opens a web browser\n"
5691                                            "with the latest news\n"
5692                                            "about the AFNI package" ) ;
5693         MCW_register_hint( vwid->news_pb , "Web: News about AFNI" ) ;
5694         XtAddCallback( vwid->news_pb , XmNactivateCallback ,
5695                        AFNI_news_CB , im3d ) ;
5696         MCW_set_widget_bg( vwid->news_pb , "#003300" , 0 ) ;
5697         MCW_set_widget_fg( vwid->news_pb , "#ffffaa" ) ;
5698 
5699         /* ------------------ forum -------------------------- */
5700         vwid->forum_pb =                /* 17 May 2019 */
5701            XtVaCreateManagedWidget(
5702               "font8" , xmPushButtonWidgetClass , vwid->top_form ,
5703                  LABEL_ARG("Forum") ,
5704                  XmNleftAttachment   , XmATTACH_WIDGET ,
5705                  XmNleftWidget       , vwid->news_pb ,
5706                  XmNbottomAttachment , XmATTACH_WIDGET ,
5707                  XmNbottomWidget     , vwid->tips_pb ,
5708                  XmNbottomOffset     , 2 ,
5709                  XmNshadowThickness  , 3 ,
5710                  XmNtraversalOn      , True  ,
5711                  XmNinitialResourcesPersistent , False ,
5712               NULL ) ;
5713         MCW_register_help( vwid->forum_pb , "Opens a web browser\n"
5714                                             "with the AFNI Forum\n"
5715                                             "(Message Board)" ) ;
5716         MCW_register_hint( vwid->forum_pb , "Web: AFNI Message Board" ) ;
5717         XtAddCallback( vwid->forum_pb , XmNactivateCallback ,
5718                        AFNI_forum_CB , im3d ) ;
5719         MCW_set_widget_bg( vwid->forum_pb , "#003300" , 0 ) ;
5720         MCW_set_widget_fg( vwid->forum_pb , "#ffffaa" ) ;
5721 
5722         vwid->phelp_pb =                /* 17 May 2019 */
5723            XtVaCreateManagedWidget(
5724               "font8" , xmPushButtonWidgetClass , vwid->top_form ,
5725                  LABEL_ARG("Helps") ,
5726                  XmNleftAttachment   , XmATTACH_WIDGET ,
5727                  XmNleftWidget       , vwid->tips_pb ,
5728                  XmNbottomAttachment , XmATTACH_OPPOSITE_WIDGET ,
5729                  XmNbottomWidget     , vwid->picture ,
5730                  XmNbottomOffset     , 2 ,
5731                  XmNshadowThickness  , 3 ,
5732                  XmNtraversalOn      , True  ,
5733                  XmNinitialResourcesPersistent , False ,
5734               NULL ) ;
5735         MCW_register_help( vwid->phelp_pb , "Opens a web browser\n"
5736                                             "with Program Helps"   ) ;
5737         MCW_register_hint( vwid->phelp_pb , "Web: AFNI Program Helps" ) ;
5738         XtAddCallback( vwid->phelp_pb , XmNactivateCallback ,
5739                        AFNI_phelp_CB , im3d ) ;
5740         MCW_set_widget_bg( vwid->phelp_pb , "#003300" , 0 ) ;
5741         MCW_set_widget_fg( vwid->phelp_pb , "#ffffaa" ) ;
5742 
5743         /* ------------------ youtube -------------------------- */
5744         vwid->ytube_pb =                /* 28 Apr 2020 discoraj*/
5745            XtVaCreateManagedWidget(
5746               "font8" , xmPushButtonWidgetClass , vwid->top_form ,
5747                  LABEL_ARG("YouTube") ,
5748                  XmNleftAttachment   , XmATTACH_WIDGET ,
5749                  XmNleftWidget       , vwid->phelp_pb ,
5750                  XmNbottomAttachment , XmATTACH_OPPOSITE_WIDGET ,
5751                  XmNbottomWidget     , vwid->picture ,
5752                  XmNbottomOffset     , 2 ,
5753                  XmNshadowThickness  , 3 ,
5754                  XmNtraversalOn      , True  ,
5755                  XmNinitialResourcesPersistent , False ,
5756               NULL ) ;
5757         MCW_register_help( vwid->ytube_pb , "Opens a web browser\n"
5758                                             "to the AFNI Bootcamp\n"
5759                                             "Youtube channel" ) ;
5760         MCW_register_hint( vwid->ytube_pb , "Web: AFNI YouTube" ) ;
5761         XtAddCallback( vwid->ytube_pb , XmNactivateCallback ,
5762                        AFNI_ytube_CB , im3d ) ;
5763         MCW_set_widget_bg( vwid->ytube_pb , "#003300" , 0 ) ;
5764         MCW_set_widget_fg( vwid->ytube_pb , "#ffffaa" ) ;
5765       }
5766    }
5767 #else
5768    MCW_register_help( imag->rowcol  , AFNI_abohelp ) ;
5769    MCW_register_help( view->rowcol  , AFNI_abohelp ) ;
5770    MCW_register_help( marks->rowcol , AFNI_abohelp ) ;
5771    MCW_register_help( func->rowcol  , AFNI_abohelp ) ;
5772    MCW_register_help( dmode->rowcol , AFNI_abohelp ) ;
5773    MCW_register_help( prog->rowcol  , AFNI_abohelp ) ;
5774 #endif
5775 
5776    /*** load icon, if desired and possible ***/
5777 
5778 #ifdef WANT_AFNI_BITMAP
5779 #ifndef DONT_INSTALL_ICONS
5780    if( afni48_pixmap != XmUNSPECIFIED_PIXMAP ){
5781       RwcBoolean good ;
5782 
5783       good = MCW_check_iconsize( afni48_width,afni48_height , im3d->dc ) ;
5784 
5785       if( good ){
5786          XtVaSetValues( im3d->vwid->top_shell ,
5787                            XmNiconPixmap , afni48_pixmap ,
5788                         NULL ) ;
5789          afni48_good = 1 ;
5790       }
5791    }
5792 #endif
5793 #endif
5794 
5795    /*---------------------------------------------------*/
5796    /*********** hidden popup menu on picture ************/
5797    /*---------------------------------------------------*/
5798 
5799    prog->hidden_menu = NULL ;
5800 
5801 #ifdef USE_HIDDEN
5802    if( vwid->picture != NULL ){
5803 
5804      /** popup on picture widget (right of Quit button) **/
5805 
5806 #ifdef BAD_BUTTON3_POPUPS   /* 21 Jul 2003 */
5807      prog->hidden_menu =
5808         XmCreatePopupMenu( prog->quit_pb , "menu" , NULL , 0 ) ;
5809 #else
5810      prog->hidden_menu =
5811         XmCreatePopupMenu( vwid->picture , "menu" , NULL , 0 ) ;
5812 #endif
5813 
5814      if( prog->hidden_menu != NULL ){
5815       SAVEUNDERIZE(XtParent(prog->hidden_menu)) ; /* 27 Feb 2001 */
5816 
5817       VISIBILIZE_WHEN_MAPPED(prog->hidden_menu) ;
5818       if( !AFNI_yesenv("AFNI_DISABLE_TEAROFF") ) TEAROFFIZE(prog->hidden_menu) ;
5819 
5820 /***
5821       XtAddCallback( prog->hidden_menu ,
5822                      XmNunmapCallback , AFNI_hidden_CB , im3d ) ;
5823 ***/
5824 
5825 /***
5826       XtVaSetValues( prog->hidden_menu ,
5827                         XmNspacing      , 0 ,
5828                         XmNmarginHeight , 0 ,
5829                         XmNmarginWidth  , 0 ,
5830                      NULL ) ;
5831 ***/
5832 
5833       XtInsertEventHandler( vwid->picture ,      /* handle events in picture */
5834 
5835                                0
5836                              | ButtonPressMask   /* button presses */
5837                              | KeyPressMask      /* get keystrokes */
5838                             ,
5839                             FALSE ,              /* nonmaskable events? */
5840                             AFNI_hidden_EV ,     /* handler */
5841                             (XtPointer) im3d ,   /* client data */
5842                             XtListTail           /* last in queue */
5843                           ) ;
5844 
5845 #ifdef ALLOW_DATASET_VLIST
5846       /**--- pullright menu for points ---**/
5847 
5848       prog->hidden_pts_menu =
5849          XmCreatePulldownMenu( prog->hidden_menu , "menu" , NULL , 0 ) ;
5850 
5851       VISIBILIZE_WHEN_MAPPED(prog->hidden_pts_menu) ;
5852       if( !AFNI_yesenv("AFNI_DISABLE_TEAROFF") ) TEAROFFIZE(prog->hidden_pts_menu) ;
5853 
5854       /** cascade button to bring this menu up **/
5855 
5856       prog->hidden_pts_cbut =
5857          XtVaCreateManagedWidget(
5858             "dialog" , xmCascadeButtonWidgetClass , prog->hidden_menu ,
5859                LABEL_ARG("Points List") ,
5860                XmNsubMenuId , prog->hidden_pts_menu ,
5861                XmNtraversalOn , True  ,
5862                XmNinitialResourcesPersistent , False ,
5863             NULL ) ;
5864 
5865       /** "Read Pts: IJK" button in pts menu **/
5866 
5867       prog->hidden_readpts_ijk_pb =
5868          XtVaCreateManagedWidget(
5869             "dialog" , xmPushButtonWidgetClass , prog->hidden_pts_menu ,
5870                LABEL_ARG("Read Pts:  IJK") ,
5871                XmNmarginHeight , 0 ,
5872                XmNtraversalOn , True  ,
5873                XmNinitialResourcesPersistent , False ,
5874             NULL ) ;
5875 
5876       XtAddCallback( prog->hidden_readpts_ijk_pb , XmNactivateCallback ,
5877                      AFNI_hidden_CB , im3d ) ;
5878 
5879       /** "Read Pts: XYZ" button in pts menu **/
5880 
5881       prog->hidden_readpts_xyz_pb =
5882          XtVaCreateManagedWidget(
5883             "dialog" , xmPushButtonWidgetClass , prog->hidden_pts_menu ,
5884                LABEL_ARG("Read Pts:  XYZ") ,
5885                XmNmarginHeight , 0 ,
5886                XmNtraversalOn , True  ,
5887                XmNinitialResourcesPersistent , False ,
5888             NULL ) ;
5889 
5890       XtAddCallback( prog->hidden_readpts_xyz_pb , XmNactivateCallback ,
5891                      AFNI_hidden_CB , im3d ) ;
5892 
5893       /** "Write Pts: IJK" button in pts menu **/
5894 
5895       prog->hidden_writepts_ijk_pb =
5896          XtVaCreateManagedWidget(
5897             "dialog" , xmPushButtonWidgetClass , prog->hidden_pts_menu ,
5898                LABEL_ARG("Write Pts: IJK") ,
5899                XmNmarginHeight , 0 ,
5900                XmNtraversalOn , True  ,
5901                XmNinitialResourcesPersistent , False ,
5902             NULL ) ;
5903 
5904       XtAddCallback( prog->hidden_writepts_ijk_pb , XmNactivateCallback ,
5905                      AFNI_hidden_CB , im3d ) ;
5906 
5907       /** "Write Pts: XYZ" button in pts menu **/
5908 
5909       prog->hidden_writepts_xyz_pb =
5910          XtVaCreateManagedWidget(
5911             "dialog" , xmPushButtonWidgetClass , prog->hidden_pts_menu ,
5912                LABEL_ARG("Write Pts: XYZ") ,
5913                XmNmarginHeight , 0 ,
5914                XmNtraversalOn , True  ,
5915                XmNinitialResourcesPersistent , False ,
5916             NULL ) ;
5917 
5918       XtAddCallback( prog->hidden_writepts_xyz_pb , XmNactivateCallback ,
5919                      AFNI_hidden_CB , im3d ) ;
5920 
5921       /** "Set Pts: COLOR" button in pts menu **/
5922 
5923       prog->hidden_colorpts_pb =
5924          XtVaCreateManagedWidget(
5925             "dialog" , xmPushButtonWidgetClass , prog->hidden_pts_menu ,
5926                LABEL_ARG("Set Pts: COLOR") ,
5927                XmNmarginHeight , 0 ,
5928                XmNtraversalOn , True  ,
5929                XmNinitialResourcesPersistent , False ,
5930             NULL ) ;
5931 
5932       XtAddCallback( prog->hidden_colorpts_pb , XmNactivateCallback ,
5933                      AFNI_hidden_CB , im3d ) ;
5934 
5935       /*---- END OF PTS STUFF ----*/
5936 #endif
5937 
5938       /*--- put build date into menu header ---*/
5939 
5940       xstr = XmStringCreateLtoR( "Build: " __DATE__ , XmFONTLIST_DEFAULT_TAG ) ;
5941       wtemp = XtVaCreateManagedWidget(
5942                "dialog" , xmLabelWidgetClass , prog->hidden_menu ,
5943                   XmNlabelString , xstr ,
5944                   XmNrecomputeSize , False ,
5945                   XmNinitialResourcesPersistent , False ,
5946                NULL ) ; LABELIZE(wtemp) ; MCW_invert_widget(wtemp) ;
5947       XmStringFree(xstr) ;
5948 
5949       (void) XtVaCreateManagedWidget(
5950                "dialog" , xmSeparatorWidgetClass , prog->hidden_menu ,
5951                   XmNseparatorType , XmSINGLE_LINE ,
5952             NULL ) ;
5953 
5954       /*---- Various Poetry Options ----*/
5955 
5956       xstr = XmStringCreateLtoR( "---- Poetry, Etc ----" , XmFONTLIST_DEFAULT_TAG ) ;
5957       wtemp = XtVaCreateManagedWidget(
5958                "dialog" , xmLabelWidgetClass , prog->hidden_menu ,
5959                   XmNlabelString , xstr ,
5960                   XmNrecomputeSize , False ,
5961                   XmNinitialResourcesPersistent , False ,
5962                NULL ) ; LABELIZE(wtemp) ;
5963       XmStringFree(xstr) ;
5964 
5965       (void) XtVaCreateManagedWidget(
5966                "dialog" , xmSeparatorWidgetClass , prog->hidden_menu ,
5967                   XmNseparatorType , XmSINGLE_LINE ,
5968             NULL ) ;
5969 
5970       /*----------*/
5971 
5972       prog->hidden_mission_pb =
5973             XtVaCreateManagedWidget(
5974                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
5975                   LABEL_ARG("Mission Statement") ,
5976                   XmNmarginHeight , 0 ,
5977                   XmNtraversalOn , True  ,
5978                   XmNinitialResourcesPersistent , False ,
5979                NULL ) ;
5980       XtAddCallback( prog->hidden_mission_pb , XmNactivateCallback ,
5981                      AFNI_hidden_CB , im3d ) ;
5982 
5983       /*----------*/
5984 
5985       prog->hidden_uscon_pb =
5986             XtVaCreateManagedWidget(
5987                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
5988                   LABEL_ARG("US Constitution") ,
5989                   XmNmarginHeight , 0 ,
5990                   XmNtraversalOn , True  ,
5991                   XmNinitialResourcesPersistent , False ,
5992                NULL ) ;
5993       XtAddCallback( prog->hidden_uscon_pb , XmNactivateCallback ,
5994                      AFNI_hidden_CB , im3d ) ;
5995 
5996       /*----------*/
5997 
5998       prog->hidden_usdecl_pb =
5999             XtVaCreateManagedWidget(
6000                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6001                   LABEL_ARG("Decl of Independence") ,
6002                   XmNmarginHeight , 0 ,
6003                   XmNtraversalOn , True  ,
6004                   XmNinitialResourcesPersistent , False ,
6005                NULL ) ;
6006       XtAddCallback( prog->hidden_usdecl_pb , XmNactivateCallback ,
6007                      AFNI_hidden_CB , im3d ) ;
6008 
6009       /*----------*/
6010 
6011 #ifdef USE_SONNETS
6012       if( ! NO_frivolities ){
6013          prog->hidden_sonnet_pb =
6014             XtVaCreateManagedWidget(
6015                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6016                   LABEL_ARG("Pick a Sonnet") ,
6017                   XmNmarginHeight , 0 ,
6018                   XmNtraversalOn , True  ,
6019                   XmNinitialResourcesPersistent , False ,
6020                NULL ) ;
6021 
6022          XtAddCallback( prog->hidden_sonnet_pb , XmNactivateCallback ,
6023                         AFNI_sonnet_CB , im3d ) ;
6024       }
6025 #endif
6026 
6027       /*----------*/
6028 
6029       prog->hidden_gamberi_pb =
6030             XtVaCreateManagedWidget(
6031                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6032                   LABEL_ARG("Gamberi Cattivi") ,
6033                   XmNmarginHeight , 0 ,
6034                   XmNtraversalOn , True  ,
6035                   XmNinitialResourcesPersistent , False ,
6036                NULL ) ;
6037       XtAddCallback( prog->hidden_gamberi_pb , XmNactivateCallback ,
6038                      AFNI_hidden_CB , im3d ) ;
6039 
6040       /*----------*/
6041 
6042       prog->hidden_hbmjust_pb =
6043             XtVaCreateManagedWidget(
6044                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6045                   LABEL_ARG("HBM Justification") ,
6046                   XmNmarginHeight , 0 ,
6047                   XmNtraversalOn , True  ,
6048                   XmNinitialResourcesPersistent , False ,
6049                NULL ) ;
6050       XtAddCallback( prog->hidden_hbmjust_pb , XmNactivateCallback ,
6051                      AFNI_hidden_CB , im3d ) ;
6052 
6053       /*----------*/
6054 
6055       prog->hidden_melter_pb =
6056             XtVaCreateManagedWidget(
6057                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6058                   LABEL_ARG("Activate Omega-13") ,
6059                   XmNmarginHeight , 0 ,
6060                   XmNtraversalOn , True  ,
6061                   XmNinitialResourcesPersistent , False ,
6062                NULL ) ;
6063       XtAddCallback( prog->hidden_melter_pb , XmNactivateCallback ,
6064                      AFNI_hidden_CB , im3d ) ;
6065       MCW_set_widget_bg( prog->hidden_melter_pb , "black" , 0 ) ;
6066       MCW_set_widget_fg( prog->hidden_melter_pb , "#ffeeee" ) ;
6067 
6068       /*----------*/
6069 
6070       if( GLOBAL_library.sound_player != NULL ){
6071         prog->hidden_sound_pb =
6072               XtVaCreateManagedWidget(
6073                  "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6074                     LABEL_ARG("Play startup sound") ,
6075                     XmNmarginHeight , 0 ,
6076                     XmNtraversalOn , True  ,
6077                     XmNinitialResourcesPersistent , False ,
6078                  NULL ) ;
6079         XtAddCallback( prog->hidden_sound_pb , XmNactivateCallback ,
6080                        AFNI_hidden_CB , im3d ) ;
6081         MCW_set_widget_bg( prog->hidden_sound_pb , "#220077" , 0 ) ;
6082         MCW_set_widget_fg( prog->hidden_sound_pb , "#ffee00" ) ;
6083 
6084       /*----------*/
6085 
6086         prog->hidden_music_pb =
6087               XtVaCreateManagedWidget(
6088                  "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6089                     LABEL_ARG("Play random music") ,
6090                     XmNmarginHeight , 0 ,
6091                     XmNtraversalOn , True  ,
6092                     XmNinitialResourcesPersistent , False ,
6093                  NULL ) ;
6094         XtAddCallback( prog->hidden_music_pb , XmNactivateCallback ,
6095                        AFNI_hidden_CB , im3d ) ;
6096         MCW_set_widget_bg( prog->hidden_music_pb , "#110055" , 0 ) ;
6097         MCW_set_widget_fg( prog->hidden_music_pb , "#ffee22" ) ;
6098 
6099       } else {
6100 
6101        prog->hidden_sound_pb = prog->hidden_music_pb = NULL ;
6102 
6103       }
6104 
6105       /*----------*/
6106 
6107       (void) XtVaCreateManagedWidget(
6108                "dialog" , xmSeparatorWidgetClass , prog->hidden_menu ,
6109                   XmNseparatorType , XmSINGLE_LINE ,
6110             NULL ) ;
6111 
6112       prog->hidden_ranpoem_pb =
6113             XtVaCreateManagedWidget(
6114                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6115                   LABEL_ARG("Random Poem") ,
6116                   XmNmarginHeight , 0 ,
6117                   XmNtraversalOn , True  ,
6118                   XmNinitialResourcesPersistent , False ,
6119                NULL ) ;
6120       XtAddCallback( prog->hidden_ranpoem_pb , XmNactivateCallback ,
6121                      AFNI_hidden_CB , im3d ) ;
6122 
6123       /*----------*/
6124 
6125 #if !defined(NO_FRIVOLITIES)
6126       prog->hidden_faces_pb =
6127             XtVaCreateManagedWidget(
6128                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6129                   LABEL_ARG("All AFNI Faces") ,
6130                   XmNmarginHeight , 0 ,
6131                   XmNtraversalOn , True  ,
6132                   XmNinitialResourcesPersistent , False ,
6133                NULL ) ;
6134       XtAddCallback( prog->hidden_faces_pb , XmNactivateCallback ,
6135                      AFNI_hidden_CB , im3d ) ;
6136 #else
6137       prog->hidden_faces_pb = NULL ;
6138 #endif
6139 
6140       /*----------*/
6141 
6142 #if !defined(NO_FRIVOLITIES)
6143       prog->hidden_splashes_pb =           /* 12 Sep 2007 */
6144             XtVaCreateManagedWidget(
6145                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6146                   LABEL_ARG("All AFNI Splashes") ,
6147                   XmNmarginHeight , 0 ,
6148                   XmNtraversalOn , True  ,
6149                   XmNinitialResourcesPersistent , False ,
6150                NULL ) ;
6151       XtAddCallback( prog->hidden_splashes_pb , XmNactivateCallback ,
6152                      AFNI_hidden_CB , im3d ) ;
6153 #else
6154       prog->hidden_splashes_pb = NULL ;
6155 #endif
6156 
6157       /*----------*/
6158 
6159       prog->hidden_broutim_pb =            /* 06 Jun 2005 */
6160             XtVaCreateManagedWidget(
6161                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6162                   LABEL_ARG("Brodmann Areas: imag") ,
6163                   XmNmarginHeight , 0 ,
6164                   XmNtraversalOn , True  ,
6165                   XmNinitialResourcesPersistent , False ,
6166                NULL ) ;
6167       XtAddCallback( prog->hidden_broutim_pb , XmNactivateCallback ,
6168                      AFNI_broutim_CB , im3d ) ;
6169 
6170       /*----------*/
6171 
6172       prog->hidden_broutext_pb =            /* 21 Dec 2005 */
6173             XtVaCreateManagedWidget(
6174                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6175                   LABEL_ARG("Brodmann Areas: text") ,
6176                   XmNmarginHeight , 0 ,
6177                   XmNtraversalOn , True  ,
6178                   XmNinitialResourcesPersistent , False ,
6179                NULL ) ;
6180       XtAddCallback( prog->hidden_broutext_pb , XmNactivateCallback ,
6181                      AFNI_broutext_CB , im3d ) ;
6182 
6183       /*----------*/
6184 
6185       prog->hidden_pvalue_pb =             /* 06 Mar 2014 */
6186          XtVaCreateManagedWidget(
6187             "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6188                LABEL_ARG("Meaning of p-values") ,
6189                XmNmarginHeight , 0 ,
6190                XmNtraversalOn , True  ,
6191                XmNinitialResourcesPersistent , False ,
6192             NULL ) ;
6193       XtAddCallback( prog->hidden_pvalue_pb , XmNactivateCallback ,
6194                      AFNI_pvalue_CB , im3d ) ;
6195       MCW_set_widget_bg( prog->hidden_pvalue_pb,PVALUE_COLOR,0) ;
6196 
6197       /*----------*/
6198 
6199       prog->hidden_papers_pb =             /* 02 May 2014 */
6200          XtVaCreateManagedWidget(
6201             "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6202                LABEL_ARG("List of AFNI papers") ,
6203                XmNmarginHeight , 0 ,
6204                XmNtraversalOn , True  ,
6205                XmNinitialResourcesPersistent , False ,
6206             NULL ) ;
6207       XtAddCallback( prog->hidden_papers_pb , XmNactivateCallback ,
6208                      AFNI_papers_CB , im3d ) ;
6209       MCW_set_widget_bg( prog->hidden_papers_pb,"#0044aa",0) ;
6210       MCW_set_widget_fg( prog->hidden_papers_pb,"#ffff00") ;
6211 
6212 #ifdef  USE_QQQQ
6213       /*----------*/
6214       { Widget qqqb =
6215          XtVaCreateManagedWidget(
6216             "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6217                LABEL_ARG("TCSV test") ,
6218                XmNmarginHeight , 0 ,
6219                XmNtraversalOn , True  ,
6220                XmNinitialResourcesPersistent , False ,
6221             NULL ) ;
6222         XtAddCallback( qqqb , XmNactivateCallback , AFNI_qqqq_CB , im3d ) ;
6223       }
6224 #endif
6225 
6226       /*----------*/
6227 
6228       (void) XtVaCreateManagedWidget(
6229                "dialog" , xmSeparatorWidgetClass , prog->hidden_menu ,
6230                   XmNseparatorType , XmSINGLE_LINE ,
6231             NULL ) ;
6232 
6233 #if 0
6234       prog->hidden_speech_pb =
6235             XtVaCreateManagedWidget(
6236                "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6237                   LABEL_ARG("Say Something") ,
6238                   XmNmarginHeight , 0 ,
6239                   XmNtraversalOn , True  ,
6240                   XmNinitialResourcesPersistent , False ,
6241                NULL ) ;
6242       XtAddCallback( prog->hidden_speech_pb , XmNactivateCallback ,
6243                      AFNI_hidden_CB , im3d ) ;
6244 #else
6245       prog->hidden_speech_pb = NULL ;
6246 #endif
6247 
6248       /*---------- modified 30 Dec 2005 ----------*/
6249 
6250       if( GLOBAL_browser != NULL ){
6251         prog->hidden_browser_pb =
6252               XtVaCreateManagedWidget(
6253                  "dialog" , xmPushButtonWidgetClass , prog->hidden_menu ,
6254                     LABEL_ARG("Web Browser: Help") ,
6255                     XmNmarginHeight , 0 ,
6256                     XmNtraversalOn , True  ,
6257                     XmNinitialResourcesPersistent , False ,
6258                  NULL ) ;
6259         XtAddCallback( prog->hidden_browser_pb , XmNactivateCallback ,
6260                        AFNI_hidden_CB , im3d ) ;
6261       } else {
6262         prog->hidden_browser_pb = NULL ;
6263       }
6264 
6265     } /* if prog->hidden_menu isn't NULL */
6266    }
6267 #endif  /* USE_HIDDEN */
6268 
6269    EXRETURN ;
6270 }
6271 
6272 /*--------------------------------------------------------------------------
6273    Find out how many controller windows are active at this instant
6274 ----------------------------------------------------------------------------*/
6275 
AFNI_count_controllers(void)6276 int AFNI_count_controllers(void)
6277 {
6278    int ii , cnt ;
6279 
6280 ENTRY("AFNI_count_controllers") ;
6281 
6282    for( ii=0,cnt=0 ; ii < MAX_CONTROLLERS ; ii++ )
6283       if( IM3D_OPEN(GLOBAL_library.controllers[ii]) ) cnt++ ;
6284 
6285    RETURN(cnt) ;
6286 }
6287 
6288 /*-------------------------------------------------------------------*/
6289 /*! Find first open controller [05 Mar 2002].
6290 ---------------------------------------------------------------------*/
6291 
AFNI_find_open_controller(void)6292 Three_D_View * AFNI_find_open_controller(void)
6293 {
6294    int ii ;
6295    for( ii=0 ; ii < MAX_CONTROLLERS ; ii++ )
6296      if( IM3D_OPEN(GLOBAL_library.controllers[ii]) )
6297        return GLOBAL_library.controllers[ii] ;
6298 
6299    return NULL ;  /* should be impossible */
6300 }
6301 
6302 /*-------------------------------------------------------------------*/
6303 /*! Popup a message, somewhere, anywhere [05 Mar 2002].
6304 ---------------------------------------------------------------------*/
6305 
AFNI_popup_message(char * str)6306 void AFNI_popup_message( char *str )
6307 {
6308    Three_D_View *im3d ;
6309    if( str == NULL || str[0] == '\0' ) return ;
6310    im3d = AFNI_find_open_controller() ;
6311    (void)MCW_popup_message( im3d->vwid->prog->clone_pb ,
6312                             str, MCW_USER_KILL|MCW_TIMER_KILL ) ;
6313    return ;
6314 }
6315 
6316 /*-------------------------------------------------------------------
6317   Find out which controller this is.  Return -1 if there is an error.
6318 ---------------------------------------------------------------------*/
6319 
AFNI_controller_index(Three_D_View * im3d)6320 int AFNI_controller_index( Three_D_View *im3d )
6321 {
6322    int ii ;
6323 
6324 ENTRY("AFNI_controller_index") ;
6325 
6326    if( ! IM3D_VALID(im3d) ) RETURN(-1) ;
6327 
6328    for( ii=0 ; ii < MAX_CONTROLLERS ; ii++ )
6329      if( GLOBAL_library.controllers[ii] == im3d ) RETURN(ii) ;
6330 
6331    RETURN(-1) ;
6332 }
6333 
6334 /*---------------------------------------------------------------------------
6335    Create and return a new controller for AFNI.
6336    Inputs:
6337    "shell" is a top level shell, to contain the entire widget hierarchy.
6338       If this shell is NULL, then the routine will create it.
6339       Normally, you would pass in the results of XtVaAppInitialize
6340       as the first controller's shell, and let the routine create
6341       any subsequent shells needed.
6342    "dc" must be created by MCW_new_DC before this routine.  It contains
6343       all the information pertaining to the X11 display.
6344    "im3d_type" is one of AFNI_3DDATA_VIEW or AFNI_IMAGES_VIEW.  The former
6345       is for viewing 3D datasets; the latter is a restricted version for
6346       viewing images only (mostly obsolete now -- use program aiv instead).
6347 -----------------------------------------------------------------------------*/
6348 
new_AFNI_controller(Widget shell,MCW_DC * dc,int im3d_type)6349 Three_D_View * new_AFNI_controller( Widget shell , MCW_DC *dc , int im3d_type )
6350 {
6351    Three_D_View *im3d ;
6352    int ii , last_color ;
6353 
6354 ENTRY("new_AFNI_controller") ;
6355 
6356    /*-- create the basic stuff --*/
6357 
6358    im3d = myXtNew(Three_D_View) ; INIT_KILL(im3d->kl) ;
6359 
6360    im3d->vwid   = myXtNew(AFNI_widget_set) ; ADDTO_KILL(im3d->kl,im3d->vwid) ;
6361    im3d->type   = im3d_type ;
6362    im3d->opened = 0 ;          /* not yet opened up */
6363    im3d->dc     = dc ;
6364    im3d->vinfo  = myXtNew( AFNI_view_info ); ADDTO_KILL(im3d->kl,im3d->vinfo);
6365 
6366    flush_vinfo_sort(im3d->vinfo, NULL);     /* ZSS April 26 2012 */
6367 
6368    im3d->brand_new = 1 ; /* 07 Dec 2001 */
6369 
6370    /* 27 Jan 2004: mark if this currently looking at dummy dataset */
6371 
6372    im3d->dummied = GLOBAL_library.have_dummy_dataset ;
6373 
6374    im3d->fimdata = myXtNew( AFNI_fimmer_type ); ADDTO_KILL(im3d->kl,im3d->fimdata);
6375    CLEAR_FIMDATA(im3d) ;
6376 
6377    strcpy( im3d->window_title , "GPL AFNI" ) ;
6378 
6379    if( shell != NULL ){
6380       im3d->vwid->top_shell = shell ;
6381    } else {
6382       im3d->vwid->top_shell = XtVaAppCreateShell(
6383                                  "AFNI" , "AFNI" ,
6384                                     topLevelShellWidgetClass , dc->display ,
6385                                     XmNinitialResourcesPersistent , False ,
6386               XmNkeyboardFocusPolicy , XmEXPLICIT ,
6387                                  NULL ) ;
6388    }
6389 
6390    DC_yokify( im3d->vwid->top_shell , dc ) ;
6391 
6392    XtVaSetValues( im3d->vwid->top_shell ,
6393                      XmNtitle    , im3d->window_title ,
6394                      XmNallowShellResize , True ,       /* let code resize shell */
6395                      XmNdeleteResponse , XmDO_NOTHING , /* deletion handled below */
6396                   NULL ) ;
6397 
6398    /* make "Close" window menu work if user has not blocked the action */
6399    if( GLOBAL_argopt.disable_done == 0 )
6400       XmAddWMProtocolCallback(
6401            im3d->vwid->top_shell ,
6402            XmInternAtom( dc->display , "WM_DELETE_WINDOW" , False ) ,
6403            AFNI_quit_CB , NULL ) ;
6404 
6405    if( MCW_isitmwm( im3d->vwid->top_shell ) )
6406       XtVaSetValues( im3d->vwid->top_shell ,
6407                         XmNmwmDecorations ,
6408                         MWM_DECOR_ALL | MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE ,
6409                      NULL ) ;
6410 
6411    /*----- null out datasets  -----*/
6412 
6413    for( ii=0 ; ii <= LAST_VIEW_TYPE ; ii++ ){
6414       im3d->anat_dset[ii] = im3d->fim_dset[ii] = NULL ;
6415    }
6416    im3d->anat_now = im3d->fim_now = NULL ;
6417    im3d->ss_now = NULL ;
6418 
6419    /* create the rest of the AFNI control data */
6420 
6421    last_color = im3d->dc->ovc->ncol_ov - 1 ;
6422 
6423    im3d->vinfo->crosshair_gap     = INIT_crosshair_gap ;
6424    im3d->vinfo->crosshair_gap_old = 0 ;
6425    im3d->vinfo->crosshair_visible = True ;                /* show crosshairs */
6426    im3d->vinfo->crosshair_ovcolor = MIN(last_color,INIT_crosshair_color) ;
6427    im3d->vinfo->time_index        = 0 ;
6428    im3d->vinfo->top_index         = 9 ;
6429    im3d->vinfo->time_on           = 0 ;                   /* 29 Jul 2003 */
6430    im3d->vinfo->view_type         = VIEW_ORIGINAL_TYPE ;  /* show +orig data */
6431    im3d->vinfo->underlay_type     = UNDERLAY_ANAT ;       /* show anatomy */
6432    im3d->vinfo->force_anat_wod    = False ;   /* don't force warp-on-demand */
6433    im3d->vinfo->force_func_wod    = False ;   /* don't force warp-on-demand */
6434    im3d->vinfo->func_visible      = (RwcBoolean)AFNI_yesenv("AFNI_SEE_OVERLAY") ;
6435    im3d->vinfo->func_visible_count  = 0 ;
6436    im3d->vinfo->func_init_subbricks = 0 ;
6437 #ifdef ALLOW_DATASET_VLIST
6438    im3d->vinfo->pts_visible       = False ;   /* don't show points */
6439    im3d->vinfo->pts_color         = 0 ;
6440 #endif
6441    im3d->vinfo->show_voxind       = False ;
6442    im3d->vinfo->resam_vox         = INIT_resam_vox ;
6443    im3d->vinfo->anat_resam_mode   = INIT_resam_anat ;
6444    im3d->vinfo->func_resam_mode   = INIT_resam_func ;
6445    im3d->vinfo->thr_resam_mode    = INIT_resam_thr ;
6446    im3d->vinfo->func_threshold    = 0.5 ;
6447    im3d->vinfo->inverted_pause    = False ;
6448 
6449    im3d->vinfo->use_autorange     = True ;   /* use automatic FIM range */
6450    im3d->vinfo->fim_range         = DEFAULT_FIM_SCALE ;
6451    im3d->vinfo->fim_autorange     = DEFAULT_FIM_SCALE ;
6452    im3d->vinfo->use_posfunc       = GLOBAL_argopt.pos_func ;
6453 
6454    im3d->vinfo->anat_index        = 0 ;  /* 30 Nov 1997 */
6455    im3d->vinfo->fim_index         = 0 ;
6456    im3d->vinfo->thr_index         = 0 ;
6457 
6458    im3d->vinfo->tempflag          = 0 ;  /* 15 Mar 2000 */
6459    im3d->vinfo->see_ttatlas       = 0 ;  /* 25 Jul 2001 */
6460 
6461    im3d->vinfo->stats_anat_ok =
6462     im3d->vinfo->stats_func_ok =
6463      im3d->vinfo->arang_func_ok =
6464       im3d->vinfo->stats_thresh_ok = 0 ; /* 29 Mar 2005 */
6465 
6466    /* Feb 1998: receive stuff, including drawing */
6467    /* Mar 1999: modified to allow for multiple receivers */
6468 
6469    im3d->vinfo->receiver          = AFMALL( AFNI_receiver*, sizeof(AFNI_receiver *));
6470    im3d->vinfo->receiver[0]       = NULL ;
6471    im3d->vinfo->num_receiver      = 0 ;
6472    im3d->vinfo->drawing_enabled   = 0 ;
6473    im3d->vinfo->drawing_mode      = DRAWING_LINES ;
6474    im3d->vinfo->drawing_pixel     = 0 ;
6475 
6476    /** July 1996: set up the montage crosshair stuff **/
6477 
6478    LOAD_IVEC3(im3d->vinfo->xhairs_ndown,0,0,0) ;
6479    LOAD_IVEC3(im3d->vinfo->xhairs_nup  ,0,0,0) ;
6480    LOAD_IVEC3(im3d->vinfo->xhairs_nskip,0,0,0) ;
6481    im3d->vinfo->xhairs_show_montage = True ;
6482    im3d->vinfo->xhairs_periodic     = INIT_montage_periodic ;
6483    im3d->vinfo->xhairs_all          = False ;
6484 
6485    /** June 1996: stuff for interactive FIM **/
6486 
6487    im3d->s123 = im3d->s231 = im3d->s312 = NULL ; /* no viewing windows yet */
6488    im3d->g123 = im3d->g231 = im3d->g312 = NULL ; /* no graphing windows yet */
6489 
6490    im3d->b123_anat = im3d->b231_anat = im3d->b312_anat =           /* created later */
6491     im3d->b123_fim  = im3d->b231_fim  = im3d->b312_fim  =
6492      im3d->b123_ulay = im3d->b231_ulay = im3d->b312_ulay = NULL ;
6493 
6494    im3d->ignore_seq_callbacks = AFNI_IGNORE_NOTHING ;   /* don't ignore these now */
6495 
6496    /* set up which datasets to deal with (defaults) */
6497 
6498    im3d->vinfo->sess_num = 0 ;  /* 1st session */
6499    im3d->vinfo->anat_num = 0 ;  /* 1st dataset */
6500    im3d->vinfo->func_num = 0 ;  /* 1st dataset */
6501 
6502    AFNI_make_widgets( im3d ) ;  /* rest of the widgets */
6503 
6504    /* 02 Nov 1996: create daxes and voxwarp spaces for viewing */
6505 
6506    im3d->wod_daxes          = myXtNew(THD_dataxes) ;
6507    im3d->wod_daxes->type    = DATAXES_TYPE ;
6508 
6509    im3d->anat_voxwarp       = myXtNew(THD_warp) ;
6510    im3d->anat_voxwarp->type = ILLEGAL_TYPE ;
6511 
6512    im3d->fim_voxwarp        = myXtNew(THD_warp) ;
6513    im3d->fim_voxwarp->type  = ILLEGAL_TYPE ;
6514 
6515    im3d->fim_selfwarp       = NULL ;  /* 27 Aug 2002 */
6516 
6517    im3d->cont_bbox = 0;            /* initialize the continuous color settings */
6518    im3d->cont_pos_only = 0;
6519    im3d->cont_autorange = 1;
6520    im3d->cont_range_fval = 1.0;
6521    im3d->first_integral = -1;
6522    im3d->cont_perc_thr = 0; /* No percentile thresholding. ZSS: April 27 2012 */
6523 
6524    IM3D_CLEAR_THRSTAT(im3d) ;  /* 12 Jun 2014 */
6525 
6526    RETURN(im3d) ;
6527 }
6528 
6529 /*---------------------------------------------------------------*/
6530 
DSET_bigositiness(THD_3dim_dataset * dset)6531 static float DSET_bigositiness( THD_3dim_dataset *dset ) /* 07 Dec 2001 */
6532 {
6533    float bb ;
6534 
6535    if( !DSET_ONDISK(dset) ) return -1 ;
6536 
6537    bb =  DSET_NVOX(dset)
6538        * DSET_NVALS(dset)
6539        * mri_datum_size(DSET_BRICK_TYPE(dset,0)) ;
6540 
6541    if( DSET_COMPRESSED(dset) || DSET_IS_MINC(dset) ) bb *= 1.666f ;
6542 
6543    return bb ;
6544 }
6545 
6546 /*---------------------------------------------------------------
6547    Set up the controller with some data to view!
6548 -----------------------------------------------------------------*/
6549 
AFNI_initialize_controller(Three_D_View * im3d)6550 void AFNI_initialize_controller( Three_D_View *im3d )
6551 {
6552    int ii , sss=0 ;
6553    char ttl[16] , *eee ;
6554    THD_3dim_dataset *temp_dset = NULL;
6555 
6556 ENTRY("AFNI_initialize_controller") ;
6557 
6558    /*--- check for various criminal behavior;
6559          the sentence for anything illegal is death ---*/
6560 
6561    if( ! IM3D_VALID(im3d) )
6562      ERROR_exit("\n** AFNI_initialize_controller: invalid input **\n") ;
6563 
6564    if( GLOBAL_library.sslist == NULL )  /* any data to use? */
6565       ERROR_exit(
6566               "\n** AFNI_initialize_controller: no sessions to view **\n") ;
6567 
6568    im3d->ss_now = GLOBAL_library.sslist->ssar[ im3d->vinfo->sess_num ] ;
6569 
6570    if( im3d->ss_now == NULL ){     /* bad choice of initial session! */
6571 
6572       im3d->vinfo->sess_num = 0 ;  /* reset 1st session */
6573       im3d->vinfo->anat_num = 0 ;  /* reset 1st anatomy */
6574       im3d->vinfo->func_num = 0 ;  /* reset 1st function */
6575 
6576       im3d->ss_now = GLOBAL_library.sslist->ssar[ im3d->vinfo->sess_num ] ;
6577 
6578       if( im3d->ss_now == NULL )  /* still no data? */
6579         ERROR_exit(
6580                 "\n** AFNI_initialize_controller: illegal initial session **\n") ;
6581    }
6582 
6583    /* 07 Dec 2001: find "smallest" datasets for startup */
6584 
6585    eee = my_getenv("AFNI_START_SMALL") ;
6586    if( eee != NULL ){
6587      char ccc = toupper(eee[0]) ;
6588      sss = (ccc == 'Y') ? 1
6589           :(ccc == 'O') ? 2 : 0 ;
6590    }
6591    if( im3d->brand_new && sss ){
6592      int jj,jb=0,qb=0 ; float bb,mm ;
6593      switch( sss ){
6594        case 2:       /* the OLD way */
6595          for( mm=1.e+33,jb=jj=0 ; jj < im3d->ss_now->num_dsset ; jj++ ){
6596            temp_dset = GET_SESSION_DSET(im3d->ss_now, jj,0);
6597            if( ISANAT(temp_dset) ){
6598              bb = DSET_bigositiness(temp_dset) ;
6599              if( bb > 0 && bb < mm ){ mm = bb; jb = jj; }
6600            }
6601          }
6602          if( mm < 1.e+33 ) im3d->vinfo->anat_num = qb = jb ;
6603          for( mm=1.e+33,jb=jj=0 ; jj < im3d->ss_now->num_dsset ; jj++ ){
6604            temp_dset = GET_SESSION_DSET(im3d->ss_now, jj,0);
6605            if( ISFUNC(temp_dset) ){
6606              bb = DSET_bigositiness(temp_dset) ;
6607              if( jj != qb && bb > 0 && bb < mm ){ mm = bb; jb = jj; }
6608            }
6609          }
6610          if( mm < 1.e+33 ) im3d->vinfo->func_num = jb ;
6611        break ;
6612 
6613        case 1:
6614          for( mm=1.e+33,jb=jj=0 ; jj < im3d->ss_now->num_dsset ; jj++ ){
6615            temp_dset = GET_SESSION_DSET(im3d->ss_now, jj,0);
6616            if( ISVALID_DSET(temp_dset) ){
6617              bb = DSET_bigositiness(temp_dset) ;
6618              if( bb > 0.0f && bb < mm ){ mm = bb; jb = jj; }
6619            }
6620          }
6621          if( mm < 1.e+33 ) im3d->vinfo->func_num = im3d->vinfo->anat_num = jb ;
6622        break ;
6623      }
6624 
6625    } else if( im3d->brand_new ){  /* 29 Jul 2003 */
6626      int jj ;
6627      for( jj=0 ; jj < im3d->ss_now->num_dsset ; jj++ ) {
6628        temp_dset = GET_SESSION_DSET(im3d->ss_now, jj,0);
6629        if( ISANAT(temp_dset) ) break ;
6630      }
6631      if( jj < im3d->ss_now->num_dsset ) im3d->vinfo->anat_num = jj ;
6632 
6633      for( jj=0 ; jj < im3d->ss_now->num_dsset ; jj++ ) {
6634        temp_dset = GET_SESSION_DSET(im3d->ss_now, jj,0);
6635        if( ISFUNC(temp_dset) ) break ;
6636      }
6637      if( jj < im3d->ss_now->num_dsset ) im3d->vinfo->func_num = jj ;
6638    }
6639 
6640    /* copy pointers from this session into the controller for fast access */
6641 
6642    for( ii=0 ; ii <= LAST_VIEW_TYPE ; ii++ )
6643       im3d->anat_dset[ii] = GET_SESSION_DSET(im3d->ss_now, im3d->vinfo->anat_num, ii);
6644       /* im3d->ss_now->dsset_xform_table[im3d->vinfo->anat_num][ii] ; */
6645 
6646    /*--- 11/23/94 addition: scan for a good view in the
6647         initial setup (to allow for input of datasets w/o +orig view) */
6648 
6649    for( ii=0 ; ii <= LAST_VIEW_TYPE ; ii++ )
6650       if( ISVALID_DSET(im3d->anat_dset[ii]) ) break ;
6651 
6652    if( ii > LAST_VIEW_TYPE )
6653       ERROR_exit("\n   AFNI_initialize_controller: cannot initialize view **\n") ;
6654 
6655    im3d->vinfo->view_type = ii ;  /* first view with a good anat */
6656 
6657    /* now find a function that can be viewed here */
6658    temp_dset = GET_SESSION_DSET(im3d->ss_now, im3d->vinfo->func_num, ii);
6659 
6660    if( !ISVALID_DSET(temp_dset) ){
6661      for( ii=0 ; ii < im3d->ss_now->num_dsset ; ii++ ){
6662        temp_dset = GET_SESSION_DSET(im3d->ss_now, ii, im3d->vinfo->view_type);
6663        if(ISVALID_DSET(temp_dset)){
6664           im3d->vinfo->func_num = ii ; break ;
6665        }
6666      }
6667    }
6668 
6669    for( ii=0 ; ii <= LAST_VIEW_TYPE ; ii++ )
6670         im3d->fim_dset[ii] = GET_SESSION_DSET(im3d->ss_now, im3d->vinfo->func_num, ii);
6671 
6672 /*      im3d->fim_dset[ii] = im3d->ss_now->dsset_xform_table[im3d->vinfo->func_num][ii] ;*/
6673 
6674    /*--- 11/23/94 addition end */
6675 
6676    im3d->anat_now = im3d->anat_dset[im3d->vinfo->view_type] ;  /* will not be NULL */
6677    im3d->fim_now  = im3d->fim_dset [im3d->vinfo->view_type] ;  /* this may be NULL */
6678    if( !ISVALID_DSET(im3d->fim_now) ) AFNI_SEE_FUNC_OFF(im3d) ;     /* 22 May 2009 */
6679    else                               CLU_setup_alpha_tables(im3d) ;   /* Jul 2010 */
6680 
6681    /* initial point of view = middle of dataset brick */
6682 
6683    im3d->vinfo->i1 = im3d->anat_now->daxes->nxx / 2 ;  /* integer indexes */
6684    im3d->vinfo->j2 = im3d->anat_now->daxes->nyy / 2 ;
6685    im3d->vinfo->k3 = im3d->anat_now->daxes->nzz / 2 ;
6686    SAVE_VPT(im3d) ;
6687 
6688    im3d->vinfo->i1_icor = im3d->vinfo->j2_icor = im3d->vinfo->k3_icor = -1 ;
6689 
6690    if( im3d->type == AFNI_3DDATA_VIEW ){  /* compute float coordinates, too */
6691       THD_fvec3 fv ;
6692 
6693       im3d->anat_now->wod_flag = 0 ;  /* 02 Nov 1996 */
6694 
6695       fv = THD_3dind_to_3dmm( im3d->anat_now ,
6696                               TEMP_IVEC3( im3d->vinfo->i1 ,
6697                                           im3d->vinfo->j2 ,
6698                                           im3d->vinfo->k3  ) ) ;
6699 
6700       fv = THD_3dmm_to_dicomm( im3d->anat_now , fv ) ;
6701 
6702       im3d->vinfo->xi = fv.xyz[0] ;  /* set display coords */
6703       im3d->vinfo->yj = fv.xyz[1] ;  /* to Dicom standard  */
6704       im3d->vinfo->zk = fv.xyz[2] ;
6705 
6706    } else {
6707       im3d->vinfo->xi = im3d->vinfo->i1 ;  /* probably never used */
6708       im3d->vinfo->yj = im3d->vinfo->j2 ;
6709       im3d->vinfo->zk = im3d->vinfo->k3 ;
6710    }
6711 
6712    /** set various widgets and values **/
6713 
6714    MCW_set_bbox( im3d->vwid->view->view_bbox     , 1 << im3d->vinfo->view_type ) ;
6715    MCW_set_bbox( im3d->vwid->view->see_func_bbox , (im3d->vinfo->func_visible) ? 1 : 0 ) ;
6716 
6717    LOAD_IVEC3(im3d->vinfo->xhairs_ndown,0,0,0) ;
6718    LOAD_IVEC3(im3d->vinfo->xhairs_nup  ,0,0,0) ;
6719    LOAD_IVEC3(im3d->vinfo->xhairs_nskip,0,0,0) ;
6720    im3d->vinfo->xhairs_periodic = INIT_montage_periodic ;
6721    MCW_set_bbox( im3d->vwid->imag->wrap_bbox  , im3d->vinfo->xhairs_periodic ? 1 : 0 ) ;
6722    MCW_set_bbox( im3d->vwid->imag->xhall_bbox , im3d->vinfo->xhairs_all      ? 1 : 0 ) ;
6723 
6724    CLEAR_FIMDATA(im3d) ;
6725 
6726    sprintf(ttl , "%sAFNI" , AFNI_controller_label(im3d) ) ;
6727    XtVaSetValues( im3d->vwid->top_shell , XmNiconName , ttl , NULL ) ;
6728 
6729    /* 06 Dec 2001: cool cursor stuff */
6730 
6731    WAIT_for_window( im3d->vwid->top_shell ) ;
6732 
6733    POPUP_cursorize( im3d->vwid->func->thr_label ) ;       /* 05 Sep 2006 */
6734 #ifdef PVAL_POPUP
6735    POPUP_cursorize( im3d->vwid->func->thr_pval_label ) ;  /* 05 Sep 2006 */
6736 #endif
6737    POPUP_cursorize( im3d->vwid->func->inten_label ) ;
6738    POPUP_cursorize( im3d->vwid->func->options_label ) ;
6739    POPUP_cursorize( im3d->vwid->func->range_label ) ;
6740    POPUP_cursorize( im3d->vwid->picture ) ;
6741    POPUP_cursorize( imag->crosshair_label ) ;
6742    POPUP_cursorize( im3d->vwid->func->thr_label ) ;
6743    POPUP_cursorize( im3d->vwid->imag->time_index_av->wlabel ) ;
6744 
6745    if( im3d->vwid->view->marks_enabled ){
6746      SHIFT_TIPS( im3d , TIPS_MINUS_SHIFT ) ;
6747      SHIFT_NEWS( im3d , TIPS_MINUS_SHIFT ) ;
6748    }
6749 
6750    /* Set index step from environment [26 Feb 2014] */
6751 
6752                  ii = (int)AFNI_numenv("AFNI_INDEX_STEP"  ) ;
6753    if( ii <= 0 ) ii = (int)AFNI_numenv("AFNI_INDEX_STRIDE") ;
6754    if( ii >  0 ) AFNI_time_index_set_fstep(im3d,ii) ;
6755 
6756    RESET_AFNI_QUIT(im3d) ;
6757    EXRETURN ;
6758 }
6759 
6760 /*---------------------------------------------------------------------------
6761   23 Sep 2000: A hack to allow the creation of a specific controller,
6762                instead of letting AFNI_clone_controller_CB choose the index.
6763 -----------------------------------------------------------------------------*/
6764 
6765 static int cii_override = -1 ;
6766 
AFNI_make_controller(int cii)6767 void AFNI_make_controller( int cii )
6768 {
6769 ENTRY("AFNI_make_controller") ;
6770 
6771    if( cii < 0 || cii >= MAX_CONTROLLERS ||
6772        IM3D_VALID(GLOBAL_library.controllers[cii]) ) EXRETURN ;
6773 
6774    cii_override = cii ;
6775    AFNI_clone_controller_CB( GLOBAL_library.controllers[0]->vwid->prog->clone_pb ,
6776                              GLOBAL_library.controllers[0] , NULL ) ;
6777 
6778    cii_override = -1 ;
6779    EXRETURN ;
6780 }
6781 
6782 /*---------------------------------------------------------------------------*/
6783 
AFNI_clone_controller_CB(Widget wcall,XtPointer cd,XtPointer cbs)6784 void AFNI_clone_controller_CB( Widget wcall , XtPointer cd , XtPointer cbs )
6785 {
6786    int ii , xx , yy ;
6787    Three_D_View *im3d ;
6788    Three_D_View *caller_im3d = (Three_D_View *)cd ;
6789    MCW_DC *new_dc , *old_dc ;
6790 
6791 ENTRY("AFNI_clone_controller_CB") ;
6792 
6793    ii = AFNI_count_controllers() ;
6794    if( ii >= MAX_CONTROLLERS ) EXRETURN ;
6795 
6796    SHOW_AFNI_PAUSE ;
6797 
6798    /** 23 Sep 2000: if cii_override is set, use that for
6799                     the index of the controller to create **/
6800 
6801    if( cii_override < 0 ){
6802       /** look for a previously opened but now closed controller **/
6803 
6804       for( ii=0 ; ii < MAX_CONTROLLERS ; ii++ ){
6805          im3d = GLOBAL_library.controllers[ii] ;
6806          if( IM3D_VALID(im3d) && ! im3d->opened ) break ;  /* found it */
6807       }
6808    } else {
6809       ii = MAX_CONTROLLERS ;  /* skip this step */
6810    }
6811 
6812    if( ii >= MAX_CONTROLLERS ){          /* look for an empty one to create */
6813 
6814       if( cii_override < 0 ){
6815          for( ii=0 ; ii < MAX_CONTROLLERS ; ii++ ){
6816             im3d = GLOBAL_library.controllers[ii] ;
6817             if( im3d == NULL ) break ;
6818          }
6819       } else {
6820          ii = cii_override ;
6821       }
6822       if( ii >= MAX_CONTROLLERS ){       /* something funny has happened! */
6823          SHOW_AFNI_READY ; EXRETURN ;
6824       }
6825 
6826       /* 06 Nov 1996: allow creation of unique dc's for each controller */
6827 
6828       new_dc = NULL ;
6829       old_dc = GLOBAL_library.dc ;
6830       if( GLOBAL_argopt.unique_dcs )
6831          new_dc = MCW_new_DC( wcall , GLOBAL_argopt.ncolor ,
6832                               INIT_ncolovr , INIT_colovr , INIT_labovr ,
6833                               GLOBAL_argopt.gamma , 0 ) ;
6834 
6835       if( new_dc == NULL ) new_dc = old_dc ;
6836 
6837       GLOBAL_library.controllers[ii] =
6838         new_AFNI_controller( NULL , new_dc , AFNI_3DDATA_VIEW ) ;
6839 
6840       if( caller_im3d != NULL ){
6841         MCW_widget_geom( caller_im3d->vwid->top_shell , NULL,NULL , &xx,&yy ) ;
6842         xx += 15 ; yy += 15 ;
6843         XtVaSetValues( GLOBAL_library.controllers[ii]->vwid->top_shell ,
6844                        XmNx , xx , XmNy , yy , NULL ) ;
6845       }
6846    }
6847 
6848    /** at this point, ii = index of a controller to use **/
6849 
6850    im3d = GLOBAL_library.controllers[ii] ;
6851 
6852    if( caller_im3d != NULL ) DISABLE_LOCK ;
6853 
6854    OPEN_CONTROLLER( im3d ) ; /* will return when window is open */
6855 
6856    AFNI_initialize_controller( im3d ) ;  /* decide what to see */
6857    AFNI_initialize_view( NULL , im3d ) ;   /* set up to see it */
6858 
6859    AFNI_controller_clonify() ;
6860 
6861    AFNI_vedit_CB( im3d->vwid->func->options_vedit_av, im3d ) ; /* 05 May 2009 */
6862 
6863    AFNI_coord_filer_setup(im3d) ; /* 07 May 2010 */
6864 
6865    if( caller_im3d != NULL ){     /* 03 Jul 2014 */
6866      ENABLE_LOCK ;
6867      AFNI_all_locks_carryout( caller_im3d ) ;
6868    }
6869 
6870    if( im3d->vwid->func->do_setup ){ /* 24 May 2019 */
6871      int ii = (int)AFNI_numenv("AFNI_THRESH_INIT_EXPON") ;
6872      if( ii > 0 && ii < THR_top_expon ) AFNI_set_thresh_itop(im3d,ii) ;
6873      im3d->vwid->func->do_setup = 0 ;
6874    }
6875 
6876    PICTURE_OFF(im3d) ; SHOW_AFNI_READY ; EXRETURN ;
6877 }
6878 
6879 /*-----------------------------------------------------------------------
6880    Called to determine if the "New" button should be active
6881 -------------------------------------------------------------------------*/
6882 
AFNI_controller_clonify(void)6883 void AFNI_controller_clonify(void)
6884 {
6885    Three_D_View *im3d ;
6886    int id ;
6887    RwcBoolean clone_on ;
6888 
6889 ENTRY("AFNI_controller_clonify") ;
6890 
6891    if( MAX_CONTROLLERS <= 1 ) EXRETURN ;
6892 
6893    clone_on = (RwcBoolean)( AFNI_count_controllers() < MAX_CONTROLLERS ) ;
6894 
6895    for( id=0 ; id < MAX_CONTROLLERS ; id++ ){
6896       im3d = GLOBAL_library.controllers[id] ;
6897       if( IM3D_OPEN(im3d) && im3d->vwid->prog->clone_pb != NULL ){
6898          SENSITIZE( im3d->vwid->prog->clone_pb , clone_on ) ;
6899          RESET_AFNI_QUIT(im3d) ;
6900       }
6901    }
6902 
6903    EXRETURN ;
6904 }
6905 
6906 /*-------------------------------------------------------------------------
6907    04 Nov 1996: make a menubar to control the coordinate locking
6908                 of the various controller windows
6909                 [buttons rearranged 05 May 2020]
6910 ---------------------------------------------------------------------------*/
6911 
AFNI_lock_button(Three_D_View * im3d)6912 void AFNI_lock_button( Three_D_View *im3d )
6913 {
6914    Widget rc , mbar , menu , cbut , wpar ;
6915    XmString xstr ;
6916 
6917    static char *clabel[] = {  /* never more than 26 controllers! */
6918       "Lock [A]", "Lock [B]", "Lock [C]", "Lock [D]", "Lock [E]",
6919       "Lock [F]", "Lock [G]", "Lock [H]", "Lock [I]", "Lock [J]",
6920       "Lock [K]", "Lock [L]", "Lock [M]", "Lock [N]", "Lock [O]",
6921       "Lock [P]", "Lock [Q]", "Lock [R]", "Lock [S]", "Lock [T]",
6922       "Lock [U]", "Lock [V]", "Lock [W]", "Lock [X]", "Lock [Y]", "Lock [Z]" } ;
6923 
6924    static char *tlabel[]   = { "Time lock" } ;
6925    static char *ijklabel[] = { "IJK lock"  } ;
6926    static char *zplabel[]  = { "Zoom lock" } ;
6927 
6928 ENTRY("AFNI_lock_button") ;
6929 
6930    wpar = im3d->vwid->dmode->mbar_rowcol ;
6931 
6932    rc =  XtVaCreateWidget(
6933            "dialog" , xmRowColumnWidgetClass , wpar ,
6934               XmNorientation , XmHORIZONTAL ,
6935               XmNpacking , XmPACK_TIGHT ,
6936               XmNtraversalOn , True  ,
6937               XmNinitialResourcesPersistent , False ,
6938            NULL ) ;
6939 
6940    mbar = XmCreateMenuBar( rc , "dialog" , NULL,0 ) ;
6941    XtVaSetValues( mbar ,
6942                      XmNmarginWidth  , 0 ,
6943                      XmNmarginHeight , 0 ,
6944                      XmNspacing      , 3 ,
6945                      XmNborderWidth  , 0 ,
6946                      XmNborderColor  , 0 ,
6947                      XmNtraversalOn  , True  ,
6948                      XmNbackground   , im3d->dc->ovc->pixov_brightest ,
6949                   NULL ) ;
6950    XtManageChild( mbar ) ;
6951 
6952    menu = XmCreatePulldownMenu( mbar , "menu" , NULL,0 ) ;
6953 
6954    VISIBILIZE_WHEN_MAPPED(menu) ;
6955    if( !AFNI_yesenv("AFNI_DISABLE_TEAROFF") ) TEAROFFIZE(menu) ;
6956 
6957    xstr = XmStringCreateLtoR( "Lock" , XmFONTLIST_DEFAULT_TAG ) ;
6958    cbut = XtVaCreateManagedWidget(
6959             "dialog" , xmCascadeButtonWidgetClass , mbar ,
6960                XmNlabelString , xstr ,
6961                XmNsubMenuId , menu ,
6962                XmNmarginWidth  , 0 ,
6963                XmNmarginHeight , 0 ,
6964                XmNmarginBottom , 0 ,
6965                XmNmarginTop    , 0 ,
6966                XmNmarginRight  , 0 ,
6967                XmNmarginLeft   , 0 ,
6968                XmNtraversalOn  , True  ,
6969                XmNinitialResourcesPersistent , False ,
6970             NULL ) ;
6971    XmStringFree( xstr ) ;
6972 
6973    MCW_register_help( cbut , "Pressing this drops down\n"
6974                              "the menu of controllers\n"
6975                              "which should be 'locked'\n"
6976                              "together in their viewpoint\n"
6977                              "coordinates.\n"
6978                              "N.B.: The lock will only take\n"
6979                              " effect when you next move\n"
6980                              " the crosshairs, or click\n"
6981                              " on the 'Enforce All' button."
6982                     ) ;
6983    MCW_register_hint( cbut , "Lock AFNI controller viewpoints" ) ;
6984 
6985    /*** top of menu = a label to click on that does nothing at all ***/
6986 
6987    /* This --- Cancel --- label does not cause the hangup, so it is
6988    left alone. See related comments in afni_graph.c
6989                            LessTif patrol, Jan 07 09 */
6990    xstr = XmStringCreateLtoR( "-- Cancel --" , XmFONTLIST_DEFAULT_TAG ) ;
6991    wtemp = XtVaCreateManagedWidget(
6992             "dialog" , xmLabelWidgetClass , menu ,
6993                XmNlabelString , xstr ,
6994                XmNrecomputeSize , False ,
6995                XmNinitialResourcesPersistent , False ,
6996             NULL ) ;
6997    XmStringFree(xstr) ; LABELIZE(wtemp) ;
6998 
6999    (void) XtVaCreateManagedWidget(
7000             "dialog" , xmSeparatorWidgetClass , menu ,
7001                XmNseparatorType , XmSINGLE_LINE ,
7002             NULL ) ;
7003 
7004    /*** to clear all locks right now ***/
7005 
7006    xstr = XmStringCreateLtoR( "Clear All" , XmFONTLIST_DEFAULT_TAG ) ;
7007    dmode->lock_clear_pb =
7008          XtVaCreateManagedWidget(
7009             "dialog" , xmPushButtonWidgetClass , menu ,
7010                XmNlabelString , xstr ,
7011                XmNmarginHeight , 0 ,
7012                XmNtraversalOn , True  ,
7013                XmNinitialResourcesPersistent , False ,
7014             NULL ) ;
7015    XtAddCallback( dmode->lock_clear_pb , XmNactivateCallback ,
7016                   AFNI_lock_clear_CB , (XtPointer)im3d ) ;
7017    XmStringFree(xstr) ;
7018    MCW_register_hint( dmode->lock_clear_pb , "Clear all locked controllers" ) ;
7019    MCW_set_widget_bg( dmode->lock_clear_pb , "#002288" , 0 ) ;
7020 
7021    (void) XtVaCreateManagedWidget(
7022             "dialog" , xmSeparatorWidgetClass , menu ,
7023                XmNseparatorType , XmSINGLE_LINE ,
7024             NULL ) ;
7025 
7026    /*** to set all locks right now [19 Apr 1999] ***/
7027 
7028    xstr = XmStringCreateLtoR( "Set All" , XmFONTLIST_DEFAULT_TAG ) ;
7029    dmode->lock_setall_pb =
7030          XtVaCreateManagedWidget(
7031             "dialog" , xmPushButtonWidgetClass , menu ,
7032                XmNlabelString , xstr ,
7033                XmNmarginHeight , 0 ,
7034                XmNtraversalOn , True  ,
7035                XmNinitialResourcesPersistent , False ,
7036             NULL ) ;
7037    XtAddCallback( dmode->lock_setall_pb , XmNactivateCallback ,
7038                   AFNI_lock_setall_CB , (XtPointer)im3d ) ;
7039    XmStringFree(xstr) ;
7040    MCW_register_hint( dmode->lock_setall_pb , "Set all locked controllers" ) ;
7041    MCW_set_widget_bg( dmode->lock_setall_pb , "#882200" , 0 ) ;
7042 
7043    (void) XtVaCreateManagedWidget(
7044             "dialog" , xmSeparatorWidgetClass , menu ,
7045                XmNseparatorType , XmSINGLE_LINE ,
7046             NULL ) ;
7047 
7048    /*** to enforce locks right now ***/
7049 
7050    xstr = XmStringCreateLtoR( "Enforce All" , XmFONTLIST_DEFAULT_TAG ) ;
7051    dmode->lock_enforce_pb =
7052          XtVaCreateManagedWidget(
7053             "dialog" , xmPushButtonWidgetClass , menu ,
7054                XmNlabelString , xstr ,
7055                XmNmarginHeight , 0 ,
7056                XmNtraversalOn , True  ,
7057                XmNinitialResourcesPersistent , False ,
7058             NULL ) ;
7059    XtAddCallback( dmode->lock_enforce_pb , XmNactivateCallback ,
7060                   AFNI_lock_enforce_CB , (XtPointer)im3d ) ;
7061    XmStringFree(xstr) ;
7062    MCW_register_hint( dmode->lock_enforce_pb , "Make lock work NOW" ) ;
7063    MCW_set_widget_bg( dmode->lock_enforce_pb , "#443344" , 0 ) ;
7064 
7065    /*** button box to control the time lock ***/
7066 
7067    (void) XtVaCreateManagedWidget(
7068             "dialog" , xmSeparatorWidgetClass , menu ,
7069                XmNseparatorType , XmSINGLE_LINE ,
7070             NULL ) ;
7071 
7072    dmode->time_lock_bbox = new_MCW_bbox( menu ,
7073                                          1 , tlabel ,
7074                                          MCW_BB_check , MCW_BB_noframe ,
7075                                          AFNI_time_lock_change_CB , (XtPointer)im3d ) ;
7076    MCW_set_bbox( dmode->time_lock_bbox , GLOBAL_library.time_lock ) ;
7077    MCW_reghint_children( dmode->time_lock_bbox->wrowcol ,
7078                          "Lock time index as well?" ) ;
7079 
7080    dmode->ijk_lock_bbox = new_MCW_bbox( menu ,
7081                                         1 , ijklabel ,
7082                                         MCW_BB_check , MCW_BB_noframe ,
7083                                         AFNI_ijk_lock_change_CB , (XtPointer)im3d ) ;
7084    MCW_set_bbox( dmode->ijk_lock_bbox , GLOBAL_library.ijk_lock ) ;
7085    MCW_reghint_children( dmode->ijk_lock_bbox->wrowcol ,
7086                          "Space lock using voxel indices?" ) ;
7087 
7088     /* zoom/pan locking [10 Dec 2019] */
7089 
7090     dmode->zoompan_lock_bbox = new_MCW_bbox( menu ,
7091                                           1 , zplabel ,
7092                                           MCW_BB_check , MCW_BB_noframe ,
7093                                           AFNI_zoompan_lock_change_CB , (XtPointer)im3d ) ;
7094     MCW_set_bbox( dmode->zoompan_lock_bbox , GLOBAL_library.zoompan_lock ) ;
7095     MCW_reghint_children( dmode->zoompan_lock_bbox->wrowcol ,
7096                           "Lock zooming/panning?" ) ;
7097 
7098    /*** button box to control the threshold lock ***/
7099 
7100    { static char *thr_lock_label[3] = { "Free Thresh",
7101                                         "Lock Val" ,
7102                                         "Lock pVal"  } ;
7103      static char *rng_lock_label[1] = { "Lock Range" } ; int rr=0 ;
7104      static char *pbar_lock_label[1]= { "Lock Pbar"  } ; int pp=0 ;
7105 
7106      GLOBAL_library.thr_lock = AFNI_thresh_lock_env_val();
7107      dmode->thr_lock_bbox =
7108             new_MCW_bbox( menu ,
7109                           3 ,
7110                           thr_lock_label ,
7111                           MCW_BB_radio_zero ,
7112                           MCW_BB_frame ,
7113                           AFNI_func_thrlock_change_CB,
7114                           (XtPointer)im3d );
7115      MCW_set_bbox( dmode->thr_lock_bbox, 1<<GLOBAL_library.thr_lock);
7116      MCW_reghint_children( dmode->thr_lock_bbox->wrowcol ,
7117                             "Lock overlay thresholds?" ) ;
7118 
7119      rr = AFNI_yesenv("AFNI_RANGE_LOCK") ;
7120      dmode->rng_lock_bbox =
7121             new_MCW_bbox( menu ,
7122                           1 ,
7123                           rng_lock_label ,
7124                           MCW_BB_radio_zero ,
7125                           MCW_BB_frame ,
7126                           AFNI_func_rnglock_change_CB,
7127                           (XtPointer)im3d );
7128      MCW_set_bbox( dmode->rng_lock_bbox, rr ) ;
7129      MCW_reghint_children( dmode->rng_lock_bbox->wrowcol ,
7130                             "Lock overlay ranges?" ) ;
7131 
7132      pp = AFNI_check_pbar_lock() ;
7133      dmode->pbar_lock_bbox =
7134             new_MCW_bbox( menu ,
7135                           1 ,
7136                           pbar_lock_label ,
7137                           MCW_BB_radio_zero ,
7138                           MCW_BB_frame ,
7139                           AFNI_func_pbarlock_change_CB,
7140                           (XtPointer)im3d );
7141      MCW_set_bbox( dmode->pbar_lock_bbox, pp ) ;
7142      MCW_reghint_children( dmode->pbar_lock_bbox->wrowcol ,
7143                             "Lock overlay color pbars?" ) ;
7144     }
7145 
7146    /*** pushbuttons ***/
7147 
7148    (void) XtVaCreateManagedWidget(
7149             "dialog" , xmSeparatorWidgetClass , menu ,
7150                XmNseparatorType , XmSINGLE_LINE ,
7151             NULL ) ;
7152 
7153    /*** button box to select locks [moved 05 May 2020] ***/
7154 
7155    dmode->lock_bbox = new_MCW_bbox( menu ,
7156                                     MAX_CONTROLLERS , clabel ,
7157                                     MCW_BB_check , MCW_BB_noframe ,
7158                                     AFNI_lock_change_CB , (XtPointer)im3d ) ;
7159 
7160    MCW_set_bbox( dmode->lock_bbox , GLOBAL_library.controller_lock ) ;
7161 
7162    MCW_reghint_children( dmode->lock_bbox->wrowcol ,
7163                          "Which ones are locked together?" ) ;
7164 
7165    XtManageChild( rc ) ;
7166    EXRETURN ;
7167 }
7168 
7169 /*---------------------------------------------------------------------
7170    30 Oct 1997: make a menubar for miscellaneous options
7171 -----------------------------------------------------------------------*/
7172 
AFNI_misc_button(Three_D_View * im3d)7173 void AFNI_misc_button( Three_D_View *im3d )
7174 {
7175    Widget rc , mbar , menu , cbut , wpar ;
7176    XmString xstr ;
7177 
7178 ENTRY("AFNI_misc_button") ;
7179 
7180    wpar = im3d->vwid->dmode->mbar_rowcol ;
7181 
7182    rc =  XtVaCreateWidget(
7183            "dialog" , xmRowColumnWidgetClass , wpar ,
7184               XmNorientation , XmHORIZONTAL ,
7185               XmNpacking , XmPACK_TIGHT ,
7186               XmNtraversalOn , True  ,
7187               XmNinitialResourcesPersistent , False ,
7188            NULL ) ;
7189 
7190    mbar = XmCreateMenuBar( rc , "dialog" , NULL,0 ) ;
7191    XtVaSetValues( mbar ,
7192                      XmNmarginWidth  , 0 ,
7193                      XmNmarginHeight , 0 ,
7194                      XmNspacing      , 3 ,
7195                      XmNborderWidth  , 0 ,
7196                      XmNborderColor  , 0 ,
7197                      XmNtraversalOn  , True  ,
7198                      XmNbackground   , im3d->dc->ovc->pixov_brightest ,
7199                   NULL ) ;
7200    XtManageChild( mbar ) ;
7201 
7202    menu = XmCreatePulldownMenu( mbar , "menu" , NULL,0 ) ;
7203 
7204    VISIBILIZE_WHEN_MAPPED(menu) ;
7205    if( !AFNI_yesenv("AFNI_DISABLE_TEAROFF") ) TEAROFFIZE(menu) ;
7206 
7207    xstr = XmStringCreateLtoR( "Misc" , XmFONTLIST_DEFAULT_TAG ) ;
7208    cbut = XtVaCreateManagedWidget(
7209             "dialog" , xmCascadeButtonWidgetClass , mbar ,
7210                XmNlabelString , xstr ,
7211                XmNsubMenuId , menu ,
7212                XmNmarginWidth  , 0 ,
7213                XmNmarginHeight , 0 ,
7214                XmNmarginBottom , 0 ,
7215                XmNmarginTop    , 0 ,
7216                XmNmarginRight  , 0 ,
7217                XmNmarginLeft   , 0 ,
7218                XmNtraversalOn  , True  ,
7219                XmNinitialResourcesPersistent , False ,
7220             NULL ) ;
7221    XmStringFree( xstr ) ;
7222 
7223    MCW_register_help( cbut , "Pressing this drops down the menu\n"
7224                              "of miscellaneous options:\n"
7225 #ifdef USE_WRITEOWNSIZE
7226                              " Write=Own size?   = Write dataset using current\n"
7227                              "                      anat dimensions, or using\n"
7228                              "                      size of dataset in its own\n"
7229                              "                      .HEAD file.\n"
7230 #endif
7231                              " Voxel Coords?     = Show crosshair location\n"
7232                              "                      in mm or voxel indexes\n"
7233 #ifndef DONT_USE_HINTS
7234                              " Show Hints?       = Turn popup hints\n"
7235                              "                      off or on\n"
7236 #endif
7237                              " ULay Info         = Show 3dinfo output\n"
7238                              " OLay Info         = for current datasets\n"
7239 #ifdef ALLOW_PLUGINS
7240                              " Edit Environment  = Control environment vars\n"
7241                              " Edit 2DChain      = Control 2DChain function\n"
7242 #endif
7243                              " Save Layout       = Save windows layout/setup\n"
7244                              " Run Script        = Run an AFNI script file\n"
7245                              " License Info      = GPL & Copyright notice\n"
7246                              " Version Check     = Check AFNI version\n"
7247                              " Message of the Day= Fetch current AFNI MotD\n"
7248                              " Purge Memory      = Of dataset BRIKs\n"
7249 #ifdef USE_TRACING
7250                              " Trace=MODE        = Set trace mode to\n"
7251                              "                      next legal setting\n"
7252 #endif
7253 #ifdef USING_MCW_MALLOC
7254                              " Malloc Summary    = Show memory usage\n"
7255                              " Dump Malloc Table = Memory usage to a file"
7256 #endif
7257                            ) ;
7258    MCW_register_hint( cbut , "Miscellaneous options" ) ;
7259 
7260    /*** top of menu = a label to click on that does nothing at all ***/
7261 
7262    /* This --- Cancel --- label does not cause the hangup, so it is
7263    left alone. See related comments in afni_graph.c
7264                            LessTif patrol, Jan 07 09 */
7265    xstr = XmStringCreateLtoR( "-- Cancel --" , XmFONTLIST_DEFAULT_TAG ) ;
7266    wtemp = XtVaCreateManagedWidget(
7267             "dialog" , xmLabelWidgetClass , menu ,
7268                XmNlabelString , xstr ,
7269                XmNrecomputeSize , False ,
7270                XmNinitialResourcesPersistent , False ,
7271             NULL ) ;
7272    XmStringFree(xstr) ; LABELIZE(wtemp) ;
7273 
7274    (void) XtVaCreateManagedWidget(
7275             "dialog" , xmSeparatorWidgetClass , menu ,
7276                XmNseparatorType , XmSINGLE_LINE ,
7277             NULL ) ;
7278 
7279 #ifdef USE_WRITEOWNSIZE
7280    /*-- 01 Aug 1999: Toggle for Write dimensions --*/
7281 
7282    { char *blab[1] = { "Write=Own Size?" } ;
7283      dmode->misc_writeownsize_bbox = new_MCW_bbox( menu ,
7284                                                    1 , blab ,
7285                                                    MCW_BB_check , MCW_BB_noframe ,
7286                                                    AFNI_misc_CB , (XtPointer)im3d ) ;
7287      dmode->misc_writeownsize_pb = dmode->misc_writeownsize_bbox->wbut[0] ;
7288    }
7289    MCW_register_hint( dmode->misc_writeownsize_pb , "Controls dimensions using Write" ) ;
7290 #else
7291    dmode->misc_writeownsize_pb = NULL ;
7292 #endif
7293 
7294    /*-- pushbutton for voxel index toggle --*/
7295 
7296    /* 01 Aug 1999: replace pushbutton with toggle button */
7297 
7298    { char *blab[1] = { "Voxel Coords?" } ;
7299      dmode->misc_voxind_bbox = new_MCW_bbox( menu ,
7300                                              1 , blab ,
7301                                              MCW_BB_check , MCW_BB_noframe ,
7302                                              AFNI_misc_CB , (XtPointer)im3d ) ;
7303      dmode->misc_voxind_pb = dmode->misc_voxind_bbox->wbut[0] ;
7304    }
7305    MCW_register_hint( dmode->misc_voxind_pb , "Toggle coordinate display" ) ;
7306 
7307     /*-- pushbutton to turn hints on and off --*/
7308 
7309 #ifndef DONT_USE_HINTS
7310    { char *hh = getenv("AFNI_HINTS") ;
7311      if( hh != NULL && ( strncmp(hh,"KILL",4)==0 ||
7312                          strncmp(hh,"kill",4)==0 ||
7313                          strncmp(hh,"Kill",4)==0 ) ){
7314 
7315             dmode->misc_hints_pb =
7316                XtVaCreateManagedWidget(
7317                   "dialog" , xmLabelWidgetClass , menu ,
7318                      LABEL_ARG("*Hints Killed*") ,
7319                      XmNmarginHeight , 0 ,
7320                      XmNrecomputeSize , False ,
7321                      XmNinitialResourcesPersistent , False ,
7322                   NULL ) ; LABELIZE(dmode->misc_hints_pb) ;
7323 
7324          } else {
7325             { char *blab[1] = { "Show Hints?" } ;
7326               dmode->misc_hints_bbox = new_MCW_bbox( menu ,
7327                                                      1 , blab ,
7328                                                      MCW_BB_check , MCW_BB_noframe ,
7329                                                      AFNI_misc_CB , (XtPointer)im3d ) ;
7330               dmode->misc_hints_pb = dmode->misc_hints_bbox->wbut[0] ;
7331             }
7332             MCW_register_hint( dmode->misc_hints_pb , "Toggle hints display" ) ;
7333             MCW_set_bbox( dmode->misc_hints_bbox , GLOBAL_library.hints_on ) ;
7334          }
7335    }
7336 #else
7337    dmode->misc_hints_pb = NULL ;
7338 #endif
7339 
7340    /*-- pushbuttons to popup info about datasets --*/
7341 
7342    dmode->misc_anat_info_pb =
7343          XtVaCreateManagedWidget(
7344             "dialog" , xmPushButtonWidgetClass , menu ,
7345                LABEL_ARG("ULay Info") ,
7346                XmNmarginHeight , 0 ,
7347                XmNtraversalOn , True  ,
7348                XmNinitialResourcesPersistent , False ,
7349             NULL ) ;
7350    XtAddCallback( dmode->misc_anat_info_pb , XmNactivateCallback ,
7351                   AFNI_misc_CB , im3d ) ;
7352    MCW_register_hint( dmode->misc_anat_info_pb , "Popup anat dataset info" ) ;
7353 
7354    dmode->misc_func_info_pb =
7355          XtVaCreateManagedWidget(
7356             "dialog" , xmPushButtonWidgetClass , menu ,
7357                LABEL_ARG("OLay Info") ,
7358                XmNmarginHeight , 0 ,
7359                XmNtraversalOn , True  ,
7360                XmNinitialResourcesPersistent , False ,
7361             NULL ) ;
7362    XtAddCallback( dmode->misc_func_info_pb , XmNactivateCallback ,
7363                   AFNI_misc_CB , im3d ) ;
7364    MCW_register_hint( dmode->misc_func_info_pb , "Popup func dataset info" ) ;
7365 
7366    /*--- 20 Jun 2000: pushbutton to popup the Environment pseudo-plugin ---*/
7367 
7368 #ifdef ALLOW_PLUGINS
7369    (void) XtVaCreateManagedWidget(
7370             "dialog" , xmSeparatorWidgetClass , menu ,
7371                XmNseparatorType , XmSINGLE_LINE ,
7372             NULL ) ;
7373 
7374    dmode->misc_environ_pb =                              /* 20 Jun 2000 */
7375          XtVaCreateManagedWidget(
7376             "dialog" , xmPushButtonWidgetClass , menu ,
7377                LABEL_ARG("Edit Environment") ,
7378                XmNmarginHeight , 0 ,
7379                XmNtraversalOn , True  ,
7380                XmNinitialResourcesPersistent , False ,
7381             NULL ) ;
7382    XtAddCallback( dmode->misc_environ_pb , XmNactivateCallback ,
7383                   AFNI_misc_CB , im3d ) ;
7384    MCW_register_hint( dmode->misc_environ_pb , "Control environment variables" ) ;
7385 
7386    dmode->misc_1dchain_pb =                              /* 03 Jul 2000 */
7387          XtVaCreateManagedWidget(
7388             "dialog" , xmPushButtonWidgetClass , menu ,
7389                LABEL_ARG("Edit 1DChain") ,
7390                XmNmarginHeight , 0 ,
7391                XmNtraversalOn , True  ,
7392                XmNinitialResourcesPersistent , False ,
7393             NULL ) ;
7394    XtAddCallback( dmode->misc_1dchain_pb , XmNactivateCallback ,
7395                   AFNI_misc_CB , im3d ) ;
7396    MCW_register_hint( dmode->misc_1dchain_pb , "Control 1DChain function" ) ;
7397    AFNI_misc_CB( dmode->misc_1dchain_pb , im3d , NULL ) ;
7398 
7399    dmode->misc_2dchain_pb =                              /* 03 Jul 2000 */
7400          XtVaCreateManagedWidget(
7401             "dialog" , xmPushButtonWidgetClass , menu ,
7402                LABEL_ARG("Edit 2DChain") ,
7403                XmNmarginHeight , 0 ,
7404                XmNtraversalOn , True  ,
7405                XmNinitialResourcesPersistent , False ,
7406             NULL ) ;
7407    XtAddCallback( dmode->misc_2dchain_pb , XmNactivateCallback ,
7408                   AFNI_misc_CB , im3d ) ;
7409    MCW_register_hint( dmode->misc_2dchain_pb , "Control 2DChain function" ) ;
7410    AFNI_misc_CB( dmode->misc_2dchain_pb , im3d , NULL ) ;
7411 #endif
7412 
7413    /*--- 23 Sep 2000: Save Layout [see afni_splash.c] ---*/
7414 
7415    dmode->misc_savelayout_pb =
7416          XtVaCreateManagedWidget(
7417             "dialog" , xmPushButtonWidgetClass , menu ,
7418                LABEL_ARG("Save Layout") ,
7419                XmNmarginHeight , 0 ,
7420                XmNtraversalOn , True  ,
7421                XmNinitialResourcesPersistent , False ,
7422             NULL ) ;
7423    XtAddCallback( dmode->misc_savelayout_pb , XmNactivateCallback ,
7424                   AFNI_save_layout_CB , im3d ) ;
7425    MCW_register_hint( dmode->misc_savelayout_pb , "Save layout to file (or .script)" ) ;
7426 
7427    /*--- 22 Jan 2003: Run Script [see afni_splash.c] ---*/
7428 
7429    dmode->misc_runscript_pb =
7430          XtVaCreateManagedWidget(
7431             "dialog" , xmPushButtonWidgetClass , menu ,
7432                LABEL_ARG("Run Script") ,
7433                XmNmarginHeight , 0 ,
7434                XmNtraversalOn , True  ,
7435                XmNinitialResourcesPersistent , False ,
7436             NULL ) ;
7437    XtAddCallback( dmode->misc_runscript_pb , XmNactivateCallback ,
7438                   AFNI_run_script_CB , im3d ) ;
7439    MCW_register_hint( dmode->misc_runscript_pb , "Run an AFNI script file" ) ;
7440 
7441    /*--- 07 Nov 2001: start plugouts [see afni_plugout.c] ---*/
7442 
7443 #ifdef ALLOW_PLUGINS
7444    if( !AFNI_have_plugouts() ){
7445       dmode->misc_plugout_pb =
7446             XtVaCreateManagedWidget(
7447                "dialog" , xmPushButtonWidgetClass , menu ,
7448                   LABEL_ARG("Start Plugouts") ,
7449                   XmNmarginHeight , 0 ,
7450                   XmNtraversalOn , True  ,
7451                   XmNinitialResourcesPersistent , False ,
7452                NULL ) ;
7453       XtAddCallback( dmode->misc_plugout_pb , XmNactivateCallback ,
7454                      AFNI_misc_CB , im3d ) ;
7455       MCW_register_hint( dmode->misc_plugout_pb ,
7456                          "Start listening for plugouts" ) ;
7457    } else {
7458       dmode->misc_plugout_pb = NULL ;
7459    }
7460 #else
7461    dmode->misc_plugout_pb = NULL ;
7462 #endif
7463 
7464    /*-- 02 Mar 2002: button to start NIML --*/
7465 
7466    if( !AFNI_have_niml() ){
7467      dmode->misc_niml_pb =
7468            XtVaCreateManagedWidget(
7469               "dialog" , xmPushButtonWidgetClass , menu ,
7470                  LABEL_ARG("Start NIML") ,
7471                  XmNmarginHeight , 0 ,
7472                  XmNtraversalOn , True  ,
7473                  XmNinitialResourcesPersistent , False ,
7474               NULL ) ;
7475      XtAddCallback( dmode->misc_niml_pb , XmNactivateCallback ,
7476                     AFNI_misc_CB , im3d ) ;
7477      MCW_register_hint( dmode->misc_niml_pb ,
7478                         "Start listening for NIML connections" ) ;
7479    } else {
7480      dmode->misc_niml_pb = NULL ;
7481    }
7482 
7483    /*--- Utility buttons ---*/
7484 
7485    (void) XtVaCreateManagedWidget(
7486             "dialog" , xmSeparatorWidgetClass , menu ,
7487                XmNseparatorType , XmSINGLE_LINE ,
7488             NULL ) ;
7489 
7490    dmode->misc_readme_env_pb =
7491          XtVaCreateManagedWidget(
7492             "dialog" , xmPushButtonWidgetClass , menu ,
7493                LABEL_ARG("README.environment") ,
7494                XmNmarginHeight , 0 ,
7495                XmNtraversalOn , True  ,
7496                XmNinitialResourcesPersistent , False ,
7497             NULL ) ;
7498    XtAddCallback( dmode->misc_readme_env_pb , XmNactivateCallback ,
7499                   AFNI_misc_CB , im3d ) ;
7500    MCW_register_hint( dmode->misc_readme_env_pb,"Display README.environment file" );
7501 
7502    dmode->misc_pvalue_pb =
7503          XtVaCreateManagedWidget(
7504             "dialog" , xmPushButtonWidgetClass , menu ,
7505                LABEL_ARG("Meaning of p-values") ,
7506                XmNmarginHeight , 0 ,
7507                XmNtraversalOn , True  ,
7508                XmNinitialResourcesPersistent , False ,
7509             NULL ) ;
7510    XtAddCallback( dmode->misc_pvalue_pb , XmNactivateCallback ,
7511                   AFNI_pvalue_CB , im3d ) ;
7512    MCW_register_hint( dmode->misc_pvalue_pb,"How to think about p-values" );
7513    MCW_set_widget_bg( dmode->misc_pvalue_pb,PVALUE_COLOR,0) ;
7514 
7515    dmode->misc_license_pb =
7516          XtVaCreateManagedWidget(
7517             "dialog" , xmPushButtonWidgetClass , menu ,
7518                LABEL_ARG("License Info") ,
7519                XmNmarginHeight , 0 ,
7520                XmNtraversalOn , True  ,
7521                XmNinitialResourcesPersistent , False ,
7522             NULL ) ;
7523    XtAddCallback( dmode->misc_license_pb , XmNactivateCallback ,
7524                   AFNI_misc_CB , im3d ) ;
7525    MCW_register_hint( dmode->misc_license_pb,"Display GPL & Copyright Notice" );
7526 
7527    if( !ALLOW_realtime ){    /* 01 May 2000: only if not doing realtime */
7528       dmode->misc_vcheck_pb =
7529             XtVaCreateManagedWidget(
7530                "dialog" , xmPushButtonWidgetClass , menu ,
7531                   LABEL_ARG("Version Check") ,
7532                   XmNmarginHeight , 0 ,
7533                   XmNtraversalOn , True  ,
7534                   XmNinitialResourcesPersistent , False ,
7535                NULL ) ;
7536       XtAddCallback( dmode->misc_vcheck_pb , XmNactivateCallback ,
7537                      AFNI_misc_CB , im3d ) ;
7538       MCW_register_hint( dmode->misc_vcheck_pb,"Compare to master distribution" );
7539    } else {
7540       dmode->misc_vcheck_pb = NULL ;
7541    }
7542 
7543    if( !ALLOW_realtime ){    /* 29 Nov 2005: message of the day */
7544       dmode->misc_motd_pb =
7545             XtVaCreateManagedWidget(
7546                "dialog" , xmPushButtonWidgetClass , menu ,
7547                   LABEL_ARG("Message of the Day") ,
7548                   XmNmarginHeight , 0 ,
7549                   XmNtraversalOn , True  ,
7550                   XmNinitialResourcesPersistent , False ,
7551                NULL ) ;
7552       XtAddCallback( dmode->misc_motd_pb , XmNactivateCallback ,
7553                      AFNI_misc_CB , im3d ) ;
7554       MCW_register_hint( dmode->misc_motd_pb,"Display latest AFNI MotD" );
7555    } else {
7556       dmode->misc_motd_pb = NULL ;
7557    }
7558 
7559    /*--- pushbutton to see AFNI's historical documents ---*/
7560 
7561    { char *pg = THD_find_executable("afni_history") ;
7562      dmode->misc_hist_pb = NULL ;
7563      if( pg != NULL ){
7564        dmode->misc_hist_pb =
7565             XtVaCreateManagedWidget(
7566                "dialog" , xmPushButtonWidgetClass , menu ,
7567                   LABEL_ARG("AFNI History") ,
7568                   XmNmarginHeight , 0 ,
7569                   XmNtraversalOn , True  ,
7570                   XmNinitialResourcesPersistent , False ,
7571                NULL ) ;
7572       XtAddCallback( dmode->misc_hist_pb , XmNactivateCallback ,
7573                      AFNI_misc_CB , im3d ) ;
7574       MCW_register_hint( dmode->misc_hist_pb,"Show the Historical Documents" );
7575      }
7576    }
7577 
7578    /*--- pushbutton to purge unused datasets ---*/
7579 
7580    (void) XtVaCreateManagedWidget(
7581             "dialog" , xmSeparatorWidgetClass , menu ,
7582                XmNseparatorType , XmSINGLE_LINE ,
7583             NULL ) ;
7584 
7585    dmode->misc_purge_pb =
7586          XtVaCreateManagedWidget(
7587             "dialog" , xmPushButtonWidgetClass , menu ,
7588                LABEL_ARG("Purge Memory") ,
7589                XmNmarginHeight , 0 ,
7590                XmNtraversalOn , True  ,
7591                XmNinitialResourcesPersistent , False ,
7592             NULL ) ;
7593    XtAddCallback( dmode->misc_purge_pb , XmNactivateCallback ,
7594                   AFNI_misc_CB , im3d ) ;
7595    MCW_register_hint( dmode->misc_purge_pb , "Purge unused datasets" ) ;
7596 
7597    /*--- pushbutton to toggle routine tracing ---*/
7598 
7599 #ifdef USE_TRACING
7600    if( !ALLOW_realtime ){    /* 26 Jan 2001: don't do this if realtime is on */
7601      dmode->misc_tracing_pb =
7602            XtVaCreateManagedWidget(
7603               "dialog" , xmPushButtonWidgetClass , menu ,
7604                  LABEL_ARG( DBG_label ) ,
7605                  XmNmarginHeight , 0 ,
7606                  XmNtraversalOn , True  ,
7607                  XmNinitialResourcesPersistent , False ,
7608               NULL ) ;
7609      XtAddCallback( dmode->misc_tracing_pb , XmNactivateCallback ,
7610                     AFNI_misc_CB , im3d ) ;
7611      MCW_register_hint( dmode->misc_tracing_pb , "A Debugging Option" ) ;
7612    } else {
7613      dmode->misc_tracing_pb = NULL ;
7614    }
7615 #else
7616    dmode->misc_tracing_pb = NULL ;
7617 #endif
7618 
7619    /*--- pushbutton to query malloc table ---*/
7620 #ifdef USING_MCW_MALLOC
7621    if( MCW_MALLOC_enabled ){  /* 06 Mar 1999 */
7622       dmode->misc_showmalloc_pb =
7623             XtVaCreateManagedWidget(
7624                "dialog" , xmPushButtonWidgetClass , menu ,
7625                   LABEL_ARG("Malloc Summary") ,
7626                   XmNmarginHeight , 0 ,
7627                   XmNtraversalOn , True  ,
7628                   XmNinitialResourcesPersistent , False ,
7629                NULL ) ;
7630       XtAddCallback( dmode->misc_showmalloc_pb , XmNactivateCallback ,
7631                      AFNI_misc_CB , im3d ) ;
7632 
7633       dmode->misc_dumpmalloc_pb =
7634             XtVaCreateManagedWidget(
7635                "dialog" , xmPushButtonWidgetClass , menu ,
7636                   LABEL_ARG("Dump Malloc Table") ,
7637                   XmNmarginHeight , 0 ,
7638                   XmNtraversalOn , True  ,
7639                   XmNinitialResourcesPersistent , False ,
7640                NULL ) ;
7641       XtAddCallback( dmode->misc_dumpmalloc_pb , XmNactivateCallback ,
7642                      AFNI_misc_CB , im3d ) ;
7643 
7644       MCW_register_hint( dmode->misc_showmalloc_pb , "A Debugging Option" ) ;
7645       MCW_register_hint( dmode->misc_dumpmalloc_pb , "A Debugging Option" ) ;
7646    } else {
7647       dmode->misc_showmalloc_pb = dmode->misc_dumpmalloc_pb = NULL ;
7648    }
7649 #else
7650    dmode->misc_showmalloc_pb = dmode->misc_dumpmalloc_pb = NULL ;
7651 #endif
7652 
7653    /*--- done ---*/
7654 
7655    XtManageChild( rc ) ;
7656    EXRETURN ;
7657 }
7658 
7659 /*------------------------------------------------------------------*/
7660 /*! Doesn't do much (for testing new buttons, mostly). */
7661 
AFNI_invert_CB(Widget wcall,XtPointer cd,XtPointer cbs)7662 void AFNI_invert_CB( Widget wcall , XtPointer cd , XtPointer cbs )
7663 {
7664    if( wcall != (Widget)NULL ) MCW_invert_widget(wcall) ;
7665 }
7666 
7667 /*------------------------------------------------------------------*/
7668 /*! Callback for NIML+PO button. */
7669 
AFNI_nimlpo_CB(Widget wcall,XtPointer cd,XtPointer cbs)7670 void AFNI_nimlpo_CB( Widget wcall , XtPointer cd , XtPointer cbs )
7671 {
7672    Three_D_View *im3d ; int id ;
7673 
7674    AFNI_init_niml() ;
7675    AFNI_init_plugouts() ;
7676 
7677    for( id=0 ; id < MAX_CONTROLLERS ; id++ ){     /* 01 Feb 2008: */
7678      im3d = GLOBAL_library.controllers[id] ;    /* disable in all */
7679      if( IM3D_VALID(im3d) )                        /* controllers */
7680        XtSetSensitive( im3d->vwid->view->nimlpo_pb , False ) ;
7681    }
7682 
7683    return ;
7684 }
7685 
7686 /*------------------------------------------------------------------*/
7687 /*! Callback for on-the-fly editing controls arrowval. */
7688 
AFNI_vedit_CB(MCW_arrowval * av,XtPointer cd)7689 void AFNI_vedit_CB( MCW_arrowval *av , XtPointer cd )
7690 {
7691    Three_D_View *im3d = (Three_D_View *)cd ;
7692 
7693 ENTRY("AFNI_vedit_CB") ;
7694 
7695    if( ! IM3D_OPEN(im3d) ) EXRETURN ;
7696 
7697    if( ! im3d->vwid->imag->pop_instacorr_pb ||
7698        ! im3d->vwid->imag->pop_icorrjump_pb ) {/*This happens when running afni
7699                                                  with -im option ZSS Aug 31 09*/
7700       EXRETURN ;
7701    }
7702 
7703    XtUnmanageChild( im3d->vwid->func->vedit_frame ) ;
7704 
7705    switch( av->ival ){
7706 
7707      /* switch to InstaCorr */
7708      case VEDIT_INSTACORR:
7709        DISABLE_TSTAT(im3d) ;
7710        DISABLE_INSTACALC(im3d) ;                          /* InstaCalc off */
7711        DISABLE_GRPINCORR(im3d) ;                          /* GrpInCorr off */
7712        XtUnmanageChild( im3d->vwid->func->icalc_rowcol) ;
7713        XtUnmanageChild( im3d->vwid->func->tstat_rowcol) ;
7714        if( im3d->vwid->func->gicor_rowcol != NULL )
7715          XtUnmanageChild( im3d->vwid->func->gicor_rowcol ) ;
7716        XtManageChild  ( im3d->vwid->func->icor_rowcol ) ;
7717      break ;
7718 
7719      /* switch to InstaCalc [18 Sep 2009] */
7720      case VEDIT_INSTACALC:
7721        DISABLE_TSTAT(im3d) ;
7722        DISABLE_INSTACORR(im3d) ;                          /* InstaCorr off */
7723        DESTROY_ICOR_setup(im3d->iset) ;
7724        DISABLE_GRPINCORR(im3d) ;                          /* GrpInCorr off */
7725        XtUnmanageChild( im3d->vwid->func->icor_rowcol ) ;
7726        XtUnmanageChild( im3d->vwid->func->tstat_rowcol) ;
7727        if( im3d->vwid->func->gicor_rowcol != NULL )
7728          XtUnmanageChild( im3d->vwid->func->gicor_rowcol ) ;
7729        XtManageChild  ( im3d->vwid->func->icalc_rowcol) ;
7730      break ;
7731 
7732      /* switch to Tstat [22 Mar 2018] */
7733      case VEDIT_TSTAT:
7734        DISABLE_INSTACALC(im3d) ;
7735        DISABLE_INSTACORR(im3d) ;                          /* InstaCorr off */
7736        DESTROY_ICOR_setup(im3d->iset) ;
7737        DISABLE_GRPINCORR(im3d) ;                          /* GrpInCorr off */
7738        XtUnmanageChild( im3d->vwid->func->icor_rowcol ) ;
7739        XtUnmanageChild( im3d->vwid->func->icalc_rowcol) ;
7740        if( im3d->vwid->func->gicor_rowcol != NULL )
7741          XtUnmanageChild( im3d->vwid->func->gicor_rowcol ) ;
7742        XtManageChild  ( im3d->vwid->func->tstat_rowcol) ;
7743      break ;
7744 
7745      /* switch to Group InstaCorr [22 Dec 2009] */
7746      case VEDIT_GRINCORR:
7747        if( im3d->vwid->func->gicor_rowcol != NULL ){
7748          DISABLE_TSTAT(im3d) ;
7749          DISABLE_INSTACALC(im3d) ;                          /* InstaCalc off */
7750          DISABLE_INSTACORR(im3d) ;                          /* InstaCorr off */
7751          DESTROY_ICOR_setup(im3d->iset) ;
7752          XtUnmanageChild( im3d->vwid->func->icor_rowcol ) ;
7753          XtUnmanageChild( im3d->vwid->func->icalc_rowcol) ;
7754          XtUnmanageChild( im3d->vwid->func->tstat_rowcol) ;
7755          XtManageChild  ( im3d->vwid->func->gicor_rowcol) ;
7756          if( im3d->giset != NULL ) ENABLE_GRPINCORR(im3d) ;
7757          else                      DISABLE_GRPINCORR(im3d) ;
7758        }
7759      break ;
7760    }
7761    XtManageChild( im3d->vwid->func->vedit_frame ) ;
7762 
7763    FIX_SCALE_SIZE(im3d) ; FIX_SCALE_VALUE(im3d) ; EXRETURN ;
7764 }
7765 
7766 /*----------------------------------------------------------------------*/
7767 /*   Set parameters for ROI colormaps [ZSS Feb 15 2010] */
7768 
AFNI_set_func_range_nval(XtPointer * vp_im3d,float rval)7769 int AFNI_set_func_range_nval(XtPointer *vp_im3d, float rval)
7770 {
7771    Three_D_View *im3d=NULL;
7772 
7773    ENTRY("AFNI_set_func_range_nval") ;
7774 
7775    im3d = (Three_D_View *)vp_im3d;
7776    if(im3d->first_integral!=0) {  /* must be switching from a continuous color scale */
7777      im3d->cont_bbox = MCW_val_bbox(im3d->vwid->func->range_bbox);
7778      im3d->cont_autorange = im3d->vinfo->use_autorange;
7779      im3d->cont_range_fval = im3d->vwid->func->range_av->fval;
7780      im3d->cont_pos_only = MCW_val_bbox( im3d->vwid->func->inten_bbox) ;
7781      im3d->cont_perc_thr = MCW_val_bbox( im3d->vwid->func->perc_bbox) ;
7782      im3d->cont_pbar_index = im3d->vwid->func->inten_pbar->bigmap_index;
7783 
7784      im3d->first_integral = 0;
7785    }
7786 
7787    if( !IM3D_OPEN(im3d) ) RETURN(0) ;
7788    MCW_set_bbox( im3d->vwid->func->range_bbox , 0 ) ;   /* autoRange box off */
7789    im3d->vinfo->use_autorange = 0 ;
7790 
7791    AV_SENSITIZE( im3d->vwid->func->range_av , 1 ) ;
7792    AV_assign_fval( im3d->vwid->func->range_av , rval ) ;
7793    AFNI_range_av_CB( im3d->vwid->func->range_av , im3d ) ;
7794 
7795    /* positive only */
7796    MCW_set_bbox( im3d->vwid->func->inten_bbox , 1 ) ;
7797    AFNI_inten_bbox_CB( im3d->vwid->func->inten_bbox->wbut[PBAR_MODEBUT] ,
7798                        (XtPointer)im3d , NULL ) ;
7799 
7800    RETURN(0) ;
7801 }
7802 
7803 /* reset color overlay for continuous data */
AFNI_reset_func_range_cont(XtPointer * vp_im3d)7804 int AFNI_reset_func_range_cont(XtPointer *vp_im3d)
7805 {
7806    Three_D_View *im3d=NULL;
7807 
7808    ENTRY("AFNI_reset_func_range_cont") ;
7809    im3d = (Three_D_View *)vp_im3d;
7810    if( !IM3D_OPEN(im3d) ) RETURN(0) ;
7811    /* check if no continuous colors have ever been set with "first_integral" as the flag */
7812    if(im3d->first_integral<0)
7813       RETURN(0);
7814 
7815    /* reset the continuous color scale back to whatever it was */
7816    PBAR_set_bigmap_index( im3d->vwid->func->inten_pbar ,
7817                           im3d->cont_pbar_index ) ;
7818 
7819    /* reset range */
7820    AV_SENSITIZE( im3d->vwid->func->range_av , 1 ) ;
7821    AV_assign_fval( im3d->vwid->func->range_av , im3d->cont_range_fval ) ;
7822    AFNI_range_av_CB( im3d->vwid->func->range_av , im3d ) ;
7823 
7824    /* reset positive only */
7825    MCW_set_bbox( im3d->vwid->func->inten_bbox , im3d->cont_pos_only ) ;
7826    AFNI_inten_bbox_CB( im3d->vwid->func->inten_bbox->wbut[PBAR_MODEBUT] ,
7827                        (XtPointer)im3d , NULL ) ;
7828 
7829    /* DRG 25 Apr 2016  */
7830    /*   extra fix for percentile flag not working with warp-on-demand switch views */
7831    /* reset perc only  - only allow for dataset on disk, not warp on demand */
7832    if(DSET_ONDISK(im3d->fim_now)) {
7833       MCW_set_bbox( im3d->vwid->func->perc_bbox ,
7834                  (im3d->cont_perc_thr) ? (1) : (0) ) ;
7835    }
7836    else
7837       MCW_set_bbox( im3d->vwid->func->perc_bbox , 0 ) ;
7838 
7839    AFNI_inten_bbox_CB( im3d->vwid->func->perc_bbox->wbut[PERC_AUTOBUT] ,
7840                        (XtPointer)im3d , NULL ) ;
7841 
7842    /* reset auto-range - redisplays if auto-ranging */
7843    MCW_set_bbox( im3d->vwid->func->range_bbox , im3d->cont_bbox ) ;   /* autoRange box */
7844    AFNI_range_bbox_CB( im3d->vwid->func->range_bbox->wbut[RANGE_AUTOBUT],
7845                        (XtPointer)im3d , NULL ) ;
7846    im3d->vinfo->use_autorange = im3d->cont_autorange ;
7847 
7848    im3d->first_integral = 1;
7849 
7850    RETURN(0) ;
7851 }
7852 
7853 /* suggest a colormap for ROI dsets */
AFNI_smallest_intpbar(THD_3dim_dataset * dset)7854 char *AFNI_smallest_intpbar(THD_3dim_dataset *dset)
7855 {
7856    float mxset;
7857    static int warn=0;
7858 
7859    mxset = THD_dset_max(dset, 1);
7860 
7861    // [PT: June 25, 2021] resetting previous change; sticking with
7862    // "<=" here, indeed.
7863    if (mxset <= 32) {
7864       return("ROI_i32" ) ;
7865    } else if (mxset <= 64) {
7866       return("ROI_i64" ) ;
7867    } else if (mxset <= 128) {
7868       return("ROI_i128" ) ;
7869    } else if (mxset <= 256) {
7870       return("ROI_i256" ) ;
7871    }
7872       /* max is high - use the ROI_i256 colorbar -
7873  *         user should use -XXXnpane option*/
7874       return("ROI_i256" ) ;
7875 
7876 
7877    return("ROI_i256" ) ;
7878 }
7879 
7880 /*----------------------------------------------------------------------*/
7881 
AFNI_set_dset_pbar(XtPointer * vp_im3d)7882 int AFNI_set_dset_pbar(XtPointer *vp_im3d)
7883 {
7884    Three_D_View *im3d=NULL;
7885    ATR_string *atr=NULL;
7886    char *pbar_name=NULL;
7887    byte switched = 0;
7888    int icmap=-1;
7889    NI_element *nel=NULL;
7890 
7891    ENTRY("AFNI_set_dset_pbar") ;
7892 
7893 /*   if (!AFNI_yesenv("AFNI_CMAP_AUTO")) RETURN(0);*/
7894 
7895    if( AFNI_noenv("AFNI_CMAP_AUTO") || AFNI_noenv("AFNI_PBAR_AUTO") ) RETURN(0);
7896    im3d = (Three_D_View *)vp_im3d;
7897    if( !IM3D_OPEN(im3d) ) RETURN(0) ;
7898 
7899    if ((atr = THD_find_string_atr( im3d->fim_now->dblk ,
7900                               "VALUE_LABEL_DTABLE" ))) {
7901 
7902       /* switch to an ROI colormap */
7903       if (!(nel = NI_read_element_fromstring(atr->ch))) {
7904          fprintf(stderr,"** WARNING: Poorly formatted VALUE_LABEL_DTABLE\n");
7905          icmap = -1;
7906       } else {
7907          pbar_name = NI_get_attribute(nel,"pbar_name");
7908          icmap = PBAR_get_bigmap_index(pbar_name);
7909       }
7910       if (icmap >=0 ) {
7911          PBAR_set_bigmap( im3d->vwid->func->inten_pbar ,  pbar_name,
7912                             THD_dset_max(im3d->fim_now, 1) ) ;
7913 /*         AFNI_set_func_range_nval(im3d->vwid->func->inten_pbar->parent,
7914                            THD_dset_max(im3d->fim_now, 1));
7915 */      } else {
7916          if (1) { /* one approach */
7917             PBAR_set_bigmap( im3d->vwid->func->inten_pbar ,
7918                              AFNI_smallest_intpbar(im3d->fim_now),
7919                              THD_dset_max(im3d->fim_now, 1) ) ;
7920          } else { /* another perhaps */
7921             PBAR_set_bigmap_index( im3d->vwid->func->inten_pbar ,
7922                               im3d->int_pbar_index ) ;
7923          }
7924       }
7925       switched = 1;
7926       /* Problem is that when you switch back to a non  ROI dset,
7927       you are stuck with the ROI deal.
7928       Perhaps one should bite the bullet and create a structure
7929       that preserves the last colormap setup for a dset.
7930       Hmmm, got to discuss this with Bob, Daniel, and Rick */
7931    } else if ((atr = THD_find_string_atr( im3d->fim_now->dblk ,
7932                               "ATLAS_LABEL_TABLE" ))) {
7933       /* switch to an ROI colormap */
7934       icmap = -1;
7935       if (!(nel = NI_read_element_fromstring(atr->ch))) {
7936          fprintf(stderr,"** WARNING: Poorly formatted ATLAS_LABEL_TABLE\n");
7937       } else {
7938          /* usually atlases don't have a pbar_name, but it does
7939          not hurt to check, allowing for its potential use someday */
7940          if ((pbar_name = NI_get_attribute(nel,"pbar_name"))) {
7941             icmap = PBAR_get_bigmap_index(pbar_name);
7942          }
7943          NI_free_element(nel); nel = NULL;
7944       }
7945 
7946       if (icmap >=0 ) {
7947          PBAR_set_bigmap( im3d->vwid->func->inten_pbar ,  pbar_name,
7948              THD_dset_max(im3d->fim_now, 1)) ;
7949 /*         AFNI_set_func_range_nval(im3d->vwid->func->inten_pbar->parent,
7950                            THD_dset_max(im3d->fim_now, 1));
7951 */      } else {
7952          if (1) { /* one approach */
7953             PBAR_set_bigmap( im3d->vwid->func->inten_pbar ,
7954                              AFNI_smallest_intpbar(im3d->fim_now),
7955                              THD_dset_max(im3d->fim_now, 1) ) ;
7956 /*            AFNI_set_func_range_nval(im3d->vwid->func->inten_pbar->parent,
7957                            THD_dset_max(im3d->fim_now, 1));
7958 */         } else { /* another perhaps */
7959             PBAR_set_bigmap_index( im3d->vwid->func->inten_pbar ,
7960                               im3d->int_pbar_index ) ;
7961          }
7962       }
7963       switched = 1;
7964    } else {
7965       /*
7966       Here one could guess at the moment (See is_integral_dset).
7967       But that can be
7968       time consuming if integer data are stored as float.
7969       It is better to have the dataset flagged by a special type
7970       in the header.
7971       */
7972       /* use ROI_i256 for now for datasets marked as integer cmaps (even sparse ones) */
7973       if(im3d->fim_now->int_cmap) {
7974          if (1) { /* one approach */
7975             PBAR_set_bigmap( im3d->vwid->func->inten_pbar ,
7976                              AFNI_smallest_intpbar(im3d->fim_now),
7977                              THD_dset_max(im3d->fim_now, 1) );
7978 /*            AFNI_set_func_range_nval(im3d->vwid->func->inten_pbar->parent,
7979                            THD_dset_max(im3d->fim_now, 1));
7980 */
7981          }
7982       }
7983       else {
7984 #if 0
7985        char *eee = getenv("AFNI_COLORSCALE_DEFAULT") ;
7986        if( eee == NULL ) eee = getenv("AFNI_COLOR_SCALE_DEFAULT") ;
7987        if( eee == NULL ) eee = "Spectrum:red_to_blue" ;
7988 #endif
7989        AFNI_reset_func_range_cont((XtPointer *)im3d);
7990       }
7991       switched = 1;
7992    }
7993 
7994    if (switched) {
7995      AFNI_inten_pbar_CB( im3d->vwid->func->inten_pbar , im3d , 0 ) ;
7996      POPUP_cursorize(im3d->vwid->func->inten_pbar->panew ) ;
7997    }
7998    RETURN(0);
7999 }
8000 
8001 
8002 /*-------------------------------------------------------------------------*/
8003 
AFNI_sesslab_EV(Widget w,XtPointer cd,XEvent * ev,RwcBoolean * continue_to_dispatch)8004 void AFNI_sesslab_EV( Widget w , XtPointer cd ,
8005                       XEvent *ev , RwcBoolean *continue_to_dispatch )
8006 {
8007    Three_D_View *im3d = (Three_D_View *)cd ;
8008 
8009 ENTRY("AFNI_sesslab_EV") ;
8010 
8011    if( ! IM3D_OPEN(im3d) ) EXRETURN ;
8012 
8013    /*** handle events ***/
8014 
8015    switch( ev->type ){
8016 
8017      /*----- take button press -----*/
8018 
8019      case ButtonPress:{
8020        XButtonEvent *event = (XButtonEvent *)ev ;
8021        if( event->button == Button3 ){
8022          AFNI_viewing_widgets *view = im3d->vwid->view ;
8023          if( view->marks_enabled ){
8024            XtUnmanageChild( view->marks_rowcol ) ;
8025            XtUnmanageChild( view->marks_frame ) ;
8026            view->marks_enabled = 0 ;
8027          } else {
8028            XtManageChild( view->marks_rowcol ) ;
8029            XtManageChild( view->marks_frame ) ;
8030            view->marks_enabled = 1 ;
8031          }
8032          XWarpPointer( XtDisplay(w) , None , XtWindow(w) , 0,0,0,0,30,10 ) ;
8033 
8034          SHIFT_TIPS( im3d ,
8035                      (view->marks_enabled) ? TIPS_MINUS_SHIFT : TIPS_PLUS_SHIFT ) ;
8036          SHIFT_NEWS( im3d ,
8037                      (view->marks_enabled) ? TIPS_MINUS_SHIFT : TIPS_PLUS_SHIFT ) ;
8038 
8039        } else if( event->button == Button2 ){
8040          XUngrabPointer( event->display , CurrentTime ) ;
8041        } else if( event->button == Button4 || event->button == Button5 ){
8042          MCW_invert_widget(w) ;
8043        }
8044      }
8045      break ;
8046 
8047    }
8048 
8049    EXRETURN ;
8050 }
8051 
8052 /*---------------------------------------------------------------------------
8053   A set of functions to handle thresholding based on percentile of threshold
8054   sub-brick.
8055 -----------------------------------------------------------------------------*/
8056 
flush_vinfo_sort(AFNI_view_info * vinfo,char * sel)8057 void flush_vinfo_sort(AFNI_view_info *vinfo, char *sel) /* ZSS April 26 2012 */
8058 {
8059    if (vinfo) {
8060       if (!sel || sel[0]=='T') {/* threshold sorting */
8061          /* INFO_message("Flushing threshold sorting"); */
8062          if (vinfo->th_sort) free(vinfo->th_sort); vinfo->th_sort=NULL;
8063          vinfo->th_sortid[0]='\0';
8064          vinfo->N_th_sort = 0;
8065       }
8066    }
8067    return;
8068 }
8069 
8070 /*--------------------------------------------------------------------------*/
8071 
flush_3Dview_sort(Three_D_View * im3d,char * sel)8072 void flush_3Dview_sort(Three_D_View *im3d, char *sel)  /* ZSS April 26 2012 */
8073 {
8074    if (im3d && im3d->vinfo) flush_vinfo_sort(im3d->vinfo, sel);
8075    return;
8076 }
8077 
8078 /*--------------------------------------------------------------------------*/
8079 
8080 #define FillSortID(sss, im3d) { \
8081    sprintf(sss,"%s_%d_%s",  \
8082            im3d->vinfo->use_posfunc ? "++":"+-",  \
8083            im3d->vinfo->thr_index, im3d->fim_now->idcode.str); \
8084 }
8085 
8086 /*--------------------------------------------------------------------------*/
8087 
get_3Dview_sort(Three_D_View * im3d,char * sel)8088 float * get_3Dview_sort(Three_D_View *im3d, char *sel) /* ZSS April 26 2012 */
8089 {
8090    char cur_dset_id[256]={""};
8091    int ii, nn;
8092 
8093    if (!im3d || !im3d->fim_now || !im3d->vinfo || im3d->vinfo->thr_index < 0) {
8094       return(NULL);
8095    }
8096 
8097    if (!sel || sel[0] == 'T') { /* threshold sorting */
8098       FillSortID(cur_dset_id, im3d);
8099       if (  !im3d->vinfo->th_sort ||
8100             strcmp(cur_dset_id, im3d->vinfo->th_sortid)) {
8101          flush_3Dview_sort(im3d, sel); /* cleanup if needed */
8102          DSET_load(im3d->fim_now);
8103          if (!(im3d->vinfo->th_sort =
8104                   THD_extract_to_float(im3d->vinfo->thr_index,
8105                                                      im3d->fim_now))) {
8106             return(NULL); /* failed */
8107          }
8108          /* get rid of zeros */
8109          nn = DSET_NVOX(im3d->fim_now);
8110          if (im3d->vinfo->use_posfunc) {
8111             ii=0; nn = 0;
8112             while(ii<DSET_NVOX(im3d->fim_now)) {
8113                if (im3d->vinfo->th_sort[ii] > 0.0f) {
8114                   im3d->vinfo->th_sort[nn] = im3d->vinfo->th_sort[ii]; ++nn;
8115                }
8116                ++ii;
8117             }
8118          } else {
8119             ii=0; nn = 0;
8120             while(ii<DSET_NVOX(im3d->fim_now)) {
8121                if (im3d->vinfo->th_sort[ii] != 0.0f) {
8122                   im3d->vinfo->th_sort[nn] = ABS(im3d->vinfo->th_sort[ii]);
8123                                                                         ++nn;
8124                }
8125                ++ii;
8126             }
8127          }
8128          im3d->vinfo->N_th_sort = nn;
8129 
8130          qsort_float(im3d->vinfo->N_th_sort, im3d->vinfo->th_sort);
8131          FillSortID(im3d->vinfo->th_sortid, im3d);
8132       } else {
8133          /* current one is OK, nothing to be done */
8134       }
8135 
8136       return(im3d->vinfo->th_sort);
8137    }
8138 
8139    ERROR_message("Not ready for selection %s\n",sel);
8140    return(NULL);
8141 }
8142 
8143 /*--------------------------------------------------------------------------*/
8144 
get_3Dview_func_thresh(Three_D_View * im3d,int apply_power)8145 float get_3Dview_func_thresh( Three_D_View *im3d, int apply_power )
8146 {
8147    float thresh = 0.0;
8148 
8149 ENTRY("get_3Dview_func_thresh") ;
8150    if( ! IM3D_VALID(im3d) || ! ISVALID_3DIM_DATASET(im3d->fim_now) )
8151       RETURN(thresh) ;
8152 
8153    if ((im3d->cont_perc_thr) && DSET_ONDISK(im3d->fim_now)) {
8154       thresh = AFNI_thresh_from_percentile(im3d, im3d->vinfo->func_threshold);
8155       /* INFO_message("In percentile mode %p %d\n"
8156                       "Still need to put flush action when 'pos' is toggled,\n"
8157                 "or when a new on the fly set is computed as in Insta stuff.\n"
8158                 "Perc. %f, thresh now: %f\n",
8159                         im3d->fim_now, im3d->vinfo->thr_index,
8160                         im3d->vinfo->func_threshold,thresh ); */
8161    } else {
8162       thresh = im3d->vinfo->func_threshold;
8163       if (apply_power) {
8164          /* get the "true" threshold (scaled up from being in [0,1]) */
8165 
8166          thresh = thresh * im3d->vinfo->func_thresh_top ;
8167       }
8168    }
8169 
8170    RETURN(thresh);
8171 }
8172 
reset_mnito(struct Three_D_View * im3d)8173 void reset_mnito(struct Three_D_View *im3d)
8174 {
8175    if(!im3d) return;
8176    if(!im3d->vwid->imag->pop_mnito_pb) return;
8177 
8178    sprintf(jumpstring, "Jump to (%s)", get_jump_space());
8179 
8180    MCW_set_widget_label( im3d->vwid->imag->pop_mnito_pb, jumpstring ) ;
8181    XtManageChild( im3d->vwid->imag->pop_mnito_pb ) ;
8182 }
8183