@@ -1,60 +1,61 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the Kicad Tools Software |
|
2 | -- This file is a part of the Kicad Tools Software | |
3 | -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
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 |
|
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 |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
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 |
|
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 |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
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 "pcbvia.h" |
|
22 | #include "pcbvia.h" | |
23 | #include <QPen> |
|
23 | #include <QPen> | |
24 |
|
24 | |||
25 |
|
25 | |||
26 | PCBVia::PCBVia(QIlib::QIcadPcbVia *viaNode, PCBContext *context) |
|
26 | PCBVia::PCBVia(QIlib::QIcadPcbVia *viaNode, PCBContext *context) | |
27 | :QGraphicsItemGroup(),viaNode(viaNode),context(context) |
|
27 | :QGraphicsItemGroup(),viaNode(viaNode),context(context) | |
28 | { |
|
28 | { | |
29 | this->init(QPointF(0.0,0.0)); |
|
29 | this->init(QPointF(0.0,0.0)); | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | PCBVia::PCBVia(QIlib::QIcadPcbVia *viaNode, QPointF offset, PCBContext *context) |
|
32 | PCBVia::PCBVia(QIlib::QIcadPcbVia *viaNode, QPointF offset, PCBContext *context) | |
33 | :QGraphicsItemGroup(),viaNode(viaNode),context(context) |
|
33 | :QGraphicsItemGroup(),viaNode(viaNode),context(context) | |
34 | { |
|
34 | { | |
35 | this->init(offset); |
|
35 | this->init(offset); | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | void PCBVia::init(QPointF offset) |
|
38 | void PCBVia::init(QPointF offset) | |
39 | { |
|
39 | { | |
40 | this->setCacheMode(QGraphicsItem::DeviceCoordinateCache); |
|
40 | this->setCacheMode(QGraphicsItem::DeviceCoordinateCache); | |
|
41 | this->setFlags(ItemIsMovable|ItemIsSelectable|ItemIsFocusable); | |||
41 | offset-=QPointF(this->viaNode->size().width()/2,this->viaNode->size().height()/2); |
|
42 | offset-=QPointF(this->viaNode->size().width()/2,this->viaNode->size().height()/2); | |
42 |
|
43 | |||
43 | for(int i=0;i<this->viaNode->layers().count();i++) |
|
44 | for(int i=0;i<this->viaNode->layers().count();i++) | |
44 | { |
|
45 | { | |
45 | QGraphicsEllipseItem* ellipse = new QGraphicsEllipseItem(); |
|
46 | QGraphicsEllipseItem* ellipse = new QGraphicsEllipseItem(); | |
46 | QPen pen = ellipse->pen(); |
|
47 | QPen pen = ellipse->pen(); | |
47 | pen.setWidthF(0.01); |
|
48 | pen.setWidthF(0.01); | |
48 | ellipse->setPen(pen); |
|
49 | ellipse->setPen(pen); | |
49 | QBrush brush = ellipse->brush(); |
|
50 | QBrush brush = ellipse->brush(); | |
50 | brush.setStyle(Qt::SolidPattern); |
|
51 | brush.setStyle(Qt::SolidPattern); | |
51 | brush.setColor(context->layerColor(this->viaNode->layers().at(i))); |
|
52 | brush.setColor(context->layerColor(this->viaNode->layers().at(i))); | |
52 | ellipse->setBrush(brush); |
|
53 | ellipse->setBrush(brush); | |
53 | QRectF rec(this->viaNode->pos()+offset,this->viaNode->size()); |
|
54 | QRectF rec(this->viaNode->pos()+offset,this->viaNode->size()); | |
54 | ellipse->setRect(rec); |
|
55 | ellipse->setRect(rec); | |
55 | ellipse->setZValue(-context->layer(viaNode->layers().at(i))); |
|
56 | ellipse->setZValue(-context->layer(viaNode->layers().at(i))); | |
56 | this->addToGroup(ellipse); |
|
57 | this->addToGroup(ellipse); | |
57 | } |
|
58 | } | |
58 |
|
59 | |||
59 | setOpacity(0.6); |
|
60 | setOpacity(0.6); | |
60 | } |
|
61 | } |
General Comments 0
You need to be logged in to leave comments.
Login now