; panel_2.pro ; Created by: James Everton ; ; PURPOSE: ; This file creates the panel used to select the images in view_cips_images. ; It also creates the event handler that is used when the buttons and ; thumbnail images are clicked. ; ; BACKGROUND: ; This program was written under instruction of Lon Riesberg ; ; ALGORITHM: ; IDL widgets combined with the iTools environment were used in creating ; this program. ; ; REFERENCES: ; ; NOTES: ; ; CONSTRAINTS: ; ; OTHER SERVERS/MODULES USED: ; ; RELATED MODULES / CLASSES: ; view_cips_images.pro contains 'view_cips_images' procedure ; ; SUPPORTING DATABASE TABLES OR FILES: ; ; USAGE EXAMPLE: ; (The file view_cips_images.pro contains the calling routine) ; ; VERSION: ; $Revision: 2.1 $ $Date: 2006-01-31 $ ; ; -------------------------------------------------------------------------- ; PROCEDURE panel_2_callback ; -------------------------------------------------------------------------- ; PURPOSE: ; This procedure is called whenever a registered component generates a ; message. In this UI panel, there are no registered components, so this ; procedure is here simply for syntactical reasons. If components get ; registered later, this is where messages will be handled. ; ; INPUT PARAMETERS: (Automatically sent by the iTools environment) ; wPanel - the widget id of the panel widget ; strID - string identifying the source of the message ; messageIn - string that uniquely identifies the message being sent. ; component - a value that is associated with the message being sent. ; PRO panel_2_callback, wPanel, strID, messageIn, component ; Make sure we have a valid widget ID IF ~WIDGET_INFO(wPanel, /VALID) THEN RETURN ; Retrieve the widget ID of the first child widget of the UI panel wChild = WIDGET_INFO(wPanel, /CHILD) ; Retrieve the state structure from the user value of the first child widget WIDGET_CONTROL, wChild, GET_UVALUE = state END ; -------------------------------------------------------------------------- ; PROCEDURE panel_2_event ; -------------------------------------------------------------------------- ; PURPOSE: ; This procedure handles all the events that get generated within the ; panel_2. When the user clicks on the 'Click to load images' ; button, the images in the panel get loaded in. When the user clicks on ; any of the images, the full size image associated with the thumbnail ; is then loaded into the main screen of the iTool. ; ; INPUT PARAMETERS: (Automatically sent by the iTools environment) ; event - a widget event generated by a widget ; PRO panel_2_event, event COMMON COLORS, R_orig, G_orig, B_orig, R_curr, G_curr, B_curr COMMON VIEW_CIPS_IMAGES_2, panel_two, panel2_tvs, is_surface_2, panel2_max ; Retrieve widget ID of first child widget of the UI panel wChild = WIDGET_INFO(event.handler, /CHILD) ; Retrieve the state structure from the user value of the first child widget. WIDGET_CONTROL, wChild, GET_UVALUE = state ; Retrieve the user value of the widget that generated the event WIDGET_CONTROL, event.id, GET_UVALUE = uvalue ; Get the parameter set that contains the images oParamSet = state.oTool->GetByIdentifier("/DATA MANAGER/CIPS PARAMETERS") ; Get the main window in which to place the new image idImage = state.oTool->FindIdentifiers('*IMAGE', /VISUALIZATIONS) oImage = state.oTool->GetByIdentifier(idImage) SWITCH STRUPCASE(uvalue.id) OF ;--- If the user decides to switch from image to surface, or vice versa 'SWITCH': BEGIN ; Get widget IDs for the draw widgets then output the thumbnails if is_surface_2 eq 0 then begin for i=0, N_ELEMENTS(panel_two.images)-1 do begin WIDGET_CONTROL, *(panel2_TVs[i]), GET_VALUE = TVID WSET, TVID SURFACE, *panel_two.images[i].thumbnail, $ shade=bytscl(*panel_two.images[i].thumbnail), $ XSTYLE = 4, YSTYLE = 4, ZSTYLE = 4 endfor is_surface_2 = 1 WIDGET_CONTROL, state.wSwitchBtn, set_value='Image View' endif else begin for i=0, N_ELEMENTS(panel_two.images)-1 do begin WIDGET_CONTROL, *(panel2_TVs[i]), GET_VALUE = TVID WSET, TVID & TV, (*panel_two.images[i].thumbnail/panel2_max)*255 endfor is_surface_2 = 0 WIDGET_CONTROL, state.wSwitchBtn, set_value='Surface View' endelse WSET, 0 WDELETE BREAK END ;--- If the user clicks on one of the draw_widgets... 'TV': BEGIN ; If event is a mouse-button-down event... IF event.press eq 1 THEN BEGIN ; Get the graphics view from the data manager view_ID = state.oTool->FindIdentifiers('*VIEW_1') oView = state.oTool->GetByIdentifier(view_ID) oView->Select, 1 void = ITGetCurrent(tool=oTool) ; Delete all images/surface plots in the current window result = oTool->FindIdentifiers('*VISUALIZATION LAYER/DATA SPACE') if result[0] ne '' then $ for i=0, N_ELEMENTS(result)-1 do $ success = oTool->RemoveByIdentifier(result[i]) ; if in 2x2 view mode, set the window layout ; to a 1x1 gridded window layout_param = oTool->FindIdentifiers('*layout*') layout_obj = oTool->GetByIdentifier(layout_param) layout_props = layout_obj->QueryProperty() layout_obj->GetProperty, VIEW_COLUMNS=cols layout_obj->GetProperty, VIEW_ROWS=rows if (rows ge 2) or (cols ge 2) then begin oView->GetProperty, DIMENSIONS=view_dims virt_width = view_dims[0] * rows virt_height = view_dims[1] * cols result = oTool->DoSetProperty(layout_param, 'SHOW_EXECUTION_UI', 0) result = oTool->DoSetProperty(layout_param, 'LAYOUT_INDEX', 1) result = oTool->DoSetProperty(layout_param, 'VIRTUAL_WIDTH', $ virt_width) result = oTool->DoSetProperty(layout_param, 'VIRTUAL_HEIGHT', $ virt_height) result = oTool->DoSetProperty(layout_param, 'VIEW_COLUMNS', 1) result = oTool->DoSetProperty(layout_param, 'VIEW_ROWS', 1) result = oTool->DoSetProperty(layout_param, 'AUTO_RESIZE', 0) result = oTool->DoAction(layout_param) oTool->CommitActions ;itpropertyreport, oTool, layout_param, /value endif ; Clear the title views result = oTool->FindIdentifiers('*ANNOTATION LAYER/*') if result[0] ne '' then $ for i=0, N_ELEMENTS(result)-1 do $ success = oTool->RemoveByIdentifier(result[i]) ; Send the large image into the main viewspace of the iTool ;result=oImage->SetData(oParam,PARAMETER_NAME="Imagepixels") if is_surface_2 eq 1 then begin oView->SetCurrentZoom, 1.0 isurface, *panel_two.images[uvalue.num-1].large_image, $ RGB_TABLE=[r_orig[128], g_orig[128], b_orig[128]], $ VIEW_NUMBER=1, STYLE=2, SHADING=1, $ VIEW_TITLE=panel_two.images[uvalue.num-1].info endif else begin ; Bring the new image into the main view iimage, *panel_two.images[uvalue.num-1].large_image, $ VIEW_NUMBER=1, RGB_TABLE=[[r_orig], [g_orig], [b_orig]], $ VIEW_TITLE=panel_two.images[uvalue.num-1].info ; Get the zoom factor and set it oView->GetProperty, DIMENSIONS=view_dims image_dims = size(*panel_two.images[uvalue.num-1].large_image, $ /DIMENSIONS) x_zoom = (view_dims[0] / (image_dims[0]+100)) y_zoom = (view_dims[1] / (image_dims[1]+100)) if x_zoom lt y_zoom then zoom_factor = x_zoom $ else zoom_factor = y_zoom if zoom_factor gt 4.0 then zoom_factor = 4.0 oView->SetCurrentZoom, 1.0 oView->SetCurrentZoom, zoom_factor endelse ENDIF BREAK END ENDSWITCH END ; -------------------------------------------------------------------------- ; PROCEDURE init_thumbs_2 ; -------------------------------------------------------------------------- pro init_thumbs_2 COMMON VIEW_CIPS_IMAGES_2, panel_two, panel2_tvs, is_surface_2, panel2_max ; Get widget IDs for the draw widgets then output the thumbnails if is_surface_2 eq 1 then begin for i=0, N_ELEMENTS(panel_two.images)-1 do begin WIDGET_CONTROL, *panel2_TVs[i], GET_VALUE = TVID WSET, TVID SURFACE, *panel_two.images[i].thumbnail, $ shade=bytscl(*panel_two.images[i].thumbnail), $ XSTYLE = 4, YSTYLE = 4, ZSTYLE = 4 endfor endif else begin for i=0, N_ELEMENTS(panel_two.images)-1 do begin WIDGET_CONTROL, *panel2_TVs[i], GET_VALUE = TVID WSET, TVID & TV, (*panel_two.images[i].thumbnail/panel2_max)*255 endfor endelse WSET, 0 WDELETE end ; -------------------------------------------------------------------------- ; PROCEDURE panel_2 ; -------------------------------------------------------------------------- ; PURPOSE: ; This procedure creates an interface panel for the 'view_cips_images' ; function. In the panel, there is a button that loads in all the panel ; images, followed by a list of thumbnail pictures and their titles. ; INPUT PARAMETERS: ; ; OUTPUT PARAMETERS: ; NONE ; ; RETURN VALUE: ; ; KEYWORD ARGUMENTS: ; ; NOTES: ; PRO panel_2, wPanel, oUI COMMON VIEW_CIPS_IMAGES_2, panel_two, panel2_tvs, is_surface_2, panel2_max ; Name the panel WIDGET_CONTROL, wPanel, BASE_SET_TITLE = panel_two.panel_name ; Specify the event handler WIDGET_CONTROL, wPanel, EVENT_PRO = "panel_2_event" ; Register the panel with the UI object strObserverIdentifier = oUI->RegisterWidget(wPanel, "Panel", $ 'panel_2_callback') ; Register to receive selection events on visualizations oUI->AddOnNotifyObserver, strObserverIdentifier, 'Visualization' ; Get reference to current iTool oTool = oUI->GetTool() ; Create base widget wBase = WIDGET_BASE(wPanel, /COLUMN, SPACE = 5, /ALIGN_CENTER) ;; Create panel contents: if is_surface_2 eq 1 then $ wSwitchBtn = widget_button(wBase, VALUE='Image View', XSIZE=100, $ UVALUE={id:'switch'}, /ALIGN_CENTER) $ else $ wSwitchBtn = widget_button(wBase, VALUE='Surface View', XSIZE=100, $ UVALUE={id:'switch'}, /ALIGN_CENTER) ; Create an array of pointers to all the draw widgets in the panel num_thumbs = N_ELEMENTS(panel_two.images) panel2_TVs = ptrarr(num_thumbs, /allocate_heap) for i=0, num_thumbs-1 do begin dimensions = size(*panel_two.images[i].thumbnail, /DIMENSIONS) panel2_TVs[i] = ptr_new(widget_draw(wBase, xsize=dimensions[0], $ ysize=dimensions[1], /BUTTON_EVENTS, RETAIN=2, $ /ALIGN_CENTER, UVALUE = {id:'TV', num:i+1})) void = widget_label(wBase, VALUE = panel_two.images[i].info) void = widget_label(wBase, VALUE = "") endfor ; Create state structure in first child state = { oTool:oTool, $ oUI:oUI, $ wPanel:wPanel, $ wBase:wBase, $ wSwitchBtn:wSwitchBtn, $ TVs:panel2_TVs $ } wChild = WIDGET_INFO(wPanel, /CHILD) IF wChild NE 0 THEN $ WIDGET_CONTROL, wChild, SET_UVALUE = state, /NO_COPY ; Add the wPanel object to the data manager ; Create the IDLitDataObject oPanel = OBJ_NEW('IDLitData', wPanel, IDENTIFIER = 'PANEL2') ; Add the data object to the data manager oTool->AddByIdentifier, '/Data Manager', oData END