LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
si_symbolpin.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_PROJECT_SI_SYMBOLPIN_H
21 #define LIBREPCB_PROJECT_SI_SYMBOLPIN_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../erc/if_ercmsgprovider.h"
27 #include "../graphicsitems/sgi_symbolpin.h"
28 #include "./si_netline.h"
29 #include "si_base.h"
30 
31 #include <QtCore>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 namespace library {
39 class SymbolPin;
40 class ComponentSignal;
41 class ComponentPinSignalMapItem;
42 } // namespace library
43 
44 namespace project {
45 
46 class Circuit;
47 class ComponentSignalInstance;
48 class SI_Symbol;
49 class ErcMsg;
50 
51 /*******************************************************************************
52  * Class SI_SymbolPin
53  ******************************************************************************/
54 
58 class SI_SymbolPin final : public SI_Base,
59  public SI_NetLineAnchor,
60  public IF_ErcMsgProvider {
61  Q_OBJECT
63 
64 public:
65  // Constructors / Destructor
66  SI_SymbolPin() = delete;
67  SI_SymbolPin(const SI_SymbolPin& other) = delete;
68  explicit SI_SymbolPin(SI_Symbol& symbol, const Uuid& pinUuid);
69  ~SI_SymbolPin();
70 
71  // Getters
72  const Uuid& getLibPinUuid() const noexcept;
73  QString getDisplayText(bool returnCmpSignalNameIfEmpty = false,
74  bool returnPinNameIfEmpty = false) const noexcept;
75  SI_Symbol& getSymbol() const noexcept { return mSymbol; }
76  const library::SymbolPin& getLibPin() const noexcept { return *mSymbolPin; }
79  }
80  NetSignal* getCompSigInstNetSignal() const noexcept;
81  SI_NetSegment* getNetSegmentOfLines() const noexcept;
82  bool isRequired() const noexcept;
83  bool isUsed() const noexcept { return (mRegisteredNetLines.count() > 0); }
84  bool isVisibleJunction() const noexcept;
85 
86  // General Methods
87  void addToSchematic() override;
88  void removeFromSchematic() override;
89  void updatePosition() noexcept;
90 
91  // Inherited from SI_Base
92  Type_t getType() const noexcept override {
94  }
95  const Point& getPosition() const noexcept override { return mPosition; }
96  QPainterPath getGrabAreaScenePx() const noexcept override;
97  void setSelected(bool selected) noexcept override;
98 
99  // Inherited from SI_NetLineAnchor
100  void registerNetLine(SI_NetLine& netline) override;
101  void unregisterNetLine(SI_NetLine& netline) override;
102  const QSet<SI_NetLine*>& getNetLines() const noexcept override {
103  return mRegisteredNetLines;
104  }
105 
106  // Operator Overloadings
107  SI_SymbolPin& operator=(const SI_SymbolPin& rhs) = delete;
108 
109 private slots:
110 
111  void updateErcMessages() noexcept;
112 
113 private:
114  void updateGraphicsItemTransform() noexcept;
115 
116  // General
118  const library::SymbolPin* mSymbolPin;
121  QMetaObject::Connection mHighlightChangedConnection;
122 
123  // Misc
126  QScopedPointer<SGI_SymbolPin> mGraphicsItem;
127 
128  // Registered Elements
130 
133 };
134 
135 /*******************************************************************************
136  * End of File
137  ******************************************************************************/
138 
139 } // namespace project
140 } // namespace librepcb
141 
142 #endif // LIBREPCB_PROJECT_SI_SYMBOLPIN_H
QMetaObject::Connection mHighlightChangedConnection
Definition: si_symbolpin.h:121
bool isVisibleJunction() const noexcept
Definition: si_symbolpin.cpp:139
const library::SymbolPin * mSymbolPin
Definition: si_symbolpin.h:118
The SI_Symbol class.
Definition: si_symbol.h:60
#define DECLARE_ERC_MSG_CLASS_NAME(msgOwnerClassName)
Definition: if_ercmsgprovider.h:44
ComponentSignalInstance * getComponentSignalInstance() const noexcept
Definition: si_symbolpin.h:77
librepcb::project::SI_SymbolPin
The ErcMsg class represents a message in the ERC (Electrical Rule Check) list.
Definition: ercmsg.h:46
ComponentSignalInstance * mComponentSignalInstance
Definition: si_symbolpin.h:120
Point mPosition
Definition: si_symbolpin.h:124
SI_Symbol & mSymbol
Definition: si_symbolpin.h:117
QString getDisplayText(bool returnCmpSignalNameIfEmpty=false, bool returnPinNameIfEmpty=false) const noexcept
Definition: si_symbolpin.cpp:91
const library::ComponentPinSignalMapItem * mPinSignalMapItem
Definition: si_symbolpin.h:119
const Uuid & getLibPinUuid() const noexcept
Definition: si_symbolpin.cpp:87
SI_Symbol & getSymbol() const noexcept
Definition: si_symbolpin.h:75
void updateGraphicsItemTransform() noexcept
Definition: si_symbolpin.cpp:247
QSet< SI_NetLine * > mRegisteredNetLines
all registered netlines
Definition: si_symbolpin.h:129
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:52
The IF_ErcMsgProvider class.
Definition: if_ercmsgprovider.h:62
Type_t getType() const noexceptoverride
Definition: si_symbolpin.h:92
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
bool isUsed() const noexcept
Definition: si_symbolpin.h:83
~SI_SymbolPin()
Definition: si_symbolpin.cpp:78
The SI_SymbolPin class.
Definition: si_symbolpin.h:58
void updateErcMessages() noexcept
Definition: si_symbolpin.cpp:233
The ComponentPinSignalMapItem class maps a symbol pin to a component signal.
Definition: componentpinsignalmap.h:55
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
void registerNetLine(SI_NetLine &netline) override
Definition: si_symbolpin.cpp:178
const Point & getPosition() const noexceptoverride
Definition: si_symbolpin.h:95
void unregisterNetLine(SI_NetLine &netline) override
Definition: si_symbolpin.cpp:196
bool isRequired() const noexcept
Definition: si_symbolpin.cpp:131
void removeFromSchematic() override
Definition: si_symbolpin.cpp:164
SI_SymbolPin & operator=(const SI_SymbolPin &rhs)=delete
The SI_NetSegment class.
Definition: si_netsegment.h:55
QScopedPointer< ErcMsg > mErcMsgUnconnectedRequiredPin
The ERC message for unconnected required pins.
Definition: si_symbolpin.h:132
Angle mRotation
Definition: si_symbolpin.h:125
Type_t
Definition: si_base.h:57
const library::SymbolPin & getLibPin() const noexcept
Definition: si_symbolpin.h:76
Definition: si_netline.h:46
const QSet< SI_NetLine * > & getNetLines() const noexceptoverride
Definition: si_symbolpin.h:102
NetSignal * getCompSigInstNetSignal() const noexcept
Definition: si_symbolpin.cpp:117
QScopedPointer< SGI_SymbolPin > mGraphicsItem
Definition: si_symbolpin.h:126
The NetSignal class.
Definition: netsignal.h:56
The ComponentSignalInstance class.
Definition: componentsignalinstance.h:61
The SymbolPin class represents one pin of a symbol.
Definition: symbolpin.h:54
SI_NetSegment * getNetSegmentOfLines() const noexcept
Definition: si_symbolpin.cpp:125
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The SI_NetLine class.
Definition: si_netline.h:64
QPainterPath getGrabAreaScenePx() const noexceptoverride
Definition: si_symbolpin.cpp:220
void addToSchematic() override
Definition: si_symbolpin.cpp:147
void updatePosition() noexcept
Definition: si_symbolpin.cpp:207
void setSelected(bool selected) noexceptoverride
Definition: si_symbolpin.cpp:224
The SGI_SymbolPin class.
Definition: sgi_symbolpin.h:56