Updated FSF address in all files. Fixes ticket:51
[debian/gnuradio] / ezdop / src / host / hunter / src / settings.cpp
1 /*
2  Copyright 2006 Johnathan Corgan.
3  
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License version 2
6  as published by the Free Software Foundation.
7  
8  This software is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  GNU General Public License for more details.
12  
13  You should have received a copy of the GNU General Public License
14  along with GNU Radio; see the file COPYING.  If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street,
16  Boston, MA 02110-1301, USA.
17 */
18
19 // Application level includes
20 #include "settings.h"
21
22 HunterSettings::HunterSettings()
23 {
24         cfg = new wxConfig(_T("TransmitterHunter"));
25 }
26
27 HunterSettings::~HunterSettings()
28 {
29         if (cfg) {
30                 cfg->Flush();
31                 delete cfg;
32         }
33 }
34
35 wxSize HunterSettings::GetWindowSize()
36 {
37     long width, height;
38     if (cfg) {
39         cfg->Read(wxT("Application/Width"), &width, 1024);
40         cfg->Read(wxT("Application/Height"), &height, 768);
41     }
42     
43     return wxSize((int)width, (int)height);
44 }
45
46 void HunterSettings::SetWindowSize(wxSize size)
47 {
48     if (cfg) {
49         cfg->Write(wxT("Application/Width"), size.GetWidth());
50         cfg->Write(wxT("Application/Height"), size.GetHeight());
51     }
52 }
53
54 int HunterSettings::GetWindowXPos()
55 {
56         long x;
57         if (cfg)
58                 cfg->Read(wxT("Application/XPos"), &x, 0);
59
60         return (int)x;
61 }
62
63 void HunterSettings::SetWindowXPos(int x)
64 {
65     if (cfg)
66         cfg->Write(wxT("Application/XPos"), (long)x);
67 }
68
69 int HunterSettings::GetWindowYPos()
70 {
71         long y;
72         if (cfg)
73                 cfg->Read(wxT("Application/YPos"), &y, 0);
74
75         return (int)y;
76 }
77
78 void HunterSettings::SetWindowYPos(int y)
79 {
80     if (cfg)
81         cfg->Write(wxT("Application/YPos"), (long)y);
82 }
83
84 bool HunterSettings::GetDopplerAutostart()
85 {
86         bool start = false;
87         if (cfg)
88                 cfg->Read(wxT("Doppler/Autostart"), &start, false);
89
90         return start;
91 }
92
93 void HunterSettings::SetDopplerAutostart(bool start)
94 {
95         if (cfg)
96                 cfg->Write(wxT("Doppler/Autostart"), start);
97 }
98
99 int HunterSettings::GetDopplerFilter()
100 {
101         long filtering;
102         if (cfg)
103                 cfg->Read(wxT("Doppler/FilterLevel"), &filtering, 20);
104
105         return (int)filtering;
106 }
107
108 void HunterSettings::SetDopplerFilter(int level)
109 {
110     if (cfg)
111         cfg->Write(wxT("Doppler/FilterLevel"), (long)level);
112 }
113
114 int HunterSettings::GetDopplerRotation()
115 {
116         long rate;
117         if (cfg)
118                 cfg->Read(wxT("Doppler/Rotation"), &rate, 4);
119
120         return (int)rate;
121 }
122
123 void HunterSettings::SetDopplerRotation(int rate)
124 {
125     if (cfg)
126         cfg->Write(wxT("Doppler/Rotation"), (long)rate);
127 }
128
129 float HunterSettings::GetDopplerCalibration(int rate)
130 {
131         double calibration;
132         wxString key;
133
134         key.Printf(_T("Doppler/Rate%iCalibration"), rate);
135         if (cfg)
136                 cfg->Read(key, &calibration, 0.0);
137         return (float)calibration;
138 }
139
140 void HunterSettings::SetDopplerCalibration(int rate, float offset)
141 {
142         wxString key;
143         key.Printf(_T("Doppler/Rate%iCalibration"), rate);
144         if (cfg)
145                 cfg->Write(key, offset);
146 }
147
148 bool HunterSettings::GetGPSAutostart()
149 {
150         bool start = false;
151         if (cfg)
152                 cfg->Read(wxT("GPS/Autostart"), &start, false);
153
154         return start;
155 }
156
157 void HunterSettings::SetGPSAutostart(bool start)
158 {
159         if (cfg)
160                 cfg->Write(wxT("GPS/Autostart"), start);
161 }
162
163 wxString HunterSettings::GetGPSDeviceName()
164 {
165     wxString name;
166     if (cfg)
167         cfg->Read(wxT("GPS/DeviceName"), &name);
168         
169     return name; 
170 }
171
172 void HunterSettings::SetGPSDeviceName(wxString &name)
173 {
174     if (cfg)
175         cfg->Write(wxT("GPS/DeviceName"), name);
176 }
177
178 bool HunterSettings::GetCalibrationAffectAllRates()
179 {
180         bool val = false;
181         if (cfg)
182                 cfg->Read(wxT("Calibration/AffectAllRates"), &val, false);
183
184         return val;
185 }
186
187 void HunterSettings::SetCalibrationAffectAllRates(bool val)
188 {
189         if (cfg)
190                 cfg->Write(wxT("Calibration/AffectAllRates"), val);
191 }
192
193 double HunterSettings::GetKnownTransmitterLongitude()
194 {
195     double lon;
196     if (cfg)
197         cfg->Read(wxT("KnownTransmitter/Longitude"), &lon);
198         
199     return lon;
200 }
201
202 void HunterSettings::SetKnownTransmitterLongitude(double lon)
203 {
204     if (cfg)
205         cfg->Write(wxT("KnownTransmitter/Longitude"), lon);
206 }
207
208 double HunterSettings::GetKnownTransmitterLatitude()
209 {
210     double lat;
211     if (cfg)
212         cfg->Read(wxT("KnownTransmitter/Latitude"), &lat);
213         
214     return lat;
215 }
216
217 void HunterSettings::SetKnownTransmitterLatitude(double lat)
218 {
219     if (cfg)
220         cfg->Write(wxT("KnownTransmitter/Latitude"), lat);
221 }
222
223 bool HunterSettings::GetUseKnownTransmitter()
224 {
225         bool use = false;
226         if (cfg)
227                 cfg->Read(wxT("KnownTransmitter/Use"), &use, false);
228
229         return use;
230 }
231
232 void HunterSettings::SetUseKnownTransmitter(bool use)
233 {
234     if (cfg)
235         cfg->Write(wxT("KnownTransmitter/Use"), use);
236 }
237
238 int HunterSettings::GetDisplayOrientation()
239 {
240         long x;
241         if (cfg)
242                 cfg->Read(wxT("Display/Orientation"), &x, 0);
243
244         return (int)x;
245 }
246
247 void HunterSettings::SetDisplayOrientation(int orientation)
248 {
249     if (cfg)
250         cfg->Write(wxT("Display/Orientation"), (long)orientation);
251 }
252
253 bool HunterSettings::GetDisplayDoppler()
254 {
255         bool val = false;
256         if (cfg)
257                 cfg->Read(wxT("Display/DopplerPointer"), &val, false);
258
259         return val;
260 }
261
262 void HunterSettings::SetDisplayDoppler(bool val)
263 {
264     if (cfg)
265         cfg->Write(wxT("Display/DopplerPointer"), val);
266 }
267
268 bool HunterSettings::GetDisplayKnown()
269 {
270         bool val = false;
271         if (cfg)
272                 cfg->Read(wxT("Display/KnownPointer"), &val, false);
273
274         return val;
275 }
276
277 void HunterSettings::SetDisplayKnown(bool val)
278 {
279     if (cfg)
280         cfg->Write(wxT("Display/KnownPointer"), val);
281 }
282
283 bool HunterSettings::GetDisplayEstimated()
284 {
285         bool val = false;
286         if (cfg)
287                 cfg->Read(wxT("Display/EstimatedPointer"), &val, false);
288
289         return val;
290 }
291
292 void HunterSettings::SetDisplayEstimated(bool val)
293 {
294     if (cfg)
295         cfg->Write(wxT("Display/EstimatedPointer"), val);
296 }
297
298 wxString HunterSettings::GetWorkingDirectory()
299 {
300     wxString str(_T("."));
301     if (cfg)
302         return cfg->Read(wxT("Application/WorkingDirectory"), str);
303     return str;
304 }
305
306 void HunterSettings::SetWorkingDirectory(const wxString &dir)
307 {
308     if (cfg)
309         cfg->Write(wxT("Application/WorkingDirectory"), dir);
310 }