32using namespace STROKEPARAMS_T;
48 double strokes[6] = { aWidth * 1.0, aWidth * 1.0, aWidth * 1.0, aWidth * 1.0, aWidth * 1.0,
54 case PLOT_DASH_TYPE::DASH:
59 case PLOT_DASH_TYPE::DOT:
64 case PLOT_DASH_TYPE::DASHDOT:
71 case PLOT_DASH_TYPE::DASHDOTDOT:
84 switch( aShape->
Type() )
108 double theta = atan2( end.
y - start.
y, end.
x - start.
x );
110 for(
size_t i = 0; i < 10000; ++i )
114 VECTOR2D next( start.
x + strokes[ i % wrapAround ] * cos( theta ),
115 start.
y + strokes[ i % wrapAround ] * sin( theta ) );
123 else if( i % 2 == 0 )
136 double C = 2.0 * M_PI * r;
143 if( arcEndAngle == startAngle )
146 if( startAngle > arcEndAngle )
154 wxASSERT( startAngle < arcEndAngle );
156 for(
size_t i = 0; i < 10000 && startAngle < arcEndAngle; ++i )
159 EDA_ANGLE endAngle = std::min( startAngle + theta, arcEndAngle );
163 VECTOR2I a( center.
x + r * startAngle.
Cos(), center.
y + r * startAngle.
Sin() );
169 startAngle = endAngle;
190 case PLOT_DASH_TYPE::DASH: token = wxT(
"dash" );
break;
191 case PLOT_DASH_TYPE::DOT: token = wxT(
"dot" );
break;
192 case PLOT_DASH_TYPE::DASHDOT: token = wxT(
"dash_dot" );
break;
193 case PLOT_DASH_TYPE::DASHDOTDOT: token = wxT(
"dash_dot_dot" );
break;
194 case PLOT_DASH_TYPE::SOLID: token = wxT(
"solid" );
break;
195 case PLOT_DASH_TYPE::DEFAULT: token = wxT(
"default" );
break;
203 std::vector<MSG_PANEL_ITEM>& aList,
204 bool aIncludeStyle,
bool aIncludeWidth )
208 wxString lineStyle =
_(
"Default" );
210 for(
const std::pair<const PLOT_DASH_TYPE, lineTypeStruct>& typeEntry :
lineTypeNames )
214 lineStyle = typeEntry.second.name;
219 aList.emplace_back(
_(
"Line Style" ), lineStyle );
228 int aNestLevel )
const
230 wxASSERT( aFormatter !=
nullptr );
234 aFormatter->
Print( aNestLevel,
"(stroke (width %s) (type %s))",
240 aFormatter->
Print( aNestLevel,
"(stroke (width %s) (type %s) (color %d %d %d %s))",
253 for( T token = NextTok(); token != T_RIGHT; token = NextTok() )
255 if( token != T_LEFT )
273 case T_dash: aStroke.
SetPlotStyle( PLOT_DASH_TYPE::DASH );
break;
274 case T_dot: aStroke.
SetPlotStyle( PLOT_DASH_TYPE::DOT );
break;
275 case T_dash_dot: aStroke.
SetPlotStyle( PLOT_DASH_TYPE::DASHDOT );
break;
276 case T_dash_dot_dot: aStroke.
SetPlotStyle( PLOT_DASH_TYPE::DASHDOTDOT );
break;
277 case T_solid: aStroke.
SetPlotStyle( PLOT_DASH_TYPE::SOLID );
break;
278 case T_default: aStroke.
SetPlotStyle( PLOT_DASH_TYPE::DEFAULT );
break;
280 Expecting(
"solid, dash, dash_dot, dash_dot_dot, dot or default" );
302 Expecting(
"width, type, or color" );
312 if( token != T_NUMBER )
315 return atoi( CurText() );
323 if( token != T_NUMBER )
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
VECTOR2I GetCenter() const
const VECTOR2I & GetP0() const
SHAPE_TYPE Type() const
Return the type of the shape.
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 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)
static void Stroke(const SHAPE *aShape, PLOT_DASH_TYPE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, std::function< void(const VECTOR2I &a, const VECTOR2I &b)> aStroker)
KIGFX::COLOR4D GetColor() const
PLOT_DASH_TYPE GetPlotStyle() const
static wxString GetLineStyleToken(PLOT_DASH_TYPE aStyle)
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale, int nestLevel) const
void SetPlotStyle(PLOT_DASH_TYPE aPlotStyle)
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
static constexpr EDA_ANGLE & ANGLE_360
static constexpr EDA_ANGLE & ANGLE_0
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_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< PLOT_DASH_TYPE, struct lineTypeStruct > lineTypeNames
PLOT_DASH_TYPE
Dashed line types.
const std::map< PLOT_DASH_TYPE, struct lineTypeStruct > lineTypeNames
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
constexpr T Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.