|
KiCad PCB EDA Suite
|
The custom rules of one board, held in memory while Board Setup is open. More...
#include <drc_rule_document.h>
Public Member Functions | |
| DRC_RULE_DOCUMENT (BOARD *aBoard) | |
| void | Load () |
| Read the board's own rules file. | |
| void | LoadFrom (const wxString &aPath) |
| Replace the rules with those of another board's file, as an import. | |
| bool | Save (wxString *aError) |
| Write the board's rules file. | |
| wxString | GetText () const |
| The rules as text, for the Custom Rules page. | |
| void | SetText (const wxString &aText) |
| Take the text of the Custom Rules page. | |
| std::vector< DRC_RE_LOADED_PANEL_ENTRY > & | Entries () |
| std::vector< int > | IndicesFor (DRC_RULE_EDITOR_CONSTRAINT_NAME aType) const |
| std::vector< int > | IndicesSetting (DRC_CONSTRAINT_T aConstraint) const |
| Every rule that sets aConstraint, whichever page edits it. | |
| int | Add (const DRC_RE_LOADED_PANEL_ENTRY &aEntry) |
| void | UpdateEntry (int aIndex, const DRC_RE_LOADED_PANEL_ENTRY &aEdited) |
| Write an edited rule back. | |
| void | Remove (int aIndex) |
| int | Duplicate (int aIndex) |
| bool | Move (int aIndex, int aDelta, DRC_RULE_EDITOR_CONSTRAINT_NAME aType) |
| Move a rule one step among the rules listed for aType. | |
| bool | IsRuleNameUnique (const wxString &aName, DRC_RULE_EDITOR_CONSTRAINT_NAME aType, int aExceptIndex) const |
| wxString | UniqueRuleName (const wxString &aBase) const |
| int | NextId () |
| bool | IsModified () const |
| bool | HasUnparsedText () const |
| True while the Custom Rules text could not be parsed. | |
Static Public Member Functions | |
| static size_t | FindConstraintClause (const wxString &aText, const wxString &aCode) |
| Position of the constraint clause for aCode in rule text, or npos. | |
| static std::set< DRC_CONSTRAINT_T > | ConstraintsOf (const DRC_RE_LOADED_PANEL_ENTRY &aEntry) |
| The DRC constraints a rule sets, read back through the rules parser. | |
Private Member Functions | |
| bool | load (const wxString &aPath) |
| Returns false when the file could not be read, leaving the document as it was. | |
| bool | parseInto (const wxString &aText) |
| void | prepareEntries () |
| void | touch () |
Private Attributes | |
| BOARD * | m_board |
| std::vector< DRC_RE_LOADED_PANEL_ENTRY > | m_entries |
| DRC_RE_FILE_TRIVIA | m_trivia |
| wxString | m_rawText |
| bool | m_hasRawText |
| bool | m_textCurrent |
| bool | m_modified |
| int | m_nextId |
| int | m_nextGroupId |
The custom rules of one board, held in memory while Board Setup is open.
Every Design Rules page edits this one object. The rules file is written once, when the dialog is accepted, and never touched before that.
Definition at line 41 of file drc_rule_document.h.
| DRC_RULE_DOCUMENT::DRC_RULE_DOCUMENT | ( | BOARD * | aBoard | ) |
Definition at line 38 of file drc_rule_document.cpp.
References m_board, m_hasRawText, m_modified, m_nextGroupId, m_nextId, and m_textCurrent.
| int DRC_RULE_DOCUMENT::Add | ( | const DRC_RE_LOADED_PANEL_ENTRY & | aEntry | ) |
Definition at line 277 of file drc_rule_document.cpp.
References m_entries, m_hasRawText, m_nextGroupId, and touch().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
static |
The DRC constraints a rule sets, read back through the rules parser.
Definition at line 186 of file drc_rule_document.cpp.
References RULE_GENERATION_CONTEXT::constraintCode, DRC_RE_LOADED_PANEL_ENTRY::constraintData, DRC_RE_BASE_CONSTRAINT_DATA::GenerateRule(), DRC_RE_BASE_CONSTRAINT_DATA::GetConstraintCode(), DRC_CONSTRAINT::m_Type, DRC_RULES_PARSER::Parse(), result, and RULE_GENERATION_CONTEXT::ruleName.
Referenced by IndicesFor(), and IndicesSetting().
| int DRC_RULE_DOCUMENT::Duplicate | ( | int | aIndex | ) |
Definition at line 347 of file drc_rule_document.cpp.
References copy, DRC_RULE_EDITOR_UTILS::CreateConstraintData(), m_entries, m_hasRawText, m_nextGroupId, name, NextId(), source, touch(), and UniqueRuleName().
Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 74 of file drc_rule_document.h.
References m_entries.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
static |
Position of the constraint clause for aCode in rule text, or npos.
The code must end at a delimiter so a code that starts like another is not matched.
Definition at line 497 of file drc_rule_document.cpp.
References end, and isSpace().
Referenced by BOOST_AUTO_TEST_CASE(), and CONSTRAINT_RULES_LIST::ConstraintText().
| wxString DRC_RULE_DOCUMENT::GetText | ( | ) | const |
The rules as text, for the Custom Rules page.
Until a page changes a rule, this is the text as it was read or typed, so comments and layout outside the rules survive.
Definition at line 164 of file drc_rule_document.cpp.
References DRC_RULE_SAVER::GenerateRulesText(), m_board, m_entries, m_rawText, m_textCurrent, and m_trivia.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), Save(), and SetText().
|
inline |
True while the Custom Rules text could not be parsed.
The pages must not edit entries then, because the text is what gets written.
Definition at line 111 of file drc_rule_document.h.
References m_hasRawText.
Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
| std::vector< int > DRC_RULE_DOCUMENT::IndicesFor | ( | DRC_RULE_EDITOR_CONSTRAINT_NAME | aType | ) | const |
Definition at line 221 of file drc_rule_document.cpp.
References DRC_RE_LOADED_PANEL_ENTRY::constraintData, ConstraintsOf(), CUSTOM_RULE, DRC_PANEL_MATCHER::GetHomePanel(), m_entries, m_hasRawText, DRC_RE_LOADED_PANEL_ENTRY::panelType, and result.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and Move().
| std::vector< int > DRC_RULE_DOCUMENT::IndicesSetting | ( | DRC_CONSTRAINT_T | aConstraint | ) | const |
Every rule that sets aConstraint, whichever page edits it.
Definition at line 260 of file drc_rule_document.cpp.
References ConstraintsOf(), m_entries, m_hasRawText, and result.
|
inline |
Definition at line 105 of file drc_rule_document.h.
References m_modified.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
| bool DRC_RULE_DOCUMENT::IsRuleNameUnique | ( | const wxString & | aName, |
| DRC_RULE_EDITOR_CONSTRAINT_NAME | aType, | ||
| int | aExceptIndex ) const |
Definition at line 448 of file drc_rule_document.cpp.
References m_entries.
Referenced by BOOST_AUTO_TEST_CASE().
| void DRC_RULE_DOCUMENT::Load | ( | ) |
Read the board's own rules file.
Nothing is marked modified.
Definition at line 49 of file drc_rule_document.cpp.
References load(), m_board, and m_modified.
|
private |
Returns false when the file could not be read, leaving the document as it was.
Definition at line 66 of file drc_rule_document.cpp.
References ConvertSmartQuotesAndDashes(), m_entries, m_hasRawText, m_rawText, m_textCurrent, m_trivia, parseInto(), and text.
Referenced by Load(), and LoadFrom().
| void DRC_RULE_DOCUMENT::LoadFrom | ( | const wxString & | aPath | ) |
Replace the rules with those of another board's file, as an import.
A board without a rules file changes nothing.
Definition at line 56 of file drc_rule_document.cpp.
References load(), and m_modified.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
| bool DRC_RULE_DOCUMENT::Move | ( | int | aIndex, |
| int | aDelta, | ||
| DRC_RULE_EDITOR_CONSTRAINT_NAME | aType ) |
Move a rule one step among the rules listed for aType.
Returns false when it is already first or last.
Definition at line 392 of file drc_rule_document.cpp.
References group, IndicesFor(), m_entries, m_hasRawText, and touch().
Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 103 of file drc_rule_document.h.
References m_nextId.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and Duplicate().
|
private |
Definition at line 101 of file drc_rule_document.cpp.
References DRC_RULE_LOADER::GetFileTrivia(), DRC_RULE_LOADER::LoadFromString(), m_entries, m_trivia, and prepareEntries().
|
private |
Definition at line 119 of file drc_rule_document.cpp.
References m_board, m_entries, m_nextGroupId, m_nextId, and LSET::Name().
Referenced by parseInto().
| void DRC_RULE_DOCUMENT::Remove | ( | int | aIndex | ) |
Definition at line 337 of file drc_rule_document.cpp.
References m_entries, m_hasRawText, and touch().
Referenced by BOOST_AUTO_TEST_CASE().
| bool DRC_RULE_DOCUMENT::Save | ( | wxString * | aError | ) |
Write the board's rules file.
Returns false and fills aError when the write fails.
Definition at line 151 of file drc_rule_document.cpp.
References KIPLATFORM::IO::AtomicWriteFile(), GetText(), m_board, m_modified, text, and utf8().
| void DRC_RULE_DOCUMENT::SetText | ( | const wxString & | aText | ) |
Take the text of the Custom Rules page.
Text that parses replaces the rules. Text that does not is kept verbatim so it is written back unchanged.
Definition at line 174 of file drc_rule_document.cpp.
References GetText(), m_hasRawText, m_modified, m_rawText, m_textCurrent, and parseInto().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
private |
Definition at line 490 of file drc_rule_document.cpp.
References m_modified, and m_textCurrent.
Referenced by Add(), Duplicate(), Move(), Remove(), and UpdateEntry().
| wxString DRC_RULE_DOCUMENT::UniqueRuleName | ( | const wxString & | aBase | ) | const |
Definition at line 467 of file drc_rule_document.cpp.
References m_entries, and name.
Referenced by BOOST_AUTO_TEST_CASE(), and Duplicate().
| void DRC_RULE_DOCUMENT::UpdateEntry | ( | int | aIndex, |
| const DRC_RE_LOADED_PANEL_ENTRY & | aEdited ) |
Write an edited rule back.
Constraints the loader split out of the same rule share the rule's name, condition, layers and severity, so those are carried over to them too.
Definition at line 294 of file drc_rule_document.cpp.
References DRC_RE_LOADED_PANEL_ENTRY::condition, DRC_RE_LOADED_PANEL_ENTRY::constraintData, RULE_EDITOR_DATA_BASE::GetComment(), DRC_RE_LOADED_PANEL_ENTRY::layerCondition, DRC_RE_LOADED_PANEL_ENTRY::layerSource, m_entries, m_hasRawText, DRC_RE_LOADED_PANEL_ENTRY::ruleGroupId, DRC_RE_LOADED_PANEL_ENTRY::ruleName, LSET::Seq(), RULE_EDITOR_DATA_BASE::SetComment(), DRC_RE_BASE_CONSTRAINT_DATA::SetGeneratedRule(), DRC_RE_BASE_CONSTRAINT_DATA::SetLayers(), DRC_RE_BASE_CONSTRAINT_DATA::SetLayerSource(), DRC_RE_BASE_CONSTRAINT_DATA::SetRuleCondition(), RULE_EDITOR_DATA_BASE::SetRuleName(), DRC_RE_BASE_CONSTRAINT_DATA::SetSeverity(), DRC_RE_LOADED_PANEL_ENTRY::severity, touch(), and DRC_RE_LOADED_PANEL_ENTRY::wasEdited.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
private |
Definition at line 132 of file drc_rule_document.h.
Referenced by DRC_RULE_DOCUMENT(), GetText(), Load(), prepareEntries(), and Save().
|
private |
Definition at line 133 of file drc_rule_document.h.
Referenced by Add(), Duplicate(), Entries(), GetText(), IndicesFor(), IndicesSetting(), IsRuleNameUnique(), load(), Move(), parseInto(), prepareEntries(), Remove(), UniqueRuleName(), and UpdateEntry().
|
private |
Definition at line 136 of file drc_rule_document.h.
Referenced by Add(), DRC_RULE_DOCUMENT(), Duplicate(), HasUnparsedText(), IndicesFor(), IndicesSetting(), load(), Move(), Remove(), SetText(), and UpdateEntry().
|
private |
Definition at line 138 of file drc_rule_document.h.
Referenced by DRC_RULE_DOCUMENT(), IsModified(), Load(), LoadFrom(), Save(), SetText(), and touch().
|
private |
Definition at line 140 of file drc_rule_document.h.
Referenced by Add(), DRC_RULE_DOCUMENT(), Duplicate(), and prepareEntries().
|
private |
Definition at line 139 of file drc_rule_document.h.
Referenced by DRC_RULE_DOCUMENT(), NextId(), and prepareEntries().
|
private |
Definition at line 135 of file drc_rule_document.h.
|
private |
Definition at line 137 of file drc_rule_document.h.
Referenced by DRC_RULE_DOCUMENT(), GetText(), load(), SetText(), and touch().
|
private |
Definition at line 134 of file drc_rule_document.h.
Referenced by GetText(), load(), and parseInto().