KiCad PCB EDA Suite
STROKE_PARAMS_PARSER Class Reference

#include <stroke_params.h>

Inheritance diagram for STROKE_PARAMS_PARSER:

Public Member Functions

 STROKE_PARAMS_PARSER (LINE_READER *aReader, int iuPerMM)
 
void ParseStroke (STROKE_PARAMS &aStroke)
 

Private Member Functions

int parseInt (const char *aText)
 
double parseDouble (const char *aText)
 

Private Attributes

int m_iuPerMM
 

Detailed Description

Definition at line 134 of file stroke_params.h.

Constructor & Destructor Documentation

◆ STROKE_PARAMS_PARSER()

STROKE_PARAMS_PARSER::STROKE_PARAMS_PARSER ( LINE_READER aReader,
int  iuPerMM 
)
inline

Definition at line 137 of file stroke_params.h.

137 :
138 STROKE_PARAMS_LEXER( aReader ),
139 m_iuPerMM( iuPerMM )
140 {
141 }

Member Function Documentation

◆ parseDouble()

double STROKE_PARAMS_PARSER::parseDouble ( const char *  aText)
private

Definition at line 310 of file stroke_params.cpp.

311{
312 T token = NextTok();
313
314 if( token != T_NUMBER )
315 Expecting( aText );
316
317 return DSNLEXER::parseDouble();
318}
double parseDouble()
Parse the current token as an ASCII numeric string with possible leading whitespace into a double pre...
Definition: dsnlexer.cpp:825

References DSNLEXER::parseDouble().

Referenced by ParseStroke().

◆ parseInt()

int STROKE_PARAMS_PARSER::parseInt ( const char *  aText)
private

Definition at line 299 of file stroke_params.cpp.

300{
301 T token = NextTok();
302
303 if( token != T_NUMBER )
304 Expecting( aText );
305
306 return atoi( CurText() );
307}

Referenced by ParseStroke().

◆ ParseStroke()

void STROKE_PARAMS_PARSER::ParseStroke ( STROKE_PARAMS aStroke)

Definition at line 242 of file stroke_params.cpp.

243{
244 for( T token = NextTok(); token != T_RIGHT; token = NextTok() )
245 {
246 if( token != T_LEFT )
247 Expecting( T_LEFT );
248
249 token = NextTok();
250
251 switch( token )
252 {
253 case T_width:
254 aStroke.SetWidth( parseDouble( "stroke width" ) * m_iuPerMM );
255 NeedRIGHT();
256 break;
257
258 case T_type:
259 {
260 token = NextTok();
261
262 switch( token )
263 {
264 case T_dash: aStroke.SetPlotStyle( PLOT_DASH_TYPE::DASH ); break;
265 case T_dot: aStroke.SetPlotStyle( PLOT_DASH_TYPE::DOT ); break;
266 case T_dash_dot: aStroke.SetPlotStyle( PLOT_DASH_TYPE::DASHDOT ); break;
267 case T_dash_dot_dot: aStroke.SetPlotStyle( PLOT_DASH_TYPE::DASHDOTDOT ); break;
268 case T_solid: aStroke.SetPlotStyle( PLOT_DASH_TYPE::SOLID ); break;
269 case T_default: aStroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); break;
270 default:
271 Expecting( "solid, dash, dash_dot, dash_dot_dot, dot or default" );
272 }
273
274 NeedRIGHT();
275 break;
276 }
277
278 case T_color:
279 {
281
282 color.r = parseInt( "red" ) / 255.0;
283 color.g = parseInt( "green" ) / 255.0;
284 color.b = parseInt( "blue" ) / 255.0;
285 color.a = Clamp( parseDouble( "alpha" ), 0.0, 1.0 );
286
287 aStroke.SetColor( color );
288 NeedRIGHT();
289 break;
290 }
291
292 default:
293 Expecting( "width, type, or color" );
294 }
295 }
296}
int color
Definition: DXF_plotter.cpp:57
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
int parseInt(const char *aText)
double parseDouble(const char *aText)
void SetWidth(int aWidth)
Definition: stroke_params.h:99
void SetColor(const KIGFX::COLOR4D &aColor)
void SetPlotStyle(PLOT_DASH_TYPE aPlotStyle)
constexpr T Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.
Definition: util.h:64

References Clamp(), color, DASH, DASHDOT, DASHDOTDOT, DEFAULT, DOT, m_iuPerMM, parseDouble(), parseInt(), STROKE_PARAMS::SetColor(), STROKE_PARAMS::SetPlotStyle(), STROKE_PARAMS::SetWidth(), and SOLID.

Referenced by PCB_PARSER::parseFP_SHAPE(), PCB_PARSER::parseFP_TEXTBOX(), PCB_PARSER::parsePCB_SHAPE(), PCB_PARSER::parsePCB_TEXTBOX(), and SCH_SEXPR_PARSER::parseStroke().

Member Data Documentation

◆ m_iuPerMM

int STROKE_PARAMS_PARSER::m_iuPerMM
private

Definition at line 150 of file stroke_params.h.

Referenced by ParseStroke().


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