-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc.gui.pro
executable file
·180 lines (166 loc) · 5.45 KB
/
func.gui.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
; *******************************************************************
; PolydefixED stress, strain, and texture analysis for experiment in
; energy dispersive geometry
; Copyright (C) 2000-2011 S. Merkel, Universite Lille 1
; http://merkel.zoneo.net/Multifit/
;
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2
; of the License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
;
; *******************************************************************
; ****************************************** changeDir *********************************
PRO changeDir, base, widget
WIDGET_CONTROL, widget, GET_VALUE=start
if (start eq '') then begin
result=dialog_pickfile(/DIRECTORY,title='Select directory', path=GETENV('HOME'), DIALOG_PARENT=base)
endif else begin
result=dialog_pickfile(/DIRECTORY,title='Select directory', path=start, DIALOG_PARENT=base)
endelse
if (result ne '') then begin
directory = result
WIDGET_CONTROL, widget, SET_VALUE=directory
endif
END
; ****************************************** REALLYQUIT *********************************
PRO reallyquit, widget
tmp = DIALOG_MESSAGE("Really quit?", /QUESTION)
if (tmp eq 'No') then return
WIDGET_CONTROL, widget, /DESTROY
end
; ******************************************************************
; Saves and reads basic information about multifit in hidden file for future
; uses
;
function readDefaultFile
common default, defaultdir
defaultdir = GETENV('HOME')
; If we are using UNIX, try to see if we saved a default file
if (STRUPCASE(!VERSION.OS_FAMILY) eq 'UNIX') then begin
default = GETENV('HOME') + "/" + ".polydefixED"
if (file_test(default)) then begin
openr, lun, default, /get_lun
while ~ EOF(lun) do begin
row = ""
readf, lun, row
word = strsplit(row, COUNT=nn, /EXTRACT)
if (nn gt 1) then begin
label = STRUPCASE(word[0])
CASE label OF
"WORK_DIRECTORY:": defaultdir = word[1]
else:
endcase
endif
endwhile
free_lun, lun
endif else begin
openw, lun, default, /get_lun
printf, lun, '# Default information for stresstrain'
free_lun, lun
endelse
endif
return, defaultdir
end
pro setDefaultFileItem, item, value
if (STRUPCASE(!VERSION.OS_FAMILY) eq 'UNIX') then begin
default = GETENV('HOME') + "/" + ".polydefixED"
if (file_test(default)) then begin
str = ""
done = 0
openr, lun, default, /get_lun
while ~ EOF(lun) do begin
row = ""
readf, lun, row
word = strsplit(row, COUNT=nn, /EXTRACT)
label = STRUPCASE(word[0])
CASE label OF
item: begin
str = str + item + " " + value + "|"
done = 1
end
else: str = str + row + "|"
endcase
endwhile
free_lun, lun
if (done eq 0) then str = str + item + " " + value + "|"
; print, "Trying to write " + str
openw, lun, default, /get_lun
word = strsplit(str, "|", COUNT=nn, /EXTRACT)
for i=0,nn-1 do printf, lun, word[i]
free_lun, lun
endif
endif
end
pro setDefaultWorkDir, dir
setDefaultFileItem, "WORK_DIRECTORY:", dir
end
; ****************************************** LOAD_DEFAULTS *********************************
PRO load_defaults
common fonts, titlefont, boldfont, mainfont
; default color palette
OS = strupcase(!VERSION.OS)
OS = strmid(OS,0,3)
if (OS ne 'WIN') then device, true_color=24
device, decomposed=0
loadct, 15
; Directory
test = readDefaultFile()
; Fonts
if (OS ne 'WIN') then begin
mainfont = '-*-courier-medium-r-*-*-12-*-*-*-*-*-*-*'
titlefont = '-*-helvetica-bold-r-*-*-18-*-*-*-*-*-*-*'
boldfont = '-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*'
endif else begin
titlefont = 'helvetica*bold*18'
boldfont = 'helvetica*bold*12'
mainfont = 'helvetica*12'
endelse
end
; ****************************************** READEXPFROMASCII *********************************
FUNCTION readExpFromAscii, base, log
common default, defaultdir
testExp = OBJ_NEW('experimentObject')
testExp->setTmp, 0
result=dialog_pickfile(title='Select experiment file', path=defaultdir, DIALOG_PARENT=base, DEFAULT_EXTENSION='.exp', FILTER=['*.exp','*.txt','*.csv','*.*'], /READ)
if (result ne '') then begin
FDECOMP, result, disk, dir, name, qual, version
logit, log, "Reading experiment data from " + result
defaultdir = disk+dir
setDefaultWorkDir, defaultdir
openr, lun, result, /get_lun
a = testExp->readFromAscii(lun, log)
free_lun, lun
if (a ne 1) then begin
tmp = DIALOG_MESSAGE("Error: " + a, /ERROR)
logit, log, "\tFailed!\n"
return, testExp
endif
testExp->setTmp, 1
logit, log, "\tSuccessful!\n"
return, testExp
endif
return, testExp
END
; ****************************************** LOGIT *********** *********************************
PRO logit, log, txt
row = strsplit(txt, '\\n', /extract, /REGEX, /PRESERVE_NULL)
for i=0, N_ELEMENTS(row)-1 do begin
col = strsplit(row[i], '\\t', /extract, /REGEX, /PRESERVE_NULL )
text = ""
for j=0, N_ELEMENTS(col)-1 do begin
text += col[j]
if (j lt N_ELEMENTS(col)-1) then text += " "
endfor
WIDGET_CONTROL, log, SET_VALUE=text, /APPEND
endfor
END