PRO spd_ui_rubber_band_box, info
Catch, theError
IF theError NE 0 THEN BEGIN
Catch, /Cancel
ok = Error_Message(Traceback=1)
RETURN
ENDIF
rubberBandXOnlyId = widget_info(info.master,find_by_uname='RUBBERBANDX')
rubberBandStruc = info.drawObject->GetRubberBandPos(xonly=widget_info(rubberBandXOnlyId,/button_set))
IF Is_Num(rubberBandStruc) EQ 1 THEN BEGIN
info.statusBar->update, 'Invalid rubber band box position information. Unable to complete rubber band operation.'
info.historyWin->update, 'Invalid rubber band box position information. Unable to complete rubber band operation.'
RETURN
ENDIF ELSE BEGIN
activeWindow=info.windowStorage->GetActive()
activeWindow->getProperty,locked=locked
newLocked = -1
newPanels=Obj_New('IDL_CONTAINER')
numNewPanels=N_Elements(rubberBandStruc)
panelId=0
IF N_Elements(activeWindow) GT 0 && Obj_Valid(activeWindow[0]) THEN BEGIN
activeWindow[0]->GetProperty, Panels=panels
IF Obj_Valid(panels) THEN BEGIN
panelObjs = panels->Get(/all)
IF NOT Is_Num(panelObjs) THEN BEGIN
newPanelList = panelObjs[rubberBandStruc[*].idx]
for i = 0,numNewPanels-1 do begin
if locked eq rubberBandStruc[i].idx then begin
newLocked = i
endif
newPanel=newPanelList[i]->Copy()
newPanel->GetProperty, XAxis=xaxis,yaxis=yaxis
xAxis->setProperty, rangeOption=2
xaxis->UpdateRange, rubberBandStruc[i].xRange
if ~widget_info(rubberBandXOnlyId,/button_set) then begin
yAxis->setProperty, rangeOption=2
yaxis->UpdateRange, rubberBandStruc[i].yRange
endif
newPanel->SetProperty, Id=panelId, XAxis=xaxis, YAxis=yaxis
newPanels->Add, newPanel
panelId=panelId+1
endfor
if locked ne -1 && newlocked eq -1 then begin
newLocked = n_elements(newPanels)-1
endif
ENDIF ELSE BEGIN
info.statusBar->update, 'No panels retrieved. Unable to complete rubber band operation.'
info.historyWin->update, 'No panels retrieved. Unable to complete rubber band operation.'
RETURN
ENDELSE
ENDIF ELSE BEGIN
info.statusBar->update, 'Unable to retrieve panel information. Rubber band operation cancelled.'
info.historyWin->update, 'Unable to retrieve panel information. Rubber band operation cancelled.'
RETURN
ENDELSE
ENDIF ELSE BEGIN
info.statusBar->update, 'Unable to retrieve active window information. Rubber band operation cancelled.'
info.historyWin->update, 'Unable to retrieve active window information. Rubber band operation cancelled.'
RETURN
ENDELSE
activeWindow->GetProperty, Settings=settings, Tracking=tracking, Locked=oldLocked
result=info.windowStorage->Add(Settings=settings, Tracking=tracking, Panels=newPanels, $
IsActive=1, Locked=newlocked)
activeWindow=info.windowStorage->GetActive()
activeWindow[0]->GetProperty, Name=name
activeWindow[0]->RePack
info.windowMenus->Add, name
info.windowMenus->Update, info.windowStorage
info.drawObject->update,info.windowStorage, info.loadedData
info.drawObject->draw
info.statusBar->update, 'Rubber band operation successful. New page created.'
info.historyWin->update, 'Rubber band operation successful. New page created.'
ENDELSE
END