owindow.pro
7.1 KB
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
;+
; NAME:
; OWINDOW
;
; PURPOSE:
; The purpose of this program is to create an object window.
; I use it mostly when I am creating and testing object graphics
; programs, but it is also a nice template for larger object
; graphics programs. The window is resizeable and it destroys
; its objects when it is destroyed.
;
; AUTHOR:
; FANNING SOFTWARE CONSULTING
; David Fanning, Ph.D.
; 1645 Sheely Drive
; Fort Collins, CO 80526 USA
; Phone: 970-221-0438
; E-mail: david@idlcoyote.com
; Coyote's Guide to IDL Programming: http://www.idlcoyote.com
;
; CATEGORY:
; Widgets, IDL 5 Object Graphics.
;
; CALLING SEQUENCE:
; thisWindow = OWindow(thisView)
;
; REQUIRED INPUTS:
; None. A default view object is created with a gray background and
; a viewplane rectangle defined as [0,0,1,1].
;
; OPTIONAL INPUTS:
;
; thisView: A view or scene object that you wish to be displayed
; in the window.
;
; RETURN VALUE:
; thisWindow: The window graphics object associated with this window.
;
; OPTIONAL KEYWORD PARAMETERS:
;
; GROUP_LEADER: The group leader for this program. When the group leader
; is destroyed, this program will be destroyed.
;
; TITLE: A string used as the title of the graphics window.
;
; XSIZE: The X Size of the graphics window in device coordinates. The
; default value is 300.
;
; YSIZE: The Y Size of the graphics window in device coordinates. The
; default value is 300.
;
; COMMON BLOCKS:
; None.
;
; SIDE EFFECTS:
; None.
;
; RESTRICTIONS:
; None.
;
; EXAMPLE:
; To display a view object in this window, type:
;
; IDL> thisWindow = OWindow(thisView)
;
; Later, after you have modified the view object, you can type:
;
; IDL> thisWindow->Draw, modifiedView
;
; MODIFICATION HISTORY:
; Written by David Fanning, 19 June 97.
; Set RETAIN=1 on draw widget. 6 Oct 97. DWF.
; Changed discredited IDLgrContainer to IDL_Container. 29 JUN 98. DWF.
; Modified draw widget to use RETAIN=2 and do away with expose events. 6 May 2011. 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 OWindow_Cleanup, tlb
; This is the clean up routine called when the TLB dies.
Widget_Control, tlb, Get_UValue=info, /No_Copy
IF N_Elements(info) GT 0 THEN Obj_Destroy, info.thisContainer
END
;------------------------------------------------------------------------
PRO OWindow_Quit, event
; Quit the program via the QUIT button.
Widget_Control, event.top, /Destroy
END
;------------------------------------------------------------------------
PRO OWindow_Event, event
; Handle window resize events here.
Widget_Control, event.top, Get_UValue=info, /No_Copy
info.thisWindow->SetProperty, Dimension=[event.x, event.y]
info.thisWindow->Draw, info.thisView
Widget_Control, event.top, Set_UValue=info, /No_Copy
END
;-------------------------------------------------------------------------
FUNCTION OWindow, thisView, XSize=xsize, YSize=ysize, Title=title, $
Group_Leader=group
; Check defaults. Define values if necessary.
IF N_Params() EQ 0 THEN thisView = Obj_New('IDLgrView', Color=[80,80,80], $
Viewplane_Rect=[0,0,1,1])
IF N_Elements(xsize) EQ 0 THEN xsize = 400
IF N_Elements(ysize) EQ 0 THEN ysize = 400
IF N_Elements(title) EQ 0 THEN title = ''
; Creat the widgets for this program.
tlb = Widget_Base(Column=1, Title=title, TLB_Size_Events=1, $
MBar=menubase)
drawID = Widget_Draw(tlb, XSize=xsize, YSize=ysize, Graphics_Level=2, Retain=2)
filer = Widget_Button(menubase, Value='File')
quitter = Widget_Button(filer, Value='Quit', Event_Pro='OWindow_Quit')
; Realize the widgets. Get the object window.
Widget_Control, tlb, /Realize
Widget_Control, drawID, Get_Value=thisWindow
; Store objects in a container for easy clean up.
thisContainer = Obj_New('IDL_Container')
thisContainer->Add, thisWindow
thisContainer->Add, thisView
; Create info structure for program information.
info = { thisWindow:thisWindow, $
thisContainer:thisContainer, $
thisView:thisView }
Widget_Control, tlb, Set_UValue=info, /No_Copy
XManager, 'owindow', tlb, /No_Block, Cleanup='OWindow_Cleanup', $
Group_Leader=group
; Draw the view.
thisWindow -> Draw, thisView
; Return the window object so you can put something else
; in this window if you like.
RETURN, thisWindow
END