FreeCAD

Форк
0
119 строк · 3.2 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2016 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
#include "PreCompiled.h"
24

25
#include <Base/Parameter.h>
26
#include <Mod/TechDraw/App/Preferences.h>
27

28
#include "Rez.h"
29

30
using namespace TechDraw;
31
using namespace TechDrawGui;
32

33
//*** initial static var outside methods!
34
double Rez::m_rezFactor = Rez::getParameter();
35
//***
36

37
double Rez::getRezFactor()
38
{
39
    return Rez::m_rezFactor;
40
}
41

42
void Rez::setRezFactor(double f)
43
{
44
    Rez::m_rezFactor = f;
45
}
46

47
//turn App side value to Gui side value
48
double Rez::guiX(double x)
49
{
50
   return getRezFactor() * x;
51
}
52

53
Base::Vector3d Rez::guiX(Base::Vector3d v)
54
{
55
    return Base::Vector3d(guiX(v.x), guiX(v.y), guiX(v.z));
56
}
57

58
Base::Vector2d Rez::guiX(Base::Vector3d v, bool planar)
59
{
60
    Q_UNUSED(planar);
61
    return Base::Vector2d(guiX(v.x), guiX(v.y));
62
}
63

64
QPointF Rez::guiX(QPointF p)
65
{
66
    return Rez::guiPt(p);
67
}
68

69
//turn Gui side value to App side value
70
double Rez::appX(double x)
71
{
72
   return x / getRezFactor();
73
}
74

75
Base::Vector3d Rez::appX(Base::Vector3d v)
76
{
77
    return Base::Vector3d(appX(v.x), appX(v.y), appX(v.z));
78
}
79

80
QPointF Rez::appX(QPointF p)
81
{
82
    return appPt(p);
83
}
84

85

86

87
//Misc conversions
88
QPointF Rez::guiPt(QPointF p)
89
{
90
    return p * getRezFactor();
91
}
92

93
QPointF Rez::appPt(QPointF p)
94
{
95
    return QPointF(appX(p.x()), appX(p.y()));
96
}
97

98
QRectF Rez::guiRect(QRectF r)
99
{
100
    return QRectF(guiX(r.left()),
101
                  guiX(r.top()),
102
                  guiX(r.width()),
103
                  guiX(r.height()));
104
}
105

106
QSize Rez::guiSize(QSize s)
107
{
108
    return QSize((int)guiX(s.width()), (int)guiX(s.height()));
109
}
110

111
QSize Rez::appSize(QSize s)
112
{
113
    return QSize((int)appX(s.width()), (int)appX(s.height()));
114
}
115

116
double Rez::getParameter()
117
{
118
    return Preferences::getPreferenceGroup("Rez")->GetFloat("Resolution", 10.0);
119
}
120

121

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

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

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

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