2020-03-16 11:05:01 +00:00
|
|
|
/*
|
|
|
|
* 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 ERC_ITEM_H
|
|
|
|
#define ERC_ITEM_H
|
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
#include <optional>
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <rc_item.h>
|
2023-01-21 23:25:40 +00:00
|
|
|
#include "sch_sheet_path.h"
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
/**
|
|
|
|
* A specialisation of the RC_TREE_MODEL class to enable ERC errors / warnings to be resolved in
|
|
|
|
* a specific sheet path context. This allows the displayed ERC descriptions in the ERC dialog to
|
|
|
|
* reflect component references on a per-sheet basis in hierarchical schematics.
|
|
|
|
* @see RC_TREE_MODEL
|
|
|
|
*/
|
|
|
|
class ERC_TREE_MODEL : public RC_TREE_MODEL
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ERC_TREE_MODEL( EDA_DRAW_FRAME* aParentFrame, wxDataViewCtrl* aView ) :
|
|
|
|
RC_TREE_MODEL( aParentFrame, aView )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~ERC_TREE_MODEL() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override of RC_TREE_MODEL::GetValue which returns item descriptions in a specific
|
|
|
|
* SCH_SHEET_PATH context, if a context is available on the given SCH_MARKER or ERC_ITEM
|
|
|
|
* targets.
|
|
|
|
*/
|
2023-01-24 15:42:41 +00:00
|
|
|
void GetValue( wxVariant& aVariant, wxDataViewItem const& aItem,
|
|
|
|
unsigned int aCol ) const override;
|
2023-01-21 23:25:40 +00:00
|
|
|
};
|
2020-03-16 11:05:01 +00:00
|
|
|
|
|
|
|
class ERC_ITEM : public RC_ITEM
|
|
|
|
{
|
|
|
|
public:
|
2020-06-08 02:19:46 +00:00
|
|
|
/**
|
|
|
|
* Constructs an ERC_ITEM for the given error code
|
|
|
|
* @see ERCE_T
|
|
|
|
*/
|
2020-08-11 13:33:16 +00:00
|
|
|
static std::shared_ptr<ERC_ITEM> Create( int aErrorCode );
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2020-11-18 22:55:38 +00:00
|
|
|
static std::shared_ptr<ERC_ITEM> Create( const wxString& aErrorKey )
|
|
|
|
{
|
|
|
|
for( const RC_ITEM& item : allItemTypes )
|
|
|
|
{
|
|
|
|
if( aErrorKey == item.GetSettingsKey() )
|
|
|
|
return std::make_shared<ERC_ITEM>( static_cast<const ERC_ITEM&>( item ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities()
|
2020-04-24 13:36:10 +00:00
|
|
|
{
|
2020-06-08 02:19:46 +00:00
|
|
|
return allItemTypes;
|
2020-04-24 13:36:10 +00:00
|
|
|
}
|
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
/**
|
|
|
|
* Determines whether the ERC item is bound to a specific sheet, or is common across multiple
|
|
|
|
* sheets (e.g. whether the error is internal to a hierarchical sheet, or is due to an enclosing
|
|
|
|
* context interacting with the hierarchical sheet)
|
|
|
|
* @return true if ERC applies to a specific sheet, otherwise false
|
|
|
|
*/
|
|
|
|
bool IsSheetSpecific() const { return m_sheetSpecificPath.has_value(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the SCH_SHEET_PATH this ERC item is bound to
|
|
|
|
* @param aSpecificSheet The SCH_SHEET_PATH containing the ERC violation
|
|
|
|
*/
|
|
|
|
void SetSheetSpecificPath( const SCH_SHEET_PATH& aSpecificSheet )
|
|
|
|
{
|
|
|
|
m_sheetSpecificPath = aSpecificSheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the SCH_SHEET_PATH this ERC item is bound to. Throws std::bad_optional_access if there
|
|
|
|
* is no specific sheet path binding
|
|
|
|
* @return the SCH_SHEET_PATH containing the ERC violation
|
|
|
|
*/
|
|
|
|
const SCH_SHEET_PATH& GetSpecificSheetPath() const
|
|
|
|
{
|
|
|
|
wxASSERT( m_sheetSpecificPath.has_value() );
|
|
|
|
return m_sheetSpecificPath.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the SCH_SHEET_PATH of the main item causing this ERC violation to (e.g. a schematic
|
|
|
|
* pin). This allows violations to be specific to particular uses of shared hierarchical
|
|
|
|
* schematics.
|
|
|
|
* @param mainItemSheet the SCH_SHEET_PATH of the item causing the ERC violation
|
|
|
|
*/
|
|
|
|
void SetItemsSheetPaths( const SCH_SHEET_PATH& mainItemSheet )
|
|
|
|
{
|
|
|
|
m_mainItemSheet = mainItemSheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the SCH_SHEET PATHs of the main and auxiliary items causing this ERC violation to (e.g.
|
|
|
|
* two schematic pins which have a mutual connection violation). This allows violations to be
|
|
|
|
* specific to particular uses of shared hierarchical schematics.
|
|
|
|
* @param mainItemSheet the SCH_SHEET_PATH of the first item causing the ERC violation
|
|
|
|
* @param auxItemSheet the SCH_SHEET_PATH of the second item causing the ERC violation
|
|
|
|
*/
|
|
|
|
void SetItemsSheetPaths( const SCH_SHEET_PATH& mainItemSheet,
|
|
|
|
const SCH_SHEET_PATH& auxItemSheet )
|
|
|
|
{
|
|
|
|
m_mainItemSheet = mainItemSheet;
|
|
|
|
m_auxItemSheet = auxItemSheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the SCH_SHEET_PATH of the main item causing this ERC violation
|
|
|
|
* @return SCH_SHEET_PATH containing the main item
|
|
|
|
*/
|
|
|
|
SCH_SHEET_PATH& GetMainItemSheetPath()
|
|
|
|
{
|
|
|
|
wxASSERT( MainItemHasSheetPath() );
|
|
|
|
return m_mainItemSheet.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the SCH_SHEET_PATH of the auxillary item causing this ERC violation
|
|
|
|
* @return SCH_SHEET_PATH containing the auxillary item
|
|
|
|
*/
|
|
|
|
SCH_SHEET_PATH& GetAuxItemSheetPath()
|
|
|
|
{
|
|
|
|
wxASSERT( AuxItemHasSheetPath() );
|
|
|
|
return m_auxItemSheet.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines whether the main item causing this ERC violation has a specific
|
|
|
|
* SCH_SHEET_PATH binding.
|
|
|
|
* @return true if the item ERC violation is specific to a sheet, false otherwise
|
|
|
|
*/
|
|
|
|
bool MainItemHasSheetPath() { return m_mainItemSheet.has_value(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines whether the auxiliary item causing this ERC violation has a specific
|
|
|
|
* SCH_SHEET_PATH binding.
|
|
|
|
* @return true if the item ERC violation is specific to a sheet, false otherwise
|
|
|
|
*/
|
|
|
|
bool AuxItemHasSheetPath() { return m_auxItemSheet.has_value(); }
|
2021-01-13 03:18:44 +00:00
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
private:
|
|
|
|
ERC_ITEM( int aErrorCode = 0, const wxString& aTitle = "", const wxString& aSettingsKey = "" )
|
|
|
|
{
|
2021-01-13 03:18:44 +00:00
|
|
|
m_errorCode = aErrorCode;
|
|
|
|
m_errorTitle = aTitle;
|
2023-01-21 23:25:40 +00:00
|
|
|
m_settingsKey = aSettingsKey;
|
2020-06-08 02:19:46 +00:00
|
|
|
}
|
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
std::optional<SCH_SHEET_PATH> m_mainItemSheet;
|
|
|
|
std::optional<SCH_SHEET_PATH> m_auxItemSheet;
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
/// A list of all ERC_ITEM types which are valid error codes
|
|
|
|
static std::vector<std::reference_wrapper<RC_ITEM>> allItemTypes;
|
|
|
|
|
2020-12-09 17:32:26 +00:00
|
|
|
static ERC_ITEM heading_connections;
|
|
|
|
static ERC_ITEM heading_conflicts;
|
|
|
|
static ERC_ITEM heading_misc;
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
static ERC_ITEM duplicateSheetName;
|
2022-03-17 20:23:14 +00:00
|
|
|
static ERC_ITEM endpointOffGrid;
|
2020-06-08 02:19:46 +00:00
|
|
|
static ERC_ITEM pinNotConnected;
|
|
|
|
static ERC_ITEM pinNotDriven;
|
2020-11-02 11:41:58 +00:00
|
|
|
static ERC_ITEM powerpinNotDriven;
|
2020-07-03 21:08:17 +00:00
|
|
|
static ERC_ITEM pinTableWarning;
|
|
|
|
static ERC_ITEM pinTableError;
|
2020-06-08 02:19:46 +00:00
|
|
|
static ERC_ITEM hierLabelMismatch;
|
|
|
|
static ERC_ITEM noConnectConnected;
|
|
|
|
static ERC_ITEM noConnectDangling;
|
|
|
|
static ERC_ITEM labelDangling;
|
|
|
|
static ERC_ITEM globalLabelDangling;
|
|
|
|
static ERC_ITEM similarLabels;
|
|
|
|
static ERC_ITEM differentUnitFootprint;
|
|
|
|
static ERC_ITEM differentUnitNet;
|
|
|
|
static ERC_ITEM busDefinitionConflict;
|
|
|
|
static ERC_ITEM multipleNetNames;
|
2022-08-14 11:03:18 +00:00
|
|
|
static ERC_ITEM netclassConflict;
|
2020-06-08 02:19:46 +00:00
|
|
|
static ERC_ITEM netNotBusMember;
|
|
|
|
static ERC_ITEM busLabelSyntax;
|
|
|
|
static ERC_ITEM busToBusConflict;
|
|
|
|
static ERC_ITEM busToNetConflict;
|
|
|
|
static ERC_ITEM unresolvedVariable;
|
2022-11-07 12:27:58 +00:00
|
|
|
static ERC_ITEM simulationModelIssues;
|
2020-08-25 22:00:07 +00:00
|
|
|
static ERC_ITEM wireDangling;
|
2020-10-07 13:15:31 +00:00
|
|
|
static ERC_ITEM libSymbolIssues;
|
2021-01-24 22:25:32 +00:00
|
|
|
static ERC_ITEM unannotated;
|
|
|
|
static ERC_ITEM extraUnits;
|
2022-11-26 04:40:01 +00:00
|
|
|
static ERC_ITEM missingUnits;
|
|
|
|
static ERC_ITEM missingInputPin;
|
|
|
|
static ERC_ITEM missingBidiPin;
|
|
|
|
static ERC_ITEM missingPowerInputPin;
|
2021-01-24 22:25:32 +00:00
|
|
|
static ERC_ITEM differentUnitValue;
|
|
|
|
static ERC_ITEM duplicateReference;
|
2021-06-16 20:02:39 +00:00
|
|
|
static ERC_ITEM busEntryNeeded;
|
2021-01-13 03:18:44 +00:00
|
|
|
|
|
|
|
/// True if this item is specific to a sheet instance (as opposed to applying to all instances)
|
2023-01-21 23:25:40 +00:00
|
|
|
std::optional<SCH_SHEET_PATH> m_sheetSpecificPath;
|
2020-03-16 11:05:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // ERC_ITEM_H
|