-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathas_datfileloader__define.pro
246 lines (176 loc) · 7.97 KB
/
as_datfileloader__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
PRO as_datfileloader_selectfile, event
@as_scatterheader.macro
Widget_Control, event.top, GET_UVALUE = as_datfileloader
as_datfileloader.selectFile, event
END
PRO as_datfileloader_event, event
@as_scatterheader.macro
Widget_Control, event.top, GET_UVALUE = as_datfileloader
as_datfileloader.event, event
END
PRO as_datfileloader::selectfile, event
@as_scatterheader.macro
IF event.clicks EQ 2 THEN BEGIN
selected = Widget_Info(Widget_Info(event.id, /TREE_ROOT),/TREE_SELECT)
nameList = list()
treeIDs = list()
FOREACH name, self.names DO treeIDs.add, Widget_Info(event.top, FIND_BY_UNAME = name)
FOREACH s, selected DO BEGIN
IF s GE 0 AND Where(s EQ treeIDs,/NULL) EQ !NULL THEN BEGIN
Widget_Control, s, GET_UVALUE = name
nameList.add, name.filename
ENDIF
ENDFOREACH
self.notify, {SELECT, filenames: nameList, Clicks: event.clicks}
ENDIF
END
PRO as_datfileloader::event, event
@as_scatterheader.macro
CASE Tag_Names(event, /STRUCTURE) OF
'WIDGET_BASE' : BEGIN
baseGeom = Widget_Info(event.id, /GEOMETRY)
wTabID = Widget_Info(event.top, FIND_BY_UNAME = 'TAB CONTAINER')
FOREACH name, self.names DO BEGIN
treeID = Widget_Info(event.top, FIND_BY_UNAME = name)
treeGeom = Widget_Info(treeID, /GEOMETRY)
Widget_Control, treeID, XSIZE = baseGeom.XSize - self.diffXSize-2, YSIZE = baseGeom.YSize - self.diffYSize - 2
ENDFOREACH
Widget_Control, wTabID, XSIZE = baseGeom.XSize - self.diffXSize, YSIZE = baseGeom.YSize - self.diffYSize
END
'WIDGET_KILL_REQUEST' : BEGIN
Obj_Destroy, self
RETURN
END
'WIDGET_CONTEXT' : BEGIN
Widget_Control, event.id, GET_UVALUE = wContextBase
WIDGET_DISPLAYCONTEXTMENU, event.id, event.x, event.y, wContextBase
RETURN
END
'WIDGET_TIMER' : BEGIN
self.refresh
IF self.polling EQ 1 THEN Widget_Control, event.id, TIMER = 2
END
ELSE:
ENDCASE
widgetName = Widget_Info(event.id, /UNAME)
Widget_Control, event.id, GET_UVALUE = uvalue
CASE widgetName OF
'REFRESH' : self.refresh
'DESELECT' : Widget_Control, uvalue, SET_TREE_SELECT = 0
'CONTOUR' : self.contour, Widget_Info(uvalue, /TREE_SELECT)
'AUTOCONTOUR' : self.contour, Widget_Info(uvalue, /TREE_SELECT), /AUTO
'MOVIE' :
ELSE :
ENDCASE
END
FUNCTION as_datfileloader::init, names, folders, GROUPLEADER = groupLeader, EXTENSION = extension, NOTIFYOBJECT = notifyObject
@as_scatterheader.macro
IF Keyword_Set(notifyObject) THEN $
IF TypeName(notifyObject[0]) EQ 'NOTIFY' $
THEN self.notifyObject = List(notifyObject,/EXTRACT)
IF ~KeyWord_Set(extension) THEN extension = 'dat'
IF KeyWord_Set(groupLeader) THEN wBase = Widget_Base(GROUP_LEADER = groupLeader, TITLE = 'Dat Files', /TLB_KILL_REQUEST_EVENTS, /COLUMN, /TLB_SIZE_EVENTS, UNAME = 'BASE') ELSE wBase = Widget_Base(TITLE = 'Dat Files', /TLB_KILL_REQUEST_EVENTS, /COLUMN, /TLB_SIZE_EVENTS, UNAME = 'BASE')
wTab = Widget_Tab(wBase, UNAME = 'TAB CONTAINER')
refresh = Widget_Button(wBase, VALUE = 'Refresh', SCR_XSIZE = 100, UNAME = 'REFRESH')
Widget_Control, wBase, /REALIZE
Widget_Control, wBase, SET_UVALUE = self
self.wBase = wBase
IF N_Elements(names) GT 0 THEN self.addTab, names, folders, EXTENSION = extension
XManager, 'as_datfileloader', wBase, /NO_BLOCK
RETURN, 1
END
PRO as_datfileloader::notify, event
@as_scatterheader.macro
FOREACH notify, self.notifyObject DO IF Obj_Valid(notify) THEN notify.notify, event
END
PRO as_datfileloader::polling, poll
CASE poll OF
0: BEGIN
self.polling = 0
END
1: BEGIN
self.polling = 1
Widget_Control, self.wBase, TIMER = 2
END
ELSE :
ENDCASE
END
PRO as_datfileloader::contour, selected, AUTO = auto
filenames = list()
FOREACH select, selected DO BEGIN
Widget_Control, select, GET_UVALUE = filename
filenames.add, filename.filename
ENDFOREACH
IF KeyWord_Set(auto) THEN BEGIN
self.polling, 1
Widget_Control, Widget_Info(Widget_Info(select,/PARENT),/PARENT), GET_UVALUE = folder
self.autocontour = folder
ENDIF
event = {CONTOUR, filenames:filenames}
self.notify, event
END
PRO as_datfileloader::addTab, names, folders, EXTENSION = extension
@as_scatterheader.macro
IF ~KeyWord_Set(extension) THEN self.extension = 'dat' ELSE self.extension = StrCompress(extension, /REMOVE_ALL)
IF N_Elements(names) EQ 0 THEN RETURN
IF N_Elements(names) NE N_Elements(folders) THEN RETURN
IF ISA(names, 'LIST') THEN self.names = names ELSE self.names = List(names, /EXTRACT)
IF ISA(folders, 'LIST') THEN self.folders = folders ELSE self.folders = List(folders, /EXTRACT)
wTab = Widget_Info(self.wBase, FIND_BY_UNAME = 'TAB CONTAINER')
Widget_Control, self.wBase, UPDATE = 0
FOREACH name, self.names, key DO BEGIN
wTabBase = Widget_Base(wTab, TITLE = name, UVALUE = name, /COLUMN)
wTree = Widget_Tree(wTabBase, /MULTIPLE, /CONTEXT_EVENTS, /DRAGGABLE, UNAME = name)
files = File_Search((self.folders)[key] + Path_Sep() + '*.' + self.extension, /NOSORT)
FOREACH file, files DO leaf = Widget_Tree(wTree, VALUE = File_Basename(file), UVALUE = {DAT, filename : file}, EVENT_PRO = 'as_datfileloader_selectfile')
wContextBase = Widget_Base(wTree, /CONTEXT_MENU, UNAME = 'TreeContextBase')
Widget_Control, wTree, SET_UVALUE = wContextBase
wDeselect = Widget_Button(wContextBase, VALUE = 'Deselect All', UVALUE = wTree, UNAME = 'DESELECT')
wContour = Widget_Button(wContextBase, VALUE = 'Contour', UVALUE = wTree, UNAME = 'CONTOUR')
wContour = Widget_Button(wContextBase, VALUE = 'Auto Contour', UVALUE = wTree, UNAME = 'AUTOCONTOUR')
wMovie = Widget_Button(wContextBase, VALUE = 'Movie', UVALUE = wTree, UNAME = 'MOVIE')
ENDFOREACH
Widget_Control, self.wBase, /UPDATE
tabGeom = Widget_Info(wTab, /GEOMETRY)
baseGeom = Widget_Info(self.wBase, /GEOMETRY)
self.diffXSize = baseGeom.Scr_XSize - tabGeom.Scr_XSize
self.diffYSize = baseGeom.Scr_YSize - tabGeom.Scr_YSize
self.refresh
END
PRO as_datfileloader::refresh
FOREACH name, self.names, key DO BEGIN
files = File_Search((self.folders)[key] + Path_Sep() + '*.' + self.extension, /NOSORT)
treeID = Widget_Info(self.wBase, FIND_BY_UNAME = name)
children = Widget_Info(treeID, /ALL_CHILDREN)
leaf = List()
FOREACH child, children DO BEGIN
IF Widget_Info(child,/TYPE) EQ 11 THEN Widget_Control, child, GET_VALUE = VALUE
leaf.add, value
ENDFOREACH
leaf = leaf.toArray()
FOREACH file, files DO BEGIN
IF Where(leaf EQ File_Basename(file), /NULL) EQ !NULL THEN BEGIN
leafID = Widget_Tree(treeID, VALUE = File_Basename(file), UVALUE = {DAT, filename : file}, EVENT_PRO = 'as_datfileloader_selectfile')
IF self.autocontour EQ name THEN self.notify, {CONTOURUPDATE, filenames: List(file)}
ENDIF
ENDFOREACH
ENDFOREACH
END
PRO as_datfileloader::contourclosed
self.polling, 0
END
PRO as_datfileloader::Cleanup
IF Widget_Info(self.wBase, /VALID) THEN Widget_Control, self.wBase, /DESTROY
END
PRO as_datfileloader__define
void = {as_datfileloader, $
wBase : 0L, $
names : List(), $
folders : List (), $
extension : '', $
notifyObject : List(), $
diffXSize : 0, $
diffYSize : 0, $
polling : 0, $
autocontour : '' }
END