Add const specifiers

This commit is contained in:
Werni 2020-11-18 19:50:36 +00:00 committed by Ian McInerney
parent f005335743
commit 0e44f5128c
44 changed files with 208 additions and 205 deletions

View File

@ -162,14 +162,14 @@ void DIALOG_SHIM::setSizeInDU( int x, int y )
} }
int DIALOG_SHIM::horizPixelsFromDU( int x ) int DIALOG_SHIM::horizPixelsFromDU( int x ) const
{ {
wxSize sz( x, 0 ); wxSize sz( x, 0 );
return ConvertDialogToPixels( sz ).x; return ConvertDialogToPixels( sz ).x;
} }
int DIALOG_SHIM::vertPixelsFromDU( int y ) int DIALOG_SHIM::vertPixelsFromDU( int y ) const
{ {
wxSize sz( 0, y ); wxSize sz( 0, y );
return ConvertDialogToPixels( sz ).y; return ConvertDialogToPixels( sz ).y;

View File

@ -379,13 +379,13 @@ void WX_HTML_REPORT_PANEL::SetVisibleSeverities( int aSeverities )
} }
int WX_HTML_REPORT_PANEL::GetVisibleSeverities() int WX_HTML_REPORT_PANEL::GetVisibleSeverities() const
{ {
return m_severities; return m_severities;
} }
void WX_HTML_REPORT_PANEL::SetFileName( wxString& aReportFileName ) void WX_HTML_REPORT_PANEL::SetFileName( const wxString& aReportFileName )
{ {
m_reportFileName = aReportFileName; m_reportFileName = aReportFileName;
} }

View File

@ -85,7 +85,7 @@ public:
///> @return the visible severity filter. ///> @return the visible severity filter.
///> If the m_showAll option is set, the mask is < 0 ///> If the m_showAll option is set, the mask is < 0
int GetVisibleSeverities(); int GetVisibleSeverities() const;
///> If true prints Info: at the beginning of each Info severity line (Default) ///> If true prints Info: at the beginning of each Info severity line (Default)
void SetPrintInfo( bool aPrintInfo ); void SetPrintInfo( bool aPrintInfo );
@ -95,7 +95,7 @@ public:
void SetShowSeverity( SEVERITY aSeverity, bool aValue ); void SetShowSeverity( SEVERITY aSeverity, bool aValue );
///> Set the report full file name to the string ///> Set the report full file name to the string
void SetFileName( wxString& aReportFileName ); void SetFileName( const wxString& aReportFileName );
///> @return reference to the current report fill file name string. ///> @return reference to the current report fill file name string.
wxString& GetFileName( void ); wxString& GetFileName( void );

View File

@ -225,7 +225,7 @@ LINE_READER* DSNLEXER::PopReader()
} }
int DSNLEXER::findToken( const std::string& tok ) int DSNLEXER::findToken( const std::string& tok ) const
{ {
KEYWORD_MAP::const_iterator it = keyword_hash.find( tok.c_str() ); KEYWORD_MAP::const_iterator it = keyword_hash.find( tok.c_str() );
@ -280,7 +280,7 @@ const char* DSNLEXER::Syntax( int aTok )
} }
const char* DSNLEXER::GetTokenText( int aTok ) const char* DSNLEXER::GetTokenText( int aTok ) const
{ {
const char* ret; const char* ret;
@ -299,7 +299,7 @@ const char* DSNLEXER::GetTokenText( int aTok )
} }
wxString DSNLEXER::GetTokenString( int aTok ) wxString DSNLEXER::GetTokenString( int aTok ) const
{ {
wxString ret; wxString ret;
@ -314,11 +314,11 @@ bool DSNLEXER::IsSymbol( int aTok )
// This is static and not inline to reduce code space. // This is static and not inline to reduce code space.
// if aTok is >= 0, then it is a coincidental match to a keyword. // if aTok is >= 0, then it is a coincidental match to a keyword.
return aTok==DSN_SYMBOL || aTok==DSN_STRING || aTok>=0; return aTok == DSN_SYMBOL || aTok == DSN_STRING || aTok >= 0;
} }
void DSNLEXER::Expecting( int aTok ) void DSNLEXER::Expecting( int aTok ) const
{ {
wxString errText = wxString::Format( wxString errText = wxString::Format(
_( "Expecting %s" ), GetTokenString( aTok ) ); _( "Expecting %s" ), GetTokenString( aTok ) );
@ -326,7 +326,7 @@ void DSNLEXER::Expecting( int aTok )
} }
void DSNLEXER::Expecting( const char* text ) void DSNLEXER::Expecting( const char* text ) const
{ {
wxString errText = wxString::Format( wxString errText = wxString::Format(
_( "Expecting '%s'" ), wxString::FromUTF8( text ) ); _( "Expecting '%s'" ), wxString::FromUTF8( text ) );
@ -334,7 +334,7 @@ void DSNLEXER::Expecting( const char* text )
} }
void DSNLEXER::Unexpected( int aTok ) void DSNLEXER::Unexpected( int aTok ) const
{ {
wxString errText = wxString::Format( wxString errText = wxString::Format(
_( "Unexpected %s" ), GetTokenString( aTok ) ); _( "Unexpected %s" ), GetTokenString( aTok ) );
@ -350,7 +350,7 @@ void DSNLEXER::Duplicate( int aTok )
} }
void DSNLEXER::Unexpected( const char* text ) void DSNLEXER::Unexpected( const char* text ) const
{ {
wxString errText = wxString::Format( wxString errText = wxString::Format(
_( "Unexpected '%s'" ), wxString::FromUTF8( text ) ); _( "Unexpected '%s'" ), wxString::FromUTF8( text ) );

View File

@ -75,7 +75,7 @@ wxString GbrMakeCreationDateAttributeString( GBR_NC_STRING_FORMAT aFormat )
} }
wxString GbrMakeProjectGUIDfromString( wxString& aText ) wxString GbrMakeProjectGUIDfromString( const wxString& aText )
{ {
/* Gerber GUID format should be RFC4122 Version 1 or 4. /* Gerber GUID format should be RFC4122 Version 1 or 4.
* See en.wikipedia.org/wiki/Universally_unique_identifier * See en.wikipedia.org/wiki/Universally_unique_identifier
@ -482,14 +482,14 @@ wxString ConvertNotAllowedCharsInGerber( const wxString& aString, bool aAllowUtf
} }
std::string GBR_DATA_FIELD::GetGerberString() std::string GBR_DATA_FIELD::GetGerberString() const
{ {
wxString converted; wxString converted;
if( !m_field.IsEmpty() ) if( !m_field.IsEmpty() )
converted = ConvertNotAllowedCharsInGerber( m_field, m_useUTF8, m_escapeString ); converted = ConvertNotAllowedCharsInGerber( m_field, m_useUTF8, m_escapeString );
// Convert the char string to std::string. Be carefull when converting awxString to // Convert the char string to std::string. Be carefull when converting a wxString to
// a std::string: using static_cast<const char*> is mandatory // a std::string: using static_cast<const char*> is mandatory
std::string txt = static_cast<const char*>( converted.utf8_str() ); std::string txt = static_cast<const char*>( converted.utf8_str() );
@ -525,7 +525,7 @@ std::string FormatStringToGerber( const wxString& aString )
#define NO_PAD_NAME wxT( "" ) // pad name of pads without pad name/number (not normalized) #define NO_PAD_NAME wxT( "" ) // pad name of pads without pad name/number (not normalized)
bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttributes, bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttributes,
GBR_NETLIST_METADATA* aData, bool& aClearPreviousAttributes, const GBR_NETLIST_METADATA* aData, bool& aClearPreviousAttributes,
bool aUseX1StructuredComment ) bool aUseX1StructuredComment )
{ {
aClearPreviousAttributes = false; aClearPreviousAttributes = false;

View File

@ -32,7 +32,7 @@ namespace UTIL {
struct equals { struct equals {
equals( const T& val ) : val_( val ) {} equals( const T& val ) : val_( val ) {}
bool operator()( const T& val ) bool operator()( const T& val ) const
{ {
return val == val_; return val == val_;
} }

View File

@ -75,7 +75,7 @@ inline void scanList( PTREE* aTree, DSNLEXER* aLexer )
} }
inline void scanAtom( PTREE* aTree, DSNLEXER* aLexer ) inline void scanAtom( PTREE* aTree, const DSNLEXER* aLexer )
{ {
const char* key = aLexer->CurText(); const char* key = aLexer->CurText();
@ -109,13 +109,13 @@ void Scan( PTREE* aTree, DSNLEXER* aLexer )
//-----<Format>------------------------------------------------------------------ //-----<Format>------------------------------------------------------------------
inline bool isAtom( CPTREE& aTree ) inline bool isAtom( const CPTREE& aTree )
{ {
return aTree.size()==0 && aTree.data().size()==0; return aTree.size() == 0 && aTree.data().size() == 0;
} }
inline bool isLast( CPTREE& aTree, CITER it ) inline bool isLast( const CPTREE& aTree, CITER it )
{ {
CITER next = it; CITER next = it;
++next; ++next;
@ -131,11 +131,10 @@ inline CITER next( CITER it )
static void formatNode( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, static void formatNode( OUTPUTFORMATTER* out, int aNestLevel, int aCtl,
const std::string& aKey, CPTREE& aTree ); const std::string& aKey, const CPTREE& aTree );
static void formatList( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, CPTREE& aTree ) static void formatList( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, const CPTREE& aTree )
{ {
for( CITER it = aTree.begin(); it != aTree.end(); ++it ) for( CITER it = aTree.begin(); it != aTree.end(); ++it )
{ {
@ -165,7 +164,7 @@ static void formatList( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, CPTREE&
static void formatNode( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, static void formatNode( OUTPUTFORMATTER* out, int aNestLevel, int aCtl,
const std::string& aKey, CPTREE& aTree ) const std::string& aKey, const CPTREE& aTree )
{ {
if( !isAtom( aTree ) ) // is a list, not an atom if( !isAtom( aTree ) ) // is a list, not an atom
@ -198,7 +197,7 @@ static void formatNode( OUTPUTFORMATTER* out, int aNestLevel, int aCtl,
} }
void Format( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, CPTREE& aTree ) void Format( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, const CPTREE& aTree )
{ {
if( aTree.size() == 1 && !aTree.data().size() ) if( aTree.size() == 1 && !aTree.data().size() )
{ {

View File

@ -278,7 +278,7 @@ public:
return res; return res;
} }
void RebuildRows( LIB_PINS& aPins, bool groupByName ) void RebuildRows( const LIB_PINS& aPins, bool groupByName )
{ {
if ( GetView() ) if ( GetView() )
{ {

View File

@ -358,8 +358,8 @@ void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll )
} }
wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxString& aPlotFileName, wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( const wxString& aPlotFileName,
wxString& aExtension, const wxString& aExtension,
REPORTER* aReporter ) REPORTER* aReporter )
{ {
wxString path = ExpandEnvVarSubstitutions( m_outputDirectoryName->GetValue(), &Prj() ); wxString path = ExpandEnvVarSubstitutions( m_outputDirectoryName->GetValue(), &Prj() );

View File

@ -148,6 +148,7 @@ private:
* @return the created file name * @return the created file name
* @throw IO_ERROR on file I/O errors * @throw IO_ERROR on file I/O errors
*/ */
wxFileName createPlotFileName( wxString& aPlotFileName, wxString& aExtension, wxFileName createPlotFileName( const wxString& aPlotFileName,
const wxString& aExtension,
REPORTER* aReporter = NULL ); REPORTER* aReporter = NULL );
}; };

