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 #ifndef _MCW_PBAR_H_
8 #define _MCW_PBAR_H_
9 
10 #include <Xm/Label.h>
11 #include <Xm/PanedW.h>
12 #include <Xm/DrawnB.h>
13 #include <Xm/BulletinB.h>
14 
15 #include <stdio.h>
16 #include <string.h>
17 #include <math.h>
18 
19 #include "mrilib.h"      /* 15 Jun 2000 */
20 #include "mcw_malloc.h"
21 
22 #include "display.h"
23 #include "bbox.h"
24 #include "xutil.h"
25 
26 #include "pbardefs.h"
27 
28 #ifdef  __cplusplus
29 extern "C" {                    /* care of Greg Balls    7 Aug 2006 [rickr] */
30 #endif
31 
32 void PBAR_click_CB   ( Widget , XtPointer , XtPointer ) ;
33 void PBAR_setcolor_CB( Widget , XtPointer , MCW_choose_cbs * ) ;
34 void PBAR_setonoff_CB( Widget , XtPointer , MCW_choose_cbs * ) ;  /* 10 Feb 2012 */
35 void PBAR_resize_CB  ( Widget , XtPointer , XtPointer ) ;
36 void PBAR_labelize   ( float , char * ) ;
37 
38 #define check_width 8
39 #define check_height 8
40 static char check_bits[] = {
41    0x11, 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa};
42 
43 static Pixmap check_pixmap = XmUNSPECIFIED_PIXMAP ;
44 
45 #define NPANE_MIN        2
46 #define NPANE_MAX       20
47 #define PANE_WIDTH      15
48 #define PANE_MIN_HEIGHT  5
49 #define PANE_LOFF        6
50 #define PANE_SPACING     2
51 
52 #define PANE_MAXMODE     2
53 
54 #define NPANE_NOSASH    21  /* doesn't work well, so this disables the no-sash feature */
55 #define SASH_HYES        5
56 #define SASH_HNO         1
57 
58 #define KEEP_LABEL(ip,np) ( ((ip)<=(np) && (np)<NPANE_NOSASH) || ((ip)==0 || (ip)==(np)) )
59 
60 #define pbCR_COLOR       (1<<0)
61 #define pbCR_VALUE       (1<<1)
62 
63 #define PBAR_BIGTHREE_MASK  1
64 
65 typedef struct {
66   Widget top , panew , panes[NPANE_MAX]   , labels[NPANE_MAX+1] ;
67   int num_panes , panes_sum , panew_height , ov_index[NPANE_MAX] , renew_all ;
68   float pval[NPANE_MAX+1] ;
69   MCW_DC *dc ;
70 
71   float pval_save[NPANE_MAX+1][NPANE_MAX+1][PANE_MAXMODE] ;  /* saved values */
72   int   ovin_save[NPANE_MAX+1][NPANE_MAX+1][PANE_MAXMODE] ;
73   int   npan_save[PANE_MAXMODE] ;
74 
75   int   pane_hsum[NPANE_MAX+1] ;  /* Dec 1997 */
76 
77   int   update_me , mode , hide_changes , keep_pval ;
78 
79   gen_func *pb_CB ;
80   XtPointer pb_data ;
81 
82   XtPointer parent ;
83 
84   int    bigmode , bigset ;     /* 30 Jan 2003 */
85   float  bigtop , bigbot , bigmax ;
86   rgbyte bigcolor[NPANE_BIGGEST] ;
87   char  *bigname ;              /* 22 Oct 2003 */
88   XImage *bigxim ;
89   int    bigmap_index ;         /* 31 Jan 2003 */
90   float  bigfac ;               /* 11 Feb 2003 */
91   int    bigflip ;              /* 07 Feb 2004 */
92   int    bigrota ;              /* 07 Feb 2004 */
93   int    big30, big32 , big31 ; /* Feb 2012 */
94   int    bigh0, bigh1 , bigh2 ; /* Feb 2012 */
95   int    ignore_resize ;        /* Feb 2012 */
96   int    dont_alter_bigmax ;    /* Feb 2012 */
97 
98   Widget big_menu, big_label, big_choose_pb, big_scaleup_pb, big_scaledn_pb ;
99   Widget big_picktopbot_pb ;
100 } MCW_pbar ;
101 
102 #define PBAR_IS_BIGMODE(pp)  ( (pp) != NULL && (pp)->bigmode )                  /* 19 Jun 2019 */
103 #define PBAR_IS_BIGTHREE(pp) ( (pp) != NULL && (pp)->bigmode && (pp)->big31 )
104 
105 MCW_pbar * new_MCW_pbar( Widget , MCW_DC * ,
106                          int,int, float,float, gen_func *, XtPointer, int ) ;
107 
108 void alter_MCW_pbar( MCW_pbar * , int , float * ) ;
109 void update_MCW_pbar( MCW_pbar * ) ;
110 
111 int MCW_pbars_equivalent( MCW_pbar *, MCW_pbar * ) ; /* 07 Jul 2014 */
112 
113 MRI_IMAGE * MCW_pbar_to_mri( MCW_pbar *,int,int ) ; /* 15 Jun 2000 */
114 
115 void rotate_MCW_pbar( MCW_pbar * , int ) ; /* 30 Mar 2001 */
116 
117 void PBAR_set_panecolor( MCW_pbar *, int , int ) ;  /* 17 Jan 2003 */
118 
119 void PBAR_set_bigmode( MCW_pbar *, int, float,float ) ;     /* 30 Jan 2003 */
120 void PBAR_bigexpose_CB( Widget , XtPointer , XtPointer ) ;  /* 30 Jan 2003 */
121 void PBAR_add_bigmap( char * , rgbyte * ) ;                 /* 31 Jan 2003 */
122 void PBAR_read_bigmap( char *, MCW_DC * ) ;                 /* 01 Feb 2003 */
123 void PBAR_make_bigmap( char *,
124                        int, float *, rgbyte *, MCW_DC * );  /* 02 Feb 2003 */
125 
126 void PBAR_set_bigmap( MCW_pbar * , char *, int ) ;          /* 03 Feb 2003, 10 Jan 2020 */
127 void PBAR_set_bigmap_index( MCW_pbar * , int ) ;            /* 11 Mar 2011 */
128 char * PBAR_get_bigmap( MCW_pbar * ) ;                      /* 03 Feb 2003 */
129 int PBAR_define_bigmap( char *cmd ) ;                       /* 07 Feb 2003 */
130 void PBAR_flip( MCW_pbar * ) ;                              /* 07 Feb 2004 */
131 int PBAR_get_bigmap_index ( char *bnam );                   /* 26 Feb 2010 ZSS */
132 
133 void PBAR_fill_bigmap( int neq, float *val, rgbyte *col, rgbyte *map, int npan ) ; /* 17 Jul 2019 */
134 
135 extern int AFNI_set_func_range_nval( XtPointer *vp_im3d, float val);
136                                                             /* 15 Feb 2010 */
137 
138 extern int AFNI_set_dset_pbar(XtPointer *vp_im3d);          /* 26 Feb 2010 ZSS */
139 
140 #define PBAR_force_bigexpose(pb) \
141   do{ MCW_kill_XImage(pb->bigxim); pb->bigxim = NULL; PBAR_bigexpose_CB(NULL,pb,NULL); } while(0)
142 
143 #ifdef  __cplusplus
144 }
145 #endif
146 
147 #endif
148