36using namespace STROKEPARAMS_T;
50 const std::function<
void(
const VECTOR2I& a,
const VECTOR2I& b )>& aStroker )
52 double strokes[6] = { aWidth * 1.0, aWidth * 1.0, aWidth * 1.0, aWidth * 1.0, aWidth * 1.0,
58 case LINE_STYLE::DASH:
68 case LINE_STYLE::DASHDOT:
75 case LINE_STYLE::DASHDOTDOT:
88 switch( aShape->
Type() )
127 double theta = atan2( end.
y - start.
y, end.
x - start.
x );
129 for(
size_t i = 0; i < 10000; ++i )
133 VECTOR2D next( start.
x + strokes[ i % wrapAround ] * cos( theta ),
134 start.
y + strokes[ i % wrapAround ] * sin( theta ) );
142 else if( i % 2 == 0 )
156 double C = 2.0 * M_PI * r;
163 if( arcEndAngle == startAngle )
166 if( startAngle > arcEndAngle )
174 wxASSERT( startAngle < arcEndAngle );
178 for(
size_t i = 0; i < 10000 && startAngle < arcEndAngle; ++i )
181 EDA_ANGLE endAngle = std::min( startAngle + theta, arcEndAngle );
185 if( ( ( aLineStyle == LINE_STYLE::DASHDOT || aLineStyle == LINE_STYLE::DASHDOTDOT )
186 && i % wrapAround == 0 )
187 || aLineStyle == LINE_STYLE::DASH )
189 for(
EDA_ANGLE currentAngle = startAngle; currentAngle < endAngle;
190 currentAngle += angleIncrementInRadians )
193 center.
y +
KiROUND( r * currentAngle.Sin() ) );
196 EDA_ANGLE nextAngle = currentAngle + angleIncrementInRadians;
198 if( nextAngle > endAngle )
200 nextAngle = endAngle;
220 startAngle = endAngle;
242 case LINE_STYLE::DASH: token = wxT(
"dash" );
break;
243 case LINE_STYLE::DOT: token = wxT(
"dot" );
break;
244 case LINE_STYLE::DASHDOT: token = wxT(
"dash_dot" );
break;
245 case LINE_STYLE::DASHDOTDOT: token = wxT(
"dash_dot_dot" );
break;
246 case LINE_STYLE::SOLID: token = wxT(
"solid" );
break;
247 case LINE_STYLE::DEFAULT: token = wxT(
"default" );
break;
255 std::vector<MSG_PANEL_ITEM>& aList,
256 bool aIncludeStyle,
bool aIncludeWidth )
260 wxString msg =
_(
"Default" );
262 for(
const auto& [ lineStyle, lineStyleDesc ] :
lineTypeNames )
266 msg = lineStyleDesc.name;
271 aList.emplace_back(
_(
"Line Style" ), msg );
280 int aNestLevel )
const
282 wxASSERT( aFormatter !=
nullptr );
286 aFormatter->
Print( aNestLevel,
"(stroke (width %s) (type %s))",
292 aFormatter->
Print( aNestLevel,
"(stroke (width %s) (type %s) (color %d %d %d %s))",
305 for( T token = NextTok(); token != T_RIGHT; token = NextTok() )
307 if( token != T_LEFT )
325 case T_dash: aStroke.
SetLineStyle( LINE_STYLE::DASH );
break;
326 case T_dot: aStroke.
SetLineStyle( LINE_STYLE::DOT );
break;
327 case T_dash_dot: aStroke.
SetLineStyle( LINE_STYLE::DASHDOT );
break;
328 case T_dash_dot_dot: aStroke.
SetLineStyle( LINE_STYLE::DASHDOTDOT );
break;
329 case T_solid: aStroke.
SetLineStyle( LINE_STYLE::SOLID );
break;
330 case T_default: aStroke.
SetLineStyle( LINE_STYLE::DEFAULT );
break;
332 Expecting(
"solid, dash, dash_dot, dash_dot_dot, dot or default" );
354 Expecting(
"width, type, or color" );
364 if( token != T_NUMBER )
367 return atoi( CurText() );
375 if( token != T_NUMBER )
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
double parseDouble()
Parse the current token as an ASCII numeric string with possible leading whitespace into a double pre...
A color representation with 4 components: red, green, blue, alpha.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
double GetGapLength(int aLineWidth) const
double GetDotLength(int aLineWidth) const
double GetDashLength(int aLineWidth) const
const VECTOR2I & GetP1() const
const VECTOR2I & GetP0() const
const VECTOR2I & GetCenter() const
SHAPE_TYPE Type() const
Return the type of the shape.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual const SEG GetSegment(int aIndex) const override
int SegmentCount() const
Return the number of segments in this line chain.
const SEG & GetSeg() const
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
virtual const SEG GetSegment(int aIndex) const override
virtual size_t GetSegmentCount() const override
An abstract shape on 2D plane.
int parseInt(const char *aText)
void ParseStroke(STROKE_PARAMS &aStroke)
double parseDouble(const char *aText)
Simple container to manage line stroke parameters.
void SetLineStyle(LINE_STYLE aLineStyle)
void SetWidth(int aWidth)
void SetColor(const KIGFX::COLOR4D &aColor)
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale, int nestLevel) const
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
static wxString GetLineStyleToken(LINE_STYLE aStyle)
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_360
a few functions useful in geometry calculations.
bool ClipLine(const BOX2I *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
#define UNIMPLEMENTED_FOR(type)
Message panel definition file.
KICOMMON_API std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
@ SH_RECT
axis-aligned rectangle
@ SH_SIMPLE
simple polygon
static wxString SHAPE_TYPE_asString(SHAPE_TYPE a)
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
const std::map< LINE_STYLE, struct LINE_STYLE_DESC > lineTypeNames
const std::map< LINE_STYLE, struct LINE_STYLE_DESC > lineTypeNames
LINE_STYLE
Dashed line types.
VECTOR2< int32_t > VECTOR2I