View File

@ -174,7 +174,7 @@ VECTOR2I EE_GRID_HELPER::AlignToWire( const VECTOR2I& aPoint, const SEG& aSeg )
return nearest; return nearest;
} }
VECTOR2I EE_GRID_HELPER::BestDragOrigin( const VECTOR2I &aMousePos, std::vector<SCH_ITEM*>& aItems ) VECTOR2I EE_GRID_HELPER::BestDragOrigin( const VECTOR2I &aMousePos, const std::vector<SCH_ITEM*>& aItems )
{ {
clearAnchors(); clearAnchors();

View File

@ -60,7 +60,7 @@ public:
VECTOR2I AlignToWire( const VECTOR2I& aPoint, const SEG& aSeg ); VECTOR2I AlignToWire( const VECTOR2I& aPoint, const SEG& aSeg );
VECTOR2I BestDragOrigin( const VECTOR2I& aMousePos, std::vector<SCH_ITEM*>& aItem ); VECTOR2I BestDragOrigin( const VECTOR2I& aMousePos, const std::vector<SCH_ITEM*>& aItem );
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, SCH_ITEM* aDraggedItem ); VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, SCH_ITEM* aDraggedItem );
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLayers, VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLayers,

View File

@ -55,7 +55,7 @@ GBR_TO_PCB_EXPORTER::~GBR_TO_PCB_EXPORTER()
} }
bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* aLayerLookUpTable, int aCopperLayers ) bool GBR_TO_PCB_EXPORTER::ExportPcb( const LAYER_NUM* aLayerLookUpTable, int aCopperLayers )
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -138,7 +138,7 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* aLayerLookUpTable, int aCopperLa
} }
void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer ) void GBR_TO_PCB_EXPORTER::export_non_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
{ {
// used when a D_CODE is not found. default D_CODE to draw a flashed item // used when a D_CODE is not found. default D_CODE to draw a flashed item
static D_CODE dummyD_CODE( 0 ); static D_CODE dummyD_CODE( 0 );
@ -252,7 +252,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LA
* the pad gets drawn as a copper polygon, or increase it to the proper size if it has a * the pad gets drawn as a copper polygon, or increase it to the proper size if it has a
* circular, concentric copper flashing. * circular, concentric copper flashing.
*/ */
void GBR_TO_PCB_EXPORTER::collect_hole( GERBER_DRAW_ITEM* aGbrItem ) void GBR_TO_PCB_EXPORTER::collect_hole( const GERBER_DRAW_ITEM* aGbrItem )
{ {
int size = std::min( aGbrItem->m_Size.x, aGbrItem->m_Size.y ); int size = std::min( aGbrItem->m_Size.x, aGbrItem->m_Size.y );
m_vias.emplace_back( aGbrItem->m_Start, size + 1, size ); m_vias.emplace_back( aGbrItem->m_Start, size + 1, size );
@ -279,7 +279,7 @@ void GBR_TO_PCB_EXPORTER::export_via( const EXPORT_VIA& aVia )
} }
void GBR_TO_PCB_EXPORTER::export_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer ) void GBR_TO_PCB_EXPORTER::export_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
{ {
switch( aGbrItem->m_Shape ) switch( aGbrItem->m_Shape )
{ {
@ -313,7 +313,7 @@ void GBR_TO_PCB_EXPORTER::export_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_
} }
void GBR_TO_PCB_EXPORTER::export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer ) void GBR_TO_PCB_EXPORTER::export_segline_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
{ {
wxPoint seg_start, seg_end; wxPoint seg_start, seg_end;
@ -328,7 +328,8 @@ void GBR_TO_PCB_EXPORTER::export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem
} }
void GBR_TO_PCB_EXPORTER::writeCopperLineItem( wxPoint& aStart, wxPoint& aEnd, void GBR_TO_PCB_EXPORTER::writeCopperLineItem( const wxPoint& aStart,
const wxPoint& aEnd,
int aWidth, LAYER_NUM aLayer ) int aWidth, LAYER_NUM aLayer )
{ {
fprintf( m_fp, "(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n", fprintf( m_fp, "(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n",
@ -341,7 +342,7 @@ void GBR_TO_PCB_EXPORTER::writeCopperLineItem( wxPoint& aStart, wxPoint& aEnd,
} }
void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer ) void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
{ {
double a = atan2( (double) ( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y ), double a = atan2( (double) ( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y ),
(double) ( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) ); (double) ( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) );
@ -402,7 +403,7 @@ void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem,
* then we'll enlarge the via to the proper size. Otherwise we create a copper polygon to * then we'll enlarge the via to the proper size. Otherwise we create a copper polygon to
* represent the flashed item (which is presumably a pad). * represent the flashed item (which is presumably a pad).
*/ */
void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( GERBER_DRAW_ITEM* aGbrItem, void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( const GERBER_DRAW_ITEM* aGbrItem,
LAYER_NUM aLayer ) LAYER_NUM aLayer )
{ {
static D_CODE flashed_item_D_CODE( 0 ); static D_CODE flashed_item_D_CODE( 0 );
@ -433,7 +434,7 @@ void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( GERBER_DRAW_ITEM* aGbrItem
} }
void GBR_TO_PCB_EXPORTER::writePcbHeader( LAYER_NUM* aLayerLookUpTable ) void GBR_TO_PCB_EXPORTER::writePcbHeader( const LAYER_NUM* aLayerLookUpTable )
{ {
fprintf( m_fp, "(kicad_pcb (version 4) (host Gerbview \"%s\")\n\n", fprintf( m_fp, "(kicad_pcb (version 4) (host Gerbview \"%s\")\n\n",
TO_UTF8( GetBuildVersion() ) ); TO_UTF8( GetBuildVersion() ) );
@ -512,7 +513,7 @@ void GBR_TO_PCB_EXPORTER::writePcbPolygon( const SHAPE_POLY_SET& aPolys, LAYER_N
} }
void GBR_TO_PCB_EXPORTER::writePcbZoneItem( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer ) void GBR_TO_PCB_EXPORTER::writePcbZoneItem( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
{ {
SHAPE_POLY_SET polys = aGbrItem->m_Polygon; SHAPE_POLY_SET polys = aGbrItem->m_Polygon;
polys.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); polys.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );

View File

@ -64,7 +64,7 @@ public:
* Function ExportPcb * Function ExportPcb
* saves a board from a set of Gerber images. * saves a board from a set of Gerber images.
*/ */
bool ExportPcb( LAYER_NUM* aLayerLookUpTable, int aCopperLayers ); bool ExportPcb( const LAYER_NUM* aLayerLookUpTable, int aCopperLayers );
private: private:
/** /**
@ -72,7 +72,7 @@ private:
* We'll use these later when writing pads & vias. * We'll use these later when writing pads & vias.
* @param aGbrItem * @param aGbrItem
*/ */
void collect_hole( GERBER_DRAW_ITEM* aGbrItem ); void collect_hole( const GERBER_DRAW_ITEM* aGbrItem );
/** /**
* write a via to the board file. * write a via to the board file.
@ -88,7 +88,7 @@ private:
* @param aGbrItem = the Gerber item (line, arc) to export * @param aGbrItem = the Gerber item (line, arc) to export
* @param aLayer = the technical layer to use * @param aLayer = the technical layer to use
*/ */
void export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer ); void export_non_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/** /**
* write a non-copper polygon to the board file. * write a non-copper polygon to the board file.
@ -103,14 +103,14 @@ private:
* @param aGbrItem = the Gerber item (line, arc) to export * @param aGbrItem = the Gerber item (line, arc) to export
* @param aLayer = the technical layer to use * @param aLayer = the technical layer to use
*/ */
void writePcbZoneItem( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer ); void writePcbZoneItem( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/** /**
* write a track (or via) to the board file. * write a track (or via) to the board file.
* @param aGbrItem = the Gerber item (line, arc, flashed) to export * @param aGbrItem = the Gerber item (line, arc, flashed) to export
* @param aLayer = the copper layer to use * @param aLayer = the copper layer to use
*/ */
void export_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer ); void export_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/** /**
* Function export_flashed_copper_item * Function export_flashed_copper_item
@ -120,7 +120,7 @@ private:
* the pad. * the pad.
* @param aGbrItem = the flashed Gerber item to export * @param aGbrItem = the flashed Gerber item to export
*/ */
void export_flashed_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer ); void export_flashed_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/** /**
* Function export_segline_copper_item * Function export_segline_copper_item
@ -128,7 +128,7 @@ private:
* @param aGbrItem = the Gerber item (line only) to export * @param aGbrItem = the Gerber item (line only) to export
* @param aLayer = the copper layer to use * @param aLayer = the copper layer to use
*/ */
void export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer ); void export_segline_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/** /**
* Function export_segarc_copper_item * Function export_segarc_copper_item
@ -137,27 +137,28 @@ private:
* @param aGbrItem = the Gerber item (arc only) to export * @param aGbrItem = the Gerber item (arc only) to export
* @param aLayer = the copper layer to use * @param aLayer = the copper layer to use
*/ */
void export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer ); void export_segarc_copper_item( const GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/** /**
* function writeCopperLineItem * function writeCopperLineItem
* basic write function to write a a TRACK item * basic write function to write a a TRACK item
* to the board file, from a non flashed item * to the board file, from a non flashed item
*/ */
void writeCopperLineItem( wxPoint& aStart, wxPoint& aEnd, void writeCopperLineItem( const wxPoint& aStart,
const wxPoint& aEnd,
int aWidth, LAYER_NUM aLayer ); int aWidth, LAYER_NUM aLayer );
/** /**
* function writePcbHeader * function writePcbHeader
* Write a very basic header to the board file * Write a very basic header to the board file
*/ */
void writePcbHeader( LAYER_NUM* aLayerLookUpTable ); void writePcbHeader( const LAYER_NUM* aLayerLookUpTable );
/** In Pcbnew files units are mm for coordinates. /** In Pcbnew files units are mm for coordinates.
* So MapToPcbUnits converts internal gerbview to mm any pcbnew value * So MapToPcbUnits converts internal gerbview to mm any pcbnew value
* @param aValue is a coordinate value to convert in mm * @param aValue is a coordinate value to convert in mm
*/ */
double MapToPcbUnits( int aValue ) double MapToPcbUnits( int aValue ) const
{ {
return aValue / IU_PER_MM; return aValue / IU_PER_MM;
} }

View File

@ -120,7 +120,7 @@ public:
void EndQuasiModal( int retCode ); // End quasi-modal mode void EndQuasiModal( int retCode ); // End quasi-modal mode
bool IsQuasiModal() { return m_qmodal_showing; } bool IsQuasiModal() const { return m_qmodal_showing; }
bool Show( bool show ) override; bool Show( bool show ) override;
@ -170,13 +170,13 @@ protected:
* Convert an integer number of dialog units to pixels, horizontally. See SetSizeInDU or * Convert an integer number of dialog units to pixels, horizontally. See SetSizeInDU or
* wxDialog documentation for more information. * wxDialog documentation for more information.
*/ */
int horizPixelsFromDU( int x ); int horizPixelsFromDU( int x ) const;
/** /**
* Convert an integer number of dialog units to pixels, vertically. See SetSizeInDU or * Convert an integer number of dialog units to pixels, vertically. See SetSizeInDU or
* wxDialog documentation for more information. * wxDialog documentation for more information.
*/ */
int vertPixelsFromDU( int y ); int vertPixelsFromDU( int y ) const;
/** /**
* Clear the existing dialog size and position. * Clear the existing dialog size and position.

View File

@ -42,7 +42,7 @@ struct KEYWORD
const char* name; ///< unique keyword. const char* name; ///< unique keyword.
int token; ///< a zero based index into an array of KEYWORDs int token; ///< a zero based index into an array of KEYWORDs
}; };
#endif #endif // SWIG
// something like this macro can be used to help initialize a KEYWORD table. // something like this macro can be used to help initialize a KEYWORD table.
// see SPECCTRA_DB::keywords[] as an example. // see SPECCTRA_DB::keywords[] as an example.
@ -55,7 +55,8 @@ struct KEYWORD
* lists all the DSN lexer's tokens that are supported in lexing. It is up * lists all the DSN lexer's tokens that are supported in lexing. It is up
* to the parser if it wants also to support them. * to the parser if it wants also to support them.
*/ */
enum DSN_SYNTAX_T { enum DSN_SYNTAX_T
{
DSN_NONE = -11, DSN_NONE = -11,
DSN_COMMENT = -10, DSN_COMMENT = -10,
DSN_STRING_QUOTE = -9, DSN_STRING_QUOTE = -9,
@ -142,11 +143,11 @@ protected:
* @return int - with a value from the enum DSN_T matching the keyword text, * @return int - with a value from the enum DSN_T matching the keyword text,
* or DSN_SYMBOL if @a aToken is not in the kewords table. * or DSN_SYMBOL if @a aToken is not in the kewords table.
*/ */
int findToken( const std::string& aToken ); int findToken( const std::string& aToken ) const;
bool isStringTerminator( char cc ) bool isStringTerminator( char cc ) const
{ {
if( !space_in_quoted_tokens && cc==' ' ) if( !space_in_quoted_tokens && cc == ' ' )
return true; return true;
if( cc == stringDelimiter ) if( cc == stringDelimiter )
@ -155,7 +156,7 @@ protected:
return false; return false;
} }
#endif #endif // SWIG
public: public:
@ -317,7 +318,7 @@ public:
* Function CurTok * Function CurTok
* returns whatever NextTok() returned the last time it was called. * returns whatever NextTok() returned the last time it was called.
*/ */
int CurTok() int CurTok() const
{ {
return curTok; return curTok;
} }
@ -326,7 +327,7 @@ public:
* Function PrevTok * Function PrevTok
* returns whatever NextTok() returned the 2nd to last time it was called. * returns whatever NextTok() returned the 2nd to last time it was called.
*/ */
int PrevTok() int PrevTok() const
{ {
return prevTok; return prevTok;
} }
@ -335,7 +336,7 @@ public:
* Function GetCurStrAsToken * Function GetCurStrAsToken
* Used to support "loose" matches (quoted tokens) * Used to support "loose" matches (quoted tokens)
*/ */
int GetCurStrAsToken() int GetCurStrAsToken() const
{ {
return findToken( curText ); return findToken( curText );
} }
@ -412,7 +413,7 @@ public:
* @param aTok is the token/keyword type which was expected at the current input location. * @param aTok is the token/keyword type which was expected at the current input location.
* @throw IO_ERROR with the location within the input file of the problem. * @throw IO_ERROR with the location within the input file of the problem.
*/ */
void Expecting( int aTok ); void Expecting( int aTok ) const;
/** /**
* Function Expecting * Function Expecting
@ -421,7 +422,7 @@ public:
* current input location, e.g. "pin|graphic|property" * current input location, e.g. "pin|graphic|property"
* @throw IO_ERROR with the location within the input file of the problem. * @throw IO_ERROR with the location within the input file of the problem.
*/ */
void Expecting( const char* aTokenList ); void Expecting( const char* aTokenList ) const;
/** /**
* Function Unexpected * Function Unexpected
@ -430,7 +431,7 @@ public:
* current input location. * current input location.
* @throw IO_ERROR with the location within the input file of the problem. * @throw IO_ERROR with the location within the input file of the problem.
*/ */
void Unexpected( int aTok ); void Unexpected( int aTok ) const;
/** /**
* Function Unexpected * Function Unexpected
@ -439,7 +440,7 @@ public:
* current input location. * current input location.
* @throw IO_ERROR with the location within the input file of the problem. * @throw IO_ERROR with the location within the input file of the problem.
*/ */
void Unexpected( const char* aToken ); void Unexpected( const char* aToken ) const;
/** /**
* Function Duplicate * Function Duplicate
@ -471,13 +472,13 @@ public:
* Function GetTokenText * Function GetTokenText
* returns the C string representation of a DSN_T value. * returns the C string representation of a DSN_T value.
*/ */
const char* GetTokenText( int aTok ); const char* GetTokenText( int aTok ) const;
/** /**
* Function GetTokenString * Function GetTokenString
* returns a quote wrapped wxString representation of a token value. * returns a quote wrapped wxString representation of a token value.
*/ */
wxString GetTokenString( int aTok ); wxString GetTokenString( int aTok ) const;
static const char* Syntax( int aTok ); static const char* Syntax( int aTok );
@ -485,7 +486,7 @@ public:
* Function CurText * Function CurText
* returns a pointer to the current token's text. * returns a pointer to the current token's text.
*/ */
const char* CurText() const char* CurText() const
{ {
return curText.c_str(); return curText.c_str();
} }
@ -494,7 +495,7 @@ public:
* Function CurStr * Function CurStr
* returns a reference to current token in std::string form. * returns a reference to current token in std::string form.
*/ */
const std::string& CurStr() const std::string& CurStr() const
{ {
return curText; return curText;
} }
@ -504,7 +505,7 @@ public:
* returns the current token text as a wxString, assuming that the input * returns the current token text as a wxString, assuming that the input
* byte stream is UTF8 encoded. * byte stream is UTF8 encoded.
*/ */
wxString FromUTF8() wxString FromUTF8() const
{ {
return wxString::FromUTF8( curText.c_str() ); return wxString::FromUTF8( curText.c_str() );
} }
@ -513,7 +514,7 @@ public:
* Function CurLineNumber * Function CurLineNumber
* returns the current line number within my LINE_READER * returns the current line number within my LINE_READER
*/ */
int CurLineNumber() int CurLineNumber() const
{ {
return reader->LineNumber(); return reader->LineNumber();
} }
@ -523,7 +524,7 @@ public:
* returns the current line of text, from which the CurText() would return * returns the current line of text, from which the CurText() would return
* its token. * its token.
*/ */
const char* CurLine() const char* CurLine() const
{ {
return (const char*)(*reader); return (const char*)(*reader);
} }
@ -534,7 +535,7 @@ public:
* @return const wxString& - the source of the lines of text, * @return const wxString& - the source of the lines of text,
* e.g. a filename or "clipboard". * e.g. a filename or "clipboard".
*/ */
const wxString& CurSource() const wxString& CurSource() const
{ {
return reader->GetSource(); return reader->GetSource();
} }
@ -544,7 +545,7 @@ public:
* returns the byte offset within the current line, using a 1 based index. * returns the byte offset within the current line, using a 1 based index.
* @return int - a one based index into the current line. * @return int - a one based index into the current line.
*/ */
int CurOffset() int CurOffset() const
{ {
return curOffset + 1; return curOffset + 1;
} }

View File

@ -66,7 +66,7 @@ wxString GbrMakeCreationDateAttributeString( GBR_NC_STRING_FORMAT aFormat );
* *
* See en.wikipedia.org/wiki/Universally_unique_identifier * See en.wikipedia.org/wiki/Universally_unique_identifier
*/ */
wxString GbrMakeProjectGUIDfromString( wxString& aText ); wxString GbrMakeProjectGUIDfromString( const wxString& aText );
// this class handle info which can be added in a gerber file as attribute // this class handle info which can be added in a gerber file as attribute
@ -272,7 +272,7 @@ wxString FormatStringFromGerber( const wxString& aString );
* will be empty * will be empty
*/ */
bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttributes, bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttributes,
GBR_NETLIST_METADATA* aData, bool& aClearPreviousAttributes, const GBR_NETLIST_METADATA* aData, bool& aClearPreviousAttributes,
bool aUseX1StructuredComment ); bool aUseX1StructuredComment );
#endif // GBR_METADATA_H #endif // GBR_METADATA_H

View File

@ -118,7 +118,7 @@ public:
bool IsEmpty() const { return m_field.IsEmpty(); } bool IsEmpty() const { return m_field.IsEmpty(); }
std::string GetGerberString(); std::string GetGerberString() const;
private: private:

View File

@ -46,7 +46,7 @@ public:
m_type( aType ) m_type( aType )
{} {}
HOLDER_TYPE GetType() { return m_type; } HOLDER_TYPE GetType() const { return m_type; }
/** /**
* Function Kiway * Function Kiway

View File

@ -90,6 +90,6 @@ void Scan( PTREE* aTree, DSNLEXER* aLexer );
* Function Format * Function Format
* outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative. * outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
*/ */
void Format( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, CPTREE& aTree ); void Format( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, const CPTREE& aTree );
#endif // PTREE_H_ #endif // PTREE_H_

View File

@ -57,7 +57,7 @@ class SHAPE_FILE_IO
void Write( const SHAPE* aShape, const std::string& aName = "<noname>" ); void Write( const SHAPE* aShape, const std::string& aName = "<noname>" );
void Write( const SHAPE& aShape, const std::string aName = "<noname>" ) void Write( const SHAPE& aShape, const std::string& aName = "<noname>" )
{ {
Write( &aShape, aName ); Write( &aShape, aName );
} }
@ -68,4 +68,4 @@ class SHAPE_FILE_IO
IO_MODE m_mode; IO_MODE m_mode;
}; };
#endif #endif // __SHAPE_FILE_IO_H

View File

@ -534,11 +534,11 @@ void SHAPE_LINE_CHAIN::Insert( size_t aVertex, const SHAPE_ARC& aArc )
struct compareOriginDistance struct compareOriginDistance
{ {
compareOriginDistance( VECTOR2I& aOrigin ) : compareOriginDistance( const VECTOR2I& aOrigin ) :
m_origin( aOrigin ) {}; m_origin( aOrigin ) {};
bool operator()( const SHAPE_LINE_CHAIN::INTERSECTION& aA, bool operator()( const SHAPE_LINE_CHAIN::INTERSECTION& aA,
const SHAPE_LINE_CHAIN::INTERSECTION& aB ) const SHAPE_LINE_CHAIN::INTERSECTION& aB ) const
{ {
return ( m_origin - aA.p ).EuclideanNorm() < ( m_origin - aB.p ).EuclideanNorm(); return ( m_origin - aA.p ).EuclideanNorm() < ( m_origin - aB.p ).EuclideanNorm();
} }

View File

@ -78,7 +78,7 @@ BOARD_STACKUP_ITEM::BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM_TYPE aType )
} }
BOARD_STACKUP_ITEM::BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM& aOther ) BOARD_STACKUP_ITEM::BOARD_STACKUP_ITEM( const BOARD_STACKUP_ITEM& aOther )
{ {
m_LayerId = aOther.m_LayerId; m_LayerId = aOther.m_LayerId;
m_DielectricLayerId = aOther.m_DielectricLayerId; m_DielectricLayerId = aOther.m_DielectricLayerId;
@ -320,7 +320,7 @@ BOARD_STACKUP::BOARD_STACKUP()
} }
BOARD_STACKUP::BOARD_STACKUP( BOARD_STACKUP& aOther ) BOARD_STACKUP::BOARD_STACKUP( const BOARD_STACKUP& aOther )
{ {
m_HasDielectricConstrains = aOther.m_HasDielectricConstrains; m_HasDielectricConstrains = aOther.m_HasDielectricConstrains;
m_HasThicknessConstrains = aOther.m_HasThicknessConstrains; m_HasThicknessConstrains = aOther.m_HasThicknessConstrains;

View File

@ -89,7 +89,7 @@ class BOARD_STACKUP_ITEM
{ {
public: public:
BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM_TYPE aType ); BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM_TYPE aType );
BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM& aOther ); BOARD_STACKUP_ITEM( const BOARD_STACKUP_ITEM& aOther );
private: private:
@ -243,7 +243,7 @@ public:
public: public:
BOARD_STACKUP(); BOARD_STACKUP();
BOARD_STACKUP( BOARD_STACKUP& aOther ); BOARD_STACKUP( const BOARD_STACKUP& aOther );
BOARD_STACKUP& operator=( const BOARD_STACKUP& aOther ); BOARD_STACKUP& operator=( const BOARD_STACKUP& aOther );
~BOARD_STACKUP() { RemoveAll(); } ~BOARD_STACKUP() { RemoveAll(); }
@ -267,7 +267,7 @@ public:
void RemoveAll(); void RemoveAll();
/// @return the number of layers in the stackup /// @return the number of layers in the stackup
int GetCount() { return (int) m_list.size(); } int GetCount() const { return (int) m_list.size(); }
/// @return the board thickness ( in UI) from the thickness of BOARD_STACKUP_ITEM list /// @return the board thickness ( in UI) from the thickness of BOARD_STACKUP_ITEM list
int BuildBoardTicknessFromStackup() const; int BuildBoardTicknessFromStackup() const;
@ -306,4 +306,4 @@ public:
}; };
#endif // #ifndef CLASS_BOARD_STACKUP_H #endif // CLASS_BOARD_STACKUP_H

View File

@ -556,8 +556,8 @@ void DIALOG_BOARD_REANNOTATE::LogChangePlan()
// //
/// Create a list of the footprints and their coordinates /// Create a list of the footprints and their coordinates
void DIALOG_BOARD_REANNOTATE::LogFootprints( wxString& aMessage, void DIALOG_BOARD_REANNOTATE::LogFootprints( const wxString& aMessage,
std::vector<RefDesInfo>& aFootprints ) const std::vector<RefDesInfo>& aFootprints )
{ {
wxString message = aMessage; wxString message = aMessage;

View File

@ -172,7 +172,7 @@ private:
void FilterBackPrefix( wxCommandEvent& event ) override; void FilterBackPrefix( wxCommandEvent& event ) override;
void ShowReport( wxString aMessage, SEVERITY aSeverity ); void ShowReport( wxString aMessage, SEVERITY aSeverity );
void LogFootprints( wxString& aMessage, std::vector<RefDesInfo>& aFootprints ); void LogFootprints( const wxString& aMessage, const std::vector<RefDesInfo>& aFootprints );
void LogChangePlan( void ); void LogChangePlan( void );
bool ReannotateBoard( void ); bool ReannotateBoard( void );

View File

@ -559,7 +559,7 @@ DIALOG_PAD_PRIMITIVES_TRANSFORM::DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aPar
// A helper function in geometry transform // A helper function in geometry transform
inline void geom_transf( wxPoint& aCoord, wxPoint& aMove, double aScale, double aRotation ) inline void geom_transf( wxPoint& aCoord, const wxPoint& aMove, double aScale, double aRotation )
{ {
aCoord.x = KiROUND( aCoord.x * aScale ); aCoord.x = KiROUND( aCoord.x * aScale );
aCoord.y = KiROUND( aCoord.y * aScale ); aCoord.y = KiROUND( aCoord.y * aScale );

View File

@ -300,7 +300,7 @@ static void create_vrml_shell( IFSG_TRANSFORM& PcbOutput, VRML_COLOR_INDEX color
static void create_vrml_plane( IFSG_TRANSFORM& PcbOutput, VRML_COLOR_INDEX colorID, static void create_vrml_plane( IFSG_TRANSFORM& PcbOutput, VRML_COLOR_INDEX colorID,
VRML_LAYER* layer, double aHeight, bool aTopPlane ); VRML_LAYER* layer, double aHeight, bool aTopPlane );
static void write_triangle_bag( std::ostream& aOut_file, VRML_COLOR& aColor, static void write_triangle_bag( std::ostream& aOut_file, const VRML_COLOR& aColor,
VRML_LAYER* aLayer, bool aPlane, bool aTop, VRML_LAYER* aLayer, bool aPlane, bool aTop,
double aTop_z, double aBottom_z ) double aTop_z, double aBottom_z )
{ {

View File

@ -41,7 +41,7 @@
namespace PCAD2KICAD { namespace PCAD2KICAD {
PCB_LAYER_ID PCB::GetKiCadLayer( int aPCadLayer ) PCB_LAYER_ID PCB::GetKiCadLayer( int aPCadLayer ) const
{ {
auto it = m_LayersMap.find( aPCadLayer ); auto it = m_LayersMap.find( aPCadLayer );
@ -51,7 +51,7 @@ PCB_LAYER_ID PCB::GetKiCadLayer( int aPCadLayer )
return it->second.KiCadLayer; return it->second.KiCadLayer;
} }
LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer ) LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer ) const
{ {
auto it = m_LayersMap.find( aPCadLayer ); auto it = m_LayersMap.find( aPCadLayer );
@ -61,7 +61,7 @@ LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer )
return it->second.layerType; return it->second.layerType;
} }
wxString PCB::GetLayerNetNameRef( int aPCadLayer ) wxString PCB::GetLayerNetNameRef( int aPCadLayer ) const
{ {
auto it = m_LayersMap.find( aPCadLayer ); auto it = m_LayersMap.find( aPCadLayer );
@ -117,9 +117,9 @@ PCB::~PCB()
} }
int PCB::GetNetCode( wxString aNetName ) int PCB::GetNetCode( const wxString& aNetName ) const
{ {
PCB_NET* net; const PCB_NET* net;
for( int i = 0; i < (int) m_PcbNetlist.GetCount(); i++ ) for( int i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
{ {
@ -134,7 +134,7 @@ int PCB::GetNetCode( wxString aNetName )
return 0; return 0;
} }
XNODE* PCB::FindCompDefName( XNODE* aNode, const wxString& aName ) XNODE* PCB::FindCompDefName( XNODE* aNode, const wxString& aName ) const
{ {
XNODE* result = NULL, * lNode; XNODE* result = NULL, * lNode;
wxString propValue; wxString propValue;
@ -449,7 +449,7 @@ void PCB::ConnectPinToNet( const wxString& aCompRef, const wxString& aPinRef,
} }
int PCB::FindLayer( const wxString& aLayerName ) int PCB::FindLayer( const wxString& aLayerName ) const
{ {
for( LAYER_NUM i = 0; i < (int)m_layersStackup.GetCount(); ++i ) for( LAYER_NUM i = 0; i < (int)m_layersStackup.GetCount(); ++i )
{ {
@ -554,7 +554,7 @@ void PCB::MapLayer( XNODE* aNode )
} }
} }
int PCB::FindOutlinePoint( VERTICES_ARRAY* aOutline, wxRealPoint aPoint ) int PCB::FindOutlinePoint( const VERTICES_ARRAY* aOutline, wxRealPoint aPoint ) const
{ {
int i; int i;
@ -572,7 +572,7 @@ int PCB::FindOutlinePoint( VERTICES_ARRAY* aOutline, wxRealPoint aPoint )
return 0; return 0;
}*/ }*/
double PCB::GetDistance( wxRealPoint* aPoint1, wxRealPoint* aPoint2 ) double PCB::GetDistance( const wxRealPoint* aPoint1, const wxRealPoint* aPoint2 ) const
{ {
return sqrt( ( aPoint1->x - aPoint2->x ) * return sqrt( ( aPoint1->x - aPoint2->x ) *
( aPoint1->x - aPoint2->x ) + ( aPoint1->x - aPoint2->x ) +

View File

@ -52,10 +52,10 @@ public:
PCB( BOARD* aBoard ); PCB( BOARD* aBoard );
~PCB(); ~PCB();
PCB_LAYER_ID GetKiCadLayer( int aPCadLayer ) override; PCB_LAYER_ID GetKiCadLayer( int aPCadLayer ) const override;
LAYER_TYPE_T GetLayerType( int aPCadLayer ) override; LAYER_TYPE_T GetLayerType( int aPCadLayer ) const override;
wxString GetLayerNetNameRef( int aPCadLayer ) override; wxString GetLayerNetNameRef( int aPCadLayer ) const override;
int GetNetCode( wxString aNetName ) override; int GetNetCode( const wxString& aNetName ) const override;
void ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, void ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc,
const wxString& aActualConversion ); const wxString& aActualConversion );
@ -65,7 +65,7 @@ public:
private: private:
wxArrayString m_layersStackup; wxArrayString m_layersStackup;
XNODE* FindCompDefName( XNODE* aNode, const wxString& aName ); XNODE* FindCompDefName( XNODE* aNode, const wxString& aName ) const;
void SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue, const wxString& aPatGraphRefName, void SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue, const wxString& aPatGraphRefName,
const wxString& aXmlName, const wxString& aActualConversion ); const wxString& aXmlName, const wxString& aActualConversion );
@ -75,10 +75,10 @@ private:
void ConnectPinToNet( const wxString& aCr, const wxString& aPr, const wxString& aNetName ); void ConnectPinToNet( const wxString& aCr, const wxString& aPr, const wxString& aNetName );
int FindLayer( const wxString& aLayerName ); int FindLayer( const wxString& aLayerName ) const;
void MapLayer( XNODE* aNode ); void MapLayer( XNODE* aNode );
int FindOutlinePoint( VERTICES_ARRAY* aOutline, wxRealPoint aPoint ); int FindOutlinePoint( const VERTICES_ARRAY* aOutline, wxRealPoint aPoint ) const;
double GetDistance( wxRealPoint* aPoint1, wxRealPoint* aPoint2 ); double GetDistance( const wxRealPoint* aPoint1, const wxRealPoint* aPoint2 ) const;
void GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConversion ); void GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConversion );
}; };

View File

@ -57,10 +57,10 @@ namespace PCAD2KICAD
{ {
} }
virtual PCB_LAYER_ID GetKiCadLayer( int aPCadLayer ) = 0; virtual PCB_LAYER_ID GetKiCadLayer( int aPCadLayer ) const = 0;
virtual LAYER_TYPE_T GetLayerType( int aPCadLayer ) = 0; virtual LAYER_TYPE_T GetLayerType( int aPCadLayer ) const = 0;
virtual wxString GetLayerNetNameRef( int aPCadLayer ) = 0; virtual wxString GetLayerNetNameRef( int aPCadLayer ) const = 0;
virtual int GetNetCode( wxString netName ) = 0; virtual int GetNetCode( const wxString& netName ) const = 0;
}; };
} }

View File

@ -67,8 +67,8 @@ public:
virtual void AddToFootprint( FOOTPRINT* aFootprint ); virtual void AddToFootprint( FOOTPRINT* aFootprint );
virtual void AddToBoard() = 0; virtual void AddToBoard() = 0;
PCB_LAYER_ID GetKiCadLayer() { return m_callbacks->GetKiCadLayer( m_PCadLayer ); } PCB_LAYER_ID GetKiCadLayer() const { return m_callbacks->GetKiCadLayer( m_PCadLayer ); }
int GetNetCode( wxString aNetName ) { return m_callbacks->GetNetCode( aNetName ); } int GetNetCode( wxString aNetName ) const { return m_callbacks->GetNetCode( aNetName ); }
protected: protected:
PCB_CALLBACKS* m_callbacks; PCB_CALLBACKS* m_callbacks;

View File

@ -497,7 +497,7 @@ public:
} }
private: private:
void updateLine( LINE &aLine, const SHAPE_LINE_CHAIN& aShape, int aNet, VIA& aVia ) void updateLine( LINE &aLine, const SHAPE_LINE_CHAIN& aShape, int aNet, const VIA& aVia )
{ {
aLine.SetShape( aShape ); aLine.SetShape( aShape );
aLine.SetWidth( m_width ); aLine.SetWidth( m_width );

View File

@ -994,7 +994,7 @@ void NODE::MapConnectivity( JOINT* aStart, std::vector<JOINT*>& aFoundJoints )
#endif #endif
int NODE::FindLinesBetweenJoints( JOINT& aA, JOINT& aB, std::vector<LINE>& aLines ) int NODE::FindLinesBetweenJoints( const JOINT& aA, const JOINT& aB, std::vector<LINE>& aLines )
{ {
for( ITEM* item : aA.LinkList() ) for( ITEM* item : aA.LinkList() )
{ {

View File

@ -425,8 +425,8 @@ public:
#endif #endif
///> finds all lines between a pair of joints. Used by the loop removal procedure. ///> finds all lines between a pair of joints. Used by the loop removal procedure.
int FindLinesBetweenJoints( JOINT& aA, int FindLinesBetweenJoints( const JOINT& aA,
JOINT& aB, const JOINT& aB,
std::vector<LINE>& aLines ); std::vector<LINE>& aLines );
///> finds the joints corresponding to the ends of line aLine ///> finds the joints corresponding to the ends of line aLine

View File

@ -89,21 +89,21 @@ int COST_ESTIMATOR::CornerCost( const LINE& aLine )
} }
void COST_ESTIMATOR::Add( LINE& aLine ) void COST_ESTIMATOR::Add( const LINE& aLine )
{ {
m_lengthCost += aLine.CLine().Length(); m_lengthCost += aLine.CLine().Length();
m_cornerCost += CornerCost( aLine ); m_cornerCost += CornerCost( aLine );
} }
void COST_ESTIMATOR::Remove( LINE& aLine ) void COST_ESTIMATOR::Remove( const LINE& aLine )
{ {
m_lengthCost -= aLine.CLine().Length(); m_lengthCost -= aLine.CLine().Length();
m_cornerCost -= CornerCost( aLine ); m_cornerCost -= CornerCost( aLine );
} }
void COST_ESTIMATOR::Replace( LINE& aOldLine, LINE& aNewLine ) void COST_ESTIMATOR::Replace( const LINE& aOldLine, const LINE& aNewLine )
{ {
m_lengthCost -= aOldLine.CLine().Length(); m_lengthCost -= aOldLine.CLine().Length();
m_cornerCost -= CornerCost( aOldLine ); m_cornerCost -= CornerCost( aOldLine );
@ -112,7 +112,7 @@ void COST_ESTIMATOR::Replace( LINE& aOldLine, LINE& aNewLine )
} }
bool COST_ESTIMATOR::IsBetter( COST_ESTIMATOR& aOther, bool COST_ESTIMATOR::IsBetter( const COST_ESTIMATOR& aOther,
double aLengthTolerance, double aLengthTolerance,
double aCornerTolerance ) const double aCornerTolerance ) const
{ {
@ -236,7 +236,7 @@ void OPTIMIZER::ClearCache( bool aStaticOnly )
} }
bool ANGLE_CONSTRAINT_45::Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) bool ANGLE_CONSTRAINT_45::Check( int aVertex1, int aVertex2, const LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement )
{ {
auto dir_orig0 = DIRECTION_45( aOriginLine->CSegment( aVertex1 ) ); auto dir_orig0 = DIRECTION_45( aOriginLine->CSegment( aVertex1 ) );
auto dir_orig1 = DIRECTION_45( aOriginLine->CSegment( aVertex2 - 1) ); auto dir_orig1 = DIRECTION_45( aOriginLine->CSegment( aVertex2 - 1) );
@ -261,7 +261,7 @@ bool ANGLE_CONSTRAINT_45::Check ( int aVertex1, int aVertex2, LINE* aOriginLine,
return true; return true;
} }
bool AREA_CONSTRAINT::Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) bool AREA_CONSTRAINT::Check( int aVertex1, int aVertex2, const LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement )
{ {
auto p1 = aOriginLine->CPoint( aVertex1 ); auto p1 = aOriginLine->CPoint( aVertex1 );
auto p2 = aOriginLine->CPoint( aVertex2 ); auto p2 = aOriginLine->CPoint( aVertex2 );
@ -288,7 +288,7 @@ class JOINT_CACHE
}; };
bool PRESERVE_VERTEX_CONSTRAINT::Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) bool PRESERVE_VERTEX_CONSTRAINT::Check( int aVertex1, int aVertex2, const LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement )
{ {
bool cv = false; bool cv = false;
@ -321,7 +321,7 @@ bool PRESERVE_VERTEX_CONSTRAINT::Check ( int aVertex1, int aVertex2, LINE* aOrig
} }
bool RESTRICT_VERTEX_RANGE_CONSTRAINT::Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) bool RESTRICT_VERTEX_RANGE_CONSTRAINT::Check( int aVertex1, int aVertex2, const LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement )
{ {
return true; return true;
} }
@ -393,7 +393,7 @@ static bool pointInside2( const SHAPE_LINE_CHAIN& aL, const VECTOR2I& aP )
} }
bool KEEP_TOPOLOGY_CONSTRAINT::Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) bool KEEP_TOPOLOGY_CONSTRAINT::Check( int aVertex1, int aVertex2, const LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement )
{ {
SHAPE_LINE_CHAIN encPoly = aOriginLine->CLine().Slice( aVertex1, aVertex2 ); SHAPE_LINE_CHAIN encPoly = aOriginLine->CLine().Slice( aVertex1, aVertex2 );
@ -411,18 +411,20 @@ bool KEEP_TOPOLOGY_CONSTRAINT::Check ( int aVertex1, int aVertex2, LINE* aOrigin
for( auto j : joints ) for( auto j : joints )
{ {
if ( j->Net() == aOriginLine->Net() ) if( j->Net() == aOriginLine->Net() )
continue; continue;
if ( pointInside2( encPoly, j->Pos() ) ) if( pointInside2( encPoly, j->Pos() ) )
{ {
bool falsePositive = false; bool falsePositive = false;
for( int k = 0; k < encPoly.PointCount(); k++) for( int k = 0; k < encPoly.PointCount(); k++ )
if(encPoly.CPoint(k) == j->Pos() ) {
if( encPoly.CPoint(k) == j->Pos() )
{ {
falsePositive = true; falsePositive = true;
break; break;
} }
}
if( !falsePositive ) if( !falsePositive )
{ {
@ -444,13 +446,13 @@ bool OPTIMIZER::checkColliding( ITEM* aItem, bool aUpdateCache )
void OPTIMIZER::ClearConstraints() void OPTIMIZER::ClearConstraints()
{ {
for (auto c : m_constraints) for( auto c : m_constraints)
delete c; delete c;
m_constraints.clear(); m_constraints.clear();
} }
void OPTIMIZER::AddConstraint ( OPT_CONSTRAINT *aConstraint ) void OPTIMIZER::AddConstraint ( OPT_CONSTRAINT *aConstraint )
{ {
m_constraints.push_back(aConstraint); m_constraints.push_back(aConstraint);
} }
@ -458,7 +460,7 @@ bool OPTIMIZER::checkConstraints( int aVertex1, int aVertex2, LINE* aOriginLine
{ {
for( auto c: m_constraints) for( auto c: m_constraints)
{ {
if ( !c->Check( aVertex1, aVertex2, aOriginLine, aCurrentPath, aReplacement ) ) if( !c->Check( aVertex1, aVertex2, aOriginLine, aCurrentPath, aReplacement ) )
{ {
return false; return false;
} }
@ -610,19 +612,19 @@ bool OPTIMIZER::Optimize( LINE* aLine, LINE* aResult )
bool rv = false; bool rv = false;
if ( m_effortLevel & PRESERVE_VERTEX ) if( m_effortLevel & PRESERVE_VERTEX )
{ {
auto c = new PRESERVE_VERTEX_CONSTRAINT( m_world, m_preservedVertex ); auto c = new PRESERVE_VERTEX_CONSTRAINT( m_world, m_preservedVertex );
AddConstraint( c ); AddConstraint( c );
} }
if ( m_effortLevel & RESTRICT_VERTEX_RANGE ) if( m_effortLevel & RESTRICT_VERTEX_RANGE )
{ {
auto c = new RESTRICT_VERTEX_RANGE_CONSTRAINT( m_world, m_restrictedVertexRange.first, m_restrictedVertexRange.second ); auto c = new RESTRICT_VERTEX_RANGE_CONSTRAINT( m_world, m_restrictedVertexRange.first, m_restrictedVertexRange.second );
AddConstraint( c ); AddConstraint( c );
} }
if ( m_effortLevel & KEEP_TOPOLOGY ) if( m_effortLevel & KEEP_TOPOLOGY )
{ {
auto c = new KEEP_TOPOLOGY_CONSTRAINT( m_world ); auto c = new KEEP_TOPOLOGY_CONSTRAINT( m_world );
AddConstraint( c ); AddConstraint( c );
@ -677,7 +679,7 @@ bool OPTIMIZER::mergeStep( LINE* aLine, SHAPE_LINE_CHAIN& aCurrentPath, int step
bool ok = false; bool ok = false;
if ( !checkColliding( aLine, bypass ) ) if( !checkColliding( aLine, bypass ) )
{ {
ok = checkConstraints ( n, n + step + 1, aLine, aCurrentPath, bypass ); ok = checkConstraints ( n, n + step + 1, aLine, aCurrentPath, bypass );
} }
@ -1426,32 +1428,30 @@ bool tightenSegment( bool dir, NODE *aNode, const LINE& cur,
return true; return true;
} }
void Tighten( NODE *aNode, SHAPE_LINE_CHAIN& aOldLine, LINE& aNewLine, LINE& aOptimized ) void Tighten( NODE *aNode, const SHAPE_LINE_CHAIN& aOldLine, const LINE& aNewLine, LINE& aOptimized )
{ {
LINE tmp; LINE tmp;
if( aNewLine.SegmentCount() < 3 )
if ( aNewLine.SegmentCount() < 3 )
return; return;
SHAPE_LINE_CHAIN current ( aNewLine.CLine() ); SHAPE_LINE_CHAIN current ( aNewLine.CLine() );
for (int step = 0; step < 3; step++) for( int step = 0; step < 3; step++)
{ {
current.Simplify(); current.Simplify();
for ( int i = 0; i <= current.SegmentCount() - 3; i++) for( int i = 0; i <= current.SegmentCount() - 3; i++)
{ {
SHAPE_LINE_CHAIN l_in, l_out; SHAPE_LINE_CHAIN l_in, l_out;
l_in = current.Slice(i, i+3); l_in = current.Slice(i, i+3);
for (int dir = 0; dir < 1; dir++) for( int dir = 0; dir < 1; dir++)
{ {
if( tightenSegment( dir ? true : false, aNode, aNewLine, l_in, l_out ) ) if( tightenSegment( dir ? true : false, aNode, aNewLine, l_in, l_out ) )
{ {
SHAPE_LINE_CHAIN opt = current; SHAPE_LINE_CHAIN opt = current;
opt.Replace(i, i+3, l_out); opt.Replace(i, i + 3, l_out);
auto optArea = std::abs(shovedArea( aOldLine, opt )); auto optArea = std::abs(shovedArea( aOldLine, opt ));
auto prevArea = std::abs(shovedArea( aOldLine, current )); auto prevArea = std::abs(shovedArea( aOldLine, current ));

View File

@ -64,11 +64,11 @@ public:
static int CornerCost( const SHAPE_LINE_CHAIN& aLine ); static int CornerCost( const SHAPE_LINE_CHAIN& aLine );
static int CornerCost( const LINE& aLine ); static int CornerCost( const LINE& aLine );
void Add( LINE& aLine ); void Add( const LINE& aLine );
void Remove( LINE& aLine ); void Remove( const LINE& aLine );
void Replace( LINE& aOldLine, LINE& aNewLine ); void Replace( const LINE& aOldLine, const LINE& aNewLine );
bool IsBetter( COST_ESTIMATOR& aOther, double aLengthTolerance, bool IsBetter( const COST_ESTIMATOR& aOther, double aLengthTolerance,
double aCornerTollerace ) const; double aCornerTollerace ) const;
double GetLengthCost() const { return m_lengthCost; } double GetLengthCost() const { return m_lengthCost; }
@ -226,7 +226,7 @@ public:
virtual ~OPT_CONSTRAINT() {}; virtual ~OPT_CONSTRAINT() {};
virtual bool Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) = 0; virtual bool Check( int aVertex1, int aVertex2, const LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) = 0;
int GetPriority() const int GetPriority() const
{ {
@ -256,7 +256,7 @@ public:
virtual ~ANGLE_CONSTRAINT_45() {}; virtual ~ANGLE_CONSTRAINT_45() {};
virtual bool Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) override; virtual bool Check( int aVertex1, int aVertex2, const LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) override;
private: private:
int m_entryDirectionMask; int m_entryDirectionMask;
@ -270,7 +270,7 @@ public:
OPT_CONSTRAINT( aWorld ), OPT_CONSTRAINT( aWorld ),
m_allowedArea ( aAllowedArea ) {}; m_allowedArea ( aAllowedArea ) {};
virtual bool Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) override; virtual bool Check( int aVertex1, int aVertex2, const LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) override;
private: private:
BOX2I m_allowedArea; BOX2I m_allowedArea;
@ -284,7 +284,7 @@ public:
OPT_CONSTRAINT( aWorld ) OPT_CONSTRAINT( aWorld )
{}; {};
virtual bool Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) override; virtual bool Check( int aVertex1, int aVertex2, const LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) override;
}; };
class PRESERVE_VERTEX_CONSTRAINT: public OPT_CONSTRAINT class PRESERVE_VERTEX_CONSTRAINT: public OPT_CONSTRAINT
@ -295,7 +295,7 @@ public:
m_v( aV ) m_v( aV )
{}; {};
virtual bool Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) override; virtual bool Check( int aVertex1, int aVertex2, const LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) override;
private: private:
VECTOR2I m_v; VECTOR2I m_v;
@ -310,7 +310,7 @@ public:
m_end( aEnd ) m_end( aEnd )
{}; {};
virtual bool Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) override; virtual bool Check( int aVertex1, int aVertex2, const LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) override;
private: private:
int m_start; int m_start;
@ -320,4 +320,4 @@ private:
}; };
#endif #endif // __PNS_OPTIMIZER_H

View File

@ -659,7 +659,7 @@ public:
* Function SetFilledPolysList * Function SetFilledPolysList
* sets the list of filled polygons. * sets the list of filled polygons.
*/ */
void SetFilledPolysList( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aPolysList ) void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
{ {
m_FilledPolysList[aLayer] = aPolysList; m_FilledPolysList[aLayer] = aPolysList;
} }
@ -668,7 +668,7 @@ public:
* Function SetFilledPolysList * Function SetFilledPolysList
* sets the list of filled polygons. * sets the list of filled polygons.
*/ */
void SetRawPolysList( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aPolysList ) void SetRawPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
{ {
m_RawPolysList[aLayer] = aPolysList; m_RawPolysList[aLayer] = aPolysList;
} }

View File

@ -45,7 +45,7 @@ std::ostream& operator<<( std::ostream& aStream, const TRIPLET& aTriplet )
} }
bool Get2DPositionAndRotation( SEXPR::SEXPR* data, DOUBLET& aPosition, double& aRotation ) bool Get2DPositionAndRotation( const SEXPR::SEXPR* data, DOUBLET& aPosition, double& aRotation )
{ {
// form: (at X Y {rot}) // form: (at X Y {rot})
int nchild = data->GetNumberOfChildren(); int nchild = data->GetNumberOfChildren();
@ -130,7 +130,7 @@ bool Get2DPositionAndRotation( SEXPR::SEXPR* data, DOUBLET& aPosition, double& a
} }
bool Get2DCoordinate( SEXPR::SEXPR* data, DOUBLET& aCoordinate ) bool Get2DCoordinate( const SEXPR::SEXPR* data, DOUBLET& aCoordinate )
{ {
// form: (at X Y {rot}) // form: (at X Y {rot})
int nchild = data->GetNumberOfChildren(); int nchild = data->GetNumberOfChildren();
@ -180,7 +180,7 @@ bool Get2DCoordinate( SEXPR::SEXPR* data, DOUBLET& aCoordinate )
} }
bool Get3DCoordinate( SEXPR::SEXPR* data, TRIPLET& aCoordinate ) bool Get3DCoordinate( const SEXPR::SEXPR* data, TRIPLET& aCoordinate )
{ {
// form: (at X Y Z) // form: (at X Y Z)
int nchild = data->GetNumberOfChildren(); int nchild = data->GetNumberOfChildren();
@ -221,7 +221,7 @@ bool Get3DCoordinate( SEXPR::SEXPR* data, TRIPLET& aCoordinate )
} }
bool GetXYZRotation( SEXPR::SEXPR* data, TRIPLET& aRotation ) bool GetXYZRotation( const SEXPR::SEXPR* data, TRIPLET& aRotation )
{ {
const char bad_rotation[] = "* invalid 3D rotation"; const char bad_rotation[] = "* invalid 3D rotation";

View File

@ -93,10 +93,10 @@ struct TRIPLET
std::ostream& operator<<( std::ostream& aStream, const TRIPLET& aTriplet ); std::ostream& operator<<( std::ostream& aStream, const TRIPLET& aTriplet );
bool Get2DPositionAndRotation( SEXPR::SEXPR* data, DOUBLET& aPosition, double& aRotation ); bool Get2DPositionAndRotation( const SEXPR::SEXPR* data, DOUBLET& aPosition, double& aRotation );
bool Get2DCoordinate( SEXPR::SEXPR* data, DOUBLET& aCoordinate ); bool Get2DCoordinate( const SEXPR::SEXPR* data, DOUBLET& aCoordinate );
bool Get3DCoordinate( SEXPR::SEXPR* data, TRIPLET& aCoordinate ); bool Get3DCoordinate( const SEXPR::SEXPR* data, TRIPLET& aCoordinate );
bool GetXYZRotation( SEXPR::SEXPR* data, TRIPLET& aRotation ); bool GetXYZRotation( const SEXPR::SEXPR* data, TRIPLET& aRotation );
/** /**
* Get the layer name from a layer element, if the layer is syntactically * Get the layer name from a layer element, if the layer is syntactically

View File

@ -49,7 +49,7 @@ KICADPAD::~KICADPAD()
} }
bool KICADPAD::Read( SEXPR::SEXPR* aEntry ) bool KICADPAD::Read( const SEXPR::SEXPR* aEntry )
{ {
// form: ( pad N thru_hole shape (at x y {r}) (size x y) (drill {oval} x {y}) (layers X X X) ) // form: ( pad N thru_hole shape (at x y {r}) (size x y) (drill {oval} x {y}) (layers X X X) )
int nchild = aEntry->GetNumberOfChildren(); int nchild = aEntry->GetNumberOfChildren();
@ -100,7 +100,7 @@ bool KICADPAD::Read( SEXPR::SEXPR* aEntry )
} }
bool KICADPAD::parseDrill( SEXPR::SEXPR* aDrill ) bool KICADPAD::parseDrill( const SEXPR::SEXPR* aDrill )
{ {
// form: (drill {oval} X {Y}) // form: (drill {oval} X {Y})
const char bad_drill[] = "* corrupt module in PCB file; bad drill"; const char bad_drill[] = "* corrupt module in PCB file; bad drill";

View File

@ -45,15 +45,15 @@ class KICADPAD
{ {
private: private:
bool m_thruhole; bool m_thruhole;
bool parseDrill( SEXPR::SEXPR* aDrill ); bool parseDrill( const SEXPR::SEXPR* aDrill );
public: public:
KICADPAD(); KICADPAD();
virtual ~KICADPAD(); virtual ~KICADPAD();
bool Read( SEXPR::SEXPR* aEntry ); bool Read( const SEXPR::SEXPR* aEntry );
bool IsThruHole() bool IsThruHole() const
{ {
return m_thruhole; return m_thruhole;
} }

View File

@ -460,7 +460,7 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
// add a pad hole or slot // add a pad hole or slot
bool PCBMODEL::AddPadHole( KICADPAD* aPad ) bool PCBMODEL::AddPadHole( const KICADPAD* aPad )
{ {
if( NULL == aPad || !aPad->IsThruHole() ) if( NULL == aPad || !aPad->IsThruHole() )
return false; return false;
@ -1623,7 +1623,7 @@ bool OUTLINE::addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBL
} }
bool OUTLINE::testClosed( KICADCURVE& aFrontCurve, KICADCURVE& aBackCurve ) bool OUTLINE::testClosed( const KICADCURVE& aFrontCurve, const KICADCURVE& aBackCurve )
{ {
double spx0, spy0, epx0, epy0; double spx0, spy0, epx0, epy0;
getEndPoints( aFrontCurve, spx0, spy0, epx0, epy0 ); getEndPoints( aFrontCurve, spx0, spy0, epx0, epy0 );

View File

@ -53,7 +53,7 @@ private:
double m_minDistance2; // min squared distance to treat points as separate entities (mm) double m_minDistance2; // min squared distance to treat points as separate entities (mm)
bool addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBLET& aLastPoint ); bool addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBLET& aLastPoint );
bool testClosed( KICADCURVE& aFrontCurve, KICADCURVE& aBackCurve ); bool testClosed( const KICADCURVE& aFrontCurve, const KICADCURVE& aBackCurve );
public: public:
std::list< KICADCURVE > m_curves; // list of contiguous segments std::list< KICADCURVE > m_curves; // list of contiguous segments
@ -118,7 +118,7 @@ public:
bool AddOutlineSegment( KICADCURVE* aCurve ); bool AddOutlineSegment( KICADCURVE* aCurve );
// add a pad hole or slot (must be in final position) // add a pad hole or slot (must be in final position)
bool AddPadHole( KICADPAD* aPad ); bool AddPadHole( const KICADPAD* aPad );
// add a component at the given position and orientation // add a component at the given position and orientation
bool AddComponent( const std::string& aFileName, const std::string& aRefDes, bool AddComponent( const std::string& aFileName, const std::string& aRefDes,
@ -149,4 +149,4 @@ public:
bool WriteSTEP( const wxString& aFileName ); bool WriteSTEP( const wxString& aFileName );
}; };
#endif //OCE_VIS_OCE_UTILS_H #endif // OCE_VIS_OCE_UTILS_H