LibrePCB Developers Documentation
maskconfig.h
Go to the documentation of this file.
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 #ifndef LIBREPCB_CORE_MASKCONFIG_H
21 #define LIBREPCB_CORE_MASKCONFIG_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "length.h"
27 
28 #include <optional/tl/optional.hpp>
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 /*******************************************************************************
38  * Class MaskConfig
39  ******************************************************************************/
40 
45 class MaskConfig final {
46  Q_DECLARE_TR_FUNCTIONS(MaskConfig)
47 
48 public:
49  // Constructors / Destructor
50  MaskConfig() = delete;
51  MaskConfig(const MaskConfig& other) noexcept;
52  ~MaskConfig() noexcept;
53 
54  // Getters
55  bool isEnabled() const noexcept { return mEnabled; }
56  const tl::optional<Length>& getOffset() const noexcept { return mOffset; }
57 
58  // Operator Overloadings
59  bool operator==(const MaskConfig& rhs) const noexcept;
60  bool operator!=(const MaskConfig& rhs) const noexcept {
61  return !(*this == rhs);
62  }
63  MaskConfig& operator=(const MaskConfig& rhs) noexcept;
64 
65  // Static Methods
66  static MaskConfig off() noexcept { return MaskConfig(false, tl::nullopt); }
67  static MaskConfig automatic() noexcept {
68  return MaskConfig(true, tl::nullopt);
69  }
70  static MaskConfig manual(const Length& offset) noexcept {
71  return MaskConfig(true, offset);
72  }
73  static MaskConfig maybe(const tl::optional<Length>& offset) noexcept {
74  return MaskConfig(offset.has_value(), offset);
75  }
76 
77 private: // Methods
78  MaskConfig(bool enabled, const tl::optional<Length>& offset) noexcept;
79 
80 private: // Data
81  bool mEnabled;
82  tl::optional<Length> mOffset;
83 };
84 
85 /*******************************************************************************
86  * End of File
87  ******************************************************************************/
88 
89 } // namespace librepcb
90 
91 #endif
tl::optional< Length > mOffset
nullopt means "from design rules"
Definition: maskconfig.h:82
The MaskConfig class defines how to add automatic stop mask or solder paste.
Definition: maskconfig.h:45
Definition: occmodel.cpp:76
bool operator!=(const MaskConfig &rhs) const noexcept
Definition: maskconfig.h:60
MaskConfig & operator=(const MaskConfig &rhs) noexcept
Definition: maskconfig.cpp:58
static MaskConfig manual(const Length &offset) noexcept
Definition: maskconfig.h:70
static MaskConfig automatic() noexcept
Definition: maskconfig.h:67
bool isEnabled() const noexcept
Definition: maskconfig.h:55
bool operator==(const MaskConfig &rhs) const noexcept
Definition: maskconfig.cpp:54
const tl::optional< Length > & getOffset() const noexcept
Definition: maskconfig.h:56
static MaskConfig off() noexcept
Definition: maskconfig.h:66
static MaskConfig maybe(const tl::optional< Length > &offset) noexcept
Definition: maskconfig.h:73
The Length class is used to represent a length (for example 12.75 millimeters)
Definition: length.h:82
bool mEnabled
Whether an automatic mask is added or not.
Definition: maskconfig.h:81
~MaskConfig() noexcept
Definition: maskconfig.cpp:47