File: setfitparm.pro

package info (click to toggle)
mpfit 1.85+2017.01.03-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 788 kB
  • sloc: python: 126; makefile: 16; sh: 13
file content (564 lines) | stat: -rw-r--r-- 18,980 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
;+
; NAME:
;   SetFitParm.pro
;
; AUTHOR:
;	F.Bringezu, denet - Internetservice, Halle Germany,
;	bringezu@denet.de
;
; PURPOSE:
;   Provide a widget interface for creating a parinfo structure.
;   This parinfo structure can by used by mpfit routines of Craig B. Markwardt.
;
; MAJOR TOPICS:
;   Widget, mpfit.
;
; CALLING SEQUENCE:
;   parinfo=SetFitParm(used_parinfo)
;
; DESCRIPTION:
;
;   SetFitParm creates PARINFO using a widget interface.
;   PARINFO provides constraints for paramters used by the mpfit routines.
;
;   PARINFO is an array of structures, one for each parameter.
;
;   A detailed description can be found in the documentation of mpcurvefit.pro
;   This routine creates an array that contains a structure for each element.
;   The structure has the following entries.
;
;   - VALUE (DOUBLE): The starting parameter
;   - FIXED (BOOLEAN): 1 fix the parameter, 0 don't fix it at the
;     point given in VALUE.
;   - LIMITS (DBLARRAY(2)): Set upper and lower limit.
;   - LIMITED (BOOLEAN ARRAY 2):  Fix the limit.
;
;
;   The parameter OLDPARINFO is optional. OLDPARINFO is used to set
;   the default values in the widget.
;
;   You can simply run:
;   test=SetFitParm() to create the array for the first time.
;   Once the array is created it can be used to set the default values
;   in the widget by calling
;
;   test2=SetFitParm(test)
;
; INPUTS:
;
;
; OPTIONAL INPUTS:
;
;   OLDFITPARM - The default values of the new array
;
; INPUT KEYWORD PARAMETERS:
;
;   PARENT - if this widget is to be a child, set this keyword to the
;            parent widget ID.
;
; OUTPUT KEYWORD PARAMETERS:
;
;   CANCEL - if the user selected the cancel button on the SETFITPARM
;            widget, then this keyword will be set upon exit.
;
; OUTPUTS:
;   PARINFO array of structures
;
; SEE ALSO:
;   mpcurvefit
;
; MODIFICATION HISTORY:
;   Written, FB, 12/1999
;   Documented, FB, Jan 2000
;   Generalized positioning code, CM 01 Feb 2000
;
;-
; Copyright (C) 1999, F.Bringezu
; This software is provided as is without any warranty whatsoever.
; Permission to use, copy and distribute unmodified copies for
; non-commercial purposes, and to modify and use for personal or
; internal use, is granted.  All other rights are reserved.
;-

Pro SetFitParm_Events, event

Widget_Control, event.id, Get_Value=buttonValue
Widget_Control, event.id, Get_UValue=buttonUValue

Widget_Control, event.top, Get_UValue=info, /No_Copy

