Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
0dadf3bc
Commit
0dadf3bc
authored
Feb 07, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrected bounding box for arcs (DRAWSEGMENT).
parent
61a76b29
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
4 deletions
+57
-4
class_drawsegment.cpp
pcbnew/class_drawsegment.cpp
+55
-1
class_drawsegment.h
pcbnew/class_drawsegment.h
+2
-3
No files found.
pcbnew/class_drawsegment.cpp
View file @
0dadf3bc
...
@@ -134,7 +134,7 @@ const wxPoint DRAWSEGMENT::GetArcEnd() const
...
@@ -134,7 +134,7 @@ const wxPoint DRAWSEGMENT::GetArcEnd() const
return
endPoint
;
// after rotation, the end of the arc.
return
endPoint
;
// after rotation, the end of the arc.
}
}
const
double
DRAWSEGMENT
::
GetArcAngleStart
()
const
double
DRAWSEGMENT
::
GetArcAngleStart
()
const
{
{
// due to the Y axis orient atan2 needs - y value
// due to the Y axis orient atan2 needs - y value
double
angleStart
=
ArcTangente
(
GetArcStart
().
y
-
GetCenter
().
y
,
double
angleStart
=
ArcTangente
(
GetArcStart
().
y
-
GetCenter
().
y
,
...
@@ -148,6 +148,7 @@ const double DRAWSEGMENT::GetArcAngleStart() const
...
@@ -148,6 +148,7 @@ const double DRAWSEGMENT::GetArcAngleStart() const
return
angleStart
;
return
angleStart
;
}
}
void
DRAWSEGMENT
::
SetAngle
(
double
aAngle
)
void
DRAWSEGMENT
::
SetAngle
(
double
aAngle
)
{
{
NORMALIZE_ANGLE_360
(
aAngle
);
NORMALIZE_ANGLE_360
(
aAngle
);
...
@@ -379,6 +380,59 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const
...
@@ -379,6 +380,59 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const
wxPoint
end
=
m_End
;
wxPoint
end
=
m_End
;
RotatePoint
(
&
end
,
m_Start
,
-
m_Angle
);
RotatePoint
(
&
end
,
m_Start
,
-
m_Angle
);
bbox
.
Merge
(
end
);
bbox
.
Merge
(
end
);
// Determine the starting quarter
// 0 right-bottom
// 1 left-bottom
// 2 left-top
// 3 right-top
unsigned
int
quarter
=
0
;
// assume right-bottom
if
(
m_End
.
y
<
m_Start
.
y
)
// change to left-top
quarter
|=
3
;
if
(
m_End
.
x
<
m_Start
.
x
)
// for left side, the LSB is 2nd bit negated
quarter
^=
1
;
int
radius
=
GetRadius
();
int
angle
=
(
int
)
GetArcAngleStart
()
%
900
+
m_Angle
;
bool
directionCW
=
(
m_Angle
>
0
);
// Is the direction of arc clockwise?
if
(
!
directionCW
)
{
angle
=
900
-
angle
;
quarter
=
(
quarter
+
3
)
%
4
;
// -1 modulo arithmetic
}
while
(
angle
>
900
)
{
switch
(
quarter
)
{
case
0
:
bbox
.
Merge
(
wxPoint
(
m_Start
.
x
,
m_Start
.
y
+
radius
)
);
// down
break
;
case
1
:
bbox
.
Merge
(
wxPoint
(
m_Start
.
x
-
radius
,
m_Start
.
y
)
);
// left
break
;
case
2
:
bbox
.
Merge
(
wxPoint
(
m_Start
.
x
,
m_Start
.
y
-
radius
)
);
// up
break
;
case
3
:
bbox
.
Merge
(
wxPoint
(
m_Start
.
x
+
radius
,
m_Start
.
y
)
);
// right
break
;
}
if
(
directionCW
)
++
quarter
;
else
quarter
+=
3
;
// -1 modulo arithmetic
quarter
%=
4
;
angle
-=
900
;
}
}
}
break
;
break
;
...
...
pcbnew/class_drawsegment.h
View file @
0dadf3bc
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
#ifndef CLASS_DRAWSEGMENT_H_
#ifndef CLASS_DRAWSEGMENT_H_
#define CLASS_DRAWSEGMENT_H_
#define CLASS_DRAWSEGMENT_H_
#include <common.h>
#include <class_board_item.h>
#include <class_board_item.h>
#include <PolyLine.h>
#include <PolyLine.h>
#include <math_for_graphics.h>
#include <math_for_graphics.h>
...
@@ -126,9 +125,9 @@ public:
...
@@ -126,9 +125,9 @@ public:
/**
/**
* function GetArcAngleStart()
* function GetArcAngleStart()
* @return the angle of the stating point of this arc, between 0 and 3600 in 0.1 deg
* @return the angle of the sta
r
ting point of this arc, between 0 and 3600 in 0.1 deg
*/
*/
const
double
GetArcAngleStart
()
const
;
double
GetArcAngleStart
()
const
;
/**
/**
* Function GetRadius
* Function GetRadius
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment