#pragma rtGlobals=3 // Use modern global access method and strict wave access. #pragma version = 2.2013.05.04 //*****************************************************************************************************************// //***** JTG_ExperimentPreview *****// //*****************************************************************************************************************// // 2013/04/12 // // --Menu items appear under the Experiment Preview item added to the main File Menu. // // --"Save Preview" will copy open graph windows to a notebook; notebook will be named after // // the experiment and saved in the same directory as the experiment. // // --"View Preview" presents the user with a panel where notebooks residing on disk can be // // quickly viewed. // // 2013/04/16 // // --Added NBP_Panel_bpOpenExperiment to open the experiment file linked to the currently // // selected notebook. Not yet functional. // // 2013/04/17 // // --Used Execute Que and LOADFILE command in NBP_Panel_bpOpenExperiment to open an // // existing experiment. Before the current experiment is closed, there is a dialog asking if it // // should be saved. // // 2013/04/19 // // --Finished modifying NBP_Panel_bpOpenExperiment so that experiment is saved or not based // // on preference stated in ckbSaveExpt. If the box is checked, the experiment is saved // // regardless of whether or not it has been changed. The experiment is saved with // // "SaveExperiment". If the experiment has been saved previously, this will overwrite the // // existing file; if it has not been saved previously, a standard save file dialog will be presented. // // --Just prior to opening the selected experiment, "Execute/P "NEWEXPERIMENT " is // // executed to suppress a save file dialog in the event the experiment has changed and the // // Save Current Expt check box is unchecked. // // 2013/04/21 // // --Added code to NBP_Panel_GetFileList to filter file list based on contents of svFilter setvar. // // Applies filter when the setvar is exited; no filtering when svFilter = "". // // --Notebook Filter String setvariable is active, can be used to filter list of files that appear in the // // listbox. Filter is incorporated into NBP_Panel_GetFileList as part of the list modifying code. // // and operates when that function is called. This happens when the panel is created, path is // // changed or when filter is changed. NBP_Panel_GetFileList is the proc for this set var; when // // the focus is moved from filter setvar the procedure is run. Uses ListMatch function to filter // // the file list, so can use "!" and "*" wildcards. // // --Began to work on help file. This is in the form of a function (NB_Help) that creates a // // notebook containing info about the package. Added item to "Experiment Preview" menu to // // open the help notebook. // // --Began working on giving more flexibility to Save. There two steps: // // --First, added function parameter "vWinType" to NBP_Save to specify the type of windows to // // include in the preview notebook; follows form of WinList's WIN: optional parameter. // // --Second, added tabs to panel in NBP_Panel_Create function (at this point it's called // // NBP_Panel_CreateWithTabs), one for Save and one for View. Added function // // NBP_Panel_TabProc to handle showing/hiding tabs. So far there is nothing on the Save Tab, // // but it should hold check boxes for the selecting the various windows that could be added to // // a notebook. // // --Added string constant to ksNoteBookWindowName to hold name of notebook subwindow // // --Procedure file version is kept in package folder as sNBP_Version (for possible future use). // // 2013/04/28 // // --Added controls to Save Tab: Graph, Table & Layout checkboxes and Save Preview button. // // --Completed Save Tab; permits selecting graphs, tables and layouts. This could be extended // // to other window types. // // 2013/04/29 // // --Added NBP_Panel_bpSavePreview to respond to Save Preview button on Save Tab. This // // function gets state of checkboxes and then calls NBP_Save with a coded list of window // // types to add to the preview. // // --NBP_Panel_TabProc Resizes panel depending on the active tab. // // 2013/04/30 // // --Adding ability to copy panels, XOP windows and Notebooks to preview. Added check boxes // // for these to the Save Tab. // // --Added string constant ksPanelName to hold base name for panel. // // --Completed project to select types of windows to save by the Save tab. // // --Looking into saving checkbox state using WaveMetrics method to save preferences. // // --Added four new constants to support saving preferences. // // --Added the following functions to support preferences: Pref_LoadPackagePrefs, // // Pref_SavePackagePrefs, Pref_KillPackagePrefs, Pref_DefaultPackageStruct, and // // NBP_Panel_ckbProc. // // --Added functions Pref_DecodeText & Pref_EncodeText to convert disk path from text to // // ASCII numeric code so that it can be saved with other preferences. Uses uchar array. // // max size of the array is [400], thus the path is limited to 400 characters. This could be // // extended by using a 16 or 32 bit integer type an some additional encoding to save a // // character in each 8 bit part of the total 16 or 32 bits available. Each of these types is also // // limited to 400 array members. // --Completed saving preferences project. The state of the checkboxes is saved when they are // // changed as is the current path. // // --Added function NBP_SaveWithDefaults to save the preview using the default or preference // // window type selections. Modified the menu items so that there is a Save with Defaults item // // that calls NBP_SaveWithDefaults. // // --Working on help notebook. // // 2013/05/04 // // --Completed the help notebook. // //*****************************************************************************************************************// //*****************************************************************************************************************// //***** To Do *****// //*****************************************************************************************************************// // -- // //*****************************************************************************************************************// //***** Other Ideas *****// //*****************************************************************************************************************// // -- // //*****************************************************************************************************************// //***** Completed *****// //*****************************************************************************************************************// // 2013/04/19 // // -- Button to open experiment file associated (by name) with the currently viewed notebook. // // --Add checkbox/radio buttons to automatically save or not save current experiment when the // // selected one is opened. // // 2013/04/21 // // --Add set variable to enter match string to limit list of notebooks shown in listbox. // // --Store procedure file version in package folder for possible future use. // // 2013/04/29 // // --Add panel for Save function. This could have checkboxes to select items (graphs, tables, // // layouts, etc. to save in notebook. // // 2013/04/30 // // -- Save a default Symbolic Path for the location of preview notebooks in the user's Igor // // preferences folder. The default could be the last used directory for viewing previews. // // --Save state of checkboxes on Save tab. // // --Check effect of setting a ruler or page width in the notebook save function. There is some // // variation in size of the text when displaying *No Notebook Selected* message in the // // notebook window when the current listbox selection is "". This may be due to changes in // // size or width of the notebook page. Didn't mess with the ruler; font size of "No Notebook // // Selected" message doesn't seem to be a problem. // //*****************************************************************************************************************// //***** Menus, Constants and Structures *****// //*****************************************************************************************************************// Menu "File" Submenu "Experiment Preview" // "Save Graphs and Tables",/Q, NBP_Save(3) "Save with Defaults",/Q, NBP_SaveWithDefaults() "Save Preview Panel",/Q, NBP_Panel_CreateWithTabs(0) "View Preview Panel",/Q, NBP_Panel_CreateWithTabs(1) "Help",/Q, NBP_Help() End End //Igor datafolder path used for package directory. Directory will be specific to each GUI panel. //Multiple panels can be in use at the same time without interfering with one another. Static StrConstant ksDFPath = "root:Packages:JTG:ExperimentPreview:" //version pragma is not easily accessed; //this constant helps with that but must be kept synchronized with it Static StrConstant ksVersion = "2.2013.05.04" //Path to default disk folder that provides list of files. It is suggested that the path expression use the //Macintosh file system convention of employing a colon to separate elements in a file path. For example: //The default path shown here points to the root directory on drive C. //Future work could involve saving the last used directory to the user's Igor preferences folder Static StrConstant ksDefaultDataPath = "C:users:grothaus.jt:" //Variable to control types of files appearing in file list box. Set to "????" for any file type or limit with //extension including the preceeding "." as in ".dat" for files with a "dat" extension. Here we want to //fine Igor formatted or unformatted notebook files. Static StrConstant ksFileTypeOrExtension = "WMT0" //Variable for start of the symbolic path name. Putting it here so it's not burried in the code. Static StrConstant ksSymbolicPathNameStart = "NBP_Path_" //Name for notebook subwindow Static StrConstant ksNoteBookWindowName = "#NB0" //Base name for panel Static StrConstant ksPanelName = "NBP_Panel" //Constants for saving preferences //Preference file version Static Constant kvPrefsVersion = 100 //package name Static StrConstant ksPackageName = "JTG_ExperimentPreview" //preferences file name Static StrConstant ksPreferencesFileName = "NBP_PanelPreferences.bin" //The recordID is a unique number identifying a record within the preference file. Static Constant kvPrefsRecordID = 0 Structure strJTG_ExperimentPreviewPrefs uint32 version // Preferences structure version number. 100 means 1.00. uchar vckbGraphState uchar vckbTableState uchar vckbLayoutState uchar vckbPanelState uchar vckbXOPwindowState uchar vckbNotebookState uchar vDefaultPath [400] //path EndStructure //*****************************************************************************************************************// //***** End of Constants and Structures *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_Help *****// //*****************************************************************************************************************// // 2013/04/21 // // --Displays notebook window with help info. // // --Proc Pictures of the Preview panel are displayed in the notebook. They are saved in this // // procedure and are enclosed within the NBP_Help top and bottom comments along with the // // function used to write the notebook. // // 2013/05/04 // // --Completed the help notebook. // // --Fudged the display of the Proc Pictures showing Preview panel tabs by displaying using // // notebook actions. Couldn't find another way and I want to save the pictures in this // // procedure. This in not so bad as the pictures can be made "live" so that clicking on them // // will open the Preview panel with the selected tab active. Added another action to display // // Igor help file for the stringmatch function to provide info on wildcards used for the notebook // // filter string. // // --Notebook is hidden while it is being created, then it is made visible and displayed showing // // beginning of the notebook. // //*****************************************************************************************************************// // --Called by: "Help" menu item // // --Calls: none // //*****************************************************************************************************************// Function NBP_Help() String nb = "NBP_HelpNotebook" nb = UniqueName(nb, 10, 0) //Create new notebook with unique name. //K=1 causes window to be killed without warning when it is closed. //V=0, create & fill notebook while it is hidden, unhide when it is complete NewNotebook/N=$nb/F=1/V=0/K=1/W=(244.5,29,867,494) Notebook $nb defaultTab=36, statusWidth=252 Notebook $nb showRuler=1, rulerUnits=1, updating={1, 1} Notebook $nb newRuler=Normal, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={}, rulerDefaults={"Arial",10,0,(0,0,0)} Notebook $nb newRuler=Title, justification=1, margins={0,0,540}, spacing={0,0,0}, tabs={}, rulerDefaults={"Arial",18,0,(0,0,0)} Notebook $nb newRuler=Topic, justification=0, margins={0,0,540}, spacing={0,0,0}, tabs={}, rulerDefaults={"Arial",16,5,(0,0,0)} Notebook $nb newRuler=TopicBody, justification=0, margins={18,18,540}, spacing={0,0,0}, tabs={}, rulerDefaults={"Arial",10,0,(0,0,0)} Notebook $nb newRuler=STHeading, justification=0, margins={18,18,540}, spacing={0,0,0}, tabs={}, rulerDefaults={"Arial",12,5,(0,0,0)} Notebook $nb newRuler=STBody, justification=0, margins={36,36,540}, spacing={0,0,0}, tabs={}, rulerDefaults={"Arial",10,0,(0,0,0)} Notebook $nb newRuler=SSTHeading, justification=0, margins={36,36,540}, spacing={0,0,0}, tabs={}, rulerDefaults={"Arial",10,4,(0,0,0)} Notebook $nb newRuler=SSTBody, justification=0, margins={54,54,540}, spacing={0,0,0}, tabs={}, rulerDefaults={"Arial",10,0,(0,0,0)} Notebook $nb ruler=Title, text="JTG_ExperimentPreview.ipf\r" //Overview Notebook $nb ruler=Topic, text="Overview\r" Notebook $nb ruler=TopicBody, text="\r" Notebook $nb text="The purpose of this package is to permit the easy previewing of Experiment files. This is done by savin" Notebook $nb text="g open graphs in the current experiment to a notebook file saved to disk in the same directory as the ex" Notebook $nb text="periment. The notebook file is named after the experiment file name. Subsequently, experiment files ca" Notebook $nb text="n be previewed by browsing through notebook files using a panel that lets the user quickly select a note" Notebook $nb text="book file and view its contents. The experiment file can be opened from the same panel after selecting " Notebook $nb text="and viewing it corresponding notebook summary.\r" Notebook $nb text="\r" Notebook $nb text="Closing this notebook will cause it to be killed without warning. It can be reopened by selecting File > " Notebook $nb text="Experiment Preview > Help.\r" Notebook $nb text="\r" //Details Notebook $nb ruler=Topic, text="Details\r" Notebook $nb ruler=Normal, text="\r" //Menu Notebook $nb ruler=STHeading, text="Menu Items\r" Notebook $nb ruler=STBody, fStyle=-1 Notebook $nb text="When the package is loaded a submenu (\"Experiment Preview\") is added to the File menu. There are four i" Notebook $nb text="tems on that menu: \"Save with Defaults\", \"Save Preview Panel\", \"View Preview Panel\", and \"Help\" . \r" Notebook $nb ruler=Normal, text="\r" //Menu Save (w/o panel) Notebook $nb ruler=SSTHeading, text="Save Preview\r" Notebook $nb ruler=SSTBody Notebook $nb text="Gets a list of all open windows (doesn't get hidden windows) according to the default settings and inser" Notebook $nb text="ts them in a new notebook as pictures. Saves the notebook to disk using the same name and disk locati" Notebook $nb text="on as the current experiment. If the experiment has not yet been saved, the notebook is not created, in" Notebook $nb text="stead a warning is printed to the history window requesting that the experiment be saved before creating" Notebook $nb text=" the preview. Gets disk location of experiment from the special \"home\" Igor Symbolic Path.\r" Notebook $nb text="\r" Notebook $nb text="Defaults values are retrieved from disk, if this package has been used previously on this computer; othe" Notebook $nb text="rwise, they are retrieved from hardcoded values in the procedure file. Unless this has been changed, th" Notebook $nb text="e hardcoded value is set to save only Graph windows. Values saved on disk are initialized when the Prev" Notebook $nb text="iew panel is opened they are changed when the checkbox states are changed on the Save tab of the Preview" Notebook $nb text=" panel. \r" Notebook $nb ruler=Normal, text="\r" //Menu Panel -- Save Tab Notebook $nb ruler=SSTHeading, text="Save Preview Panel\r" Notebook $nb ruler=SSTBody Notebook $nb text="Opens the Preview panel at the Save tab. This tab Has check boxes so the user can select from amoung va" Notebook $nb text="rious window types (Graph, Table, Layout, Panel, XOP window or Notebook) to include in the Preview. The" Notebook $nb text=" Save Preview button runs the function to save the selected window types. \r" Notebook $nb text="\r" Notebook $nb text="As checkboxes are selected/deselected the new state is saved as the default checkbox state. The next ti" Notebook $nb text="me the panel is opened, the window type checkboxes will reflect the default setting. These settings wil" Notebook $nb text="l control the behavior of the the Save Preview menu item.\r" Notebook $nb text="\r" Notebook $nb text="The Preview panel and Preveiw notebook(s) will not be saved in the Preview.\r" Notebook $nb ruler=Normal, text="\r" //Menu Panel -- View Tab Notebook $nb ruler=SSTHeading,text="View Preview Panel\r" Notebook $nb ruler=SSTBody Notebook $nb text="Opens the Preview panel at the View tab. This tab " Notebook $nb text="contains controls for: selecting a disk directory where Igor notebook files" Notebook $nb text=" (\"ifn\" extension) are located; a list box displaying notebook files from that directory and a notebook " Notebook $nb text="subwindow to display the contents of a notebook file. In addition, there is a text box for entering tex" Notebook $nb text="t to limit items shown in the list box. Finally, the experiment file associated with the notebook can b" Notebook $nb text="e opened via button on the panel and a check box can be used to save the current experiment before the s" Notebook $nb text="elected one is opened.\r" Notebook $nb ruler=Normal, text="\r" //Menu Help Notebook $nb ruler=SSTHeading, text="Help\r" Notebook $nb ruler=SSTBody,text="Displays this help file. \r" Notebook $nb ruler=Normal, text="\r" //Tabs Notebook $nb ruler=STHeading, text="Tabs\r" Notebook $nb ruler=STBody, text="There are two tabs on the panel: Save and View.\r" Notebook $nb text="\r" //SaveTab Notebook $nb ruler=SSTHeading, text="Save Tab\r" Notebook $nb ruler=SSTBody Notebook $nb text="The Save tab can be used to select types of windows that will be included in the Preview notebook. Clic" Notebook $nb text="k the setboxes to select/deselect the various types: Graphs, Tables, Layouts, Panels, XOP windows (for e" Notebook $nb text="xample, Gizmo windows) and Notebooks. When the Panels and Notebooks options are selected, any open Prev" Notebook $nb text="iew panel(s) or Preview notebook(s) will not be added to the new Preview.\r" Notebook $nb text="\r" Notebook $nb text="The latest checkbox selections will be saved as defaults and will be selected the next time the Preview " Notebook $nb text="panel is opened. They will also be in effect if the Save Preview menu item is selected. See the Miscel" Notebook $nb text="laneous section for more on defaults.\r" Notebook $nb text="\r" NotebookAction/W=$nb name=SaveTab, title="Click picture to open the Preview Panel displaying the Save tab.", procPICTName=pictSaveTab NotebookAction/W=$nb name=SaveTab, commands="NBP_Panel_CreateWithTabs(0)" Notebook $nb ruler=Normal, text="\r\r\r" //View Tab Notebook $nb ruler=SSTHeading, text="View Tab\r" Notebook $nb ruler=SSTBody, text="The View tab has three group boxes: Path, Notebooks and Preview.\r" Notebook $nb text="\r" Notebook $nb text="The ", fStyle=4, text="Path group", fStyle=-1 Notebook $nb text=" is used to select the disk location for preview notebooks. If the Set Path button is clicked a standar" Notebook $nb text="d Igor New Path dialog is opened. The Path textbox displays the current path (or as much as will fit); " Notebook $nb text="it is not editable. \r" Notebook $nb text="\r" Notebook $nb text="When the path is updated, the names of all notebook files (files with \".ifn\" extension) in the directory" Notebook $nb text=" will be displayed in the listbox in the Notebooks group. \r" Notebook $nb text="\r" Notebook $nb text="Changing the path will cause it to be saved as the default path. The next time the Preview panel is ope" Notebook $nb text="ned this will be the initial path and it will be searched for notebook files. If the default path is no" Notebook $nb text="t accessible and error will be reported. (Maybe something can be done to prevent this. Something to co" Notebook $nb text="nsider.) The first time the panel is opened, the default path will be the root directory on the system " Notebook $nb text="drive ('C:\" on most Windows machines, for example.)\r" Notebook $nb text="\r" Notebook $nb text="The ", fStyle=4, text="Notebooks group", fStyle=-1 Notebook $nb text=" contains a listbox displaying all Igor notebooks (\".ifn extension) in the path shown in the Path group." Notebook $nb text=" Clicking on an entry in this listbox will cause the contents of the notebook to be displayed in the Pr" Notebook $nb text="eview subwindow in the Preview group.\r" Notebook $nb text="\r" Notebook $nb text="A text string can be entered in the Notebook Filter String setvariable limit the list of notebooks displ" Notebook $nb text="ayed in the notebooks listbox. The built in \"ListMatch\" function is used to filter the notebook list; t" Notebook $nb text="he \"*\" wildcard can be used; also the \"!\" can be used at the beginning of the filter string to specify f" Notebook $nb text="iles not matching the filter string. (See help info for " NotebookAction/W=$nb name=StringMatch, showMode=1, title="StringMatch", commands="DisplayHelpTopic(\"StringMatch\")" Notebook $nb text=" for details.)\r" Notebook $nb text="\r" Notebook $nb text="Click the Open Experiment button to open the experiment file associated with the currently displayed Pre" Notebook $nb text="view notebook. Note that the experiment and notebook files must exist in the same directory. If no not" Notebook $nb text="ebook is selected, \"No selection for Notebook listbox.\" will be printed in the history window. If the" Notebook $nb text=" Save Current Experiment checkbox is checked the current experiment will be saved prior to opening the t" Notebook $nb text="he selected experiment. If it is not checked the current experiment will not be saved.\r" Notebook $nb text="\r" Notebook $nb text="The ", fStyle=4, text="Preview group", fStyle=-1 Notebook $nb text=" contains a notebook subwindow used to display the notebook selected in the Notebooks listbox. If no no" Notebook $nb text="tebook is selected, \"*No Notebook Selected*\" is displayed.\r" Notebook $nb ruler=Normal, text="\r" NotebookAction/W=$nb name=ViewTab, title="Click picture to open the Preview Panel displaying the View tab.", procPICTName=pictViewTab NotebookAction/W=$nb name=ViewTab, commands="NBP_Panel_CreateWithTabs(1)" Notebook $nb ruler=Normal, text="\r\r\r" //Miscellaneous Notebook $nb ruler=STHeading, text="Miscellaneous\r" Notebook $nb ruler=STBody, text="Additional items of note.\r" Notebook $nb text="\r" Notebook $nb ruler=SSTHeading, text="Preferences\r" Notebook $nb ruler=SSTBody Notebook $nb text="Preference items: types of windows to include in the Preview notebook and the path to notebook files are" Notebook $nb text=" saved to disk using the support for saving package preferences built into Igor Pro. These preferences " Notebook $nb text="will be used for any execution of this package by a user logged into the account under which the prefere" Notebook $nb text="nces were saved.\r" Notebook $nb text="\r" Notebook $nb text="The first time the package is used, only graph windows are selected to be saved and the path to notebook" Notebook $nb text=" files is the root directory on the system drive. \r" Notebook $nb ruler=Normal, text="\r" Notebook $nb ruler=SSTHeading, text="Saving Preview Notebook\r" Notebook $nb ruler=SSTBody Notebook $nb text="Saving a preview (either with the Save With Defaults menu item or the Save tab on the Preview panel) wi" Notebook $nb text="ll overwrite an existing preview notebook for the current experiment without warning. That is, if the e" Notebook $nb text="xisting preview notebook is in the same directory as the current experiment.\r" //We're finished creating the notebook now. Clean up //write protect the notebook Notebook $nb writeprotect=1 //hide the ruler Notebook $nb showruler=0 //move to beginning of notebook Notebook $nb selection={startOfFile, startOfFile}, findtext={"", 1} //now show the notebook and make it top window Notebook $nb visible=2 End //Proc Picture of Preveiw panel view tab //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ZOK:g0#Z\I.gG>.g4'+r%S4d-Qb- 2pkjB[-Lp1fq\\*!=IY8tC6Fp@'QUTpEBs"5C#=F9Mf^V=R[ou[U._`)fg#9OqtIaW^Gi@j0^C-+L` Q)_C$i&`iE46PjnadLrX]sW.:U.%mYCjqHGlYS:[C=#Yr_K"=NC6JeRbV_$PF:sQtr_tS(VQ`^DP'D0N@pWr<)9.8c>cX0>3!6;Be! t^uq#7+)O!sC"8!J5AIQHZLLmckap0@+o*SDES_c!@J]@#G.N3OL(hA%]8IRF/.$kKI)?iDd`GXG!7 EKWCTSqPUmYIVQ)]8r&7omqk)[=pW$o%6;,94:eUBmp48-?LqmoDt?qV,CQi\7*A3,IY+08#/dft6+ )/bU)(r+2cf_K55!;()1W=1!V&OsC"?f"hf'&OD^W6F[+m>?SiSe50&qEq6`W?9UN?0 3%5n=NsTEb`tciXCukQ-8KoDl]6H@XoV4[YCBuapz8OZBB Y!QNJ ASCII85End End //*****************************************************************************************************************// //***** End of Function NBP_Help *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_Save *****// //*****************************************************************************************************************// // 2013/04/12 // // --Get list of all open graphs (doesn't get hidden graphs) and inserts them in a new notebook as // // pictures. Saves the notebook to disk using the same name and disk location as the current // // experiment. If the experiment has not yet been saved, the notebook is not created, instead // // a warning is printed to the history window requesting that the experiment be saved before // // creating the preview. Gets disk location of experiment from the special "home" Igor // // Symbolic Path. // // 2013/04/21 // // --For future reference, winlist can get the following window types: // // 1: Graphs // // 2: Tables // // 4: Layouts // // 16: Notebooks // // 64: Panels // // 128: Procedure windows // // 512: Help windows // // 4096: XOP target windows (e.g., Gizmo 3D plots) // // --Added function parameter "vWinType" to specify the type of windows to include in the // // preview notebook. See list above. // // 2013/04/29 // // --Moved writing of windows to notebook to NBP_AddWindowToNotebook. Added block of // // if/then statements to do the calls to that function. // // 2013/04/30 // // --Added panels, XOP windows and notebooks. // //*****************************************************************************************************************// // --Called by: "Save Preview" item in "Experiment Preview" menu (File Menu) // // --Calls: NBP_AddWindowToNotebook // //*****************************************************************************************************************// Function NBP_Save(vWinType) Variable vWinType String sWinList = "" String sWinName = "" String sExperimentName = "" String sExperimentPath = "" String sNotebookName = "" String sMsg = "" String sNBtext = "" Variable vIndex Variable vType Variable vSavePict //First test that the vWinType results in at least one window being found sWinList = WinList("*", ";", "WIN:" + num2str(vWinType)) //check for empty string if( strlen( sWinList ) == 0 ) print "No windows were found. (Save Preview)" return 1 //failed endif //Sort list of files before storing in file name wave w //16: case-insensitive alphanumeric sort that sorts wave0 and wave9 before wave10. sWinList = SortList(sWinList, ";", 16) // print sWinList //for debugging //name of current experiment //if it is "Untitled", the experiment has not yet been saved; quit & request user first save experiment sExperimentName = IgorInfo(1) if( stringmatch( sExperimentName, "Untitled" ) == 1 ) sMsg = "This experiment has not been saved.\r" sMsg += "The preview notebook must be named after the experiment, " sMsg += "please save the experiment and then create the preview notebook." print sMsg return 1 //failed endif //path to current experiment //if the experiment is not named "Untitled", this should be valid, right? PathInfo home sExperimentPath = S_path if( V_flag == 0 ) //path doesn't exist; this shouldn't happen given the previous check sMsg = "This experiment has not been saved.\r" sMsg += "The preview notebook must be named after the experiment, " sMsg += "please save the experiment and then create the preview notebook." print sMsg endif //get legal & unique name for preview notebook sNotebookName = CleanupName( sExperimentName, 0 ) sNotebookName = UniqueName( sNotebookName, 10, 0 ) //create notebook NewNotebook /F=1 /K=0/W=(71.25,54.5,668.25,482) /N=$sNotebookName as sNotebookName //copied the following from recreation commands, not sure what all of them do, some set default properties for the notebook Notebook $sNotebookName defaultTab=36, statusWidth=252 Notebook $sNotebookName showRuler=1, rulerUnits=1, updating={1, 1} Notebook $sNotebookName newRuler=Normal, justification=0, margins={0,0,540}, spacing={0,0,0}, tabs={}, rulerDefaults={"Arial",10,0,(0,0,0)} //Add some potentially helpful header text //Other items could be added here as well sNBtext = "Experiment Name: " + sExperimentName + "\r" sNBtext += "Experiment Path: " + sExperimentPath + "\r" sNBtext += "Save Date: " + Secs2Date(DateTime,0) + ", " + Secs2Time(DateTime,0) + "\r" Notebook $sNotebookName, fsize=16, text=sNBtext //check for graphs if( vWinType & 1 ) //Graphs vType = 1 vSavePict = 0 NBP_AddWindowToNotebook(sNotebookName, "Graphs", vType, sExperimentName) endif if( vWinType & 2 ) //Tables vType = 2 vSavePict = 0 NBP_AddWindowToNotebook(sNotebookName, "Tables", vType, sExperimentName) endif if( vWinType & 4 ) //Layouts vType = 4 vSavePict = 0 NBP_AddWindowToNotebook(sNotebookName, "Layouts", vType, sExperimentName) endif if( vWinType & 64 ) //Panels vType = 64 vSavePict = 1 NBP_AddWindowToNotebook(sNotebookName, "Panels", vType, sExperimentName) endif if( vWinType & 16 ) //Panels vType = 16 vSavePict = 1 NBP_AddWindowToNotebook(sNotebookName, "Notebooks", vType, sExperimentName) endif if( vWinType & 4096 ) //XOP windows vType = 4096 vSavePict = 1 NBP_AddWindowToNotebook(sNotebookName, "XOP Windows", vType, sExperimentName) endif //save the notebook SaveNotebook /O/P=home /S=7 $sNotebookName as sExperimentName + ".ifn" End //*****************************************************************************************************************// //***** End of Function NBP_Save *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_SaveWithDefaults *****// //*****************************************************************************************************************// // 2013/04/30 // // --Saves the preview file using the hard coded default or preference (saved on disk) window type // // selections. // //*****************************************************************************************************************// // --Called by: menu item Save with Defaults // // --Calls: Pref_LoadPackagePrefs // // NBP_Save // //*****************************************************************************************************************// Function NBP_SaveWithDefaults() Variable vWinType String sMsg = "" //Get preferences from disk (or memory) or use hard coded defaultls STRUCT strJTG_ExperimentPreviewPrefs strPrefs Pref_LoadPackagePrefs(strPrefs) vWinType += strPrefs.vckbGraphState * 1 //Graphs vWinType += strPrefs.vckbTableState * 2 //Tables vWinType += strPrefs.vckbLayoutState * 4 //Layouts vWinType += strPrefs.vckbNotebookState * 16 //Notebooks vWinType += strPrefs.vckbPanelState * 64 //Panels vWinType += strPrefs.vckbXOPwindowState * 4096 //XOP windows if( vWinType == 0 ) //no checkboxes selected sMsg = "Open the Save Preview panel and select at least one window type to save " sMsg += "before pressing attempting to save a preview." DoAlert /T="Save Preview Notebook", 0, sMsg return 1 endif //call function to save preview using window types specified by vWinType NBP_Save(vWinType) End //*****************************************************************************************************************// //***** End of Function NBP_SaveWithDefaults *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_AddWindowToNotebook *****// //*****************************************************************************************************************// // 2013/04/29 // // --Called with notebook name and window type. Gets list of open windows of the given type // // and saves them in the notebook. This used to be done in NBP_Save, but was broken out to // // simplify the process for multiple window types. Each type is grouped together and the // // beginning and end of each group is denoted by the type. // // 2013/04/30 // // --Added panels, XOP windows and notebooks. // // --Lots of time spent getting the formatting (font size, line feeds, underline) correct. This // // involved *much* effort to understand when a change in font size and style takes effect. My // // understanding is that one needs to move to a new line before setting these items if you want // // the next text added to the notebook to show that style. Maybe I'm wrong, but it works. // // --The preview notebook currently being created is skipped if notebooks will be written to the // // preview. Also any preview panels will be skipped if panels are to be written to the preview. // //*****************************************************************************************************************// // --Called by: NBP_Save // // --Calls: none // //*****************************************************************************************************************// Function NBP_AddWindowToNotebook(sNotebookName, sWinTypeName, vWinType, sExperimentName) String sNotebookName String sWinTypeName Variable vWinType String sExperimentName String sWinList = "" String sWinName = "" String sPanelName = "" String sNBtext = "" Variable vIndex sPanelName = WinName(0, 64) //name of top panel //Get list of windows of type vWinType. See NBP_Save for info on window types corresponding //to vWinType values. sWinList = WinList("*", ";", "WIN:" + num2str(vWinType)) //check for empty string if( strlen( sWinList ) == 0 ) print "No " + sWinTypeName + " were found. (Save Preview)" return 1 //failed endif //Sort list of files before storing in file name wave w //16: case-insensitive alphanumeric sort that sorts wave0 and wave9 before wave10. sWinList = SortList(sWinList, ";", 16) //Add notation of window type to notebook sNBtext = "\rWindow Type: " + sWinTypeName //text to add Notebook $sNotebookName, fstyle=4, fsize=16, text=sNBtext //underlined 16 point font Notebook $sNotebookName, text= "\r" //newline, so style set in next line will be active Notebook $sNotebookName, fstyle=0 //normal style //process window list and add windows to notebook vIndex = 0 Do sWinName = StringFromList( vIndex, sWinList, ";" ) if( strlen( sWinName ) == 0 ) break //done endif switch (vWinType) case 1: //graph case 2: //table case 4: //layout sNBtext = sWinTypeName + " -- " + sWinName + "\r" //add window name before image Notebook $sNotebookName, text=sNBtext //write it to the notebook Notebook $sNotebookName, picture={$sWinName, -5, 1} //add image to notebook Notebook $sNotebookName, text= "\r" //start next addition on newline break case 64: //panel if( stringmatch( sWinName, ksPanelName + "*" ) == 1 ) //skip preview panels sNBtext = "Skipping preview panel: " + sWinName + "\r" Notebook $sNotebookName, text=sNBtext break endif //grab picture of panel SavePICT /SNAP=1 /O /P=_PictGallery_ /WIN=$sWinName /E=-5 as "NBP_Pict" sNBtext = sWinTypeName + " -- " + sWinName + "\r" //add window name before image Notebook $sNotebookName, text=sNBtext //write it to the notebook Notebook $sNotebookName, picture={NBP_Pict, -5, 1} //add image to notebook Notebook $sNotebookName, text= "\r" //start next addition on newline break case 16: //notebook if( stringmatch( sWinName, sExperimentName + "*" ) == 1 ) //skip preview notebooks sNBtext = "Skipping preview notebook: " + sWinName + "\r" Notebook $sNotebookName, text=sNBtext break endif sNBtext = sWinTypeName + " -- " + sWinName + "\r" //add window name before image Notebook $sNotebookName, text=sNBtext //write it to the notebook Notebook $sWinName getData=1 //get all content of notebook window Notebook $sNotebookName setData=S_value //save content in preview notebook Notebook $sNotebookName text = "\r" //start next addition on newline Notebook $sNotebookName ruler=Normal //notebook brings its own ruler, change back to normal break case 4096: //XOP window DoWindow /F $sWinName //bring to front for copying DoIgorMenu "Edit", "Copy" //copy to clipboard using built in menu item LoadPict /O "Clipboard", NBP_Pict //save clipboard to picture collection sNBtext = sWinTypeName + " -- " + sWinName + "\r" //add window name before image Notebook $sNotebookName, text=sNBtext //write it to the notebook Notebook $sNotebookName, picture={NBP_Pict, -5, 1} //save picture to notebook Notebook $sNotebookName text = "\r" //start next addition on newline break endswitch vIndex += 1 While ( 1 ) sNBtext = "End of " + sWinTypeName + "\r" Notebook $sNotebookName ruler=Normal Notebook $sNotebookName, fstyle=0, fsize=16, text= sNBtext return 0 //success End //*****************************************************************************************************************// //***** End of Function NBP_AddWindowToNotebook *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_View *****// //*****************************************************************************************************************// // 2013/04/12 // // --Open notebook selected from listbox and copy its content to the notebook subwindow in the // // panel. Close selected notebook after copying the contents. // //*****************************************************************************************************************// // --Called by: NBP_Panel_lbpFiles // // --Calls: none // //*****************************************************************************************************************// Function NBP_View(sPanelName, sFileName, sPath) String sPanelName //name of panel String sFileName //name of notebook file to open String sPath //name of Igor symbolic path to folder with notebook file sFileName String sNBwin = "" sNBwin = sPanelName + ksNoteBookWindowName //notebook subwindow in panel //delete current contents of notebook subwindow in panel String S_value = "" Notebook $sNBwin selection={startOfFile, endOfFile} Notebook $sNBwin setData=S_value Notebook $sNBwin magnification=3 //fit page //open selected notebook; if all goes well there will be no need for user to get involved; //if there is a problem with the path or file name, Igor will present a standard OS file open dialog OpenNotebook /N=Preview /M="Open Notebook"/V=0 /R /T="WMT0"/P=$sPath sFileName Notebook Preview getData=1 //get all content of notebook just opened Notebook $sNBwin setData=S_value //save content in notebook subwindow on panel KillWindow Preview //kill notebook just opened End //*****************************************************************************************************************// //***** End of Function NBP_View *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_Panel_CreateWithTabs *****// //*****************************************************************************************************************// // 2013/04/13 // // --Create panel for reviewing experiment preview notebooks. // // --This will create a package data folder, variables and waves in that folder and a symbolic path // // needed by the preview functions. // // --Sets hook function to close the panel and clean up. // // 2013/04/16 // // --Added set variable control to allow the user to enter a string to filter notebooks which show // // up in the Notebook listbox. // // --Added button to open experiment linked to currently selected notebook. // // --Adding tabs to put Save function and View function on same panel. Save tab will permit // // selecting which type of items to add to summary notebook. // // 2013/04/28 // // --Added controls to Save Tab: Graph, Table & Layout checkboxes and Save Preview button. // // 2013/04/29 // // --Added Panels to tab 0. // //*****************************************************************************************************************// // --Called by: "View Preview" item in "Experiment Preview" menu (File Menu) // // --Calls: NBP_Panel_GetFileList // //*****************************************************************************************************************// Function NBP_Panel_CreateWithTabs(vActiveTab) Variable vActiveTab //Get preferences from disk (or memory) or use hard coded defaultls STRUCT strJTG_ExperimentPreviewPrefs strPrefs Pref_LoadPackagePrefs(strPrefs) String sPanelName = ksPanelName String sPanelTitle = "" //title is same a s panel name String sPackageDataPath //data folder for storing panel global variables String sWSWlistOptions String sMsg = "" String sDefaultPath = "" Variable vCtrlOffset = 20 sDefaultPath = Pref_DecodeText(strPrefs) //get unique names for symbolic path and graph panel sPanelName = UniqueName(sPanelName, 9, 0 ) //panel sPackageDataPath = ksDFPath + sPanelName +":" sPanelTitle = sPanelName //Create data folders to hold panel info; ksDFPath is string constant //see top of procedure file for its value. Folder has same name as panel name. CreateDFPath(ksDFPath, sPanelName) //create global strings Make /O /T /N=10 $(sPackageDataPath + "w") = "" Wave/T w = $(sPackageDataPath + "w") //list wave for list box lbFiles String/G $(sPackageDataPath + "sPathToFiles") = "" //string holding disk path to files displayed in listbox String/G $(sPackageDataPath + "sSymbolicPathName") = "" //string holding symbolic path name String/G $(sPackageDataPath + "sNBP_Version") = ksVersion //future version might need to verify correct folder or version //we need to access the following strings in this function SVAR sPathToFiles = $(sPackageDataPath + "sPathToFiles") SVAR sSymbolicPathName = $(sPackageDataPath + "sSymbolicPathName") //set up tab control //vActiveTab should not exceed number of tabs -1 if(vActiveTab > 1) vActiveTab = 1 endif //initial size of panel depends on active tab if( vActiveTab == 0 ) NewPanel /K=1/N=$sPanelName/W=(42,48,546,202)/K=1 as sPanelTitle //tab 0 size elseif( vActiveTab == 1 ) NewPanel /K=1/N=$sPanelName/W=(60,50,564,684)/K=1 as sPanelTitle //tab 1 size endif TabControl tbTabs,pos={0,0},size={504,20},fSize=10,tabLabel(0)="Save" TabControl tbTabs,tabLabel(1)="View",value= vActiveTab,proc=NBP_Panel_TabProc //*****Tab 0 controls CheckBox ckbGraph,pos={35,40},size={52,14},title="Graphs",value=strPrefs.vckbGraphState,disable= (vActiveTab!=0) CheckBox ckbGraph,help={"Save open Graph Windows."},proc=NBP_Panel_ckbProc CheckBox ckbTable,pos={97,40},size={50,14},title="Tables",value=strPrefs.vckbTableState,disable= (vActiveTab!=0) CheckBox ckbTable,help={"Save open Table Windows."},proc=NBP_Panel_ckbProc CheckBox ckbLayout,pos={157,40},size={55,14},title="Layouts",value=strPrefs.vckbLayoutState,disable= (vActiveTab!=0) CheckBox ckbLayout,help={"Save open Layout Windows."},proc=NBP_Panel_ckbProc CheckBox ckbPanel,pos={222,40},size={55,14}, title="Panels",value=strPrefs.vckbPanelState,disable= (vActiveTab!=0) CheckBox ckbPanel help={"Save open Panel Windows."},proc=NBP_Panel_ckbProc CheckBox ckbXOPwindow,pos={287,40},size={87,14},title="XOP Windows",value=strPrefs.vckbXOPwindowState,disable= (vActiveTab!=0) CheckBox ckbXOPwindow,help={"Save open XOP Windows."},proc=NBP_Panel_ckbProc CheckBox ckbNotebook,pos={384,40},size={70,14},title="Notebooks",value=strPrefs.vckbNotebookState,disable= (vActiveTab!=0) CheckBox ckbNotebook,help={"Save open Notebook Windows."},proc=NBP_Panel_ckbProc Button btnSaveNotebook,pos={189,120},size={80,20},title="Save Preview",disable= (vActiveTab!=0) Button btnSaveNotebook,help={"Save preview notebook with windows selected in checkboxes above."} Button btnSaveNotebook,proc=NBP_Panel_bpSavePreview //*****Tab 1 controls //path selection GroupBox gbPath frame=1, title="Path", pos={0,vCtrlOffset + 5}, size={504,43},disable= (vActiveTab!=1) SetVariable svPath,pos={66,vCtrlOffset + 24},size={434,16},proc=NBP_Panel_GetFileList,title="Path",noedit=1 sMsg = "Path to search for notebook file. (Igor style path delimeters.)" SetVariable svPath,value= $(sPackageDataPath + "sPathToFiles"),help={sMsg},disable= (vActiveTab!=1) //PathToFiles Button btnSetPath,pos={8,vCtrlOffset + 22},size={50,20},proc=NBP_Panel_bpSetPath,title="Set Path" Button btnSetPath, help={"Change disk path to search for files."},disable= (vActiveTab!=1) //list box GroupBox groupListBox,pos={0,vCtrlOffset + 52},size={504,133},title="Notebooks",disable= (vActiveTab!=1) //show notebook file contents when clicked on in listbox ListBox lbFiles disable=0, editStyle= 0, listWave= w, mode=1, pos={7,vCtrlOffset + 70},selRow=-1 sMsg = "Note book files located in directory shown above in 'Path'. Click on entry to view it in the Preview Window." ListBox lbFiles size={246,107}, widths={200},proc=NBP_Panel_lbpFiles,help={sMsg},disable= (vActiveTab!=1) SetVariable svFilter,pos={263,vCtrlOffset + 73},size={200,16},title="Notebook Filter String" sMsg = "String to limit entries in Notebook list box; wildcard (*) is permitted." SetVariable svFilter, value=_STR:"",help={sMsg} SetVariable svFilter, proc=NBP_Panel_GetFileList,disable= (vActiveTab!=1) Button btnOpenExpt,pos={264,vCtrlOffset + 155},size={95,20},title="Open Experiment" sMsg = "Press to open the experiment linked to selected notebook." Button btnOpenExpt,proc=NBP_Panel_bpOpenExperiment,help={sMsg},disable= (vActiveTab!=1) CheckBox ckbSaveExpt,pos={382,vCtrlOffset + 158},size={104,14},title="Save Current Expt" CheckBox ckbSaveExpt,help={"Save current experiment before opening previewed experiment."} CheckBox ckbSaveExpt,value= 0,disable= (vActiveTab!=1) //notebook GroupBox groupNotebook,pos={0,vCtrlOffset + 188},size={504,446 - vCtrlOffset},title="Preview",disable= (vActiveTab!=1) NewNotebook /F=1 /N=nb0 /W=(7,vCtrlOffset + 207,497,626) /HOST=# SetActiveSubwindow ## String sNBwin = sPanelName + ksNoteBookWindowName Notebook $sNBwin magnification=2//, setData="this is a test" //2==fit width SetWindow $sNBwin HIDE=(vActiveTab!=1) //hide notebook window if start with save tab //An Igor Symbolic Path unique to this panel will be created; if it already exists it will be overwritten //In theory it should not preexist as the panel name will be unique and the path will be name after the //panel. The path will be killed when the panel is killed. sSymbolicPathName = ksSymbolicPathNameStart + sPanelName ////create new symbolic pant and set to default disk path (ksDefaultDataPath) // NewPath /O/Q $sSymbolicPathName, ksDefaultDataPath ////display path in set variable "Path" on panel // sPathToFiles = ksDefaultDataPath //create new symbolic pant and set to default disk path (ksDefaultDataPath) NewPath /O/Q $sSymbolicPathName, sDefaultPath //display path in set variable "Path" on panel sPathToFiles = sDefaultPath //get list of files from default path NBP_Panel_GetFileList("",0,"","") //set window hook for this panel; hook function is MultiFileLoadHook //cleans up (kills package data folder & symbolic path) SetWindow kwTopWin, hook(NBP_Panel_CleanUp )=NBP_Panel_Hook End //*****************************************************************************************************************// //***** End of Function NBP_Panel_CreateWithTabs *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_Panel_TabProc *****// //*****************************************************************************************************************// // 2013/04/21 // // --Displays and hides controls on the NBP_Panel. Based on function from QCA procedure. // // 2013/04/28 // // --Added code for controls on Save Tab // // 2013/04/29 // // --Resizes panel depending on the active tab. // // --Added Panels to tab 0. // //*****************************************************************************************************************// // --Called by: NBP_Panel_Create tbTabs Tab Control // // --Calls: none // //*****************************************************************************************************************// Function NBP_Panel_TabProc(str_Tab) STRUCT WMTabControlAction &str_Tab Variable vWinWidth Variable vWinHeight //Only respond to mouse up event if(str_Tab.eventcode != 2) return 0 endif String sPanelName = str_Tab.win String sGraphName = sPanelName + "Image" String sNBName = sPanelName + ksNoteBookWindowName Variable vActiveTab = str_Tab.tab Variable vWidth Variable vHeight //tab 0 controls CheckBox ckbGraph,disable= (vActiveTab!=0) CheckBox ckbTable,win=$sPanelName,disable= (vActiveTab!=0) CheckBox ckbLayout,win=$sPanelName,disable= (vActiveTab!=0) CheckBox ckbPanel,win=$sPanelName,disable= (vActiveTab!=0) CheckBox ckbXOPWindow,win=$sPanelName,disable= (vActiveTab!=0) CheckBox ckbNotebook,win=$sPanelName,disable= (vActiveTab!=0) Button btnSaveNotebook,win=$sPanelName,disable= (vActiveTab!=0) //tab 1 controls GroupBox gbPath,win=$sPanelName,disable= (vActiveTab!=1) SetVariable svPath,win=$sPanelName,disable= (vActiveTab!=1) Button btnSetPath,win=$sPanelName,disable= (vActiveTab!=1) GroupBox groupListBox,win=$sPanelName,disable= (vActiveTab!=1) ListBox lbFiles,win=$sPanelName,disable= (vActiveTab!=1) SetVariable svFilter,win=$sPanelName,disable= (vActiveTab!=1) Button btnOpenExpt,win=$sPanelName,disable= (vActiveTab!=1) CheckBox ckbSaveExpt,win=$sPanelName,disable= (vActiveTab!=1) GroupBox groupNotebook,win=$sPanelName,disable= (vActiveTab!=1) SetWindow $sNBName HIDE=(vActiveTab!=1) //set size of panel based on active tab GetWindow/Z $sPanelName wsize if( vActiveTab == 0 ) //tab 0 size vWidth = 504 * 72 / ScreenResolution vHeight = 154 * 72 / ScreenResolution MoveWindow /W=$sPanelName V_Left, V_Top, V_Left + vWidth, V_Top + vHeight elseif( vActiveTab == 1 ) //tab 1 size vWidth = 504 * 72 / ScreenResolution vHeight = 634 * 72 / ScreenResolution MoveWindow /W=$sPanelName V_Left, V_Top, V_Left + vWidth, V_Top + vHeight endif End //*****************************************************************************************************************// //***** End of Function NBP_Panel_TabProc *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_Panel_Hook *****// //*****************************************************************************************************************// // 2013/04/14 // // --Window hook function for NBP_Panel; cleans up when the panel is closed. Deletes // // package folder and symbolic path. // //*****************************************************************************************************************// // --Called by: NBP_Panel kill window event. // // --Calls: none // //*****************************************************************************************************************// Function NBP_Panel_Hook(s) STRUCT WMWinHookStruct &s Variable statusCode = 0 String sPanelName String sDFName sPanelName = s.winName sDFName = ksDFPath + sPanelName + ":" SVAR sSymbolicPathName = $(sDFName + "sSymbolicPathName") if(s.eventCode == 2) //kill window: clean up KillPath /Z $sSymbolicPathName //kill symbolic path unique to this panel KillDataFolder $sDFName statusCode = 0 endif return statusCode // 0 if nothing done, else 1 End //*****************************************************************************************************************// //***** End of Function NBP_Panel_Hook *****// //*****************************************************************************************************************// //****************************************************************************************************************// //***** NBP_Panel_bpSetPath *****// //*****************************************************************************************************************// // 2013/04/14 // // --Based on function from multi file loader: Called by Set Path button on panel. Opens dialog // // to select new symbolic path to directory containing files to load. Then calls routine to get all // // files from that directory and load into wave w for display in the list box. // // --Change to use WMButtonAction input structure. // //*****************************************************************************************************************// // --Called by: btnSetPath on panel // // --Calls: NBP_Panel_GetFileList // //*****************************************************************************************************************// Function NBP_Panel_bpSetPath(str_BA) Struct WMButtonAction &str_BA String sMsg = "" String sPanelName = "" String sDataLocation = "" String sNBWin = "" //string and waves associated with this panel instance are located in a data folder named //after the panel name sPanelName = str_BA.win sDataLocation = ksDFPath + sPanelName + ":" sNBWin = sPanelName + ksNoteBookWindowName SVAR sPathToFiles = $(sDataLocation + "sPathToFiles") SVAR sSymbolicPathName = $(sDataLocation + "sSymbolicPathName") //only respond to specific control if(stringmatch(str_BA.ctrlName, "btnSetPath") != 1) return 0 endif switch (str_BA.eventCode) case 2: //mouse up sMsg = "Browse To The File Location..." NewPath /M=sMsg /O/Q $sSymbolicPathName if(V_flag != 0) //user hit cancel or operation failed becaues of error (path doesn't exist) return 0 endif PathInfo $sSymbolicPathName //update global path variable; S_path is variable created by PathInfo operation sPathToFiles = S_path //fill listbox with files from new path NBP_Panel_GetFileList("",0,"","") //clear notebook contents Notebook $sNBwin magnification=100//3 //fit page Notebook $sNBwin selection={startOfFile, endOfFile}, setData="*No Notebook Selected*" //set listbox selection to no selection, otherwise row previously highlighted will remain highlighted, //but notebook in new list corresponding to that item will not be displayed in subnotebook window ListBox lbFiles win=$sPanelName, selRow=-1 //save new path as default STRUCT strJTG_ExperimentPreviewPrefs strPrefs Pref_LoadPackagePrefs(strPrefs) //load preferences Pref_EncodeText(sPathToFiles, strPrefs) //encode new path break endswitch return 0 End Function //*****************************************************************************************************************// //***** End of Function NBP_Panel_bpSetPath *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_Panel_GetFileList *****// //*****************************************************************************************************************// // 2013/04/14 // // --Get list of files from current path sSymbolicPathName, redimension waves used to hold // // file names. // // --This will automatically put new list into listbox. // // --Notebook Filter String setvariable is active, can be used to filter list of files that appear in the // // listbox. Filter is applied after the file list is sorted. NBP_Panel_GetFileList is the proc for // // the sFilter setvariable. When the focus is moved from filter setvar the procedure is run. // // Don't apply filter for zero lenght string, that is if user hasn't created a filter string. // // Uses ListMatch function to filter the file list, so can use "!" and "*" wildcards. // //*****************************************************************************************************************// // --Called by: NBP_Panel_Create // // NBP_Panel_bpSetPath // // SetVariable svFilter on panel // // --Calls: none // //*****************************************************************************************************************// Function NBP_Panel_GetFileList(ctrlName,varNum,varStr,varName) String ctrlName Variable varNum // value of variable as number String varStr // value of variable as string String varName // name of variable String sPanelName = "" String sDataLocation = "" String sFileList = "" //String and waves associated with this panel instance are located in a data folder named //after the panel name. sPanelName = WinName(0, 64) //name of top panel sDataLocation = ksDFPath + sPanelName + ":" //Igor data folder with panel data SVAR sSymbolicPathName = $(sDataLocation + "sSymbolicPathName") Wave/T w = $(sDataLocation + "w") //Get list of files in the folder pointed to by the symbolic path sSymbolicPathName; this list is limited by file type or //extension stored in string constant ksFileTypeOrExtension. If no files are found matching the specification, //IndexedFile returns and empty string "". sFileList = IndexedFile($sSymbolicPathName, -1, ksFileTypeOrExtension) //Sort list of files before storing in file name wave w //16: case-insensitive alphanumeric sort that sorts wave0 and wave9 before wave10. sFileList = SortList(sFileList, ";", 16) //Modify the files list for filter string //S_Value is the string value of the set variable //Don't apply fileter for 0 length filter strings; this is the case where nothing was entered in the //setvariable and, obviously, the user doesn't want to apply a filter. ControlInfo svFilter if( strlen( S_Value ) > 0 ) sFileList = ListMatch( sFileList, S_Value, ";" ) endif //Redimension waves used for file list and selection of files in list to match number of entries in FileList. Redimension /N=( itemsinlist(sFileList, ";") ) w w[] = StringFromList(p, sFileList, ";") //store list of file names in w End //*****************************************************************************************************************// //***** End of Function NBP_Panel_GetFileList *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_Panel_lbpFiles *****// //*****************************************************************************************************************// // 2013/04/14 // // --Action procedure for lbFiles list box. Responds to mouse click (mouse up) event. If an item // // in the box had been clicked on (selected) NBP_View will be called to open the selected // // notebook file and load its contents into the notebook embedded in the panel. // // 2013/04/14 // // --"*No Notebook Selected*" is printed in the notebook subwindow if an area of the listbox with // // no list item is selected. Sort of a warning to the user. // //*****************************************************************************************************************// // --Called by: lbFiles list box mouse up event // // --Calls: NBP_View // //*****************************************************************************************************************// Function NBP_Panel_lbpFiles(str_LBA) STRUCT WMListboxAction &str_LBA Wave/T w = str_LBA.listWave Variable vSelectedRow String sPackageDataPath = "" String sFileWithPath = "" String sNBwin = "" sPackageDataPath = ksDFPath + str_LBA.win +":" sNBwin = str_LBA.win + ksNoteBookWindowName SVAR sPathToFiles = $(sPackageDataPath + "sPathToFiles") SVAR sSymbolicPathName = $(sPackageDataPath + "sSymbolicPathName") switch (str_LBA.eventcode) case 2: //mouse up ControlInfo /W=$str_LBA.win $str_LBA.ctrlname //vSelectedRow = number of row in list box that was clicked; //corresponds to point in list wave containing entry that was selected vSelectedRow = V_value if( vSelectedRow < 0 ) //no selection print "No selection for Notebook listbox." Notebook $sNBwin selection={startOfFile, endOfFile}, magnification=100,setData="*No Notebook Selected*" return 0 endif sFileWithPath = sPathToFiles + w[vSelectedRow] NBP_View(str_LBA.win, w[vSelectedRow], sSymbolicPathName) break endswitch return 0 End //*****************************************************************************************************************// //***** End of Function NBP_Panel_lbpFiles *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_Panel_bpOpenExperiment *****// //*****************************************************************************************************************// // 2013/04/16 // // --Open experiment linked to the currently selected notebook. Opening the experiment file // // will close this experiment without saving it. // // 2013/04/17 // // --Used Execute Que and LOADFILE command to open an existing experiment. Before the // // current experiment is closed, there is a dialog asking if it should be saved. It will be simple // // to add a checkbox to automatically save or not save the experiment and so dispense with // // dialog. // // 2013/04/19 // // --Save Current Experiment checkbox is active so that experiment is saved or not based on its // // state (ckbSaveExpt). If the box is checked, the experiment is saved regardless of whether or // // not it has been changed. The experiment is saved with "SaveExperiment" operation. If the // // experiment has been saved previously, this will overwrite the existing file; if it has not been // // saved previously, a standard save file dialog will be presented. // // --Just prior to opening the selected experiment, "Execute/P "NEWEXPERIMENT " is // // executed to suppress a save file dialog in the event the experiment has changed and the // // Save Current Expt check box is unchecked. // //*****************************************************************************************************************// // --Called by: Button btnOpenExpt on panel // // --Calls: none // //*****************************************************************************************************************// Function NBP_Panel_bpOpenExperiment(ba) STRUCT WMButtonAction &ba Variable vSelectedRow String sPackageDataPath = "" String sFileWithPath = "" String sCmd = "" String sMsg = "" String sNotebookFileName = "" String sExperimentFileName = "" Variable vFileNo //data folder containing waves & variable related to the panel sPackageDataPath = ksDFPath + ba.win +":" //disk path to notebook (and experiment files, if this package is used correctly) files shown in listbox SVAR sPathToFiles = $(sPackageDataPath + "sPathToFiles") switch( ba.eventCode ) case 2: // mouse up //if checkbox is checked save current experiment before opening selected one. //SaveExperiment acts like the Save menu command in the File menu. If the experiment //is associated with an already saved file, then SaveExperiment with no parameters will simply //save the current experiment. If the experiment resides only in memory and has not yet been //saved, then a dialog will be presented unless the path and file name are specified. ControlInfo /W=$ba.win ckbSaveExpt if( V_Value ) //checked = save SaveExperiment endif //get selected file ControlInfo /W=$ba.win lbFiles //vSelectedRow = number of row in list box that was clicked; //corresponds to point in list wave containing entry that was selected vSelectedRow = V_value if( vSelectedRow < 0 ) //no selection print "No selection for Notebook listbox." return 0 endif Wave/T w = $(S_DataFolder + S_Value) //selection wave for listbox sNotebookFileName = w[vSelectedRow] //selected item in listbox //experiment should have same base name as notebook, but has ".pxp" extension sExperimentFileName = sNotebookFileName[0, strlen( sNotebookFileName ) - 5] + ".pxp" //try to open experiment file, if this fails the experiment doesn't exist in this directory Open /Z /R vFileNo as sPathToFiles + sExperimentFileName if( V_flag != 0 ) //error sMsg = "Experiment File: \r" + sExperimentFileName + "\r\r" sMsg += "Does Not Exist in the Current Directory: \r" + sPathToFiles DoAlert/T="Open Experiment" 0, sMsg return 0 //quit else Close vFileNo //succeeded, now close file endif Execute/P "NEWEXPERIMENT " sCmd = "LOADFILE " + sPathToFiles + sExperimentFileName //command to open experiment Execute/P sCmd //Do It break case -1: // control being killed break endswitch return 0 End //*****************************************************************************************************************// //***** End of Function NBP_Panel_bpOpenExperiment *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_Panel_bpSavePreview *****// //*****************************************************************************************************************// // 2013/04/29 // // --Assembles variable for WinList("*", ";", "WIN:" + num2str(vWinType) function. Variable is // // used to specify types of windows to include in the list. It is binary coded following WM // // format: // // 1: Graphs // // 2: Tables // // 4: Layouts // // 16: Notebooks // // 64: Panels // // 128: Procedure windows // // 512: Help windows // // 4096: XOP target windows (e.g., Gizmo 3D plots) // // --At this time only graphs, tables and layouts have checkboxes on the panel. // // 2013/04/30 // // --Added support for saving panels, XOP windows and Notebooks. // // --Added check that at least one checkbox was selected. // //*****************************************************************************************************************// // --Called by: btnSaveNotebook on NBP_Panel, Save Tab // // --Calls: NBP_Save // //*****************************************************************************************************************// Function NBP_Panel_bpSavePreview(ba) STRUCT WMButtonAction &ba String sMsg = "" Variable vWinType switch (ba.eventcode) case 2: //mouse up ControlInfo ckbGraph vWinType += V_Value * 1 ControlInfo ckbTable vWinType += V_Value * 2 ControlInfo ckbLayout vWinType += V_Value * 4 ControlInfo ckbPanel vWinType += V_Value * 64 ControlInfo ckbNotebook vWinType += V_Value * 16 ControlInfo ckbXOPwindow vWinType += V_Value * 4096 if( vWinType == 0 ) //no checkboxes selected sMsg = "Select at least one window type to save before pressing \"Save Preview\" button." DoAlert /T="Save Preview Notebook", 0, sMsg return 1 endif print vWinType NBP_Save(vWinType) break endswitch return 0 End //*****************************************************************************************************************// //***** End of Function NBP_Panel_bpSavePreview *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** Static Function CreateDFPath *****// //*****************************************************************************************************************// // 2013/04/14 // // --Standard function used to created a new data folder and the path to it if it does not exist. // // Function is declared as static in case it exists in other open procedure files. // //*****************************************************************************************************************// // --Called by: NBP_Panel_Create // // --Calls: none // //*****************************************************************************************************************// Static Function CreateDFPath(sFullDFPath, sNewDF) String sFullDFPath String sNewDF String sEntireDFPath //path plus new folder Variable incr String sPathElement = "" String sPartialPath = "" String sPathChar = "" sEntireDFPath = sFullDFPath + sNewDF //check that path and folder strings aren't empty if((strlen(sFullDFPath) == 0) || (strlen(sNewDF) == 0 ) == 1) DoAlert 0, "Missing Data Folder Path... check string constant at start of procedure." return 0 endif //Does path already exist? //then check for its existence, if it alrealdy exists, alert user and return success If(DataFolderExists(sEntireDFPath)) //print "Path already exists: ", sEntireDFPath return 1 EndIf //Are there any ":" at front? Do sPathChar = sEntireDFPath[0] if(stringmatch(sPathChar, ":") == 0) break endif sPartialPath += ":" sEntireDFPath = sEntireDFPath[1, inf] While(1) incr = 0 //if the first part of the path is "root:", this is a special case. It always exists and we don't //need to create it, so skip over it. //break path at folders and work with each part of the path sPathElement = StringFromList(incr, sEntireDFPath, ":") If(stringmatch(sPathElement, "root")) sPartialPath = "root:" incr += 1 EndIf Do //break path at folders and work with each part of the path sPathElement = StringFromList(incr, sEntireDFPath, ":") //exit loop when we encounter a null string, this usually means that all elements of loop //have been processed If(!strlen(sPathElement)) break EndIf sPartialPath += sPathElement // print "creating: ", sPartialPath NewDataFolder/O $sPartialPath //need ":" to separate path elements, but NewDataFolder doesn't like this on the end of a path //string, so we append it here. sPartialPath += ":" incr += 1 While(1) return 1 End //*****************************************************************************************************************// //***** End of CreateDFPath *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** Pref_LoadPackagePrefs *****// //*****************************************************************************************************************// // 2013/04/30 // // --Load preferences from disk. If preferences file is not found, get values from default function. // // --Copied from WaveMetrics Packages Preferences Demo experiment. // //*****************************************************************************************************************// // --Called by: NBP_Panel_CreateWithTabs // // --Calls: DefaultPackagePrefsStruct // // SavePackagePrefs // //*****************************************************************************************************************// Static Function Pref_LoadPackagePrefs(strPrefs) STRUCT strJTG_ExperimentPreviewPrefs &strPrefs // This loads preferences from disk if they exist on disk. LoadPackagePreferences ksPackageName, ksPreferencesFileName, kvPrefsRecordID, strPrefs // Printf "%d byte loaded\r", V_bytesRead // If error or prefs not found or not valid, initialize them. if (V_flag!=0 || V_bytesRead==0 || strPrefs.version!=kvPrefsVersion) Pref_DefaultPackageStruct(strPrefs) // Set to default values. Pref_SavePackagePrefs(strPrefs) // Create initial prefs record. endif End //*****************************************************************************************************************// //***** End of Function Pref_LoadPackagePrefs *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** Pref_SavePackagePrefs *****// //*****************************************************************************************************************// // 2013/04/30 // // --Save preferences structure to memory. // // --Copied from WaveMetrics Packages Preferences Demo experiment. // //*****************************************************************************************************************// // --Called by: LoadPackagePrefs // // NBP_Panel_ckbProc // // --Calls: none // //*****************************************************************************************************************// Static Function Pref_SavePackagePrefs(strPrefs) STRUCT strJTG_ExperimentPreviewPrefs &strPrefs SavePackagePreferences ksPackageName, ksPreferencesFileName, kvPrefsRecordID, strPrefs End //*****************************************************************************************************************// //***** End of Function Pref_SavePackagePrefs *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** KillPackagePrefs *****// //*****************************************************************************************************************// // 2013/04/30 // // --Copied from WaveMetrics Packages Preferences Demo experiment. // // --Used to test SavePackagePreferences /KILL flag added in Igor Pro 6.10B04 // //*****************************************************************************************************************// // --Called by: none // // --Calls: none // //*****************************************************************************************************************// Function Pref_KillPackagePrefs() STRUCT strJTG_ExperimentPreviewPrefs strPrefs SavePackagePreferences /KILL ksPackageName, ksPreferencesFileName, kvPrefsRecordID, strPrefs End //*****************************************************************************************************************// //***** End of Function KillPackagePrefs *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** Pref_DefaultPackageStruct *****// //*****************************************************************************************************************// // 2013/04/30 // // --Fill preferences structure with default values if preferences have not been previously stored // // on disk. // // --Copied from WaveMetrics Packages Preferences Demo experiment. // //*****************************************************************************************************************// // --Called by: Pref_LoadPackagePrefs // // --Calls: none // //*****************************************************************************************************************// Static Function Pref_DefaultPackageStruct(strPrefs) STRUCT strJTG_ExperimentPreviewPrefs &strPrefs Variable vIndex strPrefs.version = kvPrefsVersion strPrefs.vckbGraphState = 1 strPrefs.vckbTableState = 0 strPrefs.vckbLayoutState = 0 strPrefs.vckbPanelState = 0 strPrefs.vckbXOPwindowState = 0 strPrefs.vckbNotebookState = 0 for(vIndex=0; vIndex<400; vIndex+=1) strPrefs.vDefaultPath [vIndex] = 0 //path endfor //put default path in structure Pref_EncodeText(ksDefaultDataPath, strPrefs) End //End //*****************************************************************************************************************// //***** End of Function Pref_DefaultPackageStruct *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** Pref_EncodeText *****// //*****************************************************************************************************************// // 2013/04/30 // // --Encodes text in ASCII number format. Use this to save default path to files using the // // WaveMetrics preference scheme. // // --Note (from help file): // // char2num(str ) // // --The char2num function returns a number which is the numeric representation of the first // // byte in the string expression str. The char2num function treats str as a string of signed // // bytes. Consequently it returns a negative number for bytes that have bit 7 set. You can // // obtain the byte value as a positive number by ANDing with 0xFF. // //*****************************************************************************************************************// // --Called by: NBP_Panel_bpSetPath // // Pref_DefaultPackageStruct // // --Calls: Pref_SavePackagePrefs // //*****************************************************************************************************************// Function Pref_EncodeText(sText, strPrefs) String sText STRUCT strJTG_ExperimentPreviewPrefs &strPrefs String sChar = "" Variable vNumChars Variable vIndex //vNumChars equals the number of characters in sText or 400 which ever is smaller //size of array in the structure is no more than 400; thus we can encode a path of only 400 characters vNumChars = min( strlen( sText ), 400 ) //reset path to all zeroes; otherwise a new path that is shorter than current will be concatenated //with part of current path for(vIndex=0; vIndex<400; vIndex+=1) strPrefs.vDefaultPath [vIndex] = 0 endfor for( vIndex = 0; vIndex < vNumChars; vIndex += 1 ) sChar = sText[vIndex] strPrefs.vDefaultPath [vIndex] = Char2Num(sChar) endfor //save preferences with new path Pref_SavePackagePrefs(strPrefs) End //*****************************************************************************************************************// //***** End of Function Pref_EncodeText *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** Pref_DecodeText *****// //*****************************************************************************************************************// // 2013/04/30 // // --Decodes strPrefs.vDefaultPath [vIndex] from ASCII number format to text. Use this to obtain // // default path to files from the WaveMetrics preference scheme. // // --Returns text value of the encoded path. // // --Note (from help file): // // char2num(str ) // // --The char2num function returns a number which is the numeric representation of the first // // byte in the string expression str. The char2num function treats str as a string of signed // // bytes. Consequently it returns a negative number for bytes that have bit 7 set. You can // // obtain the byte value as a positive number by ANDing with 0xFF. // //*****************************************************************************************************************// // --Called by: NBP_Panel_CreateWithTabs // // --Calls: none // //*****************************************************************************************************************// Function/S Pref_DecodeText(strPrefs) STRUCT strJTG_ExperimentPreviewPrefs &strPrefs String sText = "" String sChar = "" Variable vNumChars Variable vCharNum Variable vIndex vIndex = 0 Do vCharNum = strPrefs.vDefaultPath [vIndex] //there shouldn't be a character encoded "0", there fore this marks end of ASCII coded string if( vCharNum == 0 ) break endif sText[vIndex] = Num2Char(vCharNum) vIndex += 1 While(1) return sText End //*****************************************************************************************************************// //***** End of Function Pref_DecodeText *****// //*****************************************************************************************************************// //*****************************************************************************************************************// //***** NBP_Panel_ckbProc *****// //*****************************************************************************************************************// // 2013/04/30 // // --Responds to change of state of Save tab checkboxes and saves current state of all // // checkboxes in preferences in memory. // // --Based upon from WaveMetrics Packages Preferences Demo experiment. // //*****************************************************************************************************************// // --Called by: check boxes on Save tab on NBP_Panel // // --Calls: Pref_SavePackagePrefs // //*****************************************************************************************************************// Function NBP_Panel_ckbProc(cba) STRUCT WMCheckBoxAction &cba String sStructElementName = "" STRUCT strJTG_ExperimentPreviewPrefs strPrefs Pref_LoadPackagePrefs(strPrefs) switch(cba.eventCode) case 2: //MouseUp strswitch (cba.CtrlName) case "ckbGraph": strPrefs.vckbGraphState = cba.checked break case "ckbTable": strPrefs.vckbTableState = cba.checked break case "ckbLayout": strPrefs.vckbLayoutState = cba.checked break case "ckbPanel": strPrefs.vckbPanelState = cba.checked break case "ckbXOPwindow": strPrefs.vckbXOPwindowState = cba.checked break case "ckbNotebook": strPrefs.vckbNotebookState = cba.checked break endswitch break endswitch Pref_SavePackagePrefs(strPrefs) End //*****************************************************************************************************************// //***** End of Function NBP_Panel_ckbProc *****// //*****************************************************************************************************************//