1
/***************************************************************************
2
* Copyright (c) 2016 WandererFan <wandererfan@gmail.com> *
4
* This file is part of the FreeCAD CAx development system. *
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. *
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. *
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 *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
#include <Base/Parameter.h>
26
#include <Mod/TechDraw/App/Preferences.h>
30
using namespace TechDraw;
31
using namespace TechDrawGui;
33
//*** initial static var outside methods!
34
double Rez::m_rezFactor = Rez::getParameter();
37
double Rez::getRezFactor()
39
return Rez::m_rezFactor;
42
void Rez::setRezFactor(double f)
47
//turn App side value to Gui side value
48
double Rez::guiX(double x)
50
return getRezFactor() * x;
53
Base::Vector3d Rez::guiX(Base::Vector3d v)
55
return Base::Vector3d(guiX(v.x), guiX(v.y), guiX(v.z));
58
Base::Vector2d Rez::guiX(Base::Vector3d v, bool planar)
61
return Base::Vector2d(guiX(v.x), guiX(v.y));
64
QPointF Rez::guiX(QPointF p)
69
//turn Gui side value to App side value
70
double Rez::appX(double x)
72
return x / getRezFactor();
75
Base::Vector3d Rez::appX(Base::Vector3d v)
77
return Base::Vector3d(appX(v.x), appX(v.y), appX(v.z));
80
QPointF Rez::appX(QPointF p)
88
QPointF Rez::guiPt(QPointF p)
90
return p * getRezFactor();
93
QPointF Rez::appPt(QPointF p)
95
return QPointF(appX(p.x()), appX(p.y()));
98
QRectF Rez::guiRect(QRectF r)
100
return QRectF(guiX(r.left()),
106
QSize Rez::guiSize(QSize s)
108
return QSize((int)guiX(s.width()), (int)guiX(s.height()));
111
QSize Rez::appSize(QSize s)
113
return QSize((int)appX(s.width()), (int)appX(s.height()));
116
double Rez::getParameter()
118
return Preferences::getPreferenceGroup("Rez")->GetFloat("Resolution", 10.0);