FreeCAD

Форк
0
/
UnitsSchemaMeterDecimal.cpp 
91 строка · 3.5 Кб
1
/***************************************************************************
2
 *   Copyright (c) WandererFan <wandererfan@gmail.com>                     *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
/*  Metric units schema intended for design of large objects
24
 *  Lengths are always in metres.
25
 *  Areas are always in square metres
26
 *  Volumes are always in cubic metres
27
 *  Angles in decimal degrees (use degree symbol)
28
 *  Velocities in m/sec
29
 */
30

31
#include "PreCompiled.h"
32
#ifdef __GNUC__
33
#include <unistd.h>
34
#endif
35

36
#include <QString>
37

38
#include "UnitsSchemaMeterDecimal.h"
39

40

41
using namespace Base;
42

43

44
QString UnitsSchemaMeterDecimal::schemaTranslate(const Base::Quantity& quant,
45
                                                 double& factor,
46
                                                 QString& unitString)
47
{
48
    Unit unit = quant.getUnit();
49
    if (unit == Unit::Length) {
50
        // all length units in metres
51
        unitString = QString::fromLatin1("m");
52
        factor = 1e3;
53
    }
54
    else if (unit == Unit::Area) {
55
        // all area units in square meters
56
        unitString = QString::fromLatin1("m^2");
57
        factor = 1e6;
58
    }
59
    else if (unit == Unit::Volume) {
60
        // all area units in cubic meters
61
        unitString = QString::fromLatin1("m^3");
62
        factor = 1e9;
63
    }
64
    else if (unit == Unit::Power) {
65
        // watts
66
        unitString = QString::fromLatin1("W");
67
        factor = 1000000;
68
    }
69
    else if (unit == Unit::ElectricPotential) {
70
        // volts
71
        unitString = QString::fromLatin1("V");
72
        factor = 1000000;
73
    }
74
    else if (unit == Unit::HeatFlux) {
75
        // watts per square metre
76
        unitString = QString::fromLatin1("W/m^2");
77
        factor = 1.0;
78
    }
79
    else if (unit == Unit::Velocity) {
80
        // metres per second
81
        unitString = QString::fromLatin1("m/s");
82
        factor = 1e3;
83
    }
84
    else {
85
        // default action for all cases without special treatment:
86
        unitString = quant.getUnit().getString();
87
        factor = 1.0;
88
    }
89

90
    return toLocale(quant, factor, unitString);
91
}
92

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.