2020-06-08 02:19:46 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 CERN
|
|
|
|
* @author Jon Evans <jon@craftyjon.com>
|
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2024-05-03 18:11:16 +00:00
|
|
|
#include <erc/erc_item.h>
|
|
|
|
#include <erc/erc_settings.h>
|
2020-06-08 02:19:46 +00:00
|
|
|
#include <schematic.h>
|
|
|
|
#include <sch_marker.h>
|
|
|
|
#include <sch_screen.h>
|
2021-06-04 03:52:50 +00:00
|
|
|
#include <settings/json_settings_internals.h>
|
2020-06-08 02:19:46 +00:00
|
|
|
#include <settings/parameters.h>
|
|
|
|
|
|
|
|
|
|
|
|
const int ercSettingsSchemaVersion = 0;
|
|
|
|
|
|
|
|
|
2020-07-03 21:08:17 +00:00
|
|
|
|
|
|
|
#define OK PIN_ERROR::OK
|
2020-07-04 15:51:00 +00:00
|
|
|
#define ERR PIN_ERROR::PP_ERROR
|
2020-07-03 21:08:17 +00:00
|
|
|
#define WAR PIN_ERROR::WARNING
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default Look up table which gives the ERC error level for a pair of connected pins
|
|
|
|
*/
|
|
|
|
PIN_ERROR ERC_SETTINGS::m_defaultPinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL] =
|
2021-01-22 13:04:43 +00:00
|
|
|
{
|
|
|
|
/* I, O, Bi, 3S, Pas, NIC, UnS, PwrI, PwrO, OC, OE, NC */
|
|
|
|
/* I */ { OK, OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, ERR },
|
|
|
|
/* O */ { OK, ERR, OK, WAR, OK, OK, WAR, OK, ERR, ERR, ERR, ERR },
|
|
|
|
/* Bi */ { OK, OK, OK, OK, OK, OK, WAR, OK, WAR, OK, WAR, ERR },
|
|
|
|
/* 3S */ { OK, WAR, OK, OK, OK, OK, WAR, WAR, ERR, WAR, WAR, ERR },
|
|
|
|
/*Pas */ { OK, OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, ERR },
|
|
|
|
/*NIC */ { OK, OK, OK, OK, OK, OK, OK, OK, OK, OK, OK, ERR },
|
|
|
|
/*UnS */ { WAR, WAR, WAR, WAR, WAR, OK, WAR, WAR, WAR, WAR, WAR, ERR },
|
|
|
|
/*PwrI*/ { OK, OK, OK, WAR, OK, OK, WAR, OK, OK, OK, OK, ERR },
|
|
|
|
/*PwrO*/ { OK, ERR, WAR, ERR, OK, OK, WAR, OK, ERR, ERR, ERR, ERR },
|
|
|
|
/* OC */ { OK, ERR, OK, WAR, OK, OK, WAR, OK, ERR, OK, OK, ERR },
|
|
|
|
/* OE */ { OK, ERR, WAR, WAR, OK, OK, WAR, OK, ERR, OK, OK, ERR },
|
|
|
|
/* NC */ { ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR }
|
|
|
|
};
|
2020-07-03 21:08:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Look up table which gives the minimal drive for a pair of connected pins on
|
|
|
|
* a net.
|
|
|
|
* <p>
|
|
|
|
* The initial state of a net is NOC (Net with No Connection). It can be updated to
|
|
|
|
* NPI (Pin Isolated), NET_NC (Net with a no connect symbol), NOD (Not Driven) or DRV
|
|
|
|
* (DRIven). It can be updated to NET_NC with no error only if there is only one pin
|
|
|
|
* in net. Nets are OK when their final state is NET_NC or DRV. Nets with the state
|
|
|
|
* NOD have no valid source signal.
|
|
|
|
*/
|
|
|
|
int ERC_SETTINGS::m_PinMinDrive[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL] =
|
2021-01-22 13:04:43 +00:00
|
|
|
{
|
|
|
|
/* I, O, Bi, 3S, Pas, NIC, UnS, PwrI, PwrO, OC, OE, NC */
|
|
|
|
/* I */ { NOD, DRV, DRV, DRV, DRV, NOD, DRV, NOD, DRV, DRV, DRV, NPI },
|
|
|
|
/* O */ { DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, DRV, DRV, NPI },
|
|
|
|
/* Bi */ { DRV, DRV, DRV, DRV, DRV, NOD, DRV, NOD, DRV, DRV, DRV, NPI },
|
|
|
|
/* 3S */ { DRV, DRV, DRV, DRV, DRV, NOD, DRV, NOD, DRV, DRV, DRV, NPI },
|
|
|
|
/*Pas */ { DRV, DRV, DRV, DRV, DRV, NOD, DRV, NOD, DRV, DRV, DRV, NPI },
|
|
|
|
/*NIC */ { NOD, NOD, NOD, NOD, NOD, NOD, NOD, NOD, NOD, NOD, NOD, NPI },
|
|
|
|
/*UnS */ { DRV, DRV, DRV, DRV, DRV, NOD, DRV, NOD, DRV, DRV, DRV, NPI },
|
|
|
|
/*PwrI*/ { NOD, DRV, NOD, NOD, NOD, NOD, NOD, NOD, DRV, NOD, NOD, NPI },
|
|
|
|
/*PwrO*/ { DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, DRV, DRV, NPI },
|
|
|
|
/* OC */ { DRV, DRV, DRV, DRV, DRV, NOD, DRV, NOD, DRV, DRV, DRV, NPI },
|
|
|
|
/* OE */ { DRV, DRV, DRV, DRV, DRV, NOD, DRV, NOD, DRV, DRV, DRV, NPI },
|
|
|
|
/* NC */ { NPI, NPI, NPI, NPI, NPI, NPI, NPI, NPI, NPI, NPI, NPI, NPI }
|
|
|
|
};
|
2020-07-03 21:08:17 +00:00
|
|
|
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
ERC_SETTINGS::ERC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
|
|
|
|
NESTED_SETTINGS( "erc", ercSettingsSchemaVersion, aParent, aPath )
|
|
|
|
{
|
2020-07-03 21:08:17 +00:00
|
|
|
ResetPinMap();
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
for( int i = ERCE_FIRST; i <= ERCE_LAST; ++i )
|
2022-09-06 20:26:36 +00:00
|
|
|
m_ERCSeverities[ i ] = RPT_SEVERITY_ERROR;
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2020-10-07 13:15:31 +00:00
|
|
|
// Error is the default setting so set non-error priorities here.
|
2022-09-06 20:26:36 +00:00
|
|
|
m_ERCSeverities[ERCE_UNSPECIFIED] = RPT_SEVERITY_UNDEFINED;
|
|
|
|
m_ERCSeverities[ERCE_ENDPOINT_OFF_GRID] = RPT_SEVERITY_WARNING;
|
|
|
|
m_ERCSeverities[ERCE_PIN_TO_PIN_WARNING] = RPT_SEVERITY_WARNING;
|
|
|
|
m_ERCSeverities[ERCE_SIMILAR_LABELS] = RPT_SEVERITY_WARNING;
|
2024-03-15 20:42:32 +00:00
|
|
|
m_ERCSeverities[ERCE_SINGLE_GLOBAL_LABEL] = RPT_SEVERITY_IGNORE;
|
2022-09-06 20:26:36 +00:00
|
|
|
m_ERCSeverities[ERCE_GLOBLABEL] = RPT_SEVERITY_WARNING;
|
|
|
|
m_ERCSeverities[ERCE_DRIVER_CONFLICT] = RPT_SEVERITY_WARNING;
|
|
|
|
m_ERCSeverities[ERCE_BUS_ENTRY_CONFLICT] = RPT_SEVERITY_WARNING;
|
|
|
|
m_ERCSeverities[ERCE_LIB_SYMBOL_ISSUES] = RPT_SEVERITY_WARNING;
|
2024-02-16 13:22:17 +00:00
|
|
|
m_ERCSeverities[ERCE_LIB_SYMBOL_MISMATCH] = RPT_SEVERITY_WARNING;
|
2024-02-01 17:29:16 +00:00
|
|
|
m_ERCSeverities[ERCE_FOOTPRINT_LINK_ISSUES] = RPT_SEVERITY_WARNING;
|
2022-09-06 20:26:36 +00:00
|
|
|
m_ERCSeverities[ERCE_NOCONNECT_CONNECTED] = RPT_SEVERITY_WARNING;
|
|
|
|
m_ERCSeverities[ERCE_NOCONNECT_NOT_CONNECTED] = RPT_SEVERITY_WARNING;
|
2022-11-26 04:40:01 +00:00
|
|
|
m_ERCSeverities[ERCE_MISSING_UNIT] = RPT_SEVERITY_WARNING;
|
|
|
|
m_ERCSeverities[ERCE_MISSING_INPUT_PIN] = RPT_SEVERITY_WARNING;
|
|
|
|
m_ERCSeverities[ERCE_MISSING_BIDI_PIN] = RPT_SEVERITY_WARNING;
|
2023-04-14 15:21:09 +00:00
|
|
|
m_ERCSeverities[ERCE_SIMULATION_MODEL] = RPT_SEVERITY_IGNORE;
|
2024-05-03 19:04:41 +00:00
|
|
|
m_ERCSeverities[ERCE_FOUR_WAY_JUNCTION] = RPT_SEVERITY_IGNORE;
|
2020-06-08 02:19:46 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "rule_severities",
|
|
|
|
[&]() -> nlohmann::json
|
|
|
|
{
|
|
|
|
nlohmann::json ret = {};
|
|
|
|
|
|
|
|
for( const RC_ITEM& item : ERC_ITEM::GetItemsWithSeverities() )
|
|
|
|
{
|
2020-12-14 13:33:51 +00:00
|
|
|
wxString name = item.GetSettingsKey();
|
|
|
|
int code = item.GetErrorCode();
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2022-09-06 20:26:36 +00:00
|
|
|
if( name.IsEmpty() || m_ERCSeverities.count( code ) == 0 )
|
2020-06-08 02:19:46 +00:00
|
|
|
continue;
|
|
|
|
|
2022-09-06 20:26:36 +00:00
|
|
|
ret[std::string( name.ToUTF8() )] = SeverityToString( m_ERCSeverities[code] );
|
2020-06-08 02:19:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
[&]( const nlohmann::json& aJson )
|
|
|
|
{
|
|
|
|
if( !aJson.is_object() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( const RC_ITEM& item : ERC_ITEM::GetItemsWithSeverities() )
|
|
|
|
{
|
|
|
|
int code = item.GetErrorCode();
|
|
|
|
wxString name = item.GetSettingsKey();
|
|
|
|
|
|
|
|
std::string key( name.ToUTF8() );
|
|
|
|
|
|
|
|
if( aJson.contains( key ) )
|
2022-09-06 20:26:36 +00:00
|
|
|
m_ERCSeverities[code] = SeverityFromString( aJson[key] );
|
2020-06-08 02:19:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{} ) );
|
2020-07-03 21:08:17 +00:00
|
|
|
|
2020-11-18 22:55:38 +00:00
|
|
|
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "erc_exclusions",
|
|
|
|
[&]() -> nlohmann::json
|
|
|
|
{
|
|
|
|
nlohmann::json js = nlohmann::json::array();
|
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
for( const wxString& entry : m_ErcExclusions )
|
|
|
|
js.push_back( { entry, m_ErcExclusionComments[ entry ] } );
|
2020-11-18 22:55:38 +00:00
|
|
|
|
|
|
|
return js;
|
|
|
|
},
|
|
|
|
[&]( const nlohmann::json& aObj )
|
|
|
|
{
|
|
|
|
m_ErcExclusions.clear();
|
|
|
|
|
|
|
|
if( !aObj.is_array() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( const nlohmann::json& entry : aObj )
|
|
|
|
{
|
2024-01-29 15:59:28 +00:00
|
|
|
if( entry.is_array() )
|
|
|
|
{
|
|
|
|
wxString serialized = entry[0].get<wxString>();
|
|
|
|
m_ErcExclusions.insert( serialized );
|
|
|
|
m_ErcExclusionComments[ serialized ] = entry[1].get<wxString>();
|
|
|
|
}
|
|
|
|
else if( entry.is_string() )
|
|
|
|
{
|
|
|
|
m_ErcExclusions.insert( entry.get<wxString>() );
|
|
|
|
}
|
2020-11-18 22:55:38 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{} ) );
|
|
|
|
|
2020-07-03 21:08:17 +00:00
|
|
|
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "pin_map",
|
|
|
|
[&]() -> nlohmann::json
|
|
|
|
{
|
|
|
|
nlohmann::json ret = nlohmann::json::array();
|
|
|
|
|
|
|
|
for( int i = 0; i < ELECTRICAL_PINTYPES_TOTAL; i++ )
|
|
|
|
{
|
|
|
|
nlohmann::json inner = nlohmann::json::array();
|
|
|
|
|
|
|
|
for( int j = 0; j < ELECTRICAL_PINTYPES_TOTAL; j++ )
|
|
|
|
inner.push_back( static_cast<int>( GetPinMapValue( i, j ) ) );
|
|
|
|
|
|
|
|
ret.push_back( inner );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
[&]( const nlohmann::json& aJson )
|
|
|
|
{
|
|
|
|
if( !aJson.is_array() || aJson.size() != ELECTRICAL_PINTYPES_TOTAL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( size_t i = 0; i < ELECTRICAL_PINTYPES_TOTAL; i++ )
|
|
|
|
{
|
|
|
|
if( i > aJson.size() - 1 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
nlohmann::json inner = aJson[i];
|
|
|
|
|
|
|
|
if( !inner.is_array() || inner.size() != ELECTRICAL_PINTYPES_TOTAL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( size_t j = 0; j < ELECTRICAL_PINTYPES_TOTAL; j++ )
|
|
|
|
{
|
|
|
|
if( inner[j].is_number_integer() )
|
|
|
|
{
|
|
|
|
int val = inner[j].get<int>();
|
|
|
|
|
|
|
|
if( val >= 0 && val <= static_cast<int>( PIN_ERROR::UNCONNECTED ) )
|
|
|
|
SetPinMapValue( i, j, static_cast<PIN_ERROR>( val ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{} ) );
|
2020-06-08 02:19:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ERC_SETTINGS::~ERC_SETTINGS()
|
|
|
|
{
|
|
|
|
if( m_parent )
|
|
|
|
{
|
|
|
|
m_parent->ReleaseNestedSettings( this );
|
|
|
|
m_parent = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-14 13:33:51 +00:00
|
|
|
SEVERITY ERC_SETTINGS::GetSeverity( int aErrorCode ) const
|
2020-06-08 02:19:46 +00:00
|
|
|
{
|
2024-05-26 15:18:23 +00:00
|
|
|
// Special-case duplicate pin error. Unique pin names are required by KiCad, so this
|
|
|
|
// is always an error.
|
|
|
|
if( aErrorCode == ERCE_DUPLICATE_PIN_ERROR )
|
|
|
|
{
|
|
|
|
return RPT_SEVERITY_ERROR;
|
|
|
|
}
|
2020-06-08 02:19:46 +00:00
|
|
|
// Special-case pin-to-pin errors:
|
|
|
|
// Ignore-or-not is controlled by ERCE_PIN_TO_PIN_WARNING (for both)
|
|
|
|
// Warning-or-error is controlled by which errorCode it is
|
2024-05-26 15:18:23 +00:00
|
|
|
else if( aErrorCode == ERCE_PIN_TO_PIN_ERROR )
|
2020-06-08 02:19:46 +00:00
|
|
|
{
|
2022-09-06 20:26:36 +00:00
|
|
|
wxASSERT( m_ERCSeverities.count( ERCE_PIN_TO_PIN_WARNING ) );
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2022-09-06 20:26:36 +00:00
|
|
|
if( m_ERCSeverities.at( ERCE_PIN_TO_PIN_WARNING ) == RPT_SEVERITY_IGNORE )
|
2020-06-08 02:19:46 +00:00
|
|
|
return RPT_SEVERITY_IGNORE;
|
|
|
|
else
|
|
|
|
return RPT_SEVERITY_ERROR;
|
|
|
|
}
|
|
|
|
else if( aErrorCode == ERCE_PIN_TO_PIN_WARNING )
|
|
|
|
{
|
2022-09-06 20:26:36 +00:00
|
|
|
wxASSERT( m_ERCSeverities.count( ERCE_PIN_TO_PIN_WARNING ) );
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2022-09-06 20:26:36 +00:00
|
|
|
if( m_ERCSeverities.at( ERCE_PIN_TO_PIN_WARNING ) == RPT_SEVERITY_IGNORE )
|
2020-06-08 02:19:46 +00:00
|
|
|
return RPT_SEVERITY_IGNORE;
|
|
|
|
else
|
|
|
|
return RPT_SEVERITY_WARNING;
|
|
|
|
}
|
2024-06-28 15:40:13 +00:00
|
|
|
else if( aErrorCode == ERCE_GENERIC_WARNING )
|
|
|
|
{
|
|
|
|
return RPT_SEVERITY_WARNING;
|
|
|
|
}
|
|
|
|
else if( aErrorCode == ERCE_GENERIC_ERROR )
|
|
|
|
{
|
|
|
|
return RPT_SEVERITY_ERROR;
|
|
|
|
}
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2022-09-06 20:26:36 +00:00
|
|
|
wxCHECK_MSG( m_ERCSeverities.count( aErrorCode ), RPT_SEVERITY_IGNORE,
|
2023-01-17 04:14:38 +00:00
|
|
|
wxS( "Missing severity from map in ERC_SETTINGS!" ) );
|
2020-07-03 21:08:17 +00:00
|
|
|
|
2022-09-06 20:26:36 +00:00
|
|
|
return m_ERCSeverities.at( aErrorCode );
|
2020-06-08 02:19:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-14 13:33:51 +00:00
|
|
|
void ERC_SETTINGS::SetSeverity( int aErrorCode, SEVERITY aSeverity )
|
2020-06-08 02:19:46 +00:00
|
|
|
{
|
2022-09-06 20:26:36 +00:00
|
|
|
m_ERCSeverities[ aErrorCode ] = aSeverity;
|
2020-06-08 02:19:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-03 21:08:17 +00:00
|
|
|
void ERC_SETTINGS::ResetPinMap()
|
|
|
|
{
|
|
|
|
memcpy( m_PinMap, m_defaultPinMap, sizeof( m_PinMap ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
void SHEETLIST_ERC_ITEMS_PROVIDER::visitMarkers( std::function<void( SCH_MARKER* )> aVisitor ) const
|
2020-06-08 02:19:46 +00:00
|
|
|
{
|
2021-01-13 03:18:44 +00:00
|
|
|
std::set<SCH_SCREEN*> seenScreens;
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
for( const SCH_SHEET_PATH& sheet : m_schematic->BuildUnorderedSheetList() )
|
2020-06-08 02:19:46 +00:00
|
|
|
{
|
2024-06-06 10:37:18 +00:00
|
|
|
bool firstTime = seenScreens.count( sheet.LastScreen() ) == 0;
|
2021-01-13 03:18:44 +00:00
|
|
|
|
|
|
|
if( firstTime )
|
2024-06-06 10:37:18 +00:00
|
|
|
seenScreens.insert( sheet.LastScreen() );
|
2021-01-13 03:18:44 +00:00
|
|
|
|
2024-06-06 10:37:18 +00:00
|
|
|
for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_MARKER_T ) )
|
2020-06-08 02:19:46 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
|
2020-06-08 02:19:46 +00:00
|
|
|
|
|
|
|
if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC )
|
|
|
|
continue;
|
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
std::shared_ptr<const ERC_ITEM> ercItem =
|
|
|
|
std::static_pointer_cast<const ERC_ITEM>( marker->GetRCItem() );
|
|
|
|
|
|
|
|
// Only show sheet-specific markers on the owning sheet
|
|
|
|
if( ercItem->IsSheetSpecific() )
|
2021-01-13 03:18:44 +00:00
|
|
|
{
|
2024-06-06 10:37:18 +00:00
|
|
|
if( ercItem->GetSpecificSheetPath() != sheet )
|
2023-01-21 23:25:40 +00:00
|
|
|
continue;
|
2021-01-13 03:18:44 +00:00
|
|
|
}
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
// Don't show non-specific markers more than once
|
|
|
|
if( !firstTime && !ercItem->IsSheetSpecific() )
|
|
|
|
continue;
|
|
|
|
|
2021-01-13 03:18:44 +00:00
|
|
|
aVisitor( marker );
|
2020-06-08 02:19:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-13 03:18:44 +00:00
|
|
|
void SHEETLIST_ERC_ITEMS_PROVIDER::SetSeverities( int aSeverities )
|
|
|
|
{
|
|
|
|
m_severities = aSeverities;
|
|
|
|
|
|
|
|
m_filteredMarkers.clear();
|
|
|
|
|
|
|
|
ERC_SETTINGS& settings = m_schematic->ErcSettings();
|
|
|
|
|
|
|
|
visitMarkers(
|
|
|
|
[&]( SCH_MARKER* aMarker )
|
|
|
|
{
|
|
|
|
SEVERITY markerSeverity;
|
|
|
|
|
|
|
|
if( aMarker->IsExcluded() )
|
|
|
|
markerSeverity = RPT_SEVERITY_EXCLUSION;
|
|
|
|
else
|
|
|
|
markerSeverity = settings.GetSeverity( aMarker->GetRCItem()->GetErrorCode() );
|
|
|
|
|
|
|
|
if( markerSeverity & m_severities )
|
|
|
|
m_filteredMarkers.push_back( aMarker );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
int SHEETLIST_ERC_ITEMS_PROVIDER::GetCount( int aSeverity ) const
|
2020-06-08 02:19:46 +00:00
|
|
|
{
|
|
|
|
if( aSeverity < 0 )
|
|
|
|
return m_filteredMarkers.size();
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
const ERC_SETTINGS& settings = m_schematic->ErcSettings();
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2021-01-13 03:18:44 +00:00
|
|
|
visitMarkers(
|
|
|
|
[&]( SCH_MARKER* aMarker )
|
|
|
|
{
|
|
|
|
SEVERITY markerSeverity;
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2021-01-13 03:18:44 +00:00
|
|
|
if( aMarker->IsExcluded() )
|
|
|
|
markerSeverity = RPT_SEVERITY_EXCLUSION;
|
|
|
|
else
|
|
|
|
markerSeverity = settings.GetSeverity( aMarker->GetRCItem()->GetErrorCode() );
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
if( ( markerSeverity & aSeverity ) > 0 )
|
2021-01-13 03:18:44 +00:00
|
|
|
count++;
|
|
|
|
} );
|
2020-06-08 02:19:46 +00:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
std::shared_ptr<ERC_ITEM> SHEETLIST_ERC_ITEMS_PROVIDER::GetERCItem( int aIndex ) const
|
2020-06-08 02:19:46 +00:00
|
|
|
{
|
|
|
|
SCH_MARKER* marker = m_filteredMarkers[ aIndex ];
|
|
|
|
|
2020-08-11 13:33:16 +00:00
|
|
|
return marker ? std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() ) : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
std::shared_ptr<RC_ITEM> SHEETLIST_ERC_ITEMS_PROVIDER::GetItem( int aIndex ) const
|
2020-08-11 13:33:16 +00:00
|
|
|
{
|
|
|
|
return GetERCItem( aIndex );
|
2020-06-08 02:19:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SHEETLIST_ERC_ITEMS_PROVIDER::DeleteItem( int aIndex, bool aDeep )
|
|
|
|
{
|
|
|
|
SCH_MARKER* marker = m_filteredMarkers[ aIndex ];
|
|
|
|
m_filteredMarkers.erase( m_filteredMarkers.begin() + aIndex );
|
|
|
|
|
|
|
|
if( aDeep )
|
|
|
|
{
|
|
|
|
SCH_SCREENS screens( m_schematic->Root() );
|
|
|
|
screens.DeleteMarker( marker );
|
|
|
|
}
|
|
|
|
}
|
2020-08-04 00:41:56 +00:00
|
|
|
|
|
|
|
|