1 | #pragma TextEncoding = "UTF-8" |
---|
2 | #pragma rtGlobals=3 // Use modern global access method and strict wave access |
---|
3 | #pragma DefaultTab={3,20,4} // Set default tab width in Igor Pro 9 and later |
---|
4 | #pragma version = 1.08 |
---|
5 | #pragma IgorVersion=8.03 |
---|
6 | |
---|
7 | |
---|
8 | //*************************************************************************\ |
---|
9 | //* Copyright (c) 2005 - 2022, Argonne National Laboratory |
---|
10 | //* This file is distributed subject to a Software License Agreement found |
---|
11 | //* in the file LICENSE that is included with this distribution. |
---|
12 | //*************************************************************************/ |
---|
13 | |
---|
14 | //this is tool to setup Sample Plates for USAXS, survey sample positions, and generate Command files. |
---|
15 | |
---|
16 | //1.08 add Export list of saved sets. Increased version number of the panel. |
---|
17 | //1.07 add IN3S_ImportFile which imports other command files. For nwo set for 12IDB command files. |
---|
18 | //1.06 add Import Image for iamge of sample plate. Straightens paralax and trims based on user corner selection and dimensions provided. |
---|
19 | //1.05 added Append to command file |
---|
20 | //1.04 modifications to beamline survey with epics controls. |
---|
21 | //1.03 Remove for MatrixOP /NTHR=0 since it is applicable to 3D matrices only |
---|
22 | //1.02 Added checking if existing sate is saved to reduce number of dialogs user needs to deal with. |
---|
23 | //1.01 Added NMRAcrylicPlate |
---|
24 | //1.0 September2020, first release. |
---|
25 | //0.6 many fixes |
---|
26 | //0.4 developement, with beamline survey code... |
---|
27 | |
---|
28 | |
---|
29 | //************************************************************************************************************ |
---|
30 | //to add new plate: |
---|
31 | //add in popup a name for it, create also wave/variable names |
---|
32 | //add in IN3S_CreateDefaultPlates |
---|
33 | //add in IN3S_DrawImageOfPlate |
---|
34 | //add to PopulateTabel button in IN3S_ButtonProc |
---|
35 | //warnings.. |
---|
36 | // SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
37 | // WarningForUser = "Could not records values for this positon, no row selected" |
---|
38 | // |
---|
39 | //for epics support we need epics.xop https://sourceforge.net/p/igor2epics/wiki/Home/ |
---|
40 | |
---|
41 | //************************************************************************************************************ |
---|
42 | |
---|
43 | constant IN3_SamplePlateSetupVersion=1.08 |
---|
44 | constant IN3SBeamlineSurveyEpicsMonTicks = 15 |
---|
45 | constant IN3SBeamlineSurveyDevelopOn = 0 |
---|
46 | // values for beamtime estimate, last calibrated using BS on 7/31/2021 JIL (used 15 scan records BS). |
---|
47 | // result is about 2 minutes more than real time. |
---|
48 | constant IN3BmSrvUSAXSOverhead = 10 //overhead for flyscan |
---|
49 | constant IN3BmSrvSAXSOverhead = 3 //overhead for SAXS, transmission measurement |
---|
50 | constant IN3BmSrvWAXSOverhead = 1 //overhead for WAXS |
---|
51 | constant IN3BmSrvSampleMoveSpeed = 2 //average moving samples around in mm/sec, is 4rev/sec |
---|
52 | constant IN3BmSrvTuneTimeStep = 600 //retune every 600 seconds |
---|
53 | constant IN3BmSrvTuneTimeNumU = 3 //retune every 3 USAXS scans |
---|
54 | constant IN3BmSrvTuneAveTime = 40 //retune takes avergate 40 seconds full preUSAXStune is 40 seconds... |
---|
55 | constant IN3BmSrvSWTuneAveTime = 14 //SWAXS tune MR |
---|
56 | constant IN3BmSrvMoveGeometryTime = 20 //overhead to move from USAXS to SAXS to WAXS |
---|
57 | |
---|
58 | |
---|
59 | //TODO: |
---|
60 | // add "Saved & Dirty" flag to avoid some dialogs. |
---|
61 | |
---|
62 | |
---|
63 | //************************************************************************************************************ |
---|
64 | //************************************************************************************************************ |
---|
65 | //************************************************************************************************************ |
---|
66 | //************************************************************************************************************ |
---|
67 | //**************************************************************************************** |
---|
68 | |
---|
69 | |
---|
70 | Function IN3S_SampleSetupMain() |
---|
71 | |
---|
72 | DFrEF OldDf=GetDataFolderDFR() |
---|
73 | |
---|
74 | IN3S_Initialize() |
---|
75 | IN3S_CreateDefaultPlates() |
---|
76 | KillWindow/Z TrimCorrectImageDrawing |
---|
77 | IN3S_CreateTablesForPlates(0, 0) |
---|
78 | IN3S_MainPanel() |
---|
79 | ING2_AddScrollControl() |
---|
80 | IN3_UpdatePanelVersionNumber("SamplePlateSetup", IN3_SamplePlateSetupVersion) |
---|
81 | IN3S_FixUSWAXSForAll() |
---|
82 | IN3S_UpdateListOfSavedSets() |
---|
83 | IN3S_AddTagToImage(-4) //remove all drawings, if needed |
---|
84 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
85 | WarningForUser = "Tool started... Report bugs and wishes to author!" |
---|
86 | IN3S_EstimateRunTime() |
---|
87 | setDataFolder OldDf |
---|
88 | end |
---|
89 | |
---|
90 | //************************************************************************************************************ |
---|
91 | //************************************************************************************************************ |
---|
92 | Function IN3S_ExportHookFunction(listWaveG, LBSelectionWvG) |
---|
93 | wave listWaveG, LBSelectionWvG |
---|
94 | // Modify this function as needed, for example comment out lines etc. |
---|
95 | // These are parameters: |
---|
96 | // IN3S_WriteListOfCommands(listWaveG, LBSelectionWvG, sxOffset, syOffset, TitleModifier) |
---|
97 | // 1. Keep the wave names listWaveG, LBSelectionWvG as they are. These contain info for all samples. |
---|
98 | // 2. Change the sxOffset and syOffset [mm] (these values are added to the sx and sy in the table). |
---|
99 | // 3. Change the TitleModifier, this is appended to the sample name. |
---|
100 | // 4. make sure you have "Run Export Hook function" checkbox checked and compiled procedures. |
---|
101 | //************************************************************************************************S |
---|
102 | //this measures right of center position |
---|
103 | IN3S_WriteListOfCommands(listWaveG, LBSelectionWvG, -1, 0, "_R") |
---|
104 | //this measures top of center position |
---|
105 | IN3S_WriteListOfCommands(listWaveG, LBSelectionWvG, 0, -1, "_T") |
---|
106 | //this measures left of center position |
---|
107 | IN3S_WriteListOfCommands(listWaveG, LBSelectionWvG, 1, 0, "_L") |
---|
108 | //this measures bottom of center position |
---|
109 | IN3S_WriteListOfCommands(listWaveG, LBSelectionWvG, 0, 1, "_B") |
---|
110 | end |
---|
111 | //***************************************************************************************************************** |
---|
112 | //***************************************************************************************************************** |
---|
113 | //************************************************************************************************************ |
---|
114 | //************************************************************************************************************ |
---|
115 | |
---|
116 | Function IN3S_SaPlateCheckVersion() |
---|
117 | DoWindow SamplePlateSetup |
---|
118 | if(V_Flag) |
---|
119 | if(!IN3_CheckPanelVersionNumber("SamplePlateSetup", IN3_SamplePlateSetupVersion)) |
---|
120 | DoAlert /T="The Sample Plate setup panel was created by incorrect version of Indra " 1, "Sample Plate setup needs to be restarted to work properly. Restart now?" |
---|
121 | if(V_flag==1) |
---|
122 | KillWIndow/Z SamplePlateSetup |
---|
123 | IN3S_SampleSetupMain() |
---|
124 | else //at least reinitialize the variables so we avoid major crashes... |
---|
125 | IN3S_Initialize() |
---|
126 | endif |
---|
127 | endif |
---|
128 | endif |
---|
129 | end |
---|
130 | //************************************************************************************************************ |
---|
131 | //************************************************************************************************************ |
---|
132 | |
---|
133 | |
---|
134 | Function IN3S_MainPanel() |
---|
135 | |
---|
136 | string oldDf=GetDataFolder(1) |
---|
137 | setDataFolder root:Packages:SamplePlateSetup |
---|
138 | DoWindow SamplePlateSetup |
---|
139 | if(V_Flag) |
---|
140 | DoWindow/F SamplePlateSetup |
---|
141 | else |
---|
142 | PauseUpdate // building window... |
---|
143 | NewPanel /K=1 /W=(2.25,43.25,590,725)/N=SamplePlateSetup as "Sample Plate setup" |
---|
144 | TitleBox Title title="\Zr210Sample Plate setup",pos={120,3},frame=0,fstyle=3,size={300,24},fColor=(1,4,52428), anchor=MC |
---|
145 | Button GetHelp,pos={490,25},size={80,15},fColor=(65535,32768,32768), proc=IN3S_ButtonProc,title="Get Help", help={"Open www manual page for this tool"} |
---|
146 | //left size |
---|
147 | TitleBox Info1 title="\Zr120New positions : ",pos={10,35},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
148 | Button CreateNewSet,pos={10,55},size={150,17}, proc=IN3S_ButtonProc,title="Create New Sample Set", help={"Creates new set of sample positions"} |
---|
149 | Button AddMoreLines,pos={10,75},size={150,17}, proc=IN3S_ButtonProc,title="Add Sample Positions", help={"Adds more sample positions"} |
---|
150 | SetVariable NumberOfSamplesToCreate,pos={170,62},size={100,20}, limits={1, 500, 10}, proc=IN3S_SetVarProc,title="Lines = " |
---|
151 | Setvariable NumberOfSamplesToCreate,fStyle=2, variable=root:Packages:SamplePlateSetup:NumberOfSamplesToCreate, help={"How many sample positions to create"} |
---|
152 | TitleBox Info2 title="\Zr120Saved Sets : ",pos={10,95},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
153 | PopupMenu SelectSavedSet,pos={10,110},size={330,21},noproc,title="Select Saved set : ", help={"Select folder with saved set of data"} |
---|
154 | PopupMenu SelectSavedSet,mode=1,value= #"\"---;\"+IN3S_GenStringOfSets()" |
---|
155 | Button LoadSavedSet,pos={10,135},size={180,17}, proc=IN3S_ButtonProc,title="Load saved Positions Set", help={"Loads postions set saved before"} |
---|
156 | |
---|
157 | TitleBox Info3 title="\Zr120Templates : ",pos={300,32},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
158 | SVAR SelectedPlateName=root:Packages:SamplePlateSetup:SelectedPlateName |
---|
159 | PopupMenu NewPlateTemplate,pos={300,50},size={330,21},proc=IN3S_PopMenuProc,title="Template :", help={"Pick Plate template"} |
---|
160 | PopupMenu NewPlateTemplate,mode=1,popvalue=SelectedPlateName, fColor=(1,16019,65535) |
---|
161 | PopupMenu NewPlateTemplate,value="9x9 Acrylic/magnetic plate;NMR Acrylic plate;Old Style Al Plate;NMR Tubes holder;NMR tubes heater;Generic Grid holder;AgBehenateLaB6;" |
---|
162 | Button PopulateTable,pos={300,75},size={120,17}, proc=IN3S_ButtonProc,title="Populate Table", help={"Creates new set of positions"} |
---|
163 | Button ImportFile,pos={300,92},size={120,17}, proc=IN3S_ButtonProc,title="Import file", help={"Import file as new set of positions"} |
---|
164 | Button CreateImage,pos={440,75},size={120,17}, proc=IN3S_ButtonProc,title="Create image", help={"Creates image for survey of sample positions"} |
---|
165 | Button ImportImage,pos={440,92},size={120,17}, proc=IN3S_ButtonProc,title="Import image", help={"Import image for survey of sample positions"} |
---|
166 | Button BeamlineSurvey,pos={440,110},size={120,17}, proc=IN3S_ButtonProc,title="Beamline Survey", help={"This opens GUI for survey at the beamline"} |
---|
167 | |
---|
168 | TitleBox Info4 title="\Zr110Current set name : ",pos={300,110},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
169 | SetVariable UserNameForSampleSet,pos={300,130},size={270,20}, proc=IN3S_SetVarProc,title="Set Name: " |
---|
170 | Setvariable UserNameForSampleSet,fStyle=2, variable=root:Packages:SamplePlateSetup:UserNameForSampleSet, help={"Name for these samples"} |
---|
171 | Button SavePositionSet,pos={440,145},size={120,17}, proc=IN3S_ButtonProc,title="Save Position Set", help={"Saves set of positions with user name"} |
---|
172 | |
---|
173 | TabControl TableTabs pos={0,160},size={590,430},tabLabel(0)="Sample Table", value= 0, proc=IN3S_TableTabsTabProc |
---|
174 | TabControl TableTabs tabLabel(1)="Option Controls",tabLabel(2)="Export Controls" |
---|
175 | TitleBox Info20 title="\Zr080Use shift to select range of lines, ctrl/cmd select disjoint multiple lines",pos={5,590},size={400,10},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
176 | //Tab 0 |
---|
177 | ListBox CommandsList,pos={8,185},size={573,395} //, special={0,0,1 } //this will scale the width of column, users may need to slide right using slider at the bottom. |
---|
178 | ListBox CommandsList,listWave=root:Packages:SamplePlateSetup:LBCommandWv |
---|
179 | ListBox CommandsList,selWave=root:Packages:SamplePlateSetup:LBSelectionWv |
---|
180 | ListBox CommandsList,proc=IN3S_ListBoxMenuProc, selRow= 0, editStyle= 0 |
---|
181 | ListBox CommandsList userColumnResize=1,help={"Fill here list of samples, their positions, thickness etc. "} |
---|
182 | ListBox CommandsList titleWave=root:Packages:SamplePlateSetup:LBTtitleWv, frame= 2 |
---|
183 | ListBox CommandsList widths={220,50,50,60,40,40,40,0} |
---|
184 | ListBox CommandsList mode=9 // mode=1 for single row selection, 4 multiple disjoint rows (shift only), mode=9 for shift conigous+ctrl disjoint. |
---|
185 | //Tab 1 |
---|
186 | TitleBox Info10 title="\Zr120Data Collection Controls ",size={250,15},pos={20,190},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
187 | CheckBox USAXSAll pos={30,220},size={70,20},title="USAXS All?", help={"Run USAXS for All"} |
---|
188 | CheckBox USAXSAll variable=root:Packages:SamplePlateSetup:USAXSAll, proc=IN3S_CheckProc |
---|
189 | CheckBox SAXSAll pos={30,250},size={70,20},title="SAXS All?", help={"Run SAXS for All"} |
---|
190 | CheckBox SAXSAll variable=root:Packages:SamplePlateSetup:SAXSAll, proc=IN3S_CheckProc |
---|
191 | CheckBox WAXSAll pos={30,280},size={70,20},title="WAXS All?", help={"Run WAXS for All"} |
---|
192 | CheckBox WAXSAll variable=root:Packages:SamplePlateSetup:WAXSAll, proc=IN3S_CheckProc |
---|
193 | SetVariable DefaultSampleThickness,pos={30,310},size={250,20},limits={0.01,20,0.1}, noproc,title="Default Sample thickness [mm]: " |
---|
194 | Setvariable DefaultSampleThickness,fStyle=2, variable=root:Packages:SamplePlateSetup:DefaultSampleThickness, help={"Thickness if not defined."} |
---|
195 | |
---|
196 | |
---|
197 | SVAR ExportOrder=root:Packages:SamplePlateSetup:ExportOrder |
---|
198 | PopupMenu ExportOrderPop,pos={30,340},size={350,21},proc=IN3S_PopMenuProc,title="Export order : ", help={"Pick order of scans to export"} |
---|
199 | PopupMenu ExportOrderPop,mode=1,popvalue=ExportOrder |
---|
200 | PopupMenu ExportOrderPop,value="USAXS-SAXS-WAXS;SAXS-WAXS-USAXS;USAXS-WAXS-SAXS;" |
---|
201 | |
---|
202 | CheckBox RunExportHookFunction pos={30,375},size={90,20},title="Run Export hook function? ", help={"Run export hook function"} |
---|
203 | CheckBox RunExportHookFunction variable=root:Packages:SamplePlateSetup:RunExportHookFunction, noproc |
---|
204 | |
---|
205 | Button DisplayHookFunction,pos={300,370},size={240,20}, proc=IN3S_ButtonProc,title="Display Hook Function", help={"Displays hook function for user"} |
---|
206 | |
---|
207 | TitleBox Tab1Info1 title="\Zr130These values are used only for beamtime calculation. They are not exported in command file.",pos={30,420},size={550,15},frame=0,fstyle=1,fColor=(65535,0,0),labelBack=0 |
---|
208 | |
---|
209 | SetVariable USAXSScanTime,pos={30,440},size={250,20},limits={30,360,15}, proc=IN3S_SetVarProc,title="USAXS time for run time estimate = " |
---|
210 | Setvariable USAXSScanTime,fStyle=2, variable=root:Packages:SamplePlateSetup:USAXSScanTime, help={"USAXS time from epics, used to calculate run time."} |
---|
211 | SetVariable SAXSScanTime,pos={30,460},size={250,20},limits={1,60,5}, proc=IN3S_SetVarProc,title="SAXS time for run time estimate = " |
---|
212 | Setvariable SAXSScanTime,fStyle=2, variable=root:Packages:SamplePlateSetup:SAXSScanTime, help={"SAXS time from epics, used to calculate run time."} |
---|
213 | SetVariable WAXSScanTime,pos={30,480},size={250,20},limits={1,60,5}, proc=IN3S_SetVarProc,title="WAXS time for run time estimate = " |
---|
214 | Setvariable WAXSScanTime,fStyle=2, variable=root:Packages:SamplePlateSetup:WAXSScanTime, help={"WAXS time from epics, used to calculate run time."} |
---|
215 | |
---|
216 | |
---|
217 | |
---|
218 | SetVariable DefaultCommandFileName,pos={100,550},size={450,25},noproc,title="Default Command file name : " |
---|
219 | Setvariable DefaultCommandFileName,fStyle=2, variable=root:Packages:SamplePlateSetup:DefaultCommandFileName, help={"usaxs.mac typically, or user name if wanted."} |
---|
220 | |
---|
221 | //GUI controls, rigth side |
---|
222 | TitleBox Info11 title="\Zr120GUI Controls ",size={250,15},pos={340,190},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
223 | CheckBox DisplayUSWAXScntrls pos={340,220},size={70,20},title="Display Individ Controls?", help={"Individual U-S-WAXS controls per sample"} |
---|
224 | CheckBox DisplayUSWAXScntrls variable=root:Packages:SamplePlateSetup:DisplayUSWAXScntrls, proc=IN3S_CheckProc |
---|
225 | CheckBox DisplayAllSamplesInImage pos={340,250},size={90,20},title="Display all samples in image? ", help={"Add to image all defined sample positiosn"} |
---|
226 | CheckBox DisplayAllSamplesInImage variable=root:Packages:SamplePlateSetup:DisplayAllSamplesInImage, proc=IN3S_CheckProc |
---|
227 | //Tab 2 Export controls |
---|
228 | CheckBox ExportCurrentPosSet pos={120,187},size={120,20},title="Export Current set? ", help={"Check to export current set in the table only"} |
---|
229 | CheckBox ExportCurrentPosSet variable=root:Packages:SamplePlateSetup:ExportCurrentPosSet, proc=IN3S_CheckProc, mode=1 |
---|
230 | CheckBox ExportListOfPosSets pos={320,187},size={120,20},title="Export list of sets below? ", help={"Check to export list of sets per list below"} |
---|
231 | CheckBox ExportListOfPosSets variable=root:Packages:SamplePlateSetup:ExportListOfPosSets, proc=IN3S_CheckProc, mode=1 |
---|
232 | |
---|
233 | TitleBox Tab2Info1 title="\Zr110Drag saved position from here : ",pos={60,210},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
234 | TitleBox Tab2Info2 title="\Zr110Drop here in order of export : ",pos={350,210},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
235 | ListBox SourceBox,pos={20,230},size={250,300} , listwave=root:Packages:SamplePlateSetup:ListOfSavedSetsWv |
---|
236 | ListBox SourceBox, selwave=root:Packages:SamplePlateSetup:SelListOfSavedSetsWv, mode=9, focusring=0 |
---|
237 | ListBox SourceBox, Proc=IN3S_DragDropListBoxProc |
---|
238 | ListBox TargetBox, pos={300,230},size={250,300}, listwave=root:Packages:SamplePlateSetup:ListOfWavesForExport |
---|
239 | ListBox TargetBox, selwave=root:Packages:SamplePlateSetup:SelListOfWavesForExport, mode=9, focusring=0 |
---|
240 | ListBox TargetBox, Proc=IN3S_DragDropListBoxProc |
---|
241 | TitleBox Tab2Info5 title="\Zr110Make sure you saved the current Positions set !!!! The button needs to be green. ",pos={100,540},size={550,15},frame=0,fstyle=1,fColor=(65535,0,0),labelBack=0 |
---|
242 | TitleBox Tab2Info3 title="Drag a Set from left to right listbox. You can use sets multiple times.",pos={120,555},size={550,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
243 | TitleBox Tab2Info4 title="Delete a Set from right listbox with right click. ",pos={160,570},size={550,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
244 | |
---|
245 | |
---|
246 | //controls under the table |
---|
247 | //save export |
---|
248 | Button PreviewCommandFile,pos={260,595},size={140,20}, proc=IN3S_ButtonProc,title="Preview cmd file", help={"Creates and displays command file with current set of positions"} |
---|
249 | Button ExportCommandFile,pos={415,595},size={160,20}, proc=IN3S_ButtonProc,title="Export cmd file", help={"Exports usaxs.mac or defaultname.mac cmd file with current set of positions"} |
---|
250 | Button AppendToCommandFile,pos={415,620},size={160,20}, proc=IN3S_ButtonProc,title="Append to cmd file", help={"Appends to command file on desktop"} |
---|
251 | Button ExportCommandFile2,pos={415,645},size={160,20}, proc=IN3S_ButtonProc,title="Dialog Export cmd file", help={"Dialog - Exports cmd file with current set of positions"} |
---|
252 | |
---|
253 | Setvariable NumberOfSamples title="\Zr100Samples: ",pos={10,610},size={150,15},frame=0,fstyle=3,fColor=(0,0,65535),valueColor=(0,0,0), labelBack=0, noedit=1 |
---|
254 | Setvariable NumberOfSamples,variable=root:Packages:SamplePlateSetup:NumberOfSamples, help={"Number of used saples"}, limits={0,inf,0} |
---|
255 | |
---|
256 | |
---|
257 | Setvariable CalculatedOverAllTime title="\Zr120Estimated run time [min]: ",pos={10,628},size={220,15},frame=0,fstyle=3,fColor=(0,0,65535),valueColor=(0,0,0), labelBack=0, noedit=1 |
---|
258 | Setvariable CalculatedOverAllTime,variable=root:Packages:SamplePlateSetup:CalculatedOverAllTime, help={"Estimated run time for all"}, limits={0,inf,0} |
---|
259 | |
---|
260 | Setvariable Warnings title="\Zr120Last Info/Warning: ",pos={10,662},size={550,15},frame=0,fstyle=3,fColor=(0,0,65535),valueColor=(65535,0,0), labelBack=0, noedit=1 |
---|
261 | Setvariable Warnings,variable=root:Packages:SamplePlateSetup:WarningForUser, help={"Last warning which code issued"} |
---|
262 | |
---|
263 | endif |
---|
264 | IN3S_FixTabControl() |
---|
265 | |
---|
266 | end |
---|
267 | //***************************************************************************************************************** |
---|
268 | //***************************************************************************************************************** |
---|
269 | |
---|
270 | FUnction IN3S_FixSaveButton() |
---|
271 | |
---|
272 | NVAR TableIsSaved = root:Packages:SamplePlateSetup:TableIsSaved |
---|
273 | string TitleStr |
---|
274 | if(TableIsSaved>0.5) |
---|
275 | TitleStr = "Positions saved" |
---|
276 | Button SavePositionSet,win=SamplePlateSetup, fColor=(32792,65535,1) |
---|
277 | Button SavePositionSet,win=SamplePlateSetup,title=TitleStr, disable=2*TableIsSaved |
---|
278 | else |
---|
279 | TitleStr = "Save Position Set" |
---|
280 | Button SavePositionSet,win=SamplePlateSetup, fColor=(65535,32768,32768) |
---|
281 | Button SavePositionSet,win=SamplePlateSetup,title=TitleStr, disable=2*TableIsSaved |
---|
282 | endif |
---|
283 | end |
---|
284 | //***************************************************************************************************************** |
---|
285 | //***************************************************************************************************************** |
---|
286 | |
---|
287 | Function/T IN3S_GenStringOfSets() |
---|
288 | |
---|
289 | string ListOfQFolders |
---|
290 | string result |
---|
291 | if(DataFolderExists("root:SavedSampleSets:")) |
---|
292 | result=IN2G_CreateListOfItemsInFolder("root:SavedSampleSets:", 1) |
---|
293 | else |
---|
294 | result="" |
---|
295 | endif |
---|
296 | return result |
---|
297 | end |
---|
298 | |
---|
299 | |
---|
300 | //***************************************************************************************************************** |
---|
301 | //***************************************************************************************************************** |
---|
302 | |
---|
303 | Function IN3S_SetVarProc(sva) : SetVariableControl |
---|
304 | STRUCT WMSetVariableAction &sva |
---|
305 | |
---|
306 | switch( sva.eventCode ) |
---|
307 | case 1: // mouse up |
---|
308 | case 2: // Enter key |
---|
309 | case 3: // Live update |
---|
310 | Variable dval = sva.dval |
---|
311 | String sval = sva.sval |
---|
312 | |
---|
313 | if(stringMatch(sva.ctrlname,"UserNameForSampleSet")) |
---|
314 | SVAR UserNameForSampleSet = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
315 | UserNameForSampleSet = CleanupName(sval, 0) |
---|
316 | endif |
---|
317 | |
---|
318 | if(stringMatch(sva.ctrlname,"USAXSScanTime")||stringMatch(sva.ctrlname,"SAXSScanTime")||stringMatch(sva.ctrlname,"WAXSScanTime")) |
---|
319 | IN3S_EstimateRunTime() |
---|
320 | endif |
---|
321 | |
---|
322 | break |
---|
323 | case -1: // control being killed |
---|
324 | break |
---|
325 | endswitch |
---|
326 | |
---|
327 | return 0 |
---|
328 | End |
---|
329 | //***************************************************************************************************************** |
---|
330 | ///****************************************************************************************** |
---|
331 | static Function IN3S_FixTabControl() |
---|
332 | |
---|
333 | variable CurTab |
---|
334 | ControlInfo /W=SamplePlateSetup TableTabs |
---|
335 | CurTab=V_Value |
---|
336 | STRUCT WMTabControlAction tca |
---|
337 | tca.eventCode =2 |
---|
338 | tca.tab = CurTab |
---|
339 | IN3S_TableTabsTabProc(tca) |
---|
340 | |
---|
341 | |
---|
342 | end |
---|
343 | ///****************************************************************************************** |
---|
344 | ///****************************************************************************************** |
---|
345 | ///****************************************************************************************** |
---|
346 | Function IN3S_TableTabsTabProc(tca) : TabControl |
---|
347 | STRUCT WMTabControlAction &tca |
---|
348 | |
---|
349 | switch( tca.eventCode ) |
---|
350 | case 2: // mouse up |
---|
351 | Variable tab = tca.tab |
---|
352 | //tab 0 |
---|
353 | ListBox CommandsList, win=SamplePlateSetup, disable=(tab!=0) |
---|
354 | //tab 1 |
---|
355 | CheckBox USAXSAll, win=SamplePlateSetup, disable=(tab!=1) |
---|
356 | CheckBox SAXSAll, win=SamplePlateSetup, disable=(tab!=1) |
---|
357 | CheckBox WAXSAll, win=SamplePlateSetup, disable=(tab!=1) |
---|
358 | SetVariable DefaultSampleThickness, win=SamplePlateSetup, disable=(tab!=1) |
---|
359 | TitleBox Info10, win=SamplePlateSetup, disable=(tab!=1) |
---|
360 | TitleBox Info11, win=SamplePlateSetup, disable=(tab!=1) |
---|
361 | CheckBox DisplayUSWAXScntrls, win=SamplePlateSetup, disable=(tab!=1) |
---|
362 | CheckBox DisplayAllSamplesInImage, win=SamplePlateSetup, disable=(tab!=1) |
---|
363 | SetVariable DefaultCommandFileName, win=SamplePlateSetup, disable=(tab!=1) |
---|
364 | CheckBox RunExportHookFunction, win=SamplePlateSetup, disable=(tab!=1) |
---|
365 | SetVariable USAXSScanTime, win=SamplePlateSetup, disable=(tab!=1) |
---|
366 | SetVariable SAXSScanTime, win=SamplePlateSetup, disable=(tab!=1) |
---|
367 | SetVariable WAXSScanTime, win=SamplePlateSetup, disable=(tab!=1) |
---|
368 | Button DisplayHookFunction, win=SamplePlateSetup, disable=(tab!=1) |
---|
369 | PopupMenu ExportOrderPop, win=SamplePlateSetup, disable=(tab!=1) |
---|
370 | TitleBox Tab1Info1, win=SamplePlateSetup, disable=(tab!=1) |
---|
371 | |
---|
372 | CheckBox ExportCurrentPosSet, win=SamplePlateSetup, disable=(tab!=2) |
---|
373 | CheckBox ExportListOfPosSets, win=SamplePlateSetup, disable=(tab!=2) |
---|
374 | NVAR ExportListOfPosSets=root:Packages:SamplePlateSetup:ExportListOfPosSets |
---|
375 | NVAR ExportCurrentPosSet=root:Packages:SamplePlateSetup:ExportCurrentPosSet |
---|
376 | TitleBox Tab2Info1, win=SamplePlateSetup, disable=(tab!=2||ExportCurrentPosSet) |
---|
377 | TitleBox Tab2Info2, win=SamplePlateSetup, disable=(tab!=2||ExportCurrentPosSet) |
---|
378 | TitleBox Tab2Info3, win=SamplePlateSetup, disable=(tab!=2||ExportCurrentPosSet) |
---|
379 | TitleBox Tab2Info4, win=SamplePlateSetup, disable=(tab!=2||ExportCurrentPosSet) |
---|
380 | TitleBox Tab2Info5, win=SamplePlateSetup, disable=(tab!=2||ExportCurrentPosSet) |
---|
381 | ListBox SourceBox, win=SamplePlateSetup, disable=(tab!=2||ExportCurrentPosSet) |
---|
382 | ListBox TargetBox, win=SamplePlateSetup, disable=(tab!=2||ExportCurrentPosSet) |
---|
383 | IN3S_EstimateRunTime() |
---|
384 | IN3S_UpdateListOfSavedSets() |
---|
385 | break |
---|
386 | case -1: // control being killed |
---|
387 | break |
---|
388 | endswitch |
---|
389 | |
---|
390 | return 0 |
---|
391 | End |
---|
392 | ///****************************************************************************************** |
---|
393 | ///****************************************************************************************** |
---|
394 | ///****************************************************************************************** |
---|
395 | //************************************************************************************************************ |
---|
396 | Function/S IN3S_CreateListOfRows(wave selWave) |
---|
397 | //create list of selected rows (from end) |
---|
398 | string ListOfSelRows="" |
---|
399 | variable i |
---|
400 | For(i=DimSize(selWave,0)-1;i>=0;i-=1) |
---|
401 | if(selWave[i][0]==3||selWave[i][0]==10) |
---|
402 | ListOfSelRows+=num2str(i)+";" |
---|
403 | endif |
---|
404 | endfor |
---|
405 | return ListOfSelRows |
---|
406 | end |
---|
407 | //************************************************************************************************************ |
---|
408 | //************************************************************************************************************ |
---|
409 | //************************************************************************************************************ |
---|
410 | Function IN3S_ListBoxMenuProc(lba) : ListBoxControl |
---|
411 | STRUCT WMListboxAction &lba |
---|
412 | //see IRB1_ConcSeriesListBoxProc |
---|
413 | |
---|
414 | //IN2G_PrintDebugStatement(IrenaDebugLevel, 5,"") |
---|
415 | Variable row = lba.row |
---|
416 | Variable col = lba.col |
---|
417 | WAVE/T/Z listWave = lba.listWave |
---|
418 | WAVE/Z selWave = lba.selWave |
---|
419 | string WinNameStr=lba.win |
---|
420 | string items |
---|
421 | variable i |
---|
422 | NVAR/Z TableIsSaved = root:Packages:SamplePlateSetup:TableIsSaved |
---|
423 | if(!NVAR_Exists(TableIsSaved)) |
---|
424 | variable/g root:Packages:SamplePlateSetup:TableIsSaved |
---|
425 | NVAR TableIsSaved = root:Packages:SamplePlateSetup:TableIsSaved |
---|
426 | endif |
---|
427 | string ListOfSelRows |
---|
428 | variable tempRow, j, firstSelectedRow, NoSelectedRows |
---|
429 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
430 | |
---|
431 | switch( lba.eventCode ) |
---|
432 | case -1: // control being killed |
---|
433 | break |
---|
434 | case 1: // mouse down |
---|
435 | ListOfSelRows=IN3S_CreateListOfRows(selWave) |
---|
436 | firstSelectedRow = str2num(StringFromList(ItemsInList(ListOfSelRows)-1, ListOfSelRows)) |
---|
437 | NoSelectedRows = ItemsInList(ListOfSelRows) |
---|
438 | |
---|
439 | if (lba.eventMod & 0x10) // rightclick |
---|
440 | //items = "Insert new lines;Delete selected lines;Duplicate selected Lines;Set lines as Blank;Set as Dist. Std. AgBehLaB6;Write same Name;" |
---|
441 | //items += "Write same Thickness;Same Sx to all empty;Same Sy to all empty;Increment Sx from selected row;Increment Sy from selected row;" |
---|
442 | //items += "Copy sel. rows to Clipboard;Paste Clipboard to sel. rows;Insert new rows with Clipboard vals.;" |
---|
443 | items = "Copy sel. rows to Clipboard;Paste Clipboard to sel. rows;Insert new rows with Clipboard vals.;" |
---|
444 | items += "Insert new lines;Delete selected lines;Duplicate selected Lines;Write same Name;" |
---|
445 | items += "Write same Thickness;Same Sx to all empty;Same Sy to all empty;Increment Sx from selected row;Increment Sy from selected row;" |
---|
446 | items += "Add to Sx from selected row;Add to Sy from selected row;Set lines as Blank;Set as Dist. Std. AgBehLaB6;" |
---|
447 | PopupContextualMenu items |
---|
448 | // V_flag is index of user selected item |
---|
449 | switch (V_flag) |
---|
450 | case 1: // "Copy in Table Clipboard" |
---|
451 | make/O/T/N=(NoSelectedRows) root:Packages:SamplePlateSetup:TableClipboardWv |
---|
452 | Wave/T TableClipboardWv = root:Packages:SamplePlateSetup:TableClipboardWv |
---|
453 | SVAR TableClipboard = root:Packages:SamplePlateSetup:TableClipboard |
---|
454 | For(j=0;j<NoSelectedRows;j+=1) |
---|
455 | tempRow = str2num(StringFromList(j, ListOfSelRows)) |
---|
456 | TableClipboard = "SampleName="+listWave[tempRow][0]+";" |
---|
457 | TableClipboard += "SX="+listWave[tempRow][1]+";" |
---|
458 | TableClipboard += "SY="+listWave[tempRow][2]+";" |
---|
459 | TableClipboard += "TH="+listWave[tempRow][3]+";" |
---|
460 | TableClipboard += "MD="+listWave[tempRow][4]+";" |
---|
461 | TableClipboardWv[j] = TableClipboard |
---|
462 | endfor |
---|
463 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
464 | WarningForUser = "Copied rows "+ListOfSelRows+ " in Clipboard" |
---|
465 | break; |
---|
466 | case 2: // "Paste Table Clipboard in a row" |
---|
467 | Wave/T/Z TableClipboardWv = root:Packages:SamplePlateSetup:TableClipboardWv |
---|
468 | //check we have clipboard... |
---|
469 | if(!WaveExists(TableClipboardWv)||numpnts(TableClipboardWv)<1) |
---|
470 | Abort "Nothing is stored in Clipboard" |
---|
471 | endif |
---|
472 | //check we have same number of lines selected. |
---|
473 | if(numpnts(TableClipboardWv)>1 && NoSelectedRows!=numpnts(TableClipboardWv)) |
---|
474 | Abort "Number of lines in Clipboard ("+num2str(numpnts(TableClipboardWv))+") does not match number of selected lines in table ("+num2str(NoSelectedRows)+")" |
---|
475 | endif |
---|
476 | //OK, now we should be able to do this... |
---|
477 | SVAR TableClipboard = root:Packages:SamplePlateSetup:TableClipboard |
---|
478 | For(j=0;j<NoSelectedRows;j+=1) |
---|
479 | if(numpnts(TableClipboardWv)>1) |
---|
480 | TableClipboard = TableClipboardWv[j] |
---|
481 | else |
---|
482 | TableClipboard = TableClipboardWv[0] |
---|
483 | endif |
---|
484 | tempRow = str2num(StringFromList(j, ListOfSelRows)) |
---|
485 | listWave[tempRow][0] = StringByKey("SampleName", TableClipboard, "=" , ";") |
---|
486 | listWave[tempRow][1] = StringByKey("SX", TableClipboard, "=" , ";") |
---|
487 | listWave[tempRow][2] = StringByKey("SY", TableClipboard, "=" , ";") |
---|
488 | listWave[tempRow][3] = StringByKey("TH", TableClipboard, "=" , ";") |
---|
489 | listWave[tempRow][4] = StringByKey("USAXS", TableClipboard, "=" , ";") |
---|
490 | listWave[tempRow][5] = StringByKey("SAXS", TableClipboard, "=" , ";") |
---|
491 | listWave[tempRow][6] = StringByKey("WAXS", TableClipboard, "=" , ";") |
---|
492 | listWave[tempRow][7] = StringByKey("MD", TableClipboard, "=" , ";") |
---|
493 | endfor |
---|
494 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
495 | WarningForUser = "Pasted Clipboard vals. from org. rows "+ListOfSelRows |
---|
496 | IN3S_EstimateRunTime() |
---|
497 | TableIsSaved = 0 |
---|
498 | break; |
---|
499 | case 3: // "Insert New rows with Table Clipboard" |
---|
500 | Wave/T/Z TableClipboardWv = root:Packages:SamplePlateSetup:TableClipboardWv |
---|
501 | //check we have clipboard... |
---|
502 | if(!WaveExists(TableClipboardWv)||numpnts(TableClipboardWv)<1) |
---|
503 | Abort "Nothing is stored in Clipboard" |
---|
504 | endif |
---|
505 | SVAR TableClipboard = root:Packages:SamplePlateSetup:TableClipboard |
---|
506 | For(j=0;j<numpnts(TableClipboardWv);j+=1) |
---|
507 | TableClipboard = TableClipboardWv[j] |
---|
508 | tempRow = firstSelectedRow+1 |
---|
509 | IN3S_InsertDeleteLines(1, tempRow,1) |
---|
510 | listWave[tempRow][0] = StringByKey("SampleName", TableClipboard, "=" , ";") |
---|
511 | listWave[tempRow][1] = StringByKey("SX", TableClipboard, "=" , ";") |
---|
512 | listWave[tempRow][2] = StringByKey("SY", TableClipboard, "=" , ";") |
---|
513 | listWave[tempRow][3] = StringByKey("TH", TableClipboard, "=" , ";") |
---|
514 | listWave[tempRow][4] = StringByKey("USAXS", TableClipboard, "=" , ";") |
---|
515 | listWave[tempRow][5] = StringByKey("SAXS", TableClipboard, "=" , ";") |
---|
516 | listWave[tempRow][6] = StringByKey("WAXS", TableClipboard, "=" , ";") |
---|
517 | listWave[tempRow][7] = StringByKey("MD", TableClipboard, "=" , ";") |
---|
518 | endfor |
---|
519 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
520 | WarningForUser = "Inserted "+num2str(numpnts(TableClipboardWv))+" rows with Clipboard (org. rows: "+ListOfSelRows+") " |
---|
521 | IN3S_EstimateRunTime() |
---|
522 | TableIsSaved = 0 |
---|
523 | break; |
---|
524 | case 4: // "Insert new line" |
---|
525 | For(j=0;j<ItemsInList(ListOfSelRows);j+=1) |
---|
526 | tempRow = str2num(StringFromList(j, ListOfSelRows)) |
---|
527 | IN3S_InsertDeleteLines(1, tempRow,1) |
---|
528 | endfor |
---|
529 | WarningForUser = "Inserted rows after numbers "+ ListOfSelRows |
---|
530 | IN3S_EstimateRunTime() |
---|
531 | TableIsSaved = 0 |
---|
532 | break |
---|
533 | case 5: // "Delete selected lines" |
---|
534 | For(j=0;j<ItemsInList(ListOfSelRows);j+=1) |
---|
535 | tempRow = str2num(StringFromList(j, ListOfSelRows)) |
---|
536 | IN3S_InsertDeleteLines(2, tempRow,1) |
---|
537 | endfor |
---|
538 | WarningForUser = "Deleted rows numbers "+ ListOfSelRows |
---|
539 | IN3S_EstimateRunTime() |
---|
540 | TableIsSaved = 0 |
---|
541 | break |
---|
542 | case 6: // "Duplicate selected Line" |
---|
543 | For(j=0;j<ItemsInList(ListOfSelRows);j+=1) |
---|
544 | tempRow = str2num(StringFromList(j, ListOfSelRows)) |
---|
545 | IN3S_InsertDeleteLines(3, tempRow,1) |
---|
546 | endfor |
---|
547 | WarningForUser = "Duplicated rows numbers "+ ListOfSelRows |
---|
548 | IN3S_EstimateRunTime() |
---|
549 | TableIsSaved = 0 |
---|
550 | break |
---|
551 | case 7: // "Write same name" |
---|
552 | string NewSampleName="SampleName" |
---|
553 | string FromWhere = "Selected Rows" |
---|
554 | string AddOrderNumber = "No" |
---|
555 | Prompt NewSampleName, "Write same string in names" |
---|
556 | Prompt FromWhere, "Where to write?", popup "Selected Rows;Empty only;From first selected row;All;" |
---|
557 | Prompt AddOrderNumber, "Add Order numbers (0,1,2,3...)?", popup "No;Yes;" |
---|
558 | DoPrompt /Help="Write same string name" "Default name for all positions", NewSampleName, FromWhere, AddOrderNumber |
---|
559 | if(V_Flag) |
---|
560 | abort |
---|
561 | endif |
---|
562 | string NameStrtemp2="" |
---|
563 | string OrderNumStr="" |
---|
564 | variable OrderNumber=0 |
---|
565 | For(i=0;i<DimSize(listWave,0);i+=1) |
---|
566 | if(StringMatch(FromWhere, "Empty only")) |
---|
567 | if(strlen(listWave[i][0])==0) |
---|
568 | if(StringMatch(AddOrderNumber, "Yes")) |
---|
569 | OrderNumStr=num2str(OrderNumber) |
---|
570 | OrderNumber+=1 |
---|
571 | endif |
---|
572 | if(strlen(NewSampleName)>0) |
---|
573 | listWave[i][0] = CleanupName(NewSampleName, 0 , 40)+OrderNumStr |
---|
574 | else |
---|
575 | listWave[i][0] = ""+OrderNumStr |
---|
576 | endif |
---|
577 | endif |
---|
578 | elseif(StringMatch(FromWhere, "From first selected row")) |
---|
579 | if(i>=firstSelectedRow) |
---|
580 | if(StringMatch(AddOrderNumber, "Yes")) |
---|
581 | OrderNumStr=num2str(OrderNumber) |
---|
582 | OrderNumber+=1 |
---|
583 | endif |
---|
584 | if(strlen(NewSampleName)>0) |
---|
585 | listWave[i][0] = CleanupName(NewSampleName, 0 , 40)+OrderNumStr |
---|
586 | else |
---|
587 | listWave[i][0] = ""+OrderNumStr |
---|
588 | endif |
---|
589 | endif |
---|
590 | elseif(StringMatch(FromWhere, "All")) |
---|
591 | if(StringMatch(AddOrderNumber, "Yes")) |
---|
592 | OrderNumStr=num2str(OrderNumber) |
---|
593 | OrderNumber+=1 |
---|
594 | endif |
---|
595 | if(strlen(NewSampleName)>0) |
---|
596 | listWave[i][0] = CleanupName(NewSampleName, 0 , 40)+OrderNumStr |
---|
597 | else |
---|
598 | listWave[i][0] = ""+OrderNumStr |
---|
599 | endif |
---|
600 | elseif(StringMatch(FromWhere, "Selected Rows")) |
---|
601 | For(j=0;j<ItemsInList(ListOfSelRows);j+=1) |
---|
602 | if(StringMatch(AddOrderNumber, "Yes")) |
---|
603 | OrderNumStr=num2str(ItemsInList(ListOfSelRows)-j-1) |
---|
604 | //OrderNumber+=1 |
---|
605 | endif |
---|
606 | if(strlen(NewSampleName)>0) |
---|
607 | NameStrtemp2 = CleanupName(NewSampleName, 0 , 40)+OrderNumStr |
---|
608 | else |
---|
609 | NameStrtemp2 = ""+OrderNumStr |
---|
610 | endif |
---|
611 | tempRow = str2num(StringFromList(j, ListOfSelRows)) |
---|
612 | listWave[tempRow][0]=NameStrtemp2 |
---|
613 | endfor |
---|
614 | else |
---|
615 | //nothing here... |
---|
616 | endif |
---|
617 | endfor |
---|
618 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
619 | WarningForUser = "Wrote "+CleanupName(NewSampleName, 0 , 40)+" names as requested" |
---|
620 | IN3S_EstimateRunTime() |
---|
621 | TableIsSaved = 0 |
---|
622 | break; |
---|
623 | case 8: // "Write Same Thickness" |
---|
624 | variable newThickness |
---|
625 | NVAR DefSaTh = root:Packages:SamplePlateSetup:DefaultSampleThickness |
---|
626 | newThickness = DefSaTh |
---|
627 | Prompt newThickness, "New Thickness [mm] or NaN for empty" |
---|
628 | string FromWhere2 = "Selected Rows" |
---|
629 | Prompt FromWhere2, "Where to write?", popup "Selected Rows;Empty only;From first selected row;All;" |
---|
630 | DoPrompt /Help="Write new thickness?" "New thickness and where selection", newThickness, FromWhere2 |
---|
631 | if(V_Flag) |
---|
632 | abort |
---|
633 | endif |
---|
634 | For(i=0;i<DimSize(listWave,0);i+=1) |
---|
635 | if(StringMatch(FromWhere2, "Empty only")) |
---|
636 | if(strlen(listWave[i][3])==0) |
---|
637 | if(numtype(newThickness)==0) |
---|
638 | listWave[i][3] = num2str(newThickness) |
---|
639 | else |
---|
640 | listWave[i][3] = "" |
---|
641 | endif |
---|
642 | endif |
---|
643 | elseif(StringMatch(FromWhere2, "From first selected row")) |
---|
644 | if(i>=firstSelectedRow) |
---|
645 | if(numtype(newThickness)==0) |
---|
646 | listWave[i][3] = num2str(newThickness) |
---|
647 | else |
---|
648 | listWave[i][3] = "" |
---|
649 | endif |
---|
650 | endif |
---|
651 | elseif(StringMatch(FromWhere2, "All")) |
---|
652 | if(numtype(newThickness)==0) |
---|
653 | listWave[i][3] = num2str(newThickness) |
---|
654 | else |
---|
655 | listWave[i][3] = "" |
---|
656 | endif |
---|
657 | elseif(StringMatch(FromWhere2, "Selected Rows")) |
---|
658 | For(j=0;j<ItemsInList(ListOfSelRows);j+=1) |
---|
659 | tempRow = str2num(StringFromList(j, ListOfSelRows)) |
---|
660 | if(numtype(newThickness)==0) |
---|
661 | listWave[tempRow][3] = num2str(newThickness) |
---|
662 | else |
---|
663 | listWave[tempRow][3] = "" |
---|
664 | endif |
---|
665 | endfor |
---|
666 | else |
---|
667 | //nothing here... |
---|
668 | endif |
---|
669 | endfor |
---|
670 | TableIsSaved = 0 |
---|
671 | break; |
---|
672 | case 9: // "same sx to all empty" |
---|
673 | variable NewSxForAll=10 |
---|
674 | Prompt NewSxForAll, "Write same SX in all empty lines?" |
---|
675 | DoPrompt /Help="Write same SX position for all empty SX?" "Default sx value for all", NewSxForAll |
---|
676 | if(V_Flag) |
---|
677 | abort |
---|
678 | endif |
---|
679 | For(i=0;i<DimSize(listWave,0);i+=1) |
---|
680 | if(strlen(listWave[i][1])==0) |
---|
681 | listWave[i][1] = num2str(NewSxForAll) |
---|
682 | endif |
---|
683 | endfor |
---|
684 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
685 | WarningForUser = "Wrote "+num2str(NewSxForAll)+" for all samples without SX" |
---|
686 | IN3S_EstimateRunTime() |
---|
687 | TableIsSaved = 0 |
---|
688 | break; |
---|
689 | case 10: // "same sy to all empty" |
---|
690 | variable NewSyForAll=10 |
---|
691 | Prompt NewSyForAll, "Write same SY in all empty lines?" |
---|
692 | DoPrompt /Help="Write same SY position for all empty SY?" "Default sy value for all", NewSyForAll |
---|
693 | if(V_Flag) |
---|
694 | abort |
---|
695 | endif |
---|
696 | For(i=0;i<DimSize(listWave,0);i+=1) |
---|
697 | if(strlen(listWave[i][2])==0) |
---|
698 | listWave[i][2] = num2str(NewSyForAll) |
---|
699 | endif |
---|
700 | endfor |
---|
701 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
702 | WarningForUser = "Wrote "+num2str(NewSyForAll)+" for all samples without SX" |
---|
703 | IN3S_EstimateRunTime() |
---|
704 | TableIsSaved = 0 |
---|
705 | break; |
---|
706 | case 11: // "Increment Sx from selected row" |
---|
707 | variable NewSxStep=10 |
---|
708 | variable sxstart |
---|
709 | Prompt NewSxStep, "Increment SX from first selected row higher?" |
---|
710 | DoPrompt /Help="Increment SX position for all higher rows?" "Input sx step", NewSxStep |
---|
711 | if(V_Flag) |
---|
712 | abort |
---|
713 | endif |
---|
714 | if(numtype(str2num(listWave[firstSelectedRow][1]))==0) |
---|
715 | sxstart = str2num(listWave[firstSelectedRow][1]) |
---|
716 | else |
---|
717 | sxstart = 0 |
---|
718 | endif |
---|
719 | For(i=firstSelectedRow;i<DimSize(listWave,0);i+=1) |
---|
720 | listWave[i][1] = num2str(sxstart+(i-firstSelectedRow)*NewSxStep) |
---|
721 | endfor |
---|
722 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
723 | WarningForUser = "Calculated new sx for row higher than : " +num2str(row) |
---|
724 | IN3S_EstimateRunTime() |
---|
725 | TableIsSaved = 0 |
---|
726 | break; |
---|
727 | case 12: // "Increment Sy from selected row" |
---|
728 | variable NewSyStep=10 |
---|
729 | variable systart |
---|
730 | Prompt NewSyStep, "Increment SY from selected row higher?" |
---|
731 | DoPrompt /Help="Increment SY position for all higher rows?" "Input sy step", NewSyStep |
---|
732 | if(V_Flag) |
---|
733 | abort |
---|
734 | endif |
---|
735 | if(numtype(str2num(listWave[firstSelectedRow][2]))==0) |
---|
736 | systart = str2num(listWave[firstSelectedRow][2]) |
---|
737 | else |
---|
738 | systart = 0 |
---|
739 | endif |
---|
740 | For(i=firstSelectedRow;i<DimSize(listWave,0);i+=1) |
---|
741 | listWave[i][2] = num2str(systart+(i-firstSelectedRow)*NewSyStep) |
---|
742 | endfor |
---|
743 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
744 | WarningForUser = "Calculated new sy for all samples" |
---|
745 | IN3S_EstimateRunTime() |
---|
746 | TableIsSaved = 0 |
---|
747 | break; |
---|
748 | case 13: // "Add to sx from first selected row" |
---|
749 | variable AddValue=0 |
---|
750 | Prompt AddValue, "Add value to Sx from first selected row ?" |
---|
751 | DoPrompt /Help="Add value SX position for all higher rows?" "Add value to sx", AddValue |
---|
752 | if(V_Flag) |
---|
753 | abort |
---|
754 | endif |
---|
755 | //if(numtype(str2num(listWave[firstSelectedRow][1]))==0) |
---|
756 | // sxstart = str2num(listWave[firstSelectedRow][1]) |
---|
757 | //else |
---|
758 | // sxstart = 0 |
---|
759 | //endif |
---|
760 | For(i=firstSelectedRow;i<DimSize(listWave,0);i+=1) |
---|
761 | listWave[i][1] = num2str(str2num(listWave[i][1])+AddValue) |
---|
762 | endfor |
---|
763 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
764 | WarningForUser = "Calculated new sx for row higher than : " +num2str(row) |
---|
765 | IN3S_EstimateRunTime() |
---|
766 | TableIsSaved = 0 |
---|
767 | break; |
---|
768 | case 14: // "Add to sy from first selected row" |
---|
769 | variable AddValueY=0 |
---|
770 | Prompt AddValueY, "Add value to Sy from first selected row ?" |
---|
771 | DoPrompt /Help="Add value Sy position for all higher rows?" "Add value to Sy", AddValueY |
---|
772 | if(V_Flag) |
---|
773 | abort |
---|
774 | endif |
---|
775 | For(i=firstSelectedRow;i<DimSize(listWave,0);i+=1) |
---|
776 | listWave[i][2] = num2str(str2num(listWave[i][2])+AddValueY) |
---|
777 | endfor |
---|
778 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
779 | WarningForUser = "Calculated new sy for row higher than : " +num2str(row) |
---|
780 | IN3S_EstimateRunTime() |
---|
781 | TableIsSaved = 0 |
---|
782 | break; |
---|
783 | case 15: // "Set line as Blank" |
---|
784 | For(j=0;j<ItemsInList(ListOfSelRows);j+=1) |
---|
785 | tempRow = str2num(StringFromList(j, ListOfSelRows)) |
---|
786 | listWave[tempRow][0]="Blank" |
---|
787 | listWave[tempRow][3]="0" |
---|
788 | endfor |
---|
789 | WarningForUser = "Set rows "+ListOfSelRows+" as Blank" |
---|
790 | IN3S_EstimateRunTime() |
---|
791 | TableIsSaved = 0 |
---|
792 | break |
---|
793 | case 16: // "Set Line as Distance Standard" |
---|
794 | For(j=0;j<ItemsInList(ListOfSelRows);j+=1) |
---|
795 | tempRow = str2num(StringFromList(j, ListOfSelRows)) |
---|
796 | listWave[tempRow][0]="AgBehenateLaB6" |
---|
797 | listWave[tempRow][3]="1" |
---|
798 | endfor |
---|
799 | WarningForUser = "Set rows "+ListOfSelRows+" as AgBehenateLaB6" |
---|
800 | NVAR USAXSAll=root:Packages:SamplePlateSetup:USAXSAll |
---|
801 | USAXSAll=0 |
---|
802 | IN3S_EstimateRunTime() |
---|
803 | TableIsSaved = 0 |
---|
804 | break |
---|
805 | default : // "Sort" |
---|
806 | //DataSelSortString = StringFromList(V_flag-1, items) |
---|
807 | //PopupMenu SortOptionString,win=$(TopPanel), mode=1,popvalue=DataSelSortString |
---|
808 | //IR3C_SortListOfFilesInWvs(TopPanel) |
---|
809 | break; |
---|
810 | endswitch |
---|
811 | else //left click, do something here... |
---|
812 | |
---|
813 | endif |
---|
814 | IN3S_FixSaveButton() |
---|
815 | break |
---|
816 | case 3: // double click |
---|
817 | |
---|
818 | break |
---|
819 | case 4: // cell selection |
---|
820 | IN3S_AddTagToImage(row) |
---|
821 | //sync to Bealine setup, if exists... |
---|
822 | DoWIndow BeamlinePlateSetup |
---|
823 | if(V_Flag) |
---|
824 | NVAR SelectedRow=root:Packages:SamplePlateSetup:SelectedRow |
---|
825 | SVAR SelectedSampleName=root:Packages:SamplePlateSetup:SelectedSampleName |
---|
826 | Wave/T ListWV = root:Packages:SamplePlateSetup:LBCommandWv |
---|
827 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
828 | NVAR SampleThickness=root:Packages:SamplePlateSetup:SampleThickness |
---|
829 | NVAR SampleXTAR=root:Packages:SamplePlateSetup:SampleXTAR |
---|
830 | NVAR SampleYTAR=root:Packages:SamplePlateSetup:SampleYTAR |
---|
831 | NVAR SampleXTable = root:Packages:SamplePlateSetup:SampleXTable |
---|
832 | NVAR SampleYTable = root:Packages:SamplePlateSetup:SampleYTable |
---|
833 | NVAR defTh=root:Packages:SamplePlateSetup:DefaultSampleThickness |
---|
834 | if(row>=0&& row<DimSize(ListWV, 0)) |
---|
835 | SelectedRow=row |
---|
836 | SelectedSampleName = ListWV[SelectedRow][0] |
---|
837 | //ListBox CommandsList, win=SamplePlateSetup, selrow=SelectedRow |
---|
838 | LBSelectionWv[][0]=2 |
---|
839 | LBSelectionWv[SelectedRow][0]=3 |
---|
840 | SampleXTable = str2num(ListWV[SelectedRow][1]) |
---|
841 | SampleYTable = str2num(ListWV[SelectedRow][2]) |
---|
842 | SampleThickness = str2num(ListWV[SelectedRow][3]) |
---|
843 | SampleThickness = numtype(SampleThickness)==0 ? SampleThickness : defTh |
---|
844 | endif |
---|
845 | IN3S_MoveToPositionIfOK() |
---|
846 | endif |
---|
847 | break |
---|
848 | case 5: // cell selection plus shift key |
---|
849 | break |
---|
850 | case 6: // begin edit |
---|
851 | break |
---|
852 | case 7: // finish edit |
---|
853 | //cleanup the name, if Column 0 |
---|
854 | if(col==0) |
---|
855 | string Username=listWave[row][col] |
---|
856 | if(strlen(Username)>0) |
---|
857 | listWave[row][col] = CleanupName(Username, 0 , 40) |
---|
858 | DoWIndow BeamlinePlateSetup |
---|
859 | if(V_Flag) |
---|
860 | SVAR SelectedSampleName = root:Packages:SamplePlateSetup:SelectedSampleName |
---|
861 | SelectedSampleName = listWave[row][col] |
---|
862 | endif |
---|
863 | endif |
---|
864 | endif |
---|
865 | //cleanup the numbers for sx, sy and thickness... |
---|
866 | if(col>0 && col<4) |
---|
867 | string valueStrFromUser=listWave[row][col] |
---|
868 | if(strlen(valueStrFromUser)>0) |
---|
869 | variable valueNumFromUser = str2num(valueStrFromUser) |
---|
870 | if(numtype(valueNumFromUser)==0) //something is number... |
---|
871 | listWave[row][col] = num2str(IN2G_roundDecimalPlaces(valueNumFromUser,3)) |
---|
872 | DoWIndow BeamlinePlateSetup |
---|
873 | if(V_Flag) |
---|
874 | NVAR SampleXTable = root:Packages:SamplePlateSetup:SampleXTable |
---|
875 | NVAR SampleYTable = root:Packages:SamplePlateSetup:SampleYTable |
---|
876 | NVAR Thick=root:Packages:SamplePlateSetup:SampleThickness |
---|
877 | if(col==1) |
---|
878 | SampleXTable = IN2G_roundDecimalPlaces(valueNumFromUser,2) |
---|
879 | IN3S_MoveToPositionIfOK() |
---|
880 | elseif(col==2) |
---|
881 | SampleYTable = IN2G_roundDecimalPlaces(valueNumFromUser,2) |
---|
882 | IN3S_MoveToPositionIfOK() |
---|
883 | elseif(col==3) |
---|
884 | Thick = IN2G_roundDecimalPlaces(valueNumFromUser,3) |
---|
885 | endif |
---|
886 | endif |
---|
887 | else |
---|
888 | listWave[row][col] = "" |
---|
889 | Abort "Input was not valid number, try again" |
---|
890 | endif |
---|
891 | endif |
---|
892 | endif |
---|
893 | //add tag |
---|
894 | IN3S_AddTagToImage(row) |
---|
895 | IN3S_EstimateRunTime() |
---|
896 | TableIsSaved = 0 |
---|
897 | IN3S_FixSaveButton() |
---|
898 | break |
---|
899 | case 13: // checkbox clicked (Igor 6.2 or later) |
---|
900 | //here we need to deal with what happens when user clicks on selection of checkboxes... |
---|
901 | NVAR USAXSAll = root:Packages:SamplePlateSetup:USAXSAll |
---|
902 | NVAR SAXSAll = root:Packages:SamplePlateSetup:SAXSAll |
---|
903 | NVAR WAXSAll = root:Packages:SamplePlateSetup:WAXSAll |
---|
904 | if(lba.col==4) //USAXS |
---|
905 | USAXSAll = 0 |
---|
906 | elseif(lba.col==5) //SAXS |
---|
907 | SAXSAll = 0 |
---|
908 | elseif(lba.col==6) //WAXS |
---|
909 | WAXSAll = 0 |
---|
910 | else |
---|
911 | |
---|
912 | endif |
---|
913 | break |
---|
914 | endswitch |
---|
915 | |
---|
916 | return 0 |
---|
917 | end |
---|
918 | //************************************************************************************************************ |
---|
919 | //************************************************************************************************************ |
---|
920 | |
---|
921 | Function IN3S_PopMenuProc(pa) : PopupMenuControl |
---|
922 | STRUCT WMPopupAction &pa |
---|
923 | |
---|
924 | switch( pa.eventCode ) |
---|
925 | case 2: // mouse up |
---|
926 | Variable popNum = pa.popNum |
---|
927 | String popStr = pa.popStr |
---|
928 | if(StringMatch(pa.ctrlName, "NewPlateTemplate")) |
---|
929 | SVAR SelectedPlateName=root:Packages:SamplePlateSetup:SelectedPlateName |
---|
930 | SelectedPlateName = popStr |
---|
931 | endif |
---|
932 | |
---|
933 | if(StringMatch(pa.ctrlName, "ExportOrderPop")) |
---|
934 | SVAR ExportOrder=root:Packages:SamplePlateSetup:ExportOrder |
---|
935 | ExportOrder = popStr |
---|
936 | endif |
---|
937 | |
---|
938 | break |
---|
939 | case -1: // control being killed |
---|
940 | break |
---|
941 | endswitch |
---|
942 | |
---|
943 | return 0 |
---|
944 | End |
---|
945 | //************************************************************************************************************ |
---|
946 | //************************************************************************************************************ |
---|
947 | |
---|
948 | Function IN3S_ButtonProc(ba) : ButtonControl |
---|
949 | STRUCT WMButtonAction &ba |
---|
950 | |
---|
951 | switch( ba.eventCode ) |
---|
952 | case 2: // mouse up |
---|
953 | NVAR TableIsSaved = root:Packages:SamplePlateSetup:TableIsSaved |
---|
954 | |
---|
955 | if(StringMatch(ba.ctrlName, "CreateNewSet" )) |
---|
956 | DoAlert/T="This will delete your existing data" 1, "New Sample positions will be created and existing one deleted, Do you want to continue?" |
---|
957 | if(V_Flag==1) //yes... |
---|
958 | NVAR NumberOfSamplesToCreate = root:Packages:SamplePlateSetup:NumberOfSamplesToCreate |
---|
959 | IN3S_CreateTablesForPlates(NumberOfSamplesToCreate, 1) |
---|
960 | SVAR NewPlateName = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
961 | NewPlateName = "NewSampleSet"+num2str(abs(round(gnoise(100)))) |
---|
962 | //ListBox CommandsList win=SamplePlateSetup, selRow=0 |
---|
963 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
964 | LBSelectionWv[][0]=2 |
---|
965 | LBSelectionWv[0][0]=3 |
---|
966 | IN3S_AddTagToImage(0) |
---|
967 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
968 | WarningForUser = "Created a new set of positions" |
---|
969 | IN3S_EstimateRunTime() |
---|
970 | TableIsSaved = 0 |
---|
971 | endif |
---|
972 | endif |
---|
973 | if(StringMatch(ba.ctrlName, "CreateImage" )) |
---|
974 | KillWindow/Z TrimCorrectImageDrawing |
---|
975 | SVAR SelectedPlateName = root:Packages:SamplePlateSetup:SelectedPlateName |
---|
976 | IN3S_DrawImageOfPlate(SelectedPlateName) |
---|
977 | AutoPositionWindow/M=0 /R=SamplePlateSetup SamplePlateImageDrawing |
---|
978 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
979 | ControlInfo/W=SamplePlateSetup CommandsList |
---|
980 | if(V_Flag>=0 && V_Flag<dimsize(LBCommandWv,0)) |
---|
981 | IN3S_AddTagToImage(V_Value) |
---|
982 | else |
---|
983 | IN3S_AddTagToImage(-4) //remove all drawings, if needed |
---|
984 | endif |
---|
985 | endif |
---|
986 | |
---|
987 | if(StringMatch(ba.ctrlName, "TrimImportedImage" )) |
---|
988 | IN3S_TrimAndStraightenImage() |
---|
989 | endif |
---|
990 | |
---|
991 | if(StringMatch(ba.ctrlName, "ImportImage" )) |
---|
992 | KillWindow/Z TrimCorrectImageDrawing |
---|
993 | IN3S_ImportImageOfPlate() |
---|
994 | endif |
---|
995 | if(StringMatch(ba.ctrlName, "ImportFile" )) |
---|
996 | //KillWindow/Z TrimCorrectImageDrawing |
---|
997 | IN3S_ImportFile() |
---|
998 | endif |
---|
999 | |
---|
1000 | if(StringMatch(ba.ctrlName, "DisplayHookFunction" )) |
---|
1001 | //DisplayProcedure "IN3S_ExportHookFunction" |
---|
1002 | IN3_InsertHookIntoMainProc() |
---|
1003 | endif |
---|
1004 | |
---|
1005 | |
---|
1006 | if(StringMatch(ba.ctrlName, "PopulateTable" )) |
---|
1007 | //populate table with positions |
---|
1008 | DoAlert/T="This will delete your existing data" 1, "New Sample positions will be created and existing one deleted, Do you want to continue?" |
---|
1009 | if(V_Flag==1) //yes... |
---|
1010 | KillWindow/Z TrimCorrectImageDrawing |
---|
1011 | SVAR SelectedPlateName=root:Packages:SamplePlateSetup:SelectedPlateName |
---|
1012 | NVAR USAXSAll=root:Packages:SamplePlateSetup:USAXSAll |
---|
1013 | NVAR SAXSAll=root:Packages:SamplePlateSetup:SAXSAll |
---|
1014 | NVAR WAXSAll=root:Packages:SamplePlateSetup:WAXSAll |
---|
1015 | SVAR NewPlateName = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1016 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1017 | USAXSAll= 1 |
---|
1018 | SAXSAll = 1 |
---|
1019 | WAXSAll = 1 |
---|
1020 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
1021 | strswitch (SelectedPlateName) |
---|
1022 | case "9x9 Acrylic/magnetic plate": |
---|
1023 | Wave Centers = root:Packages:SamplePlatesAvailable:Acrylic9x9PlateCenters |
---|
1024 | //create enough space: |
---|
1025 | IN3S_CreateTablesForPlates(DimSize(Centers, 0 ), 0) |
---|
1026 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
1027 | LBCommandWv[][1]=num2str(Centers[p][0]) |
---|
1028 | LBCommandWv[][2]=num2str(Centers[p][1]) |
---|
1029 | LBCommandWv[][0]="" |
---|
1030 | LBCommandWv[0][0]="Empty for LaB6AgBehehnate" |
---|
1031 | LBCommandWv[1][0]="AirBlank" |
---|
1032 | NewPlateName = "AcrylicPlateSet"+num2str(abs(round(gnoise(100)))) |
---|
1033 | //select first row |
---|
1034 | LBSelectionWv[][0]=2 |
---|
1035 | LBSelectionWv[0][0]=3 |
---|
1036 | WarningForUser = "Created a new set of positions for "+ SelectedPlateName |
---|
1037 | IN3S_EstimateRunTime() |
---|
1038 | break // exit from switch |
---|
1039 | case "NMR Acrylic plate": |
---|
1040 | Wave Centers = root:Packages:SamplePlatesAvailable:AcrylicNMRPlateCenters |
---|
1041 | //create enough space: |
---|
1042 | IN3S_CreateTablesForPlates(DimSize(Centers, 0 ), 0) |
---|
1043 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
1044 | LBCommandWv[][1]=num2str(Centers[p][0]) |
---|
1045 | LBCommandWv[][2]=num2str(Centers[p][1]) |
---|
1046 | LBCommandWv[][0]="" |
---|
1047 | LBCommandWv[0][0]="Empty for LaB6AgBehehnate" |
---|
1048 | LBCommandWv[1][0]="NMRTubeBlank" |
---|
1049 | //SVAR NewPlateName = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1050 | NewPlateName = "AcrylicPlateSet"+num2str(abs(round(gnoise(100)))) |
---|
1051 | //select first row |
---|
1052 | //ListBox CommandsList win=SamplePlateSetup, selRow=1 |
---|
1053 | LBSelectionWv[][0]=2 |
---|
1054 | LBSelectionWv[0][0]=3 |
---|
1055 | //SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1056 | WarningForUser = "Created a new set of positions for "+ SelectedPlateName |
---|
1057 | IN3S_EstimateRunTime() |
---|
1058 | break // exit from switch |
---|
1059 | case "Old Style Al Plate": |
---|
1060 | Wave Centers = root:Packages:SamplePlatesAvailable:OldStyleAlPlateCenters |
---|
1061 | //create enough space: |
---|
1062 | IN3S_CreateTablesForPlates(DimSize(Centers, 0 ), 0) |
---|
1063 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
1064 | LBCommandWv[][1]=num2str(Centers[p][0]) |
---|
1065 | LBCommandWv[][2]=num2str(Centers[p][1]) |
---|
1066 | LBCommandWv[][0]="" |
---|
1067 | LBCommandWv[0][0]="Empty for LaB6AgBehehnate" |
---|
1068 | LBCommandWv[1][0]="AirBlank" |
---|
1069 | //SVAR NewPlateName = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1070 | NewPlateName = "AlPlateSet"+num2str(abs(round(gnoise(100)))) |
---|
1071 | ListBox CommandsList win=SamplePlateSetup, selRow=1 |
---|
1072 | //SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1073 | WarningForUser = "Created a new set of positions for "+ SelectedPlateName |
---|
1074 | IN3S_EstimateRunTime() |
---|
1075 | break // exit from switch |
---|
1076 | case "NMR Tubes holder": |
---|
1077 | Wave Centers = root:Packages:SamplePlatesAvailable:NMRTubesHolderCenters |
---|
1078 | //create enough space: |
---|
1079 | IN3S_CreateTablesForPlates(DimSize(Centers, 0 ), 0) |
---|
1080 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
1081 | LBCommandWv[][0]="" |
---|
1082 | LBCommandWv[][1]=num2str(Centers[p][0]) |
---|
1083 | LBCommandWv[][2]=num2str(Centers[p][1]) |
---|
1084 | //SVAR NewPlateName = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1085 | NewPlateName = "NMRTubesSet"+num2str(abs(round(gnoise(100)))) |
---|
1086 | ListBox CommandsList win=SamplePlateSetup, selRow=1 |
---|
1087 | //SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1088 | WarningForUser = "Created a new set of positions for "+ SelectedPlateName |
---|
1089 | IN3S_EstimateRunTime() |
---|
1090 | break // exit from switch |
---|
1091 | case "NMR Tubes heater": |
---|
1092 | Wave Centers = root:Packages:SamplePlatesAvailable:NMRTubesHolderCenters |
---|
1093 | //create enough space: |
---|
1094 | IN3S_CreateTablesForPlates(DimSize(Centers, 0 ), 0) |
---|
1095 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
1096 | LBCommandWv[][0]="" |
---|
1097 | LBCommandWv[][1]=num2str(Centers[p][0]) |
---|
1098 | LBCommandWv[][2]=num2str(Centers[p][1]) |
---|
1099 | //SVAR NewPlateName = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1100 | NewPlateName = "NMRTubesSet"+num2str(abs(round(gnoise(100)))) |
---|
1101 | ListBox CommandsList win=SamplePlateSetup, selRow=1 |
---|
1102 | //SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1103 | WarningForUser = "Created a new set of positions for "+ SelectedPlateName |
---|
1104 | IN3S_EstimateRunTime() |
---|
1105 | break // exit from switch |
---|
1106 | case "Generic Grid holder": |
---|
1107 | Wave Centers = root:Packages:SamplePlatesAvailable:GenericGridHolderCenters |
---|
1108 | //get from user needed information |
---|
1109 | variable SX0=0, SY0=0, NX=5, NY=5, DX=10, DY=10 |
---|
1110 | Prompt SX0, "Input sx for first center: " |
---|
1111 | Prompt SY0, "Input sy for first center: " |
---|
1112 | Prompt NX, "Number of points horizontal : " |
---|
1113 | Prompt NY, "Number of points vertical : " |
---|
1114 | Prompt DX, "Step in x (horizontal) : " |
---|
1115 | Prompt DY, "Step in y (vertical) : " |
---|
1116 | DoPrompt "Define grid start, point numebrs and steps", SX0, SY0, NX, NY, DX, DY |
---|
1117 | if(V_Flag) |
---|
1118 | abort |
---|
1119 | endif |
---|
1120 | redimension/N=(NX*NY,2) Centers |
---|
1121 | variable i, j, ict |
---|
1122 | ict=0 |
---|
1123 | FOr(i=0;i<NX;i+=1) |
---|
1124 | For(j=0;j<NY;j+=1) |
---|
1125 | Centers[ict][0]=SX0+i*DX |
---|
1126 | Centers[ict][1]=SY0+j*DY |
---|
1127 | ict+=1 |
---|
1128 | endfor |
---|
1129 | endfor |
---|
1130 | IN3S_CreateTablesForPlates(DimSize(Centers, 0 ), 0) |
---|
1131 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
1132 | LBCommandWv[][1]=num2str(Centers[p][0]) |
---|
1133 | LBCommandWv[][2]=num2str(Centers[p][1]) |
---|
1134 | LBCommandWv[][0]="" |
---|
1135 | LBCommandWv[0][0]="" |
---|
1136 | LBCommandWv[1][0]="" |
---|
1137 | SVAR NewPlateName = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1138 | NewPlateName = "GenericPlateSet"+num2str(abs(round(gnoise(100)))) |
---|
1139 | //ListBox CommandsList win=SamplePlateSetup, selRow=1 |
---|
1140 | LBSelectionWv[][0]=2 |
---|
1141 | LBSelectionWv[0][0]=3 |
---|
1142 | //SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1143 | WarningForUser = "Created a new set of positions for "+ SelectedPlateName |
---|
1144 | IN3S_EstimateRunTime() |
---|
1145 | break // exit from switch |
---|
1146 | case "AgBehenateLaB6": |
---|
1147 | IN3S_CreateTablesForPlates(1, 1) |
---|
1148 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
1149 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
1150 | LBCommandWv[][0]="AgBehenateLaB6" |
---|
1151 | LBCommandWv[][1]="20" |
---|
1152 | LBCommandWv[][2]="20" |
---|
1153 | LBCommandWv[][3]="1" |
---|
1154 | LBSelectionWv[][4]=32 |
---|
1155 | LBSelectionWv[][5]=48 |
---|
1156 | LBSelectionWv[][6]=48 |
---|
1157 | //SVAR NewPlateName = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1158 | NewPlateName = "Standard" |
---|
1159 | //NVAR USAXSAll=root:Packages:SamplePlateSetup:USAXSAll |
---|
1160 | USAXSAll=0 |
---|
1161 | //SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1162 | WarningForUser = "Created AgBehenateLaB6 and disabled USAXS" |
---|
1163 | break // exit from switch |
---|
1164 | case "Image": |
---|
1165 | //nothing to do here... |
---|
1166 | //here is code which loads image and deal with that. this will be different code and complciated. |
---|
1167 | |
---|
1168 | break |
---|
1169 | case "Another Plate": |
---|
1170 | // <code> |
---|
1171 | break |
---|
1172 | default: |
---|
1173 | // <code>] // when no case matches |
---|
1174 | endswitch |
---|
1175 | IN3S_AddTagToImage(-4) //remove all drawings, if needed |
---|
1176 | TableIsSaved = 0 |
---|
1177 | endif |
---|
1178 | endif |
---|
1179 | |
---|
1180 | if(StringMatch(ba.ctrlName, "AddMoreLines" )) |
---|
1181 | NVAR NewLines=root:Packages:SamplePlateSetup:NumberOfSamplesToCreate |
---|
1182 | IN3S_InsertDeleteLines(4, 0, NewLines) |
---|
1183 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1184 | WarningForUser = "Added "+num2str(NewLines)+" new lines" |
---|
1185 | IN3S_EstimateRunTime() |
---|
1186 | TableIsSaved = 0 |
---|
1187 | endif |
---|
1188 | if(StringMatch(ba.ctrlName, "SavePositionSet" )) |
---|
1189 | IN3S_SaveCurrentSampleSet(0,1) |
---|
1190 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1191 | WarningForUser = "Saved set of positions" |
---|
1192 | TableIsSaved = 1 |
---|
1193 | endif |
---|
1194 | if(StringMatch(ba.ctrlName, "LoadSavedSet" )) |
---|
1195 | ControlInfo /W=SamplePlateSetup SelectSavedSet |
---|
1196 | string SelectedFolder=S_Value |
---|
1197 | if(StringMatch(SelectedFolder, "---" )) |
---|
1198 | return 0 |
---|
1199 | endif |
---|
1200 | if(TableIsSaved<0.5) |
---|
1201 | DoAlert/T="This will overwrite your existing set of positions !!! " 1, "Existing set is not saved! New set of Sample positions will be created and existing one deleted. Do you want to continue?" |
---|
1202 | if(V_Flag==1) //yes... |
---|
1203 | //KillWIndow/Z SamplePlateImageDrawing |
---|
1204 | IN3S_LoadSavedSampleSet() |
---|
1205 | endif |
---|
1206 | else |
---|
1207 | IN3S_LoadSavedSampleSet() |
---|
1208 | endif |
---|
1209 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1210 | WarningForUser = "Loaded set of positions for "+SelectedFolder |
---|
1211 | IN3S_EstimateRunTime() |
---|
1212 | TableIsSaved = 1 |
---|
1213 | endif |
---|
1214 | if(StringMatch(ba.ctrlName, "PreviewCommandFile" )) |
---|
1215 | IN3S_CheckForSensibility() |
---|
1216 | IN3S_WriteCommandFile(1,1) |
---|
1217 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1218 | WarningForUser = "Created Notebook with commands for review" |
---|
1219 | endif |
---|
1220 | string newName |
---|
1221 | if(StringMatch(ba.ctrlName, "ExportCommandFile" )) |
---|
1222 | //here we need to save that notebook somewhere |
---|
1223 | newName = IN3S_ExportMacroFile(0,0) |
---|
1224 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1225 | WarningForUser = "Exported usaxs.mac on your desktop" |
---|
1226 | IN3_FTPUSAXSMacFile() |
---|
1227 | endif |
---|
1228 | if(StringMatch(ba.ctrlName, "ExportCommandFile2" )) |
---|
1229 | //here we need to save that notebook somewhere |
---|
1230 | newName = IN3S_ExportMacroFile(1,0) |
---|
1231 | if(strlen(newName)>0) |
---|
1232 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1233 | WarningForUser = "Exported command file as "+newName |
---|
1234 | else |
---|
1235 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1236 | WarningForUser = "Command file export was cancelled" |
---|
1237 | endif |
---|
1238 | endif |
---|
1239 | if(StringMatch(ba.ctrlName, "AppendToCommandFile" )) |
---|
1240 | newName = IN3S_ExportMacroFile(0,1) |
---|
1241 | if(strlen(newName)>0) |
---|
1242 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1243 | WarningForUser = "Appended to command file "+newName |
---|
1244 | IN3_FTPUSAXSMacFile() |
---|
1245 | else |
---|
1246 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
1247 | WarningForUser = "Append To Command file export was cancelled" |
---|
1248 | endif |
---|
1249 | endif |
---|
1250 | |
---|
1251 | if(StringMatch(ba.ctrlName, "BeamlineSurvey" )) |
---|
1252 | KillWindow/Z TrimCorrectImageDrawing |
---|
1253 | IN3S_BeamlineSurvey() |
---|
1254 | endif |
---|
1255 | if(StringMatch(ba.ctrlName, "GetHelp" )) |
---|
1256 | //https://saxs-igorcodedocs.readthedocs.io/en/latest/Indra/SamplePlateSurvey.html |
---|
1257 | //Open www manual with the right page |
---|
1258 | IN2G_OpenWebManual("Indra/SamplePlateSurvey.html") |
---|
1259 | endif |
---|
1260 | |
---|
1261 | IN3S_FixSaveButton() |
---|
1262 | |
---|
1263 | break |
---|
1264 | case -1: // control being killed |
---|
1265 | break |
---|
1266 | endswitch |
---|
1267 | return 0 |
---|
1268 | End |
---|
1269 | //************************************************************************************************************ |
---|
1270 | static Function IN3_InsertHookIntoMainProc() |
---|
1271 | //figure out if we have the hook function in main package or already in main Proc window |
---|
1272 | string FuncInfo = FunctionInfo("IN3S_ExportHookFunction") |
---|
1273 | //PROCWIN:IN3_SamplePlate.ipf |
---|
1274 | if(StringMatch(StringByKey("PROCWIN", FuncInfo), "IN3_SamplePlate.ipf" )) |
---|
1275 | //original location, need to create override function. Or |
---|
1276 | String currScrap = GetScrapText() // copy current scrap text |
---|
1277 | DisplayProcedure/W=Procedure |
---|
1278 | DoIgorMenu "Edit" "Select All" |
---|
1279 | DoIgorMenu "Edit" "Copy" |
---|
1280 | string existingProCode=GetScrapText() // modify procedure code |
---|
1281 | String newCode = existingProCode + "\r\roverride "+ProcedureText("IN3S_ExportHookFunction") // modify procedure code |
---|
1282 | PutScrapText newCode // new code in clipboard... |
---|
1283 | DoIgorMenu "Edit" "Paste" //put in main proc window. |
---|
1284 | PutScrapText currScrap // put previous scrap text back |
---|
1285 | Execute/P/Q/Z "COMPILEPROCEDURES " // recompile all |
---|
1286 | HideProcedures // hide all procedure windows |
---|
1287 | endif |
---|
1288 | DisplayProcedure/W=Procedure |
---|
1289 | //DisplayProcedure "IN3S_ExportHookFunction" |
---|
1290 | End |
---|
1291 | //************************************************************************************************************ |
---|
1292 | |
---|
1293 | Function IN3_FTPUSAXSMacFile() |
---|
1294 | //look for ftp batch file and if available and instrument is not running, upload usaxs.mac from desktop. |
---|
1295 | |
---|
1296 | GetfileFolderInfo/Q/Z "C:Users:usaxs:Documents:WinSCP:putUSAXSMacFile.bat" |
---|
1297 | if(V_Flag!=0) |
---|
1298 | return 0 |
---|
1299 | else |
---|
1300 | GetfileFolderInfo/Q/Z "C:Users:usaxs:Desktop:usaxs.mac" |
---|
1301 | if(V_Flag!=0) |
---|
1302 | DoAlert /T="sftp error" 0, "usaxs.mac was not found on the desktop" |
---|
1303 | else |
---|
1304 | IN3S_BeramlineSurveyAbortIfNeeded("Cannot sftp usaxs.mac") //this will abort if instrument is running. |
---|
1305 | DoAlert /T="Sftp usaxs.mac to usaxscontrol?" 1, "Do you want to sftp new usaxs.mac to usaxscontrol? Existing one will be overwritten!" |
---|
1306 | if(V_Flag==1) |
---|
1307 | ExecuteScriptText /W=5 "\"C:\\Users\\usaxs\\Documents\\WinSCP\\putUSAXSMacFile.bat\"" |
---|
1308 | endif |
---|
1309 | endif |
---|
1310 | |
---|
1311 | endif |
---|
1312 | |
---|
1313 | end |
---|
1314 | //************************************************************************************************************ |
---|
1315 | //************************************************************************************************************ |
---|
1316 | |
---|
1317 | |
---|
1318 | Function IN3S_CheckProc(cba) : CheckBoxControl |
---|
1319 | STRUCT WMCheckboxAction &cba |
---|
1320 | |
---|
1321 | switch( cba.eventCode ) |
---|
1322 | case 2: // mouse up |
---|
1323 | Variable checked = cba.checked |
---|
1324 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
1325 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
1326 | NVAR WAXSAll = root:Packages:SamplePlateSetup:WAXSAll |
---|
1327 | NVAR USAXSAll = root:Packages:SamplePlateSetup:USAXSAll |
---|
1328 | NVAR SAXSAll = root:Packages:SamplePlateSetup:SAXSAll |
---|
1329 | NVAR ExportCurrentPosSet = root:Packages:SamplePlateSetup:ExportCurrentPosSet |
---|
1330 | NVAR ExportListOfPosSets = root:Packages:SamplePlateSetup:ExportListOfPosSets |
---|
1331 | |
---|
1332 | STRUCT WMTabControlAction tca |
---|
1333 | |
---|
1334 | if(stringmatch(cba.ctrlName,"ExportCurrentPosSet")) |
---|
1335 | ExportListOfPosSets = !ExportCurrentPosSet |
---|
1336 | tca.eventCode=2 |
---|
1337 | tca.tab = 2 |
---|
1338 | IN3S_TableTabsTabProc(tca) |
---|
1339 | endif |
---|
1340 | if(stringmatch(cba.ctrlName,"ExportListOfPosSets")) |
---|
1341 | ExportCurrentPosSet = !ExportListOfPosSets |
---|
1342 | tca.eventCode=2 |
---|
1343 | tca.tab = 2 |
---|
1344 | IN3S_TableTabsTabProc(tca) |
---|
1345 | endif |
---|
1346 | if(stringmatch(cba.ctrlName,"USAXSAll")) |
---|
1347 | if(USAXSAll) |
---|
1348 | LBSelectionWv[][4]=48 |
---|
1349 | else |
---|
1350 | LBSelectionWv[][4]=32 |
---|
1351 | endif |
---|
1352 | IN3S_EstimateRunTime() |
---|
1353 | endif |
---|
1354 | if(stringmatch(cba.ctrlName,"SAXSAll")) |
---|
1355 | if(SAXSAll) |
---|
1356 | LBSelectionWv[][5]=48 |
---|
1357 | else |
---|
1358 | LBSelectionWv[][5]=32 |
---|
1359 | endif |
---|
1360 | IN3S_EstimateRunTime() |
---|
1361 | endif |
---|
1362 | if(stringmatch(cba.ctrlName,"WAXSAll")) |
---|
1363 | if(WAXSAll) |
---|
1364 | LBSelectionWv[][6]=48 |
---|
1365 | else |
---|
1366 | LBSelectionWv[][6]=32 |
---|
1367 | endif |
---|
1368 | IN3S_EstimateRunTime() |
---|
1369 | endif |
---|
1370 | if(stringmatch(cba.ctrlName,"DisplayUSWAXScntrls")) |
---|
1371 | IN3S_FixUSWAXSForAll() |
---|
1372 | if(checked) |
---|
1373 | WAXSAll = 0 |
---|
1374 | USAXSAll = 0 |
---|
1375 | SAXSAll = 0 |
---|
1376 | else |
---|
1377 | WAXSAll = 1 |
---|
1378 | USAXSAll = 1 |
---|
1379 | SAXSAll = 1 |
---|
1380 | endif |
---|
1381 | endif |
---|
1382 | if(stringmatch(cba.ctrlName,"DisplayAllSamplesInImage")) |
---|
1383 | Wave/T listWave=root:Packages:SamplePlateSetup:LBCommandWv |
---|
1384 | if(checked) |
---|
1385 | IN3S_AddTagToImage(dimSize(listWave,0)-1) |
---|
1386 | else |
---|
1387 | ControlInfo/W=SamplePlateSetup CommandsList |
---|
1388 | if(V_Flag>=0 && V_Flag<dimsize(LBCommandWv,0)) |
---|
1389 | IN3S_AddTagToImage(V_Flag) |
---|
1390 | else |
---|
1391 | IN3S_AddTagToImage(0) //remove all drawings, if needed |
---|
1392 | LBSelectionWv[][0]=2 |
---|
1393 | LBSelectionWv[0][0]=3 |
---|
1394 | //ListBox CommandsList, win=SamplePlateSetup, selRow= 0 |
---|
1395 | endif |
---|
1396 | endif |
---|
1397 | endif |
---|
1398 | break |
---|
1399 | case -1: // control being killed |
---|
1400 | break |
---|
1401 | endswitch |
---|
1402 | |
---|
1403 | return 0 |
---|
1404 | End |
---|
1405 | //************************************************************************************************************ |
---|
1406 | //************************************************************************************************************ |
---|
1407 | static Function IN3S_FixUSWAXSForAll() |
---|
1408 | |
---|
1409 | NVAR USAXSAll = root:Packages:SamplePlateSetup:USAXSAll |
---|
1410 | NVAR SAXSAll = root:Packages:SamplePlateSetup:SAXSAll |
---|
1411 | NVAR WAXSAll = root:Packages:SamplePlateSetup:WAXSAll |
---|
1412 | NVAR DiasplyCheckb = root:Packages:SamplePlateSetup:DisplayUSWAXScntrls |
---|
1413 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
1414 | Wave/T LBTtitleWv = root:Packages:SamplePlateSetup:LBTtitleWv |
---|
1415 | variable USAXSWidth, SAXSWidth, WAXSWidth, MDwidth |
---|
1416 | //LBTtitleWv = {"Sample Name", "X [mm]", "Y [mm]", "Thick [mm]", "USAXS", "SAXS", "WAXS", "Metadata"} |
---|
1417 | //now set the columns based on what is checked... |
---|
1418 | if(DiasplyCheckb) //display checkboxes... |
---|
1419 | LBTtitleWv[4]="USAXS" |
---|
1420 | USAXSWidth = 40 |
---|
1421 | LBTtitleWv[5]="SAXS" |
---|
1422 | SAXSWidth = 40 |
---|
1423 | LBTtitleWv[6]="WAXS" |
---|
1424 | WAXSWidth = 40 |
---|
1425 | LBTtitleWv[7]="MD" |
---|
1426 | MDwidth = 40 |
---|
1427 | else |
---|
1428 | LBTtitleWv[4]="" |
---|
1429 | USAXSWidth = 0 |
---|
1430 | LBTtitleWv[5]="" |
---|
1431 | SAXSWidth = 0 |
---|
1432 | LBTtitleWv[6]="" |
---|
1433 | WAXSWidth = 0 |
---|
1434 | LBTtitleWv[7]="" |
---|
1435 | MDwidth = 0 |
---|
1436 | endif |
---|
1437 | ListBox CommandsList win=SamplePlateSetup, widths={220,50,50,60,USAXSWidth,SAXSWidth,WAXSWidth,MDwidth} |
---|
1438 | end |
---|
1439 | //************************************************************************************************************ |
---|
1440 | //************************************************************************************************************ |
---|
1441 | static Function IN3S_LoadSavedSampleSet([folderToLoad]) |
---|
1442 | string folderToLoad |
---|
1443 | |
---|
1444 | DFrEF OldDf=GetDataFolderDFR() |
---|
1445 | string SelectedFolder |
---|
1446 | if(ParamIsDefault(folderToLoad)) |
---|
1447 | ControlInfo /W=SamplePlateSetup SelectSavedSet |
---|
1448 | SelectedFolder=S_Value |
---|
1449 | if(StringMatch(SelectedFolder, "---" )) |
---|
1450 | SetDataFolder OldDf |
---|
1451 | abort |
---|
1452 | endif |
---|
1453 | else |
---|
1454 | SelectedFolder = folderToLoad |
---|
1455 | endif |
---|
1456 | if(DataFolderExists("root:SavedSampleSets:")) |
---|
1457 | setDataFolder root:SavedSampleSets: |
---|
1458 | if(DataFolderExists(SelectedFolder)) |
---|
1459 | SetDataFolder SelectedFolder |
---|
1460 | Wave/T listWave |
---|
1461 | Wave LBSelectionWv |
---|
1462 | Wave/T LBTtitleWv |
---|
1463 | NVAR USAXSAll |
---|
1464 | NVAR SAXSAll |
---|
1465 | NVAR WAXSAll |
---|
1466 | //these are global ones... |
---|
1467 | Wave/T listWaveG=root:Packages:SamplePlateSetup:LBCommandWv |
---|
1468 | Wave LBSelectionWvG= root:Packages:SamplePlateSetup:LBSelectionWv |
---|
1469 | Wave/T LBTtitleWvG = root:Packages:SamplePlateSetup:LBTtitleWv |
---|
1470 | NVAR USAXSAllG = root:Packages:SamplePlateSetup:USAXSAll |
---|
1471 | NVAR SAXSAllG = root:Packages:SamplePlateSetup:SAXSAll |
---|
1472 | NVAR WAXSAllG = root:Packages:SamplePlateSetup:WAXSAll |
---|
1473 | //and write the values... |
---|
1474 | USAXSAllG = USAXSAll |
---|
1475 | SAXSAllG = SAXSAll |
---|
1476 | WAXSAllG = WAXSAll |
---|
1477 | redimension/N=(DimSize(listWave,0), DimSize(listWave,1)) listWaveG, LBSelectionWvG |
---|
1478 | LBSelectionWvG = LBSelectionWv |
---|
1479 | listWaveG = listWave |
---|
1480 | LBTtitleWvG = LBTtitleWv |
---|
1481 | print "Restored settings from folder "+GetDataFolder(1) |
---|
1482 | SVAR NewPlateName = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1483 | NewPlateName = SelectedFolder |
---|
1484 | endif |
---|
1485 | endif |
---|
1486 | SetDataFolder OldDf |
---|
1487 | end |
---|
1488 | //************************************************************************************************************ |
---|
1489 | //************************************************************************************************************ |
---|
1490 | |
---|
1491 | static Function IN3S_SaveCurrentSampleSet(Overwrite, AddToList) |
---|
1492 | variable Overwrite, AddToList |
---|
1493 | |
---|
1494 | DFrEF OldDf=GetDataFolderDFR() |
---|
1495 | Wave/T listWaveG = root:Packages:SamplePlateSetup:LBCommandWv |
---|
1496 | Wave LBSelectionWvG= root:Packages:SamplePlateSetup:LBSelectionWv |
---|
1497 | Wave/T LBTtitleWvG = root:Packages:SamplePlateSetup:LBTtitleWv |
---|
1498 | NVAR USAXSAllG = root:Packages:SamplePlateSetup:USAXSAll |
---|
1499 | NVAR SAXSAllG = root:Packages:SamplePlateSetup:SAXSAll |
---|
1500 | NVAR WAXSAllG = root:Packages:SamplePlateSetup:WAXSAll |
---|
1501 | SVAR NewPlateName = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1502 | NewPlateName = CleanupName(NewPlateName, 1) |
---|
1503 | newDatafolder/O/S root:SavedSampleSets |
---|
1504 | string newUniqueName |
---|
1505 | if(DataFolderExists(NewPlateName)&& !Overwrite) |
---|
1506 | DoAlert /T="This name is already used" 2, "Saved named set exists, Overwite(Yes) - Make Name unique (No) - Cancel" |
---|
1507 | if(V_Flag==3) |
---|
1508 | SetDataFolder OldDf |
---|
1509 | abort |
---|
1510 | elseif(V_Flag==2) |
---|
1511 | newUniqueName= UniqueName(NewPlateName, 11, 1) |
---|
1512 | elseif(V_Flag==1) |
---|
1513 | newUniqueName = NewPlateName |
---|
1514 | KillDataFolder $(newUniqueName) |
---|
1515 | endif |
---|
1516 | else |
---|
1517 | newUniqueName = NewPlateName |
---|
1518 | if(Overwrite) |
---|
1519 | KillDataFolder/Z $(newUniqueName) |
---|
1520 | endif |
---|
1521 | endif |
---|
1522 | NewDataFOlder/O/S $(newUniqueName) |
---|
1523 | variable/g USAXSAll |
---|
1524 | USAXSAll = USAXSAllG |
---|
1525 | variable/g SAXSAll |
---|
1526 | SAXSAll = SAXSAllG |
---|
1527 | variable/g WAXSAll |
---|
1528 | WAXSAll = WAXSAllG |
---|
1529 | Duplicate/O listWaveG, listWave |
---|
1530 | Duplicate/O LBSelectionWvG, LBSelectionWv |
---|
1531 | Duplicate/O LBTtitleWvG, LBTtitleWv |
---|
1532 | print "Stored settings in folder "+GetDataFolder(1) |
---|
1533 | |
---|
1534 | PopupMenu SelectSavedSet,win=SamplePlateSetup, mode=1,value= #"\"---;\"+IN3S_GenStringOfSets()" |
---|
1535 | //add this to list in waves for multi export |
---|
1536 | if(AddToList) |
---|
1537 | IN3S_UpdateListOfSavedSets() |
---|
1538 | //Wave/T ListOfSavedSetsWv=root:Packages:SamplePlateSetup:ListOfSavedSetsWv |
---|
1539 | //Wave SelListOfSavedSetsWv=root:Packages:SamplePlateSetup:SelListOfSavedSetsWv |
---|
1540 | //variable OldLength=numpnts(ListOfSavedSetsWv) |
---|
1541 | //redimension/N=(OldLength+1) ListOfSavedSetsWv, SelListOfSavedSetsWv |
---|
1542 | //ListOfSavedSetsWv[OldLength] = newUniqueName |
---|
1543 | endif |
---|
1544 | SetDataFolder OldDf |
---|
1545 | end |
---|
1546 | //***************************************************************************************************************** |
---|
1547 | //***************************************************************************************************************** |
---|
1548 | static Function IN3S_UpdateListOfSavedSets() |
---|
1549 | |
---|
1550 | DFrEF OldDf=GetDataFolderDFR() |
---|
1551 | Wave/T ListOfSavedSetsWv=root:Packages:SamplePlateSetup:ListOfSavedSetsWv |
---|
1552 | Wave SelListOfSavedSetsWv=root:Packages:SamplePlateSetup:SelListOfSavedSetsWv |
---|
1553 | string ListOfSavedSetsStr |
---|
1554 | variable i |
---|
1555 | if(DataFolderExists("root:SavedSampleSets")) |
---|
1556 | SetDataFolder root:SavedSampleSets |
---|
1557 | DFrEF SavedSetsDRF=GetDataFolderDFR() |
---|
1558 | ListOfSavedSetsStr = IN2G_CreateListOfItemsInFolder("root:SavedSampleSets", 1) |
---|
1559 | variable NewLength=ItemsInList(ListOfSavedSetsStr) |
---|
1560 | redimension/N=(NewLength) ListOfSavedSetsWv, SelListOfSavedSetsWv |
---|
1561 | SelListOfSavedSetsWv = 0 |
---|
1562 | For(i=0;i<NewLength;i+=1) |
---|
1563 | ListOfSavedSetsWv[i] = stringFromList(i,ListOfSavedSetsStr) |
---|
1564 | endfor |
---|
1565 | else |
---|
1566 | redimension/N=(0) ListOfSavedSetsWv, SelListOfSavedSetsWv |
---|
1567 | endif |
---|
1568 | end |
---|
1569 | |
---|
1570 | //***************************************************************************************************************** |
---|
1571 | //***************************************************************************************************************** |
---|
1572 | |
---|
1573 | static Function IN3S_CheckForSensibility() |
---|
1574 | //this will check table for sensibility fo data. |
---|
1575 | |
---|
1576 | //at this time warns about lack of Blanks... |
---|
1577 | |
---|
1578 | //create USAXS command file... For now as notebook and just display for user. |
---|
1579 | |
---|
1580 | DFrEF OldDf=GetDataFolderDFR() |
---|
1581 | Wave/T listWaveG = root:Packages:SamplePlateSetup:LBCommandWv |
---|
1582 | Wave LBSelectionWvG= root:Packages:SamplePlateSetup:LBSelectionWv |
---|
1583 | Wave/T LBTtitleWvG = root:Packages:SamplePlateSetup:LBTtitleWv |
---|
1584 | NVAR USAXSAllG = root:Packages:SamplePlateSetup:USAXSAll |
---|
1585 | NVAR SAXSAllG = root:Packages:SamplePlateSetup:SAXSAll |
---|
1586 | NVAR WAXSAllG = root:Packages:SamplePlateSetup:WAXSAll |
---|
1587 | NVAR DefaultSampleThickness=root:Packages:SamplePlateSetup:DefaultSampleThickness |
---|
1588 | SVAR UserNameForSampleSet = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1589 | NVAR RunExportHookFunction= root:Packages:SamplePlateSetup:RunExportHookFunction |
---|
1590 | |
---|
1591 | variable i, haveAnySAXS, haveAnyWAXS,haveAnyUSAXS |
---|
1592 | //figure out list of names which will be used... |
---|
1593 | string ListOfSAXSNames, ListOfWAXSNames, ListOfUSAXSNames |
---|
1594 | ListOfSAXSNames="" |
---|
1595 | ListOfWAXSNames="" |
---|
1596 | ListOfUSAXSNames="" |
---|
1597 | //SAXS is first. |
---|
1598 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1599 | if(SAXSAllG || LBSelectionWvG[i][5]==48) |
---|
1600 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1601 | haveAnySAXS=1 |
---|
1602 | ListOfSAXSNames+=listWaveG[i][0]+";" |
---|
1603 | endif |
---|
1604 | endif |
---|
1605 | endfor |
---|
1606 | //WAXS is next. |
---|
1607 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1608 | if(WAXSAllG || LBSelectionWvG[i][6]==48) |
---|
1609 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1610 | haveAnyWAXS=1 |
---|
1611 | ListOfWAXSNames+=listWaveG[i][0]+";" |
---|
1612 | endif |
---|
1613 | endif |
---|
1614 | endfor |
---|
1615 | //do we have any USAXS scans? |
---|
1616 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1617 | if(USAXSAllG || LBSelectionWvG[i][4]==48) |
---|
1618 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1619 | haveAnyUSAXS=1 |
---|
1620 | ListOfUSAXSNames+=listWaveG[i][0]+";" |
---|
1621 | endif |
---|
1622 | endif |
---|
1623 | endfor |
---|
1624 | variable NumWAXS, NumWAXSBlanks |
---|
1625 | variable NumSAXS, NumSAXSBlanks |
---|
1626 | variable NumUSAXS, NumUSAXSBlanks |
---|
1627 | NumWAXS=ItemsInList(ListOfWAXSNames) |
---|
1628 | NumWAXSBlanks=ItemsInList(GrepList(ListOfWAXSNames, "(?i)blank")+GrepList(ListOfWAXSNames, "(?i)empty")) |
---|
1629 | NumSAXS=ItemsInList(ListOfSAXSNames) |
---|
1630 | NumSAXSBlanks=ItemsInList(GrepList(ListOfSAXSNames, "(?i)blank")+GrepList(ListOfSAXSNames, "(?i)empty")) |
---|
1631 | NumUSAXS=ItemsInList(ListOfUSAXSNames) |
---|
1632 | NumUSAXSBlanks=ItemsInList(GrepList(ListOfUSAXSNames, "(?i)blank")+GrepList(ListOfUSAXSNames, "(?i)empty")) |
---|
1633 | string MessageToUser="" |
---|
1634 | if((NumUSAXSBlanks/NumUSAXS)<(1/15)) |
---|
1635 | MessageToUser+=" Blanks for USAXS, " |
---|
1636 | endif |
---|
1637 | if((NumSAXSBlanks/NumSAXS)<(1/15)) |
---|
1638 | MessageToUser+=" Blanks for SAXS, " |
---|
1639 | endif |
---|
1640 | if((NumWAXSBlanks/NumWAXS)<(1/15)) |
---|
1641 | MessageToUser+=" Blanks for WAXS " |
---|
1642 | endif |
---|
1643 | if(strlen(MessageToUser)>5 &&(NumWAXS>1 || NumSAXS>1 || NumUSAXS>1)) |
---|
1644 | DoAlert /T="Not enough blanks, check history area" 0, "Looks like there is not enough "+MessageToUser |
---|
1645 | Print "You need enough background = blanks/empty runs. Default is at least 1 blank per 15 samples, Suggested is 1 blank per 10 samples." |
---|
1646 | print "Code expects background measurements will have blank of empty in the name, but name can contain more. e.g.: TapeBlank is recognized as blank." |
---|
1647 | print "If your background names are different you can go ahead as is." |
---|
1648 | endif |
---|
1649 | SetDataFolder OldDf |
---|
1650 | end |
---|
1651 | //***************************************************************************************************************** |
---|
1652 | //***************************************************************************************************************** |
---|
1653 | static Function IN3S_WriteCommandFile(show, AppendHeaders) |
---|
1654 | variable show, AppendHeaders |
---|
1655 | |
---|
1656 | |
---|
1657 | //Options to export multiple saved sets of positions... |
---|
1658 | NVAR ExportCurrentPosSet=root:Packages:SamplePlateSetup:ExportCurrentPosSet |
---|
1659 | NVAR ExportListOfPosSets=root:Packages:SamplePlateSetup:ExportListOfPosSets |
---|
1660 | SVAR CurNameStr=root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1661 | variable i |
---|
1662 | string CurFolder, TempFolder |
---|
1663 | curFolder=CurNameStr |
---|
1664 | |
---|
1665 | if(ExportListOfPosSets) //user wants to export multiple saved set... |
---|
1666 | Wave/T ListOfWavesForExport=root:Packages:SamplePlateSetup:ListOfWavesForExport |
---|
1667 | if(numpnts(ListOfWavesForExport)>0) |
---|
1668 | CurNameStr = "TempExportSetStored" |
---|
1669 | //save current, just in case |
---|
1670 | IN3S_SaveCurrentSampleSet(1,0) |
---|
1671 | //cleanup old notebook. |
---|
1672 | SVAR/Z nbl=root:Packages:SamplePlateSetup:NotebookName |
---|
1673 | if(!SVAR_Exists(nbl)) |
---|
1674 | NewDataFolder/O root:Packages |
---|
1675 | NewDataFolder/O root:Packages:SamplePlateSetup |
---|
1676 | String/G root:Packages:SamplePlateSetup:NotebookName="" |
---|
1677 | SVAR nbl=root:Packages:SamplePlateSetup:NotebookName |
---|
1678 | nbL="CommandFile" |
---|
1679 | endif |
---|
1680 | if ((strsearch(WinList("*",";","WIN:16"),nbL,0)!=-1)) ///CommandFile notebook exists |
---|
1681 | KillWindow/Z $(nbl) |
---|
1682 | endif |
---|
1683 | //cycle through the list |
---|
1684 | For(i=0;i<numpnts(ListOfWavesForExport);i+=1) |
---|
1685 | TempFolder = ListOfWavesForExport[i] |
---|
1686 | IN3S_LoadSavedSampleSet(folderToLoad=TempFolder) |
---|
1687 | IN3S_WriteCommandFileInternal(show, AppendHeaders,0) |
---|
1688 | endfor |
---|
1689 | IN3S_LoadSavedSampleSet(folderToLoad="TempExportSetStored") |
---|
1690 | KillDataFolder/Z root:SavedSampleSets:TempExportSetStored: //clean up the temp saved data set. |
---|
1691 | CurNameStr = curFolder |
---|
1692 | else |
---|
1693 | abort "Nothing is on the list here" |
---|
1694 | endif |
---|
1695 | elseif(ExportCurrentPosSet) |
---|
1696 | IN3S_WriteCommandFileInternal(show, AppendHeaders,1) |
---|
1697 | else |
---|
1698 | Abort "SOmething wrong with the code in IN3S_WriteCommandFile" |
---|
1699 | endif |
---|
1700 | end |
---|
1701 | //***************************************************************************************************************** |
---|
1702 | static FUnction IN3S_WriteCommandFileInternal(show, AppendHeaders, KillIfFound) |
---|
1703 | variable show, AppendHeaders, KillIfFound |
---|
1704 | //create USAXS command file... For now as notebook and just display for user. |
---|
1705 | |
---|
1706 | DFrEF OldDf=GetDataFolderDFR() |
---|
1707 | Wave/T listWaveG = root:Packages:SamplePlateSetup:LBCommandWv |
---|
1708 | Wave LBSelectionWvG= root:Packages:SamplePlateSetup:LBSelectionWv |
---|
1709 | Wave/T LBTtitleWvG = root:Packages:SamplePlateSetup:LBTtitleWv |
---|
1710 | NVAR USAXSAllG = root:Packages:SamplePlateSetup:USAXSAll |
---|
1711 | NVAR SAXSAllG = root:Packages:SamplePlateSetup:SAXSAll |
---|
1712 | NVAR WAXSAllG = root:Packages:SamplePlateSetup:WAXSAll |
---|
1713 | NVAR DefaultSampleThickness=root:Packages:SamplePlateSetup:DefaultSampleThickness |
---|
1714 | SVAR UserNameForSampleSet = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
1715 | NVAR RunExportHookFunction= root:Packages:SamplePlateSetup:RunExportHookFunction |
---|
1716 | SVAR/Z nbl=root:Packages:SamplePlateSetup:NotebookName |
---|
1717 | variable i, haveAnySWAXS, thickness |
---|
1718 | haveAnySWAXS = 0 |
---|
1719 | if(!SVAR_Exists(nbl)) |
---|
1720 | NewDataFolder/O root:Packages |
---|
1721 | NewDataFolder/O root:Packages:SamplePlateSetup |
---|
1722 | String/G root:Packages:SamplePlateSetup:NotebookName="" |
---|
1723 | SVAR nbl=root:Packages:SamplePlateSetup:NotebookName |
---|
1724 | nbL="CommandFile" |
---|
1725 | endif |
---|
1726 | if ((strsearch(WinList("*",";","WIN:16"),nbL,0)!=-1) && KillIfFound) ///CommandFile notebook exists |
---|
1727 | KillWindow/Z $(nbl) |
---|
1728 | endif |
---|
1729 | |
---|
1730 | if ((strsearch(WinList("*",";","WIN:16"),nbL,0) <0)) |
---|
1731 | NewNotebook/K=1/F=0/ENCG={3,0}/N=$nbl/V=1/W=(235.5,44.75,817.5,592.25) as nbl |
---|
1732 | Notebook $nbl writeBOM = 0 |
---|
1733 | if(AppendHeaders) |
---|
1734 | Notebook $nbl text=" CURRENT_EXPERIMENT_NAME \""+UserNameForSampleSet+"\"\r" |
---|
1735 | Notebook $nbl text=" # This file runs USAXS, SAXS and WAXS scans according to the syntax shown below\r" |
---|
1736 | Notebook $nbl text=" # \r" |
---|
1737 | Notebook $nbl text=" # Scan Type sx sy Thickness Sample Name\r" |
---|
1738 | Notebook $nbl text=" # ------------------------------------------------------ \r" |
---|
1739 | Notebook $nbl text=" # USAXSscan 45.07 98.3 0 \"Water Blank\"\r" |
---|
1740 | Notebook $nbl text=" # saxsExp 45.07 98.3 0 \"Water Blank\"\r" |
---|
1741 | Notebook $nbl text=" # waxsExp 45.07 98.3 0 \"Water Blank\" \r" |
---|
1742 | Notebook $nbl text=" # Use a space (not a tab) to separate arguments (i.e., 45.07 <space> 98.3 in the examples above)\r" |
---|
1743 | Notebook $nbl text="\r" |
---|
1744 | Notebook $nbl text=" # Run this file by typing the following command in the spec window: USAXS> CollectData usaxs.mac \r" |
---|
1745 | Notebook $nbl text="\r" |
---|
1746 | Notebook $nbl text=" # Stop the run using the \"Stop after this scan?\" checkbox in USAXS user main intf \r" |
---|
1747 | Notebook $nbl text=" # and wait until the USAXS> prompt reappears\r" |
---|
1748 | Notebook $nbl text="\r" |
---|
1749 | Notebook $nbl text=" ############ PLACE ALL USER COMMANDS AFTER THIS LINE ############ \r" |
---|
1750 | Notebook $nbl text="\r" |
---|
1751 | endif |
---|
1752 | endif |
---|
1753 | Notebook $nbl text=" \r" |
---|
1754 | |
---|
1755 | //and now we will write the commands... |
---|
1756 | //SAXS is first. |
---|
1757 | |
---|
1758 | IN3S_WriteListOfCommands(listWaveG, LBSelectionWvG, 0, 0, "") |
---|
1759 | if(RunExportHookFunction) |
---|
1760 | IN3S_ExportHookFunction(listWaveG, LBSelectionWvG) |
---|
1761 | endif |
---|
1762 | |
---|
1763 | if (show) ///Logbook want to show it... |
---|
1764 | DoWindow/F $nbl |
---|
1765 | else |
---|
1766 | DoWindow/HIDE=1 $nbl |
---|
1767 | endif |
---|
1768 | SetDataFolder OldDf |
---|
1769 | end |
---|
1770 | |
---|
1771 | //Function IN3S_ExportHookFunction(Command, SampleName,SX, SY, Thickness, MD) |
---|
1772 | // string Command, SampleName,SX, SY, Thickness, MD |
---|
1773 | // //this hook function will modify output of the command file for given line. This needs to be cutomized for specific need. |
---|
1774 | // SVAR nbl=root:Packages:SamplePlateSetup:NotebookName |
---|
1775 | // |
---|
1776 | // //in this case it will write each command in notebook multiple times, in original position and then +/- 1mm in sx and sy |
---|
1777 | // //center |
---|
1778 | // Notebook $nbl text=" "+Command+" "+SX+" "+SY+" "+Thickness+" \""+SampleName+"\" \r" |
---|
1779 | // //and now the variations, only if Sample Name is NOT Blank or Empty |
---|
1780 | // if(!StringMatch(SampleName, "*Blank*")&&!StringMatch(SampleName, "*Empty*")) |
---|
1781 | // string TempStr |
---|
1782 | // TempStr = num2str(str2num(SX)-1) |
---|
1783 | // Notebook $nbl text=" "+Command+" "+TempStr+" "+SY+" "+Thickness+" \""+SampleName+"_R"+"\" \r" |
---|
1784 | // TempStr = num2str(str2num(SX)+1) |
---|
1785 | // Notebook $nbl text=" "+Command+" "+TempStr+" "+SY+" "+Thickness+" \""+SampleName+"_L"+"\" \r" |
---|
1786 | // TempStr = num2str(str2num(SY)-1) |
---|
1787 | // Notebook $nbl text=" "+Command+" "+SX+" "+TempStr+" "+Thickness+" \""+SampleName+"_B"+"\" \r" |
---|
1788 | // TempStr = num2str(str2num(SY)+1) |
---|
1789 | // Notebook $nbl text=" "+Command+" "+SX+" "+TempStr+" "+Thickness+" \""+SampleName+"_T"+"\" \r" |
---|
1790 | // endif |
---|
1791 | //end |
---|
1792 | |
---|
1793 | //***************************************************************************************************************** |
---|
1794 | //***************************************************************************************************************** |
---|
1795 | |
---|
1796 | Function IN3S_WriteListOfCommands(listWaveG, LBSelectionWvG, sxOffset, syOffset, TitleModifier) |
---|
1797 | wave/T listWaveG |
---|
1798 | wave LBSelectionWvG |
---|
1799 | variable sxOffset, syOffset |
---|
1800 | string TitleModifier |
---|
1801 | |
---|
1802 | NVAR DefaultSampleThickness=root:Packages:SamplePlateSetup:DefaultSampleThickness |
---|
1803 | NVAR USAXSAllG = root:Packages:SamplePlateSetup:USAXSAll |
---|
1804 | NVAR SAXSAllG = root:Packages:SamplePlateSetup:SAXSAll |
---|
1805 | NVAR WAXSAllG = root:Packages:SamplePlateSetup:WAXSAll |
---|
1806 | SVAR ExportOrder=root:Packages:SamplePlateSetup:ExportOrder |
---|
1807 | // ExportOrder can be: USAXS-SAXS-WAXS, SAXS-WAXS-USAXS, or USAXS-WAXS-SAXS |
---|
1808 | |
---|
1809 | variable i, haveAnySWAXS, thickness, sxMod, syMod, numSAXSWAXS |
---|
1810 | haveAnySWAXS = 0 |
---|
1811 | numSAXSWAXS = 0 |
---|
1812 | |
---|
1813 | string Command, SampleName |
---|
1814 | variable SX, SY |
---|
1815 | variable HaveUSAXS |
---|
1816 | //this function will write (potentially modified) output of the command file for given line. This needs to be cutomized for specific need. |
---|
1817 | SVAR nbl=root:Packages:SamplePlateSetup:NotebookName |
---|
1818 | |
---|
1819 | strswitch(ExportOrder) |
---|
1820 | |
---|
1821 | case "USAXS-SAXS-WAXS": |
---|
1822 | Notebook $nbl text="\r" |
---|
1823 | Notebook $nbl text=" #USAXS measurements \r" |
---|
1824 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1825 | if(USAXSAllG || LBSelectionWvG[i][4]==48) |
---|
1826 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1827 | thickness = str2num(listWaveG[i][3]) |
---|
1828 | thickness = thickness>0 ? thickness : DefaultSampleThickness |
---|
1829 | SX=str2num(listWaveG[i][1])+sxOffset |
---|
1830 | SY=str2num(listWaveG[i][2])+syOffset |
---|
1831 | Notebook $nbl text=" USAXSscan "+num2str(SX)+" "+num2str(SY)+" "+num2str(thickness)+" \""+listWaveG[i][0]+TitleModifier+"\" \r" |
---|
1832 | endif |
---|
1833 | endif |
---|
1834 | endfor |
---|
1835 | Notebook $nbl text="\r" |
---|
1836 | Notebook $nbl text=" #SAXS measurements \r" |
---|
1837 | //this is SAXS |
---|
1838 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1839 | if(SAXSAllG || LBSelectionWvG[i][5]==48) |
---|
1840 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1841 | haveAnySWAXS=1 |
---|
1842 | numSAXSWAXS+=1 |
---|
1843 | thickness = str2num(listWaveG[i][3]) |
---|
1844 | thickness = thickness>0 ? thickness : DefaultSampleThickness |
---|
1845 | SX=str2num(listWaveG[i][1])+sxOffset |
---|
1846 | SY=str2num(listWaveG[i][2])+syOffset |
---|
1847 | Notebook $nbl text=" saxsExp "+num2str(SX)+" "+num2str(SY)+" "+num2str(thickness)+" \""+listWaveG[i][0]+TitleModifier+"\" \r" |
---|
1848 | endif |
---|
1849 | endif |
---|
1850 | endfor |
---|
1851 | //WAXS is next. |
---|
1852 | Notebook $nbl text="\r" |
---|
1853 | Notebook $nbl text=" #WAXS measurements \r" |
---|
1854 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1855 | if(WAXSAllG || LBSelectionWvG[i][6]==48) |
---|
1856 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1857 | haveAnySWAXS=1 |
---|
1858 | numSAXSWAXS+=1 |
---|
1859 | thickness = str2num(listWaveG[i][3]) |
---|
1860 | thickness = thickness>0 ? thickness : DefaultSampleThickness |
---|
1861 | SX=str2num(listWaveG[i][1])+sxOffset |
---|
1862 | SY=str2num(listWaveG[i][2])+syOffset |
---|
1863 | Notebook $nbl text=" waxsExp "+num2str(SX)+" "+num2str(SY)+" "+num2str(thickness)+" \""+listWaveG[i][0]+TitleModifier+"\" \r" |
---|
1864 | endif |
---|
1865 | endif |
---|
1866 | endfor |
---|
1867 | Notebook $nbl text=" #END of batch of measurements \r" |
---|
1868 | break |
---|
1869 | case "USAXS-WAXS-SAXS": |
---|
1870 | Notebook $nbl text="\r" |
---|
1871 | Notebook $nbl text=" #USAXS measurements \r" |
---|
1872 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1873 | if(USAXSAllG || LBSelectionWvG[i][4]==48) |
---|
1874 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1875 | thickness = str2num(listWaveG[i][3]) |
---|
1876 | thickness = thickness>0 ? thickness : DefaultSampleThickness |
---|
1877 | SX=str2num(listWaveG[i][1])+sxOffset |
---|
1878 | SY=str2num(listWaveG[i][2])+syOffset |
---|
1879 | Notebook $nbl text=" USAXSscan "+num2str(SX)+" "+num2str(SY)+" "+num2str(thickness)+" \""+listWaveG[i][0]+TitleModifier+"\" \r" |
---|
1880 | endif |
---|
1881 | endif |
---|
1882 | endfor |
---|
1883 | //WAXS is next. |
---|
1884 | Notebook $nbl text="\r" |
---|
1885 | Notebook $nbl text=" #WAXS measurements \r" |
---|
1886 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1887 | if(WAXSAllG || LBSelectionWvG[i][6]==48) |
---|
1888 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1889 | haveAnySWAXS=1 |
---|
1890 | numSAXSWAXS+=1 |
---|
1891 | thickness = str2num(listWaveG[i][3]) |
---|
1892 | thickness = thickness>0 ? thickness : DefaultSampleThickness |
---|
1893 | SX=str2num(listWaveG[i][1])+sxOffset |
---|
1894 | SY=str2num(listWaveG[i][2])+syOffset |
---|
1895 | Notebook $nbl text=" waxsExp "+num2str(SX)+" "+num2str(SY)+" "+num2str(thickness)+" \""+listWaveG[i][0]+TitleModifier+"\" \r" |
---|
1896 | endif |
---|
1897 | endif |
---|
1898 | endfor |
---|
1899 | Notebook $nbl text="\r" |
---|
1900 | Notebook $nbl text=" #SAXS measurements \r" |
---|
1901 | //this is SAXS |
---|
1902 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1903 | if(SAXSAllG || LBSelectionWvG[i][5]==48) |
---|
1904 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1905 | haveAnySWAXS=1 |
---|
1906 | numSAXSWAXS+=1 |
---|
1907 | thickness = str2num(listWaveG[i][3]) |
---|
1908 | thickness = thickness>0 ? thickness : DefaultSampleThickness |
---|
1909 | SX=str2num(listWaveG[i][1])+sxOffset |
---|
1910 | SY=str2num(listWaveG[i][2])+syOffset |
---|
1911 | Notebook $nbl text=" saxsExp "+num2str(SX)+" "+num2str(SY)+" "+num2str(thickness)+" \""+listWaveG[i][0]+TitleModifier+"\" \r" |
---|
1912 | endif |
---|
1913 | endif |
---|
1914 | endfor |
---|
1915 | Notebook $nbl text=" #END of batch of measurements \r" |
---|
1916 | break |
---|
1917 | case "SAXS-WAXS-USAXS": |
---|
1918 | //this is SAXS |
---|
1919 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1920 | if(SAXSAllG || LBSelectionWvG[i][5]==48) |
---|
1921 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1922 | haveAnySWAXS=1 |
---|
1923 | numSAXSWAXS+=1 |
---|
1924 | thickness = str2num(listWaveG[i][3]) |
---|
1925 | thickness = thickness>0 ? thickness : DefaultSampleThickness |
---|
1926 | SX=str2num(listWaveG[i][1])+sxOffset |
---|
1927 | SY=str2num(listWaveG[i][2])+syOffset |
---|
1928 | Notebook $nbl text=" saxsExp "+num2str(SX)+" "+num2str(SY)+" "+num2str(thickness)+" \""+listWaveG[i][0]+TitleModifier+"\" \r" |
---|
1929 | endif |
---|
1930 | endif |
---|
1931 | endfor |
---|
1932 | //WAXS is next. |
---|
1933 | Notebook $nbl text="\r" |
---|
1934 | Notebook $nbl text=" #WAXS measurements \r" |
---|
1935 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1936 | if(WAXSAllG || LBSelectionWvG[i][6]==48) |
---|
1937 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1938 | haveAnySWAXS=1 |
---|
1939 | numSAXSWAXS+=1 |
---|
1940 | thickness = str2num(listWaveG[i][3]) |
---|
1941 | thickness = thickness>0 ? thickness : DefaultSampleThickness |
---|
1942 | SX=str2num(listWaveG[i][1])+sxOffset |
---|
1943 | SY=str2num(listWaveG[i][2])+syOffset |
---|
1944 | Notebook $nbl text=" waxsExp "+num2str(SX)+" "+num2str(SY)+" "+num2str(thickness)+" \""+listWaveG[i][0]+TitleModifier+"\" \r" |
---|
1945 | endif |
---|
1946 | endif |
---|
1947 | endfor |
---|
1948 | //and USAXS . |
---|
1949 | //do we have any USAXS scans? |
---|
1950 | Duplicate/Free/R=[][4] LBSelectionWvG, TempUSAXSChoice |
---|
1951 | WaveStats/Q TempUSAXSChoice |
---|
1952 | HaveUSAXS = (V_max>40) ? 1 : 0 |
---|
1953 | if(haveAnySWAXS && USAXSAllG && HaveUSAXS) |
---|
1954 | Notebook $nbl text="\r" |
---|
1955 | Notebook $nbl text=" preUSAXStune \r" |
---|
1956 | if(numSAXSWAXS>15) |
---|
1957 | Notebook $nbl text=" preUSAXStune \r" |
---|
1958 | endif |
---|
1959 | if(numSAXSWAXS>30) |
---|
1960 | Notebook $nbl text=" preUSAXStune \r" |
---|
1961 | endif |
---|
1962 | endif |
---|
1963 | Notebook $nbl text="\r" |
---|
1964 | Notebook $nbl text=" #USAXS measurements \r" |
---|
1965 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
1966 | if(USAXSAllG || LBSelectionWvG[i][4]==48) |
---|
1967 | if(strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
1968 | thickness = str2num(listWaveG[i][3]) |
---|
1969 | thickness = thickness>0 ? thickness : DefaultSampleThickness |
---|
1970 | SX=str2num(listWaveG[i][1])+sxOffset |
---|
1971 | SY=str2num(listWaveG[i][2])+syOffset |
---|
1972 | Notebook $nbl text=" USAXSscan "+num2str(SX)+" "+num2str(SY)+" "+num2str(thickness)+" \""+listWaveG[i][0]+TitleModifier+"\" \r" |
---|
1973 | endif |
---|
1974 | endif |
---|
1975 | endfor |
---|
1976 | Notebook $nbl text="\r" |
---|
1977 | Notebook $nbl text=" #END USAXS measurements \r" |
---|
1978 | break |
---|
1979 | |
---|
1980 | endswitch |
---|
1981 | |
---|
1982 | end |
---|
1983 | |
---|
1984 | //***************************************************************************************************************** |
---|
1985 | //***************************************************************************************************************** |
---|
1986 | |
---|
1987 | static Function/T IN3S_ExportMacroFile(UseUsername, AppendToExisting) |
---|
1988 | variable UseUsername //set to 0 for usaxs.mac, 1 for user choice. |
---|
1989 | variable AppendToExisting //set to 1 if one should append to existing file on desktop. |
---|
1990 | |
---|
1991 | IN3S_CheckForSensibility() |
---|
1992 | string NewFileName |
---|
1993 | SVAR UserDefinedCmdName=root:Packages:SamplePlateSetup:DefaultCommandFileName |
---|
1994 | string UseCmdName |
---|
1995 | if(strlen(UserDefinedCmdName)>4) |
---|
1996 | UseCmdName = UserDefinedCmdName |
---|
1997 | else |
---|
1998 | UseCmdName = "usaxs.mac" |
---|
1999 | endif |
---|
2000 | NewPath /C/Q/O UserDesktop , SpecialDirPath("Desktop", 0, 0, 0 ) |
---|
2001 | if(UseUsername) |
---|
2002 | IN3S_WriteCommandFile(0,1) //this creates notebook with commands, |
---|
2003 | SVAR nbl=root:Packages:SamplePlateSetup:NotebookName |
---|
2004 | SaveNotebook /P=UserDesktop/ENCG=1/S=6/I/M="Select location and name for your command file" $(nbl) as UseCmdName |
---|
2005 | if(strlen(S_path)<1) |
---|
2006 | Abort |
---|
2007 | endif |
---|
2008 | NewFileName = S_path |
---|
2009 | string NewFullNamePath = ReplaceString(".txt", NewFileName, "" ) |
---|
2010 | //if needed and user did not use .mac, append it. |
---|
2011 | if(!StringMatch(NewFullNamePath, "*.mac")) |
---|
2012 | NewFullNamePath = NewFullNamePath+".mac" |
---|
2013 | endif |
---|
2014 | MoveFile/O NewFileName as NewFullNamePath |
---|
2015 | NewFileName = NewFullNamePath |
---|
2016 | else //using default name set in panel... Typically usaxs.mac. |
---|
2017 | if(AppendToExisting) //need to reimport the existing notebook, cannot append using SaveNotebook |
---|
2018 | IN3S_WriteCommandFile(0,0) //this creates notebook with commands, no header of comments. |
---|
2019 | SVAR nbl=root:Packages:SamplePlateSetup:NotebookName |
---|
2020 | OpenNotebook /P=UserDesktop/N=TempOldCmdFile/Z UseCmdName |
---|
2021 | if(V_Flag!=0) |
---|
2022 | NewNotebook as "TempOldCmdFile" |
---|
2023 | endif |
---|
2024 | //read all from imported TempOldCmdFile and stuff it at the beggining of the nbl |
---|
2025 | notebook TempOldCmdFile, selection={startOfFile, endOfFile } |
---|
2026 | GetSelection notebook, TempOldCmdFile, 3 |
---|
2027 | KillWindow/Z TempOldCmdFile |
---|
2028 | //print S_selection |
---|
2029 | //got to top of the notebook |
---|
2030 | notebook $(nbl), selection={startOfFile, startOfFile } |
---|
2031 | //insert old content from existing file. |
---|
2032 | notebook $(nbl), text=S_selection |
---|
2033 | notebook $(nbl), text="\r" |
---|
2034 | notebook $(nbl), text="### Appended commands \r" |
---|
2035 | notebook $(nbl), text="\r" |
---|
2036 | else |
---|
2037 | IN3S_WriteCommandFile(0,1) //this creates notebook with commands, |
---|
2038 | SVAR nbl=root:Packages:SamplePlateSetup:NotebookName |
---|
2039 | endif |
---|
2040 | SaveNotebook /P=UserDesktop/ENCG=1/S=6/O $(nbl) as UseCmdName |
---|
2041 | endif |
---|
2042 | SVAR nbl=root:Packages:SamplePlateSetup:NotebookName |
---|
2043 | KillWindow/Z $(nbl) |
---|
2044 | if(strlen(S_path)>0) |
---|
2045 | NewFileName = S_path |
---|
2046 | print "Your command file was saved as "+NewFileName |
---|
2047 | return NewFileName |
---|
2048 | else |
---|
2049 | print "Save of command file was cancelled " |
---|
2050 | return "" |
---|
2051 | endif |
---|
2052 | end |
---|
2053 | |
---|
2054 | |
---|
2055 | //************************************************************************************************************ |
---|
2056 | //************************************************************************************************************ |
---|
2057 | |
---|
2058 | static Function IN3S_Initialize() |
---|
2059 | |
---|
2060 | DFrEF OldDf=GetDataFolderDFR() |
---|
2061 | setdatafolder root: |
---|
2062 | NewDataFolder/O/S root:Packages |
---|
2063 | NewDataFolder/O USAXS |
---|
2064 | NewDataFolder/O/S SamplePlateSetup |
---|
2065 | //NewDataFolder/O root:AvailableSamplePlates |
---|
2066 | |
---|
2067 | string ListOfVariables |
---|
2068 | string ListOfStrings |
---|
2069 | variable i, j |
---|
2070 | |
---|
2071 | ListOfVariables="NumberOfSamplesToCreate;DisplayAllSamplesInImage;" |
---|
2072 | ListOfVariables+="DefaultSampleThickness;USAXSAll;SAXSAll;WAXSAll;DisplayUSWAXScntrls;" |
---|
2073 | ListOfVariables+="SampleXTAR;SampleYTAR;SelectedRow;SampleThickness;SampleXRBV;SampleYRBV;" |
---|
2074 | ListOfVariables+="SampleXTable;SampleYTable;SurveySXStep;SurveySYStep;MoveWhenRowChanges;" |
---|
2075 | ListOfVariables+="RunExportHookFunction;" |
---|
2076 | ListOfVariables+="USAXSScanTime;SAXSScanTime;WAXSScanTime;CalculatedOverAllTime;NumberOfSamples;" |
---|
2077 | ListOfVariables+="TableIsSaved;ExportCurrentPosSet;ExportListOfPosSets;" |
---|
2078 | |
---|
2079 | ListOfStrings="SelectedPlateName;UserNameForSampleSet;UserName;WarningForUser;" |
---|
2080 | ListOfStrings+="SelectedSampleName;DefaultCommandFileName;TableClipboard;" |
---|
2081 | ListOfStrings+="ExportOrder;" |
---|
2082 | //and here we create them |
---|
2083 | for(i=0;i<itemsInList(ListOfVariables);i+=1) |
---|
2084 | IN2G_CreateItem("variable",StringFromList(i,ListOfVariables)) |
---|
2085 | endfor |
---|
2086 | for(i=0;i<itemsInList(ListOfStrings);i+=1) |
---|
2087 | IN2G_CreateItem("string",StringFromList(i,ListOfStrings)) |
---|
2088 | endfor |
---|
2089 | //waves for multi table export... |
---|
2090 | Wave/Z/T ListOfSavedSetsWv |
---|
2091 | if(!WaveExists(ListOfSavedSetsWv)) |
---|
2092 | make/O/N=0/T ListOfSavedSetsWv, ListOfWavesForExport |
---|
2093 | make/O/N=0 SelListOfSavedSetsWv, SelListOfWavesForExport |
---|
2094 | endif |
---|
2095 | |
---|
2096 | NVAR USAXSAll |
---|
2097 | NVAR SAXSAll |
---|
2098 | NVAR WAXSAll |
---|
2099 | USAXSAll =1 |
---|
2100 | SAXSAll = 1 |
---|
2101 | WAXSAll = 1 |
---|
2102 | NVAR NumberOfSamplesToCreate |
---|
2103 | if(NumberOfSamplesToCreate<1) |
---|
2104 | NumberOfSamplesToCreate = 20 |
---|
2105 | endif |
---|
2106 | SVAR SelectedPlateName |
---|
2107 | if(strlen(SelectedPlateName)<2) |
---|
2108 | SelectedPlateName = "9x9 Acrylic/magnetic plate" |
---|
2109 | endif |
---|
2110 | NVAR DefaultSampleThickness |
---|
2111 | if(DefaultSampleThickness<0.01||DefaultSampleThickness>20) |
---|
2112 | DefaultSampleThickness=1 |
---|
2113 | endif |
---|
2114 | SVAR WarningForUser |
---|
2115 | WarningForUser="Tool started... Report bugs and wishes to author!" |
---|
2116 | SVAR DefaultCommandFileName |
---|
2117 | if(strlen(DefaultCommandFileName)<4) |
---|
2118 | DefaultCommandFileName="usaxs.mac" |
---|
2119 | endif |
---|
2120 | SVAR ExportOrder |
---|
2121 | if(strlen(ExportOrder)<2) |
---|
2122 | ExportOrder="USAXS-SAXS-WAXS" |
---|
2123 | endif |
---|
2124 | |
---|
2125 | NVAR ExportCurrentPosSet |
---|
2126 | NVAR ExportListOfPosSets |
---|
2127 | if(ExportCurrentPosSet+ExportListOfPosSets!=1) |
---|
2128 | ExportCurrentPosSet=1 |
---|
2129 | ExportListOfPosSets=0 |
---|
2130 | endif |
---|
2131 | NVAR SurveySXStep |
---|
2132 | if(SurveySXStep<0.01) |
---|
2133 | SurveySXStep = 1 |
---|
2134 | endif |
---|
2135 | NVAR SurveySYStep |
---|
2136 | if(SurveySYStep<0.01) |
---|
2137 | SurveySYStep = 1 |
---|
2138 | endif |
---|
2139 | NVAR USAXSScanTime |
---|
2140 | NVAR SAXSScanTime |
---|
2141 | NVAR WAXSScanTime |
---|
2142 | if(USAXSScanTime<30) |
---|
2143 | USAXSScanTime = 90 |
---|
2144 | endif |
---|
2145 | if(SAXSScanTime<3) |
---|
2146 | SAXSScanTime = 20 |
---|
2147 | endif |
---|
2148 | if(WAXSScanTime<3) |
---|
2149 | WAXSScanTime = 20 |
---|
2150 | endif |
---|
2151 | //kill potentially old stuff here |
---|
2152 | killwaves/Z imageWave, M_RGB2Gray, PlateImageTemp |
---|
2153 | |
---|
2154 | SetDataFolder OldDf |
---|
2155 | end |
---|
2156 | |
---|
2157 | //***************************************************************************************************************** |
---|
2158 | //***************************************************************************************************************** |
---|
2159 | static Function IN3S_EstimateRunTime() |
---|
2160 | |
---|
2161 | NVAR USAXSScanTime = root:Packages:SamplePlateSetup:USAXSScanTime |
---|
2162 | NVAR SAXSScanTime = root:Packages:SamplePlateSetup:SAXSScanTime |
---|
2163 | NVAR WAXSScanTime = root:Packages:SamplePlateSetup:WAXSScanTime |
---|
2164 | NVAR CalculatedOverAllTime = root:Packages:SamplePlateSetup:CalculatedOverAllTime |
---|
2165 | NVAR USAXSAllG = root:Packages:SamplePlateSetup:USAXSAll |
---|
2166 | NVAR SAXSAllG = root:Packages:SamplePlateSetup:SAXSAll |
---|
2167 | NVAR WAXSAllG = root:Packages:SamplePlateSetup:WAXSAll |
---|
2168 | |
---|
2169 | Wave/T listWaveG = root:Packages:SamplePlateSetup:LBCommandWv |
---|
2170 | Wave LBSelectionWvG= root:Packages:SamplePlateSetup:LBSelectionWv |
---|
2171 | |
---|
2172 | NVAR/Z NumberOfSamples = root:Packages:SamplePlateSetup:NumberOfSamples |
---|
2173 | if(!NVAR_Exists(NumberOfSamples)) |
---|
2174 | variable/g root:Packages:SamplePlateSetup:NumberOfSamples |
---|
2175 | NVAR NumberOfSamples = root:Packages:SamplePlateSetup:NumberOfSamples |
---|
2176 | endif |
---|
2177 | |
---|
2178 | //SAXS LBSelectionWvG[i][5]==48 |
---|
2179 | //WAXS LBSelectionWvG[i][6]==48 |
---|
2180 | //USAXS LBSelectionWvG[i][4]==48 |
---|
2181 | //constant IN3BmSrvUSAXSOverhead = 25 //overhead for flyscan |
---|
2182 | //constant IN3BmSrvSAXSOverhead = 10 //overhead for SAXS, transmission measurement |
---|
2183 | //constant IN3BmSrvWAXSOverhead = 3 //overhead for WAXS |
---|
2184 | //constant IN3BmSrvSampleMoveSpeed = 8 //average moving samples around in mm/sec |
---|
2185 | //constant IN3BmSrvTuneTimeStep = 600 //retune every 600 seconds |
---|
2186 | //constant IN3BmSrvTuneTimeNumU = 3 //retune every 3 USAXS scans |
---|
2187 | //constant IN3BmSrvTuneAveTime = 40 //retune takes avergate 40 seconds full preUSAXStune is 40 seconds... |
---|
2188 | //constant IN3BmSrvSWTuneAveTime = 14 //SWAXS tune MR |
---|
2189 | //constant IN3BmSrvMoveGeometryTime = 20 //overhead to mvoe from USAXS to SAXS to WAXS |
---|
2190 | variable NumUSAXS, NumSAXS, NumWAXS, numSamples |
---|
2191 | variable i, isused |
---|
2192 | variable lastSXSAXS, lastSYSAXS, totalSXSYSAXS, firstSXSAXS, firstSYSAXS |
---|
2193 | variable lastSXUSAXS, lastSYUSAXS, totalSXSYUSAXS, firstSXUSAXS, firstSYUSAXS |
---|
2194 | variable lastSXWAXS, lastSYWAXS, totalSXSYWAXS, firstSXWAXS, firstSYWAXS |
---|
2195 | variable SWAXSTime=0 |
---|
2196 | NumUSAXS=0 |
---|
2197 | NumSAXS=0 |
---|
2198 | NumWAXS=0 |
---|
2199 | lastSXSAXS = str2num(listWaveG[0][1]) |
---|
2200 | lastSYSAXS = str2num(listWaveG[0][2]) |
---|
2201 | firstSXSAXS = str2num(listWaveG[0][1]) |
---|
2202 | firstSYSAXS = str2num(listWaveG[0][2]) |
---|
2203 | lastSXUSAXS = str2num(listWaveG[0][1]) |
---|
2204 | lastSYUSAXS = str2num(listWaveG[0][2]) |
---|
2205 | firstSXUSAXS = str2num(listWaveG[0][1]) |
---|
2206 | firstSYUSAXS = str2num(listWaveG[0][2]) |
---|
2207 | lastSXWAXS = str2num(listWaveG[0][1]) |
---|
2208 | lastSYWAXS = str2num(listWaveG[0][2]) |
---|
2209 | firstSXWAXS = str2num(listWaveG[0][1]) |
---|
2210 | firstSYWAXS = str2num(listWaveG[0][2]) |
---|
2211 | For(i=0;i<dimsize(listWaveG,0);i+=1) |
---|
2212 | isused = (strlen(listWaveG[i][0])>0 && strlen(listWaveG[i][1])>0 && strlen(listWaveG[i][2])>0) |
---|
2213 | if((SAXSAllG || LBSelectionWvG[i][5]==48)&& isused ) |
---|
2214 | NumSAXS+=1 |
---|
2215 | totalSXSYSAXS += sqrt((str2num(listWaveG[i][1])-lastSXSAXS)^2 + (str2num(listWaveG[i][2])-lastSYSAXS)^2 ) |
---|
2216 | lastSXSAXS = str2num(listWaveG[i][1]) |
---|
2217 | lastSYSAXS = str2num(listWaveG[i][2]) |
---|
2218 | endif |
---|
2219 | if((WAXSAllG || LBSelectionWvG[i][6]==48)&& isused ) |
---|
2220 | NumWAXS+=1 |
---|
2221 | totalSXSYWAXS += sqrt((str2num(listWaveG[i][1])-lastSXWAXS)^2 + (str2num(listWaveG[i][2])-lastSYWAXS)^2 ) |
---|
2222 | lastSXWAXS = str2num(listWaveG[i][1]) |
---|
2223 | lastSYWAXS = str2num(listWaveG[i][2]) |
---|
2224 | endif |
---|
2225 | if((USAXSAllG || LBSelectionWvG[i][4]==48)&& isused ) |
---|
2226 | NumUSAXS+=1 |
---|
2227 | totalSXSYUSAXS += sqrt((str2num(listWaveG[i][1])-lastSXUSAXS)^2 + (str2num(listWaveG[i][2])-lastSYUSAXS)^2 ) |
---|
2228 | lastSXUSAXS = str2num(listWaveG[i][1]) |
---|
2229 | lastSYUSAXS = str2num(listWaveG[i][2]) |
---|
2230 | endif |
---|
2231 | endfor |
---|
2232 | numSamples = max(NumUSAXS, NumSAXS, NumWAXS) |
---|
2233 | NumberOfSamples = numSamples |
---|
2234 | |
---|
2235 | CalculatedOverAllTime = NumUSAXS*(USAXSScanTime+IN3BmSrvUSAXSOverhead)+totalSXSYUSAXS/IN3BmSrvSampleMoveSpeed+NumUSAXS //this is USAXS |
---|
2236 | // USAXS scans + Total distance/ speed + assume 1 second speed ramp up and down |
---|
2237 | if(NumUSAXS>0) |
---|
2238 | //move to USAXS geometry.... |
---|
2239 | CalculatedOverAllTime += IN3BmSrvMoveGeometryTime //USAXS->SAXS |
---|
2240 | //travel from end to start... |
---|
2241 | CalculatedOverAllTime += sqrt((lastSXUSAXS-firstSXSAXS)^2+(lastSYUSAXS-firstSXSAXS)^2)/IN3BmSrvSampleMoveSpeed //last sample to first sample |
---|
2242 | endif |
---|
2243 | |
---|
2244 | CalculatedOverAllTime += NumSAXS*(SAXSScanTime+IN3BmSrvSAXSOverhead)+totalSXSYSAXS/IN3BmSrvSampleMoveSpeed+NumSAXS //SAXS |
---|
2245 | // SAXS scans + Total distance/ speed + assume 1 second speed ramp up and down |
---|
2246 | SWAXSTime = NumSAXS*(SAXSScanTime+IN3BmSrvSAXSOverhead)+totalSXSYSAXS/IN3BmSrvSampleMoveSpeed+NumSAXS |
---|
2247 | if(NumSAXS>0) |
---|
2248 | //move to SAXS geometry.... |
---|
2249 | CalculatedOverAllTime += IN3BmSrvMoveGeometryTime //SAXS->WAXS |
---|
2250 | //travel from end to start |
---|
2251 | CalculatedOverAllTime += sqrt((lastSXSAXS-firstSXWAXS)^2+(lastSYSAXS-firstSXWAXS)^2)/IN3BmSrvSampleMoveSpeed //last sample to first sample |
---|
2252 | endif |
---|
2253 | CalculatedOverAllTime += NumWAXS*(WAXSScanTime+IN3BmSrvWAXSOverhead)+totalSXSYWAXS/IN3BmSrvSampleMoveSpeed+NumWAXS //WAXS |
---|
2254 | // WAXS scans + Total distance/ speed + assume 1 second speed ramp up and down |
---|
2255 | SWAXSTime += NumWAXS*(WAXSScanTime+IN3BmSrvWAXSOverhead)+totalSXSYWAXS/IN3BmSrvSampleMoveSpeed+NumWAXS |
---|
2256 | if(NumWAXS>0) |
---|
2257 | //move to WAXS geometry.... |
---|
2258 | CalculatedOverAllTime += IN3BmSrvMoveGeometryTime //WAXS->USAXS |
---|
2259 | //travel from end to start |
---|
2260 | CalculatedOverAllTime += sqrt((lastSXWAXS-firstSXUSAXS)^2+(lastSYWAXS-firstSXUSAXS)^2)/IN3BmSrvSampleMoveSpeed //last sample to first sample |
---|
2261 | endif |
---|
2262 | variable NumSWTunes = floor(SWAXSTime / IN3BmSrvTuneTimeStep) //this is approximate number of SAXS/WAXS tunes * tune time |
---|
2263 | variable NumUSAXStunes = floor(NumUSAXS/IN3BmSrvTuneTimeNumU) //this is typical number of USAXS related tunes (3 flyscans/tune) |
---|
2264 | CalculatedOverAllTime += NumSWTunes*IN3BmSrvSWTuneAveTime + NumUSAXStunes*IN3BmSrvTuneAveTime |
---|
2265 | //done, calculated average scan time for all which are well defined. |
---|
2266 | CalculatedOverAllTime/=60 //convert to minutes |
---|
2267 | CalculatedOverAllTime = round(CalculatedOverAllTime) |
---|
2268 | end |
---|
2269 | |
---|
2270 | //************************************************************************************************************ |
---|
2271 | //************************************************************************************************************ |
---|
2272 | |
---|
2273 | Function IN3S_CreateDefaultPlates() |
---|
2274 | |
---|
2275 | DFrEF OldDf=GetDataFolderDFR() |
---|
2276 | setdatafolder root: |
---|
2277 | NewDataFolder/O/S root:Packages |
---|
2278 | NewDataFolder/O/S SamplePlatesAvailable |
---|
2279 | //Definitions for: |
---|
2280 | //Acrylic9x9Plate = 9x9 Acrylic/magnetic plate |
---|
2281 | //OldStyleAlPlate = Old Style Al Plate |
---|
2282 | //NMRTubesHolder = NMR Tubes holder 300mm x 75mm, sample center sy=25mm |
---|
2283 | make/O/N=(81,2) Acrylic9x9PlateCenters |
---|
2284 | make/O/N=(100,2) AcrylicNMRPlateCenters |
---|
2285 | make/O/N=(60,2) OldStyleAlPlateCenters |
---|
2286 | make/O/N=(20,2) NMRTubesHolderCenters |
---|
2287 | make/O/N=(0,2) GenericGridHolderCenters |
---|
2288 | |
---|
2289 | string ListOfVariables |
---|
2290 | string ListOfStrings |
---|
2291 | variable i, j |
---|
2292 | |
---|
2293 | ListOfVariables="OldStyleAlPlateRadius;OldStyleAlPlateScale;" |
---|
2294 | ListOfVariables+="Acrylic9x9PlateRadius;Acrylic9x9PlateScale;AcrylicNMRPlateScale;" |
---|
2295 | ListOfVariables+="NMRTubesHolderRadius;NMRTubesHolderScale;" |
---|
2296 | |
---|
2297 | ListOfStrings="" |
---|
2298 | //and here we create them |
---|
2299 | for(i=0;i<itemsInList(ListOfVariables);i+=1) |
---|
2300 | IN2G_CreateItem("variable",StringFromList(i,ListOfVariables)) |
---|
2301 | endfor |
---|
2302 | for(i=0;i<itemsInList(ListOfStrings);i+=1) |
---|
2303 | IN2G_CreateItem("string",StringFromList(i,ListOfStrings)) |
---|
2304 | endfor |
---|
2305 | |
---|
2306 | //setup parameters |
---|
2307 | NVAR Acrylic9x9PlateRadius |
---|
2308 | NVAR Acrylic9x9PlateScale |
---|
2309 | Acrylic9x9PlateRadius = 4 //radius of sample hole in mm |
---|
2310 | Acrylic9x9PlateScale = 0.25 //pixels per mm |
---|
2311 | NVAR AcrylicNMRPlateScale |
---|
2312 | AcrylicNMRPlateScale = 0.25 //pixels per mm |
---|
2313 | Wave Acrylic9x9PlateCenters |
---|
2314 | Acrylic9x9PlateCenters[][0] = 20*ceil(0.01+p/9) |
---|
2315 | Acrylic9x9PlateCenters[][1] = 20+20*(p - 9*trunc(p/9)) |
---|
2316 | //NMT Acrylic plate |
---|
2317 | Wave AcrylicNMRPlateCenters |
---|
2318 | AcrylicNMRPlateCenters[][0] = 10+10*(p - 20*trunc(p/20)) ///10*ceil(0.01+p/19) |
---|
2319 | AcrylicNMRPlateCenters[][1] = 24.181 + 40*(ceil(0.01+p/20)-1) ///24.181+40*(p - 20*trunc(p/20)) |
---|
2320 | |
---|
2321 | //Al plate here |
---|
2322 | NVAR OldStyleAlPlateRadius |
---|
2323 | OldStyleAlPlateRadius=4 |
---|
2324 | NVAR OldStyleAlPlateScale |
---|
2325 | OldStyleAlPlateScale = 0.25 |
---|
2326 | Wave OldStyleAlPlateCenters |
---|
2327 | For(i=0;i<4;i+=1) |
---|
2328 | For(j=0;j<8;j+=1) |
---|
2329 | OldStyleAlPlateCenters[i*15+j][0] = 12.5+i*25 |
---|
2330 | endfor |
---|
2331 | For(j=8;j<15;j+=1) |
---|
2332 | OldStyleAlPlateCenters[i*15+j][0] = 25+i*25 |
---|
2333 | endfor |
---|
2334 | endfor |
---|
2335 | For(i=0;i<4;i+=1) |
---|
2336 | For(j=0;j<8;j+=1) |
---|
2337 | OldStyleAlPlateCenters[i*15+j][1] = 12.5+j*25 |
---|
2338 | endfor |
---|
2339 | For(j=8;j<15;j+=1) |
---|
2340 | OldStyleAlPlateCenters[i*15+j][1] = 25+(j-8)*25 |
---|
2341 | endfor |
---|
2342 | endfor |
---|
2343 | //NMR tubes holder here |
---|
2344 | NVAR NMRTubesHolderRadius |
---|
2345 | NVAR NMRTubesHolderScale |
---|
2346 | NMRTubesHolderRadius=20 |
---|
2347 | NMRTubesHolderScale=0.25 |
---|
2348 | Wave NMRTubesHolderCenters |
---|
2349 | NMRTubesHolderCenters[][0] = 15+p*10 |
---|
2350 | NMRTubesHolderCenters[][1] = 43 |
---|
2351 | SetDataFolder OldDf |
---|
2352 | end |
---|
2353 | |
---|
2354 | //***************************************************************************************************************** |
---|
2355 | //***************************************************************************************************************** |
---|
2356 | static Function IN3S_CreateTablesForPlates(HowManySamples, forceReset) |
---|
2357 | variable HowManySamples, forceReset //set forceReset=1 to rezero all waves. |
---|
2358 | |
---|
2359 | DFrEF OldDf=GetDataFolderDFR() |
---|
2360 | setdatafolder root:Packages:SamplePlateSetup |
---|
2361 | Wave/T/Z LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
2362 | Wave/Z LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
2363 | Make/N=8/T/O LBTtitleWv |
---|
2364 | if(forceReset || !WaveExists(LBSelectionWv) || !WaveExists(LBCommandWv)) |
---|
2365 | Make/N=(0,8)/T/O LBCommandWv |
---|
2366 | Make/N=(0,8)/O LBSelectionWv |
---|
2367 | endif |
---|
2368 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
2369 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
2370 | Wave/T LBTtitleWv = root:Packages:SamplePlateSetup:LBTtitleWv |
---|
2371 | if(DimSize(LBSelectionWv,0)<1 && HowManySamples<1) |
---|
2372 | HowManySamples = 20 |
---|
2373 | endif |
---|
2374 | if(HowManySamples>0) |
---|
2375 | Redimension/N=(HowManySamples,8) LBCommandWv, LBSelectionWv |
---|
2376 | endif |
---|
2377 | LBTtitleWv = {"Sample Name", "X [mm]", "Y [mm]", "Thick [mm]", "USAXS", "SAXS", "WAXS", "MetaData"} |
---|
2378 | //setup the LBSelectionWv to allow what is needed... |
---|
2379 | LBSelectionWv[][0] = 2 //set Bit 1, 0x02 |
---|
2380 | LBSelectionWv[][1] = 2 //set Bit 1, |
---|
2381 | LBSelectionWv[][2] = 2 //set Bit 1, |
---|
2382 | LBSelectionWv[][3] = 2 //set Bit 1, |
---|
2383 | LBSelectionWv[][7] = 2 //set Bit 1, |
---|
2384 | IN3S_SetAllOptions() |
---|
2385 | SetDataFolder OldDf |
---|
2386 | end |
---|
2387 | //***************************************************************************************************************** |
---|
2388 | //***************************************************************************************************************** |
---|
2389 | //***************************************************************************************************************** |
---|
2390 | static Function IN3S_SetAllOptions() |
---|
2391 | |
---|
2392 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
2393 | NVAR USAXSAll = root:Packages:SamplePlateSetup:USAXSAll |
---|
2394 | if(USAXSAll) |
---|
2395 | LBSelectionWv[][4]=48 |
---|
2396 | else |
---|
2397 | LBSelectionWv[][4]=32 |
---|
2398 | endif |
---|
2399 | NVAR SAXSAll = root:Packages:SamplePlateSetup:SAXSAll |
---|
2400 | if(SAXSAll) |
---|
2401 | LBSelectionWv[][5]=48 |
---|
2402 | else |
---|
2403 | LBSelectionWv[][5]=32 |
---|
2404 | endif |
---|
2405 | NVAR WAXSAll = root:Packages:SamplePlateSetup:WAXSAll |
---|
2406 | if(WAXSAll) |
---|
2407 | LBSelectionWv[][6]=48 |
---|
2408 | else |
---|
2409 | LBSelectionWv[][6]=32 |
---|
2410 | endif |
---|
2411 | end |
---|
2412 | //***************************************************************************************************************** |
---|
2413 | //***************************************************************************************************************** |
---|
2414 | //***************************************************************************************************************** |
---|
2415 | // |
---|
2416 | static Function IN3S_InsertDeleteLines(InsertDelete, row, newLines) //InsertDelete = 1 for insert, 2 for delete |
---|
2417 | variable InsertDelete, row, newLines //3 duplicate and add there, 4 add at the end. |
---|
2418 | //newLines used only with InsertDelete=4 and is number of new lines. |
---|
2419 | |
---|
2420 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
2421 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
2422 | variable i |
---|
2423 | if(InsertDelete==1) //insert. |
---|
2424 | InsertPoints row, 1, LBSelectionWv, LBCommandWv |
---|
2425 | LBSelectionWv[row][0]=2 |
---|
2426 | LBSelectionWv[row][1]=2 |
---|
2427 | LBSelectionWv[row][2]=2 |
---|
2428 | LBSelectionWv[row][3]=2 |
---|
2429 | NVAR USAXSAll = root:Packages:SamplePlateSetup:USAXSAll |
---|
2430 | if(USAXSAll) |
---|
2431 | LBSelectionWv[row][4]=48 |
---|
2432 | else |
---|
2433 | LBSelectionWv[row][4]=32 |
---|
2434 | endif |
---|
2435 | NVAR SAXSAll = root:Packages:SamplePlateSetup:SAXSAll |
---|
2436 | if(SAXSAll) |
---|
2437 | LBSelectionWv[row][5]=48 |
---|
2438 | else |
---|
2439 | LBSelectionWv[row][5]=32 |
---|
2440 | endif |
---|
2441 | NVAR WAXSAll = root:Packages:SamplePlateSetup:WAXSAll |
---|
2442 | if(WAXSAll) |
---|
2443 | LBSelectionWv[row][6]=48 |
---|
2444 | else |
---|
2445 | LBSelectionWv[row][6]=32 |
---|
2446 | endif |
---|
2447 | //ListBox CommandsList win=SamplePlateSetup, selRow=row |
---|
2448 | LBSelectionWv[][0]=2 |
---|
2449 | LBSelectionWv[row][0]=3 |
---|
2450 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
2451 | WarningForUser = "Inserted row number "+ num2str(row) |
---|
2452 | elseif(InsertDelete==2) //delete, easier... |
---|
2453 | if(dimsize(LBSelectionWv,0)>1) |
---|
2454 | DeletePoints /M=0 row, 1, LBSelectionWv, LBCommandWv |
---|
2455 | variable newrow |
---|
2456 | newrow = row<(dimSize(LBCommandWv,0))?row : row-1 |
---|
2457 | //ListBox CommandsList win=SamplePlateSetup, selRow=newrow |
---|
2458 | LBSelectionWv[][0]=2 |
---|
2459 | LBSelectionWv[newrow][0]=3 |
---|
2460 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
2461 | WarningForUser = "Deleted row number "+ num2str(row) |
---|
2462 | else |
---|
2463 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
2464 | WarningForUser = "Cannot delete last row ! " |
---|
2465 | endif |
---|
2466 | elseif(InsertDelete==3) //duplicate |
---|
2467 | Duplicate/Free/T/R=[row][] LBCommandWv, tempLBCommandWv |
---|
2468 | Duplicate/Free/R=[row][] LBSelectionWv, tempLBSelectionWv |
---|
2469 | InsertPoints row, 1, LBSelectionWv, LBCommandWv |
---|
2470 | LBCommandWv[row][] = tempLBCommandWv[0][q] |
---|
2471 | LBSelectionWv[row][] = tempLBSelectionWv[0][q] |
---|
2472 | //ListBox CommandsList win=SamplePlateSetup, selRow=row+1 |
---|
2473 | LBSelectionWv[][0]=2 |
---|
2474 | LBSelectionWv[row+1][0]=3 |
---|
2475 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
2476 | WarningForUser = "Duplicated row number "+ num2str(row) |
---|
2477 | elseif(InsertDelete==4) //add line at the end |
---|
2478 | variable Curlength=dimsize(LBCommandWv,0) |
---|
2479 | Redimension/N=(Curlength+newLines,-1) LBCommandWv, LBSelectionWv |
---|
2480 | LBSelectionWv[Curlength, ][0]=2 |
---|
2481 | LBSelectionWv[Curlength, ][1]=2 |
---|
2482 | LBSelectionWv[Curlength, ][2]=2 |
---|
2483 | LBSelectionWv[Curlength, ][3]=2 |
---|
2484 | NVAR USAXSAll = root:Packages:SamplePlateSetup:USAXSAll |
---|
2485 | if(USAXSAll) |
---|
2486 | LBSelectionWv[Curlength, ][4]=48 |
---|
2487 | else |
---|
2488 | LBSelectionWv[Curlength, ][4]=32 |
---|
2489 | endif |
---|
2490 | NVAR SAXSAll = root:Packages:SamplePlateSetup:SAXSAll |
---|
2491 | if(SAXSAll) |
---|
2492 | LBSelectionWv[Curlength, ][5]=48 |
---|
2493 | else |
---|
2494 | LBSelectionWv[Curlength, ][5]=32 |
---|
2495 | endif |
---|
2496 | NVAR WAXSAll = root:Packages:SamplePlateSetup:WAXSAll |
---|
2497 | if(WAXSAll) |
---|
2498 | LBSelectionWv[Curlength, ][6]=48 |
---|
2499 | else |
---|
2500 | LBSelectionWv[Curlength, ][6]=32 |
---|
2501 | endif |
---|
2502 | //ListBox CommandsList win=SamplePlateSetup, selRow=Curlength |
---|
2503 | LBSelectionWv[][0]=2 |
---|
2504 | LBSelectionWv[Curlength][0]=3 |
---|
2505 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
2506 | WarningForUser = "Added row at the end " |
---|
2507 | endif |
---|
2508 | end |
---|
2509 | //***************************************************************************************************************** |
---|
2510 | //***************************************************************************************************************** |
---|
2511 | //***************************************************************************************************************** |
---|
2512 | //***************************************************************************************************************** |
---|
2513 | //this is from //https://www.wavemetrics.com/code-snippet/listbox-drag-drop, version 1.60, 1-13-2022 |
---|
2514 | |
---|
2515 | |
---|
2516 | function IN3S_DragDropListBoxProc(STRUCT WMListboxAction &lba) |
---|
2517 | |
---|
2518 | |
---|
2519 | if(!(lba.eventCode & 0x03)) // neither mouseup nor mousedown |
---|
2520 | return 0 |
---|
2521 | endif |
---|
2522 | |
---|
2523 | variable f = 72/PanelResolution(lba.win) // point/pixel |
---|
2524 | int dragStarted = strlen(GetUserData(lba.win, lba.ctrlName, "drag")) |
---|
2525 | string otherListBox = SelectString(cmpstr(lba.ctrlName, "SourceBox")==0, "SourceBox", "TargetBox") |
---|
2526 | string items |
---|
2527 | variable j |
---|
2528 | |
---|
2529 | if (lba.eventCode==2 && dragStarted) // mouseup, drag completed |
---|
2530 | // find whether mouse is within OTHER listbox |
---|
2531 | if(IN3S_isInControl(lba.mouseLoc, lba.win, otherListBox)) |
---|
2532 | ControlInfo /W=$lba.win $otherListBox |
---|
2533 | int beforeItem = round(V_startRow + (lba.mouseLoc.v-V_top/f)/V_rowHeight) |
---|
2534 | wave /SDFR=$S_DataFolder otherListBoxWave=$S_Value |
---|
2535 | beforeItem = limit(beforeItem, 0, numpnts(otherListBoxWave)) |
---|
2536 | IN3S_copySelection(otherListBox, lba.selwave, lba.listwave, beforeItem) |
---|
2537 | endif |
---|
2538 | ListBox $lba.ctrlName, win=$lba.win, userdata(drag)="" |
---|
2539 | endif |
---|
2540 | //add right click to remove right column data |
---|
2541 | if(lba.eventCode==1 && lba.eventMod & 0x10) |
---|
2542 | if(stringmatch(nameofWave(lba.listWave),"ListOfWavesForExport")) |
---|
2543 | items = "DeleteRow;" |
---|
2544 | PopupContextualMenu items |
---|
2545 | switch (V_flag) |
---|
2546 | case 1: // "Delete row" |
---|
2547 | DeletePoints /M=0 lba.row, 1, lba.listWave, lba.selWave |
---|
2548 | break; |
---|
2549 | endswitch |
---|
2550 | endif |
---|
2551 | endif |
---|
2552 | |
---|
2553 | if(lba.eventCode==1 && dragStarted==0) // mousedown, new drag |
---|
2554 | if( lba.row < 0 || lba.row >= (DimSize(lba.listWave, 0)) ) |
---|
2555 | return 0 |
---|
2556 | endif |
---|
2557 | //this can be done only from right to left... |
---|
2558 | if(cmpstr(lba.ctrlName, "SourceBox")) |
---|
2559 | return 0 |
---|
2560 | endif |
---|
2561 | |
---|
2562 | int i, numBoxes, startrow, endrow, mode, fontSize |
---|
2563 | |
---|
2564 | // figure out visible rows |
---|
2565 | ControlInfo /W=$lba.win $lba.ctrlName |
---|
2566 | startrow = V_startRow |
---|
2567 | endrow = min(numpnts(lba.selwave)-1, startrow + ceil((V_height/f/V_rowHeight)-2)) |
---|
2568 | // record current value of mode & fsize |
---|
2569 | string strMode, strFsize |
---|
2570 | SplitString/E=("mode=\s?([[:digit:]]+)") S_recreation, strMode |
---|
2571 | mode = strlen(strMode) ? str2num(strMode) : 1 |
---|
2572 | SplitString/E=("fSize=\s?([[:digit:]]+)") S_recreation, strFsize |
---|
2573 | fontSize = strlen(strFsize) ? str2num(strFsize) : 9 |
---|
2574 | // stops cell selection as mouse moves by setting mode=0 |
---|
2575 | ListBox $lba.ctrlName, win=$lba.win, userdata(drag)="started", mode=0 |
---|
2576 | // userdata(drag) indicates dragging is active, cleared on mouseup |
---|
2577 | |
---|
2578 | // create a titlebox for every visible selected item |
---|
2579 | numBoxes=0 |
---|
2580 | string DBname, strTitle |
---|
2581 | variable height, width, top , left |
---|
2582 | for (i=startrow;i<endrow+1;i++) |
---|
2583 | if (lba.selwave[i] & 0x09) |
---|
2584 | wave /T listwave=lba.listWave |
---|
2585 | DBname = "DragBox" + num2str(numBoxes) |
---|
2586 | height = f*(V_rowHeight-1) |
---|
2587 | width = f*(lba.ctrlRect.right-lba.ctrlRect.left) |
---|
2588 | top = f*(lba.ctrlRect.top+(i-startrow)*V_rowHeight+1.5) |
---|
2589 | left = f*lba.ctrlRect.left |
---|
2590 | sprintf strTitle, "\\sa%+03d\\x%+03d %s", 3-(fontSize>12), (20-fontSize)*0.625, listwave[i] |
---|
2591 | TitleBox $DBname, win=$lba.win, title=strTitle, labelBack=(41760,52715,65482), pos={left, top} |
---|
2592 | TitleBox $DBname, win=$lba.win, fsize=fontSize, fixedSize=1, frame=0, size={width, height} |
---|
2593 | numBoxes ++ |
---|
2594 | endif |
---|
2595 | endfor |
---|
2596 | |
---|
2597 | // save coordinates of other listbox |
---|
2598 | ControlInfo /W=$lba.win $otherListBox |
---|
2599 | struct rect pixelRect |
---|
2600 | pixelRect.left = v_left/f // point -> pixel |
---|
2601 | pixelRect.right = v_right/f |
---|
2602 | pixelRect.top = v_top/f |
---|
2603 | pixelRect.bottom = pixelRect.top + v_height/f |
---|
2604 | |
---|
2605 | // monitor mouse movement until mouseup |
---|
2606 | variable dx, dy, buttondown |
---|
2607 | |
---|
2608 | do |
---|
2609 | GetMouse /W=$lba.win |
---|
2610 | buttondown = V_flag & 1 |
---|
2611 | dx = v_left - lba.mouseLoc.h // pixels |
---|
2612 | dy = v_top - lba.mouseLoc.v // pixels |
---|
2613 | // keep current mouse position updated as mouse moves |
---|
2614 | lba.mouseLoc.h = v_left |
---|
2615 | lba.mouseLoc.v = v_top |
---|
2616 | |
---|
2617 | // move titleboxes with mouse |
---|
2618 | for(i=0; i<numBoxes; i++) |
---|
2619 | TitleBox /Z $"DragBox"+num2str(i), win=$lba.win, pos+={dx,dy} |
---|
2620 | endfor |
---|
2621 | |
---|
2622 | // draw focus ring when mouse is over other listbox |
---|
2623 | if (IN3S_pointInRect(lba.mouseLoc, pixelRect)) // all units are pixels |
---|
2624 | ListBox $otherListBox, win=$lba.win, focusRing=1 |
---|
2625 | ModifyControl $otherListBox activate |
---|
2626 | else |
---|
2627 | ModifyControl $lba.ctrlName activate |
---|
2628 | endif |
---|
2629 | |
---|
2630 | DoUpdate /W=$lba.win |
---|
2631 | while(buttondown) |
---|
2632 | |
---|
2633 | // clear titleboxes and return listboxes to normal mode |
---|
2634 | for(i=0; i<numBoxes; i++) |
---|
2635 | KillControl /W=$lba.win $"DragBox"+num2str(i) |
---|
2636 | endfor |
---|
2637 | ListBox $otherListBox, win=$lba.win, focusRing=0 |
---|
2638 | ListBox $lba.ctrlName, win=$lba.win, mode=mode |
---|
2639 | ModifyControl $lba.ctrlName activate |
---|
2640 | endif // end of drag |
---|
2641 | end |
---|
2642 | |
---|
2643 | //***************************************************************************************************************** |
---|
2644 | //***************************************************************************************************************** |
---|
2645 | |
---|
2646 | static function IN3S_copySelection(string toLB, wave selwave, wave /T listwave, variable beforeItem) |
---|
2647 | |
---|
2648 | Extract /free/T listwave, switchwave, (selwave & 0x09) |
---|
2649 | //Extract /O/T listwave, listwave, !(selwave & 0x09) //this fremoves teh line from teh source, we want to keep it... |
---|
2650 | //Extract /O selwave, selwave, !(selwave & 0x09) |
---|
2651 | wave destSelWave = root:Packages:SamplePlateSetup:SelListOfWavesForExport |
---|
2652 | wave/T destListWave = root:Packages:SamplePlateSetup:ListOfWavesForExport |
---|
2653 | destSelWave = 0 |
---|
2654 | variable numItems = numpnts(switchwave) |
---|
2655 | InsertPoints beforeItem, numItems, destSelWave, destListWave |
---|
2656 | destSelWave[beforeItem, beforeItem+numItems-1] = 1 |
---|
2657 | destListWave[beforeItem, beforeItem+numItems-1] = switchwave[p-beforeItem] |
---|
2658 | end |
---|
2659 | //***************************************************************************************************************** |
---|
2660 | //***************************************************************************************************************** |
---|
2661 | |
---|
2662 | // point and rect structures must have same units |
---|
2663 | static function IN3S_pointInRect(STRUCT point &pnt, STRUCT rect &r) |
---|
2664 | return ( pnt.h>r.left && pnt.h<r.right && pnt.v>r.top && pnt.v<r.bottom ) |
---|
2665 | end |
---|
2666 | //***************************************************************************************************************** |
---|
2667 | //***************************************************************************************************************** |
---|
2668 | |
---|
2669 | static function IN3S_isInControl(STRUCT point &mouse, string strWin, string strCtrl) |
---|
2670 | ControlInfo /W=$strWin $strCtrl |
---|
2671 | variable f = 72/PanelResolution(strWin) |
---|
2672 | variable hpoint = mouse.h * f |
---|
2673 | variable vpoint = mouse.v * f |
---|
2674 | return ( hpoint>V_left && hpoint<(V_right) && vpoint>V_top && vpoint<(V_top+V_height) ) |
---|
2675 | end |
---|
2676 | |
---|
2677 | //***************************************************************************************************************** |
---|
2678 | //***************************************************************************************************************** |
---|
2679 | //***************************************************************************************************************** |
---|
2680 | //***************************************************************************************************************** |
---|
2681 | static Function IN3S_DrawImageOfPlate(WhichOne) |
---|
2682 | string WhichOne |
---|
2683 | |
---|
2684 | //WhichOne = "9x9 Acrylic/magnetic plate" |
---|
2685 | |
---|
2686 | DFrEF OldDf=GetDataFolderDFR() |
---|
2687 | setdatafolder root:Packages:SamplePlatesAvailable |
---|
2688 | KillWindow/Z SamplePlateImageDrawing |
---|
2689 | variable HorSize, VertSize |
---|
2690 | if(stringMatch(whichOne,"9x9 Acrylic/magnetic plate")) |
---|
2691 | Wave Centers = root:Packages:SamplePlatesAvailable:Acrylic9x9PlateCenters |
---|
2692 | NVAR Radius = root:Packages:SamplePlatesAvailable:Acrylic9x9PlateRadius |
---|
2693 | NVAR Scaling = root:Packages:SamplePlatesAvailable:Acrylic9x9PlateScale |
---|
2694 | //plate is 304.8mm wide x 200mm high, use 1200x800 wave, 0.25mm pixel scaling. |
---|
2695 | HorSize = 300/Scaling |
---|
2696 | VertSize = 200/Scaling |
---|
2697 | Make/O/N=(HorSize,VertSize)/B/U PlateImage |
---|
2698 | wave PlateImage |
---|
2699 | //PlateImage = 128 //set image to 128, that is medium grey in our color system. |
---|
2700 | SetScale/P x 0,Scaling,"mm", PlateImage |
---|
2701 | SetScale/P y 0,Scaling,"mm", PlateImage |
---|
2702 | Duplicate/Free Centers, CentersForDrawing |
---|
2703 | //create circles, set image to 128, that is medium grey in our color system in solid and 0 in opening for samples. |
---|
2704 | IN3S_CreateCircles(PlateImage, CentersForDrawing, Radius, Scaling) |
---|
2705 | elseif(stringMatch(whichOne,"NMR Acrylic plate")) |
---|
2706 | Wave Centers = root:Packages:SamplePlatesAvailable:AcrylicNMRPlateCenters |
---|
2707 | //NVAR Radius = root:Packages:SamplePlatesAvailable:Acrylic9x9PlateRadius |
---|
2708 | NVAR Scaling = root:Packages:SamplePlatesAvailable:AcrylicNMRPlateScale |
---|
2709 | //plate is 330.2mm wide x 200mm high, use 1200x800 wave, 0.25mm pixel scaling. |
---|
2710 | HorSize = 330/Scaling |
---|
2711 | VertSize = 200/Scaling |
---|
2712 | Make/O/N=(HorSize,VertSize)/B/U PlateImage |
---|
2713 | wave PlateImage |
---|
2714 | //PlateImage = 128 //set image to 128, that is medium grey in our color system. |
---|
2715 | SetScale/P x 0,Scaling,"mm", PlateImage |
---|
2716 | SetScale/P y 0,Scaling,"mm", PlateImage |
---|
2717 | Duplicate/Free Centers, CentersForDrawing |
---|
2718 | //create NMR tubes, set image to 128, that is medium grey in our color system in solid and 0 in opening for samples. |
---|
2719 | IN3S_CreateNMRTubes(PlateImage, CentersForDrawing, Scaling) |
---|
2720 | elseif(stringMatch(whichOne,"Old Style Al Plate")) |
---|
2721 | Wave Centers = root:Packages:SamplePlatesAvailable:OldStyleAlPlateCenters |
---|
2722 | NVAR Radius = root:Packages:SamplePlatesAvailable:OldStyleAlPlateRadius |
---|
2723 | NVAR Scaling = root:Packages:SamplePlatesAvailable:OldStyleAlPlateScale |
---|
2724 | //plate is 250mm wide x 200mm high, use 1000x800 wave, 0.25mm pixel scaling. |
---|
2725 | HorSize = 250/Scaling |
---|
2726 | VertSize = 200/Scaling |
---|
2727 | Make/O/N=(HorSize,VertSize)/B/U PlateImage |
---|
2728 | wave PlateImage |
---|
2729 | //PlateImage = 128 //set image to 128, that is medium grey in our color system. |
---|
2730 | SetScale/P x 0,Scaling,"mm", PlateImage |
---|
2731 | SetScale/P y 0,Scaling,"mm", PlateImage |
---|
2732 | Duplicate/Free Centers, CentersForDrawing |
---|
2733 | //create circles, set image to 128, that is medium grey in our color system in solid and 0 in opening for samples. |
---|
2734 | IN3S_CreateCircles(PlateImage, CentersForDrawing, Radius, Scaling) |
---|
2735 | elseif(stringMatch(whichOne,"NMR Tubes holder")) |
---|
2736 | Wave Centers = root:Packages:SamplePlatesAvailable:NMRTubesHolderCenters |
---|
2737 | NVAR Radius = root:Packages:SamplePlatesAvailable:NMRTubesHolderRadius |
---|
2738 | NVAR Scaling = root:Packages:SamplePlatesAvailable:NMRTubesHolderScale |
---|
2739 | //plate is 300mm wide x 75mm high, use 1200x300 wave with 0.25mm pixel scaling. |
---|
2740 | HorSize = 300/Scaling |
---|
2741 | VertSize = 75/Scaling |
---|
2742 | Make/O/N=(HorSize,VertSize)/B/U PlateImage |
---|
2743 | wave PlateImage |
---|
2744 | //PlateImage = 128 //set image to 128, that is medium grey in our color system. |
---|
2745 | SetScale/P x 0,Scaling,"mm", PlateImage |
---|
2746 | SetScale/P y 0,Scaling,"mm", PlateImage |
---|
2747 | Duplicate/Free/R=[1,12] Centers, CentersForDrawing |
---|
2748 | //create opening for samples, set image to 128, that is medium grey in our color system in solid and 0 in opening for samples. |
---|
2749 | //IN3S_CreateCircles(PlateImage, CentersForDrawing, Radius, Scaling) |
---|
2750 | PlateImage = 128 |
---|
2751 | PlateImage[10/Scaling, 210/Scaling][20/Scaling,66/Scaling] = 0 |
---|
2752 | |
---|
2753 | //add tube lines... |
---|
2754 | IN3S_AddOtherDrawings(PlateImage, Centers, Radius, Scaling, "VerticalNMR") |
---|
2755 | |
---|
2756 | elseif(stringMatch(whichOne,"Image")) |
---|
2757 | //here is code which loads image and deal with that. this will be different code and complciated. |
---|
2758 | |
---|
2759 | else |
---|
2760 | Abort "This sample plate name does not have drawign available." |
---|
2761 | endif |
---|
2762 | //create plate drawing. |
---|
2763 | DoWIndow SamplePlateImageDrawing |
---|
2764 | if(V_Flag!=1) |
---|
2765 | PauseUpdate |
---|
2766 | NewImage/K=1/N=SamplePlateImageDrawing root:Packages:SamplePlatesAvailable:PlateImage |
---|
2767 | DoWindow/T SamplePlateImageDrawing,"Image of "+WhichOne |
---|
2768 | ModifyImage PlateImage ctab= {0,256,Grays,1} |
---|
2769 | ModifyGraph margin(left)=28,margin(bottom)=28,margin(top)=28,margin(right)=28 |
---|
2770 | SetAxis/R left (VertSize*Scaling+0.125),-0.125 |
---|
2771 | SetAxis/R top (HorSize*Scaling+0.125),-0.125 |
---|
2772 | Label left "\\Zr133millimeters from top right corner" |
---|
2773 | Label top "\\Zr133millimeters from top right corner" |
---|
2774 | ModifyGraph grid=1 |
---|
2775 | ModifyGraph mirror=3 |
---|
2776 | ModifyGraph nticks(left)=22,nticks(top)=22 |
---|
2777 | ModifyGraph minor=1 |
---|
2778 | ModifyGraph standoff=0 |
---|
2779 | ModifyGraph tkLblRot(left)=90 |
---|
2780 | ModifyGraph btLen=3 |
---|
2781 | ModifyGraph tlOffset=-2 |
---|
2782 | DoUpdate |
---|
2783 | endif |
---|
2784 | SetWindow SamplePlateImageDrawing hook(ImageHook)=IN3S_PlateImageHook |
---|
2785 | |
---|
2786 | SetDataFolder OldDf |
---|
2787 | end |
---|
2788 | //***************************************************************************************************************** |
---|
2789 | //***************************************************************************************************************** |
---|
2790 | static Function IN3S_WritePositionInTable(mouseVert, mouseHor) |
---|
2791 | variable mouseHor, mouseVert |
---|
2792 | |
---|
2793 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
2794 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
2795 | SVAR SelectedPlateName = root:Packages:SamplePlateSetup:SelectedPlateName |
---|
2796 | //need to identify where we are and what size the image is |
---|
2797 | string Margins = IN2G_FindInRecreation(winrecreation("SamplePlateImageDrawing",0), "margin") |
---|
2798 | variable margleft=NumberByKey("margin(left)", Margins,"=", ",") |
---|
2799 | variable margright=NumberByKey("margin(right)", Margins,"=", ",") |
---|
2800 | variable margtop=NumberByKey("margin(top)", Margins,"=", ",") |
---|
2801 | variable margbot=NumberByKey("margin(bottom)", Margins,"=", ",") |
---|
2802 | getwindow SamplePlateImageDrawing wsizeDC |
---|
2803 | variable horsize=(V_right - V_left) |
---|
2804 | variable versize=(V_bottom - V_top) |
---|
2805 | GetAxis /W=SamplePlateImageDrawing /Q left |
---|
2806 | variable VertMin=min(V_min, V_max) |
---|
2807 | variable VertMax=max(V_min, V_max) |
---|
2808 | GetAxis /W=SamplePlateImageDrawing /Q top |
---|
2809 | variable HorMin=min(V_min, V_max) |
---|
2810 | variable HorMax=max(V_min, V_max) |
---|
2811 | variable xpos, ypos |
---|
2812 | horsize = horsize-margleft-margright |
---|
2813 | versize = versize-margtop-margbot |
---|
2814 | variable HorRange=HorMax - HorMin |
---|
2815 | variable VertRange=VertMax - VertMin |
---|
2816 | xpos = HorMin + HorRange*(horsize - (mouseHor-margleft))/(horsize) |
---|
2817 | |
---|
2818 | ypos = VertMin + VertRange *(mouseVert-margtop)/(versize) |
---|
2819 | |
---|
2820 | //FindLevel /EDGE=1 /P/Q LBSelectionWv, 0.5 |
---|
2821 | variable SelectedRow = IN3S_FindFirstSelectedRow() |
---|
2822 | //ControlInfo /W=SamplePlateSetup CommandsList |
---|
2823 | if(SelectedRow>=0&&SelectedRow<dimSize(LBCommandWv,0)) |
---|
2824 | LBCommandWv[SelectedRow][1]=num2str(xpos) |
---|
2825 | LBCommandWv[SelectedRow][2]=num2str(ypos) |
---|
2826 | else |
---|
2827 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
2828 | WarningForUser = "Could not records values for this positon, no row selected" |
---|
2829 | print "Could not records values for this positon, no row selected" |
---|
2830 | endif |
---|
2831 | |
---|
2832 | end |
---|
2833 | //***************************************************************************************************************** |
---|
2834 | static Function IN3S_FindFirstSelectedRow() |
---|
2835 | |
---|
2836 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
2837 | string ListOfSelRows=IN3S_CreateListOfRows(LBSelectionWv) |
---|
2838 | variable firstSelectedRow = str2num(StringFromList(ItemsInList(ListOfSelRows)-1, ListOfSelRows)) |
---|
2839 | firstSelectedRow = numtype(firstSelectedRow)==0 ? firstSelectedRow : 0 |
---|
2840 | return firstSelectedRow |
---|
2841 | end |
---|
2842 | |
---|
2843 | //***************************************************************************************************************** |
---|
2844 | //***************************************************************************************************************** |
---|
2845 | static Function IN3S_AddTagToImage(row) //add one tag if row is number, all if -1 or DisplayAllSamplesInImage=1 |
---|
2846 | variable row |
---|
2847 | |
---|
2848 | DoWindow SamplePlateImageDrawing |
---|
2849 | if(V_Flag) |
---|
2850 | Wave/T listWave=root:Packages:SamplePlateSetup:LBCommandWv |
---|
2851 | if(row>DimSize(listWave,0)-1) |
---|
2852 | return 0 //we seem to have issues with row being selected while there are no rows... |
---|
2853 | endif |
---|
2854 | NVAR DisplayAllSamplesInImage = root:Packages:SamplePlateSetup:DisplayAllSamplesInImage |
---|
2855 | //removeFromGraph /Z/W=SamplePlateImageDrawing Tagy |
---|
2856 | if(row>=0 && !DisplayAllSamplesInImage) |
---|
2857 | MAKE/O/N=1 root:Packages:SamplePlateSetup:TagX |
---|
2858 | MAKE/O/N=1 root:Packages:SamplePlateSetup:Tagy |
---|
2859 | MAKE/O/N=1/T root:Packages:SamplePlateSetup:TagNames |
---|
2860 | Wave tagx=root:Packages:SamplePlateSetup:TagX |
---|
2861 | Wave tagy= root:Packages:SamplePlateSetup:Tagy |
---|
2862 | Wave/T TagNames= root:Packages:SamplePlateSetup:TagNames |
---|
2863 | if(strlen(listWave[row][1])>0 && strlen(listWave[row][2])>0) |
---|
2864 | tagx=str2num(listWave[row][1]) |
---|
2865 | tagy=str2num(listWave[row][2]) |
---|
2866 | Duplicate/O tagy, root:Packages:SamplePlateSetup:TagyLabel |
---|
2867 | Wave TagyLabel= root:Packages:SamplePlateSetup:TagyLabel |
---|
2868 | TagNames = " "+listWave[row][0] |
---|
2869 | CheckDisplayed /W=SamplePlateImageDrawing Tagy |
---|
2870 | if(V_Flag==0) |
---|
2871 | AppendToGraph /W=SamplePlateImageDrawing/T/L Tagy vs tagx |
---|
2872 | ModifyGraph /W=SamplePlateImageDrawing mode(Tagy)=3,marker(Tagy)=19,msize(Tagy)=0,mrkThick(Tagy)=1 |
---|
2873 | ModifyGraph /W=SamplePlateImageDrawing useMrkStrokeRGB(Tagy)=1 |
---|
2874 | endif |
---|
2875 | CheckDisplayed /W=SamplePlateImageDrawing TagyLabel |
---|
2876 | if(V_Flag==0) |
---|
2877 | AppendToGraph /W=SamplePlateImageDrawing/T/L TagyLabel vs tagx |
---|
2878 | ModifyGraph mode=3,textMarker(TagyLabel)={TagNames,"default",0,20,4,0.00,0.00} |
---|
2879 | endif |
---|
2880 | else |
---|
2881 | removeFromGraph /Z/W=SamplePlateImageDrawing Tagy |
---|
2882 | removeFromGraph /Z/W=SamplePlateImageDrawing TagyLabel |
---|
2883 | endif |
---|
2884 | //Tag/C/W=SamplePlateImageDrawing/N=SampleName/F=0/TL=0/I=1/B=0/G=(64640,0,2246) Tagy, 0, TagNames[0] |
---|
2885 | elseif(row==-1 || DisplayAllSamplesInImage) |
---|
2886 | MAKE/O/N=(dimsize(listWave,0)) root:Packages:SamplePlateSetup:TagX |
---|
2887 | MAKE/O/N=(dimsize(listWave,0)) root:Packages:SamplePlateSetup:Tagy |
---|
2888 | MAKE/O/N=(dimsize(listWave,0))/T root:Packages:SamplePlateSetup:TagNames |
---|
2889 | Wave tagx=root:Packages:SamplePlateSetup:TagX |
---|
2890 | Wave tagy= root:Packages:SamplePlateSetup:Tagy |
---|
2891 | Wave/T TagNames= root:Packages:SamplePlateSetup:TagNames |
---|
2892 | tagx=str2num(listWave[p][1]) |
---|
2893 | tagy=str2num(listWave[p][2]) |
---|
2894 | Duplicate/O tagy, root:Packages:SamplePlateSetup:TagyLabel |
---|
2895 | Wave TagyLabel= root:Packages:SamplePlateSetup:TagyLabel |
---|
2896 | TagNames = " "+listWave[p][0] |
---|
2897 | CheckDisplayed /W=SamplePlateImageDrawing Tagy |
---|
2898 | if(V_Flag==0) |
---|
2899 | AppendToGraph /W=SamplePlateImageDrawing/T/L Tagy vs tagx |
---|
2900 | ModifyGraph /W=SamplePlateImageDrawing mode(Tagy)=3,marker(Tagy)=19,msize(Tagy)=0,mrkThick(Tagy)=1 |
---|
2901 | ModifyGraph /W=SamplePlateImageDrawing useMrkStrokeRGB(Tagy)=1 |
---|
2902 | endif |
---|
2903 | CheckDisplayed /W=SamplePlateImageDrawing TagyLabel |
---|
2904 | if(V_Flag==0) |
---|
2905 | AppendToGraph /W=SamplePlateImageDrawing/T/L TagyLabel vs tagx |
---|
2906 | ModifyGraph mode=3,textMarker(TagyLabel)={TagNames,"default",0,40,4,0.00,0.00} |
---|
2907 | endif |
---|
2908 | else |
---|
2909 | Wave/Z tagx=root:Packages:SamplePlateSetup:TagX |
---|
2910 | Wave/Z tagy= root:Packages:SamplePlateSetup:Tagy |
---|
2911 | Wave/T/Z TagNames= root:Packages:SamplePlateSetup:TagNames |
---|
2912 | if(WaveExists(tagx)&&WaveExists(tagy)&&WaveExists(TagNames)) |
---|
2913 | redimension/N=0 tagx, tagy, TagNames |
---|
2914 | endif |
---|
2915 | removeFromGraph /Z/W=SamplePlateImageDrawing Tagy |
---|
2916 | removeFromGraph /Z/W=SamplePlateImageDrawing TagyLabel |
---|
2917 | endif |
---|
2918 | |
---|
2919 | |
---|
2920 | endif |
---|
2921 | end |
---|
2922 | //***************************************************************************************************************** |
---|
2923 | //***************************************************************************************************************** |
---|
2924 | |
---|
2925 | Function IN3S_PlateImageHook(s) |
---|
2926 | STRUCT WMWinHookStruct &s |
---|
2927 | |
---|
2928 | if(stringMatch(s.winName, "SamplePlateImageDrawing")) |
---|
2929 | switch( s.eventCode ) |
---|
2930 | case -1: // control being killed |
---|
2931 | break |
---|
2932 | case 3: // mouse down |
---|
2933 | if (s.eventMod & 0x10) // rightclick |
---|
2934 | string items |
---|
2935 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
2936 | items = "Write position;Add Line with positions;Igor right click cmds;" |
---|
2937 | PopupContextualMenu items |
---|
2938 | // V_flag is index of user selected item |
---|
2939 | switch (V_flag) |
---|
2940 | case 1: // "Write position" |
---|
2941 | IN3S_WritePositionInTable(s.mouseLoc.v, s.mouseLoc.h) |
---|
2942 | //ControlInfo /W=SamplePlateSetup CommandsList |
---|
2943 | variable V_Value=IN3S_FindFirstSelectedRow() |
---|
2944 | IN3S_AddTagToImage(V_Value) |
---|
2945 | variable serrow=V_Value |
---|
2946 | //sync to Bealine setup, if exists... |
---|
2947 | DoWIndow BeamlinePlateSetup |
---|
2948 | if(V_Flag) |
---|
2949 | NVAR SelectedRow=root:Packages:SamplePlateSetup:SelectedRow |
---|
2950 | SVAR SelectedSampleName=root:Packages:SamplePlateSetup:SelectedSampleName |
---|
2951 | Wave/T ListWV = root:Packages:SamplePlateSetup:LBCommandWv |
---|
2952 | NVAR SampleThickness=root:Packages:SamplePlateSetup:SampleThickness |
---|
2953 | NVAR SampleXTAR=root:Packages:SamplePlateSetup:SampleXTAR |
---|
2954 | NVAR SampleYTAR=root:Packages:SamplePlateSetup:SampleYTAR |
---|
2955 | NVAR SampleXTable = root:Packages:SamplePlateSetup:SampleXTable |
---|
2956 | NVAR SampleYTable = root:Packages:SamplePlateSetup:SampleYTable |
---|
2957 | if(serrow>=0) |
---|
2958 | SelectedRow=serrow |
---|
2959 | SelectedSampleName = ListWV[SelectedRow][0] |
---|
2960 | //ListBox CommandsList, win=SamplePlateSetup, selrow=SelectedRow |
---|
2961 | LBSelectionWv[][0]=2 |
---|
2962 | LBSelectionWv[SelectedRow][0]=3 |
---|
2963 | SampleXTable = str2num(ListWV[SelectedRow][1]) |
---|
2964 | SampleYTable = str2num(ListWV[SelectedRow][2]) |
---|
2965 | SampleThickness = str2num(ListWV[SelectedRow][3]) |
---|
2966 | SampleThickness = numtype(SampleThickness)==0 ? SampleThickness : 1 |
---|
2967 | endif |
---|
2968 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
2969 | WarningForUser = "Written right click position in table" |
---|
2970 | IN3S_MoveToPositionIfOK() |
---|
2971 | endif |
---|
2972 | return 1 |
---|
2973 | break; |
---|
2974 | case 2: // "Add Line with positions" |
---|
2975 | IN3S_InsertDeleteLines(4, 0,1) |
---|
2976 | //now select the line. |
---|
2977 | variable SelRow2 |
---|
2978 | Wave/T listWave=root:Packages:SamplePlateSetup:LBCommandWv |
---|
2979 | SelRow2 = dimSize(listWave,0)-1 |
---|
2980 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
2981 | LBSelectionWv[][0]=2 |
---|
2982 | LBSelectionWv[SelRow2][0]=3 |
---|
2983 | ListBox CommandsList, win=SamplePlateSetup, selRow= SelRow2 |
---|
2984 | IN3S_WritePositionInTable(s.mouseLoc.v, s.mouseLoc.h) |
---|
2985 | IN3S_AddTagToImage(SelRow2) |
---|
2986 | //sync to Bealine setup, if exists... |
---|
2987 | DoWIndow BeamlinePlateSetup |
---|
2988 | if(V_Flag) |
---|
2989 | NVAR SelectedRow=root:Packages:SamplePlateSetup:SelectedRow |
---|
2990 | SVAR SelectedSampleName=root:Packages:SamplePlateSetup:SelectedSampleName |
---|
2991 | Wave/T ListWV = root:Packages:SamplePlateSetup:LBCommandWv |
---|
2992 | NVAR SampleThickness=root:Packages:SamplePlateSetup:SampleThickness |
---|
2993 | NVAR SampleXTAR=root:Packages:SamplePlateSetup:SampleXTAR |
---|
2994 | NVAR SampleYTAR=root:Packages:SamplePlateSetup:SampleYTAR |
---|
2995 | NVAR SampleXTable = root:Packages:SamplePlateSetup:SampleXTable |
---|
2996 | NVAR SampleYTable = root:Packages:SamplePlateSetup:SampleYTable |
---|
2997 | if(dimSize(listWave,0)-1>=0) |
---|
2998 | SelectedRow=dimSize(listWave,0)-1 |
---|
2999 | SelectedSampleName = ListWV[SelectedRow][0] |
---|
3000 | //ListBox CommandsList, win=SamplePlateSetup, selrow=SelectedRow |
---|
3001 | LBSelectionWv[][0]=2 |
---|
3002 | LBSelectionWv[SelectedRow][0]=3 |
---|
3003 | SampleXTable = str2num(ListWV[SelectedRow][1]) |
---|
3004 | SampleYTable = str2num(ListWV[SelectedRow][2]) |
---|
3005 | SampleThickness = str2num(ListWV[SelectedRow][3]) |
---|
3006 | SampleThickness = numtype(SampleThickness)==0 ? SampleThickness : 1 |
---|
3007 | endif |
---|
3008 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
3009 | WarningForUser = "Added new line with rigth click positions" |
---|
3010 | IN3S_MoveToPositionIfOK() |
---|
3011 | endif |
---|
3012 | return 1 |
---|
3013 | break |
---|
3014 | case 3: // "Igor right click cmds" |
---|
3015 | return 0 |
---|
3016 | break |
---|
3017 | case 4: // "Duplicate selected Line" |
---|
3018 | //IN3S_InsertDeleteLines(3, row) |
---|
3019 | break |
---|
3020 | default : // "Sort" |
---|
3021 | break; |
---|
3022 | endswitch |
---|
3023 | else //left click, do something here... |
---|
3024 | //IN3S_WritePositionInTable(s.mouseLoc.v, s.mouseLoc.h) |
---|
3025 | break |
---|
3026 | endif |
---|
3027 | break |
---|
3028 | case 4: // mousemoved |
---|
3029 | break |
---|
3030 | case 5: // mouseup |
---|
3031 | break |
---|
3032 | case 6: // begin edit |
---|
3033 | break |
---|
3034 | case 7: // finish edit |
---|
3035 | break |
---|
3036 | case 13: // checkbox clicked (Igor 6.2 or later) |
---|
3037 | break |
---|
3038 | endswitch |
---|
3039 | endif |
---|
3040 | return 0 |
---|
3041 | end |
---|
3042 | |
---|
3043 | |
---|
3044 | //***************************************************************************************************************** |
---|
3045 | //***************************************************************************************************************** |
---|
3046 | //***************************************************************************************************************** |
---|
3047 | |
---|
3048 | static Function IN3S_AddOtherDrawings(PlateImage, Centers, Radius, Scaling, WhatDrawing) |
---|
3049 | wave PlateImage, Centers |
---|
3050 | variable Radius, Scaling |
---|
3051 | string WhatDrawing |
---|
3052 | //here we draw other drawings in the image as needed. |
---|
3053 | variable i, j |
---|
3054 | variable locCenterX, locCenterY, locWidthX |
---|
3055 | variable tmpX, tmpYt, tmpYb |
---|
3056 | |
---|
3057 | variable NMRverticallenght=23 |
---|
3058 | variable NMRradius=2 |
---|
3059 | if(StringMatch(WhatDrawing, "VerticalNMR")) |
---|
3060 | |
---|
3061 | For(i=0;i<dimSize(Centers,0);i+=1) |
---|
3062 | locCenterX = centers[i][0]/Scaling |
---|
3063 | locCenterY = centers[i][1]/Scaling |
---|
3064 | locWidthX = floor(NMRradius/Scaling) |
---|
3065 | //left line |
---|
3066 | tmpX = locCenterX - locWidthX |
---|
3067 | tmpYt = locCenterY + NMRverticallenght/Scaling |
---|
3068 | tmpYb = locCenterY - NMRverticallenght/Scaling |
---|
3069 | PlateImage[tmpX][tmpYb,tmpYt] = 255 |
---|
3070 | //right line |
---|
3071 | tmpX = locCenterX + locWidthX |
---|
3072 | PlateImage[tmpX][tmpYb,tmpYt] = 255 |
---|
3073 | //fill |
---|
3074 | PlateImage[locCenterX-locWidthX+1,locCenterX+locWidthX-1][tmpYb,tmpYt] = 64 |
---|
3075 | |
---|
3076 | endfor |
---|
3077 | |
---|
3078 | endif |
---|
3079 | |
---|
3080 | end |
---|
3081 | //***************************************************************************************************************** |
---|
3082 | //***************************************************************************************************************** |
---|
3083 | //***************************************************************************************************************** |
---|
3084 | |
---|
3085 | static Function IN3S_CreateCircles(PlateImage, Centers, Radius,Scaling) |
---|
3086 | wave PlateImage, Centers |
---|
3087 | variable Radius, Scaling |
---|
3088 | |
---|
3089 | variable i |
---|
3090 | //this needs to be done by FFT, this is crazy slow... |
---|
3091 | //For(i=0;i<DimSize(Centers, 0);i+=1) |
---|
3092 | // PlateImage = sqrt((x - Centers[i][0])^2+( y - Centers[i][1])^2)<Radius ? 0 : PlateImage(x)(y) |
---|
3093 | //endfor |
---|
3094 | //now FFT... Much faster, but bit cumbersome... |
---|
3095 | //this method - in convolutions - shifts the centers by : |
---|
3096 | variable PadSphere=Radius/Scaling |
---|
3097 | //make work space... |
---|
3098 | Make/Free/S/N=(dimsize(PlateImage,0)+PadSphere, dimsize(PlateImage,1)+PadSphere) WaveToWorkOn, Circle |
---|
3099 | //SET TO 1 where will be centers of holes |
---|
3100 | For(i=0;i<DimSize(Centers, 0);i+=1) |
---|
3101 | WaveToWorkOn [Centers[i][0]/Scaling][Centers[i][1]/Scaling] = 1 |
---|
3102 | endfor |
---|
3103 | //create image of hole |
---|
3104 | Circle[0,ceil(2*Radius/Scaling+2)][0,ceil(2*Radius/Scaling+2)] = (sqrt((p*Scaling-Radius)^2+(q*Scaling-Radius)^2)<Radius) ? 1 : 0 |
---|
3105 | //now use fft. MatrixOp should be bit faster. |
---|
3106 | //fft/DEST=CircleFFT/Free Circle |
---|
3107 | MatrixOp/FREE CircleFFT=fft(Circle,0) |
---|
3108 | //fft/DEST=Wave2DInFFT/Free WaveToWorkOn |
---|
3109 | MatrixOp/FREE Wave2DInFFT=fft(WaveToWorkOn,0) |
---|
3110 | //convolute together |
---|
3111 | MatrixOp/FREE MultipliedFFT = Wave2DInFFT * CircleFFT |
---|
3112 | //IFFT, force real result |
---|
3113 | //IFFT/Dest=Wave2DOutIFFT/Free MultipliedFFT |
---|
3114 | MatrixOp/FREE Wave2DOutIFFT=ifft(MultipliedFFT,1) |
---|
3115 | //this depends on what is used for convolution. If sharp sphere, this is what you need... thresholds are much smaller for gauss... |
---|
3116 | imageThreshold/T=(0.5) Wave2DOutIFFT |
---|
3117 | wave M_ImageThresh |
---|
3118 | //now we need to shrink it back to size and remove first PadSphere rows and columns |
---|
3119 | Duplicate/Free/R=[PadSphere, ][PadSphere, ] M_ImageThresh, ShrunkImageThresh |
---|
3120 | //and return back to the code. |
---|
3121 | PlateImage = 128 - (ShrunkImageThresh/2) |
---|
3122 | end |
---|
3123 | //***************************************************************************************************************** |
---|
3124 | //***************************************************************************************************************** |
---|
3125 | //***************************************************************************************************************** |
---|
3126 | |
---|
3127 | static Function IN3S_CreateNMRTubes(PlateImage, Centers, Scaling) |
---|
3128 | wave PlateImage, Centers |
---|
3129 | variable Scaling |
---|
3130 | |
---|
3131 | variable i |
---|
3132 | variable NMRTubeRadius, NMRTubeHeight, CenterP, CenterQ |
---|
3133 | NMRTubeRadius = 2/Scaling |
---|
3134 | NMRTubeHeight = 10/Scaling |
---|
3135 | CenterP = NMRTubeHeight - NMRTubeRadius |
---|
3136 | CenterQ = NMRTubeHeight - NMRTubeRadius |
---|
3137 | //this needs to be done by FFT, this is crazy slow... |
---|
3138 | //For(i=0;i<DimSize(Centers, 0);i+=1) |
---|
3139 | // PlateImage = sqrt((x - Centers[i][0])^2+( y - Centers[i][1])^2)<Radius ? 0 : PlateImage(x)(y) |
---|
3140 | //endfor |
---|
3141 | //now FFT... Much faster, but bit cumbersome... |
---|
3142 | //this method - in convolutions - shifts the centers by : |
---|
3143 | variable PadSphereP=NMRTubeRadius/Scaling |
---|
3144 | variable PadSphereQ=0//NMRTubeHeight/Scaling |
---|
3145 | //make work space... |
---|
3146 | Make/Free/S/N=(dimsize(PlateImage,0)+PadSphereP, dimsize(PlateImage,1)+PadSphereP) WaveToWorkOn, NMRTube |
---|
3147 | //SET TO 1 where will be centers of holes |
---|
3148 | For(i=0;i<DimSize(Centers, 0);i+=1) |
---|
3149 | WaveToWorkOn [Centers[i][0]/Scaling][Centers[i][1]/Scaling] = 1 |
---|
3150 | endfor |
---|
3151 | //create image of hole |
---|
3152 | NMRTube[0,ceil(2*NMRTubeHeight+2)][0,ceil(2*NMRTubeHeight+2)] = ((abs(p-CenterP)<NMRTubeRadius)&& (abs(q-CenterQ)<NMRTubeHeight)) ? 1 : 0 |
---|
3153 | //now use fft. MatrixOp should be bit faster. |
---|
3154 | //fft/DEST=CircleFFT/Free Circle |
---|
3155 | MatrixOp/FREE NMRTubeFFT=fft(NMRTube,0) |
---|
3156 | //fft/DEST=Wave2DInFFT/Free WaveToWorkOn |
---|
3157 | MatrixOp/FREE Wave2DInFFT=fft(WaveToWorkOn,0) |
---|
3158 | //convolute together |
---|
3159 | MatrixOp/FREE MultipliedFFT = Wave2DInFFT * NMRTubeFFT |
---|
3160 | //IFFT, force real result |
---|
3161 | //IFFT/Dest=Wave2DOutIFFT/Free MultipliedFFT |
---|
3162 | MatrixOp/FREE Wave2DOutIFFT=ifft(MultipliedFFT,1) |
---|
3163 | //this depends on what is used for convolution. If sharp sphere, this is what you need... thresholds are much smaller for gauss... |
---|
3164 | imageThreshold/T=(0.5) Wave2DOutIFFT |
---|
3165 | wave M_ImageThresh |
---|
3166 | //now we need to shrink it back to size and remove first PadSphere rows and columns |
---|
3167 | Duplicate/Free/R=[PadSphereP, ][PadSphereP, ] M_ImageThresh, ShrunkImageThresh |
---|
3168 | //and return back to the code. |
---|
3169 | PlateImage = 128 - (ShrunkImageThresh/2) |
---|
3170 | end |
---|
3171 | |
---|
3172 | //************************************************************************************************************ |
---|
3173 | //************************************************************************************************************ |
---|
3174 | Function IN3S_ImportFile() //thsi imports ASCII file, need to add otehr types of fioles as needed. |
---|
3175 | |
---|
3176 | DFrEF OldDf=GetDataFolderDFR() |
---|
3177 | setdatafolder root:Packages:SamplePlateSetup: |
---|
3178 | |
---|
3179 | Wave/T LBCommandWv = root:Packages:SamplePlateSetup:LBCommandWv |
---|
3180 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
3181 | //Wave/T LBTtitleWv = root:Packages:SamplePlateSetup:LBTtitleWv |
---|
3182 | redimension/N=(400,8) LBCommandWv, LBSelectionWv |
---|
3183 | //initialize... |
---|
3184 | string/g ImportFileType |
---|
3185 | SVAR ImportFileType |
---|
3186 | if(strlen(ImportFileType)<1) |
---|
3187 | ImportFileType="12IDB command file" |
---|
3188 | endif |
---|
3189 | //import the the text file. |
---|
3190 | variable refNum, i, imax, iused |
---|
3191 | String line, tmpStr, MDStart="" |
---|
3192 | if(StringMatch(ImportFileType, "12IDB command file" )) //this is reading web created command files from 12IDB |
---|
3193 | open/R/F="????" refnum |
---|
3194 | if(strlen(S_fileName)==0) |
---|
3195 | abort |
---|
3196 | endif |
---|
3197 | print "Importing 12IDB commands from file : "+S_fileName |
---|
3198 | SVAR SetName = root:Packages:SamplePlateSetup:UserNameForSampleSet |
---|
3199 | SetName = CleanupName(StringFromList(ItemsInList(S_fileName,":")-1, S_fileName, ":"), 0) |
---|
3200 | i=0;imax=0 |
---|
3201 | FSetPos refnum,0 |
---|
3202 | do |
---|
3203 | FReadLine refnum, line |
---|
3204 | if(!StringMatch(line, "#*")&&strlen(line)>1) //if does not start with # |
---|
3205 | //# sample_Name sample_x sample_y ExposureTime thickness(???) sample_description |
---|
3206 | LBCommandWv[i][0] = CleanupName(StringFromList(0, line , ","), 0 , 40) |
---|
3207 | LBCommandWv[i][1] = StringFromList(1, line , ",") |
---|
3208 | LBCommandWv[i][2] = StringFromList(2, line , ",") |
---|
3209 | LBCommandWv[i][3] = StringFromList(4, line , ",") |
---|
3210 | //LBCommandWv[i][4] = StringFromList(3, line , ",") |
---|
3211 | //LBCommandWv[i][5] = StringFromList(3, line , ",") |
---|
3212 | //LBCommandWv[i][6] = StringFromList(3, line , ",") |
---|
3213 | //SG4M4, 78, 0, 1.0, 1, 1.5, 100x diluted short nanowires, pH=10, 1.5 M KCl |
---|
3214 | tmpStr = line |
---|
3215 | tmpStr = RemoveFromList(StringFromList(0, line , ","), tmpStr, ",") //remove name |
---|
3216 | tmpStr = RemoveFromList(StringFromList(1, line , ","), tmpStr, ",") //remove x |
---|
3217 | tmpStr = RemoveFromList(StringFromList(2, line , ","), tmpStr, ",") //remove y |
---|
3218 | tmpStr = RemoveFromList(StringFromList(3, line , ","), tmpStr, ",") //remove exposure time |
---|
3219 | tmpStr = RemoveFromList(StringFromList(4, line , ","), tmpStr, ",") //remove thickness |
---|
3220 | tmpStr = RemoveEnding(tmpStr, "\r") |
---|
3221 | tmpStr = RemoveEnding(tmpStr, "\r\n") |
---|
3222 | LBCommandWv[i][7] = MDStart+"Sample description: "+tmpStr //StringFromList(6, line , ",") //this is MD for BS, ddi tno work with , used by users in description. |
---|
3223 | i+=1 |
---|
3224 | else |
---|
3225 | if(!(StringMatch(line, "#IP*") ||StringMatch(line, "# sample_Name*")||StringMatch(line, "#Holder*") )) |
---|
3226 | tmpStr = ReplaceString("#", line, "") |
---|
3227 | tmpStr = ReplaceString("^t", tmpStr, "") |
---|
3228 | MDStart+=RemoveEnding(tmpStr, "\r")+";" |
---|
3229 | endif |
---|
3230 | endif |
---|
3231 | while(strlen(line)>0) |
---|
3232 | close refnum |
---|
3233 | LBSelectionWv[][0]=2 |
---|
3234 | LBSelectionWv[][1]=2 |
---|
3235 | LBSelectionWv[][2]=2 |
---|
3236 | LBSelectionWv[][3]=2 |
---|
3237 | NVAR USAXSAll = root:Packages:SamplePlateSetup:USAXSAll |
---|
3238 | if(USAXSAll) |
---|
3239 | LBSelectionWv[][4]=48 |
---|
3240 | else |
---|
3241 | LBSelectionWv[][4]=32 |
---|
3242 | endif |
---|
3243 | NVAR SAXSAll = root:Packages:SamplePlateSetup:SAXSAll |
---|
3244 | if(SAXSAll) |
---|
3245 | LBSelectionWv[][5]=48 |
---|
3246 | else |
---|
3247 | LBSelectionWv[][5]=32 |
---|
3248 | endif |
---|
3249 | NVAR WAXSAll = root:Packages:SamplePlateSetup:WAXSAll |
---|
3250 | if(WAXSAll) |
---|
3251 | LBSelectionWv[][6]=48 |
---|
3252 | else |
---|
3253 | LBSelectionWv[][6]=32 |
---|
3254 | endif |
---|
3255 | endif |
---|
3256 | redimension/N=(i,8) LBSelectionWv,LBCommandWv |
---|
3257 | |
---|
3258 | |
---|
3259 | SetDataFolder OldDf |
---|
3260 | end |
---|
3261 | //************************************************************************************************************ |
---|
3262 | //************************************************************************************************************ |
---|
3263 | Function IN3S_ImportImageOfPlate() |
---|
3264 | // imports the image in here: root:Packages:SamplePlatesAvailable:PlateImage |
---|
3265 | // and allows user to remvoe parralax and trim, set dimensions. |
---|
3266 | |
---|
3267 | DFrEF OldDf=GetDataFolderDFR() |
---|
3268 | setdatafolder root:Packages:SamplePlatesAvailable |
---|
3269 | KillWindow/Z SamplePlateImageDrawing |
---|
3270 | NVAR Scaling = root:Packages:SamplePlatesAvailable:Acrylic9x9PlateScale |
---|
3271 | //need variables here, this may go in Init routine later |
---|
3272 | variable HorSize, VertSize |
---|
3273 | variable/g xRT, xRB, xLT, xLB |
---|
3274 | variable/g yRT, yRB, yLT, yLB |
---|
3275 | variable/g xDimension |
---|
3276 | variable/g yDimension |
---|
3277 | //import the image somehwere |
---|
3278 | ImageLoad/T=any/O |
---|
3279 | if(V_Flag!=1) |
---|
3280 | abort |
---|
3281 | endif |
---|
3282 | string/g LoadedImageName=S_fileName |
---|
3283 | wave imageWave = $(LoadedImageName) |
---|
3284 | ImageTransform rgb2gray imageWave |
---|
3285 | Wave M_RGB2Gray |
---|
3286 | Duplicate/O M_RGB2Gray, PlateImageTemp |
---|
3287 | killwaves/Z imageWave, M_RGB2Gray |
---|
3288 | //set values for the variables, for now 0,0 is in top left corner... |
---|
3289 | xRT = dimsize(PlateImageTemp,0)*0.9 |
---|
3290 | xRB = dimsize(PlateImageTemp,0)*0.9 |
---|
3291 | xLT = dimsize(PlateImageTemp,0)*0.1 |
---|
3292 | xLB = dimsize(PlateImageTemp,0)*0.2 |
---|
3293 | yRT = dimsize(PlateImageTemp,1)*0.1 |
---|
3294 | yRB = dimsize(PlateImageTemp,1)*0.9 |
---|
3295 | yLT = dimsize(PlateImageTemp,1)*0.2 |
---|
3296 | yLB = dimsize(PlateImageTemp,1)*0.8 |
---|
3297 | if((xDimension+yDimension)<50) |
---|
3298 | xDimension = 200 |
---|
3299 | yDimension = 100 |
---|
3300 | endif |
---|
3301 | |
---|
3302 | //make image, get user input here so we can trim the image and return it back... |
---|
3303 | KillWindow/Z TrimCorrectImageDrawing |
---|
3304 | NewImage/K=1/N=TrimCorrectImageDrawing root:Packages:SamplePlatesAvailable:PlateImageTemp |
---|
3305 | Cursor/W=TrimCorrectImageDrawing/C=(65535,0,0)/H=0/I/P/S=1/T={1,1,1}/NUML=1 A, PlateImageTemp, xRT, yRT |
---|
3306 | Cursor/W=TrimCorrectImageDrawing/C=(65535,0,0)/H=0/I/P/S=1/T={1,2,2}/NUML=2 B, PlateImageTemp, xRB, yRB |
---|
3307 | Cursor/W=TrimCorrectImageDrawing/C=(65535,0,0)/H=0/I/P/S=1/T={1,3,3}/NUML=3 C, PlateImageTemp, xLT, yLT |
---|
3308 | Cursor/W=TrimCorrectImageDrawing/C=(65535,0,0)/H=0/I/P/S=1/T={1,4,4}/NUML=4 D, PlateImageTemp, xLB, yLB |
---|
3309 | ControlBar /T/W=TrimCorrectImageDrawing 80 |
---|
3310 | TitleBox LeftTop title="\Zr120Left top (C) : ",pos={10,5},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
3311 | SetVariable xLT,pos={10,25},size={90,20}, disable=2, noedit=1,limits={-inf,inf,0},noproc ,title="Xpos = " |
---|
3312 | Setvariable xLT,fStyle=2, variable=root:Packages:SamplePlatesAvailable:xLT, help={"This is x postion of C corner"} |
---|
3313 | SetVariable yLT,pos={10,45},size={90,20}, disable=2, noedit=1,limits={-inf,inf,0},noproc ,title="Ypos = " |
---|
3314 | Setvariable yLT,fStyle=2, variable=root:Packages:SamplePlatesAvailable:yLT, help={"This is y postion of C corner"} |
---|
3315 | |
---|
3316 | TitleBox LeftBot title="\Zr120Left bot (D) : ",pos={150,5},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
3317 | SetVariable xLB,pos={150,25},size={90,20}, disable=2, noedit=1,limits={-inf,inf,0},noproc ,title="Xpos = " |
---|
3318 | Setvariable xLB,fStyle=2, variable=root:Packages:SamplePlatesAvailable:xLB, help={"This is x postion of D corner"} |
---|
3319 | SetVariable yLB,pos={150,45},size={90,20}, disable=2, noedit=1,limits={-inf,inf,0},noproc ,title="Ypos = " |
---|
3320 | Setvariable yLB,fStyle=2, variable=root:Packages:SamplePlatesAvailable:yLB, help={"This is y postion of D corner"} |
---|
3321 | |
---|
3322 | TitleBox Dimensions title="\Zr120Dimensions[mm]: ",pos={260,30},size={150,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
3323 | SetVariable xDimension,pos={270,5},size={200,20}, noedit=0,limits={50,500,10},noproc,bodyWidth=70, title="Horizontal [mm] " |
---|
3324 | Setvariable xDimension,fStyle=2, variable=root:Packages:SamplePlatesAvailable:xDimension, help={"This is x dimension in mm of C corner"} |
---|
3325 | SetVariable yDimension,pos={270,55},size={200,20}, noedit=0,limits={50,500,10},noproc,bodyWidth=70,title="Vertical [mm] " |
---|
3326 | Setvariable yDimension,fStyle=2, variable=root:Packages:SamplePlatesAvailable:yDimension, help={"This is y dimension in mm of C corner"} |
---|
3327 | |
---|
3328 | Button TrimImportedImage,pos={400,30},size={120,17}, proc=IN3S_ButtonProc,title="Trim image", help={"Trims the image"} |
---|
3329 | |
---|
3330 | TitleBox RightBot title="\Zr120Right bot (B) : ",pos={550,5},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
3331 | SetVariable xRB,pos={550,25},size={90,20}, disable=2, noedit=1,limits={-inf,inf,0},noproc ,title="Xpos = " |
---|
3332 | Setvariable xRB,fStyle=2, variable=root:Packages:SamplePlatesAvailable:xRB, help={"This is x postion of B corner"} |
---|
3333 | SetVariable yRB,pos={550,45},size={90,20}, disable=2, noedit=1,limits={-inf,inf,0},noproc ,title="Ypos = " |
---|
3334 | Setvariable yRB,fStyle=2, variable=root:Packages:SamplePlatesAvailable:yRB, help={"This is y postion of B corner"} |
---|
3335 | |
---|
3336 | TitleBox RightTop title="\Zr120Right top (A) : ",pos={690,5},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
3337 | SetVariable xRT,pos={690,25},size={90,20}, disable=2, noedit=1,limits={-inf,inf,0},noproc ,title="Xpos = " |
---|
3338 | Setvariable xRT,fStyle=2, variable=root:Packages:SamplePlatesAvailable:xRT, help={"This is x postion of A corner"} |
---|
3339 | SetVariable yRT,pos={690,45},size={90,20}, disable=2, noedit=1,limits={-inf,inf,0},noproc ,title="Ypos = " |
---|
3340 | Setvariable yRT,fStyle=2, variable=root:Packages:SamplePlatesAvailable:yRT, help={"This is y postion of A corner"} |
---|
3341 | |
---|
3342 | SetWindow TrimCorrectImageDrawing, hook(CursorsMoved) = IN3S_MyCursorsMovedHook // Install window hook |
---|
3343 | |
---|
3344 | SetDataFolder OldDf |
---|
3345 | |
---|
3346 | end |
---|
3347 | //************************************************************************************************************ |
---|
3348 | //************************************************************************************************************ |
---|
3349 | |
---|
3350 | Function IN3S_TrimAndStraightenImage() |
---|
3351 | |
---|
3352 | |
---|
3353 | DFrEF OldDf=GetDataFolderDFR() |
---|
3354 | setdatafolder root:Packages:SamplePlatesAvailable |
---|
3355 | wave ImageIn = root:Packages:SamplePlatesAvailable:PlateImageTemp |
---|
3356 | |
---|
3357 | NVAR xRT=root:Packages:SamplePlatesAvailable:xRT |
---|
3358 | NVAR xRB=root:Packages:SamplePlatesAvailable:xRB |
---|
3359 | NVAR xLT=root:Packages:SamplePlatesAvailable:xLT |
---|
3360 | NVAR xLB=root:Packages:SamplePlatesAvailable:xLB |
---|
3361 | |
---|
3362 | NVAR yRT=root:Packages:SamplePlatesAvailable:yRT |
---|
3363 | NVAR yRB=root:Packages:SamplePlatesAvailable:yRB |
---|
3364 | NVAR yLT=root:Packages:SamplePlatesAvailable:yLT |
---|
3365 | NVAR yLB=root:Packages:SamplePlatesAvailable:yLB |
---|
3366 | |
---|
3367 | NVAR xDimension=root:Packages:SamplePlatesAvailable:xDimension |
---|
3368 | NVAR yDimension=root:Packages:SamplePlatesAvailable:yDimension |
---|
3369 | |
---|
3370 | SVAR LoadedImageName=root:Packages:SamplePlatesAvailable:LoadedImageName |
---|
3371 | |
---|
3372 | variable x1,x2,x3,x4,y1,y2,y3,y4 |
---|
3373 | x1 = xRT |
---|
3374 | x2 = xRB |
---|
3375 | x3 = xLT |
---|
3376 | x4 = xLB |
---|
3377 | y1 = yRT |
---|
3378 | y2 = yRB |
---|
3379 | y3 = yLT |
---|
3380 | y4 = yLB |
---|
3381 | |
---|
3382 | variable Scaling = 10 //10 points/mm. 0.1 mm/pixel. |
---|
3383 | variable Pwidth |
---|
3384 | variable NumPx = xDimension*Scaling |
---|
3385 | variable NumPy = yDimension*Scaling |
---|
3386 | Pwidth = DimSize(ImageIn,1)/NumPy |
---|
3387 | make/O/N=(NumPx, NumPy) PlateImage |
---|
3388 | SetScale/I x 0,xDimension,"mm", PlateImage |
---|
3389 | SetScale/I y 0,yDimension,"mm", PlateImage |
---|
3390 | |
---|
3391 | //now we need to fill this image with interpolated lines... |
---|
3392 | make/N=(NumPx)/O/FREE xwave, ywave |
---|
3393 | make/N=(NumPy)/O/FREE dummy |
---|
3394 | MatrixOP/O/free pWave=indexRows(xWave) |
---|
3395 | |
---|
3396 | MultiThread dummy=IN3S_TrimImgCalcOneLine(p,x1,x2,x3,x4,y1,y2,y3,y4,NumPx-1,NumPy-1,ImageIn,PlateImage, pWave, Pwidth) |
---|
3397 | |
---|
3398 | // //create plate drawing. |
---|
3399 | KillWIndow/Z SamplePlateImageDrawing |
---|
3400 | PauseUpdate |
---|
3401 | NewImage/K=1/N=SamplePlateImageDrawing root:Packages:SamplePlatesAvailable:PlateImage |
---|
3402 | DoWindow/T SamplePlateImageDrawing,"Image of "+LoadedImageName |
---|
3403 | //ModifyImage PlateImage ctab= {0,256,Grays,1} |
---|
3404 | ModifyGraph margin(left)=28,margin(bottom)=28,margin(top)=28,margin(right)=28 |
---|
3405 | SetAxis/R left (yDimension+0.125),-0.125 |
---|
3406 | SetAxis/R top (xDimension+0.125),-0.125 |
---|
3407 | Label left "\\Zr133millimeters from top right corner" |
---|
3408 | Label top "\\Zr133millimeters from top right corner" |
---|
3409 | ModifyGraph grid=1 |
---|
3410 | ModifyGraph mirror=3 |
---|
3411 | ModifyGraph nticks(left)=22,nticks(top)=22 |
---|
3412 | ModifyGraph minor=1 |
---|
3413 | ModifyGraph standoff=0 |
---|
3414 | ModifyGraph tkLblRot(left)=90 |
---|
3415 | ModifyGraph btLen=3 |
---|
3416 | ModifyGraph tlOffset=-2 |
---|
3417 | DoUpdate |
---|
3418 | SetWindow SamplePlateImageDrawing hook(ImageHook)=IN3S_PlateImageHook |
---|
3419 | |
---|
3420 | SetDataFolder OldDf |
---|
3421 | |
---|
3422 | End |
---|
3423 | //************************************************************************************************************ |
---|
3424 | //************************************************************************************************************ |
---|
3425 | |
---|
3426 | Function IN3S_MyCursorsMovedHook(s) |
---|
3427 | STRUCT WMWinHookStruct &s |
---|
3428 | |
---|
3429 | Variable hookResult = 0 // 0 if we do not handle event, 1 if we handle it. |
---|
3430 | NVAR xRT=root:Packages:SamplePlatesAvailable:xRT |
---|
3431 | NVAR xRB=root:Packages:SamplePlatesAvailable:xRB |
---|
3432 | NVAR xLT=root:Packages:SamplePlatesAvailable:xLT |
---|
3433 | NVAR xLB=root:Packages:SamplePlatesAvailable:xLB |
---|
3434 | |
---|
3435 | NVAR yRT=root:Packages:SamplePlatesAvailable:yRT |
---|
3436 | NVAR yRB=root:Packages:SamplePlatesAvailable:yRB |
---|
3437 | NVAR yLT=root:Packages:SamplePlatesAvailable:yLT |
---|
3438 | NVAR yLB=root:Packages:SamplePlatesAvailable:yLB |
---|
3439 | |
---|
3440 | switch(s.eventCode) |
---|
3441 | case 7: // cursor moved is 7... |
---|
3442 | //print s.cursorName |
---|
3443 | //print s.pointNumber |
---|
3444 | //print s.yPointNumber |
---|
3445 | strswitch(s.cursorName) |
---|
3446 | hookResult =1 |
---|
3447 | case "A": |
---|
3448 | xRT = s.pointNumber |
---|
3449 | yRT = s.yPointNumber |
---|
3450 | break |
---|
3451 | case "B": |
---|
3452 | xRB = s.pointNumber |
---|
3453 | yRB = s.yPointNumber |
---|
3454 | break |
---|
3455 | case "C": |
---|
3456 | xLT = s.pointNumber |
---|
3457 | yLT = s.yPointNumber |
---|
3458 | break |
---|
3459 | case "D": |
---|
3460 | xLB = s.pointNumber |
---|
3461 | yLB = s.yPointNumber |
---|
3462 | break |
---|
3463 | endswitch |
---|
3464 | break |
---|
3465 | endswitch |
---|
3466 | |
---|
3467 | return hookResult // 0 if nothing done, else 1 |
---|
3468 | End |
---|
3469 | |
---|
3470 | //************************************************************************************************************ |
---|
3471 | //************************************************************************************************************ |
---|
3472 | |
---|
3473 | ThreadSafe static function IN3S_TrimImgCalcOneLine(i,x1,x2,x3,x4,y1,y2,y3,y4,NumPx,NumPy,M_RGB2Gray,DestImage,pWave, Pwidth) |
---|
3474 | Variable i,x1,x2,x3,x4,y1,y2,y3,y4,NumPx,NumPy, Pwidth |
---|
3475 | Wave M_RGB2Gray,DestImage,pWave |
---|
3476 | |
---|
3477 | |
---|
3478 | Variable xfrac = i/(NumPy) |
---|
3479 | Variable xstart = (1-xfrac)*x1 + xfrac*x2 |
---|
3480 | Variable ystart = (1-xfrac)*y1 + xfrac*y2 |
---|
3481 | Variable xend = (1-xfrac)*x3 + xfrac*x4 |
---|
3482 | Variable yend = (1-xfrac)*y3 + xfrac*y4 |
---|
3483 | Variable xScale=(xend-xstart)/(NumPx) |
---|
3484 | Variable yScale=(yend-ystart)/(NumPx) |
---|
3485 | |
---|
3486 | MatrixOP/O/FREE xwave=xstart+pWave*xScale // |
---|
3487 | MatrixOP/O/FREE ywave=ystart+pWave*yScale |
---|
3488 | ImageLineProfile/V xWave=xwave, yWave=ywave, srcwave=M_RGB2Gray, width=Pwidth |
---|
3489 | |
---|
3490 | Wave W_ImageLineProfile |
---|
3491 | //DestImage[][i]=W_ImageLineProfile[p] |
---|
3492 | //MatrixOP/O DestImage=setCol(DestImage,i,W_ImageLineProfile) |
---|
3493 | ImageTransform/G=(i)/D=W_ImageLineProfile putCol DestImage |
---|
3494 | End |
---|
3495 | //************************************************************************************************************ |
---|
3496 | //************************************************************************************************************ |
---|
3497 | //***************************************************************************************************************** |
---|
3498 | //***************************************************************************************************************** |
---|
3499 | |
---|
3500 | // B E A M L I N E S U R V E Y C O D E |
---|
3501 | |
---|
3502 | //***************************************************************************************************************** |
---|
3503 | //***************************************************************************************************************** |
---|
3504 | |
---|
3505 | Function IN3S_BeamlineSurvey() |
---|
3506 | |
---|
3507 | //abort if epics support does not exist... |
---|
3508 | if(exists("pvOpen")!=4 && IN3SBeamlineSurveyDevelopOn<1) |
---|
3509 | Abort "This is useful only at the beamline on usaxspc7 or usaxspc11" |
---|
3510 | endif |
---|
3511 | /// abort if instrument in use. |
---|
3512 | IN3S_BeramlineSurveyAbortIfNeeded("Cannot use survey tool") |
---|
3513 | // |
---|
3514 | Wave/T ListWV = root:Packages:SamplePlateSetup:LBCommandWv |
---|
3515 | NVAR SelectedRow=root:Packages:SamplePlateSetup:SelectedRow |
---|
3516 | //ControlInfo/W=SamplePlateSetup CommandsList |
---|
3517 | variable V_Value=IN3S_FindFirstSelectedRow() |
---|
3518 | if(V_Value>=0 && V_Value<DimSize(ListWV,0)-1) |
---|
3519 | SelectedRow = V_Value |
---|
3520 | else |
---|
3521 | SelectedRow = 0 |
---|
3522 | endif |
---|
3523 | //Sync values |
---|
3524 | SVAR SelectedSampleName=root:Packages:SamplePlateSetup:SelectedSampleName |
---|
3525 | NVAR SampleThickness=root:Packages:SamplePlateSetup:SampleThickness |
---|
3526 | NVAR SampleXTAR=root:Packages:SamplePlateSetup:SampleXTAR |
---|
3527 | NVAR SampleYTAR=root:Packages:SamplePlateSetup:SampleYTAR |
---|
3528 | NVAR SampleXTable = root:Packages:SamplePlateSetup:SampleXTable |
---|
3529 | NVAR SampleYTable = root:Packages:SamplePlateSetup:SampleYTable |
---|
3530 | NVAR SampleXRBV=root:Packages:SamplePlateSetup:SampleXRBV |
---|
3531 | NVAR SampleYRBV=root:Packages:SamplePlateSetup:SampleYRBV |
---|
3532 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
3533 | SelectedSampleName = ListWV[SelectedRow][0] |
---|
3534 | //ListBox CommandsList, win=SamplePlateSetup, selrow=SelectedRow |
---|
3535 | LBSelectionWv[][0]=2 |
---|
3536 | LBSelectionWv[SelectedRow][0]=3 |
---|
3537 | SampleXTable = str2num(ListWV[SelectedRow][1]) |
---|
3538 | SampleYTable = str2num(ListWV[SelectedRow][2]) |
---|
3539 | SampleThickness = str2num(ListWV[SelectedRow][3]) |
---|
3540 | SampleThickness = numtype(SampleThickness)==0 ? SampleThickness : 1 |
---|
3541 | IN3S_AddTagToImage(SelectedRow) |
---|
3542 | DoWIndow BeamlinePlateSetup |
---|
3543 | if(V_Flag) |
---|
3544 | DoWindow/F BeamlinePlateSetup |
---|
3545 | else |
---|
3546 | IN3S_BeamlineSurveyPanel() |
---|
3547 | endif |
---|
3548 | SetWindow BeamlinePlateSetup hook(EpicsMon)=IN3S_BeamlineSurveyEpicsHook |
---|
3549 | IN3S_BeamlineSurveyStartEpicsUpdate() |
---|
3550 | //sync epics, RBV and TAR positions here |
---|
3551 | #if(exists("pvOpen")==4) |
---|
3552 | variable SxPV, SyPV |
---|
3553 | pvOpen/Q SxPV, "9idcLAX:m58:c2:m1.RBV" |
---|
3554 | pvOpen/Q SyPV, "9idcLAX:m58:c2:m2.RBV" |
---|
3555 | pvWait 5 |
---|
3556 | //this needs to be in background function and in 10Hz loop. |
---|
3557 | SampleXRBV = IN3S_GetMotorPositions(SxPV) |
---|
3558 | SampleYRBV = IN3S_GetMotorPositions(SyPV) |
---|
3559 | //end of background function loop. |
---|
3560 | pvClose SxPV |
---|
3561 | pvClose SyPV |
---|
3562 | #endif |
---|
3563 | SampleXTAR = SampleXRBV |
---|
3564 | SampleYTAR = SampleYRBV |
---|
3565 | end |
---|
3566 | |
---|
3567 | //************************************************************************************************* |
---|
3568 | //************************************************************************************************* |
---|
3569 | static Function IN3S_BeramlineSurveyAbortIfNeeded(string WhyString) |
---|
3570 | variable InstrumentUsed |
---|
3571 | #if(exists("pvOpen")==4) |
---|
3572 | InstrumentUsed = IN3S_GetPVVariableValue("9idcLAX:dataColInProgress") |
---|
3573 | if(InstrumentUsed) |
---|
3574 | abort "Instrument is collecting data, cannot "+WhyString |
---|
3575 | endif |
---|
3576 | #endif |
---|
3577 | end |
---|
3578 | //************************************************************************************************* |
---|
3579 | static Function IN3S_BeamlineSurveyStartEpicsUpdate() |
---|
3580 | //this starts updating epics. |
---|
3581 | CtrlNamedBackground IN2SMonitorEpics, period=IN3SBeamlineSurveyEpicsMonTicks, proc=IN3S_BackgroundEpics |
---|
3582 | CtrlNamedBackground IN2SMonitorEpics, start |
---|
3583 | return 0 |
---|
3584 | end |
---|
3585 | //************************************************************************************************* |
---|
3586 | static Function IN3S_BeamlineSurveyStopEpicsUpdate() |
---|
3587 | //this starts updating epics. |
---|
3588 | //CtrlNamedBackground IN2SMonitorEpics, period=IN3SBeamlineSurveyEpicsMonTicks, proc=IN3S_BackgroundEpics |
---|
3589 | CtrlNamedBackground IN2SMonitorEpics, stop |
---|
3590 | return 1 |
---|
3591 | end |
---|
3592 | //************************************************************************************************* |
---|
3593 | Function IN3S_BeamlineSurveyEpicsHook(s) |
---|
3594 | STRUCT WMWinHookStruct &s |
---|
3595 | |
---|
3596 | if(stringMatch(s.winName, "BeamlinePlateSetup")) |
---|
3597 | switch( s.eventCode ) |
---|
3598 | case 0: // window being activated |
---|
3599 | IN3S_BeamlineSurveyStartEpicsUpdate() |
---|
3600 | break |
---|
3601 | case 1: // window being deactivated |
---|
3602 | //IN3S_BeamlineSurveyStopEpicsUpdate() |
---|
3603 | break |
---|
3604 | case 2: // window being killed |
---|
3605 | IN3S_BeamlineSurveyStopEpicsUpdate() |
---|
3606 | break |
---|
3607 | case 15: // hide |
---|
3608 | IN3S_BeamlineSurveyStopEpicsUpdate() |
---|
3609 | break |
---|
3610 | case 16: // show |
---|
3611 | IN3S_BeamlineSurveyStartEpicsUpdate() |
---|
3612 | break |
---|
3613 | case 7: // finish edit |
---|
3614 | break |
---|
3615 | endswitch |
---|
3616 | endif |
---|
3617 | return 0 |
---|
3618 | end |
---|
3619 | //************************************************************************************************* |
---|
3620 | Function IN3S_BackgroundEpics(s) // This is the function that will be called periodically |
---|
3621 | STRUCT WMBackgroundStruct &s //note: cannot be static or things will not work. |
---|
3622 | NVAR SampleXRBV=root:Packages:SamplePlateSetup:SampleXRBV |
---|
3623 | NVAR SampleYRBV=root:Packages:SamplePlateSetup:SampleYRBV |
---|
3624 | #if(exists("pvOpen")==4) |
---|
3625 | variable SxPV, SyPV |
---|
3626 | pvOpen/Q SxPV, "9idcLAX:m58:c2:m1.RBV" |
---|
3627 | pvOpen/Q SyPV, "9idcLAX:m58:c2:m2.RBV" |
---|
3628 | pvWait 5 |
---|
3629 | //this needs to be in background function and in 10Hz loop. |
---|
3630 | SampleXRBV = IN3S_GetMotorPositions(SxPV) |
---|
3631 | SampleYRBV = IN3S_GetMotorPositions(SyPV) |
---|
3632 | //end of background function loop. |
---|
3633 | pvClose SxPV |
---|
3634 | pvClose SyPV |
---|
3635 | #endif |
---|
3636 | return 0 |
---|
3637 | end |
---|
3638 | //************************************************************************************************* |
---|
3639 | static function IN3S_GetMotorPositions(SPV) |
---|
3640 | variable SPV |
---|
3641 | |
---|
3642 | #if(exists("pvOpen")==4) |
---|
3643 | variable tempRBV |
---|
3644 | pvGet SPV, tempRBV |
---|
3645 | return tempRBV |
---|
3646 | #endif |
---|
3647 | end |
---|
3648 | //************************************************************************************************* |
---|
3649 | static function IN3S_GetPVVariableValue(PVString) |
---|
3650 | string PVString |
---|
3651 | |
---|
3652 | #if(exists("pvOpen")==4) |
---|
3653 | variable tempRBV, PVv |
---|
3654 | pvOpen/Q PVv, PVString |
---|
3655 | pvGet PVv, tempRBV |
---|
3656 | pvClose PVv |
---|
3657 | return tempRBV |
---|
3658 | #endif |
---|
3659 | end |
---|
3660 | //************************************************************************************************* |
---|
3661 | //************************************************************************************************* |
---|
3662 | //************************************************************************************************* |
---|
3663 | |
---|
3664 | Function IN3S_BeamlineSurveyPanel() |
---|
3665 | |
---|
3666 | string oldDf=GetDataFolder(1) |
---|
3667 | setDataFolder root:Packages:SamplePlateSetup |
---|
3668 | /// abort if instrument in use. |
---|
3669 | IN3S_BeramlineSurveyAbortIfNeeded("Cannot use survey tool") |
---|
3670 | |
---|
3671 | DoWindow BeamlinePlateSetup |
---|
3672 | if(V_Flag) |
---|
3673 | DoWindow/F BeamlinePlateSetup |
---|
3674 | else |
---|
3675 | PauseUpdate // building window... |
---|
3676 | NewPanel /K=1 /W=(592.25,43.25,1000,550)/N=BeamlinePlateSetup as "Beamline Sample Plate survey" |
---|
3677 | SetDrawLayer UserBack |
---|
3678 | //SetDrawEnv fillfgc= (16386,65535,16385),fillbgc= (0,65535,0) |
---|
3679 | //SetDrawEnv linefgc= (32792,65535,1),fillbgc= (32792,65535,1),fillfgc= (32792,65535,1) |
---|
3680 | SetDrawEnv linefgc= (49151,65535,49151),fillbgc= (49151,65535,49151),fillfgc= (49151,65535,49151) |
---|
3681 | DrawRect 194,175,400,198 |
---|
3682 | SetDrawEnv fillfgc= (49151,65535,49151) |
---|
3683 | DrawRRect 6,234,189,400 |
---|
3684 | SetDrawEnv fillfgc= (49151,65535,49151) |
---|
3685 | DrawRRect 212,234,395,400 |
---|
3686 | TitleBox Title title="\Zr210Beamline survey",pos={50,3},frame=0,fstyle=3,size={300,24},fColor=(1,4,52428), anchor=MC |
---|
3687 | //selected row and sample name |
---|
3688 | SetVariable SelectedRow,pos={100,40},size={180,20}, limits={0,200,0}, proc=IN3S_SurveySetVarProc,title="Selected row: ",fSize=14 |
---|
3689 | Setvariable SelectedRow,fStyle=2, variable=root:Packages:SamplePlateSetup:SelectedRow, help={"Selected row in the table"},format="%3.0f" |
---|
3690 | |
---|
3691 | Button MoveRowUp,pos={80,70},size={100,25}, proc=IN3S_SurveyButtonProc,title="Row ⇑",fSize=14, help={"Moves row up (lower row number)"} |
---|
3692 | Button MoveRowDown,pos={220,70},size={100,25}, proc=IN3S_SurveyButtonProc,title="Row ⇓",fSize=14, help={"Moves row up (lower row number)"} |
---|
3693 | SetVariable SelectedSampleName,pos={10,105},size={370,25}, limits={0,200,1}, proc=IN3S_SurveySetVarProc,title="Sa Name: ",fSize=14 |
---|
3694 | Setvariable SelectedSampleName,fStyle=2, variable=root:Packages:SamplePlateSetup:SelectedSampleName, help={"Sample name from the table or saved to table"} |
---|
3695 | SetVariable SampleThickness,pos={20,130},size={250,25}, limits={0,20,0.1}, proc=IN3S_SurveySetVarProc,title="Sa Thickness [mm]: ",fSize=14 |
---|
3696 | Setvariable SampleThickness,fStyle=2, variable=root:Packages:SamplePlateSetup:SampleThickness, help={"Sample Thickness in mm"},format="%3.3f" |
---|
3697 | Button GoTo00,pos={300,130},size={100,15}, proc=IN3S_SurveyButtonProc,title="Go 0,0",fSize=14, help={"Moves to 0,0"} |
---|
3698 | Button GoTo00 fColor=(0,65535,0) |
---|
3699 | |
---|
3700 | SetVariable SampleXTable,pos={30,155},size={130,15}, limits={-inf,inf,0}, noproc, noedit=1,title="Sa X tbl =",fSize=12, frame=0 |
---|
3701 | Setvariable SampleXTable,fStyle=2, variable=root:Packages:SamplePlateSetup:SampleXTable, help={"Sample Thickness in mm"},format="%3.2f" |
---|
3702 | SetVariable SampleYTable,pos={220,155},size={130,15}, limits={-inf,inf,0}, proc=IN3S_SetVarProc,title="Sa Y tbl =",fSize=12, frame=0 |
---|
3703 | Setvariable SampleYTable,fStyle=2, variable=root:Packages:SamplePlateSetup:SampleYTable, help={"Sample Thickness in mm"},format="%3.2f" |
---|
3704 | |
---|
3705 | Button DriveTovals,pos={10,178},size={160,20}, proc=IN3S_SurveyButtonProc,title="Drive to table values",fSize=12, help={"Moves SX and SY to table positions"} |
---|
3706 | Button DriveTovals fColor=(0,65535,0) |
---|
3707 | CheckBox MoveWhenRowChanges pos={200,180},size={70,20},title="Drive to SX/SY on row change?", help={"When selected, SX and SY will move when row is changed"} |
---|
3708 | CheckBox MoveWhenRowChanges variable=root:Packages:SamplePlateSetup:MoveWhenRowChanges, noproc, fColor=(0,0,0),labelBack=(49151,65535,49151) |
---|
3709 | |
---|
3710 | //save values... |
---|
3711 | Button SaveValues,pos={100,208.00},size={200,20}, proc=IN3S_SurveyButtonProc,title="Save Values",fSize=14, help={"Copies values to the table of positions"} |
---|
3712 | Button SaveValues fColor=(65535,32768,32768) |
---|
3713 | |
---|
3714 | TitleBox Info1 title="\Zr200Sx : ",pos={45,238},size={20,15},frame=0,fColor=(0,0,65535),labelBack=0,fstyle=1 |
---|
3715 | TitleBox Info2 title="\Zr200Sy : ",pos={265,238},size={20,15},frame=0,fColor=(0,0,65535),labelBack=0,fstyle=1 |
---|
3716 | SetVariable SampleXRBV,pos={80,238},size={60,30}, limits={-200,200, 0}, noproc,title=" ",fSize=18, noedit=1, frame=0 |
---|
3717 | SetVariable SampleXRBV,variable=root:Packages:SamplePlateSetup:SampleXRBV, help={"SX RBV position"},format="%6.2f" |
---|
3718 | SetVariable SampleYRBV,pos={300,238},size={60,30}, limits={-200,200, 0}, noproc,title=" ",fSize=18, noedit=1, frame=0 |
---|
3719 | SetVariable SampleYRBV,variable=root:Packages:SamplePlateSetup:SampleYRBV, help={"SY RBV position"},format="%6.2f" |
---|
3720 | |
---|
3721 | SetVariable SampleXTAR,pos={50,270},size={90,30}, limits={-200,200, 0}, proc=IN3S_SurveySetVarProc,title=" ",fSize=25 |
---|
3722 | Setvariable SampleXTAR,fStyle=2, variable=root:Packages:SamplePlateSetup:SampleXTAR, help={"SX position"},format="%6.2f" |
---|
3723 | SetVariable SampleYTAR,pos={260,270},size={90,30}, limits={-200,200, 0}, proc=IN3S_SurveySetVarProc,title=" ",fSize=25 |
---|
3724 | Setvariable SampleYTAR,fStyle=2, variable=root:Packages:SamplePlateSetup:SampleYTAR, help={"SY position"},format="%6.2f" |
---|
3725 | |
---|
3726 | Button MoveSXLow,pos={10,260},size={30,50}, proc=IN3S_SurveyButtonProc,title="-",help={"Moves SX lower by the step value"} |
---|
3727 | Button MoveSXLow,fSize=24,fstyle=1,fColor=(1,16019,65535) |
---|
3728 | Button MoveSXHigh,pos={150,260},size={30,50}, proc=IN3S_SurveyButtonProc,title="+",help={"Moves SX higher by the step value"} |
---|
3729 | Button MoveSXHigh,fSize=24,fstyle=1,fColor=(1,16019,65535) |
---|
3730 | |
---|
3731 | Button MoveSYLow,pos={220,260},size={30,50}, proc=IN3S_SurveyButtonProc,title="-",help={"Moves SY lower by the step value"} |
---|
3732 | Button MoveSYLow,fSize=24,fstyle=1,fColor=(1,16019,65535) |
---|
3733 | Button MoveSYHigh,pos={360,260},size={30,50}, proc=IN3S_SurveyButtonProc,title="+",help={"Moves SY higher by the step value"} |
---|
3734 | Button MoveSYHigh,fSize=24,fstyle=1,fColor=(1,16019,65535) |
---|
3735 | |
---|
3736 | |
---|
3737 | TitleBox Info3 title="\Zr130Sx step : ",pos={50,310},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0,fstyle=1 |
---|
3738 | TitleBox Info4 title="\Zr130Sy step : ",pos={265,310},size={250,15},frame=0,fColor=(0,0,65535),labelBack=0,fstyle=1 |
---|
3739 | |
---|
3740 | SetVariable SurveySXStep,pos={52,330},size={90,20}, limits={0,100, 1}, proc=IN3S_SurveySetVarProc,title=" ",fSize=20 |
---|
3741 | Setvariable SurveySXStep,fStyle=2, variable=root:Packages:SamplePlateSetup:SurveySXStep, help={"SX step"},format="%6.2f" |
---|
3742 | SetVariable SurveySYStep,pos={262,330},size={90,20}, limits={0,100, 1}, proc=IN3S_SurveySetVarProc,title=" ",fSize=20 |
---|
3743 | Setvariable SurveySYStep,fStyle=2, variable=root:Packages:SamplePlateSetup:SurveySYStep, help={"SY step"},format="%6.2f" |
---|
3744 | |
---|
3745 | |
---|
3746 | Button ChangeSXStepLow,pos={10,370},size={75,20}, proc=IN3S_SurveyButtonProc,title="x 0.1",fSize=14, help={"Changes SX step by 0.1"} |
---|
3747 | Button ChangeSXStepHigh,pos={100,370},size={75,20}, proc=IN3S_SurveyButtonProc,title="x 10",fSize=14, help={"Changes SX step by 10"} |
---|
3748 | |
---|
3749 | Button ChangeSYStepLow,pos={220,370},size={75,20}, proc=IN3S_SurveyButtonProc,title="x 0.1",fSize=14, help={"Changes SX step by 0.1"} |
---|
3750 | Button ChangeSYStepHigh,pos={310,370},size={75,20}, proc=IN3S_SurveyButtonProc,title="x 10",fSize=14, help={"Changes SX step by 10"} |
---|
3751 | |
---|
3752 | Button SetSXAs00,pos={50,405},size={70,15}, proc=IN3S_SurveyButtonProc,title="Set SX 0",fSize=14, help={"Sets current position as 0,0"} |
---|
3753 | Button SetSXAs00 fColor=(65535,32768,32768) |
---|
3754 | Button SetSYAs00,pos={260,405},size={70,15}, proc=IN3S_SurveyButtonProc,title="Set SY 0",fSize=14, help={"Sets current position as 0,0"} |
---|
3755 | Button SetSYAs00 fColor=(65535,32768,32768) |
---|
3756 | |
---|
3757 | Button SyncMotors,pos={10,425},size={105,15}, proc=IN3S_SurveyButtonProc,title="Sync w/epics",fSize=14, help={"Sync all motors positons with epics"} |
---|
3758 | Button STOPMotors,pos={10,450},size={105,30}, proc=IN3S_SurveyButtonProc,title="STOP motors",fSize=14, help={"STOP ALL MOTORS MOVEMENT"} |
---|
3759 | Button STOPMotors fColor=(65535,32768,32768) |
---|
3760 | |
---|
3761 | Button OpenSlitsLarge,pos={250,425},size={135,20}, proc=IN3S_SurveyButtonProc,title="Open Slits Large",fSize=14, help={"Open slits as large as possible"} |
---|
3762 | Button OpenSlitsUSAXS,pos={250,450},size={135,20}, proc=IN3S_SurveyButtonProc,title="USAXS Slits",fSize=14, help={"Open Slits for USAXS"} |
---|
3763 | Button OpenSlitsSWAXS,pos={250,475},size={135,20}, proc=IN3S_SurveyButtonProc,title="SWAXS Slits",fSize=14, help={"Open Slits for SAXS/WAXS"} |
---|
3764 | |
---|
3765 | TitleBox Info5 title="\Zr110NOTE: row numbering is 0 based...",size={355,20},pos={5,485},frame=0,fColor=(0,0,65535),labelBack=0 |
---|
3766 | |
---|
3767 | endif |
---|
3768 | |
---|
3769 | end |
---|
3770 | |
---|
3771 | |
---|
3772 | //***************************************************************************************************************** |
---|
3773 | //***************************************************************************************************************** |
---|
3774 | //************************************************************************************************************ |
---|
3775 | //************************************************************************************************************ |
---|
3776 | |
---|
3777 | |
---|
3778 | Function IN3S_SurveySetVarProc(sva) : SetVariableControl |
---|
3779 | STRUCT WMSetVariableAction &sva |
---|
3780 | |
---|
3781 | switch( sva.eventCode ) |
---|
3782 | case 1: // mouse up |
---|
3783 | case 2: // Enter key |
---|
3784 | case 3: // Live update |
---|
3785 | Variable dval = sva.dval |
---|
3786 | String sval = sva.sval |
---|
3787 | |
---|
3788 | if(StringMatch(sva.ctrlName, "SelectedRow")) |
---|
3789 | NVAR SelectedRow=root:Packages:SamplePlateSetup:SelectedRow |
---|
3790 | SVAR SelectedSampleName=root:Packages:SamplePlateSetup:SelectedSampleName |
---|
3791 | Wave/T ListWV = root:Packages:SamplePlateSetup:LBCommandWv |
---|
3792 | NVAR SampleThickness=root:Packages:SamplePlateSetup:SampleThickness |
---|
3793 | NVAR SampleXTAR=root:Packages:SamplePlateSetup:SampleXTAR |
---|
3794 | NVAR SampleYTAR=root:Packages:SamplePlateSetup:SampleYTAR |
---|
3795 | NVAR SampleXTable = root:Packages:SamplePlateSetup:SampleXTable |
---|
3796 | NVAR SampleYTable = root:Packages:SamplePlateSetup:SampleYTable |
---|
3797 | NVAR DefSaThick = root:Packages:SamplePlateSetup:DefaultSampleThickness |
---|
3798 | if(SelectedRow>DimSize(ListWV,0)-2) |
---|
3799 | IN3S_InsertDeleteLines(4, SelectedRow, 1) |
---|
3800 | endif |
---|
3801 | SelectedRow=SelectedRow+1 |
---|
3802 | SelectedSampleName = ListWV[SelectedRow][0] |
---|
3803 | //ListBox CommandsList, win=SamplePlateSetup, selrow=SelectedRow |
---|
3804 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
3805 | LBSelectionWv[][0]=2 |
---|
3806 | LBSelectionWv[SelectedRow][0]=3 |
---|
3807 | SampleXTable = str2num(ListWV[SelectedRow][1]) |
---|
3808 | SampleYTable = str2num(ListWV[SelectedRow][2]) |
---|
3809 | SampleThickness = str2num(ListWV[SelectedRow][3]) |
---|
3810 | SampleThickness = numtype(SampleThickness)==0 ? SampleThickness : DefSaThick |
---|
3811 | IN3S_AddTagToImage(SelectedRow) |
---|
3812 | IN3S_EstimateRunTime() |
---|
3813 | endif |
---|
3814 | |
---|
3815 | if(StringMatch(sva.ctrlName, "SampleXTAR")) |
---|
3816 | IN3S_BeamlineSurveyStartEpicsUpdate() |
---|
3817 | IN3S_MoveMotorInEpics("SX",dval) |
---|
3818 | endif |
---|
3819 | if(StringMatch(sva.ctrlName, "SampleYTAR")) |
---|
3820 | IN3S_BeamlineSurveyStartEpicsUpdate() |
---|
3821 | IN3S_MoveMotorInEpics("SY",dval) |
---|
3822 | endif |
---|
3823 | if(StringMatch(sva.ctrlName, "SelectedSampleName")) |
---|
3824 | SVAR SelectedSampleName = root:Packages:SamplePlateSetup:SelectedSampleName |
---|
3825 | SelectedSampleName = CleanupName(sval, 0 , 40) |
---|
3826 | endif |
---|
3827 | if(StringMatch(sva.ctrlName, "SampleThickness")) |
---|
3828 | NVAR SampleThickness = root:Packages:SamplePlateSetup:SampleThickness |
---|
3829 | if(dval<0 || dval>20) |
---|
3830 | DoAlert /T="Wrong thickness" 0, "Thickness must be between 0 and 20 [mm]" |
---|
3831 | SampleThickness = DefSaThick |
---|
3832 | endif |
---|
3833 | endif |
---|
3834 | |
---|
3835 | break |
---|
3836 | case -1: // control being killed |
---|
3837 | break |
---|
3838 | endswitch |
---|
3839 | |
---|
3840 | return 0 |
---|
3841 | End |
---|
3842 | //***************************************************************************************************************** |
---|
3843 | //***************************************************************************************************************** |
---|
3844 | //************************************************************************************************************ |
---|
3845 | //************************************************************************************************************ |
---|
3846 | |
---|
3847 | |
---|
3848 | Function IN3S_SurveyButtonProc(ba) : ButtonControl |
---|
3849 | STRUCT WMButtonAction &ba |
---|
3850 | |
---|
3851 | switch( ba.eventCode ) |
---|
3852 | case 2: // mouse up |
---|
3853 | // click code here |
---|
3854 | NVAR SXStep = root:Packages:SamplePlateSetup:SurveySXStep |
---|
3855 | NVAR SYStep = root:Packages:SamplePlateSetup:SurveySYStep |
---|
3856 | // NVAR CurentSX=root:Packages:SamplePlateSetup:SampleXTAR |
---|
3857 | // NVAR CurentSY=root:Packages:SamplePlateSetup:SampleYTAR |
---|
3858 | NVAR SampleXTAR = root:Packages:SamplePlateSetup:SampleXTAR |
---|
3859 | NVAR SampleYTAR = root:Packages:SamplePlateSetup:SampleYTAR |
---|
3860 | NVAR SampleXRBV = root:Packages:SamplePlateSetup:SampleXRBV |
---|
3861 | NVAR SampleYRBV = root:Packages:SamplePlateSetup:SampleYRBV |
---|
3862 | Wave LBSelectionWv = root:Packages:SamplePlateSetup:LBSelectionWv |
---|
3863 | if(StringMatch(ba.ctrlName, "MoveSXLow")) |
---|
3864 | SampleXTAR = SampleXTAR-SXStep |
---|
3865 | IN3S_MoveMotorInEpics("SX",SampleXTAR) |
---|
3866 | endif |
---|
3867 | if(StringMatch(ba.ctrlName, "MoveSXHigh")) |
---|
3868 | SampleXTAR = SampleXTAR+SXStep |
---|
3869 | IN3S_MoveMotorInEpics("SX",SampleXTAR) |
---|
3870 | endif |
---|
3871 | if(StringMatch(ba.ctrlName, "MoveSYLow")) |
---|
3872 | SampleyTAR = SampleYTAR-SyStep |
---|
3873 | IN3S_MoveMotorInEpics("SY",SampleyTAR) |
---|
3874 | endif |
---|
3875 | if(StringMatch(ba.ctrlName, "MoveSYHigh")) |
---|
3876 | SampleyTAR = SampleYTAR+SyStep |
---|
3877 | IN3S_MoveMotorInEpics("SY",SampleyTAR) |
---|
3878 | endif |
---|
3879 | if(StringMatch(ba.ctrlName, "ChangeSXStepLow")) |
---|
3880 | SXStep = (SXStep<0.01 || SXStep>100) ? 1 : SXStep |
---|
3881 | SXStep = SXStep>0.1 ? SXStep*0.1 : 0.01 |
---|
3882 | endif |
---|
3883 | if(StringMatch(ba.ctrlName, "ChangeSXStepHigh")) |
---|
3884 | SXStep = (SXStep<0.01 || SXStep>100) ? 1 : SXStep |
---|
3885 | SXStep = SXStep<10 ? SXStep*10 : 100 |
---|
3886 | endif |
---|
3887 | |
---|
3888 | if(StringMatch(ba.ctrlName, "ChangeSYStepLow")) |
---|
3889 | SYStep = (SYStep<0.01 || SYStep>100) ? 1 : SYStep |
---|
3890 | SYStep = SYStep>0.1 ? SYStep*0.1 : 0.01 |
---|
3891 | endif |
---|
3892 | if(StringMatch(ba.ctrlName, "ChangeSYStepHigh")) |
---|
3893 | SYStep = (SYStep<0.01 || SYStep>100) ? 1 : SYStep |
---|
3894 | SYStep = SYStep<10 ? SYStep*10 : 100 |
---|
3895 | endif |
---|
3896 | |
---|
3897 | if(StringMatch(ba.ctrlName, "GoTo00")) |
---|
3898 | SampleXTAR = 0 |
---|
3899 | SampleYTAR = 0 |
---|
3900 | IN3S_MoveMotorInEpics("SX",SampleXTAR) |
---|
3901 | IN3S_MoveMotorInEpics("SY",SampleYTAR) |
---|
3902 | endif |
---|
3903 | if(StringMatch(ba.ctrlName, "SyncMotors")) |
---|
3904 | #if(exists("pvOpen")==4) |
---|
3905 | variable SxPV, SyPV |
---|
3906 | pvOpen/Q SxPV, "9idcLAX:m58:c2:m1.RBV" |
---|
3907 | pvOpen/Q SyPV, "9idcLAX:m58:c2:m2.RBV" |
---|
3908 | SampleXTAR = IN3S_GetMotorPositions(SxPV) |
---|
3909 | SampleYTAR = IN3S_GetMotorPositions(SyPV) |
---|
3910 | SampleXRBV = IN3S_GetMotorPositions(SxPV) |
---|
3911 | SampleYRBV = IN3S_GetMotorPositions(SyPV) |
---|
3912 | pvWait 5 |
---|
3913 | pvClose SxPV |
---|
3914 | pvClose SyPV |
---|
3915 | #endif |
---|
3916 | endif |
---|
3917 | variable InstrumentUsed |
---|
3918 | if(StringMatch(ba.ctrlName, "SetSXAs00")) |
---|
3919 | #if(exists("pvOpen")==4) |
---|
3920 | InstrumentUsed = IN3S_GetPVVariableValue("9idcLAX:dataColInProgress") |
---|
3921 | if(InstrumentUsed) |
---|
3922 | abort "Instrument is collecting data, cannot move motors" |
---|
3923 | else |
---|
3924 | //"SX" |
---|
3925 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m1.SSET", 1) |
---|
3926 | sleep/T 10 |
---|
3927 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m1.VAL", 0) |
---|
3928 | sleep/T 10 |
---|
3929 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m1.SUSE", 1) |
---|
3930 | endif |
---|
3931 | SampleXTAR = 0 |
---|
3932 | #endif |
---|
3933 | endif |
---|
3934 | if(StringMatch(ba.ctrlName, "SetSYAs00")) |
---|
3935 | #if(exists("pvOpen")==4) |
---|
3936 | InstrumentUsed = IN3S_GetPVVariableValue("9idcLAX:dataColInProgress") |
---|
3937 | if(InstrumentUsed) |
---|
3938 | abort "Instrument is collecting data, cannot move motors" |
---|
3939 | else |
---|
3940 | //"SY" |
---|
3941 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m2.SSET", 1) |
---|
3942 | sleep/T 10 |
---|
3943 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m2.VAL", 0) |
---|
3944 | sleep/T 10 |
---|
3945 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m2.SUSE", 1) |
---|
3946 | endif |
---|
3947 | SampleYTAR = 0 |
---|
3948 | #endif |
---|
3949 | endif |
---|
3950 | if(StringMatch(ba.ctrlName, "STOPMotors")) |
---|
3951 | #if(exists("pvOpen")==4) |
---|
3952 | InstrumentUsed = IN3S_GetPVVariableValue("9idcLAX:dataColInProgress") |
---|
3953 | if(InstrumentUsed) |
---|
3954 | abort "Instrument is collecting data, cannot move motors" |
---|
3955 | else |
---|
3956 | IN3S_PutEpicsPv("9idcLAX:alltop", 1) |
---|
3957 | endif |
---|
3958 | #endif |
---|
3959 | endif |
---|
3960 | variable HorSlit, VertSLit, HorGuardSlit, VertGuardSlit |
---|
3961 | if(StringMatch(ba.ctrlName, "OpenSlitsLarge")) |
---|
3962 | #if(exists("pvOpen")==4) |
---|
3963 | InstrumentUsed = IN3S_GetPVVariableValue("9idcLAX:dataColInProgress") |
---|
3964 | if(InstrumentUsed) |
---|
3965 | abort "Instrument is collecting data, cannot move motors" |
---|
3966 | else |
---|
3967 | //c2:m8 is Horizontal slit size |
---|
3968 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m8.VAL", 2.5) |
---|
3969 | IN3S_PutEpicsPv("9idcLAX:GSlit1H:size", 2.8) |
---|
3970 | //c2:m8 is Vertical slit size |
---|
3971 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m7.VAL", 1.2) |
---|
3972 | IN3S_PutEpicsPv("9idcLAX:GSlit1V:size", 1.4) |
---|
3973 | endif |
---|
3974 | #endif |
---|
3975 | endif |
---|
3976 | |
---|
3977 | if(StringMatch(ba.ctrlName, "OpenSlitsUSAXS")) |
---|
3978 | #if(exists("pvOpen")==4) |
---|
3979 | InstrumentUsed = IN3S_GetPVVariableValue("9idcLAX:dataColInProgress") |
---|
3980 | if(InstrumentUsed) |
---|
3981 | abort "Instrument is collecting data, cannot move motors" |
---|
3982 | else |
---|
3983 | HorSlit = IN3S_GetPVVariableValue("9idcLAX:USAXS_hslit_ap") |
---|
3984 | VertSLit = IN3S_GetPVVariableValue("9idcLAX:USAXS_vslit_ap") |
---|
3985 | HorGuardSlit = IN3S_GetPVVariableValue("9idcLAX:USAXS_hgslit_ap") |
---|
3986 | VertGuardSlit = IN3S_GetPVVariableValue("9idcLAX:USAXS_vgslit_ap") |
---|
3987 | //c2:m8 is Horizontal slit size |
---|
3988 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m8.VAL", HorSlit) |
---|
3989 | IN3S_PutEpicsPv("9idcLAX:GSlit1H:size", HorGuardSlit) |
---|
3990 | //c2:m8 is Vertical slit size |
---|
3991 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m7.VAL", VertSLit) |
---|
3992 | IN3S_PutEpicsPv("9idcLAX:GSlit1V:size", VertGuardSlit) |
---|
3993 | endif |
---|
3994 | #endif |
---|
3995 | endif |
---|
3996 | if(StringMatch(ba.ctrlName, "OpenSlitsSWAXS")) |
---|
3997 | #if(exists("pvOpen")==4) |
---|
3998 | InstrumentUsed = IN3S_GetPVVariableValue("9idcLAX:dataColInProgress") |
---|
3999 | if(InstrumentUsed) |
---|
4000 | abort "Instrument is collecting data, cannot move motors" |
---|
4001 | else |
---|
4002 | HorSlit = IN3S_GetPVVariableValue("9idcLAX:SAXS_hslit_ap") |
---|
4003 | VertSLit = IN3S_GetPVVariableValue("9idcLAX:SAXS_vslit_ap") |
---|
4004 | HorGuardSlit = IN3S_GetPVVariableValue("9idcLAX:SAXS_hgslit_ap") |
---|
4005 | VertGuardSlit = IN3S_GetPVVariableValue("9idcLAX:SAXS_vgslit_ap") |
---|
4006 | //c2:m8 is Horizontal slit size |
---|
4007 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m8.VAL", HorSlit) |
---|
4008 | IN3S_PutEpicsPv("9idcLAX:GSlit1H:size", HorGuardSlit) |
---|
4009 | //c2:m8 is Vertical slit size |
---|
4010 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m7.VAL", VertSLit) |
---|
4011 | IN3S_PutEpicsPv("9idcLAX:GSlit1V:size", VertGuardSlit) |
---|
4012 | endif |
---|
4013 | #endif |
---|
4014 | endif |
---|
4015 | |
---|
4016 | if(StringMatch(ba.ctrlName, "MoveRowUp")) |
---|
4017 | Wave SelWv=root:Packages:SamplePlateSetup:LBSelectionWv |
---|
4018 | NVAR SelectedRow=root:Packages:SamplePlateSetup:SelectedRow |
---|
4019 | SVAR SelectedSampleName=root:Packages:SamplePlateSetup:SelectedSampleName |
---|
4020 | Wave/T ListWV = root:Packages:SamplePlateSetup:LBCommandWv |
---|
4021 | NVAR SampleThickness=root:Packages:SamplePlateSetup:SampleThickness |
---|
4022 | NVAR SampleXTAR=root:Packages:SamplePlateSetup:SampleXTAR |
---|
4023 | NVAR SampleYTAR=root:Packages:SamplePlateSetup:SampleYTAR |
---|
4024 | NVAR SampleXTable = root:Packages:SamplePlateSetup:SampleXTable |
---|
4025 | NVAR SampleYTable = root:Packages:SamplePlateSetup:SampleYTable |
---|
4026 | NVAR DefSaThick = root:Packages:SamplePlateSetup:DefaultSampleThickness |
---|
4027 | if(SelectedRow>0) |
---|
4028 | SelectedRow=SelectedRow-1 |
---|
4029 | SelWv[][0]=2 |
---|
4030 | SelWv[SelectedRow]=3 |
---|
4031 | SelectedSampleName = ListWV[SelectedRow][0] |
---|
4032 | //LBSelectionWv[][0]=2 |
---|
4033 | //LBSelectionWv[SelectedRow][0]=3 |
---|
4034 | SampleXTable = str2num(ListWV[SelectedRow][1]) |
---|
4035 | SampleYTable = str2num(ListWV[SelectedRow][2]) |
---|
4036 | SampleThickness = str2num(ListWV[SelectedRow][3]) |
---|
4037 | SampleThickness = numtype(SampleThickness)==0 ? SampleThickness : DefSaThick |
---|
4038 | endif |
---|
4039 | IN3S_AddTagToImage(SelectedRow) |
---|
4040 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
4041 | WarningForUser = "Moved selected row up" |
---|
4042 | IN3S_MoveToPositionIfOK() |
---|
4043 | IN3S_EstimateRunTime() |
---|
4044 | endif |
---|
4045 | if(StringMatch(ba.ctrlName, "MoveRowDown")) |
---|
4046 | Wave SelWv=root:Packages:SamplePlateSetup:LBSelectionWv |
---|
4047 | NVAR SelectedRow=root:Packages:SamplePlateSetup:SelectedRow |
---|
4048 | SVAR SelectedSampleName=root:Packages:SamplePlateSetup:SelectedSampleName |
---|
4049 | Wave/T ListWV = root:Packages:SamplePlateSetup:LBCommandWv |
---|
4050 | NVAR SampleThickness=root:Packages:SamplePlateSetup:SampleThickness |
---|
4051 | NVAR SampleXTAR=root:Packages:SamplePlateSetup:SampleXTAR |
---|
4052 | NVAR SampleYTAR=root:Packages:SamplePlateSetup:SampleYTAR |
---|
4053 | NVAR SampleXTable = root:Packages:SamplePlateSetup:SampleXTable |
---|
4054 | NVAR SampleYTable = root:Packages:SamplePlateSetup:SampleYTable |
---|
4055 | NVAR DefSaThick = root:Packages:SamplePlateSetup:DefaultSampleThickness |
---|
4056 | if(SelectedRow>DimSize(ListWV,0)-2) |
---|
4057 | IN3S_InsertDeleteLines(4, SelectedRow, 1) |
---|
4058 | endif |
---|
4059 | SelectedRow=SelectedRow+1 |
---|
4060 | SelWv[][0]=2 |
---|
4061 | SelWv[SelectedRow]=3 |
---|
4062 | SelectedSampleName = ListWV[SelectedRow][0] |
---|
4063 | //LBSelectionWv[][0]=2 |
---|
4064 | //LBSelectionWv[SelectedRow][0]=3 |
---|
4065 | SampleXTable = str2num(ListWV[SelectedRow][1]) |
---|
4066 | SampleYTable = str2num(ListWV[SelectedRow][2]) |
---|
4067 | SampleThickness = str2num(ListWV[SelectedRow][3]) |
---|
4068 | SampleThickness = numtype(SampleThickness)==0 ? SampleThickness : DefSaThick |
---|
4069 | IN3S_AddTagToImage(SelectedRow) |
---|
4070 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
4071 | WarningForUser = "Moved selected row down" |
---|
4072 | IN3S_MoveToPositionIfOK() |
---|
4073 | IN3S_EstimateRunTime() |
---|
4074 | endif |
---|
4075 | if(StringMatch(ba.ctrlName, "DriveTovals")) |
---|
4076 | NVAR SelectedRow=root:Packages:SamplePlateSetup:SelectedRow |
---|
4077 | Wave/T ListWV = root:Packages:SamplePlateSetup:LBCommandWv |
---|
4078 | NVAR SampleXTable = root:Packages:SamplePlateSetup:SampleXTable |
---|
4079 | NVAR SampleYTable = root:Packages:SamplePlateSetup:SampleYTable |
---|
4080 | NVAR SampleXTAR = root:Packages:SamplePlateSetup:SampleXTAR |
---|
4081 | NVAR SampleYTAR = root:Packages:SamplePlateSetup:SampleYTAR |
---|
4082 | SampleXTAR = SampleXTable |
---|
4083 | SampleYTAR = SampleYTable |
---|
4084 | IN3S_MoveMotorInEpics("SX",SampleXTAR) |
---|
4085 | IN3S_MoveMotorInEpics("SY",SampleYTAR) |
---|
4086 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
4087 | WarningForUser = "Moved to sample position from table" |
---|
4088 | endif |
---|
4089 | if(StringMatch(ba.ctrlName, "SaveValues")) |
---|
4090 | NVAR SelectedRow=root:Packages:SamplePlateSetup:SelectedRow |
---|
4091 | NVAR SampleThickness=root:Packages:SamplePlateSetup:SampleThickness |
---|
4092 | SVAR SelectedSampleName=root:Packages:SamplePlateSetup:SelectedSampleName |
---|
4093 | NVAR SampleXRBV=root:Packages:SamplePlateSetup:SampleXRBV |
---|
4094 | NVAR SampleYRBV=root:Packages:SamplePlateSetup:SampleYRBV |
---|
4095 | Wave/T ListWV = root:Packages:SamplePlateSetup:LBCommandWv |
---|
4096 | ListWV[SelectedRow][0] = SelectedSampleName |
---|
4097 | ListWV[SelectedRow][1] = num2str(IN2G_RoundDecimalPlaces(SampleXRBV,3)) |
---|
4098 | ListWV[SelectedRow][2] = num2str(IN2G_RoundDecimalPlaces(SampleYRBV,3)) |
---|
4099 | ListWV[SelectedRow][3] = num2str(IN2G_RoundDecimalPlaces(SampleThickness,3)) |
---|
4100 | NVAR SelectedRow=root:Packages:SamplePlateSetup:SelectedRow |
---|
4101 | IN3S_AddTagToImage(SelectedRow) |
---|
4102 | SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
4103 | WarningForUser = "Saved positions to table" |
---|
4104 | NVAR TableIsSaved = root:Packages:SamplePlateSetup:TableIsSaved |
---|
4105 | TableIsSaved = 0 |
---|
4106 | IN3S_FixSaveButton() |
---|
4107 | IN3S_EstimateRunTime() |
---|
4108 | endif |
---|
4109 | break |
---|
4110 | case -1: // control being killed |
---|
4111 | break |
---|
4112 | endswitch |
---|
4113 | |
---|
4114 | return 0 |
---|
4115 | End |
---|
4116 | //***************************************************************************************************************** |
---|
4117 | //***************************************************************************************************************** |
---|
4118 | //***************************************************************************************************************** |
---|
4119 | Function IN3S_MoveToPositionIfOK() |
---|
4120 | //moves to SX and SY on row change, if OK |
---|
4121 | //root:Packages:SamplePlateSetup:MoveWhenRowChanges = 1 |
---|
4122 | //panel BeamlinePlateSetup exists |
---|
4123 | DoWindow BeamlinePlateSetup |
---|
4124 | if(V_Flag) //exists |
---|
4125 | NVAR ShouldMove=root:Packages:SamplePlateSetup:MoveWhenRowChanges |
---|
4126 | if(ShouldMove) |
---|
4127 | NVAR SampleXTAR=root:Packages:SamplePlateSetup:SampleXTAR |
---|
4128 | NVAR SampleYTAR=root:Packages:SamplePlateSetup:SampleYTAR |
---|
4129 | NVAR TableSX=root:Packages:SamplePlateSetup:SampleXTable |
---|
4130 | NVAR TableSY=root:Packages:SamplePlateSetup:SampleYTable |
---|
4131 | if(numtype(TableSX)==0 && numtype(TableSY)==0) //are these numbers? |
---|
4132 | SampleXTAR = TableSX |
---|
4133 | SampleYTAR = TableSY |
---|
4134 | IN3S_MoveMotorInEpics("SX",TableSX) |
---|
4135 | IN3S_MoveMotorInEpics("SY",TableSY) |
---|
4136 | //SVAR WarningForUser = root:Packages:SamplePlateSetup:WarningForUser |
---|
4137 | //WarningForUser = "Moving to SX and SY position read from Table" |
---|
4138 | endif |
---|
4139 | endif |
---|
4140 | endif |
---|
4141 | end |
---|
4142 | //***************************************************************************************************************** |
---|
4143 | //************************************************************************************************************ |
---|
4144 | //************************************************************************************************************ |
---|
4145 | |
---|
4146 | static Function IN3S_MoveMotorInEpics(WhichMotor,MovePosition) |
---|
4147 | string WhichMotor //SX or SY |
---|
4148 | variable MovePosition |
---|
4149 | //avoid moving if instrument is running, 9idcLAX:dataColInProgress = 1 |
---|
4150 | variable InstrumentUsed=0 |
---|
4151 | #if(exists("pvOpen")==4) |
---|
4152 | InstrumentUsed = IN3S_GetPVVariableValue("9idcLAX:dataColInProgress") |
---|
4153 | if(InstrumentUsed) |
---|
4154 | abort "Instrument is collecting data, cannot move motors" |
---|
4155 | else |
---|
4156 | if(stringMatch(WhichMotor,"SX")) |
---|
4157 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m1.VAL", MovePosition) |
---|
4158 | elseif(stringMatch(WhichMotor,"SY")) |
---|
4159 | IN3S_PutEpicsPv("9idcLAX:m58:c2:m2.VAL", MovePosition) |
---|
4160 | endif |
---|
4161 | endif |
---|
4162 | #else |
---|
4163 | print "Could not move motors, no epics installed" |
---|
4164 | #endif |
---|
4165 | end |
---|
4166 | //***************************************************************************************************************** |
---|
4167 | //***************************************************************************************************************** |
---|
4168 | //************************************************************************************************************ |
---|
4169 | //************************************************************************************************************ |
---|
4170 | |
---|
4171 | static Function IN3S_PutEpicsPv(PVAddress, target) //note, this waits until motor is done moving... |
---|
4172 | string PVAddress |
---|
4173 | variable target |
---|
4174 | #if(exists("pvOpen")==4) |
---|
4175 | variable sxRBV |
---|
4176 | pvOpen/T=5 sxRBV, PVAddress // /T is timeout, should wait only this timeout. |
---|
4177 | pvPutNumber/Q sxRBV, target // /Q returns immediately, else waits until completion. |
---|
4178 | pvClose sxRBV |
---|
4179 | #endif |
---|
4180 | end |
---|
4181 | |
---|
4182 | //***************************************************************************************************************** |
---|
4183 | //***************************************************************************************************************** |
---|
4184 | |
---|
4185 | // E N D B E A M L I N E S U R V E Y C O D E |
---|
4186 | |
---|
4187 | //***************************************************************************************************************** |
---|
4188 | //***************************************************************************************************************** |
---|
4189 | |
---|
4190 | //Function IN3S_ExportHookFunction(Command, SampleName,SX, SY, Thickness, MD) |
---|
4191 | // string Command, SampleName,SX, SY, Thickness, MD |
---|
4192 | // //this hook function will modify output of the command file for given line. This needs to be cutomized for specific need. |
---|
4193 | // SVAR nbl=root:Packages:SamplePlateSetup:NotebookName |
---|
4194 | // |
---|
4195 | // //in this case it will write each command in notebook multiple times, in original position and then +/- 1mm in sx and sy |
---|
4196 | // //center |
---|
4197 | // Notebook $nbl text=" "+Command+" "+SX+" "+SY+" "+Thickness+" \""+SampleName+"\" \r" |
---|
4198 | // //and now the variations, only if Sample Name is NOT Blank or Empty |
---|
4199 | // if(!StringMatch(SampleName, "*Blank*")&&!StringMatch(SampleName, "*Empty*")) |
---|
4200 | // string TempStr |
---|
4201 | // TempStr = num2str(str2num(SX)-1) |
---|
4202 | // Notebook $nbl text=" "+Command+" "+TempStr+" "+SY+" "+Thickness+" \""+SampleName+"_R"+"\" \r" |
---|
4203 | // TempStr = num2str(str2num(SX)+1) |
---|
4204 | // Notebook $nbl text=" "+Command+" "+TempStr+" "+SY+" "+Thickness+" \""+SampleName+"_L"+"\" \r" |
---|
4205 | // TempStr = num2str(str2num(SY)-1) |
---|
4206 | // Notebook $nbl text=" "+Command+" "+SX+" "+TempStr+" "+Thickness+" \""+SampleName+"_B"+"\" \r" |
---|
4207 | // TempStr = num2str(str2num(SY)+1) |
---|
4208 | // Notebook $nbl text=" "+Command+" "+SX+" "+TempStr+" "+Thickness+" \""+SampleName+"_T"+"\" \r" |
---|
4209 | // endif |
---|
4210 | //end |
---|