LibrePCB Developers Documentation
graphicsexportsettings.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_GRAPHICSEXPORTSETTINGS_H
21 #define LIBREPCB_CORE_GRAPHICSEXPORTSETTINGS_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../types/length.h"
27 #include "../types/ratio.h"
28 
29 #include <optional/tl/optional.hpp>
30 
31 #include <QtCore>
32 #include <QtGui>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class Theme;
40 
41 /*******************************************************************************
42  * Class GraphicsExportSettings
43  ******************************************************************************/
44 
52 public:
53  // Types
54  enum class Orientation {
55  Landscape,
56  Portrait,
57  Auto,
58  };
59 
60  // Constructors / Destructor
61  GraphicsExportSettings() noexcept;
62  GraphicsExportSettings(const GraphicsExportSettings& other) noexcept;
63  ~GraphicsExportSettings() noexcept;
64 
65  // Getters
66  const tl::optional<QPageSize>& getPageSize() const noexcept {
67  return mPageSize;
68  }
69  Orientation getOrientation() const noexcept { return mOrientation; }
70  const UnsignedLength& getMarginLeft() const noexcept { return mMarginLeft; }
71  const UnsignedLength& getMarginTop() const noexcept { return mMarginTop; }
72  const UnsignedLength& getMarginRight() const noexcept { return mMarginRight; }
73  const UnsignedLength& getMarginBottom() const noexcept {
74  return mMarginBottom;
75  }
76  bool getRotate() const noexcept { return mRotate; }
77  bool getMirror() const noexcept { return mMirror; }
78  const tl::optional<UnsignedRatio>& getScale() const noexcept {
79  return mScale;
80  }
81  int getPixmapDpi() const noexcept { return mPixmapDpi; }
82  bool getBlackWhite() const noexcept { return mBlackWhite; }
83  const QColor& getBackgroundColor() const noexcept { return mBackgroundColor; }
84  const UnsignedLength& getMinLineWidth() const noexcept {
85  return mMinLineWidth;
86  }
87  const QList<std::pair<QString, QColor>>& getColors() const noexcept {
88  return mColors;
89  }
90  QStringList getPaintOrder() const noexcept;
91  QColor getColor(const QString& colorName) const noexcept;
92  QColor getFillColor(const QString& colorName, bool isFilled,
93  bool isGrabArea) const noexcept;
94 
95  // Setters
96  void setPageSize(const tl::optional<QPageSize>& size) noexcept {
97  mPageSize = size;
98  }
99  void setOrientation(Orientation orientation) noexcept {
100  mOrientation = orientation;
101  }
102  void setMarginLeft(const librepcb::UnsignedLength& margin) noexcept {
103  mMarginLeft = margin;
104  }
105  void setMarginTop(const librepcb::UnsignedLength& margin) noexcept {
106  mMarginTop = margin;
107  }
108  void setMarginRight(const librepcb::UnsignedLength& margin) noexcept {
109  mMarginRight = margin;
110  }
111  void setMarginBottom(const librepcb::UnsignedLength& margin) noexcept {
112  mMarginBottom = margin;
113  }
114  void setRotate(bool rotate) noexcept { mRotate = rotate; }
115  void setMirror(bool mirror) noexcept { mMirror = mirror; }
116  void setScale(tl::optional<UnsignedRatio> scale) noexcept { mScale = scale; }
117  void setPixmapDpi(int dpi) noexcept { mPixmapDpi = dpi; }
118  void setBlackWhite(bool blackWhite) noexcept { mBlackWhite = blackWhite; }
119  void setBackgroundColor(const QColor& c) noexcept { mBackgroundColor = c; }
120  void setMinLineWidth(const UnsignedLength& width) noexcept {
121  mMinLineWidth = width;
122  }
123  void setColors(const QList<std::pair<QString, QColor>>& colors) noexcept {
124  mColors = colors;
125  }
126 
127  // General Methods
128  void loadColorsFromTheme(const Theme& theme, bool schematic = true,
129  bool board = true,
130  int innerLayerCount = -1) noexcept;
131 
132  // Operator Overloadings
134  bool operator==(const GraphicsExportSettings& rhs) const noexcept;
135  bool operator!=(const GraphicsExportSettings& rhs) const noexcept;
136 
137 private: // Methods
138  QColor getColorImpl(const QString& name) const noexcept;
139 
140 private: // Data
141  tl::optional<QPageSize> mPageSize;
147  bool mRotate;
148  bool mMirror;
149  tl::optional<UnsignedRatio> mScale;
154  QList<std::pair<QString, QColor>> mColors;
155 };
156 
157 /*******************************************************************************
158  * End of File
159  ******************************************************************************/
160 
161 } // namespace librepcb
162 
163 #endif
void setMarginRight(const librepcb::UnsignedLength &margin) noexcept
Definition: graphicsexportsettings.h:108
const UnsignedLength & getMarginLeft() const noexcept
Definition: graphicsexportsettings.h:70
const UnsignedLength & getMarginTop() const noexcept
Definition: graphicsexportsettings.h:71
void setMarginLeft(const librepcb::UnsignedLength &margin) noexcept
Definition: graphicsexportsettings.h:102
UnsignedLength mMarginTop
Definition: graphicsexportsettings.h:144
const UnsignedLength & getMarginRight() const noexcept
Definition: graphicsexportsettings.h:72
Orientation getOrientation() const noexcept
Definition: graphicsexportsettings.h:69
void setScale(tl::optional< UnsignedRatio > scale) noexcept
Definition: graphicsexportsettings.h:116
bool operator==(const GraphicsExportSettings &rhs) const noexcept
Definition: graphicsexportsettings.cpp:261
Definition: occmodel.cpp:76
void setPageSize(const tl::optional< QPageSize > &size) noexcept
Definition: graphicsexportsettings.h:96
void setBackgroundColor(const QColor &c) noexcept
Definition: graphicsexportsettings.h:119
void loadColorsFromTheme(const Theme &theme, bool schematic=true, bool board=true, int innerLayerCount=-1) noexcept
Definition: graphicsexportsettings.cpp:160
QColor getColor(const QString &colorName) const noexcept
Definition: graphicsexportsettings.cpp:129
tl::optional< UnsignedRatio > mScale
Definition: graphicsexportsettings.h:149
~GraphicsExportSettings() noexcept
Definition: graphicsexportsettings.cpp:114
GraphicsExportSettings() noexcept
Definition: graphicsexportsettings.cpp:90
tl::optional< QPageSize > mPageSize
Definition: graphicsexportsettings.h:141
QColor mBackgroundColor
Definition: graphicsexportsettings.h:152
UnsignedLength mMarginBottom
Definition: graphicsexportsettings.h:146
GraphicsExportSettings & operator=(const GraphicsExportSettings &rhs) noexcept
Definition: graphicsexportsettings.cpp:242
bool operator!=(const GraphicsExportSettings &rhs) const noexcept
Definition: graphicsexportsettings.cpp:280
void setOrientation(Orientation orientation) noexcept
Definition: graphicsexportsettings.h:99
bool mBlackWhite
Definition: graphicsexportsettings.h:151
Orientation mOrientation
Definition: graphicsexportsettings.h:142
UnsignedLength mMarginLeft
Definition: graphicsexportsettings.h:143
void setMarginTop(const librepcb::UnsignedLength &margin) noexcept
Definition: graphicsexportsettings.h:105
const tl::optional< UnsignedRatio > & getScale() const noexcept
Definition: graphicsexportsettings.h:78
Settings for librepcb::GraphicsExport.
Definition: graphicsexportsettings.h:51
bool getRotate() const noexcept
Definition: graphicsexportsettings.h:76
void setMirror(bool mirror) noexcept
Definition: graphicsexportsettings.h:115
void setMinLineWidth(const UnsignedLength &width) noexcept
Definition: graphicsexportsettings.h:120
const QColor & getBackgroundColor() const noexcept
Definition: graphicsexportsettings.h:83
const tl::optional< QPageSize > & getPageSize() const noexcept
Definition: graphicsexportsettings.h:66
UnsignedLength mMinLineWidth
Definition: graphicsexportsettings.h:153
const QList< std::pair< QString, QColor > > & getColors() const noexcept
Definition: graphicsexportsettings.h:87
QStringList getPaintOrder() const noexcept
Definition: graphicsexportsettings.cpp:121
QList< std::pair< QString, QColor > > mColors
Definition: graphicsexportsettings.h:154
QColor getColorImpl(const QString &name) const noexcept
Definition: graphicsexportsettings.cpp:289
Orientation
Definition: graphicsexportsettings.h:54
QColor getFillColor(const QString &colorName, bool isFilled, bool isGrabArea) const noexcept
Definition: graphicsexportsettings.cpp:138
void setBlackWhite(bool blackWhite) noexcept
Definition: graphicsexportsettings.h:118
void setMarginBottom(const librepcb::UnsignedLength &margin) noexcept
Definition: graphicsexportsettings.h:111
void setColors(const QList< std::pair< QString, QColor >> &colors) noexcept
Definition: graphicsexportsettings.h:123
void setPixmapDpi(int dpi) noexcept
Definition: graphicsexportsettings.h:117
void setRotate(bool rotate) noexcept
Definition: graphicsexportsettings.h:114
const UnsignedLength & getMarginBottom() const noexcept
Definition: graphicsexportsettings.h:73
int getPixmapDpi() const noexcept
Definition: graphicsexportsettings.h:81
int mPixmapDpi
Definition: graphicsexportsettings.h:150
UnsignedLength mMarginRight
Definition: graphicsexportsettings.h:145
Theme class as used by librepcb::WorkspaceSettingsItem_Themes.
Definition: theme.h:44
bool mRotate
Definition: graphicsexportsettings.h:147
bool mMirror
Definition: graphicsexportsettings.h:148
bool getMirror() const noexcept
Definition: graphicsexportsettings.h:77
bool getBlackWhite() const noexcept
Definition: graphicsexportsettings.h:82
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:670
const UnsignedLength & getMinLineWidth() const noexcept
Definition: graphicsexportsettings.h:84