pro spd_ui_load_indices_event,event
compile_opt hidden,idl2
err_xxx = 0
Catch, err_xxx
IF (err_xxx NE 0) THEN BEGIN
Catch, /Cancel
Help, /Last_Message, Output = err_msg
if is_struct(state) then begin
FOR j = 0, N_Elements(err_msg)-1 DO state.historywin->update,err_msg[j]
if widget_valid(state.baseID) && obj_valid(state.historyWin) then begin
spd_gui_error,state.baseid,state.historyWin
endif
if obj_valid(state.loadTree) then begin
*state.treeCopyPtr = state.loadTree->getCopy()
endif
Widget_Control, event.TOP, Set_UValue=state, /No_Copy
endif
Print, 'Error--See history'
ok=error_message('An unknown error occured and the window must be restarted. See console for details.',$
/noname, /center, title='Error in Load Geomagnetic Indices Data')
widget_control, event.top,/destroy
RETURN
ENDIF
widget_control, event.handler, Get_UValue=state, /no_copy
widget_control, event.id, get_uvalue = uval
if is_string(uval) then begin
case uval of
'DATALIST': begin
rlistparam = widget_info(event.handler, find_by_uname='reslist')
dlistparam = widget_info(event.handler, find_by_uname='datalist')
curvalue = widget_info(dlistparam, /list_select)
ilistparam = widget_info(event.handler, find_by_uname='indexlist')
ilistselect = widget_info(ilistparam, /list_select)
widget_control, rlistparam, set_value=*(*state.ptrindexResolutions[ilistselect])[curvalue]
end
'INDEXLIST': begin
ilistparam = widget_info(event.handler, find_by_uname='indexlist')
ilistselect = widget_info(ilistparam, /list_select)
dlistparam = widget_info(event.handler,find_by_uname='datalist')
widget_control, dlistparam, set_value=*state.typeArray[event.index]
rlistparam = widget_info(event.handler,find_by_uname='reslist')
widget_control, rlistparam, set_value=*(*state.ptrindexResolutions[ilistselect])[0]
widget_control, dlistparam, set_list_select=0
widget_control, rlistparam, set_list_select=0
sourcelabel1 = widget_info(event.handler, find_by_uname='dataSource1')
sourcelabel2 = widget_info(event.handler, find_by_uname='dataSource2')
widget_control, sourcelabel1, set_value=(*state.dsourceLabels[event.index])[0]
widget_control, sourcelabel2, set_value=(*state.dsourceLabels[event.index])[1]
end
'CLEARINDEX': begin
indexlist = widget_info(event.handler,find_by_uname='indexlist')
widget_control,indexlist,set_list_select=-1
end
'CLEARTYPE': begin
datalist = widget_info(event.handler,find_by_uname='datalist')
widget_control,datalist,set_list_select=-1
end
'CLEARRES': begin
reslist = widget_info(event.handler,find_by_uname='reslist')
widget_control,reslist,set_list_select=-1
end
'CLEARDATA': begin
ok = dialog_message("This will delete all currently loaded data. Are you sure you wish to continue?",/question,/default_no,/center)
if strlowcase(ok) eq 'yes' then begin
datanames = state.loadedData->getAll(/parent)
if is_string(datanames) then begin
for i = 0,n_elements(dataNames)-1 do begin
result = state.loadedData->remove(datanames[i])
if ~result then begin
state.statusBar->update,'Unexpected error while removing data.'
state.historyWin->update,'Unexpected error while removing data.'
endif
endfor
endif
state.loadTree->update
state.callSequence->clearCalls
endif
end
'DEL': begin
dataNames = state.loadTree->getValue()
if ptr_valid(datanames[0]) then begin
for i = 0,n_elements(dataNames)-1 do begin
result = state.loadedData->remove((*datanames[i]).groupname)
if ~result then begin
state.statusBar->update,'Unexpected error while removing data.'
state.historyWin->update,'Unexpected error while removing data.'
endif else begin
state.callSequence->adddeletecall,(*datanames[i]).groupname
endelse
endfor
endif
state.loadTree->update
end
'ADD': begin
datalist = widget_info(event.handler,find_by_uname='datalist')
typeSelect = widget_info(datalist,/list_select)
if typeSelect[0] eq -1 then begin
state.statusBar->update,'You must select at least one data type'
state.historyWin->update,'Load Geomagnetic Indices add attempted without selecting data type'
break
endif
indexlist = widget_info(event.handler,find_by_uname='indexlist')
indexSelect = widget_info(indexlist,/list_select)
if indexSelect[0] eq -1 then begin
state.statusBar->update,'You must select at least one index'
state.historyWin->update,'Load Geomagnetic Indices add attempted without selecting index'
break
endif
reslist = widget_info(event.handler, find_by_uname='reslist')
resSelect = widget_info(reslist, /list_select)
if resSelect[0] eq -1 then begin
state.statusBar->update,'You must select at least one resolution'
state.historyWin->update,'Load Geomagnetic Indices add attempted without selecting resolution'
break
endif
indices = state.indexArray[indexSelect]
types = (*state.typeArray[indexSelect])[typeSelect]
resolution = (*(*state.ptrindexResolutions[indexSelect])[typeSelect])[resSelect]
timeRangeObj = state.timeRangeObj
timeRangeObj->getProperty,startTime=startTimeObj,endTime=endTimeObj
startTimeObj->getProperty,tdouble=startTimeDouble,tstring=startTimeString
endTimeObj->getProperty,tdouble=endTimeDouble,tstring=endTimeString
if startTimeDouble ge endTimeDouble then begin
state.statusBar->update,'Cannot add data unless end time is greater than start time.'
state.historyWin->update,'Load Geomagnetic Indices add attempted with start time greater than end time.'
break
endif
widget_control, /hourglass
loadStruc = { index:indices, $
datatypes:types, $
resolution:resolution, $
timeRange:[startTimeString, endTimeString] }
spd_ui_load_indices_load, $
loadStruc,$
state.loadedData,$
state.statusBar,$
state.historyWin,$
state.baseid,$
replay=replay,$
overwrite_selections=overwrite_selections
state.loadTree->update
callSeqStruc = { type:'loadapidata', $
subtype:'spd_ui_load_indices_load', $
loadStruc:loadStruc, $
overwrite_selections:overwrite_selections }
state.callSequence->addSt, callSeqStruc
end
else:
endcase
endif
Widget_Control, event.handler, Set_UValue=state, /No_Copy
return
end
function spd_ui_index_source_data
dsourceLabels = ptrarr(11)
dsourceLabels[0] = ptr_new(['Ap data is provided by the NOAA National Geophysical Data Center',' '])
dsourceLabels[1] = ptr_new(['Auroral Electrojet (AE) data is provided by the WDC for Geomagnetism,','Kyoto (Japan)'])
dsourceLabels[2] = ptr_new(['Cp data is provided by the NOAA National Geophysical Data Center',' '])
dsourceLabels[3] = ptr_new(['C9 data is provided by the NOAA National Geophysical Data Center',' '])
dsourceLabels[4] = ptr_new(['Disturbance storm-time (Dst) index data is provided by the WDC ','for Geomagnetism, Kyoto (Japan).'])
dsourceLabels[5] = ptr_new(['10.7-cm solar radio flux data is provided by the NOAA ','National Geophysical Data Center'])
dsourceLabels[6] = ptr_new(['Kp data is provided by the NOAA National Geophysical Data Center',' '])
dsourceLabels[7] = ptr_new(['Solar rotation data is provided by the NOAA National Geophysical','Data Center'])
dsourceLabels[8] = ptr_new(['Solar rotation data is provided by the NOAA National Geophysical','Data Center'])
dsourceLabels[9] = ptr_new(['International sunspot number data is provided by the NOAA','National Geophysical Data Center'])
dsourceLabels[10] = ptr_new(['SYM/ASY data are loaded from the OMNI dataset, provided','by NASA ISTP/SPDF'])
return, dsourceLabels
end
function spd_ui_index_data_types
paramArray = ptrarr(11)
paramArray[0] = ptr_new(['*', 'ap', 'Ap (ap mean)'])
paramArray[1] = ptr_new(['*','AE prov','AO prov','AU prov','AL prov','AX prov'])
paramArray[2] = ptr_new(['Cp'])
paramArray[3] = ptr_new(['C9'])
paramArray[4] = ptr_new(['Dst'])
paramArray[5] = ptr_new(['F10.7'])
paramArray[6] = ptr_new(['*','Kp', 'Kp sum'])
paramArray[7] = ptr_new(['Solar rotation #'])
paramArray[8] = ptr_new(['Solar rotation day'])
paramArray[9] = ptr_new(['Sunspot #'])
paramArray[10] = ptr_new(['*','Sym-H', 'Sym-D', 'Asy-H', 'Asy-D' ])
return, paramArray
end
function spd_ui_index_resolutions
resArray = ptrarr(11)
apRes = ptrarr(3)
aeRes = ptrarr(6)
cpRes = ptrarr(1)
c9Res = ptrarr(1)
dstRes = ptrarr(1)
f107Res = ptrarr(1)
kpRes = ptrarr(3)
solrotRes = ptrarr(1)
soldayRes = ptrarr(1)
sunspotRes = ptrarr(1)
symRes = ptrarr(5)
apRes[0] = ptr_new('*')
apRes[1] = ptr_new('3-hour')
apRes[2] = ptr_new('daily')
aeRes[0] = ptr_new('*')
for i=1,n_elements(aeRes)-1 do aeRes[i] = ptr_new('1-min')
cpRes[0] = ptr_new('daily')
c9Res[0] = ptr_new('daily')
dstRes[0] = ptr_new('1-hour')
f107Res[0] = ptr_new('daily')
kpRes[0] = ptr_new('*')
kpRes[1] = ptr_new('3-hour')
kpRes[2] = ptr_new('daily')
solrotRes[0] = ptr_new('daily')
soldayRes[0] = ptr_new('daily')
sunspotRes[0] = ptr_new('daily')
for i=0,n_elements(symRes)-1 do symRes[i] = ptr_new(['*', '1-min','5-min'])
resArray[0] = ptr_new(apRes)
resArray[1] = ptr_new(aeRes)
resArray[2] = ptr_new(cpRes)
resArray[3] = ptr_new(c9Res)
resArray[4] = ptr_new(dstRes)
resArray[5] = ptr_new(f107Res)
resArray[6] = ptr_new(kpRes)
resArray[7] = ptr_new(solrotRes)
resArray[8] = ptr_new(soldayRes)
resArray[9] = ptr_new(sunspotRes)
resArray[10] = ptr_new(symRes)
return, resArray
end
pro spd_ui_load_indices,tabid,loadedData,historyWin,statusBar,treeCopyPtr,timeRangeObj,callSequence,loadTree=loadTree,timeWidget=timeWidget
compile_opt idl2,hidden
getresourcepath,rpath
rightArrow = read_bmp(rpath + 'arrow_000_medium.bmp', /rgb)
trashcan = read_bmp(rpath + 'trashcan.bmp', /rgb)
spd_ui_match_background, tabid, rightArrow
spd_ui_match_background, tabid, trashcan
topBase = Widget_Base(tabid, /Row, /Align_Top, /Align_Left, YPad=1,event_pro='spd_ui_load_indices_event')
leftBase = widget_base(topBase,/col)
middleBase = widget_base(topBase,/col,/align_center)
rightBase = widget_base(topBase,/col)
leftLabel = widget_label(leftBase,value='Geomagnetic & Solar Indices Data:',/align_left)
rightLabel = widget_label(rightBase,value='Data Loaded:',/align_left)
selectionBase = widget_base(leftBase,/col,/frame)
treeBase = widget_base(rightBase,/col,/frame)
addButton = Widget_Button(middleBase, Value=rightArrow, /Bitmap, UValue='ADD', $
ToolTip='Load data selection')
minusButton = Widget_Button(middleBase, Value=trashcan, /Bitmap, $
Uvalue='DEL', $
ToolTip='Delete data selected in the list of loaded data')
loadTree = Obj_New('spd_ui_widget_tree', treeBase, 'LOADTREE', loadedData, $
XSize=400, YSize=425, mode=0, /multi,/showdatetime)
loadTree->update,from_copy=*treeCopyPtr
clearDataBase = widget_base(rightBase,/row,/align_center)
clearDataButton = widget_button(clearDataBase,value='Delete All Data',uvalue='CLEARDATA',/align_center,ToolTip='Deletes all loaded data')
timeWidget = spd_ui_time_widget(selectionBase,$
statusBar,$
historyWin,$
timeRangeObj=timeRangeObj,$
uvalue='TIME_WIDGET',$
uname='time_widget')
indexArrayValues = ['Ap', 'AE', 'Cp', 'C9', 'Dst', 'F10.7', 'Kp', 'Solar rotation #', 'Solar rotation day', 'Sunspot #', 'SYM/ASY']
paramArray = spd_ui_index_data_types()
ptrSourceLabels = spd_ui_index_source_data()
ptrindexResolutions = spd_ui_index_resolutions()
dataBase = widget_base(selectionBase,/row)
indexBase = widget_base(dataBase,/col)
indexLabel = widget_label(indexBase,value='Index: ')
indexList = widget_list(indexBase,$
value=indexArrayValues,$
uname='indexlist',$
uvalue='INDEXLIST',$
xsize=16,$
ysize=15)
widget_control, indexList, set_list_select = 0
clearindexButton = widget_button(indexBase,value='Clear Indices',uvalue='CLEARINDEX',ToolTip='Deselect all indices')
typeBase = widget_base(dataBase,/col)
typeLabel = widget_label(typeBase,value='Data Type:')
typeList = widget_list(typeBase,$
value=*paramArray[0],$
uname='datalist',$
uvalue='DATALIST',$
xsize=16,$
ysize=15)
clearTypeButton = widget_button(typeBase,value='Clear Data Type',uvalue='CLEARTYPE',ToolTip='Deselect all index types')
widget_control, typeList, set_list_select = 0
resBase = widget_base(dataBase,/col)
resLabel = widget_label(resBase,value='Resolution:')
resList = widget_list(resBase,$
value=*(*ptrindexResolutions[0])[0],$
uname='reslist',$
xsize=16,$
ysize=15)
clearResButton = widget_button(resBase,value='Clear Resolution',uvalue='CLEARRES',ToolTip='Deselect all resolutions')
dataSourceLabel1 = widget_label(leftBase, value=(*ptrSourceLabels[0])[0], uname='dataSource1', /align_left, /dynamic_resize)
dataSourceLabel2 = widget_label(leftBase, value=(*ptrSourceLabels[0])[1], uname='dataSource2', /align_left, /dynamic_resize)
state = {baseid:topBase,$
loadTree:loadTree,$
treeCopyPtr:treeCopyPtr,$
timeRangeObj:timeRangeObj,$
statusBar:statusBar,$
historyWin:historyWin,$
loadedData:loadedData,$
callSequence:callSequence,$
indexArray:indexArrayValues,$
typeArray:paramArray,$
dsourceLabels:ptrSourceLabels,$
ptrindexResolutions:ptrindexResolutions }
widget_control,topBase,set_uvalue=state
return
end