kicad/pcbnew/cleanup_item.h

125 lines
3.3 KiB
C
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 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
*/
#ifndef CLEANUP_ITEM_H
#define CLEANUP_ITEM_H
#include <rc_item.h>
#include <drc/drc.h>
class PCB_BASE_FRAME;
enum CLEANUP_RC_CODE {
CLEANUP_FIRST = DRCE_LAST + 1,
CLEANUP_SHORT = CLEANUP_FIRST,
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,
CLEANUP_LINES_TO_RECT
};
class CLEANUP_ITEM : public RC_ITEM
{
public:
CLEANUP_ITEM( int aErrorCode );
/**
* Function GetErrorText
* returns the string form of a drc error code.
*/
wxString GetErrorText( int aErrorCode = -1, bool aTranslate = true ) const override;
/**
* Function ShowHtml
* translates this object into a fragment of HTML suitable for the wxHtmlListBox class.
* @return wxString - the html text.
*/
wxString ShowHtml( PCB_BASE_FRAME* aFrame ) const;
};
/**
* VECTOR_CLEANUP_ITEMS_PROVIDER
* is an implementation of the interface named RC_ITEMS_PROVIDER which uses a vector
* 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
{
std::vector<CLEANUP_ITEM*>* m_sourceVector; // owns its CLEANUP_ITEMs
public:
VECTOR_CLEANUP_ITEMS_PROVIDER( std::vector<CLEANUP_ITEM*>* aList ) :
m_sourceVector( aList )
{
}
void SetSeverities( int aSeverities ) override
{
}
int GetCount( int aSeverity = -1 ) override
{
return m_sourceVector->size();
}
CLEANUP_ITEM* GetItem( int aIndex ) override
{
return m_sourceVector->at( aIndex );
}
void DeleteItem( int aIndex, bool aDeep ) override
{
if( aDeep )
{
CLEANUP_ITEM* item = m_sourceVector->at( aIndex );
delete item;
m_sourceVector->erase( m_sourceVector->begin() + aIndex );
}
}
void DeleteAllItems() override
{
if( m_sourceVector )
{
for( CLEANUP_ITEM* item : *m_sourceVector )
delete item;
m_sourceVector->clear();
}
}
};
#endif // CLEANUP_ITEM_H