; split_window_panel_1.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) ; ; ; -------------------------------------------------------------------------- ; PROCEDURE split_window_panel_1_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 split_window_panel_1_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 split_window_panel_1_event ; -------------------------------------------------------------------------- ; PURPOSE: ; This procedure handles all the events that get generated within the ; split_window_panel_1. 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 split_window_panel_1_event, event COMMON COLORS, R_orig, G_orig, B_orig, R_curr, G_curr, B_curr COMMON VIEW_CIPS_SPLIT_WINDOW_1, split_window1_images, split_window1_tvs, $ is_surface_split_1, split1_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 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_split_1 eq 0 then begin for i=0, N_ELEMENTS(SPLIT_WINDOW1_IMAGES.THUMBNAILS)-1 do begin WIDGET_CONTROL, *(state.TVs[i]), GET_VALUE = TVID WSET, TVID SURFACE, *SPLIT_WINDOW1_IMAGES.THUMBNAILS[i], $ shade=bytscl(*SPLIT_WINDOW1_IMAGES.THUMBNAILS[i]), $ XSTYLE = 4, YSTYLE = 4, ZSTYLE = 4 endfor is_surface_split_1 = 1 endif else begin for i=0, N_ELEMENTS(SPLIT_WINDOW1_IMAGES.THUMBNAILS)-1 do begin WIDGET_CONTROL, *(state.TVs[i]), GET_VALUE = TVID WSET, TVID & TV, (*SPLIT_WINDOW1_IMAGES.THUMBNAILS[i] $ / split1_max) * 255 endfor is_surface_split_1 = 0 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) void = ITGetCurrent(tool=oTool) ; if in 1x1 view mode, set the window layout ; to a 2x2 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 le 1) and (cols le 1) then begin oView->GetProperty, DIMENSIONS=view_dims virt_width = view_dims[0]/2 help, virt_width virt_height = view_dims[1]/2 help, virt_height 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', 2) result = oTool->DoSetProperty(layout_param, 'VIEW_ROWS', 2) 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]) if is_surface_split_1 eq 1 then begin ; surface view view_ID = state.oTool->FindIdentifiers('*VIEW_1') oView = state.oTool->GetByIdentifier(view_ID) oView->SetCurrentZoom, 1.0 view_ID = state.oTool->FindIdentifiers('*VIEW_2') oView = state.oTool->GetByIdentifier(view_ID) oView->SetCurrentZoom, 1.0 view_ID = state.oTool->FindIdentifiers('*VIEW_3') oView = state.oTool->GetByIdentifier(view_ID) oView->SetCurrentZoom, 1.0 view_ID = state.oTool->FindIdentifiers('*VIEW_4') oView = state.oTool->GetByIdentifier(view_ID) oView->SetCurrentZoom, 1.0 ; VIEW_NUMBER 1 isurface, *(SPLIT_WINDOW1_IMAGES.view_1[uvalue.num-1].large_image),$ VIEW_NUMBER=1, RGB_TABLE=[[r_orig], [g_orig], [b_orig]], $ STYLE=2, SHADING=1, $ VIEW_TITLE=SPLIT_WINDOW1_IMAGES.view_1_title ; VIEW_NUMBER 2 isurface, *(SPLIT_WINDOW1_IMAGES.view_2[uvalue.num-1].large_image),$ VIEW_NUMBER=2, RGB_TABLE=[[r_orig], [g_orig], [b_orig]], $ STYLE=2, SHADING=1, $ VIEW_TITLE=SPLIT_WINDOW1_IMAGES.view_2_title ; VIEW_NUMBER 3 isurface, *(SPLIT_WINDOW1_IMAGES.view_3[uvalue.num-1].large_image),$ VIEW_NUMBER=3, RGB_TABLE=[[r_orig], [g_orig], [b_orig]], $ STYLE=2, SHADING=1, $ VIEW_TITLE=SPLIT_WINDOW1_IMAGES.view_3_title ; VIEW_NUMBER 4 isurface, *(SPLIT_WINDOW1_IMAGES.view_4[uvalue.num-1].large_image),$ VIEW_NUMBER=4, RGB_TABLE=[[r_orig], [g_orig], [b_orig]], $ STYLE=2, SHADING=1, $ VIEW_TITLE=SPLIT_WINDOW1_IMAGES.view_4_title endif else begin ; image view ; initialize the zoom factor view_ID = state.oTool->FindIdentifiers('*VIEW_1') oView = state.oTool->GetByIdentifier(view_ID) oView->GetProperty, DIMENSIONS=view_dims image_dims = size(*SPLIT_WINDOW1_IMAGES.view_1[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, zoom_factor ; VIEW_NUMBER 1 iimage, *(SPLIT_WINDOW1_IMAGES.view_1[uvalue.num-1]).large_image, $ VIEW_NUMBER=1, RGB_TABLE=[[r_orig], [g_orig], [b_orig]], $ STYLE=2, SHADING=1, IMAGE_LOCATION=[100, 100], $ VIEW_TITLE=SPLIT_WINDOW1_IMAGES.view_1_title ; VIEW_NUMBER 2 view_ID = state.oTool->FindIdentifiers('*VIEW_2') oView = state.oTool->GetByIdentifier(view_ID) oView->SetCurrentZoom, zoom_factor iimage, *(SPLIT_WINDOW1_IMAGES.view_2[uvalue.num-1].large_image), $ VIEW_NUMBER=2, RGB_TABLE=[[r_orig], [g_orig], [b_orig]], $ STYLE=2, SHADING=1, IMAGE_LOCATION=[100, 100], $ VIEW_TITLE=SPLIT_WINDOW1_IMAGES.view_2_title ; VIEW_NUMBER 3 view_ID = state.oTool->FindIdentifiers('*VIEW_3') oView = state.oTool->GetByIdentifier(view_ID) oView->SetCurrentZoom, zoom_factor iimage, *(SPLIT_WINDOW1_IMAGES.view_3[uvalue.num-1].large_image), $ VIEW_NUMBER=3, RGB_TABLE=[[r_orig], [g_orig], [b_orig]], $ STYLE=2, SHADING=1, IMAGE_LOCATION=[100, 100], $ VIEW_TITLE=SPLIT_WINDOW1_IMAGES.view_3_title ; VIEW_NUMBER 4 view_ID = state.oTool->FindIdentifiers('*VIEW_4') oView = state.oTool->GetByIdentifier(view_ID) oView->SetCurrentZoom, zoom_factor iimage, *(SPLIT_WINDOW1_IMAGES.view_4[uvalue.num-1].large_image), $ VIEW_NUMBER=4, RGB_TABLE=[[r_orig], [g_orig], [b_orig]], $ STYLE=2, SHADING=1, IMAGE_LOCATION=[100, 100], $ VIEW_TITLE=SPLIT_WINDOW1_IMAGES.view_4_title endelse ENDIF BREAK END ENDSWITCH END ; -------------------------------------------------------------------------- ; PROCEDURE init_split_window1_thumbs ; -------------------------------------------------------------------------- pro init_split_window1_thumbs COMMON VIEW_CIPS_SPLIT_WINDOW_1, split_window1_images, split_window1_tvs, $ is_surface_split_1, split1_max ; Get widget IDs for the draw widgets then output the thumbnails for i=0, N_ELEMENTS(split_window1_images.thumbnails)-1 do begin WIDGET_CONTROL, *split_window1_tvs[i], GET_VALUE = TVID WSET, TVID & TV, (*split_window1_images.thumbnails[i]/split1_max)*255 endfor WSET, 0 WDELETE end ; -------------------------------------------------------------------------- ; PROCEDURE split_window_1 ; -------------------------------------------------------------------------- ; 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 split_window_panel_1, wPanel, oUI COMMON VIEW_CIPS_SPLIT_WINDOW_1, split_window1_images, split_window1_tvs, $ is_surface_split_1, split1_max ; Name the panel WIDGET_CONTROL, wPanel, BASE_SET_TITLE = split_window1_images.panel_name ; Specify the event handler WIDGET_CONTROL, wPanel, EVENT_PRO = "split_window_panel_1_event" ; Register the panel with the UI object strObserverIdentifier = oUI->RegisterWidget(wPanel, "Panel", $ 'split_window_panel_1_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_split_1 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(split_window1_images.thumbnails) split_window1_tvs = ptrarr(num_thumbs, /allocate_heap) for i=0, num_thumbs-1 do begin dimensions = size(*SPLIT_WINDOW1_IMAGES.thumbnails[i], /DIMENSIONS) split_window1_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 = split_window1_images.view_1[i].info) void = widget_label(wBase, VALUE = "") endfor ; Create state structure in first child state = { oTool:oTool, $ oUI:oUI, $ wPanel:wPanel, $ wBase:wBase, $ TVs:split_window1_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 = 'SPLIT_PANEL1') ; Add the data object to the data manager oTool->AddByIdentifier, '/Data Manager', oData END