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