2121#include < utility>
2222
2323Pin::Pin ()
24- : _direction(Pin::Right),
25- _pinType(Pin::Normal),
24+ : _pinType(Pin::Normal),
2625 _electricalType(Pin::Input)
2726{
27+ _angle = 0 ;
2828 _unit = 1 ;
2929 _length = 300 ;
3030 _textNameSize = 50 ;
@@ -35,10 +35,10 @@ Pin::Pin()
3535Pin::Pin (const QString &name, const QString &padName)
3636 : _name(name),
3737 _padName(padName),
38- _direction(Pin::Right),
3938 _pinType(Pin::Normal),
4039 _electricalType(Pin::Input)
4140{
41+ _angle = 0 ;
4242 _unit = 1 ;
4343 _length = 300 ;
4444 _textNameSize = 50 ;
@@ -56,7 +56,7 @@ Pin::Pin(const Pin &other)
5656 _name = other._name ;
5757 _pos = other._pos ;
5858 _padName = other._padName ;
59- _direction = other._direction ;
59+ _angle = other._angle ;
6060 _pinType = other._pinType ;
6161 _electricalType = other._electricalType ;
6262 _unit = other._unit ;
@@ -91,24 +91,60 @@ void Pin::setPos(int x, int y)
9191 _pos = QPoint (x, y);
9292}
9393
94- QString Pin::padName () const
94+ Pin::Direction Pin::direction () const
9595{
96- return _padName;
96+ if (_angle > 315 || _angle <= 45 )
97+ {
98+ return Right;
99+ }
100+ if (_angle > 45 && _angle <= 135 )
101+ {
102+ return Up;
103+ }
104+ if (_angle > 135 && _angle <= 225 )
105+ {
106+ return Left;
107+ }
108+ return Down;
97109}
98110
99- void Pin::setPadName ( const QString &padname )
111+ void Pin::setDirection (Direction direction )
100112{
101- _padName = padname;
113+ switch (direction)
114+ {
115+ case Right:
116+ _angle = 0 ;
117+ break ;
118+ case Up:
119+ _angle = 90 ;
120+ break ;
121+ case Left:
122+ _angle = 180 ;
123+ break ;
124+ case Down:
125+ _angle = 270 ;
126+ break ;
127+ }
102128}
103129
104- Pin::Direction Pin::direction () const
130+ int Pin::angle () const
105131{
106- return _direction ;
132+ return _angle ;
107133}
108134
109- void Pin::setDirection (Direction direction)
135+ void Pin::setAngle (int angle)
136+ {
137+ _angle = angle;
138+ }
139+
140+ QString Pin::padName () const
110141{
111- _direction = direction;
142+ return _padName;
143+ }
144+
145+ void Pin::setPadName (const QString &padname)
146+ {
147+ _padName = padname;
112148}
113149
114150Pin::PinType Pin::pinType () const
0 commit comments