31 changed files with 1169 additions and 941 deletions
-
7include/board_design_settings.h
-
3pcbnew/CMakeLists.txt
-
77pcbnew/board_connected_item.cpp
-
13pcbnew/board_connected_item.h
-
27pcbnew/board_design_settings.cpp
-
5pcbnew/class_board.cpp
-
4pcbnew/class_track.cpp
-
8pcbnew/class_zone.cpp
-
4pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp
-
911pcbnew/drc/drc.cpp
-
79pcbnew/drc/drc.h
-
259pcbnew/drc/drc_clearance_test_functions.cpp
-
62pcbnew/drc/drc_drilled_hole_tester.cpp
-
2pcbnew/drc/drc_drilled_hole_tester.h
-
193pcbnew/drc/drc_keepout_tester.cpp
-
52pcbnew/drc/drc_keepout_tester.h
-
162pcbnew/drc/drc_netclass_tester.cpp
-
54pcbnew/drc/drc_netclass_tester.h
-
87pcbnew/drc/drc_textvar_tester.cpp
-
48pcbnew/drc/drc_textvar_tester.h
-
4pcbnew/eagle_plugin.cpp
-
2pcbnew/footprint_viewer_frame.cpp
-
2pcbnew/footprint_wizard_frame.cpp
-
10pcbnew/legacy_plugin.cpp
-
5pcbnew/netclass.h
-
10pcbnew/netinfo.h
-
2pcbnew/pcb_parser.cpp
-
2pcbnew/router/pns_sizes_settings.cpp
-
12pcbnew/specctra_import_export/specctra_export.cpp
-
3pcbnew/tracks_cleaner.cpp
-
1pcbnew/tracks_cleaner.h
911
pcbnew/drc/drc.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,193 @@ |
|||
/*
|
|||
* 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 |
|||
*/ |
|||
|
|||
|
|||
#include <drc/drc_keepout_tester.h>
|
|||
|
|||
#include <class_module.h>
|
|||
#include <drc/drc.h>
|
|||
|
|||
|
|||
DRC_KEEPOUT_TESTER::DRC_KEEPOUT_TESTER( MARKER_HANDLER aMarkerHandler ) : |
|||
DRC_TEST_PROVIDER( std::move( aMarkerHandler ) ), |
|||
m_units( EDA_UNITS::MILLIMETRES ), |
|||
m_board( nullptr ) |
|||
{ |
|||
} |
|||
|
|||
|
|||
bool DRC_KEEPOUT_TESTER::RunDRC( EDA_UNITS aUnits, BOARD& aBoard ) |
|||
{ |
|||
bool success = true; |
|||
|
|||
m_units = aUnits; |
|||
m_board = &aBoard; |
|||
|
|||
// Get a list of all zones to inspect, from both board and footprints
|
|||
std::list<ZONE_CONTAINER*> areasToInspect = m_board->GetZoneList( true ); |
|||
|
|||
// Test keepout areas for vias, tracks and pads inside keepout areas
|
|||
for( ZONE_CONTAINER* area : areasToInspect ) |
|||
{ |
|||
if( area->GetIsKeepout() ) |
|||
{ |
|||
if( area->GetDoNotAllowTracks() || area->GetDoNotAllowVias() ) |
|||
success &= checkTracksAndVias( area ); |
|||
|
|||
if( area->GetDoNotAllowPads() || area->GetDoNotAllowFootprints() ) |
|||
success &= checkFootprints( area ); |
|||
} |
|||
} |
|||
|
|||
return success; |
|||
} |
|||
|
|||
|
|||
bool DRC_KEEPOUT_TESTER::checkTracksAndVias( ZONE_CONTAINER* aKeepout ) |
|||
{ |
|||
bool success = true; |
|||
|
|||
for( TRACK* segm : m_board->Tracks() ) |
|||
{ |
|||
if( segm->Type() == PCB_TRACE_T && aKeepout->GetDoNotAllowTracks() ) |
|||
{ |
|||
// Ignore if the keepout zone is not on the same layer
|
|||
if( !aKeepout->IsOnLayer( segm->GetLayer() ) ) |
|||
continue; |
|||
|
|||
int widths = segm->GetWidth() / 2; |
|||
SEG trackSeg( segm->GetStart(), segm->GetEnd() ); |
|||
SEG::ecoord center2center_squared = aKeepout->Outline()->SquaredDistance( trackSeg ); |
|||
|
|||
if( center2center_squared <= SEG::Square( widths) ) |
|||
{ |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_TRACK_INSIDE_KEEPOUT ); |
|||
drcItem->SetItems( segm, aKeepout ); |
|||
|
|||
HandleMarker( new MARKER_PCB( drcItem, DRC::GetLocation( segm, aKeepout ) ) ); |
|||
success = false; |
|||
} |
|||
} |
|||
else if( segm->Type() == PCB_VIA_T && aKeepout->GetDoNotAllowVias() ) |
|||
{ |
|||
if( !aKeepout->CommonLayerExists( segm->GetLayerSet() ) ) |
|||
continue; |
|||
|
|||
int widths = segm->GetWidth() / 2; |
|||
wxPoint viaPos = segm->GetPosition(); |
|||
SEG::ecoord center2center_squared = aKeepout->Outline()->SquaredDistance( viaPos ); |
|||
|
|||
if( center2center_squared <= SEG::Square( widths) ) |
|||
{ |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_VIA_INSIDE_KEEPOUT ); |
|||
drcItem->SetItems( segm, aKeepout ); |
|||
|
|||
HandleMarker( new MARKER_PCB( drcItem, DRC::GetLocation( segm, aKeepout ) ) ); |
|||
success = false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return success; |
|||
} |
|||
|
|||
|
|||
bool DRC_KEEPOUT_TESTER::checkFootprints( ZONE_CONTAINER* aKeepout ) |
|||
{ |
|||
bool success = true; |
|||
EDA_RECT areaBBox = aKeepout->GetBoundingBox(); |
|||
bool checkFront = aKeepout->CommonLayerExists( LSET::FrontMask() ); |
|||
bool checkBack = aKeepout->CommonLayerExists( LSET::BackMask() ); |
|||
|
|||
for( MODULE* fp : m_board->Modules() ) |
|||
{ |
|||
if( aKeepout->GetDoNotAllowFootprints() && ( fp->IsFlipped() ? checkBack : checkFront ) ) |
|||
{ |
|||
// Fast test to detect a footprint inside the keepout area bounding box.
|
|||
if( areaBBox.Intersects( fp->GetBoundingBox() ) ) |
|||
{ |
|||
SHAPE_POLY_SET outline; |
|||
|
|||
if( fp->BuildPolyCourtyard() ) |
|||
{ |
|||
outline = fp->IsFlipped() ? fp->GetPolyCourtyardBack() |
|||
: fp->GetPolyCourtyardFront(); |
|||
} |
|||
|
|||
if( outline.OutlineCount() == 0 ) |
|||
outline = fp->GetBoundingPoly(); |
|||
|
|||
// Build the common area between footprint and the keepout area:
|
|||
outline.BooleanIntersection( *aKeepout->Outline(), SHAPE_POLY_SET::PM_FAST ); |
|||
|
|||
// If it's not empty then we have a violation
|
|||
if( outline.OutlineCount() ) |
|||
{ |
|||
const VECTOR2I& pt = outline.CVertex( 0, 0, -1 ); |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_FOOTPRINT_INSIDE_KEEPOUT ); |
|||
drcItem->SetItems( fp, aKeepout ); |
|||
|
|||
HandleMarker( new MARKER_PCB( drcItem, (wxPoint) pt ) ); |
|||
success = false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
if( aKeepout->GetDoNotAllowPads() ) |
|||
{ |
|||
for( D_PAD* pad : fp->Pads() ) |
|||
{ |
|||
if( !aKeepout->CommonLayerExists( pad->GetLayerSet() ) ) |
|||
continue; |
|||
|
|||
// Fast test to detect a pad inside the keepout area bounding box.
|
|||
EDA_RECT padBBox( pad->ShapePos(), wxSize() ); |
|||
padBBox.Inflate( pad->GetBoundingRadius() ); |
|||
|
|||
if( areaBBox.Intersects( padBBox ) ) |
|||
{ |
|||
SHAPE_POLY_SET outline; |
|||
pad->TransformShapeWithClearanceToPolygon( outline, 0 ); |
|||
|
|||
// Build the common area between pad and the keepout area:
|
|||
outline.BooleanIntersection( *aKeepout->Outline(), SHAPE_POLY_SET::PM_FAST ); |
|||
|
|||
// If it's not empty then we have a violation
|
|||
if( outline.OutlineCount() ) |
|||
{ |
|||
const VECTOR2I& pt = outline.CVertex( 0, 0, -1 ); |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_PAD_INSIDE_KEEPOUT ); |
|||
drcItem->SetItems( pad, aKeepout ); |
|||
|
|||
HandleMarker( new MARKER_PCB( drcItem, (wxPoint) pt ) ); |
|||
success = false; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
return success; |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,52 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 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 |
|||
*/ |
|||
|
|||
|
|||
#ifndef DRC_KEEPOUT_TESTER__H |
|||
#define DRC_KEEPOUT_TESTER__H |
|||
|
|||
#include <drc/drc_provider.h> |
|||
|
|||
|
|||
class BOARD; |
|||
|
|||
|
|||
class DRC_KEEPOUT_TESTER : public DRC_TEST_PROVIDER |
|||
{ |
|||
public: |
|||
DRC_KEEPOUT_TESTER( MARKER_HANDLER aMarkerHandler ); |
|||
|
|||
virtual ~DRC_KEEPOUT_TESTER() {}; |
|||
|
|||
bool RunDRC( EDA_UNITS aUnits, BOARD& aBoard ) override; |
|||
|
|||
private: |
|||
bool checkTracksAndVias( ZONE_CONTAINER* aKeepout ); |
|||
bool checkFootprints( ZONE_CONTAINER* aKeepout ); |
|||
|
|||
private: |
|||
EDA_UNITS m_units; |
|||
BOARD* m_board; |
|||
}; |
|||
|
|||
#endif // DRC_KEEPOUT_TESTER__H |
|||
@ -0,0 +1,162 @@ |
|||
/*
|
|||
* 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 |
|||
*/ |
|||
|
|||
|
|||
#include <drc/drc_netclass_tester.h>
|
|||
|
|||
|
|||
DRC_NETCLASS_TESTER::DRC_NETCLASS_TESTER( MARKER_HANDLER aMarkerHandler ) : |
|||
DRC_TEST_PROVIDER( std::move( aMarkerHandler ) ), |
|||
m_units( EDA_UNITS::MILLIMETRES ), |
|||
m_board( nullptr ) |
|||
{ |
|||
} |
|||
|
|||
|
|||
bool DRC_NETCLASS_TESTER::RunDRC( EDA_UNITS aUnits, BOARD& aBoard ) |
|||
{ |
|||
m_units = aUnits; |
|||
m_board = &aBoard; |
|||
|
|||
bool success = true; |
|||
NETCLASSES& netclasses = m_board->GetDesignSettings().m_NetClasses; |
|||
|
|||
success &= checkNetClass( netclasses.GetDefault() ); |
|||
|
|||
for( NETCLASSES::const_iterator i = netclasses.begin(); i != netclasses.end(); ++i ) |
|||
success &= checkNetClass( i->second ); |
|||
|
|||
return success; |
|||
} |
|||
|
|||
|
|||
bool DRC_NETCLASS_TESTER::checkNetClass( const NETCLASSPTR& nc ) |
|||
{ |
|||
bool ret = true; |
|||
|
|||
const BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings(); |
|||
|
|||
if( nc->GetClearance() < bds.m_MinClearance ) |
|||
{ |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_NETCLASS_CLEARANCE ); |
|||
|
|||
m_msg.Printf( drcItem->GetErrorText() + _( " (board minimum %s; %s netclass %s)" ), |
|||
MessageTextFromValue( m_units, bds.m_MinClearance, true ), |
|||
nc->GetName(), |
|||
MessageTextFromValue( m_units, nc->GetClearance(), true ) ); |
|||
|
|||
drcItem->SetErrorMessage( m_msg ); |
|||
HandleMarker( new MARKER_PCB( drcItem, wxPoint() ) ); |
|||
ret = false; |
|||
} |
|||
|
|||
if( nc->GetTrackWidth() < bds.m_TrackMinWidth ) |
|||
{ |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_NETCLASS_TRACKWIDTH ); |
|||
|
|||
m_msg.Printf( drcItem->GetErrorText() + _( " (board minimum %s; %s netclass %s)" ), |
|||
MessageTextFromValue( m_units, bds.m_TrackMinWidth, true ), |
|||
nc->GetName(), |
|||
MessageTextFromValue( m_units, nc->GetTrackWidth(), true ) ); |
|||
|
|||
drcItem->SetErrorMessage( m_msg ); |
|||
HandleMarker( new MARKER_PCB( drcItem, wxPoint() ) ); |
|||
ret = false; |
|||
} |
|||
|
|||
if( nc->GetViaDiameter() < bds.m_ViasMinSize ) |
|||
{ |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_NETCLASS_VIASIZE ); |
|||
|
|||
m_msg.Printf( drcItem->GetErrorText() + _( " (board minimum %s; %s netclass %s)" ), |
|||
MessageTextFromValue( m_units, bds.m_ViasMinSize, true ), |
|||
nc->GetName(), |
|||
MessageTextFromValue( m_units, nc->GetViaDiameter(), true ) ); |
|||
|
|||
drcItem->SetErrorMessage( m_msg ); |
|||
HandleMarker( new MARKER_PCB( drcItem, wxPoint() ) ); |
|||
ret = false; |
|||
} |
|||
|
|||
if( nc->GetViaDrill() < bds.m_MinThroughDrill ) |
|||
{ |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_NETCLASS_VIADRILLSIZE ); |
|||
|
|||
m_msg.Printf( drcItem->GetErrorText() + _( " (board min through hole %s; %s netclass %s)" ), |
|||
MessageTextFromValue( m_units, bds.m_MinThroughDrill, true ), |
|||
nc->GetName(), |
|||
MessageTextFromValue( m_units, nc->GetViaDrill(), true ) ); |
|||
|
|||
drcItem->SetErrorMessage( m_msg ); |
|||
HandleMarker( new MARKER_PCB( drcItem, wxPoint() ) ); |
|||
ret = false; |
|||
} |
|||
|
|||
int ncViaAnnulus = ( nc->GetViaDiameter() - nc->GetViaDrill() ) / 2; |
|||
|
|||
if( ncViaAnnulus < bds.m_ViasMinAnnulus ) |
|||
{ |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_NETCLASS_VIAANNULUS ); |
|||
|
|||
m_msg.Printf( drcItem->GetErrorText() + _( " (board minimum %s; %s netclass %s)" ), |
|||
MessageTextFromValue( m_units, bds.m_ViasMinAnnulus, true ), |
|||
nc->GetName(), |
|||
MessageTextFromValue( m_units, ncViaAnnulus, true ) ); |
|||
|
|||
drcItem->SetErrorMessage( m_msg ); |
|||
HandleMarker( new MARKER_PCB( drcItem, wxPoint() ) ); |
|||
ret = false; |
|||
} |
|||
|
|||
if( nc->GetuViaDiameter() < bds.m_MicroViasMinSize ) |
|||
{ |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_NETCLASS_uVIASIZE ); |
|||
|
|||
m_msg.Printf( drcItem->GetErrorText() + _( " (board minimum %s; %s netclass %s)" ), |
|||
MessageTextFromValue( m_units, bds.m_MicroViasMinSize, true ), |
|||
nc->GetName(), |
|||
MessageTextFromValue( m_units, nc->GetuViaDiameter(), true ) ); |
|||
|
|||
drcItem->SetErrorMessage( m_msg ); |
|||
HandleMarker( new MARKER_PCB( drcItem, wxPoint() ) ); |
|||
ret = false; |
|||
} |
|||
|
|||
if( nc->GetuViaDrill() < bds.m_MicroViasMinDrill ) |
|||
{ |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_NETCLASS_uVIADRILLSIZE ); |
|||
|
|||
m_msg.Printf( drcItem->GetErrorText() + _( " (board minimum %s; %s netclass %s)" ), |
|||
MessageTextFromValue( m_units, bds.m_MicroViasMinDrill, true ), |
|||
nc->GetName(), |
|||
MessageTextFromValue( m_units, nc->GetuViaDrill(), true ) ); |
|||
|
|||
drcItem->SetErrorMessage( m_msg ); |
|||
HandleMarker( new MARKER_PCB( drcItem, wxPoint() ) ); |
|||
ret = false; |
|||
} |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,54 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 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 |
|||
*/ |
|||
|
|||
|
|||
#ifndef DRC_NETCLASS_TESTER__H |
|||
#define DRC_NETCLASS_TESTER__H |
|||
|
|||
#include <drc/drc_provider.h> |
|||
|
|||
|
|||
class BOARD; |
|||
class BOARD_ITEM; |
|||
|
|||
|
|||
class DRC_NETCLASS_TESTER : public DRC_TEST_PROVIDER |
|||
{ |
|||
public: |
|||
DRC_NETCLASS_TESTER( MARKER_HANDLER aMarkerHandler ); |
|||
|
|||
virtual ~DRC_NETCLASS_TESTER() {}; |
|||
|
|||
bool RunDRC( EDA_UNITS aUnits, BOARD& aBoard ) override; |
|||
|
|||
private: |
|||
bool checkNetClass( const NETCLASSPTR& nc ); |
|||
|
|||
private: |
|||
EDA_UNITS m_units; |
|||
BOARD* m_board; |
|||
|
|||
wxString m_msg; // Construct only once for performance |
|||
}; |
|||
|
|||
#endif // DRC_NETCLASS_TESTER__H |
|||
@ -0,0 +1,87 @@ |
|||
/*
|
|||
* 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 |
|||
*/ |
|||
|
|||
|
|||
#include <drc/drc_textvar_tester.h>
|
|||
|
|||
#include <class_module.h>
|
|||
#include <class_pcb_text.h>
|
|||
|
|||
|
|||
DRC_TEXTVAR_TESTER::DRC_TEXTVAR_TESTER( MARKER_HANDLER aMarkerHandler ) : |
|||
DRC_TEST_PROVIDER( std::move( aMarkerHandler ) ), |
|||
m_units( EDA_UNITS::MILLIMETRES ), |
|||
m_board( nullptr ) |
|||
{ |
|||
} |
|||
|
|||
|
|||
bool DRC_TEXTVAR_TESTER::RunDRC( EDA_UNITS aUnits, BOARD& aBoard ) |
|||
{ |
|||
bool success = true; |
|||
|
|||
m_units = aUnits; |
|||
m_board = &aBoard; |
|||
|
|||
for( MODULE* module : m_board->Modules() ) |
|||
{ |
|||
module->RunOnChildren( |
|||
[&]( BOARD_ITEM* child ) |
|||
{ |
|||
if( child->Type() == PCB_MODULE_TEXT_T ) |
|||
{ |
|||
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( child ); |
|||
|
|||
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) ) |
|||
{ |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_UNRESOLVED_VARIABLE ); |
|||
drcItem->SetItems( text ); |
|||
|
|||
HandleMarker( new MARKER_PCB( drcItem, text->GetPosition() ) ); |
|||
success = false; |
|||
} |
|||
} |
|||
} ); |
|||
} |
|||
|
|||
for( BOARD_ITEM* drawing : m_board->Drawings() ) |
|||
{ |
|||
if( drawing->Type() == PCB_TEXT_T ) |
|||
{ |
|||
TEXTE_PCB* text = static_cast<TEXTE_PCB*>( drawing ); |
|||
|
|||
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) ) |
|||
{ |
|||
DRC_ITEM* drcItem = new DRC_ITEM( DRCE_UNRESOLVED_VARIABLE ); |
|||
drcItem->SetItems( text ); |
|||
|
|||
HandleMarker( new MARKER_PCB( drcItem, text->GetPosition() ) ); |
|||
success = false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return success; |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,48 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 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 |
|||
*/ |
|||
|
|||
|
|||
#ifndef DRC_TEXTVAR_TESTER__H |
|||
#define DRC_TEXTVAR_TESTER__H |
|||
|
|||
#include <drc/drc_provider.h> |
|||
|
|||
|
|||
class BOARD; |
|||
|
|||
|
|||
class DRC_TEXTVAR_TESTER : public DRC_TEST_PROVIDER |
|||
{ |
|||
public: |
|||
DRC_TEXTVAR_TESTER( MARKER_HANDLER aMarkerHandler ); |
|||
|
|||
virtual ~DRC_TEXTVAR_TESTER() {}; |
|||
|
|||
bool RunDRC( EDA_UNITS aUnits, BOARD& aBoard ) override; |
|||
|
|||
private: |
|||
EDA_UNITS m_units; |
|||
BOARD* m_board; |
|||
}; |
|||
|
|||
#endif // DRC_TEXTVAR_TESTER__H |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue