Rev 146 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
146 | f9daq | 1 | #include "../include/sipmscan.h" |
2 | #include "../include/workstation.h" |
||
3 | |||
4 | #include <stdio.h> |
||
5 | #include <stdlib.h> |
||
6 | |||
7 | // Title labels for each of the frame |
||
8 | void TGAppMainFrame::TGTitleLabel(TGWindow *parent, TGHorizontalFrame *fTitle, const char *title, Pixel_t foreColor, Pixel_t backColor, const char *font) |
||
9 | { |
||
10 | TGLabel *lab = new TGLabel(fTitle, title); |
||
11 | lab->ChangeBackground(backColor); |
||
12 | lab->SetTextColor(foreColor); |
||
13 | lab->SetTextFont(font); |
||
14 | fTitle->AddFrame(lab, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY) ); |
||
15 | fTitle->ChangeBackground(backColor); |
||
16 | } |
||
17 | |||
18 | // Splitter to a set number of frames |
||
19 | bool TGAppMainFrame::TGSplitter(TGWindow *parent, const char *majorSplit, int *horSplits, int *vertSplits, const char *frameTitles[512], TGCompositeFrame **frames, int *frameWidth, int *frameHeight) |
||
20 | { |
||
21 | // Number of Frames that are not the ones we supply |
||
22 | int nrofmed = 0; |
||
23 | // Number of all splits in the minor direction |
||
24 | int minorSplits = 0; |
||
25 | int k = 0; |
||
26 | |||
27 | // Title frame height |
||
28 | int titHeight = 25; |
||
29 | |||
30 | if(strcmp("horizontal",majorSplit) == 0) |
||
31 | { |
||
32 | fLayout[idtotal] = new TGCompositeFrame(parent, 300, 300, kHorizontalFrame); |
||
33 | for(int i = 0; i <= horSplits[0]; i++) |
||
34 | { |
||
35 | minorSplits += vertSplits[i]; |
||
36 | if(vertSplits[i] > 0) |
||
37 | nrofmed++; |
||
38 | } |
||
39 | |||
40 | if(DBGSIG > 1) printf("TGSplitter(): Number of intermediate frames = %d, all minor splits = %d\n", nrofmed, minorSplits); |
||
41 | |||
42 | |||
43 | TGCompositeFrame *fInter[nrofmed]; |
||
44 | TGVSplitter *vsplit[horSplits[0]]; |
||
45 | TGHSplitter *hsplit[minorSplits]; |
||
46 | |||
47 | nrofmed = 0; |
||
48 | |||
49 | for(int i = 0; i <= horSplits[0]; i++) |
||
50 | { |
||
51 | if(DBGSIG > 1) printf("TGSplitter(): i = %d\n",i); |
||
52 | for(int j = 0; j <= vertSplits[i]; j++) |
||
53 | { |
||
54 | if(DBGSIG > 1) printf("TGSplitter(): j = %d, vertSplits = %d\n",j, vertSplits[i]); |
||
55 | if( vertSplits[i] > 0 ) |
||
56 | { |
||
57 | if(j == 0) |
||
58 | { |
||
59 | if(DBGSIG > 1) printf("TGSplitter(): vertSplits - j = %d (nrofmed = %d)\n", (vertSplits[i]-j), nrofmed); |
||
60 | if(i > 0) |
||
61 | { |
||
62 | fInter[nrofmed] = new TGCompositeFrame(fLayout[idtotal], frameWidth[k], 200, kVerticalFrame); |
||
63 | fLayout[idtotal]->AddFrame(fInter[nrofmed], new TGLayoutHints(kLHintsExpandY | kLHintsExpandX)); |
||
64 | } |
||
65 | else |
||
66 | { |
||
67 | fInter[nrofmed] = new TGCompositeFrame(fLayout[idtotal], frameWidth[k], 200, kVerticalFrame | kFixedWidth); |
||
68 | fLayout[idtotal]->AddFrame(fInter[nrofmed], new TGLayoutHints(kLHintsExpandY)); |
||
69 | } |
||
70 | } |
||
71 | |||
72 | if( (vertSplits[i]-j) > 0) |
||
73 | { |
||
74 | if(DBGSIG > 1) printf("TGSplitter(): Step 0a (k = %d)\n", k); |
||
75 | |||
76 | frames[k] = new TGCompositeFrame(fInter[nrofmed], frameWidth[k], frameHeight[k], kVerticalFrame | kFixedHeight | kSunkenFrame); |
||
77 | fTitle = new TGHorizontalFrame(frames[k], 100, titHeight, kFixedHeight | kSunkenFrame); |
||
78 | TGTitleLabel(frames[k], fTitle, frameTitles[k], (Pixel_t)FORECOLOR, (Pixel_t)BACKCOLOR, FONT); |
||
79 | frames[k]->AddFrame(fTitle, new TGLayoutHints(kLHintsExpandX | kLHintsTop) ); |
||
80 | fInter[nrofmed]->AddFrame(frames[k], new TGLayoutHints(kLHintsExpandX)); |
||
81 | |||
82 | if(DBGSIG > 1) printf("TGSplitter(): Step 1a\n"); |
||
83 | |||
84 | hsplit[nrofmed] = new TGHSplitter(fInter[nrofmed]); |
||
85 | hsplit[nrofmed]->SetFrame(frames[k], kTRUE); |
||
86 | fInter[nrofmed]->AddFrame(hsplit[nrofmed], new TGLayoutHints(kLHintsExpandX)); |
||
87 | |||
88 | if(DBGSIG > 1) printf("TGSplitter(): Step 2a\n"); |
||
89 | |||
90 | k++; |
||
91 | } |
||
92 | else |
||
93 | { |
||
94 | if(DBGSIG > 1) printf("TGSplitter(): Step 0b (k = %d)\n", k); |
||
95 | |||
96 | frames[k] = new TGCompositeFrame(fInter[nrofmed], frameWidth[k], frameHeight[k], kVerticalFrame | kSunkenFrame); |
||
97 | fTitle = new TGHorizontalFrame(frames[k], 100, titHeight, kFixedHeight | kSunkenFrame); |
||
98 | TGTitleLabel(frames[k], fTitle, frameTitles[k], (Pixel_t)FORECOLOR, (Pixel_t)BACKCOLOR, FONT); |
||
99 | frames[k]->AddFrame(fTitle, new TGLayoutHints(kLHintsExpandX | kLHintsTop) ); |
||
100 | fInter[nrofmed]->AddFrame(frames[k], new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); |
||
101 | |||
102 | if(DBGSIG > 1) printf("TGSplitter(): Step 1b\n"); |
||
103 | k++; |
||
104 | } |
||
105 | } |
||
106 | else |
||
107 | { |
||
108 | if(DBGSIG > 1) printf("TGSplitter(): Step 0c (k = %d)\n", k); |
||
109 | |||
110 | frames[k] = new TGCompositeFrame(fLayout[idtotal], frameWidth[k], frameHeight[k], kVerticalFrame | kSunkenFrame); |
||
111 | fTitle = new TGHorizontalFrame(frames[k], 100, titHeight, kFixedHeight | kSunkenFrame); |
||
112 | TGTitleLabel(frames[k], fTitle, frameTitles[k], (Pixel_t)FORECOLOR, (Pixel_t)BACKCOLOR, FONT); |
||
113 | frames[k]->AddFrame(fTitle, new TGLayoutHints(kLHintsExpandX | kLHintsTop) ); |
||
114 | fLayout[idtotal]->AddFrame(frames[k], new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); |
||
115 | |||
116 | if(DBGSIG > 1) printf("TGSplitter(): Step 1c\n"); |
||
117 | k++; |
||
118 | } |
||
119 | } |
||
120 | |||
121 | if(DBGSIG > 1) printf("TGSplitter(): i = %d, horSplits = %d\n", i, horSplits[0]); |
||
122 | |||
123 | if(i != horSplits[0]) |
||
124 | { |
||
125 | vsplit[i] = new TGVSplitter(fLayout[idtotal]); |
||
126 | if( vertSplits[i] > 0 ) |
||
127 | vsplit[i]->SetFrame(fInter[nrofmed], kTRUE); |
||
128 | else |
||
129 | vsplit[i]->SetFrame(frames[k], kTRUE); |
||
130 | fLayout[idtotal]->AddFrame(vsplit[nrofmed], new TGLayoutHints(kLHintsExpandY)); |
||
131 | } |
||
132 | |||
133 | nrofmed++; |
||
134 | } |
||
135 | |||
136 | if(DBGSIG > 1) printf("TGSplitter(): Finished horizontal layout\n"); |
||
137 | } |
||
138 | else if(strcmp("vertical",majorSplit) == 0) |
||
139 | { |
||
140 | /* for(int i = 0; i <= vertSplits[0]; i++) |
||
141 | { |
||
142 | minorSplits += horSplits[i]; |
||
143 | if(horSplits[i] > 0) |
||
144 | nrofmed++; |
||
145 | } |
||
146 | |||
147 | printf("Number of intermediate frames = %d\n", nrofmed); |
||
148 | |||
149 | TGCompositeFrame *fInter[nrofmed];*/ |
||
150 | } |
||
151 | else |
||
152 | return false; |
||
153 | |||
154 | return true; |
||
155 | } |
||
156 | |||
157 | // Function for setting up the layout |
||
158 | void TGAppMainFrame::LayoutRead(int nrframes, int *w, int *h) |
||
159 | { |
||
160 | int WM, HM, k = 0, start = 0; |
||
161 | |||
162 | std::ifstream ilayout; |
||
163 | |||
164 | char *cTemp, *cTemp2, readTemp[1024]; |
||
165 | cTemp = new char[512]; |
||
166 | cTemp2 = new char[512]; |
||
167 | sprintf(cTemp, "%s/layout/selected_layout.txt", rootdir); |
||
168 | ilayout.open(cTemp, std::ifstream::in); |
||
169 | if(ilayout.is_open()) |
||
170 | { |
||
171 | ilayout >> cTemp2; |
||
172 | } |
||
173 | ilayout.close(); |
||
174 | printf("Loaded layout file is: %s\n", cTemp2); |
||
175 | |||
176 | sprintf(cTemp, "%s/layout/%s", rootdir, cTemp2); |
||
177 | ilayout.open(cTemp, std::ifstream::in); |
||
178 | if(ilayout.is_open()) |
||
179 | { |
||
180 | while(1) |
||
181 | { |
||
182 | if(ilayout.peek() == '#') |
||
183 | { |
||
184 | ilayout.getline(readTemp, 1024, '\n'); |
||
185 | if(DBGSIG > 1) printf("LayoutRead(): readTemp = %s\n", readTemp); |
||
186 | } |
||
187 | else if(ilayout.peek() == '\n') |
||
188 | ilayout.ignore(1, '\n'); |
||
189 | else |
||
190 | { |
||
191 | if(start == 0) |
||
192 | { |
||
193 | ilayout >> WM >> HM >> readTemp; |
||
194 | ilayout.ignore(1, '\n'); |
||
195 | start++; |
||
196 | if(DBGSIG > 1) printf("LayoutRead(): W = %d, H = %d, Name = %s\n", WM, HM, readTemp); |
||
197 | } |
||
198 | else |
||
199 | { |
||
200 | ilayout >> w[k] >> h[k] >> readTemp; |
||
201 | ilayout.ignore(1, '\n'); |
||
202 | if(DBGSIG > 1) printf("LayoutRead(): w[%d] = %d, h[%d] = %d, Name = %s\n", k, w[k], k, h[k], readTemp); |
||
203 | k++; |
||
204 | |||
205 | if(k == nrframes) break; |
||
206 | } |
||
207 | } |
||
208 | } |
||
209 | } |
||
210 | |||
211 | ilayout.close(); |
||
212 | delete[] cTemp; |
||
213 | delete[] cTemp2; |
||
214 | } |
||
215 | |||
216 | // Function for saving the current layout |
||
217 | void TGAppMainFrame::LayoutSave() |
||
218 | { |
||
219 | TGFileInfo file_info; |
||
220 | const char *filetypes[] = {"Layout","*.layout",0,0}; |
||
221 | char *cTemp; |
||
222 | file_info.fFileTypes = filetypes; |
||
223 | cTemp = new char[1024]; |
||
224 | sprintf(cTemp, "%s/layout", rootdir); |
||
225 | file_info.fIniDir = StrDup(cTemp); |
||
226 | new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDSave, &file_info); |
||
227 | delete[] cTemp; |
||
228 | |||
229 | if(file_info.fFilename != NULL) |
||
230 | { |
||
231 | if(DBGSIG) printf("LayoutSave(): The layout save name: %s\n", file_info.fFilename); |
||
232 | |||
233 | std::ofstream olayout; |
||
234 | |||
235 | olayout.open(file_info.fFilename, std::ofstream::out); |
||
236 | if(olayout.is_open()) |
||
237 | { |
||
238 | olayout << "# Whole window width and height" << std::endl; |
||
239 | olayout << fMain->GetWidth() << "\t" << fMain->GetHeight() << "\tmain" << std::endl << std::endl; |
||
240 | olayout << "# Measurement subwindows width and height" << std::endl; |
||
241 | for(int i = 0; i < measwin; i++) |
||
242 | olayout << measLayout[i]->GetWidth() << "\t" << measLayout[i]->GetHeight() << "\tmeasurementwindow" << i << std::endl; |
||
243 | olayout << std::endl; |
||
244 | olayout << "# Analysis subwindows width and height" << std::endl; |
||
245 | for(int i = 0; i < analysiswin; i++) |
||
246 | olayout << analysisLayout[i]->GetWidth() << "\t" << analysisLayout[i]->GetHeight() << "\tanalysiswindow" << i << std::endl; |
||
247 | } |
||
248 | else |
||
249 | printf("Error! Save file can not be opened (please do not use default.layout since it is write protected).\n"); |
||
250 | olayout.close(); |
||
251 | } |
||
252 | } |
||
253 | |||
254 | // Function for setting a user created layout |
||
255 | void TGAppMainFrame::LayoutSet() |
||
256 | { |
||
257 | TGFileInfo file_info; |
||
258 | int ret = 0; |
||
259 | const char *filetypes[] = {"Layout","*.layout",0,0}; |
||
260 | char *cTemp, *layoutdir; |
||
261 | file_info.fFileTypes = filetypes; |
||
262 | layoutdir = new char[1024]; |
||
263 | sprintf(layoutdir, "%s/layout", rootdir); |
||
264 | file_info.fIniDir = StrDup(layoutdir); |
||
265 | new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDOpen, &file_info); |
||
266 | |||
267 | if(file_info.fFilename != NULL) |
||
268 | { |
||
269 | if(DBGSIG) printf("LayoutSet(): The layout save name: %s\n", file_info.fFilename); |
||
270 | cTemp = new char[512]; |
||
271 | remove_before_last(file_info.fFilename, '/', cTemp); |
||
272 | if(DBGSIG) printf("LayoutSet(): New selected layout: %s\n", cTemp); |
||
273 | |||
274 | FILE *fp; |
||
275 | sprintf(layoutdir, "%s/layout/selected_layout.txt", rootdir); |
||
276 | fp = fopen(layoutdir, "w"); |
||
277 | fprintf(fp, "%s", cTemp); |
||
278 | fclose(fp); |
||
279 | |||
280 | sprintf(layoutdir, "Please restart the program to enable the selected layout (%s) for future use.", cTemp); |
||
281 | new TGMsgBox(gClient->GetRoot(), fMain, "Setting new layout", layoutdir, kMBIconAsterisk, kMBOk, &ret); |
||
282 | delete[] cTemp; |
||
283 | } |
||
284 | delete[] layoutdir; |
||
285 | } |
||
286 | |||
173 | f9daq | 287 | // Function for saving all current measurement settings in a file and reopening them on next program open |
288 | void TGAppMainFrame::SaveMeasSettings() |
||
289 | { |
||
290 | char *cTemp; |
||
291 | cTemp = new char[1024]; |
||
292 | sprintf(cTemp, "%s/settings/measurement_settings.txt", rootdir); |
||
293 | |||
294 | std::ofstream osettings; |
||
295 | |||
296 | osettings.open(cTemp, std::ofstream::out); |
||
297 | if(osettings.is_open()) |
||
298 | { |
||
299 | osettings << "# Settings pane" << std::endl; |
||
300 | for(int i = 0; i < 4; i++) |
||
301 | osettings << (int)scansOn->widgetChBox[i]->IsDown() << std::endl; |
||
302 | osettings << vHardlimit->widgetNE[0]->GetNumber() << std::endl; |
||
303 | osettings << NCH->widgetNE[0]->GetNumber() << std::endl; |
||
304 | osettings << posUnits->widgetCB->GetSelected() << std::endl; |
||
305 | osettings << rotUnits->widgetCB->GetSelected() << std::endl; |
||
306 | osettings << oscConnect->widgetTE->GetText() << std::endl; |
||
307 | osettings << laserInfo->widgetTE->GetText() << std::endl; |
||
308 | osettings << chtemp->widgetNE[0]->GetNumber() << std::endl; |
||
309 | osettings << (int)liveDisp->widgetChBox[0]->IsDown() << std::endl; |
||
310 | osettings << std::endl; |
||
311 | |||
312 | osettings << "# Main measurement window" << std::endl; |
||
313 | osettings << vOutCh->widgetCB->GetSelected() << std::endl; |
||
314 | for(int i = 0; i < 2; i++) |
||
315 | osettings << (int)vOutOpt->widgetChBox[i]->IsDown() << std::endl; |
||
316 | osettings << vOutStart->widgetNE[0]->GetNumber() << std::endl; |
||
317 | osettings << vOutStop->widgetNE[0]->GetNumber() << std::endl; |
||
318 | osettings << vOutStep->widgetNE[0]->GetNumber() << std::endl; |
||
319 | |||
320 | osettings << zPosMin->widgetNE[0]->GetNumber() << std::endl; |
||
321 | osettings << zPosMax->widgetNE[0]->GetNumber() << std::endl; |
||
322 | osettings << zPosStep->widgetNE[0]->GetNumber() << std::endl; |
||
323 | osettings << xPosMin->widgetNE[0]->GetNumber() << std::endl; |
||
324 | osettings << xPosMax->widgetNE[0]->GetNumber() << std::endl; |
||
325 | osettings << xPosStep->widgetNE[0]->GetNumber() << std::endl; |
||
326 | osettings << yPosMin->widgetNE[0]->GetNumber() << std::endl; |
||
327 | osettings << yPosMax->widgetNE[0]->GetNumber() << std::endl; |
||
328 | osettings << yPosStep->widgetNE[0]->GetNumber() << std::endl; |
||
329 | |||
330 | osettings << rotPosMin->widgetNE[0]->GetNumber() << std::endl; |
||
331 | osettings << rotPosMax->widgetNE[0]->GetNumber() << std::endl; |
||
332 | osettings << rotPosStep->widgetNE[0]->GetNumber() << std::endl; |
||
333 | |||
334 | osettings << evtNum->widgetNE[0]->GetNumber() << std::endl; |
||
335 | osettings << fileName->widgetTE->GetText() << std::endl; |
||
336 | |||
337 | printf("Saving measurement settings to file.\n"); |
||
338 | } |
||
339 | else |
||
340 | printf("Error! Save file can not be opened.\n"); |
||
341 | osettings.close(); |
||
342 | } |
||
343 | |||
344 | // Function for saving all current analysis settings in a file and reopening them on next program open |
||
345 | void TGAppMainFrame::SaveAnalSettings() |
||
346 | { |
||
347 | char *cTemp; |
||
348 | cTemp = new char[1024]; |
||
349 | sprintf(cTemp, "%s/settings/analysis_settings.txt", rootdir); |
||
350 | |||
351 | std::ofstream osettings; |
||
352 | |||
353 | osettings.open(cTemp, std::ofstream::out); |
||
354 | if(osettings.is_open()) |
||
355 | { |
||
356 | osettings << "# Analysis" << std::endl; |
||
357 | // Integrate spectrum |
||
358 | for(int i = 0; i < 3; i++) |
||
359 | osettings << (int)intSpect->widgetChBox[i]->IsDown() << std::endl; |
||
360 | for(int i = 0; i < 2; i++) |
||
361 | osettings << resol2d->widgetNE[i]->GetNumber() << std::endl; |
||
362 | |||
363 | // Relative PDE |
||
364 | osettings << (int)relPde->widgetChBox[0]->IsDown() << std::endl; |
||
365 | osettings << (int)midPeak->widgetChBox[0]->IsDown() << std::endl; |
||
366 | osettings << zeroAngle->widgetNE[0]->GetNumber() << std::endl; |
||
367 | |||
368 | // Breakdown voltage |
||
369 | osettings << minPeak->widgetNE[0]->GetNumber() << std::endl; |
||
370 | osettings << peakSepCalc->widgetNE[0]->GetNumber() << std::endl; |
||
371 | |||
372 | // Surface scan |
||
373 | for(int i = 0; i < 2; i++) |
||
374 | osettings << (int)surfScanOpt->widgetChBox[i]->IsDown() << std::endl; |
||
375 | for(int i = 0; i < 2; i++) |
||
376 | osettings << resolSurf->widgetNE[i]->GetNumber() << std::endl; |
||
377 | |||
378 | // Fitting |
||
379 | osettings << fitSigma->widgetNE[0]->GetNumber() << std::endl; |
||
380 | osettings << fitTresh->widgetNE[0]->GetNumber() << std::endl; |
||
381 | osettings << fitInter->widgetNE[0]->GetNumber() << std::endl; |
||
382 | osettings << adcOffset->widgetNE[0]->GetNumber() << std::endl; |
||
383 | osettings << accError->widgetNE[0]->GetNumber() << std::endl; |
||
384 | osettings << pedesLow->widgetNE[0]->GetNumber() << std::endl; |
||
385 | for(int i = 0; i < 2; i++) |
||
386 | osettings << (int)fitChecks->widgetChBox[i]->IsDown() << std::endl; |
||
387 | osettings << std::endl; |
||
388 | |||
389 | osettings << "# Histogram controls" << std::endl; |
||
390 | for(int i = 0; i < 2; i++) |
||
391 | osettings << adcRange->widgetNE[i]->GetNumber() << std::endl; |
||
392 | for(int i = 0; i < 2; i++) |
||
393 | osettings << tdcRange->widgetNE[i]->GetNumber() << std::endl; |
||
394 | for(int i = 0; i < 2; i++) |
||
395 | osettings << yRange->widgetNE[i]->GetNumber() << std::endl; |
||
396 | osettings << selectCh->widgetNE[0]->GetNumber() << std::endl; |
||
397 | for(int i = 0 ; i < 2; i++) |
||
398 | osettings << (int)histOpt->widgetChBox[i]->IsDown() << std::endl; |
||
399 | osettings << posUnitsPlot->widgetCB->GetSelected() << std::endl; |
||
400 | |||
401 | printf("Saving analysis settings to file.\n"); |
||
402 | } |
||
403 | else |
||
404 | printf("Error! Save file can not be opened.\n"); |
||
405 | osettings.close(); |
||
406 | } |
||
407 | |||
408 | // Function for getting all measurement settings from a file |
||
409 | void TGAppMainFrame::GetMeasSettings() |
||
410 | { |
||
411 | char *cTemp, readTemp[1024]; |
||
412 | cTemp = new char[1024]; |
||
413 | sprintf(cTemp, "%s/settings/measurement_settings.txt", rootdir); |
||
414 | |||
415 | int iTemp, k = 0; |
||
416 | double dTemp; |
||
417 | |||
418 | std::ifstream isettings; |
||
419 | |||
420 | isettings.open(cTemp, std::ifstream::in); |
||
421 | if(isettings.is_open()) |
||
422 | { |
||
423 | printf("Opening measurement settings from file.\n"); |
||
424 | |||
425 | while(1) |
||
426 | { |
||
427 | if(isettings.peek() == '#') |
||
428 | { |
||
429 | isettings.getline(readTemp, 1024, '\n'); |
||
430 | if(DBGSIG > 1) printf("GetMeasSettings(): readTemp = %s\n", readTemp); |
||
431 | } |
||
432 | else if(isettings.peek() == '\n') |
||
433 | isettings.ignore(1, '\n'); |
||
434 | else |
||
435 | { |
||
436 | if(k == 0) |
||
437 | { |
||
438 | // Scan settings |
||
439 | for(int i = 0; i < 4; i++) |
||
440 | { |
||
441 | isettings >> iTemp; |
||
442 | isettings.ignore(1, '\n'); |
||
443 | if(iTemp == 0) scansOn->widgetChBox[i]->SetState(kButtonUp); |
||
444 | else if(iTemp == 1) scansOn->widgetChBox[i]->SetState(kButtonDown); |
||
445 | } |
||
446 | // Hard voltage limit |
||
447 | isettings >> dTemp; |
||
448 | isettings.ignore(1, '\n'); |
||
449 | vHardlimit->widgetNE[0]->SetNumber(dTemp); |
||
450 | // Number of channels |
||
451 | isettings >> iTemp; |
||
452 | isettings.ignore(1, '\n'); |
||
453 | NCH->widgetNE[0]->SetNumber(iTemp); |
||
454 | // Position units |
||
455 | isettings >> iTemp; |
||
456 | isettings.ignore(1, '\n'); |
||
457 | posUnits->widgetCB->Select(iTemp); |
||
458 | // Rotation units |
||
459 | isettings >> iTemp; |
||
460 | isettings.ignore(1, '\n'); |
||
461 | rotUnits->widgetCB->Select(iTemp); |
||
462 | // Oscilloscope IP address |
||
463 | isettings.getline(readTemp, 1024, '\n'); |
||
464 | oscConnect->widgetTE->SetText(readTemp); |
||
465 | // Laser info |
||
466 | isettings.getline(readTemp, 1024, '\n'); |
||
467 | laserInfo->widgetTE->SetText(readTemp); |
||
468 | // Chamber temperature |
||
469 | isettings >> dTemp; |
||
470 | isettings.ignore(1, '\n'); |
||
471 | chtemp->widgetNE[0]->SetNumber(dTemp); |
||
472 | // Live display |
||
473 | isettings >> iTemp; |
||
474 | isettings.ignore(1, '\n'); |
||
475 | if(iTemp == 0) liveDisp->widgetChBox[0]->SetState(kButtonUp); |
||
476 | else if(iTemp == 1) liveDisp->widgetChBox[0]->SetState(kButtonDown); |
||
477 | |||
478 | k++; |
||
479 | } |
||
480 | else if(k == 1) |
||
481 | { |
||
482 | // Voltage supply channel |
||
483 | isettings >> iTemp; |
||
484 | isettings.ignore(1, '\n'); |
||
485 | vOutCh->widgetCB->Select(iTemp); |
||
486 | // Voltage supply options |
||
487 | for(int i = 0; i < 2; i++) |
||
488 | { |
||
489 | isettings >> iTemp; |
||
490 | isettings.ignore(1, '\n'); |
||
491 | if(iTemp == 0) vOutOpt->widgetChBox[i]->SetState(kButtonUp); |
||
492 | else if(iTemp == 1) vOutOpt->widgetChBox[i]->SetState(kButtonDown); |
||
493 | } |
||
494 | // Voltage supply min, max and step |
||
495 | isettings >> dTemp; |
||
496 | isettings.ignore(1, '\n'); |
||
497 | vOutStart->widgetNE[0]->SetNumber(dTemp); |
||
498 | isettings >> dTemp; |
||
499 | isettings.ignore(1, '\n'); |
||
500 | vOutStop->widgetNE[0]->SetNumber(dTemp); |
||
501 | isettings >> dTemp; |
||
502 | isettings.ignore(1, '\n'); |
||
503 | vOutStep->widgetNE[0]->SetNumber(dTemp); |
||
504 | // Z axis scan min, max and step |
||
505 | isettings >> dTemp; |
||
506 | isettings.ignore(1, '\n'); |
||
507 | zPosMin->widgetNE[0]->SetNumber(dTemp); |
||
508 | isettings >> dTemp; |
||
509 | isettings.ignore(1, '\n'); |
||
510 | zPosMax->widgetNE[0]->SetNumber(dTemp); |
||
511 | isettings >> dTemp; |
||
512 | isettings.ignore(1, '\n'); |
||
513 | zPosStep->widgetNE[0]->SetNumber(dTemp); |
||
514 | // X axis scan min, max and step |
||
515 | isettings >> dTemp; |
||
516 | isettings.ignore(1, '\n'); |
||
517 | xPosMin->widgetNE[0]->SetNumber(dTemp); |
||
518 | isettings >> dTemp; |
||
519 | isettings.ignore(1, '\n'); |
||
520 | xPosMax->widgetNE[0]->SetNumber(dTemp); |
||
521 | isettings >> dTemp; |
||
522 | isettings.ignore(1, '\n'); |
||
523 | xPosStep->widgetNE[0]->SetNumber(dTemp); |
||
524 | // Y axis scan min, max and step |
||
525 | isettings >> dTemp; |
||
526 | isettings.ignore(1, '\n'); |
||
527 | yPosMin->widgetNE[0]->SetNumber(dTemp); |
||
528 | isettings >> dTemp; |
||
529 | isettings.ignore(1, '\n'); |
||
530 | yPosMax->widgetNE[0]->SetNumber(dTemp); |
||
531 | isettings >> dTemp; |
||
532 | isettings.ignore(1, '\n'); |
||
533 | yPosStep->widgetNE[0]->SetNumber(dTemp); |
||
534 | // Rotation min, max and step |
||
535 | isettings >> dTemp; |
||
536 | isettings.ignore(1, '\n'); |
||
537 | rotPosMin->widgetNE[0]->SetNumber(dTemp); |
||
538 | isettings >> dTemp; |
||
539 | isettings.ignore(1, '\n'); |
||
540 | rotPosMax->widgetNE[0]->SetNumber(dTemp); |
||
541 | isettings >> dTemp; |
||
542 | isettings.ignore(1, '\n'); |
||
543 | rotPosStep->widgetNE[0]->SetNumber(dTemp); |
||
544 | // Number of events |
||
545 | isettings >> iTemp; |
||
546 | isettings.ignore(1, '\n'); |
||
547 | evtNum->widgetNE[0]->SetNumber(iTemp); |
||
548 | // Save filename |
||
549 | isettings.getline(readTemp, 1024, '\n'); |
||
550 | fileName->widgetTE->SetText(readTemp); |
||
551 | |||
552 | k++; |
||
553 | } |
||
554 | else |
||
555 | break; |
||
556 | } |
||
557 | } |
||
558 | } |
||
559 | else |
||
560 | printf("Error! Measurement settings file can not be opened. Using defaults.\n"); |
||
561 | } |
||
562 | |||
563 | // Function for getting all analysis settings from a file |
||
564 | void TGAppMainFrame::GetAnalSettings() |
||
565 | { |
||
566 | char *cTemp, readTemp[1024]; |
||
567 | cTemp = new char[1024]; |
||
568 | sprintf(cTemp, "%s/settings/analysis_settings.txt", rootdir); |
||
569 | |||
570 | int iTemp, k = 0; |
||
571 | double dTemp; |
||
572 | |||
573 | std::ifstream isettings; |
||
574 | |||
575 | isettings.open(cTemp, std::ifstream::in); |
||
576 | if(isettings.is_open()) |
||
577 | { |
||
578 | printf("Opening analysis settings from file.\n"); |
||
579 | |||
580 | while(1) |
||
581 | { |
||
582 | if(isettings.peek() == '#') |
||
583 | { |
||
584 | isettings.getline(readTemp, 1024, '\n'); |
||
585 | if(DBGSIG > 1) printf("GetAnalSettings(): readTemp = %s\n", readTemp); |
||
586 | } |
||
587 | else if(isettings.peek() == '\n') |
||
588 | isettings.ignore(1, '\n'); |
||
589 | else |
||
590 | { |
||
591 | if(k == 0) |
||
592 | { |
||
593 | // Integrate spectrum options |
||
594 | for(int i = 0; i < 3; i++) |
||
595 | { |
||
596 | isettings >> iTemp; |
||
597 | isettings.ignore(1, '\n'); |
||
598 | if(iTemp == 0) intSpect->widgetChBox[i]->SetState(kButtonUp); |
||
599 | else if(iTemp == 1) intSpect->widgetChBox[i]->SetState(kButtonDown); |
||
600 | } |
||
601 | // Integrate spectrum 2D resolution |
||
602 | for(int i = 0; i < 2; i++) |
||
603 | { |
||
604 | isettings >> iTemp; |
||
605 | isettings.ignore(1, '\n'); |
||
606 | resol2d->widgetNE[i]->SetNumber(iTemp); |
||
607 | } |
||
608 | // Relative PDE normalization |
||
609 | isettings >> iTemp; |
||
610 | isettings.ignore(1, '\n'); |
||
611 | if(iTemp == 0) relPde->widgetChBox[0]->SetState(kButtonUp); |
||
612 | else if(iTemp == 1) relPde->widgetChBox[0]->SetState(kButtonDown); |
||
613 | // Relative PDE middle peak |
||
614 | isettings >> iTemp; |
||
615 | isettings.ignore(1, '\n'); |
||
616 | if(iTemp == 0) midPeak->widgetChBox[0]->SetState(kButtonUp); |
||
617 | else if(iTemp == 1) midPeak->widgetChBox[0]->SetState(kButtonDown); |
||
618 | // Relative PDE zero angle setting |
||
619 | isettings >> dTemp; |
||
620 | isettings.ignore(1, '\n'); |
||
621 | zeroAngle->widgetNE[0]->SetNumber(dTemp); |
||
622 | // Breakdown voltage minimum number of detected peaks |
||
623 | isettings >> iTemp; |
||
624 | isettings.ignore(1, '\n'); |
||
625 | minPeak->widgetNE[0]->SetNumber(iTemp); |
||
626 | // Breakdown voltage separation calculation |
||
627 | isettings >> iTemp; |
||
628 | isettings.ignore(1, '\n'); |
||
629 | peakSepCalc->widgetNE[0]->SetNumber(iTemp); |
||
630 | // Surface scan options |
||
631 | for(int i = 0; i < 2; i++) |
||
632 | { |
||
633 | isettings >> iTemp; |
||
634 | isettings.ignore(1, '\n'); |
||
635 | if(iTemp == 0) surfScanOpt->widgetChBox[i]->SetState(kButtonUp); |
||
636 | else if(iTemp == 1) surfScanOpt->widgetChBox[i]->SetState(kButtonDown); |
||
637 | } |
||
638 | // Surface scan 2D resolution |
||
639 | for(int i = 0; i < 2; i++) |
||
640 | { |
||
641 | isettings >> iTemp; |
||
642 | isettings.ignore(1, '\n'); |
||
643 | resolSurf->widgetNE[i]->SetNumber(iTemp); |
||
644 | } |
||
645 | // Fitting - sigma |
||
646 | isettings >> dTemp; |
||
647 | isettings.ignore(1, '\n'); |
||
648 | fitSigma->widgetNE[0]->SetNumber(dTemp); |
||
649 | // Fitting - S/N ratio |
||
650 | isettings >> dTemp; |
||
651 | isettings.ignore(1, '\n'); |
||
652 | fitTresh->widgetNE[0]->SetNumber(dTemp); |
||
653 | // Fitting - interpolation |
||
654 | isettings >> iTemp; |
||
655 | isettings.ignore(1, '\n'); |
||
656 | fitInter->widgetNE[0]->SetNumber(iTemp); |
||
657 | // Fitting - ADC offset |
||
658 | isettings >> dTemp; |
||
659 | isettings.ignore(1, '\n'); |
||
660 | adcOffset->widgetNE[0]->SetNumber(dTemp); |
||
661 | // Fitting - Acceptable error |
||
662 | isettings >> dTemp; |
||
663 | isettings.ignore(1, '\n'); |
||
664 | accError->widgetNE[0]->SetNumber(dTemp); |
||
665 | // Fitting - Pedestal lower limit |
||
666 | isettings >> dTemp; |
||
667 | isettings.ignore(1, '\n'); |
||
668 | pedesLow->widgetNE[0]->SetNumber(dTemp); |
||
669 | // Fitting - settings |
||
670 | for(int i = 0; i < 2; i++) |
||
671 | { |
||
672 | isettings >> iTemp; |
||
673 | isettings.ignore(1, '\n'); |
||
674 | if(iTemp == 0) fitChecks->widgetChBox[i]->SetState(kButtonUp); |
||
675 | else if(iTemp == 1) fitChecks->widgetChBox[i]->SetState(kButtonDown); |
||
676 | } |
||
677 | |||
678 | k++; |
||
679 | } |
||
680 | else if(k == 1) |
||
681 | { |
||
682 | // ADC range |
||
683 | for(int i = 0; i < 2; i++) |
||
684 | { |
||
685 | isettings >> dTemp; |
||
686 | isettings.ignore(1, '\n'); |
||
687 | adcRange->widgetNE[i]->SetNumber(dTemp); |
||
688 | } |
||
689 | // TDC range |
||
690 | for(int i = 0; i < 2; i++) |
||
691 | { |
||
692 | isettings >> dTemp; |
||
693 | isettings.ignore(1, '\n'); |
||
694 | tdcRange->widgetNE[i]->SetNumber(dTemp); |
||
695 | } |
||
696 | // Y axis range |
||
697 | for(int i = 0; i < 2; i++) |
||
698 | { |
||
699 | isettings >> dTemp; |
||
700 | isettings.ignore(1, '\n'); |
||
701 | yRange->widgetNE[i]->SetNumber(dTemp); |
||
702 | } |
||
703 | // Displayed channel |
||
704 | isettings >> iTemp; |
||
705 | isettings.ignore(1, '\n'); |
||
706 | selectCh->widgetNE[0]->SetNumber(iTemp); |
||
707 | // Display options |
||
708 | for(int i = 0; i < 2; i++) |
||
709 | { |
||
710 | isettings >> iTemp; |
||
711 | isettings.ignore(1, '\n'); |
||
712 | if(iTemp == 0) histOpt->widgetChBox[i]->SetState(kButtonUp); |
||
713 | else if(iTemp == 1) histOpt->widgetChBox[i]->SetState(kButtonDown); |
||
714 | } |
||
715 | // Display position units |
||
716 | isettings >> iTemp; |
||
717 | isettings.ignore(1, '\n'); |
||
718 | posUnitsPlot->widgetCB->Select(iTemp); |
||
719 | |||
720 | k++; |
||
721 | } |
||
722 | else |
||
723 | break; |
||
724 | } |
||
725 | } |
||
726 | } |
||
727 | else |
||
728 | printf("Error! Measurement settings file can not be opened. Using defaults.\n"); |
||
729 | } |
||
730 | |||
146 | f9daq | 731 | // Layout function for the main window (width and height) |
732 | void layoutMainWindow(int *w, int *h) |
||
733 | { |
||
734 | std::ifstream ilayout; |
||
735 | |||
736 | char *cTemp, *cTemp2, readTemp[1024]; |
||
737 | cTemp = new char[512]; |
||
738 | cTemp2 = new char[512]; |
||
739 | sprintf(cTemp, "%s/layout/selected_layout.txt", rootdir); |
||
740 | ilayout.open(cTemp, std::ifstream::in); |
||
741 | if(ilayout.is_open()) |
||
742 | { |
||
743 | ilayout >> cTemp2; |
||
744 | } |
||
745 | ilayout.close(); |
||
746 | if(DBGSIG) printf("layoutMainWindow(): Loaded layout file is: %s\n", cTemp2); |
||
747 | |||
748 | sprintf(cTemp, "%s/layout/%s", rootdir, cTemp2); |
||
749 | ilayout.open(cTemp, std::ifstream::in); |
||
750 | if(ilayout.is_open()) |
||
751 | { |
||
752 | while(1) |
||
753 | { |
||
754 | if(ilayout.peek() == '#') |
||
755 | ilayout.getline(readTemp, 1024, '\n'); |
||
756 | else if(ilayout.peek() == '\n') |
||
757 | ilayout.ignore(1, '\n'); |
||
758 | else |
||
759 | { |
||
760 | ilayout >> *w >> *h; |
||
761 | if(DBGSIG > 1) printf("layoutMainWindow(): W = %d, H = %d\n", *w, *h); |
||
762 | break; |
||
763 | } |
||
764 | } |
||
765 | } |
||
766 | |||
767 | ilayout.close(); |
||
768 | delete[] cTemp; |
||
769 | delete[] cTemp2; |
||
770 | } |
||
771 |