/*---------------------------------------------------------------------------- Program: igraph.scl Author: Robert Peszek DISCLAIMER: THE SCL PROGRAM AND THE FRAME ENTRY ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. RECIPIENTS ACKNOWLEDGE AND AGREE THAT NEITHER AUTHORS NOR SAS INSTITUTE SHALL BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING OUT OF THEIR USE OF THIS MATERIAL. IN ADDITION, SAS INSTITUTE AND AUTHORS WILL PROVIDE NO SUPPORT FOR THE MATERIALS CONTAINED HEREIN. Description: SCL source code for igraph.frame interactive graph software input: dataset work.g_list, sas datasets specified by ianno variable in work.g_list gseg entries specified by gout_nm variable in work.g_list window blocks: prev_pb : push button clicked event causes displaying next graph specified in work.g_list next_pb : push button clicked event causes displaying previous graph specified in work.g_list show_pb : push button and a char variable hides and displays interactive points graph : SAS/GRAPH output object displays gplot output specified by gout_nm variable in work.g_list graphic : GRAPHICS object liked to dataset specified by IANNO variable in work.g_list con_box : container box not referenced in SCL, allows graph and graphic to be siblings non-window variables: named as in G_LIST and IANNO datasets, p_selec, progexe, graph_no, y_var, x_var, clicked non-window blocks: open_ds : open datasets close_ds : close datasets ini_disp : initialize display settings selct_pt : executes on select point (on the graph) event mk_popup : executes on popup event submit : submits menu execution program displ1 : displays _msg_ and gets info about selected point ---------------------------------------------------------------------------*/ *-----------------------------------------------------------+ | macro initpop used to initialize interactive annotation | | variables exe1-exe9 and | | name_e1- name_e9 used in pop-up menu | +-----------------------------------------------------------; %macro INITPOP; %do i=1 %to 9; exe&i $40 name_e&i $40 %end; %mend INITPOP; init: *------------------------; * initialize variables ; *------------------------; length p_selec 8 clicked 8 desc_st $ 40 pnt_id $40 progexe $40 gout_nm $40 ianno $40 g_label $40 %initpop ; *----------------------------------------------------------------------; * initialize arrays for popup menu of sas programs for selected point ; *----------------------------------------------------------------------; array exeprog{9} exe1-exe9; array popname{9} name_e1-name_e9 *----------------------------------------------------------------------; * initialize graph_no so the display starts from 1-st ; * graph from g_list dataset ; *----------------------------------------------------------------------; graph_no=1; *------------------------------; * link block opening datasets ; *------------------------------; link open_ds; *----------------------------------------------; * link block initializing the display settings ; *----------------------------------------------; link ini_disp; return; main: return; term: *-----------------------------; * link close datasets block ; *-----------------------------; link close_ds; return; open_ds: *----------------------------------------------------; * this block opens datasets ; *----------------------------------------------------; *---------------------------------------------------------------; * open g_list ; *---------------------------------------------------------------; dsid1=open('WORK.G_LIST','i'); if dsid1 = 0 then _msg_='Error opening WORK.G_LIST'; call set(dsid1); *-----------------------------------------; * load g_list observation no. graph_no ; *-----------------------------------------; rc=fetchobs(dsid1,graph_no); *---------------------------------------------------------------; * hide up button if first graph from g_list, unhide otherwise ; *---------------------------------------------------------------; call notify('prev_pb', '_is_hidden_', rc); if graph_no = 1 and rc = 0 then call notify('prev_pb', '_hide_'); if graph_no > 1 and rc = 1 then call notify('prev_pb', '_unhide_'); *---------------------------------------------------------------; * hide down button if last graph from g_list, unhide otherwise; *---------------------------------------------------------------; graph_mx= attrn(dsid1, 'nobs'); call notify('next_pb', '_is_hidden_', rc); if graph_no = graph_mx and rc = 0 then call notify('next_pb', '_hide_'); if graph_no < graph_mx and rc = 1 then call notify('next_pb', '_unhide_'); *---------------------------------------; * specify IANNO and graph output name ; * for GRAPHIC and GRAPH objects ; *---------------------------------------; call notify('graphic','_set_dsname_',ianno); call notify('graph','_set_graph_',gout_nm); *---------------------------; * change window title bar ; *---------------------------; if g_label ne ' ' then call wname('Interactive Graph: '||g_label); *----------------------------------; * open dataset specified in IANNO ; *----------------------------------; dsid2=open(IANNO,'i'); if dsid2 = 0 then _msg_='Error opening'||IANNO||' specified as IANNO'; call set(dsid2); return; ini_disp: *-------------------------------------------------------; * this block initializes display settings ; *-------------------------------------------------------; call notify('graphic', '_set_color_','axis', 'white'); call notify ('graphic', '_set_max_', 'dep_axis' ,100); call notify ('graphic', '_set_min_', 'dep_axis' ,0); call notify ('graphic', '_set_max_', 'indep_axis' ,100); call notify ('graphic', '_set_min_', 'indep_axis' ,0); *----------------------------------------; * link show_pb label with show_pb = ' ' ; *----------------------------------------; link show_pb; *----------------------------------------; * modification for SAS 6.12 only ; *----------------------------------------; call notify('graphic', '_set_color_', 'backplane', 'transparent'); return; close_ds: *---------------------------------------------------; * this block closes datasets ; *---------------------------------------------------; rc=close(dsid1); rc=close(dsid2); return; show_pb: *-------------------------------------------------------------------; * block shows-hides interactive points ; * clicked push button event executes this block with ; * show_pb='Show' or show_pb='Hide' SCL links with show_pb= ' ' ; **------------------------------------------------------------------; if show_pb = 'Show' then do; call notify ('graphic', '_set_marker_', 13, 1); call notify ('graphic', '_set_color_', 'marker', 'green', 1); call notify('show_pb', '_set_label_', 'Hide'); end; else if show_pb in ('Hide', ' ') then do; call notify ('graphic', '_set_marker_', 11, 1); call notify ('graphic', '_set_color_', 'marker', 'black', 1); call notify('show_pb', '_set_label_', 'Show'); end; return; graphic: *-------------------------------------------------------------------; * runs GRAPHIC object events ; *-------------------------------------------------------------------; if _status_ = 'P' then link mk_popup; else if _status_ = ' ' then link selct_pt; return; selct_pt: *------------------------------------------------------; * block executes select event on GRAPHIC object ; * get coordinates of selected point ; *------------------------------------------------------; call notify('graphic', '_get_value_', depinfo); clicked=listlen(depinfo); if clicked > 0 then do; lclickx = winfo('xpixel'); lclicky = winfo('ypixel'); info= getniteml(depinfo, 'depvalue'); y_var= getitemn(info, 1); call notify('graphic', '_get_value_', indinfo); x_var= getnitemn(indinfo, 'indvalue'); *-------------------------------------------------------; * link block displaying info on clicked point as _msg_ ; *-------------------------------------------------------; link displ1; end; else _msg_='Try clicking on a point again'; return; submit: *--------------------------------------------------------; * submit Menu Exec Prgm, pass info about selected point ; *--------------------------------------------------------; submit continue; %let pnt_id = %str(&pnt_id); * clicked point = PNT_ID ; %let desc_st = %str(&desc_st); * short description ; %let graph_no = &graph_no; * graph number ; %let menu_no = &p_selec; * menu item no ; %include &progexe; endsubmit; return; displ1: *------------------------------------------------------; * this block displays info on clicked point as _MSG_ ; *------------------------------------------------------; rc=where(dsid2,'xval='|| x_var||' and yval='|| y_var); rc=fetch(dsid2); if rc ne 0 then _msg_= 'Error: see displ1 block'; else do; _msg_=desc_st; refresh; end; return; prev_pb: *-----------------------------------------------------; * block executed by Push Button clicked event ; * moves up on the graph list ; *-----------------------------------------------------; link close_ds; graph_no = graph_no -1; link open_ds; return; next_pb: *----------------------------------------------------; * block executed by Push Button clicked event ; * -moves down on the graph list ; *----------------------------------------------------; link close_ds; graph_no = graph_no +1; link open_ds; return; mk_popup: *---------------------------------------------------------------; * this block executes on GRAPHIC object popup event ; *---------------------------------------------------------------; *---------------------------------------------------------------; * check if an interactive point was selected ; *---------------------------------------------------------------; if clicked le 0 then do; _msg_ = 'Select an interactive point first'; return; end; *---------------------------------------------------------------; * check if right-click was on the selected point ; *---------------------------------------------------------------; rclickx= winfo('xpixel'); rclicky = winfo('ypixel'); if abs(rclickx - lclickx) > 10 or abs(rclicky - lclicky) > 10 then do; _msg_ = 'Right-click on the selected point'; return; end; *---------------------------------------------------------------; * refresh message line with info about the selected point ; *---------------------------------------------------------------; _msg_=desc_st; refresh; *---------------------------------------------------------------; * get the number of nonmissing popup names from the dataset ; *---------------------------------------------------------------; n_exe =0; do i=1 to dim(popname); if popname{i} ne ' ' then n_exe= i; end; if n_exe ne 0 then do; *-----------------------------; * initialize choice list ; *-----------------------------; choice=makelist(n_exe); *--------------------------------------; * place popname array on the list ; *--------------------------------------; do i=1 to n_exe; rc= setitemc(choice, popname{i}, i); end; * set selected item number to p_selec **; p_selec= popmenu(choice); if p_selec ne 0 then do; * set progexe as selected sas program **; progexe = exeprog{p_selec}; link submit; end; end; else _msg_ = 'Pop-up menu not available for this point'; return;