@@ -0,0 +1,62 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the Kicad Tools Software | |||
|
3 | -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
|
22 | #include "pcbzone.h" | |||
|
23 | #include <QPen> | |||
|
24 | #include <QPixmapCache> | |||
|
25 | ||||
|
26 | PCBZone::PCBZone(QIlib::QIcadPcbZone *zoneNode, PCBContext *context) | |||
|
27 | :QGraphicsItemGroup(),zoneNode(zoneNode),context(context) | |||
|
28 | { | |||
|
29 | this->init(); | |||
|
30 | } | |||
|
31 | ||||
|
32 | void PCBZone::init() | |||
|
33 | { | |||
|
34 | this->setFlags(ItemIsMovable|ItemIsSelectable|ItemIsFocusable); | |||
|
35 | QPolygonF poly; | |||
|
36 | for(int i=0;i<this->zoneNode->filledPolygon.points.points.count();i++) | |||
|
37 | { | |||
|
38 | poly.append(this->zoneNode->filledPolygon.points.points.at(i)->pos()); | |||
|
39 | } | |||
|
40 | QGraphicsPixmapItem* test=new QGraphicsPixmapItem(); | |||
|
41 | QPixmap pix; | |||
|
42 | QPainter painter; | |||
|
43 | QGraphicsPolygonItem* polygonItem = new QGraphicsPolygonItem(); | |||
|
44 | QPen pen = polygonItem->pen(); | |||
|
45 | pen.setWidthF(0.01); | |||
|
46 | ||||
|
47 | polygonItem->setPen(pen); | |||
|
48 | QBrush brush = polygonItem->brush(); | |||
|
49 | brush.setStyle(Qt::SolidPattern); | |||
|
50 | brush.setColor(context->layerColor(this->zoneNode->layer.value())); | |||
|
51 | polygonItem->setBrush(brush); | |||
|
52 | polygonItem->setZValue(-context->layer(this->zoneNode->layer.value())); | |||
|
53 | polygonItem->setPolygon(poly); | |||
|
54 | polygonItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache); | |||
|
55 | // test->setPixmap(polygonItem->); | |||
|
56 | //voir doc/qt/... | |||
|
57 | // polygonItem->paint(); | |||
|
58 | this->addToGroup(polygonItem); | |||
|
59 | ||||
|
60 | this->setCacheMode(QGraphicsItem::DeviceCoordinateCache); | |||
|
61 | setOpacity(0.6); | |||
|
62 | } |
@@ -0,0 +1,43 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the Kicad Tools Software | |||
|
3 | -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
5 | -- This program is free software; you can redistribute it and/or modify | |||
|
6 | -- it under the terms of the GNU General Public License as published by | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
15 | -- You should have received a copy of the GNU General Public License | |||
|
16 | -- along with this program; if not, write to the Free Software | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
|
22 | #ifndef PCBZONE_H | |||
|
23 | #define PCBZONE_H | |||
|
24 | #include <QObject> | |||
|
25 | #include <QWidget> | |||
|
26 | #include <QGraphicsRectItem> | |||
|
27 | #include <QGraphicsItemGroup> | |||
|
28 | #include <pcbcontext.h> | |||
|
29 | #include <qicadpcb.h> | |||
|
30 | #include <QPainterPath> | |||
|
31 | ||||
|
32 | class PCBZone: public QGraphicsItemGroup | |||
|
33 | { | |||
|
34 | public: | |||
|
35 | PCBZone(QIlib::QIcadPcbZone* zoneNode,PCBContext* context); | |||
|
36 | private: | |||
|
37 | void init(); | |||
|
38 | QIlib::QIcadPcbZone* zoneNode; | |||
|
39 | int layer; | |||
|
40 | PCBContext* context; | |||
|
41 | }; | |||
|
42 | ||||
|
43 | #endif // PCBZONE_H |
@@ -49,6 +49,7 const char* feature1_c = "(feature1 | |||||
49 | const char* feature2_c = "(feature2"; |
|
49 | const char* feature2_c = "(feature2"; | |
50 | const char* field_c = "(field"; |
|
50 | const char* field_c = "(field"; | |
51 | const char* fields_c = "(fields"; |
|
51 | const char* fields_c = "(fields"; | |
|
52 | const char* filled_polygon_c = "(filled_polygon"; | |||
52 | const char* font_c = "(font"; |
|
53 | const char* font_c = "(font"; | |
53 | const char* fp_circle_c = "(fp_circle"; |
|
54 | const char* fp_circle_c = "(fp_circle"; | |
54 | const char* fp_line_c = "(fp_line"; |
|
55 | const char* fp_line_c = "(fp_line"; | |
@@ -112,8 +113,10 const char* plotinvisibletext_c = " | |||||
112 | const char* plotothertext_c = "(plotothertext"; |
|
113 | const char* plotothertext_c = "(plotothertext"; | |
113 | const char* plotreference_c = "(plotreference"; |
|
114 | const char* plotreference_c = "(plotreference"; | |
114 | const char* plotvalue_c = "(plotvalue"; |
|
115 | const char* plotvalue_c = "(plotvalue"; | |
|
116 | const char* polygon_c = "(polygon"; | |||
115 | const char* psa4output_c = "(psa4output"; |
|
117 | const char* psa4output_c = "(psa4output"; | |
116 | const char* psnegative_c = "(psnegative"; |
|
118 | const char* psnegative_c = "(psnegative"; | |
|
119 | const char* pts_c = "(pts"; | |||
117 | const char* ref_c = "(ref"; |
|
120 | const char* ref_c = "(ref"; | |
118 | const char* rotate = "(rota"; |
|
121 | const char* rotate = "(rota"; | |
119 | const char* scale_c = "(scale"; |
|
122 | const char* scale_c = "(scale"; | |
@@ -158,6 +161,7 const char* viasonmask_c = "(viason | |||||
158 | const char* visible_elements_c = "(visible_elements"; |
|
161 | const char* visible_elements_c = "(visible_elements"; | |
159 | const char* width_c = "(width"; |
|
162 | const char* width_c = "(width"; | |
160 | const char* xyz = "(x"; |
|
163 | const char* xyz = "(x"; | |
|
164 | const char* xy_c = "(xy"; | |||
161 | const char* zone_45_only_c = "(zone_45_only"; |
|
165 | const char* zone_45_only_c = "(zone_45_only"; | |
162 | const char* zone_clearance_c = "(zone_clearance"; |
|
166 | const char* zone_clearance_c = "(zone_clearance"; | |
163 | const char* zone_c = "(zone"; |
|
167 | const char* zone_c = "(zone"; |
@@ -59,6 +59,7 extern "C" const char* feature1_c; | |||||
59 | extern "C" const char* feature2_c; |
|
59 | extern "C" const char* feature2_c; | |
60 | extern "C" const char* field_c; |
|
60 | extern "C" const char* field_c; | |
61 | extern "C" const char* fields_c; |
|
61 | extern "C" const char* fields_c; | |
|
62 | extern "C" const char* filled_polygon_c; | |||
62 | extern "C" const char* font_c; |
|
63 | extern "C" const char* font_c; | |
63 | extern "C" const char* fp_circle_c; |
|
64 | extern "C" const char* fp_circle_c; | |
64 | extern "C" const char* fp_line_c; |
|
65 | extern "C" const char* fp_line_c; | |
@@ -122,8 +123,10 extern "C" const char* plotinvisiblete | |||||
122 | extern "C" const char* plotothertext_c; |
|
123 | extern "C" const char* plotothertext_c; | |
123 | extern "C" const char* plotreference_c; |
|
124 | extern "C" const char* plotreference_c; | |
124 | extern "C" const char* plotvalue_c; |
|
125 | extern "C" const char* plotvalue_c; | |
|
126 | extern "C" const char* polygon_c; | |||
125 | extern "C" const char* psa4output_c; |
|
127 | extern "C" const char* psa4output_c; | |
126 | extern "C" const char* psnegative_c; |
|
128 | extern "C" const char* psnegative_c; | |
|
129 | extern "C" const char* pts_c; | |||
127 | extern "C" const char* ref_c; |
|
130 | extern "C" const char* ref_c; | |
128 | extern "C" const char* rotate; |
|
131 | extern "C" const char* rotate; | |
129 | extern "C" const char* scale_c; |
|
132 | extern "C" const char* scale_c; | |
@@ -168,6 +171,7 extern "C" const char* viasonmask_c; | |||||
168 | extern "C" const char* visible_elements_c; |
|
171 | extern "C" const char* visible_elements_c; | |
169 | extern "C" const char* width_c; |
|
172 | extern "C" const char* width_c; | |
170 | extern "C" const char* xyz; |
|
173 | extern "C" const char* xyz; | |
|
174 | extern "C" const char* xy_c; | |||
171 | extern "C" const char* zone_45_only_c; |
|
175 | extern "C" const char* zone_45_only_c; | |
172 | extern "C" const char* zone_clearance_c; |
|
176 | extern "C" const char* zone_clearance_c; | |
173 | extern "C" const char* zone_c; |
|
177 | extern "C" const char* zone_c; |
@@ -1120,10 +1120,118 void QIlib::QIcadPcbZone::setNode(QIlib: | |||||
1120 | if(node->name==QIlib::Lexique::zone_c) |
|
1120 | if(node->name==QIlib::Lexique::zone_c) | |
1121 | { |
|
1121 | { | |
1122 | this->p_node = node; |
|
1122 | this->p_node = node; | |
|
1123 | for(int i=0;i<node->nodes.count();i++) | |||
|
1124 | { | |||
|
1125 | if(node->nodes.at(i)->name==QIlib::Lexique::polygon_c) | |||
|
1126 | { | |||
|
1127 | this->polygon.setNode(node->nodes.at(i)); | |||
|
1128 | } | |||
|
1129 | if(node->nodes.at(i)->name==QIlib::Lexique::filled_polygon_c) | |||
|
1130 | { | |||
|
1131 | this->filledPolygon.setNode(node->nodes.at(i)); | |||
|
1132 | } | |||
|
1133 | if(node->nodes.at(i)->name==QIlib::Lexique::layer_c) | |||
|
1134 | { | |||
|
1135 | this->layer.setNode(node->nodes.at(i)); | |||
|
1136 | } | |||
|
1137 | } | |||
|
1138 | } | |||
|
1139 | } | |||
|
1140 | ||||
|
1141 | ||||
|
1142 | QIlib::QIcadPcbPolygonPoint::QIcadPcbPolygonPoint(QIlib::AbstractNode *node) | |||
|
1143 | :QIcadAbstractNodeWrapper(node) | |||
|
1144 | { | |||
|
1145 | this->p_pos.setX(0.0); | |||
|
1146 | this->p_pos.setY(0.0); | |||
|
1147 | this->setNode(node); | |||
|
1148 | } | |||
|
1149 | ||||
|
1150 | void QIlib::QIcadPcbPolygonPoint::setNode(QIlib::AbstractNode *node) | |||
|
1151 | { | |||
|
1152 | if(node->name==QIlib::Lexique::xy_c) | |||
|
1153 | { | |||
|
1154 | this->p_node = node; | |||
|
1155 | this->p_pos = nodeTo2DCoords(node); | |||
1123 | } |
|
1156 | } | |
1124 | } |
|
1157 | } | |
1125 |
|
1158 | |||
1126 |
|
1159 | |||
|
1160 | QIlib::QIcadPcbPolygon::QIcadPcbPolygon(QIlib::AbstractNode *node) | |||
|
1161 | :QIcadAbstractNodeWrapper(node) | |||
|
1162 | { | |||
|
1163 | this->setNode(node); | |||
|
1164 | } | |||
|
1165 | ||||
|
1166 | void QIlib::QIcadPcbPolygon::setNode(QIlib::AbstractNode *node) | |||
|
1167 | { | |||
|
1168 | if(node->name==QIlib::Lexique::polygon_c) | |||
|
1169 | { | |||
|
1170 | this->p_node = node; | |||
|
1171 | this->p_filled = false; | |||
|
1172 | for(int i=0;i<node->nodes.count();i++) | |||
|
1173 | { | |||
|
1174 | if(node->nodes.at(i)->name==QIlib::Lexique::pts_c) | |||
|
1175 | { | |||
|
1176 | this->points.setNode(node->nodes.at(i)); | |||
|
1177 | } | |||
|
1178 | } | |||
|
1179 | } | |||
|
1180 | if(node->name==QIlib::Lexique::filled_polygon_c) | |||
|
1181 | { | |||
|
1182 | this->p_node = node; | |||
|
1183 | this->p_filled = true; | |||
|
1184 | for(int i=0;i<node->nodes.count();i++) | |||
|
1185 | { | |||
|
1186 | if(node->nodes.at(i)->name==QIlib::Lexique::pts_c) | |||
|
1187 | { | |||
|
1188 | this->points.setNode(node->nodes.at(i)); | |||
|
1189 | } | |||
|
1190 | } | |||
|
1191 | } | |||
|
1192 | } | |||
|
1193 | ||||
|
1194 | QIlib::QIcadPcbPolygonPoints::QIcadPcbPolygonPoints(QIlib::AbstractNode *node) | |||
|
1195 | :QIcadAbstractNodeWrapper(node) | |||
|
1196 | { | |||
|
1197 | this->setNode(node); | |||
|
1198 | } | |||
|
1199 | ||||
|
1200 | void QIlib::QIcadPcbPolygonPoints::setNode(QIlib::AbstractNode *node) | |||
|
1201 | { | |||
|
1202 | this->clrPoints(); | |||
|
1203 | if(node->name==QIlib::Lexique::pts_c) | |||
|
1204 | { | |||
|
1205 | this->p_node = node; | |||
|
1206 | for(int i=0;i<node->nodes.count();i++) | |||
|
1207 | { | |||
|
1208 | if(node->nodes.at(i)->name==QIlib::Lexique::xy_c) | |||
|
1209 | { | |||
|
1210 | this->apendPoint(node->nodes.at(i)); | |||
|
1211 | } | |||
|
1212 | } | |||
|
1213 | } | |||
|
1214 | } | |||
|
1215 | ||||
|
1216 | void QIlib::QIcadPcbPolygonPoints::clrPoints() | |||
|
1217 | { | |||
|
1218 | while(points.count()) | |||
|
1219 | { | |||
|
1220 | QIcadPcbPolygonPoint* point; | |||
|
1221 | point = points.last(); | |||
|
1222 | points.removeLast(); | |||
|
1223 | delete point; | |||
|
1224 | } | |||
|
1225 | } | |||
|
1226 | ||||
|
1227 | void QIlib::QIcadPcbPolygonPoints::apendPoint(QIlib::AbstractNode *node) | |||
|
1228 | { | |||
|
1229 | if(node->name==QIlib::Lexique::xy_c) | |||
|
1230 | { | |||
|
1231 | this->points.append(new QIcadPcbPolygonPoint(node)); | |||
|
1232 | } | |||
|
1233 | } | |||
|
1234 | ||||
1127 | const QPointF QIlib::nodeTo2DCoords(QIlib::AbstractNode *node) |
|
1235 | const QPointF QIlib::nodeTo2DCoords(QIlib::AbstractNode *node) | |
1128 | { |
|
1236 | { | |
1129 | QPointF point; |
|
1237 | QPointF point; | |
@@ -1193,3 +1301,8 const QSizeF QIlib::nodeTo2DSize(QIlib:: | |||||
1193 | } |
|
1301 | } | |
1194 | return size; |
|
1302 | return size; | |
1195 | } |
|
1303 | } | |
|
1304 | ||||
|
1305 | ||||
|
1306 | ||||
|
1307 | ||||
|
1308 |
@@ -363,11 +363,52 public: | |||||
363 | void setNode(QIlib::AbstractNode* node); |
|
363 | void setNode(QIlib::AbstractNode* node); | |
364 | }; |
|
364 | }; | |
365 |
|
365 | |||
|
366 | ||||
|
367 | class QIcadPcbPolygonPoint : public QIcadAbstractNodeWrapper | |||
|
368 | { | |||
|
369 | public: | |||
|
370 | QIcadPcbPolygonPoint(QIlib::AbstractNode* node); | |||
|
371 | QIcadPcbPolygonPoint(){} | |||
|
372 | void setNode(QIlib::AbstractNode* node); | |||
|
373 | const QPointF& pos(){return p_pos;} | |||
|
374 | private: | |||
|
375 | QPointF p_pos; | |||
|
376 | }; | |||
|
377 | ||||
|
378 | ||||
|
379 | class QIcadPcbPolygonPoints : public QIcadAbstractNodeWrapper | |||
|
380 | { | |||
|
381 | public: | |||
|
382 | QIcadPcbPolygonPoints(QIlib::AbstractNode* node); | |||
|
383 | QIcadPcbPolygonPoints(){} | |||
|
384 | void setNode(QIlib::AbstractNode* node); | |||
|
385 | QList<QIcadPcbPolygonPoint*> points; | |||
|
386 | void clrPoints(); | |||
|
387 | void apendPoint(QIlib::AbstractNode* node); | |||
|
388 | private: | |||
|
389 | QPointF p_pos; | |||
|
390 | }; | |||
|
391 | ||||
|
392 | class QIcadPcbPolygon : public QIcadAbstractNodeWrapper | |||
|
393 | { | |||
|
394 | public: | |||
|
395 | QIcadPcbPolygon(QIlib::AbstractNode* node); | |||
|
396 | QIcadPcbPolygon(){} | |||
|
397 | QIcadPcbPolygonPoints points; | |||
|
398 | void setNode(QIlib::AbstractNode* node); | |||
|
399 | bool isFilled(){return p_filled;} | |||
|
400 | private: | |||
|
401 | bool p_filled; | |||
|
402 | }; | |||
|
403 | ||||
366 | class QIcadPcbZone : public QIcadAbstractNodeWrapper |
|
404 | class QIcadPcbZone : public QIcadAbstractNodeWrapper | |
367 | { |
|
405 | { | |
368 | public: |
|
406 | public: | |
369 | QIcadPcbZone(QIlib::AbstractNode* node); |
|
407 | QIcadPcbZone(QIlib::AbstractNode* node); | |
370 | QIcadPcbZone(){} |
|
408 | QIcadPcbZone(){} | |
|
409 | QIcadPcbPolygon polygon; | |||
|
410 | QIcadPcbPolygon filledPolygon; | |||
|
411 | QIcadAbstractNodeWrapper layer; | |||
371 | void setNode(QIlib::AbstractNode* node); |
|
412 | void setNode(QIlib::AbstractNode* node); | |
372 | }; |
|
413 | }; | |
373 |
|
414 |
@@ -25,18 +25,20 LIBS += -L../../bin -lQIlib | |||||
25 | SOURCES += main.cpp\ |
|
25 | SOURCES += main.cpp\ | |
26 | mainwindow.cpp \ |
|
26 | mainwindow.cpp \ | |
27 | pcbgraphicview.cpp \ |
|
27 | pcbgraphicview.cpp \ | |
28 | pcbrectpad.cpp \ |
|
|||
29 | pcbmodule.cpp \ |
|
28 | pcbmodule.cpp \ | |
30 | pcbline.cpp \ |
|
29 | pcbline.cpp \ | |
31 | pcbcontext.cpp \ |
|
30 | pcbcontext.cpp \ | |
32 | pcbvia.cpp |
|
31 | pcbvia.cpp \ | |
|
32 | pcbpad.cpp \ | |||
|
33 | pcbzone.cpp | |||
33 |
|
34 | |||
34 | HEADERS += mainwindow.h \ |
|
35 | HEADERS += mainwindow.h \ | |
35 | pcbgraphicview.h \ |
|
36 | pcbgraphicview.h \ | |
36 | pcbrectpad.h \ |
|
|||
37 | pcbmodule.h \ |
|
37 | pcbmodule.h \ | |
38 | pcbline.h \ |
|
38 | pcbline.h \ | |
39 | pcbcontext.h \ |
|
39 | pcbcontext.h \ | |
40 | pcbvia.h |
|
40 | pcbvia.h \ | |
|
41 | pcbpad.h \ | |||
|
42 | pcbzone.h | |||
41 |
|
43 | |||
42 | FORMS += mainwindow.ui |
|
44 | FORMS += mainwindow.ui |
@@ -24,6 +24,7 | |||||
24 | #include "pcbmodule.h" |
|
24 | #include "pcbmodule.h" | |
25 | #include "pcbline.h" |
|
25 | #include "pcbline.h" | |
26 | #include "pcbvia.h" |
|
26 | #include "pcbvia.h" | |
|
27 | #include "pcbzone.h" | |||
27 | #include <QFileDialog> |
|
28 | #include <QFileDialog> | |
28 |
|
29 | |||
29 |
|
30 | |||
@@ -33,6 +34,7 MainWindow::MainWindow(QWidget *parent) | |||||
33 | { |
|
34 | { | |
34 | ui->setupUi(this); |
|
35 | ui->setupUi(this); | |
35 | this->p_scene = new QGraphicsScene(); |
|
36 | this->p_scene = new QGraphicsScene(); | |
|
37 | // this->p_scene->setItemIndexMethod(QGraphicsScene::NoIndex); | |||
36 | this->context = new PCBContext(); |
|
38 | this->context = new PCBContext(); | |
37 | this->ui->graphicsView->setScene(this->p_scene); |
|
39 | this->ui->graphicsView->setScene(this->p_scene); | |
38 | this->pcbDriver =NULL; |
|
40 | this->pcbDriver =NULL; | |
@@ -78,10 +80,7 void MainWindow::loadFile(const QString | |||||
78 | pcbDriver = new QIlib::QIcadPcb(); |
|
80 | pcbDriver = new QIlib::QIcadPcb(); | |
79 | this->context->clear(); |
|
81 | this->context->clear(); | |
80 | this->p_scene->clear(); |
|
82 | this->p_scene->clear(); | |
81 | // pcbDriver.parsePcb("/opt/kicadTools/test/testFiles/pcb2.kicad_pcb"); |
|
|||
82 | // pcbDriver.parsePcb("/home/jeandet/Documents/PCB/ADC_STAMP/ADC_STAMP.kicad_pcb"); |
|
|||
83 | pcbDriver->parsePcb(file); |
|
83 | pcbDriver->parsePcb(file); | |
84 | // pcbDriver.parsePcb("/usr/share/kicad/demos/kit-dev-coldfire-xilinx_5213/kit-dev-coldfire-xilinx_5213.kicad_pcb"); |
|
|||
85 | for(int i=0;i<pcbDriver->pcbRoot->layers.layers.count();i++) |
|
84 | for(int i=0;i<pcbDriver->pcbRoot->layers.layers.count();i++) | |
86 | { |
|
85 | { | |
87 | this->context->addlayer(pcbDriver->pcbRoot->layers.layers.at(i)->name(),pcbDriver->pcbRoot->layers.layers.at(i)->index()); |
|
86 | this->context->addlayer(pcbDriver->pcbRoot->layers.layers.at(i)->name(),pcbDriver->pcbRoot->layers.layers.at(i)->index()); | |
@@ -102,4 +101,8 void MainWindow::loadFile(const QString | |||||
102 | { |
|
101 | { | |
103 | this->p_scene->addItem(new PCBVia(pcbDriver->pcbRoot->vias.at(i),this->context)); |
|
102 | this->p_scene->addItem(new PCBVia(pcbDriver->pcbRoot->vias.at(i),this->context)); | |
104 | } |
|
103 | } | |
|
104 | for(int i=0;i<pcbDriver->pcbRoot->zones.count();i++) | |||
|
105 | { | |||
|
106 | this->p_scene->addItem(new PCBZone(pcbDriver->pcbRoot->zones.at(i),this->context)); | |||
|
107 | } | |||
105 | } |
|
108 | } |
@@ -23,11 +23,12 | |||||
23 |
|
23 | |||
24 | #include <math.h> |
|
24 | #include <math.h> | |
25 | #include <QGLWidget> |
|
25 | #include <QGLWidget> | |
|
26 | #include <QOpenGLWidget> | |||
|
27 | #include <QPixmapCache> | |||
26 |
|
28 | |||
27 | PCBGraphicView::PCBGraphicView(QWidget *parent) |
|
29 | PCBGraphicView::PCBGraphicView(QWidget *parent) | |
28 | :QGraphicsView(parent) |
|
30 | :QGraphicsView(parent) | |
29 | { |
|
31 | { | |
30 |
|
||||
31 | this->setRenderHint(QPainter::Antialiasing, true); |
|
32 | this->setRenderHint(QPainter::Antialiasing, true); | |
32 | this->setDragMode(QGraphicsView::RubberBandDrag); |
|
33 | this->setDragMode(QGraphicsView::RubberBandDrag); | |
33 | this->setOptimizationFlags(QGraphicsView::DontSavePainterState); |
|
34 | this->setOptimizationFlags(QGraphicsView::DontSavePainterState); | |
@@ -37,10 +38,10 PCBGraphicView::PCBGraphicView(QWidget * | |||||
37 | this->setTransformationAnchor(AnchorUnderMouse); |
|
38 | this->setTransformationAnchor(AnchorUnderMouse); | |
38 | this->scale(qreal(0.8), qreal(0.8)); |
|
39 | this->scale(qreal(0.8), qreal(0.8)); | |
39 | this->setRubberBandSelectionMode(Qt::ContainsItemBoundingRect); |
|
40 | this->setRubberBandSelectionMode(Qt::ContainsItemBoundingRect); | |
40 | this->setDragMode(RubberBandDrag); |
|
|||
41 | this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
41 | this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
42 | this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
42 | this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
43 |
|
43 | // this->setViewport(new QOpenGLWidget()); | ||
|
44 | QPixmapCache::setCacheLimit(1024*1024*4); | |||
44 | this->ctrl_pressed = false; |
|
45 | this->ctrl_pressed = false; | |
45 | this->shift_pressed = false; |
|
46 | this->shift_pressed = false; | |
46 | } |
|
47 | } | |
@@ -82,22 +83,23 void PCBGraphicView::keyReleaseEvent(QKe | |||||
82 |
|
83 | |||
83 | void PCBGraphicView::wheelEvent(QWheelEvent *event) |
|
84 | void PCBGraphicView::wheelEvent(QWheelEvent *event) | |
84 | { |
|
85 | { | |
85 |
|
86 | if (event->modifiers() & Qt::ControlModifier) | ||
86 | if (event->modifiers() & Qt::ControlModifier) |
|
|||
87 | { |
|
|||
88 | if (event->orientation()== Qt::Vertical) |
|
|||
89 | scaleView(pow((double)2, event->delta() / 240.0)); |
|
|||
90 | } |
|
|||
91 | else |
|
|||
92 | { |
|
|||
93 | if (event->modifiers() & Qt::ShiftModifier) |
|
|||
94 | { |
|
87 | { | |
95 | QWheelEvent* tempevent = new QWheelEvent(event->pos(),(event->delta()/10),event->buttons(),event->modifiers(),Qt::Horizontal); |
|
88 | event->accept(); | |
96 | QGraphicsView::wheelEvent(tempevent); |
|
89 | if (event->orientation()== Qt::Vertical) | |
|
90 | scaleView(pow((double)2, event->delta() / 240.0)); | |||
97 | } |
|
91 | } | |
98 | else |
|
92 | else | |
99 | QGraphicsView::wheelEvent(event); |
|
93 | { | |
100 | } |
|
94 | if (event->modifiers() & Qt::ShiftModifier) | |
|
95 | { | |||
|
96 | event->accept(); | |||
|
97 | QWheelEvent* tempevent = new QWheelEvent(event->pos(),(event->delta()/10),event->buttons(),event->modifiers(),Qt::Horizontal); | |||
|
98 | QGraphicsView::wheelEvent(tempevent); | |||
|
99 | } | |||
|
100 | else | |||
|
101 | QGraphicsView::wheelEvent(event); | |||
|
102 | } | |||
101 | } |
|
103 | } | |
102 |
|
104 | |||
103 |
|
105 |
@@ -28,6 +28,7 | |||||
28 | #include <QKeyEvent> |
|
28 | #include <QKeyEvent> | |
29 | #include <QPainter> |
|
29 | #include <QPainter> | |
30 | #include <QMap> |
|
30 | #include <QMap> | |
|
31 | #include <QElapsedTimer> | |||
31 |
|
32 | |||
32 | class PCBGraphicView : public QGraphicsView |
|
33 | class PCBGraphicView : public QGraphicsView | |
33 | { |
|
34 | { |
@@ -21,15 +21,13 | |||||
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include "pcbmodule.h" |
|
22 | #include "pcbmodule.h" | |
23 | #include "pcbline.h" |
|
23 | #include "pcbline.h" | |
24 |
#include "pcb |
|
24 | #include "pcbpad.h" | |
25 |
|
25 | |||
26 | PCBModule::PCBModule(QIlib::QIcadPcbModule *moduleNode, PCBContext *context) |
|
26 | PCBModule::PCBModule(QIlib::QIcadPcbModule *moduleNode, PCBContext *context) | |
27 | :QGraphicsItemGroup(),context(context) |
|
27 | :QGraphicsItemGroup(),context(context) | |
28 | { |
|
28 | { | |
29 | this->setCacheMode(QGraphicsItem::DeviceCoordinateCache); |
|
29 | this->setCacheMode(QGraphicsItem::DeviceCoordinateCache); | |
30 | this->setFlags(ItemIsMovable|ItemIsSelectable|ItemIsFocusable); |
|
30 | this->setFlags(ItemIsMovable|ItemIsSelectable|ItemIsFocusable); | |
31 | // this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); |
|
|||
32 | // this->addToGroup(new QGraphicsRectItem(0,0,2,2)); |
|
|||
33 | this->setPos(moduleNode->pos()); |
|
31 | this->setPos(moduleNode->pos()); | |
34 | for(int i=0;i<moduleNode->fp_lines.count();i++) |
|
32 | for(int i=0;i<moduleNode->fp_lines.count();i++) | |
35 | { |
|
33 | { | |
@@ -37,7 +35,7 PCBModule::PCBModule(QIlib::QIcadPcbModu | |||||
37 | } |
|
35 | } | |
38 | for(int i=0;i<moduleNode->pads.count();i++) |
|
36 | for(int i=0;i<moduleNode->pads.count();i++) | |
39 | { |
|
37 | { | |
40 |
this->addToGroup(new PCB |
|
38 | this->addToGroup(new PCBPad((QIlib::QIcadPcbPad*)moduleNode->pads.at(i),moduleNode->pos(),context)); | |
41 | } |
|
39 | } | |
42 | this->setRotation(moduleNode->angle()); |
|
40 | this->setRotation(moduleNode->angle()); | |
43 | } |
|
41 | } |
@@ -19,10 +19,10 | |||||
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 |
#include "pcb |
|
22 | #include "pcbpad.h" | |
23 | #include <QPen> |
|
23 | #include <QPen> | |
24 |
|
24 | |||
25 |
PCB |
|
25 | PCBPad::PCBPad(QIlib::QIcadPcbPad *padNode, PCBContext *context) | |
26 | :QGraphicsItemGroup(),padNode(padNode),context(context) |
|
26 | :QGraphicsItemGroup(),padNode(padNode),context(context) | |
27 | { |
|
27 | { | |
28 | this->init(QPointF(0.0,0.0)); |
|
28 | this->init(QPointF(0.0,0.0)); | |
@@ -30,13 +30,13 PCBRectPad::PCBRectPad(QIlib::QIcadPcbPa | |||||
30 |
|
30 | |||
31 |
|
31 | |||
32 |
|
32 | |||
33 |
PCB |
|
33 | PCBPad::PCBPad(QIlib::QIcadPcbPad *padNode, QPointF offset, PCBContext *context) | |
34 | :QGraphicsItemGroup(),padNode(padNode),context(context) |
|
34 | :QGraphicsItemGroup(),padNode(padNode),context(context) | |
35 | { |
|
35 | { | |
36 | this->init(offset); |
|
36 | this->init(offset); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 |
void PCB |
|
39 | void PCBPad::init( QPointF offset) | |
40 | { |
|
40 | { | |
41 | this->setCacheMode(QGraphicsItem::DeviceCoordinateCache); |
|
41 | this->setCacheMode(QGraphicsItem::DeviceCoordinateCache); | |
42 | offset-=QPointF(this->padNode->size().width()/2,this->padNode->size().height()/2); |
|
42 | offset-=QPointF(this->padNode->size().width()/2,this->padNode->size().height()/2); |
@@ -19,8 +19,8 | |||||
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 |
#ifndef PCB |
|
22 | #ifndef PCBPAD_H | |
23 |
#define PCB |
|
23 | #define PCBPAD_H | |
24 |
|
24 | |||
25 | #include <QObject> |
|
25 | #include <QObject> | |
26 | #include <QWidget> |
|
26 | #include <QWidget> | |
@@ -29,11 +29,11 | |||||
29 | #include <pcbcontext.h> |
|
29 | #include <pcbcontext.h> | |
30 | #include <qicadpcb.h> |
|
30 | #include <qicadpcb.h> | |
31 |
|
31 | |||
32 |
class PCB |
|
32 | class PCBPad : public QGraphicsItemGroup | |
33 | { |
|
33 | { | |
34 | public: |
|
34 | public: | |
35 |
PCB |
|
35 | PCBPad(QIlib::QIcadPcbPad* padNode,PCBContext* context); | |
36 |
PCB |
|
36 | PCBPad(QIlib::QIcadPcbPad* padNode,QPointF offset,PCBContext* context); | |
37 |
|
37 | |||
38 | private: |
|
38 | private: | |
39 | void init(QPointF offset); |
|
39 | void init(QPointF offset); | |
@@ -45,4 +45,4 private: | |||||
45 | PCBContext* context; |
|
45 | PCBContext* context; | |
46 | }; |
|
46 | }; | |
47 |
|
47 | |||
48 |
#endif // PCB |
|
48 | #endif // PCBPAD_H |
@@ -37,11 +37,11 PCBVia::PCBVia(QIlib::QIcadPcbVia *viaNo | |||||
37 |
|
37 | |||
38 | void PCBVia::init(QPointF offset) |
|
38 | void PCBVia::init(QPointF offset) | |
39 | { |
|
39 | { | |
|
40 | this->setCacheMode(QGraphicsItem::DeviceCoordinateCache); | |||
|
41 | this->setFlags(ItemIsMovable|ItemIsSelectable|ItemIsFocusable); | |||
40 | this->path.addEllipse(this->viaNode->pos(),this->viaNode->size().width()/2,this->viaNode->size().height()/2); |
|
42 | this->path.addEllipse(this->viaNode->pos(),this->viaNode->size().width()/2,this->viaNode->size().height()/2); | |
41 | double thickness = (this->viaNode->size().width()-this->viaNode->drill())/2; |
|
43 | double thickness = (this->viaNode->size().width()-this->viaNode->drill())/2; | |
42 | this->path.addEllipse(this->viaNode->pos(),(this->viaNode->size().width()/2)-thickness,(this->viaNode->size().height()/2)-thickness); |
|
44 | this->path.addEllipse(this->viaNode->pos(),(this->viaNode->size().width()/2)-thickness,(this->viaNode->size().height()/2)-thickness); | |
43 | this->setCacheMode(QGraphicsItem::DeviceCoordinateCache); |
|
|||
44 | this->setFlags(ItemIsMovable|ItemIsSelectable|ItemIsFocusable); |
|
|||
45 | offset-=QPointF(this->viaNode->size().width()/2,this->viaNode->size().height()/2); |
|
45 | offset-=QPointF(this->viaNode->size().width()/2,this->viaNode->size().height()/2); | |
46 |
|
46 | |||
47 | for(int i=0;i<this->viaNode->layers().count();i++) |
|
47 | for(int i=0;i<this->viaNode->layers().count();i++) |
General Comments 0
You need to be logged in to leave comments.
Login now