Rev 209 | Rev 234 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 209 | Rev 221 | ||
|---|---|---|---|
| 1 | #ifdef _CVI_ |
1 | #ifdef _CVI_ |
| 2 | # include <ansi_c.h> |
2 | # include <ansi_c.h> |
| 3 | # else /* _CVI_ */ |
3 | # else /* _CVI_ */ |
| 4 | # include <stdlib.h> |
4 | # include <stdlib.h> |
| 5 | # include <stdio.h> |
5 | # include <stdio.h> |
| 6 | # include <string.h> |
6 | # include <string.h> |
| 7 | #endif /* _CVI_ */ |
7 | #endif /* _CVI_ */ |
| 8 | 8 | ||
| 9 | #include "H2D.h" |
9 | #include "H2D.h" |
| 10 | 10 | ||
| 11 | #define H2DMAX 500 |
11 | #define H2DMAX 500 |
| 12 | H2D *h2[H2DMAX]; |
12 | H2D *h2[H2DMAX]; |
| 13 | //int Printf(char *format, ...); |
13 | //int Printf(char *format, ...); |
| 14 | 14 | ||
| 15 | int _VI_FUNC H2D_Clear(int h2d) { |
15 | int _VI_FUNC H2D_Clear(int h2d) { |
| 16 | if (!h2[h2d]) return -1; |
16 | if (!h2[h2d]) return -1; |
| 17 | memset(h2[h2d]->data, 0,h2[h2d]->size ); |
17 | memset(h2[h2d]->data, 0,h2[h2d]->size ); |
| 18 | h2[h2d]->min=0; |
18 | h2[h2d]->min=0; |
| 19 | h2[h2d]->max=0; |
19 | h2[h2d]->max=0; |
| 20 | h2[h2d]->nentries=0; |
20 | h2[h2d]->nentries=0; |
| 21 | return 0; |
21 | return 0; |
| 22 | } |
22 | } |
| 23 | 23 | ||
| 24 | int _VI_FUNC H2D_Print(int h2d) { |
24 | int _VI_FUNC H2D_Print(int h2d) { |
| 25 | if (!h2[h2d]) return -1; |
25 | if (!h2[h2d]) return -1; |
| 26 | //Printf("PrintH2D nx=%d minx=%f stepx=%f ny=%d miny=%f stepy=%f size=%d\n", h2[h2d]->nx, h2[h2d]->minx, h2[h2d]->stepx, h2[h2d]->ny, h2[h2d]->miny, h2[h2d]->stepy, h2[h2d]->size ) ; |
26 | //Printf("PrintH2D nx=%d minx=%f stepx=%f ny=%d miny=%f stepy=%f size=%d\n", h2[h2d]->nx, h2[h2d]->minx, h2[h2d]->stepx, h2[h2d]->ny, h2[h2d]->miny, h2[h2d]->stepy, h2[h2d]->size ) ; |
| 27 | return 0; |
27 | return 0; |
| 28 | } |
28 | } |
| 29 | 29 | ||
| 30 | int _VI_FUNC H2D_Exist(int h) { |
30 | int _VI_FUNC H2D_Exist(int h) { |
| 31 | if (h2[h]) return 1; |
31 | if (h2[h]) return 1; |
| 32 | else return 0; |
32 | else return 0; |
| 33 | } |
33 | } |
| 34 | 34 | ||
| 35 | int _VI_FUNC H2D_GetBin(int h2d,int x, int y) { |
35 | int _VI_FUNC H2D_GetBin(int h2d,int x, int y) { |
| 36 | return x+h2[h2d]->nx * y; |
36 | return x+h2[h2d]->nx * y; |
| 37 | } |
37 | } |
| 38 | 38 | ||
| 39 | int _VI_FUNC H2D_CalculateBin(int h, int axis, double value) { |
39 | int _VI_FUNC H2D_CalculateBin(int h, int axis, double value) { |
| 40 | int nx=0; |
40 | int nx=0; |
| 41 | double xmin=0,dx=0; |
41 | double xmin=0,dx=0; |
| 42 | int bin; |
42 | int bin; |
| 43 | switch (axis) { |
43 | switch (axis) { |
| 44 | case 0: |
44 | case 0: |
| 45 | nx = H2D_GetNbinsX(h); |
45 | nx = H2D_GetNbinsX(h); |
| 46 | xmin= H2D_GetMinX(h); |
46 | xmin= H2D_GetMinX(h); |
| 47 | dx = H2D_GetStepX(h); |
47 | dx = H2D_GetStepX(h); |
| 48 | break; |
48 | break; |
| 49 | case 1: |
49 | case 1: |
| 50 | nx = H2D_GetNbinsY(h); |
50 | nx = H2D_GetNbinsY(h); |
| 51 | xmin= H2D_GetMinY(h); |
51 | xmin= H2D_GetMinY(h); |
| 52 | dx = H2D_GetStepY(h); |
52 | dx = H2D_GetStepY(h); |
| 53 | break; |
53 | break; |
| 54 | default: |
54 | default: |
| 55 | return -1; |
55 | return -1; |
| 56 | } |
56 | } |
| 57 | if (dx<1e-10) return -1; |
57 | if (dx<1e-10) return -1; |
| 58 | if (value<xmin) return -1; |
58 | if (value<xmin) return -1; |
| 59 | bin = (int)((value-xmin)/dx); |
59 | bin = (int)((value-xmin)/dx); |
| 60 | if (bin>=nx) return -1; |
60 | if (bin>=nx) return -1; |
| 61 | else return bin; |
61 | else return bin; |
| 62 | } |
62 | } |
| 63 | 63 | ||
| 64 | int _VI_FUNC H2D_Fill(int h2d,double x, double y, double val) { |
64 | int _VI_FUNC H2D_Fill(int h2d,double x, double y, double val) { |
| 65 | 65 | ||
| 66 | int ix,iy; |
66 | int ix,iy; |
| 67 | if (!h2[h2d]) return -1; |
67 | if (!h2[h2d]) return -1; |
| 68 | ix = H2D_CalculateBin(h2d,0,x); |
68 | ix = H2D_CalculateBin(h2d,0,x); |
| 69 | if (ix<0) return ix; |
69 | if (ix<0) return ix; |
| 70 | iy = H2D_CalculateBin(h2d,1,y); |
70 | iy = H2D_CalculateBin(h2d,1,y); |
| 71 | if (iy<0) return iy; |
71 | if (iy<0) return iy; |
| 72 | return H2D_SetBinContent(h2d,ix, iy, val); |
72 | return H2D_SetBinContent(h2d,ix, iy, val); |
| 73 | } |
73 | } |
| 74 | 74 | ||
| 75 | int _VI_FUNC H2D_SetBinContent(int h2d,int x, int y, double val) { |
75 | int _VI_FUNC H2D_SetBinContent(int h2d,int x, int y, double val) { |
| 76 | 76 | ||
| 77 | int idx; |
77 | int idx; |
| 78 | if (!h2[h2d]) { |
78 | if (!h2[h2d]) { |
| 79 | //Printf("FillH2D_ error h2d is not initialized\n"); |
79 | //Printf("FillH2D_ error h2d is not initialized\n"); |
| 80 | return -1; |
80 | return -1; |
| 81 | } |
81 | } |
| 82 | 82 | ||
| 83 | idx = x+y*h2[h2d]->nx; |
83 | idx = x+y*h2[h2d]->nx; |
| 84 | h2[h2d]->data[idx]+=val; |
84 | h2[h2d]->data[idx]+=val; |
| 85 | //Printf("%d %d data %f %f\n",x,y,val, h2[h2d]->data[idx]); |
85 | //Printf("%d %d data %f %f\n",x,y,val, h2[h2d]->data[idx]); |
| 86 | if (h2[h2d]->data[idx]>h2[h2d]->max) h2[h2d]->max= h2[h2d]->data[idx]; |
86 | if (h2[h2d]->data[idx]>h2[h2d]->max) h2[h2d]->max= h2[h2d]->data[idx]; |
| 87 | if (h2[h2d]->data[idx]<h2[h2d]->min) h2[h2d]->min= h2[h2d]->data[idx]; |
87 | if (h2[h2d]->data[idx]<h2[h2d]->min) h2[h2d]->min= h2[h2d]->data[idx]; |
| 88 | h2[h2d]->nentries++; |
88 | h2[h2d]->nentries++; |
| 89 | return 0; |
89 | return 0; |
| 90 | } |
90 | } |
| 91 | 91 | ||
| 92 | double _VI_FUNC H2D_GetBinContent(int h2d,int atx,int aty) { |
92 | double _VI_FUNC H2D_GetBinContent(int h2d,int atx,int aty) { |
| 93 | 93 | ||
| 94 | int idx; |
94 | int idx; |
| 95 | if (!h2[h2d]) return 0; |
95 | if (!h2[h2d]) return 0; |
| 96 | if (h2[h2d]->nx <= (unsigned int)atx) return 0; |
96 | if (h2[h2d]->nx <= (unsigned int)atx) return 0; |
| 97 | if (h2[h2d]->ny <= (unsigned int)aty) return 0; |
97 | if (h2[h2d]->ny <= (unsigned int)aty) return 0; |
| 98 | idx = atx+aty*h2[h2d]->nx; |
98 | idx = atx+aty*h2[h2d]->nx; |
| 99 | if (idx*sizeof(double) < h2[h2d]->size ) return h2[h2d]->data[idx]; |
99 | if (idx*sizeof(double) < h2[h2d]->size ) return h2[h2d]->data[idx]; |
| 100 | return 0; |
100 | return 0; |
| 101 | } |
101 | } |
| 102 | 102 | ||
| 103 | int _VI_FUNC H2D_Init(int h2d,const char *name,const char *title,int nx, double minx, double maxx, int ny, double miny, double maxy) { |
103 | int _VI_FUNC H2D_Init(int h2d,const char *name,const char *title,int nx, double minx, double maxx, int ny, double miny, double maxy) { |
| 104 | 104 | ||
| 105 | if (h2[h2d]) { |
105 | if (h2[h2d]) { |
| 106 | free(h2[h2d]->data); |
106 | free(h2[h2d]->data); |
| 107 | free(h2[h2d]); |
107 | free(h2[h2d]); |
| 108 | h2[h2d] = NULL; |
108 | h2[h2d] = NULL; |
| 109 | } |
109 | } |
| 110 | //printf("InitH2D_ hID=%d\n",h2d); |
110 | //printf("InitH2D_ hID=%d\n",h2d); |
| 111 | h2[h2d] = (H2D *) malloc(sizeof(H2D)); |
111 | h2[h2d] = (H2D *) malloc(sizeof(H2D)); |
| 112 | //h2 =h2d; |
112 | //h2 =h2d; |
| 113 | H2D_SetTitle(h2d,title); |
113 | H2D_SetTitle(h2d,title); |
| 114 | H2D_SetName(h2d,name); |
114 | H2D_SetName(h2d,name); |
| 115 | h2[h2d]->id=H2D_ID; |
115 | h2[h2d]->id=H2D_ID; |
| 116 | h2[h2d]->nx = nx; |
116 | h2[h2d]->nx = nx; |
| 117 | h2[h2d]->ny = ny; |
117 | h2[h2d]->ny = ny; |
| 118 | h2[h2d]->minx = minx; |
118 | h2[h2d]->minx = minx; |
| 119 | h2[h2d]->miny = miny; |
119 | h2[h2d]->miny = miny; |
| 120 | 120 | ||
| 121 | h2[h2d]->stepx = (nx> |
121 | h2[h2d]->stepx = (nx>0)?(maxx-minx)/(nx):0; |
| 122 | h2[h2d]->stepy = (nx> |
122 | h2[h2d]->stepy = (nx>0)?(maxy-miny)/(ny):0; |
| 123 | 123 | ||
| 124 | h2[h2d]->size = h2[h2d]->nx*h2[h2d]->ny*sizeof(double); |
124 | h2[h2d]->size = h2[h2d]->nx*h2[h2d]->ny*sizeof(double); |
| 125 | h2[h2d]->data = (double *) malloc(h2[h2d]->size); |
125 | h2[h2d]->data = (double *) malloc(h2[h2d]->size); |
| 126 | h2[h2d]->len=sizeof(H2D)-sizeof(double *)+h2[h2d]->size; |
126 | h2[h2d]->len=sizeof(H2D)-sizeof(double *)+h2[h2d]->size; |
| 127 | H2D_Clear(h2d); |
127 | H2D_Clear(h2d); |
| 128 | H2D_Print(h2d); |
128 | H2D_Print(h2d); |
| 129 | //Printf("InitH2D 0x%x\n", h2d ); |
129 | //Printf("InitH2D 0x%x\n", h2d ); |
| 130 | return 0; |
130 | return 0; |
| 131 | } |
131 | } |
| 132 | 132 | ||
| 133 | double _VI_FUNC H2D_GetXBinCenter(int h2d,int xbin) { |
133 | double _VI_FUNC H2D_GetXBinCenter(int h2d,int xbin) { |
| 134 | return h2[h2d]->minx+xbin*h2[h2d]->stepx; |
134 | return h2[h2d]->minx+(xbin+0.5)*h2[h2d]->stepx; |
| 135 | } |
135 | } |
| 136 | 136 | ||
| 137 | double _VI_FUNC H2D_GetYBinCenter(int h2d,int ybin) { |
137 | double _VI_FUNC H2D_GetYBinCenter(int h2d,int ybin) { |
| 138 | return h2[h2d]->miny+ybin*h2[h2d]->stepy; |
138 | return h2[h2d]->miny+(ybin+0.5)*h2[h2d]->stepy; |
| 139 | } |
139 | } |
| 140 | 140 | ||
| 141 | int _VI_FUNC H2D_Write2File(int h2d,FILE *fp) { |
141 | int _VI_FUNC H2D_Write2File(int h2d,FILE *fp) { |
| 142 | 142 | ||
| 143 | if (!fp) return -1; |
143 | if (!fp) return -1; |
| 144 | //printf("H2D sizeof(H2D)=%lu len-datasize=%d len=%lu datasize=%d\t",sizeof(H2D)-sizeof(double *),h2[h2d]->len-h2[h2d]->size,h2[h2d]->len,h2[h2d]->size); |
144 | //printf("H2D sizeof(H2D)=%lu len-datasize=%d len=%lu datasize=%d\t",sizeof(H2D)-sizeof(double *),h2[h2d]->len-h2[h2d]->size,h2[h2d]->len,h2[h2d]->size); |
| 145 | //printf("H2D sz=%d %d\n",sizeof(double),sizeof(double *)); |
145 | //printf("H2D sz=%d %d\n",sizeof(double),sizeof(double *)); |
| 146 | if (!H2D_Exist(h2d)){ |
146 | if (!H2D_Exist(h2d)){ |
| 147 | printf("Histogram H2D=%d is not initialized\n",h2d); |
147 | printf("Histogram H2D=%d is not initialized\n",h2d); |
| 148 | return -1; |
148 | return -1; |
| 149 | } |
149 | } |
| 150 | fwrite (h2[h2d], 1, sizeof(H2D)-sizeof(double *), fp); |
150 | fwrite (h2[h2d], 1, sizeof(H2D)-sizeof(double *), fp); |
| 151 | fwrite (h2[h2d]->data, 1, h2[h2d]->size, fp); |
151 | fwrite (h2[h2d]->data, 1, h2[h2d]->size, fp); |
| 152 | return 0; |
152 | return 0; |
| 153 | } |
153 | } |
| 154 | 154 | ||
| 155 | int _VI_FUNC H2D_Write(int h2d,const char *fname,const char *opt) { |
155 | int _VI_FUNC H2D_Write(int h2d,const char *fname,const char *opt) { |
| 156 | FILE *fp=fopen(fname,opt); |
156 | FILE *fp=fopen(fname,opt); |
| 157 | H2D_Write2File(h2d,fp); |
157 | H2D_Write2File(h2d,fp); |
| 158 | fclose(fp); |
158 | fclose(fp); |
| 159 | return 0; |
159 | return 0; |
| 160 | } |
160 | } |
| 161 | 161 | ||
| 162 | int _VI_FUNC H2D_SetTitle(int h2d,const char *title) { |
162 | int _VI_FUNC H2D_SetTitle(int h2d,const char *title) { |
| 163 | sprintf(h2[h2d]->title,"%s",title); |
163 | sprintf(h2[h2d]->title,"%s",title); |
| 164 | return 0; |
164 | return 0; |
| 165 | } |
165 | } |
| 166 | 166 | ||
| 167 | int _VI_FUNC H2D_SetTitleX(int h2d,const char *title) { |
167 | int _VI_FUNC H2D_SetTitleX(int h2d,const char *title) { |
| 168 | sprintf(h2[h2d]->titlex,"%s",title); |
168 | sprintf(h2[h2d]->titlex,"%s",title); |
| 169 | return 0; |
169 | return 0; |
| 170 | } |
170 | } |
| 171 | 171 | ||
| 172 | int _VI_FUNC H2D_SetTitleY(int h2d,const char *title) { |
172 | int _VI_FUNC H2D_SetTitleY(int h2d,const char *title) { |
| 173 | sprintf(h2[h2d]->titley,"%s",title); |
173 | sprintf(h2[h2d]->titley,"%s",title); |
| 174 | return 0; |
174 | return 0; |
| 175 | } |
175 | } |
| 176 | 176 | ||
| 177 | int _VI_FUNC H2D_SetName(int h2d,const char *title) { |
177 | int _VI_FUNC H2D_SetName(int h2d,const char *title) { |
| 178 | sprintf(h2[h2d]->name,"%s",title); |
178 | sprintf(h2[h2d]->name,"%s",title); |
| 179 | return 0; |
179 | return 0; |
| 180 | } |
180 | } |
| 181 | 181 | ||
| 182 | int _VI_FUNC H2D_GetNbinsY(int h) { |
182 | int _VI_FUNC H2D_GetNbinsY(int h) { |
| 183 | if (h2[h]) return h2[h]->ny; |
183 | if (h2[h]) return h2[h]->ny; |
| 184 | else return 0; |
184 | else return 0; |
| 185 | } |
185 | } |
| 186 | 186 | ||
| 187 | int _VI_FUNC H2D_GetNbinsX(int h) { |
187 | int _VI_FUNC H2D_GetNbinsX(int h) { |
| 188 | if (h2[h]) return h2[h]->nx; |
188 | if (h2[h]) return h2[h]->nx; |
| 189 | else return 0; |
189 | else return 0; |
| 190 | } |
190 | } |
| 191 | 191 | ||
| 192 | double _VI_FUNC H2D_GetMinY(int h) { |
192 | double _VI_FUNC H2D_GetMinY(int h) { |
| 193 | if (h2[h]) return h2[h]->miny; |
193 | if (h2[h]) return h2[h]->miny; |
| 194 | else return 0; |
194 | else return 0; |
| 195 | } |
195 | } |
| 196 | 196 | ||
| 197 | double _VI_FUNC H2D_GetMinX(int h) { |
197 | double _VI_FUNC H2D_GetMinX(int h) { |
| 198 | if (h2[h]) return h2[h]->minx; |
198 | if (h2[h]) return h2[h]->minx; |
| 199 | else return 0; |
199 | else return 0; |
| 200 | } |
200 | } |
| 201 | 201 | ||
| 202 | 202 | ||
| 203 | double _VI_FUNC H2D_GetMaxX(int h){ |
203 | double _VI_FUNC H2D_GetMaxX(int h){ |
| 204 | return h2[h]->minx+(h2[h]->nx-1)*h2[h]->stepx; |
204 | return h2[h]->minx+(h2[h]->nx-1)*h2[h]->stepx; |
| 205 | } |
205 | } |
| 206 | 206 | ||
| 207 | double _VI_FUNC H2D_GetMaxY(int h){ |
207 | double _VI_FUNC H2D_GetMaxY(int h){ |
| 208 | return h2[h]->miny+(h2[h]->ny-1)*h2[h]->stepy; |
208 | return h2[h]->miny+(h2[h]->ny-1)*h2[h]->stepy; |
| 209 | } |
209 | } |
| 210 | 210 | ||
| 211 | 211 | ||
| 212 | double _VI_FUNC H2D_GetStepY(int h) { |
212 | double _VI_FUNC H2D_GetStepY(int h) { |
| 213 | if (h2[h]) return h2[h]->stepy; |
213 | if (h2[h]) return h2[h]->stepy; |
| 214 | else return 0; |
214 | else return 0; |
| 215 | } |
215 | } |
| 216 | 216 | ||
| 217 | double _VI_FUNC H2D_GetStepX(int h) { |
217 | double _VI_FUNC H2D_GetStepX(int h) { |
| 218 | if (h2[h]) return h2[h]->stepx; |
218 | if (h2[h]) return h2[h]->stepx; |
| 219 | else return 0; |
219 | else return 0; |
| 220 | } |
220 | } |
| 221 | 221 | ||
| 222 | double _VI_FUNC H2D_GetMin(int h) { |
222 | double _VI_FUNC H2D_GetMin(int h) { |
| 223 | if (h2[h]) return h2[h]->min; |
223 | if (h2[h]) return h2[h]->min; |
| 224 | else return 0; |
224 | else return 0; |
| 225 | } |
225 | } |
| 226 | 226 | ||
| 227 | double _VI_FUNC H2D_GetMax(int h) { |
227 | double _VI_FUNC H2D_GetMax(int h) { |
| 228 | if (h2[h]) return h2[h]->max; |
228 | if (h2[h]) return h2[h]->max; |
| 229 | else return 0; |
229 | else return 0; |
| 230 | } |
230 | } |
| 231 | 231 | ||
| 232 | double * _VI_FUNC H2D_GetData(int h) { |
232 | double * _VI_FUNC H2D_GetData(int h) { |
| 233 | if (h2[h]) return h2[h]->data; |
233 | if (h2[h]) return h2[h]->data; |
| 234 | else return NULL; |
234 | else return NULL; |
| 235 | } |
235 | } |
| 236 | 236 | ||
| 237 | 237 | ||
| 238 | 238 | ||
| 239 | #ifdef _CVI_ |
239 | #ifdef _CVI_ |
| 240 | // defined only in CVI |
240 | // defined only in CVI |
| 241 | static HColorMap *colormap = NULL; |
241 | static HColorMap *colormap = NULL; |
| 242 | 242 | ||
| 243 | 243 | ||
| 244 | HColorMap * _VI_FUNC H2D_GetColorMap(void) { |
244 | HColorMap * _VI_FUNC H2D_GetColorMap(void) { |
| 245 | return colormap; |
245 | return colormap; |
| 246 | } |
246 | } |
| 247 | 247 | ||
| 248 | 248 | ||
| 249 | int _VI_FUNC H2D_SetRangeColors( double min, double max) { |
249 | int _VI_FUNC H2D_SetRangeColors( double min, double max) { |
| 250 | int i; |
250 | int i; |
| 251 | 251 | ||
| 252 | 252 | ||
| 253 | if (colormap == NULL) { |
253 | if (colormap == NULL) { |
| 254 | colormap = malloc(sizeof(HColorMap)); |
254 | colormap = malloc(sizeof(HColorMap)); |
| 255 | 255 | ||
| 256 | colormap->numberofColors = 5; |
256 | colormap->numberofColors = 5; |
| 257 | colormap->array = malloc(colormap->numberofColors*sizeof(ColorMapEntry)); |
257 | colormap->array = malloc(colormap->numberofColors*sizeof(ColorMapEntry)); |
| 258 | 258 | ||
| 259 | colormap->array[0].color = 0x0000ff; //BLUE |
259 | colormap->array[0].color = 0x0000ff; //BLUE |
| 260 | colormap->array[1].color = 0x00ff00; //GREEN |
260 | colormap->array[1].color = 0x00ff00; //GREEN |
| 261 | colormap->array[2].color = 0xffff00; //YELLOW |
261 | colormap->array[2].color = 0xffff00; //YELLOW |
| 262 | colormap->array[3].color = 0xff8000; //ORANGE |
262 | colormap->array[3].color = 0xff8000; //ORANGE |
| 263 | colormap->array[4].color = 0xff0000; //RED |
263 | colormap->array[4].color = 0xff0000; //RED |
| 264 | 264 | ||
| 265 | colormap->HiColor =colormap->array[colormap->numberofColors-1].color ; |
265 | colormap->HiColor =colormap->array[colormap->numberofColors-1].color ; |
| 266 | } |
266 | } |
| 267 | if (colormap->numberofColors<2) return -1; |
267 | if (colormap->numberofColors<2) return -1; |
| 268 | double fx = (max-min)/(colormap->numberofColors-1); |
268 | double fx = (max-min)/(colormap->numberofColors-1); |
| 269 | for (i=0; i<colormap->numberofColors; i++) { |
269 | for (i=0; i<colormap->numberofColors; i++) { |
| 270 | colormap->array[i].dataValue.valDouble=i*fx+min; |
270 | colormap->array[i].dataValue.valDouble=i*fx+min; |
| 271 | } |
271 | } |
| 272 | return 0; |
272 | return 0; |
| 273 | } |
273 | } |
| 274 | 274 | ||
| 275 | 275 | ||
| 276 | 276 | ||
| 277 | 277 | ||
| 278 | 278 | ||
| 279 | int _VI_FUNC H2D_Draw(int histogram,int panel, int control, int *plothandle) { |
279 | int _VI_FUNC H2D_Draw(int histogram,int panel, int control, int *plothandle) { |
| 280 | 280 | ||
| 281 | if (!H2D_Exist(histogram)) { |
281 | if (!H2D_Exist(histogram)) { |
| 282 | printf("2D Histogram %d does not exist!\n",histogram); |
282 | printf("2D Histogram %d does not exist!\n",histogram); |
| 283 | return 0; |
283 | return 0; |
| 284 | } |
284 | } |
| 285 | 285 | ||
| 286 | 286 | ||
| 287 | if (*plothandle> 0 ) DeleteGraphPlot (panel, control, *plothandle, VAL_IMMEDIATE_DRAW); |
287 | if (*plothandle> 0 ) DeleteGraphPlot (panel, control, *plothandle, VAL_IMMEDIATE_DRAW); |
| 288 | H2D_SetRangeColors(H2D_GetMin(histogram),H2D_GetMax(histogram)); |
288 | H2D_SetRangeColors(H2D_GetMin(histogram),H2D_GetMax(histogram)); |
| 289 | *plothandle = PlotScaledIntensity (panel, control, |
289 | *plothandle = PlotScaledIntensity (panel, control, |
| 290 | H2D_GetData(histogram), |
290 | H2D_GetData(histogram), |
| 291 | H2D_GetNbinsX(histogram), |
291 | H2D_GetNbinsX(histogram), |
| 292 | H2D_GetNbinsY(histogram), |
292 | H2D_GetNbinsY(histogram), |
| 293 | VAL_DOUBLE, |
293 | VAL_DOUBLE, |
| 294 | H2D_GetStepY(histogram), |
294 | H2D_GetStepY(histogram), |
| 295 |
|
295 | H2D_GetYBinCenter(histogram,0), |
| 296 | H2D_GetStepX(histogram), |
296 | H2D_GetStepX(histogram), |
| 297 |
|
297 | H2D_GetXBinCenter(histogram,0), |
| 298 | colormap->array, |
298 | colormap->array, |
| 299 | colormap->HiColor, |
299 | colormap->HiColor, |
| 300 | colormap->numberofColors, 1, 0); |
300 | colormap->numberofColors, 1, 0); |
| 301 | RefreshGraph (panel, control); |
301 | RefreshGraph (panel, control); |
| 302 | 302 | ||
| 303 | ProcessSystemEvents (); |
303 | ProcessSystemEvents (); |
| 304 | return *plothandle; |
304 | return *plothandle; |
| 305 | 305 | ||
| 306 | } |
306 | } |
| 307 | 307 | ||
| 308 | #endif |
308 | #endif |
| 309 | 309 | ||