2020-06-13 23:28:08 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 KiCad Developers, see change_log.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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2020-09-11 15:04:11 +00:00
|
|
|
#ifndef DRC_TEST_PROVIDER__H
|
|
|
|
#define DRC_TEST_PROVIDER__H
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <pcb_marker.h>
|
2020-06-13 23:28:08 +00:00
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
class DRC_ENGINE;
|
2020-09-11 15:04:11 +00:00
|
|
|
class DRC_TEST_PROVIDER;
|
|
|
|
|
2020-10-25 20:24:47 +00:00
|
|
|
class DRC_TEST_PROVIDER_REGISTRY
|
2020-06-17 22:36:54 +00:00
|
|
|
{
|
2020-09-11 15:04:11 +00:00
|
|
|
public:
|
|
|
|
DRC_TEST_PROVIDER_REGISTRY() {};
|
|
|
|
~DRC_TEST_PROVIDER_REGISTRY() {};
|
2020-06-17 22:36:54 +00:00
|
|
|
|
2020-09-11 15:04:11 +00:00
|
|
|
static DRC_TEST_PROVIDER_REGISTRY& Instance()
|
|
|
|
{
|
|
|
|
static DRC_TEST_PROVIDER_REGISTRY self;
|
|
|
|
return self;
|
|
|
|
}
|
2020-06-17 22:36:54 +00:00
|
|
|
|
2020-09-11 15:04:11 +00:00
|
|
|
void RegisterTestProvider( DRC_TEST_PROVIDER* provider ) { m_providers.push_back( provider ); }
|
|
|
|
std::vector<DRC_TEST_PROVIDER*> GetTestProviders() const { return m_providers; }
|
2020-06-17 22:36:54 +00:00
|
|
|
|
2020-09-11 15:04:11 +00:00
|
|
|
private:
|
|
|
|
std::vector<DRC_TEST_PROVIDER*> m_providers;
|
2020-06-17 22:36:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template<class T> class DRC_REGISTER_TEST_PROVIDER
|
|
|
|
{
|
2020-09-11 15:04:11 +00:00
|
|
|
public:
|
|
|
|
DRC_REGISTER_TEST_PROVIDER()
|
|
|
|
{
|
|
|
|
T* provider = new T;
|
|
|
|
DRC_TEST_PROVIDER_REGISTRY::Instance().RegisterTestProvider( provider );
|
|
|
|
}
|
2020-06-17 22:36:54 +00:00
|
|
|
};
|
|
|
|
|
2020-06-13 23:28:08 +00:00
|
|
|
/**
|
|
|
|
* DRC_TEST_PROVIDER
|
|
|
|
* is a base class that represents a DRC "provider" which runs some DRC functions over a
|
2020-09-14 17:54:14 +00:00
|
|
|
* #BOARD and spits out #DRC_ITEMs and positions as needed.
|
2020-06-13 23:28:08 +00:00
|
|
|
*/
|
|
|
|
class DRC_TEST_PROVIDER
|
|
|
|
{
|
|
|
|
public:
|
2020-06-17 22:36:54 +00:00
|
|
|
DRC_TEST_PROVIDER ();
|
2020-06-13 23:28:08 +00:00
|
|
|
virtual ~DRC_TEST_PROVIDER() {}
|
|
|
|
|
2020-06-17 22:36:54 +00:00
|
|
|
void SetDRCEngine( DRC_ENGINE *engine )
|
|
|
|
{
|
|
|
|
m_drcEngine = engine;
|
2020-10-24 21:16:07 +00:00
|
|
|
m_stats.clear();
|
2020-06-17 22:36:54 +00:00
|
|
|
}
|
|
|
|
|
2020-06-13 23:28:08 +00:00
|
|
|
/**
|
|
|
|
* Runs this provider against the given PCB with configured options (if any).
|
|
|
|
*/
|
|
|
|
virtual bool Run() = 0;
|
|
|
|
|
|
|
|
virtual const wxString GetName() const;
|
|
|
|
virtual const wxString GetDescription() const;
|
|
|
|
|
2020-09-13 10:37:20 +00:00
|
|
|
virtual std::set<DRC_CONSTRAINT_TYPE_T> GetConstraintTypes() const = 0;
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
virtual int GetNumPhases() const = 0;
|
|
|
|
|
2020-08-25 17:42:52 +00:00
|
|
|
virtual bool IsRuleDriven() const
|
|
|
|
{
|
|
|
|
return m_isRuleDriven;
|
|
|
|
}
|
|
|
|
|
2020-09-18 14:24:09 +00:00
|
|
|
bool IsEnabled() const
|
|
|
|
{
|
|
|
|
return m_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Enable( bool aEnable )
|
|
|
|
{
|
|
|
|
m_enabled = aEnable;
|
|
|
|
}
|
|
|
|
|
2020-06-13 23:28:08 +00:00
|
|
|
protected:
|
2020-09-12 19:28:22 +00:00
|
|
|
int forEachGeometryItem( const std::vector<KICAD_T>& aTypes, LSET aLayers,
|
|
|
|
const std::function<bool(BOARD_ITEM*)>& aFunc );
|
2020-08-11 22:15:50 +00:00
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
virtual void reportAux( wxString fmt, ... );
|
2020-09-15 11:06:15 +00:00
|
|
|
virtual void reportViolation( std::shared_ptr<DRC_ITEM>& item, wxPoint aMarkerPos );
|
2020-09-18 19:57:54 +00:00
|
|
|
virtual bool reportProgress( int aCount, int aSize, int aDelta );
|
|
|
|
virtual bool reportPhase( const wxString& aStageName );
|
2020-09-14 17:54:14 +00:00
|
|
|
|
2020-07-27 13:32:37 +00:00
|
|
|
virtual void reportRuleStatistics();
|
2020-09-11 13:41:45 +00:00
|
|
|
virtual void accountCheck( const DRC_RULE* ruleToTest );
|
|
|
|
virtual void accountCheck( const DRC_CONSTRAINT& constraintToTest );
|
2020-06-13 23:28:08 +00:00
|
|
|
|
2020-10-02 18:58:12 +00:00
|
|
|
bool isInvisibleText( const BOARD_ITEM* aItem ) const;
|
|
|
|
|
2020-10-25 20:24:47 +00:00
|
|
|
// List of basic (ie: non-compound) geometry items
|
|
|
|
static std::vector<KICAD_T> s_allBasicItems;
|
2020-10-27 17:09:27 +00:00
|
|
|
static std::vector<KICAD_T> s_allBasicItemsButZones;
|
2020-10-25 20:24:47 +00:00
|
|
|
|
2020-09-11 21:50:53 +00:00
|
|
|
EDA_UNITS userUnits() const;
|
|
|
|
DRC_ENGINE* m_drcEngine;
|
2020-09-11 13:41:45 +00:00
|
|
|
std::unordered_map<const DRC_RULE*, int> m_stats;
|
2020-09-11 21:50:53 +00:00
|
|
|
bool m_isRuleDriven = true;
|
2020-10-24 21:16:07 +00:00
|
|
|
bool m_enabled = true;
|
2020-09-11 21:50:53 +00:00
|
|
|
|
|
|
|
wxString m_msg; // Allocating strings gets expensive enough to want to avoid it
|
2020-06-13 23:28:08 +00:00
|
|
|
};
|
|
|
|
|
2020-09-11 15:04:11 +00:00
|
|
|
#endif // DRC_TEST_PROVIDER__H
|