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...
 
bool 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

bool angleIsSpecial ( double  aRadians)

Definition at line 87 of file arc_assistant.cpp.

References ANGLE_EPSILON.

Referenced by drawArcWithHilight(), and drawLineWithHilight().

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

Definition at line 110 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().

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

Definition at line 93 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().

95 {
96  auto gal = aView->GetGAL();
97  auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
98 
99  const auto vec = aEnd - aStart;
100  COLOR4D strokeColor = rs->GetLayerColor( LAYER_AUX_ITEMS );
101 
102  if( angleIsSpecial( vec.Angle() ) )
103  strokeColor = rs->IsBackgroundDark() ? COLOR4D( 0.5, 1.0, 0.5, 1.0 ) : COLOR4D( 0.0, 0.7, 0.0, 1.0 ) ;
104 
105  gal->SetStrokeColor( strokeColor.WithAlpha( PreviewOverlayDeemphAlpha( aDim ) ) );
106  gal->DrawLine( aStart, aEnd );
107 }
bool angleIsSpecial(double aRadians)
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
Auxiliary items (guides, rule, etc)
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:180
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:233
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
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 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 70 of file arc_assistant.cpp.

References RAD2DECIDEG().

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

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

Variable Documentation

const double ANGLE_EPSILON = 1e-9
static

Definition at line 85 of file arc_assistant.cpp.

Referenced by angleIsSpecial().