1
/*===========================================================================
2
Copyright (C) 1995-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
19
Corresponding concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
29
/*******************************************************************************
35
*******************************************************************************/
46
/*******************************************************************************
47
Includes, Defines, and Global variables from the Declarations Editor:
48
*******************************************************************************/
50
#include <ExternResources.h>
54
extern void do_bbody();
58
extern struct s_bbody N;
60
/*******************************************************************************
61
The definition of the context structure:
62
If you create multiple instances of your interface, the context
63
structure ensures that your callbacks use the variables for the
66
For each swidget in the interface, each argument to the Interface
67
function, and each variable in the Instance Specific section of the
68
Declarations Editor, there is an entry in the context structure.
69
and a #define. The #define makes the variable name refer to the
70
corresponding entry in the context structure.
71
*******************************************************************************/
91
#define form7 UxBlackBodyContext->Uxform7
92
#define form8 UxBlackBodyContext->Uxform8
93
#define ApplyBB UxBlackBodyContext->UxApplyBB
94
#define CancelBB UxBlackBodyContext->UxCancelBB
95
#define separator9 UxBlackBodyContext->Uxseparator9
96
#define lbl_T UxBlackBodyContext->Uxlbl_T
97
#define lbl_Dist UxBlackBodyContext->Uxlbl_Dist
98
#define tf_T UxBlackBodyContext->Uxtf_T
99
#define tf_Dist UxBlackBodyContext->Uxtf_Dist
100
#define lbl_radius UxBlackBodyContext->Uxlbl_radius
101
#define lbl_wr UxBlackBodyContext->Uxlbl_wr
102
#define tf_radius UxBlackBodyContext->Uxtf_radius
103
#define tf_wrmin UxBlackBodyContext->Uxtf_wrmin
104
#define tf_wrmax UxBlackBodyContext->Uxtf_wrmax
106
static _UxCBlackBody *UxBlackBodyContext;
110
/*******************************************************************************
111
The following are translation tables.
112
*******************************************************************************/
114
static char *BBtext_tab = "#override\n\
115
<Key>Delete:delete-previous-character()\n\
116
<Key>BackSpace:delete-previous-character()\n\
117
<Key>osfBackSpace:delete-previous-character()\n\
118
<Key>osfDelete:delete-previous-character()\n";
120
/*******************************************************************************
121
Forward declarations of functions that are defined later in this file.
122
*******************************************************************************/
124
swidget create_BlackBody();
126
/*******************************************************************************
127
The following are callback functions.
128
*******************************************************************************/
130
static void activateCB_ApplyBB( UxWidget, UxClientData, UxCallbackArg )
132
XtPointer UxClientData, UxCallbackArg;
134
_UxCBlackBody *UxSaveCtx, *UxContext;
135
swidget UxThisWidget;
137
UxThisWidget = UxWidgetToSwidget( UxWidget );
138
UxSaveCtx = UxBlackBodyContext;
139
UxBlackBodyContext = UxContext =
140
(_UxCBlackBody *) UxGetContext( UxThisWidget );
144
UxBlackBodyContext = UxSaveCtx;
147
static void activateCB_CancelBB( UxWidget, UxClientData, UxCallbackArg )
149
XtPointer UxClientData, UxCallbackArg;
151
_UxCBlackBody *UxSaveCtx, *UxContext;
152
swidget UxThisWidget;
154
UxThisWidget = UxWidgetToSwidget( UxWidget );
155
UxSaveCtx = UxBlackBodyContext;
156
UxBlackBodyContext = UxContext =
157
(_UxCBlackBody *) UxGetContext( UxThisWidget );
159
UxPopdownInterface(BlackBody);
161
UxBlackBodyContext = UxSaveCtx;
164
static void losingFocusCB_tf_T( UxWidget, UxClientData, UxCallbackArg )
166
XtPointer UxClientData, UxCallbackArg;
168
_UxCBlackBody *UxSaveCtx, *UxContext;
169
swidget UxThisWidget;
171
UxThisWidget = UxWidgetToSwidget( UxWidget );
172
UxSaveCtx = UxBlackBodyContext;
173
UxBlackBodyContext = UxContext =
174
(_UxCBlackBody *) UxGetContext( UxThisWidget );
181
nid=sscanf(UxGetText(UxFindSwidget("tf_T")),"%f",&temp);
184
if ((temp>=1000.)&&(temp<=100000.))
188
else if (temp>10000.)
192
sprintf(am,"%.1f",N.T);
193
UxPutText(UxFindSwidget("tf_T"),am);
196
UxBlackBodyContext = UxSaveCtx;
199
static void losingFocusCB_tf_Dist( UxWidget, UxClientData, UxCallbackArg )
201
XtPointer UxClientData, UxCallbackArg;
203
_UxCBlackBody *UxSaveCtx, *UxContext;
204
swidget UxThisWidget;
206
UxThisWidget = UxWidgetToSwidget( UxWidget );
207
UxSaveCtx = UxBlackBodyContext;
208
UxBlackBodyContext = UxContext =
209
(_UxCBlackBody *) UxGetContext( UxThisWidget );
215
nid=sscanf(UxGetText(UxFindSwidget("tf_Dist")),"%f",&real);
218
if ((real>=.01)&&(real<=10000.))
222
else if (real>10000.)
226
sprintf(am,"%.2f",N.dist);
227
UxPutText(UxFindSwidget("tf_Dist"),am);
230
UxBlackBodyContext = UxSaveCtx;
233
static void losingFocusCB_tf_radius( UxWidget, UxClientData, UxCallbackArg )
235
XtPointer UxClientData, UxCallbackArg;
237
_UxCBlackBody *UxSaveCtx, *UxContext;
238
swidget UxThisWidget;
240
UxThisWidget = UxWidgetToSwidget( UxWidget );
241
UxSaveCtx = UxBlackBodyContext;
242
UxBlackBodyContext = UxContext =
243
(_UxCBlackBody *) UxGetContext( UxThisWidget );
250
nid=sscanf(UxGetText(UxFindSwidget("tf_radius")),"%f",&real);
253
if ((real>=.01)&&(real<=10000.))
257
else if (real>10000.)
261
sprintf(am,"%.2f",N.radius);
262
UxPutText(UxFindSwidget("tf_radius"),am);
265
UxBlackBodyContext = UxSaveCtx;
268
static void losingFocusCB_tf_wrmin( UxWidget, UxClientData, UxCallbackArg )
270
XtPointer UxClientData, UxCallbackArg;
272
_UxCBlackBody *UxSaveCtx, *UxContext;
273
swidget UxThisWidget;
275
UxThisWidget = UxWidgetToSwidget( UxWidget );
276
UxSaveCtx = UxBlackBodyContext;
277
UxBlackBodyContext = UxContext =
278
(_UxCBlackBody *) UxGetContext( UxThisWidget );
284
nid=sscanf(UxGetText(UxFindSwidget("tf_wrmin")),"%f",&minw);
287
if ((minw>=300.)&&(minw<=1200.))
295
sprintf(am,"%.1f",N.wrmin);
296
UxPutText(UxFindSwidget("tf_wrmin"),am);
300
UxBlackBodyContext = UxSaveCtx;
303
static void losingFocusCB_tf_wrmax( UxWidget, UxClientData, UxCallbackArg )
305
XtPointer UxClientData, UxCallbackArg;
307
_UxCBlackBody *UxSaveCtx, *UxContext;
308
swidget UxThisWidget;
310
UxThisWidget = UxWidgetToSwidget( UxWidget );
311
UxSaveCtx = UxBlackBodyContext;
312
UxBlackBodyContext = UxContext =
313
(_UxCBlackBody *) UxGetContext( UxThisWidget );
320
nid=sscanf(UxGetText(UxFindSwidget("tf_wrmax")),"%f",&maxw);
323
if ((maxw>=300.)&&(maxw<=1200.))
331
sprintf(am,"%.1f",N.wrmax);
332
UxPutText(UxFindSwidget("tf_wrmax"),am);
336
UxBlackBodyContext = UxSaveCtx;
339
/*******************************************************************************
340
The 'init_' function sets the private properties for all the
341
swidgets to the values specified in the Property Table.
342
Some properties need to be set after the X widgets have been
343
created and the setting of these properties is done in the
344
'build_' function after the UxCreateWidget call.
345
*******************************************************************************/
347
static void _Uxinit_BlackBody()
349
UxPutBackground( BlackBody, WindowBackground );
350
UxPutBorderColor( BlackBody, WindowBackground );
351
UxPutKeyboardFocusPolicy( BlackBody, "pointer" );
352
UxPutIconName( BlackBody, "Black Body" );
353
UxPutHeight( BlackBody, 230 );
354
UxPutWidth( BlackBody, 380 );
355
UxPutY( BlackBody, 165 );
356
UxPutX( BlackBody, 430 );
358
UxPutBorderColor( form7, WindowBackground );
359
UxPutBackground( form7, WindowBackground );
360
UxPutHeight( form7, 548 );
361
UxPutWidth( form7, 490 );
364
UxPutUnitType( form7, "pixels" );
365
UxPutResizePolicy( form7, "resize_none" );
367
UxPutBorderColor( form8, ButtonBackground );
368
UxPutBackground( form8, ButtonBackground );
369
UxPutHeight( form8, 44 );
370
UxPutWidth( form8, 490 );
371
UxPutY( form8, 150 );
373
UxPutResizePolicy( form8, "resize_none" );
375
UxPutLabelString( ApplyBB, "Apply" );
376
UxPutForeground( ApplyBB, ApplyForeground );
377
UxPutFontList( ApplyBB, BoldTextFont );
378
UxPutBorderColor( ApplyBB, ButtonBackground );
379
UxPutBackground( ApplyBB, ButtonBackground );
380
UxPutHeight( ApplyBB, 30 );
381
UxPutWidth( ApplyBB, 80 );
382
UxPutY( ApplyBB, 6 );
383
UxPutX( ApplyBB, 10 );
385
UxPutLabelString( CancelBB, "Cancel" );
386
UxPutForeground( CancelBB, CancelForeground );
387
UxPutFontList( CancelBB, BoldTextFont );
388
UxPutBorderColor( CancelBB, ButtonBackground );
389
UxPutBackground( CancelBB, ButtonBackground );
390
UxPutHeight( CancelBB, 30 );
391
UxPutWidth( CancelBB, 86 );
392
UxPutY( CancelBB, 6 );
393
UxPutX( CancelBB, 110 );
395
UxPutBorderColor( separator9, WindowBackground );
396
UxPutBackground( separator9, WindowBackground );
397
UxPutHeight( separator9, 10 );
398
UxPutWidth( separator9, 492 );
399
UxPutY( separator9, 140 );
400
UxPutX( separator9, 0 );
402
UxPutForeground( lbl_T, TextForeground );
403
UxPutAlignment( lbl_T, "alignment_beginning" );
404
UxPutLabelString( lbl_T, "Temperature (K) :" );
405
UxPutFontList( lbl_T, TextFont );
406
UxPutBorderColor( lbl_T, LabelBackground );
407
UxPutBackground( lbl_T, LabelBackground );
408
UxPutHeight( lbl_T, 30 );
409
UxPutWidth( lbl_T, 126 );
413
UxPutForeground( lbl_Dist, TextForeground );
414
UxPutAlignment( lbl_Dist, "alignment_beginning" );
415
UxPutLabelString( lbl_Dist, "Distance (pc) :" );
416
UxPutFontList( lbl_Dist, TextFont );
417
UxPutBorderColor( lbl_Dist, LabelBackground );
418
UxPutBackground( lbl_Dist, LabelBackground );
419
UxPutHeight( lbl_Dist, 30 );
420
UxPutWidth( lbl_Dist, 104 );
421
UxPutY( lbl_Dist, 50 );
422
UxPutX( lbl_Dist, 10 );
424
UxPutTranslations( tf_T, BBtext_tab );
425
UxPutSelectionArrayCount( tf_T, 3 );
426
UxPutMaxLength( tf_T, 200 );
427
UxPutForeground( tf_T, TextForeground );
428
UxPutFontList( tf_T, TextFont );
429
UxPutBorderColor( tf_T, TextBackground );
430
UxPutBackground( tf_T, TextBackground );
431
UxPutHeight( tf_T, 35 );
432
UxPutWidth( tf_T, 80 );
436
UxPutTranslations( tf_Dist, BBtext_tab );
437
UxPutSelectionArrayCount( tf_Dist, 3 );
438
UxPutMaxLength( tf_Dist, 200 );
439
UxPutForeground( tf_Dist, TextForeground );
440
UxPutFontList( tf_Dist, TextFont );
441
UxPutBorderColor( tf_Dist, TextBackground );
442
UxPutBackground( tf_Dist, TextBackground );
443
UxPutHeight( tf_Dist, 35 );
444
UxPutWidth( tf_Dist, 80 );
445
UxPutY( tf_Dist, 48 );
446
UxPutX( tf_Dist, 190 );
448
UxPutForeground( lbl_radius, TextForeground );
449
UxPutAlignment( lbl_radius, "alignment_beginning" );
450
UxPutLabelString( lbl_radius, "Radius (solar unit) :" );
451
UxPutFontList( lbl_radius, TextFont );
452
UxPutBorderColor( lbl_radius, LabelBackground );
453
UxPutBackground( lbl_radius, LabelBackground );
454
UxPutHeight( lbl_radius, 30 );
455
UxPutWidth( lbl_radius, 132 );
456
UxPutY( lbl_radius, 90 );
457
UxPutX( lbl_radius, 10 );
459
UxPutForeground( lbl_wr, TextForeground );
460
UxPutAlignment( lbl_wr, "alignment_beginning" );
461
UxPutLabelString( lbl_wr, "Wavelength Range (nm):" );
462
UxPutFontList( lbl_wr, TextFont );
463
UxPutBorderColor( lbl_wr, LabelBackground );
464
UxPutBackground( lbl_wr, LabelBackground );
465
UxPutHeight( lbl_wr, 30 );
466
UxPutWidth( lbl_wr, 170 );
467
UxPutY( lbl_wr, 130 );
468
UxPutX( lbl_wr, 10 );
470
UxPutTranslations( tf_radius, BBtext_tab );
471
UxPutSelectionArrayCount( tf_radius, 3 );
472
UxPutMaxLength( tf_radius, 200 );
473
UxPutForeground( tf_radius, TextForeground );
474
UxPutFontList( tf_radius, TextFont );
475
UxPutBorderColor( tf_radius, TextBackground );
476
UxPutBackground( tf_radius, TextBackground );
477
UxPutHeight( tf_radius, 35 );
478
UxPutWidth( tf_radius, 80 );
479
UxPutY( tf_radius, 88 );
480
UxPutX( tf_radius, 190 );
482
UxPutTranslations( tf_wrmin, BBtext_tab );
483
UxPutSelectionArrayCount( tf_wrmin, 3 );
484
UxPutMaxLength( tf_wrmin, 200 );
485
UxPutForeground( tf_wrmin, TextForeground );
486
UxPutFontList( tf_wrmin, TextFont );
487
UxPutBorderColor( tf_wrmin, TextBackground );
488
UxPutBackground( tf_wrmin, TextBackground );
489
UxPutHeight( tf_wrmin, 35 );
490
UxPutWidth( tf_wrmin, 80 );
491
UxPutY( tf_wrmin, 128 );
492
UxPutX( tf_wrmin, 190 );
494
UxPutTranslations( tf_wrmax, BBtext_tab );
495
UxPutSelectionArrayCount( tf_wrmax, 3 );
496
UxPutMaxLength( tf_wrmax, 200 );
497
UxPutForeground( tf_wrmax, TextForeground );
498
UxPutFontList( tf_wrmax, TextFont );
499
UxPutBorderColor( tf_wrmax, TextBackground );
500
UxPutBackground( tf_wrmax, TextBackground );
501
UxPutHeight( tf_wrmax, 35 );
502
UxPutWidth( tf_wrmax, 80 );
503
UxPutY( tf_wrmax, 128 );
504
UxPutX( tf_wrmax, 278 );
508
/*******************************************************************************
509
The 'build_' function creates all the swidgets and X widgets,
510
and sets their properties to the values specified in the
512
*******************************************************************************/
514
static swidget _Uxbuild_BlackBody()
516
/* Create the swidgets */
518
BlackBody = UxCreateApplicationShell( "BlackBody", NO_PARENT );
519
UxPutContext( BlackBody, UxBlackBodyContext );
521
form7 = UxCreateForm( "form7", BlackBody );
522
form8 = UxCreateForm( "form8", form7 );
523
ApplyBB = UxCreatePushButton( "ApplyBB", form8 );
524
CancelBB = UxCreatePushButton( "CancelBB", form8 );
525
separator9 = UxCreateSeparator( "separator9", form7 );
526
lbl_T = UxCreateLabel( "lbl_T", form7 );
527
lbl_Dist = UxCreateLabel( "lbl_Dist", form7 );
528
tf_T = UxCreateText( "tf_T", form7 );
529
tf_Dist = UxCreateText( "tf_Dist", form7 );
530
lbl_radius = UxCreateLabel( "lbl_radius", form7 );
531
lbl_wr = UxCreateLabel( "lbl_wr", form7 );
532
tf_radius = UxCreateText( "tf_radius", form7 );
533
tf_wrmin = UxCreateText( "tf_wrmin", form7 );
534
tf_wrmax = UxCreateText( "tf_wrmax", form7 );
538
/* Create the X widgets */
540
UxCreateWidget( BlackBody );
541
UxCreateWidget( form7 );
542
UxPutRightAttachment( form8, "attach_form" );
543
UxPutLeftAttachment( form8, "attach_form" );
544
UxPutBottomOffset( form8, 2 );
545
UxPutBottomAttachment( form8, "attach_form" );
546
UxCreateWidget( form8 );
548
UxCreateWidget( ApplyBB );
549
UxCreateWidget( CancelBB );
550
UxPutRightAttachment( separator9, "attach_form" );
551
UxPutLeftAttachment( separator9, "attach_form" );
552
UxPutBottomWidget( separator9, "form8" );
553
UxPutBottomOffset( separator9, 0 );
554
UxPutBottomAttachment( separator9, "attach_widget" );
555
UxCreateWidget( separator9 );
557
UxCreateWidget( lbl_T );
558
UxCreateWidget( lbl_Dist );
559
UxCreateWidget( tf_T );
560
UxCreateWidget( tf_Dist );
561
UxCreateWidget( lbl_radius );
562
UxCreateWidget( lbl_wr );
563
UxCreateWidget( tf_radius );
564
UxCreateWidget( tf_wrmin );
565
UxCreateWidget( tf_wrmax );
567
UxAddCallback( ApplyBB, XmNactivateCallback,
569
(XtPointer) UxBlackBodyContext );
571
UxAddCallback( CancelBB, XmNactivateCallback,
573
(XtPointer) UxBlackBodyContext );
575
UxAddCallback( tf_T, XmNlosingFocusCallback,
577
(XtPointer) UxBlackBodyContext );
579
UxAddCallback( tf_Dist, XmNlosingFocusCallback,
580
losingFocusCB_tf_Dist,
581
(XtPointer) UxBlackBodyContext );
583
UxAddCallback( tf_radius, XmNlosingFocusCallback,
584
losingFocusCB_tf_radius,
585
(XtPointer) UxBlackBodyContext );
587
UxAddCallback( tf_wrmin, XmNlosingFocusCallback,
588
losingFocusCB_tf_wrmin,
589
(XtPointer) UxBlackBodyContext );
591
UxAddCallback( tf_wrmax, XmNlosingFocusCallback,
592
losingFocusCB_tf_wrmax,
593
(XtPointer) UxBlackBodyContext );
596
/* Finally, call UxRealizeInterface to create the X windows
597
for the widgets created above. */
599
UxRealizeInterface( BlackBody );
601
return ( BlackBody );
604
/*******************************************************************************
605
The following function includes the code that was entered
606
in the 'Initial Code' and 'Final Code' sections of the
607
Declarations Editor. This function is called from the
608
'Interface function' below.
609
*******************************************************************************/
611
static swidget _Ux_create_BlackBody()
614
_UxCBlackBody *UxContext;
616
UxBlackBodyContext = UxContext =
617
(_UxCBlackBody *) UxMalloc( sizeof(_UxCBlackBody) );
619
rtrn = _Uxbuild_BlackBody();
624
/*******************************************************************************
625
The following is the 'Interface function' which is the
626
external entry point for creating this interface.
627
This function should be called from your application or from
629
*******************************************************************************/
631
swidget create_BlackBody()
635
_Uxrtrn = _Ux_create_BlackBody();
640
/*******************************************************************************
642
*******************************************************************************/