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::VIEW *aView, const VECTOR2I &aStart, const VECTOR2I &aEnd, bool aDim)
 
static void drawArcWithHilight (KIGFX::VIEW *aView, 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 86 of file arc_assistant.cpp.

References ANGLE_EPSILON.

Referenced by drawArcWithHilight(), and drawLineWithHilight().

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

Definition at line 109 of file arc_assistant.cpp.

References angleIsSpecial(), color, KIGFX::VIEW::GetGAL(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), and LAYER_AUX_ITEMS.

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

112 {
113  auto gal = aView->GetGAL();
114  auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
115 
116  auto color = rs->GetLayerColor( LAYER_AUX_ITEMS );
117 
118  if( angleIsSpecial( aStartAngle - aEndAngle ) )
119  color = rs->IsBackgroundDark() ? COLOR4D( 0.5, 1.0, 0.5, 1.0 ) : COLOR4D( 0.0, 0.7, 0.0, 1.0 ) ;
120 
121  gal->SetStrokeColor( color );
122  gal->SetFillColor( color.WithAlpha( 0.2 ) );
123 
124  // draw the angle reference arc
125  gal->DrawArc( aOrigin, aRad, -aStartAngle, -aEndAngle );
126 }
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
Auxillary items (guides, rule, etc)
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:177
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
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::VIEW aView,
const VECTOR2I aStart,
const VECTOR2I aEnd,
bool  aDim 
)
static

Definition at line 92 of file arc_assistant.cpp.

References angleIsSpecial(), KIGFX::VIEW::GetGAL(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), LAYER_AUX_ITEMS, KIGFX::PREVIEW::PreviewOverlayDeemphAlpha(), and KIGFX::COLOR4D::WithAlpha().

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

94 {
95  auto gal = aView->GetGAL();
96  auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
97 
98  const auto vec = aEnd - aStart;
99  COLOR4D strokeColor = rs->GetLayerColor( LAYER_AUX_ITEMS );
100 
101  if( angleIsSpecial( vec.Angle() ) )
102  strokeColor = rs->IsBackgroundDark() ? COLOR4D( 0.5, 1.0, 0.5, 1.0 ) : COLOR4D( 0.0, 0.7, 0.0, 1.0 ) ;
103 
104  gal->SetStrokeColor( strokeColor.WithAlpha( PreviewOverlayDeemphAlpha( aDim ) ) );
105  gal->DrawLine( aStart, aEnd );
106 }
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
Auxillary items (guides, rule, etc)
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:177
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:232
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
double PreviewOverlayDeemphAlpha(bool aDeemph=true)
Default alpha of "de-emphasised" features (like previously locked-in lines.
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
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 69 of file arc_assistant.cpp.

References RAD2DECIDEG().

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

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

Variable Documentation

const double ANGLE_EPSILON = 1e-9
static

Definition at line 84 of file arc_assistant.cpp.

Referenced by angleIsSpecial().