CASE buttonUValue OF

	'Cancel' : Widget_Control, event.top, /Destroy

        'FIX_HEIGHT': (*info.ptr).fparm(0).fixed = fix(event.select)
        'FIX_XMAX':   (*info.ptr).fparm(1).fixed = fix(event.select)
        'FIX_WIDTH':  (*info.ptr).fparm(2).fixed = fix(event.select)
        'FIX_OFFSET': (*info.ptr).fparm(3).fixed = fix(event.select)
        'FIX_SLOPE':  (*info.ptr).fparm(4).fixed = fix(event.select)

        'LIMIT_HEIGHT_LOW': (*info.ptr).fparm(0).limited(0) = fix(event.select)
        'LIMIT_XMAX_LOW':   (*info.ptr).fparm(1).limited(0) = fix(event.select)
        'LIMIT_WIDTH_LOW':  (*info.ptr).fparm(2).limited(0) = fix(event.select)
        'LIMIT_OFFSET_LOW': (*info.ptr).fparm(3).limited(0) = fix(event.select)
        'LIMIT_SLOPE_LOW':  (*info.ptr).fparm(4).limited(0) = fix(event.select)

        'LIMIT_HEIGHT_UP':  (*info.ptr).fparm(0).limited(1) = fix(event.select)
        'LIMIT_XMAX_UP':    (*info.ptr).fparm(1).limited(1) = fix(event.select)
        'LIMIT_WIDTH_UP':   (*info.ptr).fparm(2).limited(1) = fix(event.select)
        'LIMIT_OFFSET_UP':  (*info.ptr).fparm(3).limited(1) = fix(event.select)
        'LIMIT_SLOPE_UP':   (*info.ptr).fparm(4).limited(1) = fix(event.select)

   'Accept' : BEGIN

         ; OK, get the information the user put into the form.
         ; Should do error checking, but...maybe later!

      Widget_Control, info.text(0), Get_Value=height
      Widget_Control, info.text(1), Get_Value=xmax
      Widget_Control, info.text(2), Get_Value=width
      Widget_Control, info.text(3), Get_Value=offset
      Widget_Control, info.text(4), Get_Value=slope

      Widget_Control, info.text(5), Get_Value=ll_height
      Widget_Control, info.text(6), Get_Value=ll_xmax
      Widget_Control, info.text(7), Get_Value=ll_width
      Widget_Control, info.text(8), Get_Value=ll_offset
      Widget_Control, info.text(9), Get_Value=ll_slope

      Widget_Control, info.text(10), Get_Value=ul_height
      Widget_Control, info.text(11), Get_Value=ul_xmax
      Widget_Control, info.text(12), Get_Value=ul_width
      Widget_Control, info.text(13), Get_Value=ul_offset
      Widget_Control, info.text(14), Get_Value=ul_slope

         ; Fill out the data structure with information
         ; collected from the form.

      (*info.ptr).fparm(0).value = height
      (*info.ptr).fparm(1).value = xmax
      (*info.ptr).fparm(2).value = width
      (*info.ptr).fparm(3).value = offset
      (*info.ptr).fparm(4).value = slope

      (*info.ptr).fparm(0).limits(0) = ll_height
      (*info.ptr).fparm(1).limits(0) = ll_xmax
      (*info.ptr).fparm(2).limits(0) = ll_width
      (*info.ptr).fparm(3).limits(0) = ll_offset
      (*info.ptr).fparm(4).limits(0) = ll_slope
      
      (*info.ptr).fparm(0).limits(1) = ul_height
      (*info.ptr).fparm(1).limits(1) = ul_xmax
      (*info.ptr).fparm(2).limits(1) = ul_width
      (*info.ptr).fparm(3).limits(1) = ul_offset
      (*info.ptr).fparm(4).limits(1) = ul_slope

      (*info.ptr).cancel = 0

         ; Destroy the widget program

      Widget_Control, event.top, /Destroy
      END
else:

ENDCASE





if buttonValue ne 'Cancel' and buttonValue ne 'Accept' then begin
Widget_Control, event.top, Set_UValue=info, /No_Copy

endif

END ;*******************************************************************

Function SetFitParm,	thisFParm,$
						Parent=parent,$
						Cancel=cancel

On_Error, 2

IF N_Elements(thisFParm) EQ 0 THEN $
fparm = replicate({value:0.D, fixed:0, limited:[0,0], limits:[0.D,0]}, 5) $
  	ELSE FParm=thisFParm

Device, Get_Screen_Size=screenSize
xCenter=FIX(screenSize(0)/2.)
yCenter=FIX(screenSize(1)/2.)
xoff=xCenter-150
yoff=yCenter-150


   ; Create a top-level base. Must have a Group Leader defined
   ; for Modal operation. If this widget is NOT modal, then it
   ; should only be called from the IDL command line as a blocking
   ; widget.

