KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGFX::PREVIEW::DRAW_CONTEXT Class Reference

A KIGFX::PREVIEW::DRAW_CONTEXT is a wrapper around a GAL and some other settings that makes it easy to draw preview items consistently. More...

#include <draw_context.h>

Public Member Functions

 DRAW_CONTEXT (KIGFX::VIEW &aView)
 
void DrawCircle (const VECTOR2I &aOrigin, double aRad, bool aDeEmphasised)
 Draw a preview circle on the current layer.
 
void DrawCircleDashed (const VECTOR2I &aOrigin, double aRad, double aStepAngle, double aFillAngle, bool aDeEmphasised)
 Draw a dashed preview circle on the current layer.
 
void DrawLine (const VECTOR2I &aStart, const VECTOR2I &aEnd, bool aDeEmphasised)
 Draw a simple line on the current layer.
 
void DrawLineDashed (const VECTOR2I &aStart, const VECTOR2I &aEn, int aDashStep, int aDashFill, bool aDeEmphasised)
 Draw a dashed line on the current layer.
 
void DrawLineWithAngleHighlight (const VECTOR2I &aStart, const VECTOR2I &aEnd, bool aDeEmphasised)
 Draw a straight line on the current layer, with a special highlight when the line angle is a multiple of 45 degrees.
 
void DrawArcWithAngleHighlight (const VECTOR2I &aOrigin, double aRad, double aStartAngle, double aEndAngle)
 Draw an arc on the current layer, with a special highlight when the line angle is a multiple of 45 degrees.
 

Private Member Functions

COLOR4D getSpecialAngleColour () const
 The GAL to draw into.
 

Private Attributes

KIGFX::GALm_gal
 
const KIGFX::RENDER_SETTINGSm_render_settings
 The current layer to draw onto.
 
GAL_LAYER_ID m_currLayer
 
float m_lineWidth
 The line width to use for items.
 

Detailed Description

A KIGFX::PREVIEW::DRAW_CONTEXT is a wrapper around a GAL and some other settings that makes it easy to draw preview items consistently.

This class provides some graphical items that are often used by preview items. Complex items can be composed from these.

Definition at line 44 of file draw_context.h.

Constructor & Destructor Documentation

◆ DRAW_CONTEXT()

DRAW_CONTEXT::DRAW_CONTEXT ( KIGFX::VIEW aView)

Definition at line 48 of file draw_context.cpp.

Member Function Documentation

◆ DrawArcWithAngleHighlight()

void KIGFX::PREVIEW::DRAW_CONTEXT::DrawArcWithAngleHighlight ( const VECTOR2I aOrigin,
double  aRad,
double  aStartAngle,
double  aEndAngle 
)

Draw an arc on the current layer, with a special highlight when the line angle is a multiple of 45 degrees.

Parameters
aOriginthe arc centre
aRadthe arc radius
aStartAnglethe arc start angle
aEndAnglethe arc end angle

◆ DrawCircle()

void DRAW_CONTEXT::DrawCircle ( const VECTOR2I aOrigin,
double  aRad,
bool  aDeEmphasised 
)

Draw a preview circle on the current layer.

Parameters
aOrigincircle origin
aRadcircle radius
aDeEmphasiseddraw the circle de-emphasised

Definition at line 57 of file draw_context.cpp.

References color, deemphasise(), KIGFX::GAL::DrawCircle(), KIGFX::RENDER_SETTINGS::GetLayerColor(), m_currLayer, m_gal, m_lineWidth, m_render_settings, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

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

◆ DrawCircleDashed()

void DRAW_CONTEXT::DrawCircleDashed ( const VECTOR2I aOrigin,
double  aRad,
double  aStepAngle,
double  aFillAngle,
bool  aDeEmphasised 
)

Draw a dashed preview circle on the current layer.

Parameters
aOrigincircle origin
aRadcircle radius
aStepAngledash step angle
aFillAngledash fill angle
aDeEmphasiseddraw the circle de-emphasised

