4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_USER_UNITS_FORMATTER_HPP
25 #define XCSOAR_USER_UNITS_FORMATTER_HPP
27 #include "Units/Unit.hpp"
28 #include "Math/fixed.hpp"
32 class AtmosphericPressure
;
35 * Converts a double-based Altitude into a formatted string
36 * @param Altitude The double-based Altitude
37 * @param buffer buffer string to write to (pointer)
38 * @param size Size of the buffer
40 void FormatUserAltitude(fixed value
, TCHAR
*buffer
,
41 bool include_unit
= true);
44 * Converts a double-based Altitude into a formatted string of the alternate
46 * @param Altitude The double-based Altitude
47 * @param buffer buffer string to write to (pointer)
48 * @param size Size of the buffer
50 void FormatAlternateUserAltitude(fixed value
, TCHAR
*buffer
,
51 bool include_unit
= true);
54 * Converts a double-based Arrival Altitude into a formatted string
55 * @param Altitude The double-based Arrival Altitude
56 * @param buffer buffer string to write to (pointer)
57 * @param size Size of the buffer
59 void FormatRelativeUserAltitude(fixed value
, TCHAR
*buffer
,
60 bool include_unit
= true);
63 * Converts a distance into a formatted string
64 * @param value the distance
65 * @param buffer buffer string to write to (pointer)
66 * @param include_unit include the unit into the string?
67 * @param precision the number of decimal places
69 void FormatUserDistance(fixed value
, TCHAR
*buffer
,
70 bool include_unit
= true, int precision
= 0);
73 * Converts a distance into a formatted string using the smaller version
74 * of the user-defined distance unit (km -> m, nm -> ft, sm -> ft)
75 * @param buffer buffer string to write to (pointer)
76 * @param size Size of the buffer
77 * @param value the distance
78 * @param include_unit include the unit into the string?
79 * @param precision the number of decimal places
80 * @return the unit used for output formatting
82 Unit
FormatSmallUserDistance(TCHAR
*buffer
, fixed value
,
83 bool include_unit
= true, int precision
= 0);
86 * Converts a double-based horizontal Distance into a formatted string
87 * @param Distance The double-based Distance
88 * @param buffer buffer string to write to (pointer)
89 * @param size Size of the buffer
91 Unit
FormatUserDistanceSmart(fixed value
, TCHAR
*buffer
,
92 bool include_unit
= true,
93 fixed small_unit_threshold
= fixed(0),
94 fixed precision_threshold
= fixed(100));
96 Unit
FormatUserMapScale(fixed value
, TCHAR
*buffer
,
97 bool include_unit
= true);
100 * Converts a double-based Speed into a formatted string
101 * @param Speed The double-based Speed
102 * @param buffer buffer string to write to (pointer)
103 * @param size Size of the buffer
104 * @return True if buffer long enough, False otherwise
106 void FormatUserSpeed(fixed value
, TCHAR
*buffer
,
107 bool include_unit
= true, bool Precision
= true);
110 * Converts a double-based Speed into a formatted string
111 * @param Speed The double-based Speed
112 * @param buffer buffer string to write to (pointer)
113 * @param size Size of the buffer
114 * @return True if buffer long enough, False otherwise
116 void FormatUserWindSpeed(fixed value
, TCHAR
*buffer
,
117 bool include_unit
= true, bool Precision
= true);
120 * Convert a speed [m/s] to the user's task speed and format it into
123 * @param value the speed value [m/s]
125 void FormatUserTaskSpeed(fixed value
, TCHAR
*buffer
,
126 bool include_unit
=true, bool precision
=true);
129 * Give the proper format to display the vertical speed
130 * @param include_unit include the unit into the string?
131 * @param include_sign include the sign into the string?
134 const TCHAR
* GetUserVerticalSpeedFormat(bool include_unit
= false,
135 bool include_sign
= true);
138 * Give the basic step for pressure editing
141 fixed
GetUserVerticalSpeedStep();
144 * Converts a double-based vertical Speed into a formatted string
145 * @param Speed The double-based vertical Speed
146 * @param buffer buffer string to write to (pointer)
147 * @param size Size of the buffer
148 * @param include_sign include the sign into the string?
149 * @return True if buffer long enough, False otherwise
151 void FormatUserVerticalSpeed(fixed value
, TCHAR
*buffer
,
152 bool include_unit
= true, bool include_sign
= true);
155 * Converts a temperature into a formatted string
156 * @param temperature The double-based vertical Speed
157 * @param buffer buffer string to write to (pointer)
158 * @param size Size of the buffer
160 void FormatUserTemperature(fixed value
, TCHAR
*buffer
,
161 bool include_unit
= true);
164 * Converts a double-based Pressure into a formatted string
165 * @param Pressure The double-based Pressure
166 * @param buffer buffer string to write to (pointer)
167 * @param size Size of the buffer
169 void FormatUserPressure(AtmosphericPressure value
, TCHAR
*buffer
,
170 bool include_unit
= true);
173 * Give the proper format to display the pressure
174 * @param buffer buffer string to write to (pointer)
175 * @param size Size of the buffer
176 * @return True if buffer long enough, False otherwise
178 const TCHAR
* GetUserPressureFormat(bool include_unit
= false);
181 * Give the basic step for pressure editing
184 fixed
GetUserPressureStep();