2020-06-17 12:46:50 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2022-09-24 16:29:14 +00:00
|
|
|
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-06-17 12:46:50 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CLEANUP_ITEM_H
|
|
|
|
#define CLEANUP_ITEM_H
|
|
|
|
|
2020-09-15 19:13:45 +00:00
|
|
|
#include <drc/drc_item.h>
|
2020-06-17 12:46:50 +00:00
|
|
|
|
|
|
|
class PCB_BASE_FRAME;
|
|
|
|
|
|
|
|
|
|
|
|
enum CLEANUP_RC_CODE {
|
|
|
|
CLEANUP_FIRST = DRCE_LAST + 1,
|
2022-03-18 11:04:17 +00:00
|
|
|
CLEANUP_SHORTING_TRACK = CLEANUP_FIRST,
|
2020-08-18 18:32:43 +00:00
|
|
|
CLEANUP_SHORTING_VIA,
|
2020-06-17 12:46:50 +00:00
|
|
|
CLEANUP_REDUNDANT_VIA,
|
|
|
|
CLEANUP_DUPLICATE_TRACK,
|
|
|
|
CLEANUP_MERGE_TRACKS,
|
|
|
|
CLEANUP_DANGLING_TRACK,
|
|
|
|
CLEANUP_DANGLING_VIA,
|
|
|
|
CLEANUP_ZERO_LENGTH_TRACK,
|
|
|
|
CLEANUP_TRACK_IN_PAD,
|
|
|
|
CLEANUP_NULL_GRAPHIC,
|
|
|
|
CLEANUP_DUPLICATE_GRAPHIC,
|
2022-09-24 16:29:14 +00:00
|
|
|
CLEANUP_LINES_TO_RECT,
|
|
|
|
CLEANUP_MERGE_PAD
|
2020-06-17 12:46:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CLEANUP_ITEM : public RC_ITEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CLEANUP_ITEM( int aErrorCode );
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Return the string form of a drc error code.
|
2020-06-17 12:46:50 +00:00
|
|
|
*/
|
2020-06-08 02:19:46 +00:00
|
|
|
wxString GetErrorText( int aErrorCode = -1, bool aTranslate = true ) const;
|
2021-06-04 13:04:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxString m_errorMessage;
|
2020-06-17 12:46:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* An implementation of the interface named RC_ITEMS_PROVIDER which uses a vector
|
2020-06-17 12:46:50 +00:00
|
|
|
* of pointers to CLEANUP_ITEMs to fulfill the interface. No ownership is taken of the
|
|
|
|
* vector.
|
|
|
|
*/
|
|
|
|
class VECTOR_CLEANUP_ITEMS_PROVIDER : public RC_ITEMS_PROVIDER
|
|
|
|
{
|
|
|
|
public:
|
2020-08-11 13:33:16 +00:00
|
|
|
VECTOR_CLEANUP_ITEMS_PROVIDER( std::vector<std::shared_ptr<CLEANUP_ITEM> >* aList ) :
|
2020-06-17 12:46:50 +00:00
|
|
|
m_sourceVector( aList )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSeverities( int aSeverities ) override
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
int GetCount( int aSeverity = -1 ) const override
|
2020-06-17 12:46:50 +00:00
|
|
|
{
|
|
|
|
return m_sourceVector->size();
|
|
|
|
}
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
std::shared_ptr<RC_ITEM> GetItem( int aIndex ) const override
|
2020-06-17 12:46:50 +00:00
|
|
|
{
|
|
|
|
return m_sourceVector->at( aIndex );
|
|
|
|
}
|
|
|
|
|
2020-08-11 13:33:16 +00:00
|
|
|
std::shared_ptr<CLEANUP_ITEM> GetCleanupItem( int aIndex )
|
|
|
|
{
|
|
|
|
return m_sourceVector->at( aIndex );
|
|
|
|
}
|
|
|
|
|
2020-06-17 12:46:50 +00:00
|
|
|
void DeleteItem( int aIndex, bool aDeep ) override
|
|
|
|
{
|
|
|
|
if( aDeep )
|
|
|
|
{
|
2020-08-11 13:33:16 +00:00
|
|
|
auto item = m_sourceVector->at( aIndex );
|
2020-06-17 12:46:50 +00:00
|
|
|
m_sourceVector->erase( m_sourceVector->begin() + aIndex );
|
|
|
|
}
|
|
|
|
}
|
2020-08-04 00:41:56 +00:00
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
private:
|
|
|
|
std::vector<std::shared_ptr<CLEANUP_ITEM> >* m_sourceVector; // owns its CLEANUP_ITEMs
|
2020-06-17 12:46:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CLEANUP_ITEM_H
|