Changeset 666
- Timestamp:
- Apr 6, 2010 5:21:46 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Common/DataSetHandling.ipf
r631 r666 15 15 /////////////////// Data Management Panel /////////////////////////////////////////////////////// 16 16 17 // 17 18 Function MakeDMPanel() 19 DoWindow/F DataManagementPanel 20 if(V_flag==0) 21 fMakeDMPanel() 22 endif 23 24 return(0) 25 End 26 27 Function fMakeDMPanel() 18 28 PauseUpdate; Silent 1 // building window... 19 NewPanel /W=(459,44,959,3 64)/N=DataManagementPanel/K=1as "Data Set Management"20 ModifyPanel fixedSize=1 29 NewPanel /W=(459,44,959,300)/N=DataManagementPanel/K=2 as "Data Set Management" 30 ModifyPanel fixedSize=1,cbRGB=(30000,60000,60000) 21 31 22 32 //Main bit of panel 23 GroupBox grpBox_0,pos={20,10},size={460,50} 24 GroupBox grpBox_1,pos={20,80},size={460,200} 25 26 Button DS1_button,pos={300,20},size={150,20},proc=DM_LoadDataSetProc,title="Load 1D Data Set 1" 27 PopupMenu DS1_popup,pos={30,21},size={318,20},title="Data Set 1",proc=DMDS_PopMenuProc 28 PopupMenu DS1_popup,mode=1,value= #"DM_DataSetPopupList()" 29 30 //Management Tab 31 Button Rename_button,title="Rename",pos={75,200},size={150,20} 32 Button Duplicate_button,title="Duplicate",pos={275,200},size={150,20} 33 Button Save_button,title="Save",pos={75,240},size={150,20} 34 Button Unload_button,title="Unload",pos={275,240},size={150,20} 35 SetVariable OldName_setvar,title="Old Name",pos={50,100},size={400,20} 36 SetVariable OldName_setvar,fsize=12,value=_STR:"",noedit=2 33 GroupBox grpBox_0,pos={20,10},size={460,100} 34 GroupBox grpBox_1,pos={20,130},size={460,70} 35 36 Button DS_button,pos={300,20},size={150,20},proc=DM_LoadDataSetProc,title="Load 1D Data Set" 37 Button Save_button,title="Save 1D Data Set",pos={300,50},size={150,20} 38 Button Save_button,proc=DM_SaveProc 39 Button Unload_button,title="Unload 1D Data Set",pos={300,80},size={150,20} 40 Button Unload_button,proc=DM_UnloadProc 41 PopupMenu DS_popup,pos={30,52},size={318,20},title="Data Set ",proc=DM_PopupProc 42 PopupMenu DS_popup,mode=1,value= #"DM_DataSetPopupList()" 43 44 Button Rename_button,title="Rename",pos={75,170},size={150,20} 45 Button Rename_button,proc=DM_RenameProc 46 Button Duplicate_button,title="Duplicate",pos={275,170},size={150,20} 47 Button Duplicate_button,proc=DM_DuplicateProc 48 37 49 SetVariable NewName_setvar,title="New Name (max 25 characters)",pos={50,140},size={400,20} 38 SetVariable NewName_setvar,fsize=12,value=_STR:"",proc=DANameSetvarproc,live=1 39 40 End 50 SetVariable NewName_setvar,fsize=12,value=_STR:"",proc=DMNameSetvarproc,live=1 51 52 Button DMDone_button,title="Done",pos={360,210},size={60,20} 53 Button DMDone_button,proc=DMDoneButtonProc 54 Button DMHelp_button,title="?",pos={440,210},size={30,20} 55 Button DMHelp_button,proc=DMHelpButtonProc 56 57 58 ControlInfo/W=DataManagementPanel DS_popup 59 if (cmpstr(S_Value,"No data loaded") == 0) 60 SetVariable NewName_setvar,value=_STR:"dataset_copy" 61 else 62 //fake call to popup 63 STRUCT WMPopupAction pa 64 pa.win = "DataManagementPanel" 65 pa.ctrlName = "DS_popup" 66 pa.eventCode = 2 67 DM_PopupProc(pa) 68 endif 69 70 End 71 72 73 Function DMNameSetvarproc(sva) : SetVariableControl 74 STRUCT WMSetVariableAction &sva 75 76 switch( sva.eventCode ) 77 case 1: // mouse up 78 case 2: // Enter key 79 case 3: // Live update 80 String sv = sva.sval 81 if( strlen(sv) > 25 ) 82 sv= sv[0,24] 83 SetVariable $(sva.ctrlName),win=$(sva.win),value=_STR:sv 84 ControlUpdate /W=$(sva.win) $(sva.ctrlName) 85 Beep 86 endif 87 break 88 endswitch 89 return 0 90 End 91 92 Function DM_RenameProc(ba) : ButtonControl 93 STRUCT WMButtonAction &ba 94 95 String DS,NewName 96 97 ControlInfo/W=$(ba.win) DS_popup 98 DS = S_Value 99 100 ControlInfo/W=$(ba.win) NewName_setvar 101 NewName = CleanupName(S_Value, 0 ) //clean up any bad characters, and put the cleaned string back 102 SetVariable NewName_setvar,value=_STR:NewName 103 104 switch (ba.eventcode) 105 case 2: // mouse up 106 RenameDataSet(DS,NewName) 107 ControlUpdate /W=$(ba.win) DS_Popup 108 break 109 endswitch 110 111 112 113 return 0 114 end 115 116 Function DM_DuplicateProc(ba) : ButtonControl 117 STRUCT WMButtonAction &ba 118 119 String DS,NewName 120 121 ControlInfo/W=$(ba.win) DS_popup 122 DS = S_Value 123 124 ControlInfo/W=$(ba.win) NewName_setvar 125 NewName = CleanupName(S_Value, 0 ) //clean up any bad characters, and put the cleaned string back 126 SetVariable NewName_setvar,value=_STR:NewName 127 128 switch (ba.eventcode) 129 case 2: // mouse up 130 DuplicateDataSet(DS,NewName,0) 131 ControlUpdate /W=$(ba.win) DS_Popup 132 break 133 endswitch 134 135 return 0 136 end 137 138 Function DM_SaveProc(ba) : ButtonControl 139 STRUCT WMButtonAction &ba 140 141 switch(ba.eventCode) 142 case 2: 143 ControlInfo/W=$(ba.win) DS_popup 144 SaveDataSetToFile(S_Value) 145 break 146 endswitch 147 148 return 0 149 end 150 151 Function DM_UnloadProc(ba) : ButtonControl 152 STRUCT WMButtonAction &ba 153 154 switch (ba.eventcode) 155 case 2: // mouse up 156 157 String savDF=GetDataFolder(1) 158 String DF 159 ControlInfo /W=$(ba.win) DS_Popup 160 DF = S_Value 161 162 print DF 163 //check for horrific null output from control 164 if (cmpstr(DF,"") != 0) 165 166 SetDataFolder DF 167 KillVariables/A 168 SetDataFolder savDF 169 170 KillDataFolder/Z $DF 171 ControlUpdate /W=$(ba.win) DS_Popup 172 173 ControlInfo/W=DataManagementPanel DS_popup 174 if (cmpstr(S_Value,"No data loaded") == 0) 175 SetVariable NewName_setvar,value=_STR:"dataset_copy" 176 else 177 //fake call to popup 178 STRUCT WMPopupAction pa 179 pa.win = "DataManagementPanel" 180 pa.ctrlName = "DS_popup" 181 pa.eventCode = 2 182 DM_PopupProc(pa) 183 endif 184 endif 185 break 186 endswitch 187 188 return 0 189 end 190 191 192 Function DM_PopupProc(pa) : PopupMenuControl 193 STRUCT WMPopupAction &pa 194 195 String resultName 196 197 switch( pa.eventCode) 198 case 2: 199 //print "Called by "+pa.ctrlname+" with value "+pa.popStr 200 ControlInfo/W=$(pa.win) $(pa.ctrlName) 201 String popStr = S_Value 202 if (stringmatch(pa.ctrlname,"*DS*") == 1) 203 resultName = stringfromlist(0,popStr,"_")+"_copy" 204 205 SetVariable NewName_setvar win=$(pa.win), value=_STR:resultName 206 endif 207 break 208 endswitch 209 210 211 End 212 41 213 42 214 //Must follow naming scheme to match buttons to popups … … 70 242 ControlUpdate/W=$(windowName) $(popupName) 71 243 72 if (cmpstr(popupName,"DS 1_popup") == 0)244 if (cmpstr(popupName,"DS_popup") == 0) 73 245 //send fake mouse action to popup to update old name if 74 246 Struct WMPopupAction pa 75 247 pa.eventCode = 2 //fake mouse up 76 248 pa.win = windowName 77 pa.ctrlName = "DS 1_popup"78 DM DS_PopMenuProc(pa)249 pa.ctrlName = "DS_popup" 250 DM_PopupProc(pa) 79 251 endif 80 252 endif … … 82 254 endswitch 83 255 84 return 085 End86 87 88 Function DMDS_PopMenuProc(pa) : PopupMenuControl89 STRUCT WMPopupAction &pa90 91 switch( pa.eventCode )92 case 2: // mouse up93 ControlInfo/W=$(pa.win) $(pa.ctrlName)94 SetVariable OldName_setvar,win=$(pa.win),value=_STR:S_Value95 // ControlInfo/W=$(pa.win) DSTabItem_0e96 // SVAR val = S_Value97 //98 // ControlInfo/W=$(pa.win) $(pa.ctrlName)99 // val = S_Value100 101 SetDataFolder root:102 break103 endswitch104 105 256 return 0 106 257 End … … 123 274 End 124 275 276 277 Function DMDoneButtonProc(ba) : ButtonControl 278 STRUCT WMButtonAction &ba 279 280 String win = ba.win 281 282 switch (ba.eventCode) 283 case 2: 284 DoWindow/K DataManagementPanel 285 break 286 endswitch 287 288 return 0 289 End 290 291 Function DMHelpButtonProc(ba) : ButtonControl 292 STRUCT WMButtonAction &ba 293 294 String win = ba.win 295 296 switch (ba.eventCode) 297 case 2: 298 // click code here 299 DisplayHelpTopic/Z/K=1 "Data Set Management" 300 if(V_flag !=0) 301 DoAlert 0,"The Data Set Management Help file could not be found" 302 endif 303 break 304 endswitch 305 306 return 0 307 End 125 308 126 309 /////////////////////// Data Arithmetic Panel ///////////////////////////////////////// … … 177 360 Button DACalculate_button,proc=DACalculateProc 178 361 Button DASave_button,title="Save Result",pos={300,310},size={150,20} 179 Button DASave_button,proc=DASaveProc 362 Button DASave_button,proc=DASaveProc,disable=2 180 363 Button DACursors_button,title="Get Matching Range",pos={175,250},size={150,20} 181 364 Button DACursors_button,proc=DACursorButtonProc … … 578 761 AddDAPlot(3) 579 762 DoWindow/F DataArithmeticPanel 763 764 //Enable save button now that we have a result to save 765 Button DASave_Button win=$(ba.win),disable=0 766 580 767 // SetActiveSubWindow DAPlotPanel 581 768 endswitch … … 858 1045 sv= sv[0,24] 859 1046 SetVariable $(sva.ctrlName),win=$(sva.win),value=_STR:sv 1047 ControlUpdate /W=$(sva.win) $(sva.ctrlName) 860 1048 Beep 861 1049 endif 1050 Button DASave_Button win=$(sva.win), disable=2 862 1051 break 863 1052 endswitch … … 1137 1326 1138 1327 1139 //This will be hideous1140 Function UnloadDataSet(folderName)1141 String folderName1142 1143 1144 End1145 1146 1328 1147 1329 //////////////////// Write data functions ////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.