Add dashed lines and circles to preview draw context.
This commit is contained in:
parent
de0c1218c3
commit
113208455d
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -66,6 +66,24 @@ void DRAW_CONTEXT::DrawCircle( const VECTOR2I& aOrigin, double aRad, bool aDeEmp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DRAW_CONTEXT::DrawCircleDashed( const VECTOR2I& aOrigin, double aRad, double aStepAngle,
|
||||||
|
double aFillAngle, bool aDeEmphasised )
|
||||||
|
{
|
||||||
|
const COLOR4D& color = m_render_settings.GetLayerColor( m_currLayer );
|
||||||
|
|
||||||
|
m_gal.SetLineWidth( m_lineWidth );
|
||||||
|
m_gal.SetStrokeColor( deemphasise( color, aDeEmphasised ) );
|
||||||
|
m_gal.SetIsStroke( true );
|
||||||
|
m_gal.SetIsFill( false );
|
||||||
|
|
||||||
|
for( int i = 0; i < 360; i += aStepAngle )
|
||||||
|
{
|
||||||
|
m_gal.DrawArc( aOrigin, aRad, EDA_ANGLE( i, DEGREES_T ),
|
||||||
|
EDA_ANGLE( i + aFillAngle, DEGREES_T ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DRAW_CONTEXT::DrawLine( const VECTOR2I& aStart, const VECTOR2I& aEnd, bool aDeEmphasised )
|
void DRAW_CONTEXT::DrawLine( const VECTOR2I& aStart, const VECTOR2I& aEnd, bool aDeEmphasised )
|
||||||
{
|
{
|
||||||
COLOR4D strokeColor = m_render_settings.GetLayerColor( m_currLayer );
|
COLOR4D strokeColor = m_render_settings.GetLayerColor( m_currLayer );
|
||||||
|
@ -77,6 +95,28 @@ void DRAW_CONTEXT::DrawLine( const VECTOR2I& aStart, const VECTOR2I& aEnd, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DRAW_CONTEXT::DrawLineDashed( const VECTOR2I& aStart, const VECTOR2I& aEnd, int aDashStep,
|
||||||
|
int aDashFill, bool aDeEmphasised )
|
||||||
|
{
|
||||||
|
COLOR4D strokeColor = m_render_settings.GetLayerColor( m_currLayer );
|
||||||
|
|
||||||
|
m_gal.SetLineWidth( m_lineWidth );
|
||||||
|
m_gal.SetIsStroke( true );
|
||||||
|
m_gal.SetStrokeColor( deemphasise( strokeColor, aDeEmphasised ) );
|
||||||
|
|
||||||
|
VECTOR2I delta = aEnd - aStart;
|
||||||
|
int vecLen = delta.EuclideanNorm();
|
||||||
|
|
||||||
|
for( int i = 0; i < vecLen; i += aDashStep )
|
||||||
|
{
|
||||||
|
VECTOR2I a = aStart + delta.Resize( i );
|
||||||
|
VECTOR2I b = aStart + delta.Resize( std::min( i + aDashFill, vecLen ) );
|
||||||
|
|
||||||
|
m_gal.DrawLine( a, b );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DRAW_CONTEXT::DrawLineWithAngleHighlight( const VECTOR2I& aStart, const VECTOR2I& aEnd,
|
void DRAW_CONTEXT::DrawLineWithAngleHighlight( const VECTOR2I& aStart, const VECTOR2I& aEnd,
|
||||||
bool aDeEmphasised )
|
bool aDeEmphasised )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Kicad Developers, see change_log.txt for contributors.
|
* Copyright (C) 2017-2023 Kicad Developers, see change_log.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -55,6 +55,17 @@ namespace PREVIEW
|
||||||
*/
|
*/
|
||||||
void DrawCircle( const VECTOR2I& aOrigin, double aRad, bool aDeEmphasised );
|
void DrawCircle( const VECTOR2I& aOrigin, double aRad, bool aDeEmphasised );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a dashed preview circle on the current layer
|
||||||
|
*
|
||||||
|
* @param aOrigin circle origin
|
||||||
|
* @param aRad circle radius
|
||||||
|
* @param aStepAngle dash step angle
|
||||||
|
* @param aFillAngle dash fill angle
|
||||||
|
* @param aDeEmphasised draw the circle de-emphasised
|
||||||
|
*/
|
||||||
|
void DrawCircleDashed( const VECTOR2I& aOrigin, double aRad, double aStepAngle,
|
||||||
|
double aFillAngle, bool aDeEmphasised );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a simple line on the current layer.
|
* Draw a simple line on the current layer.
|
||||||
|
@ -65,6 +76,17 @@ namespace PREVIEW
|
||||||
*/
|
*/
|
||||||
void DrawLine( const VECTOR2I& aStart, const VECTOR2I& aEnd, bool aDeEmphasised );
|
void DrawLine( const VECTOR2I& aStart, const VECTOR2I& aEnd, bool aDeEmphasised );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a dashed line on the current layer.
|
||||||
|
*
|
||||||
|
* @param aStart line start point
|
||||||
|
* @param aEnd line end point
|
||||||
|
* @param aDashStep dash step distance
|
||||||
|
* @param aDashFill dash fill distance
|
||||||
|
* @param aDeEmphasised draw the line de-emphasised
|
||||||
|
*/
|
||||||
|
void DrawLineDashed( const VECTOR2I& aStart, const VECTOR2I& aEn, int aDashStep,
|
||||||
|
int aDashFill, bool aDeEmphasised );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a straight line on the current layer, with a special highlight when
|
* Draw a straight line on the current layer, with a special highlight when
|
||||||
|
|
Loading…
Reference in New Issue