-
Notifications
You must be signed in to change notification settings - Fork 1
/
mpi_plotconfig__define.pro
1464 lines (1120 loc) · 55.8 KB
/
mpi_plotconfig__define.pro
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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;+
; NAME:
; MPI_PLOTCONFIG__DEFINE
;
; PURPOSE:
;
; This is a program for interactively adjusting and keeping track
; of keywords appropriate for configuring the PLOT command.
;
; AUTHOR:
;
; FANNING SOFTWARE CONSULTING
; David Fanning, Ph.D.
; 1645 Sheely Drive
; Fort Collins, CO 80526 USA
; Phone: 970-221-0438
; E-mail: [email protected]
; Coyote's Guide to IDL Programming: http://www.idlcoyote.com
;
; CATEGORY:
;
; Graphics
;
; CALLING SEQUENCE:
;
; plotConfigObj = Obj_New("MPI_PLOTCONFIG")
;
; INPUT PARAMETERS:
;
; None.
;
; INPUT KEYWORDS (Sent to the INIT method. The same keywords can be set with the SETPROPERTY method of the object.):
;
; BACKGROUND - The name of the background color. By default on 24-bit systems: 'IVORY'. ON 8-bit systems 'GRAY'.
;
; CHARSIZE - The character size of the plot. By default, 1.0.
;
; CHARTHICK - The character thickness of the plot. By default, 1.0.
;
; COLOR - The name of the plot color. (This will be the axis color if DATACOLOR is also used.)
; By default on 24-bit systems: 'SADDLE BROWN'. Uses 'GREEN' on 8-bit systems.
;
; DATACOLOR - The name of the data color. (Requires use of USEDATACOLOR to be active.) By default
; on 24-bit systems: 'NAVY'. Uses 'YELLOW' on 8-bit systems.
;
; _EXTRA - Extra keywords to be passed to MPI_AXIS objects used internally.
;
; FONT - The type of plot font: -1=Hershey, 0=Hardware, 1=True-Type. By default, !P.FONT.;
;
; LINESTYLE - The plot linestyle. By default, 0. Possible values are:
; 0 - Solid Line
; 1 - Dotted
; 2 - Dashed
; 3 - Dash Dot
; 4 - Dash Dot Dot
; 5 - Long Dash
; 6 - No Line
;
; NOAXISINFO - Set this keyword to inhibit axis information on the GUI. By default, 0.
;
; POSITION - The position of the plot in the plot window in normalized coordinates. By default, [0.20, 0.15, 0.95, 0.95].
;
; PSYM - The plot symbol value. By default, 18. Possible values are:
; 0 - Dot
; 1 - Filled Circle
; 2 - Filled Upward Triangle
; 3 - Filled Downward Triangle
; 4 - Filled Diamond
; 5 - Filled Square
; 6 - Open Circle
; 7 - Open Upward Triangle
; 8 - Open Downward Triangle
; 9 - Open Diamond
; 10 - Open Square
; 11 - Plus Sign
; 12 - X
; 13 - Star
; 14 - Filed Rightfacing Triangle
; 15 - Filled Leftfacing Triangle
; 16 - Open Rightfacing Triangle
; 17 - Open Leftfacing Triangle
; 18 - No Symbol (the default).
;
; SYMSIZE - The plot symbol size. By default, 1.0.
;
; SUBTITLE - The plot subtitle. By default, "".
;
; TITLE - The plot title. By default, "".
;
; THICK - The plot line thickness. By default, 1.0.
;
; TICKLEN - The plot tick length. By default, 0.02.
;
; USEDATACOLOR - Set this keyword to return a DATACOLOR field in the keyword structure. By default, 0.
;
; XAXIS - An MPI_AXIS object for the X axis. One is created by default, if not provided.
;
; YAXIS - An MPI_AXIS object for the Y axis. One is created by default, if not provided.
;
; METHOD PROCEDURES:
;
; GUI - This procedure method displays a graphical user interface that allows the user
; to change plot configuration parameters. The following keywords can be used:
;
; ALL_EVENTS - Set this keyword to have an event sent any time something in the
; GUI changes. The default is to send an event only when the user hits the ACCEPT button.
; Note that the NOTIFYID keyword must be used to generate events.
;
; BLOCK - Set this keyword if you want to block the command line. The default is to NOT block the command line.
;
; DEFAULTFONT - The name of a font to use as the default font.
;
; GROUP_LEADER - The group leader for this GUI. If this keyword is used, the program will be
; distroyed when the group leader is destroyed.
;
; LABELDEFAULTSIZE - The default screen size for a label. All labels are offsets from this size. 55 by default.
; The purpose of this keyword is to allow the user to modify the look of the GUI if different
; fonts are used.
;
; LABELFONT - The name of a font to use for program labels.
;
; NOTIFYID - A two-element array containing the widget identifier and top-level base ID of a widget
; designated to receive an event from this program. The event structure will be defined and sent
; like this:
;
; Widget_Control, notifyid[0], Send_Event={ MPI_PLOTCONFIG_EVENT, $
; ID: notifyid[0], $
; TOP:notifyid[1], $
; HANDLER: 0L, $
; OBJECT: self }
;
; Most event handlers will be written so that they will get the plot keywords
; from the plot configuration object and draw the plot. A sample event handler might
; look like this:
;
; PRO MPI_Plot_Configuration_Events, event
; Widget_Control, event.top, Get_UValue=info, /No_Copy
; WSet, info.wid
; plotkeywords = event.object->GetKeywords()
; Plot, info.indep, info.dep, _Extra=plotkeywords
; Widget_Control, event.top, Set_UValue=info, /No_Copy
; END
;
; XLONGFORM - By default, the X axis information is displayed in "short" form, with only the
; most relevant information readily available. Other axis information is accessed via buttons.
; Set this keyword to display the X axis information in a "long" form, in which all the axis
; information is immediately visible.
;
; YLONGFORM - By default, the Y axis information is displayed in "short" form, with only the
; most relevant information readily available. Other axis information is accessed via buttons.
; Set this keyword to display the Y axis information in a "long" form, in which all the axis
; information is immediately visible.
;
; SETPROPERTY - This procedure can be used to set the properties of the plot
; configuration object without using the graphical user interface. The
; keywords are identical to those used in the INIT method, above.
;
; METHOD FUNCTIONS:
;
; GETKEYWORDS - This function method contains no arguments or keywords. It returns a
; structure, with fields equivalent to PLOT keywords. The idea is that these
; keywords can be passed directly to the PLOT command using the keyword inheritance
; mechanism via the _EXTRA keyword to the plot command. A possible sequence of commands
; might look like this:
;
; IDL> plotConfigObj = Obj_New("MPI_PLOTCONFIG") ; Create the plot configuration object.
; IDL> plotConfigObj->GUI, /Block ; Allow the user to configure the plot parameters.
; IDL> plotKeywords = plotConfigObj->GetKeywords() ; Get the plot keywords.
; IDL> Plot, x, y, _Extra=plotKeywords ; Draw the plot in the way the user specified.
; IDL> Obj_Destroy, plotConfigObj ; Destroy the object when finished with it.
;
; PROGRAM NOTES:
;
; Color Names: Color names are those used with cgColor and PickColorName. See the
; documentation for those programs for instuctions on loading your own colors.
; To see the default colors and names, type this:
;
; IDL> color = PickColorName('yellow')
;
; Working with DataColor: Many people like to have the data color in a line plot
; different from the axis color. This requires two commands in IDL: a PLOT command
; with the NODATA keyword set, to draw in the axis color, followed by the OPLOT command,
; with the data drawn in the data color. Unfortunately, IDL only has a single COLOR keyword
; to represent both colors. So, you must be a bit resourceful to use this feature.
;
; The proper sequence of commands to use this feature of the plot configuration object
; will looks like this. First, initialize the object with the USEDATACOLOR keyword:
;
; plotConfigObj = Obj_New("MPI_PLOTCONFIG", /UseDataColor) ; Use the DataColor option.
;
; When you are ready to draw the plot, the keyword structure will have a new field named
; DataColor. Since this keyword is not recognized by the PLOT command, it will be ignored
; in the first PLOT command to draw the axes:
;
; plotKeywords = plotConfigObj->GetKeywords() ; Get the plot keywords.
; Plot, x, y, _Extra=plotKeywords, /NoData ; Just draw the axes.
;
; Next, change the color field to the datacolor field value, and overplot the
; data onto the axes you just drew:
;
; plotKeywords.color = PlotKeywords.datacolor
; OPlot, x, y, _Extra=plotKeywords
;
; You can see an example of how this is done in the heavily documented example program
; MPI_PLOT, which you can use as a wrapper for the PLOT command with your own data, if you like.
;
; Required Programs: The following programs are required to reside in your !PATH. They can be
; obtained from the Coyote Library:
;
; http://www.idlcoyote.com/programs/adjustposition.pro
; http://www.idlcoyote.com/programs/cw_drawcolor.pro
; http://www.idlcoyote.com/programs/cw_spacer.pro
; http://www.idlcoyote.com/programs/error_message.pro
; http://www.idlcoyote.com/programs/cgColor.pro
; http://www.idlcoyote.com/programs/fsc_droplist.pro
; http://www.idlcoyote.com/programs/fsc_field.pro
; http://www.idlcoyote.com/programs/fsc_plotwindow.pro
; http://www.idlcoyote.com/programs/mpi_axis__define.pro
; http://www.idlcoyote.com/programs/pickcolorname.pro
; http://www.idlcoyote.com/programs/pswindow.pro
; http://www.idlcoyote.com/programs/cgsnapshot.pro
;
; EXAMPLE:
;
; A heavily documented program, named MPI_PLOT, is supplied with this program.
; This program not only explains how to use the MPI_PLOTCONFIG__DEFINE program,
; it can be used as a wrapper program for the PLOT command that you can use with
; your own data. The program can be downloaded here:
;
; http://www.idlcoyote.com/programs/mpi_plot.pro
;
; MODIFICATION HISTORY:
;
; Written by David W. Fanning, March 2001.
; Made a change to the GUI method that fixes a problem I have been having
; on some Linux machines in widgets not always showing up. 15 July 2003. DWF.
; Removed obsolete STR_SEP and replaced with STRSPLIT. 27 Oct 2004. DWF.
; Fixed a problem when users tried to set PSYM to a negative value. 24 June 2008. DWF.
;-
;
;******************************************************************************************;
; Copyright (c) 2008, by Fanning Software Consulting, Inc. ;
; All rights reserved. ;
; ;
; Redistribution and use in source and binary forms, with or without ;
; modification, are permitted provided that the following conditions are met: ;
; ;
; * Redistributions of source code must retain the above copyright ;
; notice, this list of conditions and the following disclaimer. ;
; * Redistributions in binary form must reproduce the above copyright ;
; notice, this list of conditions and the following disclaimer in the ;
; documentation and/or other materials provided with the distribution. ;
; * Neither the name of Fanning Software Consulting, Inc. nor the names of its ;
; contributors may be used to endorse or promote products derived from this ;
; software without specific prior written permission. ;
; ;
; THIS SOFTWARE IS PROVIDED BY FANNING SOFTWARE CONSULTING, INC. ''AS IS'' AND ANY ;
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ;
; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT ;
; SHALL FANNING SOFTWARE CONSULTING, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, ;
; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED ;
; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ;
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;
;******************************************************************************************;
PRO MPI_PlotConfig_CenterTLB, tlb
; Center the top-level base on the display.
screenSize = Get_Screen_Size()
IF screenSize[0] GT 2000 THEN screenSize[0] = screenSize[0]/2 ; Dual monitors.
xCenter = screenSize(0) / 2
yCenter = screenSize(1) / 2
geom = Widget_Info(tlb, /Geometry)
xHalfSize = geom.Scr_XSize / 2
yHalfSize = geom.Scr_YSize / 2
Widget_Control, tlb, XOffset = xCenter-xHalfSize, $
YOffset = yCenter-yHalfSize
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig_Error_Message, theMessage, Traceback=traceback, NoName=noName, _Extra=extra
On_Error, 2
; Check for presence and type of message.
IF N_Elements(theMessage) EQ 0 THEN theMessage = !Error_State.Msg
s = Size(theMessage)
messageType = s[s[0]+1]
IF messageType NE 7 THEN BEGIN
Message, "The message parameter must be a string.", _Extra=extra
ENDIF
; Get the call stack and the calling routine's name.
Help, Calls=callStack
callingRoutine = (StrSplit(StrCompress(callStack[1])," ", /Extract))[0]
; Are widgets supported? Doesn't matter in IDL 5.3 and higher.
widgetsSupported = ((!D.Flags AND 65536L) NE 0) OR Float(!Version.Release) GE 5.3
IF widgetsSupported THEN BEGIN
IF Keyword_Set(noName) THEN answer = Dialog_Message(theMessage, _Extra=extra) ELSE BEGIN
IF StrUpCase(callingRoutine) EQ "$MAIN$" THEN answer = Dialog_Message(theMessage, _Extra=extra) ELSE $
answer = Dialog_Message(StrUpCase(callingRoutine) + ": " + theMessage, _Extra=extra)
ENDELSE
ENDIF ELSE BEGIN
Message, theMessage, /Continue, /NoPrint, /NoName, /NoPrefix, _Extra=extra
Print, '%' + callingRoutine + ': ' + theMessage
answer = 'OK'
ENDELSE
; Provide traceback information if requested.
IF Keyword_Set(traceback) THEN BEGIN
Help, /Last_Message, Output=traceback
Print,''
Print, 'Traceback Report from ' + StrUpCase(callingRoutine) + ':'
Print, ''
FOR j=0,N_Elements(traceback)-1 DO Print, " " + traceback[j]
ENDIF
RETURN, answer
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::Symbol, number
; This method calculates a user-defined symbol for the PSYM keyword.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 18
ENDIF
; Error checking.
IF N_Elements(number) EQ 0 THEN RETURN, 18
IF (number GT 18) THEN Message, /NoName, 'Symbol number out of defined range. Returning NO SYMBOL.'
IF number LT 0 THEN BEGIN
sign = -1
number = Abs(number)
ENDIF ELSE BEGIN
sign = 1
ENDELSE
; Define helper variables for creating circles.
phi = Findgen(32) * (!PI * 2 / 32.)
phi = [ phi, phi(0) ]
; Use user defined symbol by default.
result = 8
CASE number OF
0 : result = 3 ; Dot
1 : UserSym, Cos(phi), Sin(phi), /Fill ; Filled circle.
2 : UserSym, [ -1, 0, 1, -1 ], [ -1, 1, -1, -1 ], /Fill ; Filled upward triangle.
3 : UserSym, [ -1, 0, 1, -1 ], [ 1, -1, 1, 1 ], /Fill ; Filled downward triangle.
4 : UserSym, [ 0, 1, 0, -1, 0 ], [ 1, 0, -1, 0, 1 ], /Fill ; Filled diamond.
5 : UserSym, [ -1, 1, 1, -1, -1 ], [ 1, 1, -1, -1, 1 ], /Fill ; Filled square.
6 : UserSym, cos(phi), sin(phi) ; Open circle.
7 : UserSym, [ -1, 0, 1, -1 ], [ -1, 1, -1, -1 ] ; Open upward triangle.
8 : UserSym, [ -1, 0, 1, -1 ], [ 1, -1, 1, 1 ] ; Open downward triangle.
9 : UserSym, [ 0, 1, 0, -1, 0 ], [ 1, 0, -1, 0, 1 ] ; Open diamond.
10 : UserSym, [ -1, 1, 1, -1, -1 ], [ 1, 1, -1, -1, 1 ] ; Open square.
11 : result = 1 ; Plus.
12 : result = 7 ; X.
13 : result = 2 ; Star.
14 : UserSym, [ -1, 1, -1, -1 ], [1, 0, -1, 1 ], /Fill ; Filled rightfacing triangle.
15 : UserSym, [ 1, -1, 1, 1 ], [1, 0, -1, 1 ], /Fill ; Filled leftfacing triangle.
16 : UserSym, [ -1, 1, -1, -1 ], [1, 0, -1, 1 ] ; Open rightfacing triangle.
17 : UserSym, [ 1, -1, 1, 1 ], [1, 0, -1, 1 ] ; Open leftfacing triangle.
18 : result = 0 ; No symbol at all.
ENDCASE
RETURN, result * sign
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::AxisObjectEvents, event
; This method responds to events from the axis objects, if they are
; associated with the plot object.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
PRO MPI_PlotConfig::SetPlotKeywords, plotkeywords
; This method sets the plot properties from a structure of keywords.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN
ENDIF
tagnames = Tag_Names(plotkeywords)
plotkeywords.color = plotkeywords.name_color
plotkeywords.background = plotkeywords.name_background
index = Where(tagnames EQ 'DATACOLOR', count)
IF count GT 0 THEN plotkeywords.datacolor = plotkeywords.name_datacolor
END ;-----------------------------------------------------------------------------------------------------------------------------
PRO MPI_PlotConfig::Destroy
; This method destroys the top-level base of the compound widget.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN
ENDIF
IF Widget_Info(self.tlb, /Valid_ID) THEN Widget_Control, self.tlb, /Destroy
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::GetTLB
; This method returns the top-level base of the compound widget.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
RETURN, self.tlb
END ;-----------------------------------------------------------------------------------------------------------------------------
PRO MPI_PlotConfig::SendEvent
; This method sends an event to the widget to be notified, if one exists.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN
ENDIF
IF Total(self.notifyID) GT 0 THEN BEGIN
thisEvent = { MPI_PLOTCONFIG_EVENT, $
ID: self.notifyID[0], $
TOP:self.notifyID[1], $
HANDLER: 0L, $
OBJECT: self }
Widget_Control, self.notifyID[0], Send_Event=thisEvent
ENDIF
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::GetKeywords
; This method constructs a structure containing fields with values
; set to the current state of the object.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self->UpdateObject
struct = Create_Struct( $
'background', cgColor(self.background, !P.Background), $
'charthick', self.charthick, $
'charsize', self.charsize, $
'color', cgColor(self.color, !D.Table_Size-2), $
'font', self.font, $
'linestyle', self.linestyle, $
'position', self.position, $
'psym', self->Symbol(self.psym) * self.noline, $
'subtitle', self.subtitle, $
'symsize', self.symsize, $
'thick', self.thick, $
'ticklen', self.ticklen, $
'title', self.title, $
'name_color', self.color, $
'name_background', self.background )
; Add axis color information, if required.
IF self.usedatacolor THEN $
struct = Create_Struct(struct, 'datacolor', cgColor(self.dataColor, !D.Table_Size-3), $
'name_datacolor', self.datacolor)
; Done unless axis information is required.
IF self.noaxisinfo THEN RETURN, struct
IF Obj_Valid(self.xaxis) THEN BEGIN
xstruct = self.xaxis->GetKeywords()
struct = Create_Struct(struct, xstruct)
ENDIF
IF Obj_Valid(self.yaxis) THEN BEGIN
ystruct = self.yaxis->GetKeywords()
struct = Create_Struct(struct, ystruct)
ENDIF
RETURN, struct
END ;-----------------------------------------------------------------------------------------------------------------------------
PRO MPI_PlotConfig::UpdateObject
; This method simply gathers all the information in the graphical
; user interface (that doesn't update itself) and updates the self
; object. If fields are undefined, they are set to their default values.
IF Obj_Valid(self.titleObj) NE 0 THEN BEGIN
IF N_Elements(self.titleObj->Get_Value()) EQ 0 THEN BEGIN
value = ""
self.titleObj->Set_Value, value
ENDIF ELSE value = self.titleObj->Get_Value()
self.title = value
ENDIF
IF Obj_Valid(self.subtitleObj) NE 0 THEN BEGIN
IF N_Elements(self.subtitleObj->Get_Value()) EQ 0 THEN BEGIN
value = ""
self.subtitleObj->Set_Value, value
ENDIF ELSE value = self.subtitleObj->Get_Value()
self.subtitle = value
ENDIF
IF Obj_Valid(self.thickObj) NE 0 THEN BEGIN
IF Finite(self.thickObj->Get_Value()) EQ 0 THEN BEGIN
value = 1.0
self.thickObj->Set_Value, value
ENDIF ELSE value = self.thickObj->Get_Value()
self.thick = value
ENDIF
IF Obj_Valid(self.symsizeObj) NE 0 THEN BEGIN
IF Finite(self.symsizeObj->Get_Value()) EQ 0 THEN BEGIN
value = 1.0
self.symsizeObj->Set_Value, value
ENDIF ELSE value = self.symsizeObj->Get_Value()
self.symsize = value
ENDIF
IF Obj_Valid(self.charthickObj) NE 0 THEN BEGIN
IF Finite(self.charthickObj->Get_Value()) EQ 0 THEN BEGIN
value = 1.0
self.charthickObj->Set_Value, value
ENDIF ELSE value = self.charthickObj->Get_Value()
self.charthick = value
ENDIF
IF Obj_Valid(self.ticklenObj) NE 0 THEN BEGIN
IF Finite(self.ticklenObj->Get_Value()) EQ 0 THEN BEGIN
value = 0.020
self.ticklenObj->Set_Value, value
ENDIF ELSE value = self.ticklenObj->Get_Value()
self.ticklen = value
ENDIF
IF Obj_Valid(self.charsizeObj) NE 0 THEN BEGIN
IF Finite(self.charsizeObj->Get_Value()) EQ 0 THEN BEGIN
value = 1.0
self.charsizeObj->Set_Value, value
ENDIF ELSE value = self.charsizeObj->Get_Value()
self.charsize = value
ENDIF
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::CheckEvent, event
; This event handler method checks to see if an event
; should be passed on.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
; Make sure all values are current by updating.
self->UpdateObject
IF self.all_events THEN self->SendEvent
RETURN, 0
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetPlotPosition, event
; This event handler method sets the plot position.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
Widget_Control, event.top, TLB_Get_Offset=offsets, TLB_Get_Size=tlbsizes
self.position = AdjustPosition(self.position, Group_Leader=event.top, Cancel=cancelled, $
XOffset=offsets[0] + 0.7*tlbsizes[0], YOffset=offsets[1] + 0.4*tlbsizes[1])
IF cancelled THEN RETURN, 0 ELSE RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetTitle, event
; This event handler method sets the plot title.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self.title = *event.value
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetSubTitle, event
; This event handler method sets the plot subtitle.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self.subtitle = *event.value
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetFont, event
; This event handler method sets the plot font style.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self.font = event.index - 1
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetLinestyle, event
; This event handler method sets the plot line style.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
; Can't have no symbols and no lines. If this is the
; case, set the symbol droplist to dots.
IF self.lineStyleID->GetSelection() EQ 'No Line' THEN BEGIN
IF self.psymID->GetSelection() EQ 'No Symbol' THEN BEGIN
self.psym = self.lastvalidsymbol
self.psymID->SetIndex, self.lastvalidsymbol
self.noline = 1
ENDIF
self.noline = 1
ENDIF ELSE BEGIN
self.lastvalidline = event.index
self.noline = -1
ENDELSE
self.linestyle = event.index
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetSymbol, event
; This event handler method sets the plot symbol type.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
; Can't have no symbols and no lines. If this is the
; case, set the line style droplist to solid lines.
IF self.psymID->GetSelection() EQ 'No Symbol' THEN BEGIN
IF self.lineStyleID->GetSelection() EQ 'No Line' THEN BEGIN
self.lineStyleID->SetIndex, self.lastvalidline
self.linestyle = self.lastvalidline
self.noline = 1
ENDIF
ENDIF ELSE self.lastvalidsymbol = event.index
self.psym = event.index
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetBackgroundColor, event
; This event handler method sets the plot background color.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self.background = event.color
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetColor, event
; This event handler method sets the plot color.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self.color = event.color
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetDataColor, event
; This event handler method sets the axis color.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self.datacolor = event.color
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetLineThick, event
; This event handler method sets the plot line thickness.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self.thick = *event.value
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetCharThick, event
; This event handler method sets the plot character thickness.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self.charthick = *event.value
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetSymSize, event
; This event handler method sets the plot symbol size.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self.symsize = *event.value
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetCharSize, event
; This event handler method sets the plot symbol size.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self.charsize = *event.value
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SymbolWithLine, event
; This event handler method changes the psym field so that symbols are
; connected with lines.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
IF event.select EQ 1 THEN self.noline = -1 ELSE self.noline = 1
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::SetTickLen, event
; This event handler method sets the plot tick length.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self.ticklen = *event.value
RETURN, self->CheckEvent(event)
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::DismissDialog, event
; This event handler method destroys the widget.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
Widget_Control, self.tlb, /Destroy
RETURN, 0
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::AcceptDialog, event
; This event handler method updates the dialog and destroys the widget.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self->UpdateObject
IF Obj_Valid(self.xaxis) THEN self.xaxis->UpdateObject
IF Obj_Valid(self.yaxis) THEN self.yaxis->UpdateObject
self->SendEvent
self->Destroy
RETURN, 0
END ;-----------------------------------------------------------------------------------------------------------------------------
FUNCTION MPI_PlotConfig::ApplyDialog, event
; This event handler method updates the dialog and destroys the widget.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN, 0
ENDIF
self->UpdateObject
IF Obj_Valid(self.xaxis) THEN self.xaxis->UpdateObject
IF Obj_Valid(self.yaxis) THEN self.yaxis->UpdateObject
self->SendEvent
RETURN, 0
END ;-----------------------------------------------------------------------------------------------------------------------------
PRO MPI_PlotConfig::GUI, $
; This method displays a graphical user interface for changing the values in the object.
All_events=all_events, $ ; Set this keyword to get all of the events generated.
Block=block, $ ; Set this keyword if you want to block the command line.
Defaultfont=defaultfont, $ ; The name of a font to use as the default font.
Group_Leader=group_leader, $ ; The group leader for this GUI.
LabelDefaultSize=labeldefaultsize, $ ; The default screen size for a label. All labels are offsets from this size. 55 by default.
LabelFont=labelfont, $ ; The name of a font to use for program labels.
NotifyID=notifyID, $ ; The widget ID and top-level base to notify upon an event.
XLongForm=xlongform, $ ; Set this keyword to display the X axis information in a long form.
YLongForm=ylongform ; Set this keyword to display the Y axis information in a long form.
; Error handling.
Catch, theError
IF theError NE 0 THEN BEGIN
ok = MPI_PlotConfig_Error_Message(/Traceback)
RETURN
ENDIF
; Only one version of this program at a time.
IF XRegistered('mpi_plotconfig') GT 0 THEN RETURN
; Check keyword arguments.
self.all_events = Keyword_Set(all_events)
IF N_Elements(notifyID) NE 0 THEN self.notifyID = notifyID