• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KUnitConversion

  • sources
  • kde-4.14
  • kdelibs
  • kunitconversion
velocity.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Petri Damstén <damu@iki.fi>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include "velocity.h"
21 #include "converter.h"
22 #include <math.h>
23 #include <klocale.h>
24 
25 using namespace KUnitConversion;
26 
27 class BeaufortConv : public Complex
28 {
29  double toDefault(double value) const { return 0.836 * pow(value, 3.0 / 2.0); };
30  double fromDefault(double value) const { return pow(value / 0.836, 2.0 / 3.0); };
31 };
32 
33 Velocity::Velocity() : UnitCategory(VelocityCategory)
34 {
35  setName(i18n("Speed"));
36  setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (velocity)", "%1 %2"));
37 
38  setDefaultUnit(UP(MeterPerSecond, 1,
39  i18nc("velocity unit symbol", "m/s"),
40  i18nc("unit description in lists", "meters per second"),
41  i18nc("unit synonyms for matching user input", "meter per second;meters per second;m/s;ms"),
42  ki18nc("amount in units (real)", "%1 meters per second"),
43  ki18ncp("amount in units (integer)", "%1 meter per second", "%1 meters per second")
44  ));
45  U(KilometerPerHour, 0.277778,
46  i18nc("velocity unit symbol", "km/h"),
47  i18nc("unit description in lists", "kilometers per hour"),
48  i18nc("unit synonyms for matching user input",
49  "kilometer per hour;kilometers per hour;km/h;kmh"),
50  ki18nc("amount in units (real)", "%1 kilometers per hour"),
51  ki18ncp("amount in units (integer)", "%1 kilometer per hour", "%1 kilometers per hour")
52  );
53  U(MilePerHour, 0.44704,
54  i18nc("velocity unit symbol", "mph"),
55  i18nc("unit description in lists", "miles per hour"),
56  i18nc("unit synonyms for matching user input", "mile per hour;miles per hour;mph"),
57  ki18nc("amount in units (real)", "%1 miles per hour"),
58  ki18ncp("amount in units (integer)", "%1 mile per hour", "%1 miles per hour")
59  );
60  U(FootPerSecond, 0.3048,
61  i18nc("velocity unit symbol", "ft/s"),
62  i18nc("unit description in lists", "feet per second"),
63  i18nc("unit synonyms for matching user input",
64  "foot per second;feet per second;ft/s;ft/sec;fps"),
65  ki18nc("amount in units (real)", "%1 feet per second"),
66  ki18ncp("amount in units (integer)", "%1 foot per second", "%1 feet per second")
67  );
68  U(InchPerSecond, 0.0254,
69  i18nc("velocity unit symbol", "in/s"),
70  i18nc("unit description in lists", "inches per second"),
71  i18nc("unit synonyms for matching user input",
72  "inch per second;inches per second;in/s;in/sec;ips"),
73  ki18nc("amount in units (real)", "%1 inches per second"),
74  ki18ncp("amount in units (integer)", "%1 inch per second", "%1 inches per second")
75  );
76  U(Knot, 0.514444,
77  i18nc("velocity unit symbol", "kt"),
78  i18nc("unit description in lists", "knots"),
79  i18nc("unit synonyms for matching user input", "knot;knots;kt;nautical miles per hour"),
80  ki18nc("amount in units (real)", "%1 knots"),
81  ki18ncp("amount in units (integer)", "%1 knot", "%1 knots")
82  );
83  // http://en.wikipedia.org/wiki/Speed_of_sound
84  U(Mach, 343,
85  i18nc("velocity unit symbol", "Ma"),
86  i18nc("unit description in lists", "Mach"),
87  i18nc("unit synonyms for matching user input", "mach;machs;Ma;speed of sound"),
88  ki18nc("amount in units (real)", "Mach %1"),
89  ki18ncp("amount in units (integer)", "Mach %1", "Mach %1")
90  );
91  U(SpeedOfLight, 2.99792458e+08,
92  i18nc("velocity unit symbol", "c"),
93  i18nc("unit description in lists", "speed of light"),
94  i18nc("unit synonyms for matching user input", "speed of light;c"),
95  ki18nc("amount in units (real)", "%1 speed of light"),
96  ki18ncp("amount in units (integer)", "%1 speed of light", "%1 speed of light")
97  );
98  // http://en.wikipedia.org/wiki/Beaufort_scale
99  U(Beaufort, new BeaufortConv(),
100  i18nc("velocity unit symbol", "bft"),
101  i18nc("unit description in lists", "Beaufort"),
102  i18nc("unit synonyms for matching user input", "Beaufort;Bft"),
103  ki18nc("amount in units (real)", "%1 on the Beaufort scale"),
104  ki18ncp("amount in units (integer)", "%1 on the Beaufort scale", "%1 on the Beaufort scale")
105  );
106 
107  setMostCommonUnits(QList<int>() <<
108  MeterPerSecond << KilometerPerHour << MilePerHour << Knot << Mach);
109 }
KUnitConversion::UnitCategory::setMostCommonUnits
void setMostCommonUnits(const QList< int > &units)
Definition: unitcategory.cpp:80
KUnitConversion::UnitCategory::setName
void setName(const QString &name)
Definition: unitcategory.cpp:156
KUnitConversion::MeterPerSecond
Definition: converter.h:88
KUnitConversion::Complex
Definition: unit.h:34
KUnitConversion::MilePerHour
Definition: converter.h:88
UP
#define UP(id, m, s, d, sy, r, i)
Definition: unit.h:127
KUnitConversion::Mach
Definition: converter.h:89
converter.h
QList
KUnitConversion::Beaufort
Definition: converter.h:89
KUnitConversion::UnitCategory::setDefaultUnit
void setDefaultUnit(UnitPtr defaultUnit)
Definition: unitcategory.cpp:161
KUnitConversion::FootPerSecond
Definition: converter.h:88
KUnitConversion::UnitCategory
Definition: unitcategory.h:33
KUnitConversion::SpeedOfLight
Definition: converter.h:89
KUnitConversion::KilometerPerHour
Definition: converter.h:88
KUnitConversion::InchPerSecond
Definition: converter.h:88
KUnitConversion::UnitCategory::setSymbolStringFormat
void setSymbolStringFormat(const KLocalizedString &symbolStringFormat)
Definition: unitcategory.cpp:60
velocity.h
Velocity::Velocity
Velocity()
Definition: velocity.cpp:33
U
#define U(id, m, s, d, sy, r, i)
Definition: unit.h:129
KUnitConversion::Knot
Definition: converter.h:88
KUnitConversion::VelocityCategory
Definition: converter.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KUnitConversion

Skip menu "KUnitConversion"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal