⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xxx_gui.pro

📁 IDL语言编写的用于天文自适应光学仿真的软件CAOS V6.0的第三部分。
💻 PRO
📖 第 1 页 / 共 2 页
字号:
      widget_control, event.top, /DESTROY      return   end       ; handle event from standard help button   'help': begin      widget_control, /HOURGLASS      spawn, !caos_env.browser+" "+(xxx_info()).help+"\#" $            +strupcase(state.par.module.mod_name)+"&"   end   ; handle event from standard restore button   'restore': begin      ; restore the desired parameter file      par = 0      title = "parameter file to restore"      restore, filename_gui(state.def_file,                          $                            title,                                   $                            GROUP_LEADER=event.top,                  $                            FILTER=state.par.module.mod_name+'*sav', $                            /NOEDIT,                                 $                            /MUST_EXIST,                             $                            /ALL_EVENTS                              )      ; update the current module number      par.module.n_module = state.par.module.n_module      ; set the default values for all the widgets      ;**      ;** as usual here, this is based on the present example...      ;** it must be adapted to the actual case of the module.      ;**      widget_control, state.id.choice,        SET_VALUE=par.choice      widget_control, state.id.choice0_param, SET_VALUE=par.choice0_param      widget_control, state.id.choice1_param, SET_VALUE=par.choice1_param      widget_control, state.id.choice1_type,  SET_DROPLIST_SELECT= $                                                 par.choice1_type      widget_control, state.id.time_integ,    SET_VALUE=par.time_integ      widget_control, state.id.time_delay,    SET_VALUE=par.time_delay      ; update the state structure      state.par = par   end   ; handle event of standard cancel button (exit without saving)   'cancel': begin      error = !caos_error.cancel      widget_control, event.top, /DESTROY      return   endendcase; reset the setting parameters statusxxx_gui_set, state; write the GUI state structurewidget_control, event.top, SET_UVALUE=statereturnend;**;** here is the actual GUI generation function xxx_gui;**;;;;;;;;;;;;;;;;;;;;;;;; GUI generation code ;;;;;;;;;;;;;;;;;;;;;;;;;function xxx_gui, n_module,  $                  proj_name, $                  GROUP_LEADER=group; error status from the event handler procedurecommon error_block, error; retrieve the module informationinfo = xxx_info(); check if a saved parameter file already exists for this module.; if it exists it is restored, otherwise the default parameter file is restored.sav_file = mk_par_name(info.mod_name, n_module, PROJ_NAME=proj_name)def_file = mk_par_name(info.mod_name, PACK_NAME=info.pack_name, /DEFAULT)par=0check_file = findfile(sav_file)if check_file[0] eq '' then begin   restore, def_file   par.module.n_module = n_module   if (par.module.mod_name ne info.mod_name) then      $      message, 'the default parameter file ('+def_file $              +') is from another module: please take the right one'   if (par.module.ver ne info.ver) then                $      message, 'the default parameter file ('+def_file $              +') is not compatible: please generate it again'   endif else begin   restore, sav_file   if (par.module.mod_name ne info.mod_name) then $      message, 'the parameter file '+sav_file     $              +' is from another module: please generate a new one'   if (par.module.ver ne info.ver) then begin      print, '************************************************************'      print, 'WARNING: the parameter file '+sav_file      print, 'is probably from an older version than '+info.pack_name+' !!'         print, 'You should possibly need to generate it again...'      print, '************************************************************'   endifendelse; build the widget id structure where all the needed (in xxx_gui_event); widget's id will be storedid = $   { $                     ; widget id structure   par_base        : 0L, $ ; parameter base id      choice       : 0L, $ ; choice bgroup id      choice0_base : 0L, $ ; choice 0 base id      choice0_param: 0L, $ ; choice 0 parameter field id      choice0_test : 0L, $ ; choice 0 test parameter field id      choice1_base : 0L, $ ; choice 1 base id      choice1_param: 0L, $ ; choice 1 parameter slider id      choice1_type : 0L, $ ; choice 1 type droplist id      tab_base     : 0L, $ ; table base id      tab_row_nb   : 0L, $ ; table number of row id      tab          : 0L, $ ; table id      sub_gui      : 0L, $ ; sub-gui call button id      graphic      : 0L, $ ; graphic id      time_base    : 0L, $ ; time evolution base id      time_integ   : 0L, $ ; time integration field id      time_delay   : 0L  $ ; time delay field id   }; build the state structure were par, id, sav_file and def_file will be stored; (and passed to xxx_gui_event).state = $   {    $                ; widget state structure   sav_file: sav_file, $ ; actual name of the file where save params   def_file: def_file, $ ; default name of the file where save params   id      : id,       $ ; widget id structure   par     : par       $ ; parameter structure   };**;** the following lines of code defines the whole GUI. it is based on two;** main sub-bases: the paramaters one, and the standard buttons one.;** both are mandatory (except for the time evolution management part of;** the parameters sub-base).;**; root base definitionmodal = n_elements(group) ne 0dummy = strupcase(info.mod_name)+' parameters setting GUI'root_base_id = widget_base(TITLE=dummy, MODAL=modal, /COL, GROUP_LEADER=group); set the status structurewidget_control, root_base_id, SET_UVALUE=state   ; parameters base   state.id.par_base = widget_base(root_base_id, FRAME=10, ROW=2)   dummy = widget_label(state.id.par_base, VALUE='parameters', /FRAME)   par_base_id = widget_base(state.id.par_base, /ROW)   ;**   ;** in this example there are two parameters sub-bases (choice_base_id   ;** and state.id.time_base) that are distibuted in two colums (keyword /ROW   ;** above).   ;**      ; parameters sub-bases:      ; example: choice between two cases/methods/algorithms/etc.      choice_base_id = widget_base(par_base_id, $                                   /FRAME,      $                                   ROW=4        )         ; label widget for the base 'choice_base_id'         dummy = widget_label(choice_base_id,                               $                              VALUE=                                        $                    'here are a choice to make and some parameters to set', $                              /FRAME                                        )         ; example of an exclusive bgroup         state.id.choice = cw_bgroup(choice_base_id,                $                                     label_left = 'which choice ?', $                                     ['choice 0','choice 1'],       $                                     COLUMN=2,                      $                                     SET_VALUE=state.par.choice,    $                                     /EXCLUSIVE,                    $                                     UVALUE='choice'                )         ; sub-base for choice0         state.id.choice0_base = widget_base(choice_base_id, $                                             COL=3           )            ; example of an editable integer field            state.id.choice0_param = cw_field(state.id.choice0_base,          $                                              TITLE='choice 0 param. [unit]', $                                              /COLUMN,                        $                                              VALUE=state.par.choice0_param,  $                                              /INTEGER,                       $                                              UVALUE="choice0_param",         $                                              /ALL_EVENTS                     )            ; example of a non-editable integer field            state.id.choice0_test = cw_field(state.id.choice0_base,            $                                            TITLE='(twice choice 0 param is)', $                                            /COLUMN,                           $                                            VALUE=2*state.par.choice0_param,   $                                            /INTEGER,                          $                                            /NOEDIT                            )         ; choice 1 sub-base         state.id.choice1_base = widget_base(choice_base_id, $                                             COL=2           )            ; example of an editable float field with a slider            state.id.choice1_param = cw_fslider(state.id.choice1_base,         $                                                TITLE='choice 1 parameter',    $                                                VALUE=state.par.choice1_param, $                                                MAXIMUM=1, SCROLL=.05,         $                                                UVALUE="choice1_param",        $                                                /EDIT,                         $                                                /DRAG                          )            ; array for droplist            dummy = $               [    $               'first  type', $               'second type', $               'third  type', $               'fourth type', $               'fifth  type', $               'sixth  type'  $               ]            ; example of a droplist widget            state.id.choice1_type = widget_droplist(state.id.choice1_base,   $                                                    TITLE='choice 1 type: ', $                                                    VALUE=dummy,             $                                                    UVALUE='choice1_type'    )            ; set droplist default value            widget_control, state.id.choice1_type, $                            SET_DROPLIST_SELECT=state.par.choice1_type      ; time evolution      state.id.time_base = widget_base(par_base_id, $                                       /FRAME,      $                                       ROW=3        )         ; label widget for the base 'state.id.time_base'         dummy = widget_label(state.id.time_base,VALUE='time evolution',/FRAME)         ; integration time widget         state.id.time_integ = cw_field(state.id.time_base,                   $                                        TITLE='integration [base-time unit]', $                                        /COLUMN,                              $                                        VALUE=state.par.time_integ,           $                                        /INTEGER,                             $                                        UVALUE='time_integ',                  $                                        /ALL_EVENTS                           )         ; delay time widget         state.id.time_delay = cw_field(state.id.time_base,                   $                                        TITLE='delay [base-time unit]',       $                                        /COLUMN,                              $                                        VALUE=state.par.time_delay,           $                                        /INTEGER,                             $                                        UVALUE='time_delay',                  $                                        /ALL_EVENTS                           )   ;**   ;** the following lines of code deal with the standard buttons.   ;**   ; button base for control buttons (standard buttons)   btn_base_id = widget_base(root_base_id, FRAME=10, /ROW)      dummy = widget_button(btn_base_id, VALUE="HELP", UVALUE="help")      cancel_id = widget_button(btn_base_id, VALUE="CANCEL", UVALUE="cancel")      if modal then widget_control, cancel_id, /CANCEL_BUTTON      dummy = widget_button(btn_base_id, VALUE="RESTORE PARAMETERS", $                            UVALUE="restore"                         )      save_id = widget_button(btn_base_id, VALUE="SAVE PARAMETERS",  $                              UVALUE="save"                          )      if modal then widget_control, save_id, /DEFAULT_BUTTON;**;** eliminate the following line if the function xxx_gui_set is not required;**; initialize all the sensitive statesxxx_gui_set, state;**;** do not modify the following lines (except for changing xxx onto the;** module three-characters name).;**; save the state structure of the GUI in the top base uvaluewidget_control, root_base_id, SET_UVALUE=state; draw the GUIwidget_control, root_base_id, /REALIZE; launch xmanagerxmanager, 'xxx_gui', root_base_id, GROUP_LEADER=group; back to the main calling programreturn, errorend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -