LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
symbolclipboarddata.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_LIBRARY_EDITOR_SYMBOLCLIPBOARDDATA_H
21 #define LIBREPCB_LIBRARY_EDITOR_SYMBOLCLIPBOARDDATA_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 
32 
33 #include <QtCore>
34 #include <QtWidgets>
35 
36 #include <memory>
37 
38 /*******************************************************************************
39  * Namespace / Forward Declarations
40  ******************************************************************************/
41 namespace librepcb {
42 
43 class IF_GraphicsLayerProvider;
44 
45 namespace library {
46 namespace editor {
47 
48 /*******************************************************************************
49  * Class SymbolClipboardData
50  ******************************************************************************/
51 
56 public:
57  // Constructors / Destructor
58  SymbolClipboardData() = delete;
59  SymbolClipboardData(const SymbolClipboardData& other) = delete;
60  SymbolClipboardData(const Uuid& symbolUuid, const Point& cursorPos) noexcept;
61  explicit SymbolClipboardData(const SExpression& node);
62  ~SymbolClipboardData() noexcept;
63 
64  // Getters
65  bool getItemCount() const noexcept {
66  return mPins.count() + mPolygons.count() + mCircles.count() +
67  mTexts.count();
68  }
69  const Uuid& getSymbolUuid() const noexcept { return mSymbolUuid; }
70  const Point& getCursorPos() const noexcept { return mCursorPos; }
71  SymbolPinList& getPins() noexcept { return mPins; }
72  const SymbolPinList& getPins() const noexcept { return mPins; }
73  PolygonList& getPolygons() noexcept { return mPolygons; }
74  const PolygonList& getPolygons() const noexcept { return mPolygons; }
75  CircleList& getCircles() noexcept { return mCircles; }
76  const CircleList& getCircles() const noexcept { return mCircles; }
77  TextList& getTexts() noexcept { return mTexts; }
78  const TextList& getTexts() const noexcept { return mTexts; }
79 
80  // General Methods
81  std::unique_ptr<QMimeData> toMimeData(const IF_GraphicsLayerProvider& lp);
82  static std::unique_ptr<SymbolClipboardData> fromMimeData(
83  const QMimeData* mime);
84 
85  // Operator Overloadings
87 
88 private: // Methods
90  void serialize(SExpression& root) const override;
91 
92  QPixmap generatePixmap(const IF_GraphicsLayerProvider& lp) noexcept;
93  static QString getMimeType() noexcept;
94 
95 private: // Data
102 };
103 
104 /*******************************************************************************
105  * End of File
106  ******************************************************************************/
107 
108 } // namespace editor
109 } // namespace library
110 } // namespace librepcb
111 
112 #endif // LIBREPCB_LIBRARY_EDITOR_SYMBOLCLIPBOARDDATA_H
std::unique_ptr< QMimeData > toMimeData(const IF_GraphicsLayerProvider &lp)
Definition: symbolclipboarddata.cpp:66
CircleList mCircles
Definition: symbolclipboarddata.h:100
The SymbolClipboardData class.
Definition: symbolclipboarddata.h:55
Point mCursorPos
Definition: symbolclipboarddata.h:97
const Point & getCursorPos() const noexcept
Definition: symbolclipboarddata.h:70
static std::unique_ptr< SymbolClipboardData > fromMimeData(const QMimeData *mime)
Definition: symbolclipboarddata.cpp:77
static QString getMimeType() noexcept
Definition: symbolclipboarddata.cpp:122
const SymbolPinList & getPins() const noexcept
Definition: symbolclipboarddata.h:72
int count() const noexcept
Definition: serializableobjectlist.h:184
const TextList & getTexts() const noexcept
Definition: symbolclipboarddata.h:78
bool getItemCount() const noexcept
Definition: symbolclipboarddata.h:65
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:227
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: symbolclipboarddata.cpp:93
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
QPixmap generatePixmap(const IF_GraphicsLayerProvider &lp) noexcept
Definition: symbolclipboarddata.cpp:102
const CircleList & getCircles() const noexcept
Definition: symbolclipboarddata.h:76
const PolygonList & getPolygons() const noexcept
Definition: symbolclipboarddata.h:74
SymbolPinList mPins
Definition: symbolclipboarddata.h:98
SymbolPinList & getPins() noexcept
Definition: symbolclipboarddata.h:71
TextList mTexts
Definition: symbolclipboarddata.h:101
PolygonList mPolygons
Definition: symbolclipboarddata.h:99
PolygonList & getPolygons() noexcept
Definition: symbolclipboarddata.h:73
~SymbolClipboardData() noexcept
Definition: symbolclipboarddata.cpp:59
const Uuid & getSymbolUuid() const noexcept
Definition: symbolclipboarddata.h:69
SymbolClipboardData & operator=(const SymbolClipboardData &rhs)=delete
TextList & getTexts() noexcept
Definition: symbolclipboarddata.h:77
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The SExpression class.
Definition: sexpression.h:57
Uuid mSymbolUuid
Definition: symbolclipboarddata.h:96
CircleList & getCircles() noexcept
Definition: symbolclipboarddata.h:75