Definition at line 69 of file draw_context.cpp.

References color, deemphasise(), DEGREES_T, KIGFX::GAL::DrawArc(), KIGFX::RENDER_SETTINGS::GetLayerColor(), m_currLayer, m_gal, m_lineWidth, m_render_settings, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ DrawLine()

void DRAW_CONTEXT::DrawLine ( const VECTOR2I aStart,
const VECTOR2I aEnd,
bool  aDeEmphasised 
)

Draw a simple line on the current layer.

Parameters
aStartline start point
aEndline end point
aDeEmphasiseddraw the line de-emphasised

Definition at line 87 of file draw_context.cpp.

References deemphasise(), KIGFX::GAL::DrawLine(), KIGFX::RENDER_SETTINGS::GetLayerColor(), m_currLayer, m_gal, m_lineWidth, m_render_settings, KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

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

◆ DrawLineDashed()

void DRAW_CONTEXT::DrawLineDashed ( const VECTOR2I aStart,
const VECTOR2I aEn,
int  aDashStep,
int  aDashFill,
bool  aDeEmphasised 
)

Draw a dashed line on the current layer.

Parameters
aStartline start point
aEndline end point
aDashStepdash step distance
aDashFilldash fill distance
aDeEmphasiseddraw the line de-emphasised

Definition at line 98 of file draw_context.cpp.

References deemphasise(), delta, KIGFX::GAL::DrawLine(), KIGFX::RENDER_SETTINGS::GetLayerColor(), m_currLayer, m_gal, m_lineWidth, m_render_settings, KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

Referenced by PCB_TUNING_PATTERN::ViewDraw().

◆ DrawLineWithAngleHighlight()

void DRAW_CONTEXT::DrawLineWithAngleHighlight ( const VECTOR2I aStart,
const VECTOR2I aEnd,
bool  aDeEmphasised 
)

Draw a straight line on the current layer, with a special highlight when the line angle is a multiple of 45 degrees.

Parameters
aStartline start point
aEndline end point
aDeEmphasiseddraw the line de-emphasised

Definition at line 120 of file draw_context.cpp.

References angleIsSpecial(), deemphasise(), KIGFX::GAL::DrawLine(), KIGFX::RENDER_SETTINGS::GetLayerColor(), getSpecialAngleColour(), m_currLayer, m_gal, m_lineWidth, m_render_settings, KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

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

◆ getSpecialAngleColour()

COLOR4D DRAW_CONTEXT::getSpecialAngleColour ( ) const
private

The GAL to draw into.

Returns
the colour to use for "special" angles

Definition at line 136 of file draw_context.cpp.

References KIGFX::RENDER_SETTINGS::IsBackgroundDark(), and m_render_settings.

Referenced by DrawLineWithAngleHighlight().

Member Data Documentation

◆ m_currLayer

GAL_LAYER_ID KIGFX::PREVIEW::DRAW_CONTEXT::m_currLayer
private

◆ m_gal

KIGFX::GAL& KIGFX::PREVIEW::DRAW_CONTEXT::m_gal
private

◆ m_lineWidth

float KIGFX::PREVIEW::DRAW_CONTEXT::m_lineWidth
private

The line width to use for items.

Definition at line 129 of file draw_context.h.

Referenced by DrawCircle(), DrawCircleDashed(), DrawLine(), DrawLineDashed(), and DrawLineWithAngleHighlight().

◆ m_render_settings

const KIGFX::RENDER_SETTINGS& KIGFX::PREVIEW::DRAW_CONTEXT::m_render_settings
private

The current layer to draw onto.

Definition at line 123 of file draw_context.h.

Referenced by DrawCircle(), DrawCircleDashed(), DrawLine(), DrawLineDashed(), DrawLineWithAngleHighlight(), and getSpecialAngleColour().


The documentation for this class was generated from the following files: