KiCad PCB EDA Suite
arc_assistant.cpp File Reference

Go to the source code of this file.

Functions

double getNormDeciDegFromRad (double aRadians)
 Get deci-degrees from radians, normalised to +/- 360. More...
 
double angleIsSpecial (double aRadians)
 
static void drawLineWithHilight (KIGFX::GAL &aGal, const VECTOR2I &aStart, const VECTOR2I &aEnd, bool aDim)
 
static void drawArcWithHilight (KIGFX::GAL &aGal, const VECTOR2I &aOrigin, double aRad, double aStartAngle, double aEndAngle)
 

Variables

static const double ANGLE_EPSILON = 1e-9
 

Function Documentation

double angleIsSpecial ( double  aRadians)

Definition at line 85 of file arc_assistant.cpp.

References ANGLE_EPSILON.

Referenced by drawArcWithHilight(), and drawLineWithHilight().

86 {
87  return std::fabs( std::remainder( aRadians, M_PI_4 ) ) < ANGLE_EPSILON;
88 }
static const double ANGLE_EPSILON
static void drawArcWithHilight ( KIGFX::GAL aGal,
const VECTOR2I aOrigin,
double  aRad,
double  aStartAngle,
double  aEndAngle 
)
static

Definition at line 105 of file arc_assistant.cpp.

References angleIsSpecial(), KIGFX::GAL::DrawArc(), KIGFX::PREVIEW::PreviewOverlayDefaultColor(), KIGFX::PREVIEW::PreviewOverlaySpecialAngleColor(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetStrokeColor(), and KIGFX::COLOR4D::WithAlpha().

Referenced by KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().

108 {
110 
111  if( angleIsSpecial( aStartAngle - aEndAngle ) )
113 
114  aGal.SetStrokeColor( color );
115  aGal.SetFillColor( color.WithAlpha( 0.2 ) );
116 
117  // draw the angle reference arc
118  aGal.DrawArc( aOrigin, aRad, -aStartAngle, -aEndAngle );
119 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
COLOR4D PreviewOverlayDefaultColor()
The default fill/stroke color of preview overlay items.
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:232
COLOR4D PreviewOverlaySpecialAngleColor()
The colour of "special" angle overlay features.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
double angleIsSpecial(double aRadians)
static void drawLineWithHilight ( KIGFX::GAL aGal,
const VECTOR2I aStart,
const VECTOR2I aEnd,
bool  aDim 
)
static

Definition at line 91 of file arc_assistant.cpp.

References angleIsSpecial(), KIGFX::GAL::DrawLine(), KIGFX::PREVIEW::PreviewOverlayDeemphAlpha(), KIGFX::PREVIEW::PreviewOverlayDefaultColor(), KIGFX::PREVIEW::PreviewOverlaySpecialAngleColor(), KIGFX::GAL::SetStrokeColor(), and KIGFX::COLOR4D::WithAlpha().

Referenced by KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().

93 {
94  const auto vec = aEnd - aStart;
95  COLOR4D strokeColor = PreviewOverlayDefaultColor();
96 
97  if( angleIsSpecial( vec.Angle() ) )
98  strokeColor = PreviewOverlaySpecialAngleColor();
99 
100  aGal.SetStrokeColor( strokeColor.WithAlpha( PreviewOverlayDeemphAlpha( aDim ) ) );
101  aGal.DrawLine( aStart, aEnd );
102 }
COLOR4D PreviewOverlayDefaultColor()
The default fill/stroke color of preview overlay items.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:232
double PreviewOverlayDeemphAlpha(bool aDeemph=true)
Default alpha of "de-emphasised" features (like previously locked-in lines.
COLOR4D PreviewOverlaySpecialAngleColor()
The colour of "special" angle overlay features.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
double angleIsSpecial(double aRadians)
double getNormDeciDegFromRad ( double  aRadians)

Get deci-degrees from radians, normalised to +/- 360.

The normalisation is such that a negative angle will stay negative.

Definition at line 68 of file arc_assistant.cpp.

References RAD2DECIDEG().

Referenced by KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().

69 {
70  double degs = RAD2DECIDEG( aRadians );
71 
72  // normalise to +/- 360
73  while( degs < -3600.0 )
74  degs += 3600.0;
75 
76  while( degs > 3600.0 )
77  degs -= 3600.0;
78 
79  return degs;
80 }
double RAD2DECIDEG(double rad)
Definition: trigo.h:196

Variable Documentation

const double ANGLE_EPSILON = 1e-9
static

Definition at line 83 of file arc_assistant.cpp.

Referenced by angleIsSpecial().