IF N_Elements(parent) NE 0 THEN $
   tlb = Widget_Base( GROUP_LEADER=parent $
      , UNAME='WID_BASE_0', XOffset=xoff, YOffset=yoff   $
      , XSIZE=380, YSIZE=320 ,TITLE='Parinfo Setup' ,SPACE=3 ,XPAD=3  $
      ,YPAD=3, /Floating, /Modal ,/Base_Align_Center) ELSE $
   tlb = Widget_Base( UNAME='WID_BASE_0', XOffset=xoff, YOffset=yoff   $
      , XSIZE=380, YSIZE=320 ,TITLE='Parinfo Setup' ,SPACE=3 ,XPAD=3  $
      ,YPAD=3, /Base_Align_Center)


  WID_BASE_1 = Widget_Base(tlb, UNAME='WID_BASE_1' ,FRAME=1  $
      ,XOFFSET=10 ,YOFFSET=55 , XSIZE=350, YSIZE=200  $
      ,TITLE='IDL' ,SPACE=3 ,XPAD=3 ,YPAD=3)


  WID_LABEL_0 = Widget_Label(WID_BASE_1, UNAME='WID_LABEL_0'  $
      ,XOFFSET=10 ,YOFFSET=45, XSIZE=42, YSIZE=18  $
      ,/ALIGN_LEFT ,VALUE='Ampl.')


  WID_LABEL_1 = Widget_Label(WID_BASE_1, UNAME='WID_LABEL_1'  $
      ,XOFFSET=10 ,YOFFSET=75 , XSIZE=42, YSIZE=18  $
      ,/ALIGN_LEFT ,VALUE='X(max)')


  WID_LABEL_2 = Widget_Label(WID_BASE_1, UNAME='WID_LABEL_2'  $
      ,XOFFSET=10 ,YOFFSET=105 , XSIZE=42 ,YSIZE=18  $
      ,/ALIGN_LEFT ,VALUE='Width')

  WID_LABEL_3 = Widget_Label(WID_BASE_1, UNAME='WID_LABEL_3'  $
      ,XOFFSET=10 ,YOFFSET=135, XSIZE=42 ,YSIZE=18  $
      ,/ALIGN_LEFT ,VALUE='Offset')

  WID_LABEL_4 = Widget_Label(WID_BASE_1, UNAME='WID_LABEL_4'  $
      ,XOFFSET=10 ,YOFFSET=165 ,XSIZE=42 ,YSIZE=18  $
      ,/ALIGN_LEFT ,VALUE='Slope')


