1 | #pragma TextEncoding = "MacRoman" |
---|
2 | #pragma rtGlobals=3 // Use modern global access method and strict wave access. |
---|
3 | |
---|
4 | // |
---|
5 | // Mask utilities: |
---|
6 | // - loader |
---|
7 | // - simple editor |
---|
8 | // - save mask file |
---|
9 | // - assign mask file to data file |
---|
10 | // |
---|
11 | // |
---|
12 | // this is (at first) to be a very simple editor to generate masks row/column wise, not drawing |
---|
13 | // masks with arbitrary shape. |
---|
14 | // |
---|
15 | // |
---|
16 | // |
---|
17 | // |
---|
18 | // |
---|
19 | // |
---|
20 | |
---|
21 | ///// LOADING |
---|
22 | |
---|
23 | // TODO |
---|
24 | // -- when mask is loaded, need to be sure to clean up the "extra" waves that may be present |
---|
25 | // |
---|
26 | // -- the overlay and the currentTube waves since these are not overwritten or killed when new mask |
---|
27 | // data is read in from HDF. need to manually? check for these and delete then, or the data and |
---|
28 | // mask overlay will be out of sync. |
---|
29 | // |
---|
30 | |
---|
31 | |
---|
32 | // passing null file string presents a dialog |
---|
33 | // called from the Main Button " Read Mask" |
---|
34 | Proc V_LoadMASKData() |
---|
35 | V_LoadHDF5Data("","MSK") |
---|
36 | End |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | //// DRAWING/SAVING |
---|
41 | // |
---|
42 | // (DONE) |
---|
43 | // x- CHANGE the mask behavior to a more logical choice - and consistent with SANS |
---|
44 | // x- CHANGE to: |
---|
45 | // 1 == mask == discard data |
---|
46 | // 0 == no Mask == keep data |
---|
47 | // x- and then make the corresponding changes in the I(Q) routines |
---|
48 | // |
---|
49 | // x- move the mask generating utilities from VC_HDF5_Utils into this procedure - to keep |
---|
50 | // all of the mask procedures together |
---|
51 | |
---|
52 | |
---|
53 | // TODO |
---|
54 | // -- document the arrow keys moving the tube number and adding/deleting tubes from the mask |
---|
55 | // this is done through a window hook function (LR moves tube number, up/down = add/delete) |
---|
56 | // |
---|
57 | // (DONE) |
---|
58 | // x- (NO)- Igor 7 is necessary for some VSANS functionality, so do not support Igor 6 |
---|
59 | // x (no)make the arrow keys Igor 6 compatible - search for specialKeyCode or Keyboard Events in the help file |
---|
60 | // and what needs to be replaced for Igor 6 |
---|
61 | // DONE |
---|
62 | // x- for L/R panels, the maksing of columns should be sufficient. Tubes are vertical. For the T/B panels |
---|
63 | // the L/R panels cast a vertical shadow (=vertical mask) AND the tubes are horizontal, so the individual |
---|
64 | // tubes will likely need to be masked in a horizontal line too, per tube. ADD this in... |
---|
65 | |
---|
66 | |
---|
67 | //TODO |
---|
68 | // x- draw a mask |
---|
69 | // x- save a mask (all panels) |
---|
70 | // -- move everything into it's own folder, rather than root: |
---|
71 | // -- be able to save the mask name to the RAW data file |
---|
72 | // -- be able to read a mask based on what name is in the data file |
---|
73 | // |
---|
74 | // x- biggest thing now is to re-write the DrawDetPanel() routine from the beamCenter.ipf |
---|
75 | // to do what this panel needs |
---|
76 | // |
---|
77 | // x- add this to the list of includes, move the file to SVN, and add it. |
---|
78 | // |
---|
79 | // -- for working with VCALC -- maybe have an automatic generator (if val < -2e6, mask = 0) |
---|
80 | // this can be checked column-wise to go faster (1st index) |
---|
81 | // |
---|
82 | // x- re-write V_OverlayMask to make the "overlay" wave that has the NaNs, and then the drawing |
---|
83 | // routines need to be aware of this |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | // called from the main button "Draw Mask" |
---|
88 | Proc V_Edit_a_Mask() |
---|
89 | V_EditMask() |
---|
90 | end |
---|
91 | |
---|
92 | Function V_EditMask() |
---|
93 | DoWindow/F MaskEditPanel |
---|
94 | if(V_flag==0) |
---|
95 | |
---|
96 | NewDataFolder/O root:Packages:NIST:VSANS:Globals:Mask |
---|
97 | |
---|
98 | Variable/G root:Packages:NIST:VSANS:Globals:Mask:gMaskTube = 0 |
---|
99 | Variable/G root:Packages:NIST:VSANS:Globals:Mask:gMaskMaxIndex = 47 |
---|
100 | |
---|
101 | // check for a mask, if not present, generate a default mask |
---|
102 | String str="FT" |
---|
103 | wave/Z maskW = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":data") |
---|
104 | if(!WaveExists(maskW)) |
---|
105 | V_GenerateDefaultMask() |
---|
106 | endif |
---|
107 | |
---|
108 | Execute "V_MaskEditorPanel()" |
---|
109 | endif |
---|
110 | End |
---|
111 | |
---|
112 | // |
---|
113 | // TODO |
---|
114 | // -- may need to adjust the display for the different pixel dimensions |
---|
115 | // ModifyGraph width={Plan,1,bottom,left} |
---|
116 | // |
---|
117 | // TODO |
---|
118 | // need buttons for: |
---|
119 | // -- quit (to exit gracefully) |
---|
120 | // -- help (button is there, fill in the content) |
---|
121 | // |
---|
122 | Proc V_MaskEditorPanel() : Panel |
---|
123 | PauseUpdate; Silent 1 // building window... |
---|
124 | |
---|
125 | NewPanel /W=(662,418,1300,960)/N=MaskEditPanel /K=1 |
---|
126 | // ShowTools/A |
---|
127 | |
---|
128 | PopupMenu popup_0,pos={20,50},size={109,20},proc=V_SetMaskPanelPopMenuProc,title="Detector Panel" |
---|
129 | PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;MR;ML;MT;MB;B;\"" |
---|
130 | PopupMenu popup_2,pos={20,20},size={109,20},title="Data Source"//,proc=SetFldrPopMenuProc |
---|
131 | PopupMenu popup_2,mode=1,popvalue="RAW",value= #"\"RAW;SAM;VCALC;\"" |
---|
132 | |
---|
133 | SetVariable setvar0,pos={257.00,20.00},size={150.00,14.00},title="tube number" |
---|
134 | SetVariable setvar0,limits={0,127,1},value=root:Packages:NIST:VSANS:Globals:Mask:gMaskTube |
---|
135 | Button button_0,pos={257,46.00},size={50.00,20.00},proc=V_AddToMaskButtonProc,title="Add" |
---|
136 | Button button_1,pos={319.00,46.00},size={50.00,20.00},proc=V_RemoveFromMaskButtonProc,title="Del" |
---|
137 | Button button_2,pos={409.00,46.00},size={90.00,20.00},proc=V_ToggleMaskButtonProc,title="Toggle" |
---|
138 | Button button_3,pos={509.00,46.00},size={80.00,20.00},proc=V_SaveMaskButtonProc,title="Save" |
---|
139 | Button button_4,pos={603.00,10.00},size={20.00,20.00},proc=V_DrawMaskHelpButtonProc,title="?" |
---|
140 | CheckBox check_0,pos={190.00,23.00},size={37.00,15.00},proc=V_DrawMaskRadioCheckProc,title="Row" |
---|
141 | CheckBox check_0,value= 0,mode=1 |
---|
142 | CheckBox check_1,pos={190.00,46.00},size={32.00,15.00},proc=V_DrawMaskRadioCheckProc,title="Col" |
---|
143 | CheckBox check_1,value= 1,mode=1 |
---|
144 | |
---|
145 | SetWindow MaskEditPanel, hook(MyHook)=V_MaskWindowHook |
---|
146 | |
---|
147 | // draw the correct images |
---|
148 | //draw the detector panel |
---|
149 | V_DrawPanelToMask("FL") |
---|
150 | |
---|
151 | // overlay the current mask |
---|
152 | V_OverlayMask("FL",1) |
---|
153 | |
---|
154 | EndMacro |
---|
155 | |
---|
156 | Function V_DrawMaskHelpButtonProc(ba) : ButtonControl |
---|
157 | STRUCT WMButtonAction &ba |
---|
158 | |
---|
159 | switch( ba.eventCode ) |
---|
160 | case 2: // mouse up |
---|
161 | // click code here |
---|
162 | DoAlert 0, "Draw Mask Help not written yet..." |
---|
163 | break |
---|
164 | case -1: // control being killed |
---|
165 | break |
---|
166 | endswitch |
---|
167 | |
---|
168 | return 0 |
---|
169 | End |
---|
170 | |
---|
171 | // |
---|
172 | //a simple toggle between the two, so the logic is not done in the cleanest way. |
---|
173 | // |
---|
174 | // update the limits on the tube nubmer based on row/col and the panel (gMaskMaxIndex global) |
---|
175 | // |
---|
176 | Function V_DrawMaskRadioCheckProc(cba) : CheckBoxControl |
---|
177 | STRUCT WMCheckboxAction &cba |
---|
178 | |
---|
179 | switch( cba.eventCode ) |
---|
180 | case 2: // mouse up |
---|
181 | Variable checked = cba.checked |
---|
182 | String name = cba.ctrlName |
---|
183 | |
---|
184 | //get information to update the limits on the tube number setvar |
---|
185 | ControlInfo popup_0 |
---|
186 | String str=S_Value |
---|
187 | wave data = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":data") |
---|
188 | Variable val |
---|
189 | |
---|
190 | // update the radio button status and the setvar limits |
---|
191 | if(cmpstr(name,"check_0") == 0) // ROW is being selected |
---|
192 | CheckBox check_0,value = 1 |
---|
193 | CheckBox check_1,value = 0 |
---|
194 | val = DimSize(data, 1) -1 |
---|
195 | else |
---|
196 | // COL is being selected |
---|
197 | CheckBox check_0,value = 0 |
---|
198 | CheckBox check_1,value = 1 |
---|
199 | val = DimSize(data, 0) -1 |
---|
200 | endif |
---|
201 | |
---|
202 | // print "max = ",val |
---|
203 | |
---|
204 | SetVariable setvar0,limits={0,val,1} |
---|
205 | NVAR gVal = root:Packages:NIST:VSANS:Globals:Mask:gMaskTube |
---|
206 | NVAR gMax = root:Packages:NIST:VSANS:Globals:Mask:gMaskMaxIndex |
---|
207 | gMax = val |
---|
208 | if(gVal > val) |
---|
209 | gVal = val |
---|
210 | endif |
---|
211 | |
---|
212 | break |
---|
213 | case -1: // control being killed |
---|
214 | break |
---|
215 | endswitch |
---|
216 | |
---|
217 | return 0 |
---|
218 | End |
---|
219 | |
---|
220 | Function V_MaskWindowHook(s) |
---|
221 | STRUCT WMWinHookStruct &s |
---|
222 | |
---|
223 | Variable hookResult = 0 // 0 if we do not handle event, 1 if we handle it. |
---|
224 | |
---|
225 | String message = "" |
---|
226 | |
---|
227 | switch(s.eventCode) |
---|
228 | case 11: // Keyboard event |
---|
229 | // String keyCodeInfo |
---|
230 | // sprintf keyCodeInfo, "s.keycode = 0x%04X", s.keycode |
---|
231 | // if (strlen(message) > 0) |
---|
232 | // message += "\r" |
---|
233 | // endif |
---|
234 | // message +=keyCodeInfo |
---|
235 | // |
---|
236 | // message += "\r" |
---|
237 | // String specialKeyCodeInfo |
---|
238 | // sprintf specialKeyCodeInfo, "s.specialKeyCode = %d", s.specialKeyCode |
---|
239 | // message +=specialKeyCodeInfo |
---|
240 | // message += "\r" |
---|
241 | // |
---|
242 | // String keyTextInfo |
---|
243 | // sprintf keyTextInfo, "s.keyText = \"%s\"", s.keyText |
---|
244 | // message +=keyTextInfo |
---|
245 | // |
---|
246 | // String text = "\\Z24" + message |
---|
247 | // Textbox /C/N=Message/W=KeyboardEventsGraph/A=MT/X=0/Y=15 text |
---|
248 | |
---|
249 | // NOTE: these special keyCodes are all Igor-7 ONLY |
---|
250 | |
---|
251 | // Note that I need to keep track of the index value since I'm intercepting the |
---|
252 | // SetVariable event here. I need to keep the index in range. |
---|
253 | STRUCT WMButtonAction ba |
---|
254 | ba.eventCode = 2 |
---|
255 | NVAR tubeVal = root:Packages:NIST:VSANS:Globals:Mask:gMaskTube |
---|
256 | if(s.specialKeyCode == 100) |
---|
257 | //left arrow |
---|
258 | tubeVal -= 1 |
---|
259 | endif |
---|
260 | if(s.specialKeyCode == 101) |
---|
261 | //right arrow |
---|
262 | tubeVal += 1 |
---|
263 | endif |
---|
264 | if(s.specialKeyCode == 102) |
---|
265 | //up arrow |
---|
266 | V_AddToMaskButtonProc(ba) |
---|
267 | endif |
---|
268 | if(s.specialKeyCode == 103) |
---|
269 | //down arrow |
---|
270 | V_RemoveFromMaskButtonProc(ba) |
---|
271 | endif |
---|
272 | |
---|
273 | // enforce the limits on the setvar |
---|
274 | NVAR gMax = root:Packages:NIST:VSANS:Globals:Mask:gMaskMaxIndex |
---|
275 | if(tubeVal > gMax) |
---|
276 | tubeVal = gMax |
---|
277 | endif |
---|
278 | if(tubeVal < 0) |
---|
279 | tubeVal = 0 |
---|
280 | endif |
---|
281 | |
---|
282 | // draw the "currentTube" every time |
---|
283 | ControlInfo popup_0 |
---|
284 | String str=S_Value |
---|
285 | wave currentTube = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":currentTube") |
---|
286 | |
---|
287 | // update so that the proper row is displayed on the currentTube |
---|
288 | currentTube = 0 |
---|
289 | |
---|
290 | ControlInfo check_0 // is it row? |
---|
291 | Variable isRow = V_value |
---|
292 | if(isRow) |
---|
293 | currentTube[][tubeVal] = 1 |
---|
294 | else |
---|
295 | currentTube[tubeVal][] = 1 |
---|
296 | endif |
---|
297 | |
---|
298 | |
---|
299 | hookResult = 1 // We handled keystroke |
---|
300 | break |
---|
301 | endswitch |
---|
302 | |
---|
303 | return hookResult // If non-zero, we handled event and Igor will ignore it. |
---|
304 | End |
---|
305 | |
---|
306 | |
---|
307 | Function V_ToggleMaskButtonProc(ba) : ButtonControl |
---|
308 | STRUCT WMButtonAction &ba |
---|
309 | |
---|
310 | switch( ba.eventCode ) |
---|
311 | case 2: // mouse up |
---|
312 | // click code here |
---|
313 | |
---|
314 | ControlInfo popup_0 |
---|
315 | String str=S_Value |
---|
316 | |
---|
317 | wave/Z overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":overlay") |
---|
318 | |
---|
319 | CheckDisplayed/W=MaskEditPanel#DetData overlay |
---|
320 | Variable state = !(V_flag) //if V_flag == 0, then set to 1 (and vice versa) |
---|
321 | V_OverlayMask(str,state) |
---|
322 | |
---|
323 | break |
---|
324 | case -1: // control being killed |
---|
325 | break |
---|
326 | endswitch |
---|
327 | |
---|
328 | return 0 |
---|
329 | End |
---|
330 | |
---|
331 | |
---|
332 | Function V_AddToMaskButtonProc(ba) : ButtonControl |
---|
333 | STRUCT WMButtonAction &ba |
---|
334 | |
---|
335 | switch( ba.eventCode ) |
---|
336 | case 2: // mouse up |
---|
337 | // click code here |
---|
338 | ControlInfo popup_0 |
---|
339 | String str=S_Value |
---|
340 | |
---|
341 | wave/Z maskData = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":data") |
---|
342 | |
---|
343 | Variable val |
---|
344 | ControlInfo setvar0 //get the tube number |
---|
345 | val = V_Value |
---|
346 | |
---|
347 | ControlInfo check_0 // is it row? |
---|
348 | Variable isRow = V_value |
---|
349 | if(isRow) |
---|
350 | maskData[][val] = 1 |
---|
351 | else |
---|
352 | maskData[val][] = 1 |
---|
353 | endif |
---|
354 | |
---|
355 | V_OverlayMask(str,1) |
---|
356 | |
---|
357 | break |
---|
358 | case -1: // control being killed |
---|
359 | break |
---|
360 | endswitch |
---|
361 | |
---|
362 | return 0 |
---|
363 | End |
---|
364 | |
---|
365 | Function V_RemoveFromMaskButtonProc(ba) : ButtonControl |
---|
366 | STRUCT WMButtonAction &ba |
---|
367 | |
---|
368 | switch( ba.eventCode ) |
---|
369 | case 2: // mouse up |
---|
370 | // click code here |
---|
371 | ControlInfo popup_0 |
---|
372 | String str=S_Value |
---|
373 | |
---|
374 | wave/Z maskData = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":data") |
---|
375 | |
---|
376 | Variable val |
---|
377 | ControlInfo setvar0 // get the tube number |
---|
378 | val = V_Value |
---|
379 | |
---|
380 | ControlInfo check_0 // is it row? |
---|
381 | Variable isRow = V_value |
---|
382 | if(isRow) |
---|
383 | maskData[][val] = 0 |
---|
384 | else |
---|
385 | maskData[val][] = 0 |
---|
386 | endif |
---|
387 | |
---|
388 | V_OverlayMask(str,1) |
---|
389 | |
---|
390 | break |
---|
391 | case -1: // control being killed |
---|
392 | break |
---|
393 | endswitch |
---|
394 | |
---|
395 | return 0 |
---|
396 | End |
---|
397 | |
---|
398 | // |
---|
399 | // function to choose which detector panel to display, and then to actually display it |
---|
400 | // |
---|
401 | Function V_SetMaskPanelPopMenuProc(pa) : PopupMenuControl |
---|
402 | STRUCT WMPopupAction &pa |
---|
403 | |
---|
404 | switch( pa.eventCode ) |
---|
405 | case 2: // mouse up |
---|
406 | Variable popNum = pa.popNum |
---|
407 | String popStr = pa.popStr |
---|
408 | |
---|
409 | // remove the old image (it may not be the right shape) |
---|
410 | // -- but make sure it exists first... |
---|
411 | String childList = ChildWindowList("MaskEditPanel") |
---|
412 | Variable flag |
---|
413 | |
---|
414 | flag = WhichListItem("DetData", ChildList) //returns -1 if not in list, 0+ otherwise |
---|
415 | if(flag != -1) |
---|
416 | KillWindow MaskEditPanel#DetData |
---|
417 | endif |
---|
418 | |
---|
419 | flag = WhichListItem("ModelData", ChildList) |
---|
420 | if(flag != -1) |
---|
421 | KillWindow MaskEditPanel#ModelData |
---|
422 | endif |
---|
423 | |
---|
424 | // draw the correct images |
---|
425 | V_DrawPanelToMask(popStr) |
---|
426 | |
---|
427 | // fake a "click" on the radio buttons to re-set the row/col limits |
---|
428 | STRUCT WMCheckboxAction cba |
---|
429 | cba.eventCode = 2 |
---|
430 | |
---|
431 | ControlInfo check_0 |
---|
432 | if(V_flag == 1) //row is currently selected |
---|
433 | cba.ctrlName = "check_0" |
---|
434 | else |
---|
435 | cba.ctrlName = "check_1" |
---|
436 | endif |
---|
437 | |
---|
438 | V_DrawMaskRadioCheckProc(cba) //call the radio button action proc |
---|
439 | |
---|
440 | //overlay the mask |
---|
441 | V_OverlayMask(popStr,1) |
---|
442 | |
---|
443 | break |
---|
444 | case -1: // control being killed |
---|
445 | break |
---|
446 | endswitch |
---|
447 | |
---|
448 | return 0 |
---|
449 | End |
---|
450 | |
---|
451 | // |
---|
452 | // SEE DrawDetPanel() in the BeamCenter file |
---|
453 | // |
---|
454 | // TODO |
---|
455 | // x- currently is hard-wired for the simulation path! need to make it more generic, especially for RAW data |
---|
456 | // |
---|
457 | // -- need to adjust the size of the image subwindows |
---|
458 | // |
---|
459 | // -- need to do something for panel "B". currently ignored |
---|
460 | // |
---|
461 | // |
---|
462 | // draw the selected panel and the model calculation, adjusting for the |
---|
463 | // orientation of the panel and the number of pixels, and pixel sizes |
---|
464 | Function V_DrawPanelToMask(str) |
---|
465 | String str |
---|
466 | |
---|
467 | // from the selection, find the path to the data |
---|
468 | |
---|
469 | Variable xDim,yDim |
---|
470 | Variable left,top,right,bottom |
---|
471 | Variable height, width |
---|
472 | Variable left2,top2,right2,bottom2 |
---|
473 | Variable nPix_X,nPix_Y,pixSize_X,pixSize_Y |
---|
474 | |
---|
475 | |
---|
476 | // Wave dispW=root:curDispPanel |
---|
477 | |
---|
478 | //plot it in the subwindow with the proper aspect and positioning |
---|
479 | // for 48x256 (8mm x 4mm), aspect = (256/2)/48 = 2.67 (LR panels) |
---|
480 | // for 128x48 (4mm x 8 mm), aspect = 48/(128/2) = 0.75 (TB panels) |
---|
481 | |
---|
482 | |
---|
483 | // using two switches -- one to set the panel-specific dimensions |
---|
484 | // and the other to set the "common" values, some of which are based on the panel dimensions |
---|
485 | |
---|
486 | // set the source of the data. not always VCALC anymore |
---|
487 | String folder |
---|
488 | ControlInfo popup_2 |
---|
489 | folder = S_Value |
---|
490 | |
---|
491 | // TODO -- fix all of this mess |
---|
492 | if(cmpstr(folder,"VCALC") == 0) |
---|
493 | // panel-specific values |
---|
494 | Variable VC_nPix_X = VCALC_get_nPix_X(str) |
---|
495 | Variable VC_nPix_Y = VCALC_get_nPix_Y(str) |
---|
496 | Variable VC_pixSize_X = VCALC_getPixSizeX(str) |
---|
497 | Variable VC_pixSize_Y = VCALC_getPixSizeY(str) |
---|
498 | |
---|
499 | |
---|
500 | // if VCALC declare this way |
---|
501 | wave newW = $("root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_"+str+":det_"+str) |
---|
502 | nPix_X = VC_nPix_X |
---|
503 | nPix_Y = VC_nPix_Y |
---|
504 | pixSize_X = VC_pixSize_X |
---|
505 | pixSize_Y = VC_pixSize_Y |
---|
506 | |
---|
507 | else |
---|
508 | // TODO: if real data, need new declaration w/ data as the wave name |
---|
509 | wave newW = $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+str+":data") |
---|
510 | |
---|
511 | nPix_X = V_getDet_pixel_num_x(folder,str) |
---|
512 | nPix_Y = V_getDet_pixel_num_Y(folder,str) |
---|
513 | pixSize_X = V_getDet_x_pixel_size(folder,str)/10 |
---|
514 | pixSize_Y = V_getDet_y_pixel_size(folder,str)/10 |
---|
515 | endif |
---|
516 | |
---|
517 | |
---|
518 | Variable scale = 10 |
---|
519 | |
---|
520 | // common values (panel position, etc) |
---|
521 | // TODO -- units are absolute, based on pixels in cm. make sure this is always correct |
---|
522 | strswitch(str) |
---|
523 | case "FL": |
---|
524 | case "FR": |
---|
525 | case "ML": |
---|
526 | case "MR": |
---|
527 | width = trunc(nPix_X*pixSize_X *scale*1.15) //48 tubes @ 8 mm |
---|
528 | height = trunc(nPix_Y*pixSize_Y *scale*0.8) //128 pixels @ 8 mm |
---|
529 | |
---|
530 | left = 20 |
---|
531 | top = 80 |
---|
532 | right = left+width |
---|
533 | bottom = top+height |
---|
534 | |
---|
535 | left2 = right + 20 |
---|
536 | right2 = left2 + width |
---|
537 | top2 = top |
---|
538 | bottom2 = bottom |
---|
539 | |
---|
540 | break |
---|
541 | case "FT": |
---|
542 | case "FB": |
---|
543 | case "MT": |
---|
544 | case "MB": |
---|
545 | width = trunc(nPix_X*pixSize_X *scale*1.) //128 pix @ 4 mm |
---|
546 | height = trunc(nPix_Y*pixSize_Y *scale) // 48 tubes @ 8 mm |
---|
547 | |
---|
548 | left = 20 |
---|
549 | top = 80 |
---|
550 | right = left+width |
---|
551 | bottom = top+height |
---|
552 | |
---|
553 | left2 = left |
---|
554 | right2 = right |
---|
555 | top2 = top + height + 20 |
---|
556 | bottom2 = bottom + height + 20 |
---|
557 | |
---|
558 | break |
---|
559 | case "B": |
---|
560 | width = trunc(nPix_X/3.2) // |
---|
561 | height = trunc(nPix_Y/3.2) // |
---|
562 | |
---|
563 | left = 20 |
---|
564 | top = 80 |
---|
565 | right = left+width |
---|
566 | bottom = top+height |
---|
567 | |
---|
568 | Print left,top,right,bottom |
---|
569 | |
---|
570 | break |
---|
571 | default: |
---|
572 | return(0) //just exit |
---|
573 | endswitch |
---|
574 | |
---|
575 | SetDataFolder root:Packages:NIST:VSANS:Globals:Mask |
---|
576 | |
---|
577 | // generate the new panel display |
---|
578 | duplicate/O newW curDispPanel |
---|
579 | SetScale/P x 0,1, curDispPanel |
---|
580 | SetScale/P y 0,1, curDispPanel |
---|
581 | |
---|
582 | NVAR defaultLogScaling = root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault |
---|
583 | if(defaultLogScaling) |
---|
584 | Wave LookupWave = root:Packages:NIST:VSANS:Globals:logLookupWave |
---|
585 | else |
---|
586 | Wave LookupWave = root:Packages:NIST:VSANS:Globals:linearLookupWave |
---|
587 | endif |
---|
588 | |
---|
589 | //draw the detector panel |
---|
590 | Display/W=(left,top,right,bottom)/HOST=# |
---|
591 | AppendImage curDispPanel |
---|
592 | ModifyImage curDispPanel ctab= {*,*,ColdWarm,0} |
---|
593 | // ModifyImage curDispPanel log=1 // this fails, since there are data values that are zero |
---|
594 | ModifyImage curDispPanel ctabAutoscale=0,lookup= LookupWave |
---|
595 | Label left "Y pixels" |
---|
596 | Label bottom "X pixels" |
---|
597 | RenameWindow #,DetData |
---|
598 | SetActiveSubwindow ## |
---|
599 | |
---|
600 | DoUpdate |
---|
601 | |
---|
602 | SetDataFolder root: |
---|
603 | return(0) |
---|
604 | End |
---|
605 | |
---|
606 | // |
---|
607 | // overlay the mask |
---|
608 | // |
---|
609 | // (DONE) |
---|
610 | // x- remove the old mask first |
---|
611 | // x- make the mask "toggle" to remove it |
---|
612 | // x- go see SANS for color, implementation, etc. |
---|
613 | // x- un-comment the (two) calls |
---|
614 | // |
---|
615 | // |
---|
616 | //toggles a mask on/off of the SANS_Data window |
---|
617 | // points directly to window, doesn't need current display type |
---|
618 | // |
---|
619 | // if state==1, show the mask, if ==0, hide the mask |
---|
620 | // |
---|
621 | //** This assumes that if the overlay is/not present on the image display, then the currentTube is also there/not |
---|
622 | // and is not checked |
---|
623 | // |
---|
624 | Function V_OverlayMask(str,state) |
---|
625 | String str |
---|
626 | Variable state |
---|
627 | |
---|
628 | |
---|
629 | String maskPath = "root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":data" |
---|
630 | if(WaveExists($maskPath) == 1) |
---|
631 | if(state == 1) |
---|
632 | //duplicate the mask, which is named "data" |
---|
633 | wave maskW = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":data") |
---|
634 | |
---|
635 | Duplicate/O maskW $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":overlay") |
---|
636 | wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":overlay") |
---|
637 | Duplicate/O maskW $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":currentTube") |
---|
638 | wave currentTube = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":currentTube") |
---|
639 | |
---|
640 | Redimension/D overlay,currentTube |
---|
641 | SetScale/P x 0,1, overlay,currentTube |
---|
642 | SetScale/P y 0,1, overlay,currentTube |
---|
643 | |
---|
644 | // overlay = (maskW == 1) ? 1 : NaN //no need to do this - simply adjust the coloring |
---|
645 | |
---|
646 | // update so that the proper row is displayed on the currentTube |
---|
647 | currentTube = 0 |
---|
648 | |
---|
649 | Variable val |
---|
650 | ControlInfo setvar0 //get the tube number |
---|
651 | val = V_Value |
---|
652 | |
---|
653 | ControlInfo check_0 // is it row? |
---|
654 | Variable isRow = V_value |
---|
655 | if(isRow) |
---|
656 | currentTube[][val] = 1 |
---|
657 | else |
---|
658 | currentTube[val][] = 1 |
---|
659 | endif |
---|
660 | |
---|
661 | CheckDisplayed/W=MaskEditPanel#DetData overlay |
---|
662 | if(V_flag==0) //so the overlay doesn't get appended more than once |
---|
663 | AppendImage/W=MaskEditPanel#DetData overlay |
---|
664 | AppendImage/W=MaskEditPanel#DetData currentTube |
---|
665 | // ModifyImage/W=MaskEditPanel#DetData overlay ctab= {0.9,1,BlueRedGreen,0} ,minRGB=NaN,maxRGB=0 |
---|
666 | ModifyImage/W=MaskEditPanel#DetData overlay ctab= {0.9,0.95,BlueRedGreen,0} ,minRGB=NaN,maxRGB=(0,65000,0,40000) |
---|
667 | ModifyImage/W=MaskEditPanel#DetData currentTube ctab= {0.9,1,CyanMagenta,0} ,minRGB=NaN,maxRGB=0 |
---|
668 | // ModifyImage/W=MaskEditPanel#DetData overlay ctab= {0,*,BlueRedGreen,0} |
---|
669 | endif |
---|
670 | endif |
---|
671 | |
---|
672 | if(state == 0) |
---|
673 | wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":overlay") |
---|
674 | wave currentTube = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":currentTube") |
---|
675 | |
---|
676 | CheckDisplayed/W=MaskEditPanel#DetData overlay |
---|
677 | // Print "V_flag = ",V_flag |
---|
678 | |
---|
679 | If(V_Flag == 1) //overlay is present |
---|
680 | RemoveImage/W=MaskEditPanel#DetData overlay |
---|
681 | RemoveImage/W=MaskEditPanel#DetData currentTube |
---|
682 | endif |
---|
683 | endif |
---|
684 | Endif |
---|
685 | |
---|
686 | return(0) |
---|
687 | End |
---|
688 | |
---|
689 | |
---|
690 | Function V_SaveMaskButtonProc(ba) : ButtonControl |
---|
691 | STRUCT WMButtonAction &ba |
---|
692 | |
---|
693 | switch( ba.eventCode ) |
---|
694 | case 2: // mouse up |
---|
695 | // click code here |
---|
696 | |
---|
697 | // fills in a "default mask" in a separate folder to then write out |
---|
698 | Execute "H_Setup_VSANS_MASK_Structure()" |
---|
699 | |
---|
700 | // fill with current "stuff" |
---|
701 | SetDataFolder root:VSANS_MASK_file:entry |
---|
702 | Wave/T title = title |
---|
703 | title = "This is a custom MASK file for VSANS: VSANS_MASK" |
---|
704 | SetDataFolder root: |
---|
705 | |
---|
706 | |
---|
707 | // copy over what was actually drawn for all of the detector panels |
---|
708 | |
---|
709 | Variable ii |
---|
710 | String str |
---|
711 | for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) |
---|
712 | str = StringFromList(ii, ksDetectorListAll, ";") |
---|
713 | Wave det_str = $("root:VSANS_MASK_file:entry:instrument:detector_"+str+":data") |
---|
714 | wave maskW = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":data") |
---|
715 | det_str = maskW |
---|
716 | endfor |
---|
717 | |
---|
718 | //save it |
---|
719 | // String fileName = "ThisIsAMASK" |
---|
720 | |
---|
721 | Execute "Save_VSANS_MASK_Nexus()" |
---|
722 | |
---|
723 | break |
---|
724 | case -1: // control being killed |
---|
725 | break |
---|
726 | endswitch |
---|
727 | |
---|
728 | SetDataFolder root: |
---|
729 | return 0 |
---|
730 | End |
---|
731 | |
---|
732 | |
---|
733 | ////////////// fake MASK file tests |
---|
734 | // |
---|
735 | // |
---|
736 | // Make/O/T/N=1 file_name = "VSANS_MASK_test.h5" |
---|
737 | // |
---|
738 | // simple generation of a fake MASK file. for sans, nothing other than the creation date was written to the |
---|
739 | // file header. nothing more is needed (possibly) |
---|
740 | // |
---|
741 | // |
---|
742 | // TODO |
---|
743 | // -- make the number of pixels GLOBAL to pick up the right numbers for the detector dimensions |
---|
744 | // x- there will be lots of work to do to develop the procedures necessary to actually generate the |
---|
745 | // 9 data sets to become the MASK file contents. More complexity here than for the simple SANS case. |
---|
746 | // |
---|
747 | // x- this is currently random 0|1 values, need to write an editor |
---|
748 | // |
---|
749 | // currently set up to use 1 = YES MASK == exclude the data |
---|
750 | // and 0 = NO MASK == keep the data |
---|
751 | // |
---|
752 | Proc H_Setup_VSANS_MASK_Structure() |
---|
753 | |
---|
754 | NewDataFolder/O/S root:VSANS_MASK_file |
---|
755 | |
---|
756 | NewDataFolder/O/S root:VSANS_MASK_file:entry |
---|
757 | Make/O/T/N=1 title = "This is a MASK file for VSANS: VSANS_MASK" |
---|
758 | Make/O/T/N=1 start_date = "2015-02-28T08:15:30-5:00" |
---|
759 | NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument |
---|
760 | Make/O/T/N=1 name = "NG3_VSANS" |
---|
761 | NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_B |
---|
762 | Make/O/I/N=(680,1656) data = 0 |
---|
763 | data[][0,5] = 1 |
---|
764 | data[][1650,1655] = 1 |
---|
765 | data[0,5][] = 1 |
---|
766 | data[675,679][] = 1 |
---|
767 | NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_MR |
---|
768 | Make/O/I/N=(48,128) data = 0 |
---|
769 | data[44,47][] = 1 |
---|
770 | data[][0,4] = 1 |
---|
771 | data[][123,127] = 1 |
---|
772 | NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_ML |
---|
773 | Make/O/I/N=(48,128) data = 0 |
---|
774 | data[0,3][] = 1 |
---|
775 | data[][0,4] = 1 |
---|
776 | data[][123,127] = 1 |
---|
777 | NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_MT |
---|
778 | Make/O/I/N=(128,48) data = 0 |
---|
779 | data[0,49][] = 1 |
---|
780 | data[78,127][] = 1 |
---|
781 | data[50,77][] = 0 |
---|
782 | |
---|
783 | NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_MB |
---|
784 | Make/O/I/N=(128,48) data = 0 |
---|
785 | data[0,49][] = 1 |
---|
786 | data[78,127][] = 1 |
---|
787 | data[50,77][] = 0 |
---|
788 | |
---|
789 | NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FR |
---|
790 | Make/O/I/N=(48,128) data = 0 |
---|
791 | data[44,47][] = 1 |
---|
792 | data[][0,4] = 1 |
---|
793 | data[][123,127] = 1 |
---|
794 | NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FL |
---|
795 | Make/O/I/N=(48,128) data = 0 |
---|
796 | data[0,3][] = 1 |
---|
797 | data[][0,4] = 1 |
---|
798 | data[][123,127] = 1 |
---|
799 | NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FT |
---|
800 | Make/O/I/N=(128,48) data = 0 |
---|
801 | data[0,49][] = 1 |
---|
802 | data[78,127][] = 1 |
---|
803 | data[50,77][] = 0 |
---|
804 | |
---|
805 | NewDataFolder/O/S root:VSANS_MASK_file:entry:instrument:detector_FB |
---|
806 | Make/O/I/N=(128,48) data = 0 |
---|
807 | data[0,49][] = 1 |
---|
808 | data[78,127][] = 1 |
---|
809 | data[50,77][] = 0 |
---|
810 | |
---|
811 | |
---|
812 | // fake, empty folders so that the generic loaders can be used |
---|
813 | NewDataFolder/O root:VSANS_MASK_file:entry:DAS_logs |
---|
814 | NewDataFolder/O root:VSANS_MASK_file:entry:control |
---|
815 | NewDataFolder/O root:VSANS_MASK_file:entry:reduction |
---|
816 | NewDataFolder/O root:VSANS_MASK_file:entry:sample |
---|
817 | NewDataFolder/O root:VSANS_MASK_file:entry:user |
---|
818 | SetDataFolder root: |
---|
819 | |
---|
820 | End |
---|
821 | |
---|
822 | |
---|
823 | // this default mask is only generated on startup of the panel, if a mask |
---|
824 | // has not been previously loaded. If any mask is present ("FT" is tested) then |
---|
825 | // this function is skipped and the existing mask is not overwritten |
---|
826 | Function V_GenerateDefaultMask() |
---|
827 | |
---|
828 | NewDataFolder/O/S root:Packages:NIST:VSANS:MSK:entry |
---|
829 | Make/O/T/N=1 title = "This is a MASK file for VSANS: VSANS_MASK" |
---|
830 | Make/O/T/N=1 start_date = "2015-02-28T08:15:30-5:00" |
---|
831 | NewDataFolder/O/S root:Packages:NIST:VSANS:MSK:entry:instrument |
---|
832 | Make/O/T/N=1 name = "NG3_VSANS" |
---|
833 | NewDataFolder/O/S root:Packages:NIST:VSANS:MSK:entry:instrument:detector_B |
---|
834 | Make/O/I/N=(680,1656) data = 0 |
---|
835 | data[][0,5] = 1 |
---|
836 | data[][1650,1655] = 1 |
---|
837 | data[0,5][] = 1 |
---|
838 | data[675,679][] = 1 |
---|
839 | NewDataFolder/O/S root:Packages:NIST:VSANS:MSK:entry:instrument:detector_MR |
---|
840 | Make/O/I/N=(48,128) data = 0 |
---|
841 | // data[][0,3] = 1 |
---|
842 | data[44,47][] = 1 |
---|
843 | data[][0,4] = 1 |
---|
844 | data[][123,127] = 1 |
---|
845 | NewDataFolder/O/S root:Packages:NIST:VSANS:MSK:entry:instrument:detector_ML |
---|
846 | Make/O/I/N=(48,128) data = 0 |
---|
847 | data[0,3][] = 1 |
---|
848 | // data[44,47][] = 1 |
---|
849 | data[][0,4] = 1 |
---|
850 | data[][123,127] = 1 |
---|
851 | NewDataFolder/O/S root:Packages:NIST:VSANS:MSK:entry:instrument:detector_MT |
---|
852 | Make/O/I/N=(128,48) data = 0 |
---|
853 | data[0,49][] = 1 |
---|
854 | data[78,127][] = 1 |
---|
855 | data[50,77][] = 0 |
---|
856 | |
---|
857 | NewDataFolder/O/S root:Packages:NIST:VSANS:MSK:entry:instrument:detector_MB |
---|
858 | Make/O/I/N=(128,48) data = 0 |
---|
859 | data[0,49][] = 1 |
---|
860 | data[78,127][] = 1 |
---|
861 | data[50,77][] = 0 |
---|
862 | |
---|
863 | NewDataFolder/O/S root:Packages:NIST:VSANS:MSK:entry:instrument:detector_FR |
---|
864 | Make/O/I/N=(48,128) data = 0 |
---|
865 | // data[][0,3] = 1 |
---|
866 | data[44,47][] = 1 |
---|
867 | data[][0,4] = 1 |
---|
868 | data[][123,127] = 1 |
---|
869 | NewDataFolder/O/S root:Packages:NIST:VSANS:MSK:entry:instrument:detector_FL |
---|
870 | Make/O/I/N=(48,128) data = 0 |
---|
871 | data[0,3][] = 1 |
---|
872 | // data[44,47][] = 1 |
---|
873 | data[][0,4] = 1 |
---|
874 | data[][123,127] = 1 |
---|
875 | NewDataFolder/O/S root:Packages:NIST:VSANS:MSK:entry:instrument:detector_FT |
---|
876 | Make/O/I/N=(128,48) data = 0 |
---|
877 | data[0,49][] = 1 |
---|
878 | data[78,127][] = 1 |
---|
879 | data[50,77][] = 0 |
---|
880 | |
---|
881 | NewDataFolder/O/S root:Packages:NIST:VSANS:MSK:entry:instrument:detector_FB |
---|
882 | Make/O/I/N=(128,48) data = 0 |
---|
883 | data[0,49][] = 1 |
---|
884 | data[78,127][] = 1 |
---|
885 | data[50,77][] = 0 |
---|
886 | |
---|
887 | SetDataFolder root: |
---|
888 | |
---|
889 | end |
---|
890 | |
---|
891 | ////////////////////// MASK FILE |
---|
892 | |
---|
893 | |
---|
894 | // (DONE) |
---|
895 | // x- currently, there are no dummy fill values or attributes for the fake MASK file |
---|
896 | // |
---|
897 | Proc Setup_VSANS_MASK_Struct() |
---|
898 | |
---|
899 | // lays out the tree and fills with dummy values |
---|
900 | H_Setup_VSANS_MASK_Structure() |
---|
901 | |
---|
902 | // writes in the attributes |
---|
903 | // H_Fill_VSANS_Attributes() |
---|
904 | |
---|
905 | |
---|
906 | End |
---|
907 | |
---|
908 | Proc Save_VSANS_MASK_Nexus(fileName) |
---|
909 | String fileName="Test_VSANS_MASK_file" |
---|
910 | |
---|
911 | // save as HDF5 (no attributes saved yet) |
---|
912 | Save_VSANS_file("root:VSANS_MASK_file", fileName+".h5") |
---|
913 | |
---|
914 | // // read in a data file using the gateway-- reads from the home path |
---|
915 | // H_HDF5Gate_Read_Raw(fileName+".h5") |
---|
916 | // |
---|
917 | // // after reading in a "partial" file using the gateway (to generate the xref) |
---|
918 | // // Save the xref to disk (for later use) |
---|
919 | // Save_HDF5___xref("root:"+fileName,"HDF5___xref") |
---|
920 | // |
---|
921 | // // after you've generated the HDF5___xref, load it in and copy it |
---|
922 | // // to the necessary folder location. |
---|
923 | // Copy_HDF5___xref("root:VSANS_MASK_file", "HDF5___xref") |
---|
924 | // |
---|
925 | // // writes out the contents of a data folder using the gateway |
---|
926 | // H_HDF5Gate_Write_Raw("root:VSANS_MASK_file", fileName+".h5") |
---|
927 | // |
---|
928 | // // re-load the data file using the gateway-- reads from the home path |
---|
929 | // // now with attributes |
---|
930 | // H_HDF5Gate_Read_Raw(fileName+".h5") |
---|
931 | |
---|
932 | End |
---|