-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathG_circleInterior.cpp
More file actions
105 lines (79 loc) · 2.87 KB
/
Copy pathG_circleInterior.cpp
File metadata and controls
105 lines (79 loc) · 2.87 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
98
99
100
101
102
103
104
105
/*
* KSeg
* Copyright (C) 1999-2006 Ilya Baran
*
* 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 2 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* ibaran@mit.edu
*/
#include "G_circleInterior.H"
#include "G_drawstyle.H"
#include "KSegView.H"
#include "G_segment.H"
#include "G_line.H"
#include "G_ray.H"
//drawing:
void G_circleInterior::draw(QPainter &p, const G_drawstyle &d, bool selected)
{ //FIXME!
double r = circle.getRadius();
QRect re = p.window();
if(!inRect(re)) return;
if(r > DRAW_MAX / 2) {
//draw big circle...
return;
}
p.setBrush(d.getBrush());
p.setPen(QPen(Qt::NoPen));
if(/*p.device()->isExtDev() ||*/ p.hasViewXForm()) { //draw at higher accuracy to a printer or image
p.scale(0.125, .125);
p.drawEllipse(ROUND((circle.getCenter().getX() - r) * 8),
ROUND((circle.getCenter().getY() - r) * 8),
ROUND(r * 16), ROUND(r * 16));
p.scale(8, 8);
return;
}
p.drawEllipse(ROUND(circle.getCenter().getX() - r),
ROUND(circle.getCenter().getY() - r),
ROUND(r * 2), ROUND(r * 2));
if(selected) {
if(KSegView::getSelectType() == KSegView::BORDER_SELECT) {
p.setBrush(QBrush(G_drawstyle::getBorderColor(d.getBrush().color()), Qt::BDiagPattern));
}
if(selected && KSegView::getSelectType() == KSegView::BLINKING_SELECT) {
QColor c(QTime::currentTime().msec() * 17, 255, 255, QColor::Hsv);
p.setBrush(QBrush(c, Qt::BDiagPattern));
}
p.drawEllipse(ROUND(circle.getCenter().getX() - r),
ROUND(circle.getCenter().getY() - r),
ROUND(r * 2), ROUND(r * 2));
}
p.setBrush(QBrush());
return;
}
G_point G_circleInterior::getNearestPoint(const G_point &p) const
{
if((circle.getCenter() - p).length() < circle.getRadius()) return p;
return circle.getNearestPoint(p);
}
bool G_circleInterior::inRect(const QRect &rect) const
{
if(getNearestPoint(rect.topRight()) == G_point(rect.topRight())) return true;
if(getNearestPoint(rect.topLeft()) == G_point(rect.topLeft())) return true;
if(getNearestPoint(rect.bottomRight()) == G_point(rect.bottomRight())) return true;
if(getNearestPoint(rect.bottomLeft()) == G_point(rect.bottomLeft())) return true;
if(circle.inRect(rect)) return true;
return false;
}