;;;;;;;;;;;;;;;;;;;  table headline ;;;;;;;;;;;;;;;;;;;;;;;;
;; with top labels VALUE AND LIMIT

  WID_LABEL_6 = Widget_Label(WID_BASE_1, UNAME='WID_LABEL_6'  $
      ,XOFFSET=60 ,YOFFSET=15, XSIZE=42, YSIZE=18  $
      ,/ALIGN_LEFT ,VALUE='Value')



  WID_LABEL_8 = Widget_Label(WID_BASE_1, UNAME='WID_LABEL_8'  $
      ,XOFFSET=250 ,YOFFSET=15 ,XSIZE=40,YSIZE=18  $
      ,/ALIGN_LEFT ,VALUE='Limits')

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


  WID_TEXT_0 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_0' ,FRAME=1  $
      ,XOFFSET=60 ,YOFFSET=40 , VALUE=[strtrim(string(fparm(0).value),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable,/ALIGN_LEFT) ;;; Amplitude


  WID_TEXT_1 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_1' ,FRAME=1  $
      ,XOFFSET=60 ,YOFFSET=70, VALUE=[strtrim(string(fparm(1).value),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; X(max)


  WID_TEXT_2 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_2' ,FRAME=1  $
      ,XOFFSET=60 ,YOFFSET=100, VALUE=[strtrim(string(fparm(2).value),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; Width

  WID_TEXT_3 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_3' ,FRAME=1  $
      ,XOFFSET=60 ,YOFFSET=130,VALUE=[strtrim(string(fparm(3).value),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; Offset

  WID_TEXT_4 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_4' ,FRAME=1  $
      ,XOFFSET=60 ,YOFFSET=160 ,VALUE=[strtrim(string(fparm(4).value),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; Slope

;;;;; Text widgets for lower limits

  WID_TEXT_5 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_5' ,FRAME=1  $
      ,XOFFSET=210 ,YOFFSET=40 ,VALUE=[strtrim(string(fparm(0).limits(0)),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable,/ALIGN_LEFT) ;;; Amplitude


  WID_TEXT_6 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_6' ,FRAME=1  $
      ,XOFFSET=210 ,YOFFSET=70, VALUE=[strtrim(string(fparm(1).limits(0)),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; X(max)


  WID_TEXT_7 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_7' ,FRAME=1  $
      ,XOFFSET=210 ,YOFFSET=100,VALUE=[strtrim(string(fparm(2).limits(0)),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; Width

  WID_TEXT_8 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_8' ,FRAME=1  $
      ,XOFFSET=210 ,YOFFSET=130, VALUE=[strtrim(string(fparm(3).limits(0)),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; Offset

  WID_TEXT_9 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_9' ,FRAME=1  $
      ,XOFFSET=210 ,YOFFSET=160 ,VALUE=[strtrim(string(fparm(4).limits(0)),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; Slope


;;;;; Text widgets for upper limits

  WID_TEXT_10 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_10' ,FRAME=1  $
      ,XOFFSET=290 ,YOFFSET=40, VALUE=[strtrim(string(fparm(0).limits(1)),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable,/ALIGN_LEFT) ;;; Amplitude


  WID_TEXT_11 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_11' ,FRAME=1  $
      ,XOFFSET=290 ,YOFFSET=70, VALUE=[strtrim(string(fparm(1).limits(1)),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; X(max)


  WID_TEXT_12 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_12' ,FRAME=1  $
      ,XOFFSET=290 ,YOFFSET=100, VALUE=[strtrim(string(fparm(2).limits(1)),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; Width

  WID_TEXT_13 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_13' ,FRAME=1  $
      ,XOFFSET=290 ,YOFFSET=130, VALUE=[strtrim(string(fparm(3).limits(1)),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; Offset

  WID_TEXT_14 = Widget_Text(WID_BASE_1, UNAME='WID_TEXT_14' ,FRAME=1  $
      ,XOFFSET=290 ,YOFFSET=160, VALUE=[strtrim(string(fparm(4).limits(1)),1)]  $
      ,XSIZE=5 ,YSIZE=1,/editable) ;;; Slope




;;;;;;;;;;;; Container for checkboxes and checkboxes for FIXED ;;;;;;;;;;;;;;;;

  WID_BASE_2 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_2'  $
      ,XOFFSET=110 ,YOFFSET=40 ,XSIZE=20 ,YSIZE=20  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER , ROW=1 ,/NONEXCLUSIVE)


  WID_BUTTON_0 = Widget_Button(WID_BASE_2,/ALIGN_CENTER,UVALUE='FIX_HEIGHT' $
      , VALUE='')
      ;;; Amplitude


  WID_BASE_3 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_3'  $
      ,XOFFSET=110 ,YOFFSET=70 ,XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER ,/NONEXCLUSIVE)


  WID_BUTTON_1 = Widget_Button(WID_BASE_3 ,/ALIGN_LEFT,UVALUE='FIX_XMAX' $
      , VALUE='')
      ;;; X(max)


  WID_BASE_4 = Widget_Base(WID_BASE_1  $
      ,XOFFSET=110 ,YOFFSET=100 ,XSIZE=20 ,YSIZE=27 ,/ALIGN_TOP ,/BASE_ALIGN_CENTER, /NONEXCLUSIVE)


  WID_BUTTON_2 = Widget_Button(WID_BASE_4, /ALIGN_LEFT,UVALUE='FIX_WIDTH' $
      , VALUE='')
      ;;; Width

  WID_BASE_5 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_5'  $
      ,XOFFSET=110 ,YOFFSET=130 ,XSIZE=20 ,YSIZE=27, /ALIGN_TOP, /BASE_ALIGN_CENTER, /NONEXCLUSIVE)


  WID_BUTTON_3 = Widget_Button(WID_BASE_5, /ALIGN_LEFT, UVALUE='FIX_OFFSET' $
      ,  VALUE='')
      ;;; Slope

  WID_BASE_6 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_6'  $
      , XOFFSET=110 ,YOFFSET=160, XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER, /NONEXCLUSIVE)


  WID_BUTTON_4 = Widget_Button(WID_BASE_6,/ALIGN_LEFT, UVALUE='FIX_SLOPE' $
      ,  value='')
      ;;; Slope

;;;;;;;;;;;; Container for checkboxes and checkboxes for lower limited ;;;;;;;;;;;;;;;;

  WID_BASE_7 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_7'  $
      ,XOFFSET=180 ,YOFFSET=40 ,XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER ,TITLE='IDL' ,SPACE=2 ,ROW=1  $
      ,/GRID_LAYOUT ,/NONEXCLUSIVE)


  WID_BUTTON_5 = Widget_Button(WID_BASE_7 $
       ,/ALIGN_LEFT,UVALUE='LIMIT_HEIGHT_LOW',  VALUE='')
      ;;; Height

  WID_BASE_8 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_8'  $
      ,XOFFSET=180 ,YOFFSET=70 ,XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER ,TITLE='IDL' ,SPACE=2 ,ROW=1  $
      ,/GRID_LAYOUT ,/NONEXCLUSIVE)


  WID_BUTTON_6 = Widget_Button(WID_BASE_8 $
      ,/ALIGN_LEFT,UVALUE='LIMIT_XMAX_LOW', VALUE='')
      ;;; Xmax

  WID_BASE_9 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_9'  $
      ,XOFFSET=180 ,YOFFSET=100 ,XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER ,TITLE='IDL' ,SPACE=2 ,ROW=1  $
      ,/GRID_LAYOUT ,/NONEXCLUSIVE)


  WID_BUTTON_7 = Widget_Button(WID_BASE_9  $
      ,/ALIGN_LEFT,UVALUE='LIMIT_WIDTH_LOW',  value='')
      ;;; Width

  WID_BASE_10 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_10'  $
      ,XOFFSET=180 ,YOFFSET=130 ,XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER ,TITLE='IDL' ,SPACE=2 ,ROW=1  $
      ,/GRID_LAYOUT ,/NONEXCLUSIVE)


  WID_BUTTON_8 = Widget_Button(WID_BASE_10, UNAME='WID_BUTTON_8'  $
     ,/ALIGN_LEFT,UVALUE='LIMIT_OFFSET_LOW', value= '')
      ;;; Offset

  WID_BASE_11 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_11'  $
      ,XOFFSET=180 ,YOFFSET=160 ,XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER ,TITLE='IDL' ,SPACE=2 ,ROW=1  $
      ,/GRID_LAYOUT ,/NONEXCLUSIVE)


  WID_BUTTON_9 = Widget_Button(WID_BASE_11, UNAME='WID_BUTTON_9'  $
      ,/ALIGN_LEFT,UVALUE='LIMIT_SLOPE_LOW',  value='')
      ;;; Offset


;;;;;;;;;;;; Container for checkboxes and checkboxes for upper limited ;;;;;;;;;;;;;;;;

  WID_BASE_12 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_12'  $
      ,XOFFSET=265 ,YOFFSET=40 ,XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER ,TITLE='IDL' ,SPACE=2 ,ROW=1  $
      ,/GRID_LAYOUT ,/NONEXCLUSIVE)


  WID_BUTTON_10 = Widget_Button(WID_BASE_12, UNAME='WID_BUTTON_10' $
  ,/ALIGN_LEFT,UVALUE='LIMIT_HEIGHT_UP',  value='')
      ;;; Height

  WID_BASE_13 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_13'  $
      ,XOFFSET=265 ,YOFFSET=70 ,XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER ,TITLE='IDL' ,SPACE=2 ,ROW=1  $
      ,/GRID_LAYOUT ,/NONEXCLUSIVE)


  WID_BUTTON_11 = Widget_Button(WID_BASE_13, UNAME='WID_BUTTON_11'  $
       ,/ALIGN_LEFT,UVALUE='LIMIT_XMAX_UP',  value='')
      ;;; Xmax

  WID_BASE_14 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_14'  $
      ,XOFFSET=265 ,YOFFSET=100 ,XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER ,TITLE='IDL' ,SPACE=2 ,ROW=1  $
      ,/GRID_LAYOUT ,/NONEXCLUSIVE)


  WID_BUTTON_12 = Widget_Button(WID_BASE_14, UNAME='WID_BUTTON_12'  $
 	 ,/ALIGN_LEFT,UVALUE='LIMIT_WIDTH_UP',  value='')
      ;;; Width

  WID_BASE_15 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_15'  $
      ,XOFFSET=265 ,YOFFSET=130 ,XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER ,TITLE='IDL' ,SPACE=2 ,ROW=1  $
      ,/GRID_LAYOUT ,/NONEXCLUSIVE)


  WID_BUTTON_13 = Widget_Button(WID_BASE_15, UNAME='WID_BUTTON_13'  $
    	,/ALIGN_LEFT,UVALUE='LIMIT_OFFSET_UP',  VALUE='')
      ;;; Offset

  WID_BASE_16 = Widget_Base(WID_BASE_1, UNAME='WID_BASE_16'  $
      ,XOFFSET=265 ,YOFFSET=160 ,XSIZE=20 ,YSIZE=27  $
      ,/ALIGN_TOP ,/BASE_ALIGN_CENTER ,TITLE='IDL' ,SPACE=2 ,ROW=1  $
      ,/GRID_LAYOUT ,/NONEXCLUSIVE)


  WID_BUTTON_14 = Widget_Button(WID_BASE_16, UNAME='WID_BUTTON_14'  $
     ,/ALIGN_LEFT,UVALUE='LIMIT_SLOPE_UP',  value='')
      ;;; Offset


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


  BUT_BASE=Widget_Base(tlb,Row=1,yoffset=260,xoffset=120,/ALIGN_CENTER)
  CANCEL=Widget_Button(BUT_BASE,Value='Cancel', UVALUE='Cancel')
  ACCEPT=Widget_Button(BUT_BASE,Value='Accept', UVALUE='Accept')

   ; Create a pointer. This will point to the location where the
   ; information collected from the user will be stored.


ptr = Ptr_New({fparm:fparm, Cancel:1})

   ; Create info structure to hold information needed in event handler. This info structure containes also the parinfo
   ; that is used for mpfit.


buttons=[WID_BUTTON_0,WID_BUTTON_1,WID_BUTTON_2,WID_BUTTON_3,WID_BUTTON_4,$
		 WID_BUTTON_5,WID_BUTTON_6,WID_BUTTON_7,WID_BUTTON_8,WID_BUTTON_9,$
		 WID_BUTTON_10,WID_BUTTON_11,WID_BUTTON_12,WID_BUTTON_13,WID_BUTTON_14,$
		 CANCEL]
text = 	[WID_TEXT_0,WID_TEXT_1,WID_TEXT_2,WID_TEXT_3,WID_TEXT_4,$
		 WID_TEXT_5,WID_TEXT_6,WID_TEXT_7,WID_TEXT_8,WID_TEXT_9,$
		 WID_TEXT_10,WID_TEXT_11,WID_TEXT_12,WID_TEXT_13,WID_TEXT_14]

for i=0,4 do begin
widget_control,buttons(i),set_button=fparm(i).fixed
endfor

for i=5,9 do begin
widget_control,buttons(i),set_button=fparm(i-5).limited(0)
endfor

for i=10,14 do begin
widget_control,buttons(i),set_button=fparm(i-10).limited(1)
endfor


info = {buttons:buttons, $ 	; Identifier of widget holding buttons (checkboxes).
		text:text,$			; Identifier of widget holding textfields.
		fparm:fparm,$		; The actual parinfo
		ptr:ptr} 			; The pointer


            ; Store the info structure in the top-level base

Widget_Control, tlb, Set_UValue=info, /No_Copy
Widget_Control, /REALIZE, tlb

   ; Register the program, set up event loop. Make this program a
   ; blocking widget. This will allow the program to also be called
   ; from IDL command line without a PARENT parameter. The program
   ; blocks here until the entire program is destroyed.

XManager, 'SetFitParm', tlb, Event_Handler='SetFitParm_Events'

  ; OK,

newInfo = *ptr
Ptr_Free, ptr

  ; All kinds of things can go wrong now. Let's CATCH them all.

Catch, error
IF error NE 0 THEN BEGIN
   Catch, /Cancel

		      ; If an error occurs, set the CANCEL flag and return -1.

   ok = Dialog_Message(!Err_String)
   cancel = 1
   RETURN, -1
ENDIF


   ; If the error flag is set, let's disappear!

cancel = newInfo.cancel
IF cancel THEN RETURN, FParm

   ; OK, try to read the data file. Watch out!


RETURN, newInfo.FParm
END ;*******************************************************************