-
Notifications
You must be signed in to change notification settings - Fork 852
/
Copy pathconnector.h
103 lines (87 loc) · 3.41 KB
/
connector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*******************************************************************
Part of the Fritzing project - http://fritzing.org
Copyright (c) 2007-2019 Fritzing
Fritzing is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Fritzing is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fritzing. If not, see <http://www.gnu.org/licenses/>.
********************************************************************/
#ifndef CONNECTOR_H
#define CONNECTOR_H
#include <QHash>
#include <QString>
#include <QList>
#include <QXmlStreamWriter>
#include <QGraphicsScene>
#include <QSvgRenderer>
#include <QPointer>
#include "../viewlayer.h"
class Connector : public QObject
{
Q_OBJECT
public:
enum ConnectorType {
Male,
Female,
Wire,
Pad,
Unknown
};
public:
Connector(class ConnectorShared *, class ModelPart * modelPart);
~Connector();
Connector::ConnectorType connectorType() const;
void addViewItem(class ConnectorItem *);
void removeViewItem(class ConnectorItem *);
class ConnectorShared * connectorShared();
void connectTo(Connector *);
void disconnectFrom(Connector *);
void saveAsPart(QXmlStreamWriter & writer);
const QList<Connector *> & toConnectors();
ConnectorItem * connectorItemByViewLayerID(ViewLayer::ViewID, ViewLayer::ViewLayerID);
ConnectorItem * connectorItem(ViewLayer::ViewID);
bool connectionIsAllowed(Connector* that);
const QString & connectorSharedID() const;
const QString & connectorSharedName() const;
const QString & connectorSharedDescription() const;
const QString & connectorSharedReplacedby() const;
class ErcData * connectorSharedErcData();
const QString & busID();
class Bus * bus();
void setBus(class Bus *);
long modelIndex();
ModelPart * modelPart();
int connectorItemCount();
void unprocess(ViewLayer::ViewID viewID, ViewLayer::ViewLayerID viewLayerID);
class SvgIdLayer * fullPinInfo(ViewLayer::ViewID viewId, ViewLayer::ViewLayerID viewLayerID);
const QList<SvgIdLayer *> svgIdLayers() const;
QList< QPointer<class ConnectorItem> > viewItems();
const QString & legID(ViewLayer::ViewID, ViewLayer::ViewLayerID);
void setConnectorLocalName(const QString &);
const QString & connectorLocalName();
void addPin(ViewLayer::ViewID, const QString & svgId, ViewLayer::ViewLayerID, const QString & terminalId, const QString & legId, bool hybrid);
public:
static void initNames();
static const QString & connectorNameFromType(ConnectorType);
static ConnectorType connectorTypeFromName(const QString & name);
protected:
void writeLayerAttr(QXmlStreamWriter &writer, ViewLayer::ViewLayerID);
void writeSvgIdAttr(QXmlStreamWriter &writer, ViewLayer::ViewID view, QString connId);
void writeTerminalIdAttr(QXmlStreamWriter &writer, ViewLayer::ViewID view, QString terminalId);
protected:
QPointer<class ConnectorShared> m_connectorShared;
QHash< int, QPointer<class ConnectorItem> > m_connectorItems;
QList<Connector *> m_toConnectors;
QPointer<class ModelPart> m_modelPart;
QPointer<class Bus> m_bus;
QString m_connectorLocalName;
protected:
static QHash<ConnectorType, QString> Names;
};
#endif