1 /*
2  * LibrePCB - Professional EDA for everyone!
3  * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4  * https://librepcb.org/
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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 General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 /*******************************************************************************
21  *  Includes
22  ******************************************************************************/
23 #include "gridproperties.h"
24 
25 #include <QtCore>
26 
27 /*******************************************************************************
28  *  Namespace
29  ******************************************************************************/
30 namespace librepcb {
31 
32 /*******************************************************************************
33  *  Constructors / Destructor
34  ******************************************************************************/
35 
GridProperties()36 GridProperties::GridProperties() noexcept
37   : mType(Type_t::Lines), mInterval(2540000), mUnit(LengthUnit::millimeters()) {
38 }
39 
GridProperties(const SExpression & node,const Version & fileFormat)40 GridProperties::GridProperties(const SExpression& node,
41                                const Version& fileFormat)
42   : mType(deserialize<Type_t>(node.getChild("type/@0"), fileFormat)),
43     mInterval(
44         deserialize<PositiveLength>(node.getChild("interval/@0"), fileFormat)),
45     mUnit(deserialize<LengthUnit>(node.getChild("unit/@0"), fileFormat)) {
46 }
47 
GridProperties(Type_t type,const PositiveLength & interval,const LengthUnit & unit)48 GridProperties::GridProperties(Type_t type, const PositiveLength& interval,
49                                const LengthUnit& unit) noexcept
50   : mType(type), mInterval(interval), mUnit(unit) {
51 }
52 
GridProperties(const GridProperties & other)53 GridProperties::GridProperties(const GridProperties& other) noexcept
54   : mType(other.mType), mInterval(other.mInterval), mUnit(other.mUnit) {
55 }
56 
~GridProperties()57 GridProperties::~GridProperties() noexcept {
58 }
59 
60 /*******************************************************************************
61  *  General Methods
62  ******************************************************************************/
63 
serialize(SExpression & root) const64 void GridProperties::serialize(SExpression& root) const {
65   root.appendChild("type", mType, false);
66   root.appendChild("interval", mInterval, false);
67   root.appendChild("unit", mUnit, false);
68 }
69 
70 /*******************************************************************************
71  *  Operators
72  ******************************************************************************/
73 
operator =(const GridProperties & rhs)74 GridProperties& GridProperties::operator=(const GridProperties& rhs) noexcept {
75   mType = rhs.mType;
76   mInterval = rhs.mInterval;
77   mUnit = rhs.mUnit;
78   return *this;
79 }
80 
81 /*******************************************************************************
82  *  End of File
83  ******************************************************************************/
84 
85 }  // namespace librepcb
86