Menu

[r171]: / specctra / cpcbpolylinepath.cpp  Maximize  Restore  History

Download this file

99 lines (86 with data), 2.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*******************************************************************************
* Copyright (C) 2014 Pike Aerospace Research Corporation *
* Author: Mike Sharkey <mike@pikeaero.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License at <http://www.gnu.org/licenses/> *
* for more details. *
* *
*******************************************************************************/
#include "cpcbpolylinepath.h"
#define inherited CSpecctraObject
CPcbPolylinePath::CPcbPolylinePath(QGraphicsItem *parent)
: inherited(parent)
{
}
CPcbPolylinePath::~CPcbPolylinePath()
{
}
QString CPcbPolylinePath::layer()
{
QString rc;
if ( properties().count() )
rc = properties()[0];
return rc;
}
double CPcbPolylinePath::width()
{
double w=0.0;
if ( properties().count() >= 2 )
w = properties()[1].toDouble();
return w;
}
int CPcbPolylinePath::coords()
{
return properties().count()-2;
}
double CPcbPolylinePath::coord(int idx)
{
return properties()[idx+2].toDouble();
}
int CPcbPolylinePath::points()
{
return coords()/2;
}
QPointF CPcbPolylinePath::point(int idx)
{
int x = (idx*2)+2;
int y = (idx*2)+3;
QPointF pt(properties()[x].toDouble(),properties()[y].toDouble());
return pt;
}
QRectF CPcbPolylinePath::boundingRect() const
{
return shape().boundingRect();
}
QPainterPath CPcbPolylinePath::shape() const
{
CPcbPolylinePath* me=(CPcbPolylinePath*)this;
QPainterPath ppath;
QPointF pt;
for(int n=0; n < me->coords(); n+=2)
{
int x = me->coord(n);
int y = me->coord(n+1);
if (n==0)
{
pt = QPointF(x,y);
ppath.moveTo(pt);
}
else
{
if ( fabs(x) <= 0.1 ) x = pt.x();
if ( fabs(y) <= 0.1 ) y = pt.y();
pt = QPointF(x,y);
ppath.lineTo(pt);
}
}
return ppath;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.