LibrePCB Developers Documentation
Loading...
Searching...
No Matches
graphicslayer.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_EDITOR_GRAPHICSLAYER_H
21#define LIBREPCB_EDITOR_GRAPHICSLAYER_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29#include <QtWidgets>
30
31#include <memory>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class Layer;
39
40namespace editor {
41
42/*******************************************************************************
43 * Class GraphicsLayer
44 ******************************************************************************/
45
54 Q_DECLARE_TR_FUNCTIONS(GraphicsLayer)
55
56public:
57 // Signals
66
67 // Constructors / Destructor
68 GraphicsLayer() = delete;
69 GraphicsLayer(const GraphicsLayer& other) noexcept;
70 explicit GraphicsLayer(const QString& name, const QString& nameTr,
71 const QColor& color, const QColor& colorHighlighted,
72 bool visible = true, bool enabled = true) noexcept;
73 virtual ~GraphicsLayer() noexcept;
74
75 // Getters
76 const QString& getName() const noexcept { return mName; }
77 const QString& getNameTr() const noexcept { return mNameTr; }
78 const QColor& getColor(bool highlighted = false) const noexcept {
79 return highlighted ? mColorHighlighted : mColor;
80 }
81 bool getVisible() const noexcept { return mIsVisible; }
82 bool isEnabled() const noexcept { return mIsEnabled; }
83 bool isVisible() const noexcept { return mIsEnabled && mIsVisible; }
84
85 // Setters
86 void setColor(const QColor& color) noexcept;
87 void setColorHighlighted(const QColor& color) noexcept;
88 void setVisible(bool visible) noexcept;
89 void setEnabled(bool enable) noexcept;
90
91 // Operator Overloadings
92 GraphicsLayer& operator=(const GraphicsLayer& rhs) = delete;
93
94protected: // Data
95 const QString mName;
96 const QString mNameTr;
97 QColor mColor;
101};
102
103/*******************************************************************************
104 * Interface IF_GraphicsLayerProvider
105 ******************************************************************************/
106
112public:
113 virtual ~IF_GraphicsLayerProvider() noexcept {}
114 virtual QList<std::shared_ptr<GraphicsLayer>> getAllLayers()
115 const noexcept = 0;
116 virtual std::shared_ptr<GraphicsLayer> getLayer(
117 const QString& name) const noexcept = 0;
118 std::shared_ptr<GraphicsLayer> getLayer(const Layer& layer) const noexcept;
120 const Layer& outlineLayer) const noexcept;
121};
122
123/*******************************************************************************
124 * End of File
125 ******************************************************************************/
126
127} // namespace editor
128} // namespace librepcb
129
130#endif
The Layer class provides all supported geometry layers.
Definition layer.h:42
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
The Slot class is used to receive signals from non-QObject derived classes.
Definition signalslot.h:170
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition graphicslayer.h:53
const QString & getNameTr() const noexcept
Definition graphicslayer.h:77
bool isEnabled() const noexcept
Definition graphicslayer.h:82
Slot< GraphicsLayer, Event > OnEditedSlot
Definition graphicslayer.h:65
const QString mName
Theme color name.
Definition graphicslayer.h:95
const QString & getName() const noexcept
Definition graphicslayer.h:76
void setEnabled(bool enable) noexcept
Definition graphicslayer.cpp:92
void setColor(const QColor &color) noexcept
Definition graphicslayer.cpp:71
Event
Definition graphicslayer.h:58
const QString mNameTr
Translated layer name as shown in the GUI.
Definition graphicslayer.h:96
bool getVisible() const noexcept
Definition graphicslayer.h:81
Signal< GraphicsLayer, Event > onEdited
Definition graphicslayer.h:64
void setColorHighlighted(const QColor &color) noexcept
Definition graphicslayer.cpp:78
void setVisible(bool visible) noexcept
Definition graphicslayer.cpp:85
QColor mColorHighlighted
Color of highlighted graphics items.
Definition graphicslayer.h:98
QColor mColor
Color of graphics items.
Definition graphicslayer.h:97
bool mIsEnabled
Availability of the layer itself.
Definition graphicslayer.h:100
GraphicsLayer & operator=(const GraphicsLayer &rhs)=delete
const QColor & getColor(bool highlighted=false) const noexcept
Definition graphicslayer.h:78
bool mIsVisible
Visibility of graphics items on that layer.
Definition graphicslayer.h:99
bool isVisible() const noexcept
Definition graphicslayer.h:83
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition graphicslayer.h:111
virtual std::shared_ptr< GraphicsLayer > getLayer(const QString &name) const noexcept=0
std::shared_ptr< GraphicsLayer > getGrabAreaLayer(const Layer &outlineLayer) const noexcept
Definition graphicslayer.cpp:108
virtual ~IF_GraphicsLayerProvider() noexcept
Definition graphicslayer.h:113
virtual QList< std::shared_ptr< GraphicsLayer > > getAllLayers() const noexcept=0
Definition occmodel.cpp:76
Definition uuid.h:186