7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 14:50:11 +00:00

STROKE_PARAMS: Separate parser into own header

Again, the main object doesn't need to drag the lexer
into the header and expose it to all users. It's used only
in the sch/pcb parser files.
This commit is contained in:
John Beard 2024-10-03 23:06:49 +01:00
parent c14e8aea89
commit 4582bf85b5
5 changed files with 60 additions and 34 deletions

View File

@ -16,19 +16,22 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <macros.h>
#include "stroke_params.h"
#include "stroke_params_parser.h"
#include <base_units.h>
#include <charconv>
#include <string_utils.h>
#include <render_settings.h>
#include <geometry/geometry_utils.h>
#include <geometry/shape.h>
#include <geometry/shape_rect.h>
#include <geometry/shape_segment.h>
#include <geometry/shape_simple.h>
#include <geometry/geometry_utils.h>
#include <stroke_params.h>
#include <macros.h>
#include <trigo.h>
#include <widgets/msgpanel.h>
#include "geometry/shape_rect.h"
using namespace STROKEPARAMS_T;

View File

@ -59,12 +59,13 @@
#include <sch_junction.h>
#include <sch_no_connect.h>
#include <sch_screen.h>
#include <sch_shape.h>
#include <sch_sheet_pin.h>
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h>
#include <stroke_params_parser.h>
#include <template_fieldnames.h>
#include <trigo.h>
#include <progress_reporter.h>
#include <sch_shape.h>
#include <sim/sim_model.h>

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -21,8 +21,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef STROKE_PARAMS_H
#define STROKE_PARAMS_H
#pragma once
#include <map>
#include <bitmaps.h>
@ -30,8 +29,8 @@
#include <gal/color4d.h>
#include <wx/translation.h>
#include <geometry/shape.h>
#include <stroke_params_lexer.h>
class OUTPUTFORMATTER;
class STROKE_PARAMS_LEXER;
class MSG_PANEL_ITEM;
@ -122,26 +121,3 @@ private:
LINE_STYLE m_lineStyle;
KIGFX::COLOR4D m_color;
};
class STROKE_PARAMS_PARSER : public STROKE_PARAMS_LEXER
{
public:
STROKE_PARAMS_PARSER( LINE_READER* aReader, int iuPerMM ) :
STROKE_PARAMS_LEXER( aReader ),
m_iuPerMM( iuPerMM )
{
}
void ParseStroke( STROKE_PARAMS& aStroke );
private:
int parseInt( const char* aText );
double parseDouble( const char* aText );
private:
int m_iuPerMM;
};
#endif // STROKE_PARAMS_H

View File

@ -0,0 +1,45 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma once
#include <stroke_params.h>
#include <stroke_params_lexer.h>
class STROKE_PARAMS_PARSER : public STROKE_PARAMS_LEXER
{
public:
STROKE_PARAMS_PARSER( LINE_READER* aReader, int iuPerMM ) :
STROKE_PARAMS_LEXER( aReader ), m_iuPerMM( iuPerMM )
{
}
void ParseStroke( STROKE_PARAMS& aStroke );
private:
int parseInt( const char* aText );
double parseDouble( const char* aText );
private:
int m_iuPerMM;
};

View File

@ -66,6 +66,7 @@
#include <convert_basic_shapes_to_polygon.h> // for RECT_CHAMFER_POSITIONS definition
#include <math/util.h> // KiROUND, Clamp
#include <string_utils.h>
#include <stroke_params_parser.h>
#include <wx/log.h>
#include <progress_reporter.h>
#include <board_stackup_manager/stackup_predefined_prms.h>
@ -5556,7 +5557,7 @@ void PCB_IO_KICAD_SEXPR_PARSER::parsePadstack( PAD* aPad )
{
case T_shape:
token = NextTok();
switch( token )
{
case T_circle:
@ -5588,7 +5589,7 @@ void PCB_IO_KICAD_SEXPR_PARSER::parsePadstack( PAD* aPad )
default:
Expecting( "circle, rectangle, roundrect, oval, trapezoid or custom" );
}
NeedRIGHT();
break;