|
21 | 21 | #include <QDateTime> |
22 | 22 | #include <QDebug> |
23 | 23 | #include <QFileInfo> |
| 24 | +#include <QtMath> |
24 | 25 |
|
25 | 26 | #include "model/drawcircle.h" |
26 | 27 | #include "model/drawpoly.h" |
@@ -225,7 +226,7 @@ void KicadLibParser::writePin(Pin *pin) |
225 | 226 | _stream << " " << pin->padName() << " " // pad name |
226 | 227 | << pin->pos().x() << " " << -pin->pos().y() << " " // x y position |
227 | 228 | << pin->length() << " " // lenght |
228 | | - << pinDirectionString(pin->angle()) << " " // pin direction (up/down/left/right) |
| 229 | + << pinDirectionString(pin->angle()) << " " // pin direction (up/down/left/right) |
229 | 230 | << "50" |
230 | 231 | << " " // name text size |
231 | 232 | << "50" |
@@ -275,14 +276,8 @@ void KicadLibParser::writeDraw(Draw *draw) |
275 | 276 | // T direction posx posy text_size text_type unit convert text text_italic text_bold text_hjustify text_vjustify |
276 | 277 | drawText = dynamic_cast<DrawText *>(draw); |
277 | 278 | _stream << "T "; |
278 | | - if (drawText->direction() == DrawText::DirectionHorizontal) |
279 | | - { |
280 | | - _stream << "0 "; |
281 | | - } |
282 | | - else |
283 | | - { |
284 | | - _stream << "900 "; |
285 | | - } |
| 279 | + |
| 280 | + _stream << uint(qFloor((drawText->angle() * 10) + 0.5)) << " "; |
286 | 281 |
|
287 | 282 | _stream << drawText->pos().x() << " " << -drawText->pos().y() << " " << drawText->textSize() << " " |
288 | 283 | << "0 " << drawText->unit() << " " << drawText->convert() << " " |
@@ -345,7 +340,7 @@ void KicadLibParser::writeLabel(DrawText *draw) |
345 | 340 |
|
346 | 341 | _stream << draw->pos().x() << " " << -draw->pos().y() << " " << draw->textSize() << " "; |
347 | 342 |
|
348 | | - if (draw->direction() == DrawText::DirectionHorizontal) |
| 343 | + if (draw->angle() < 45.0) |
349 | 344 | { |
350 | 345 | _stream << "H "; |
351 | 346 | } |
@@ -708,14 +703,7 @@ Draw *KicadLibParser::readDraw(char c) |
708 | 703 | { |
709 | 704 | DrawText *draw = new DrawText(); |
710 | 705 | _stream >> n; |
711 | | - if (n == 0) |
712 | | - { |
713 | | - draw->setDirection(DrawText::DirectionHorizontal); |
714 | | - } |
715 | | - else |
716 | | - { |
717 | | - draw->setDirection(DrawText::DirectionVertital); |
718 | | - } |
| 706 | + draw->setAngle(qreal(n) / 10); |
719 | 707 |
|
720 | 708 | _stream >> n; |
721 | 709 | draw->pos().setX(n); |
@@ -881,11 +869,11 @@ DrawText *KicadLibParser::readLabel() |
881 | 869 | _stream >> nc; |
882 | 870 | if (nc == 'H') |
883 | 871 | { |
884 | | - draw->setDirection(DrawText::DirectionHorizontal); |
| 872 | + draw->setAngle(0.0); |
885 | 873 | } |
886 | 874 | else |
887 | 875 | { |
888 | | - draw->setDirection(DrawText::DirectionVertital); |
| 876 | + draw->setAngle(90.0); |
889 | 877 | } |
890 | 878 |
|
891 | 879 | _stream.skipWhiteSpace(); |
|
0 commit comments