KiCad PCB EDA Suite
Loading...
Searching...
No Matches
DRC_RULE_SAVER Class Reference

Saves DRC panel entries back to .kicad_dru files. More...

#include <drc_re_rule_saver.h>

Public Member Functions

 DRC_RULE_SAVER ()
 
bool SaveFile (const wxString &aPath, const std::vector< DRC_RE_LOADED_PANEL_ENTRY > &aEntries, const BOARD *aBoard=nullptr)
 Save all panel entries to a file.
 
wxString GenerateRulesText (const std::vector< DRC_RE_LOADED_PANEL_ENTRY > &aEntries, const BOARD *aBoard=nullptr)
 Generate rule text from panel entries.
 

Private Member Functions

wxString generateRuleText (const DRC_RE_LOADED_PANEL_ENTRY &aEntry, const BOARD *aBoard)
 Generate the rule text for a single panel entry.
 
wxString generateLayerClause (const LSET &aLayers, const BOARD *aBoard)
 Generate a layer clause from an LSET.
 
wxString generateSeverityClause (SEVERITY aSeverity)
 Generate a severity clause.
 
wxString generateMergedRuleText (const std::vector< const DRC_RE_LOADED_PANEL_ENTRY * > &aEntries, const BOARD *aBoard)
 Generate a merged rule text from multiple panel entries with the same name/condition.
 

Detailed Description

Saves DRC panel entries back to .kicad_dru files.

This class handles the conversion of graphical panel entries back to text-based DRC rules. It supports round-trip preservation, meaning unedited rules will be saved with their original text intact.

Definition at line 44 of file drc_re_rule_saver.h.

Constructor & Destructor Documentation

◆ DRC_RULE_SAVER()

DRC_RULE_SAVER::DRC_RULE_SAVER ( )

Definition at line 55 of file drc_re_rule_saver.cpp.

Member Function Documentation

◆ generateLayerClause()

wxString DRC_RULE_SAVER::generateLayerClause ( const LSET & aLayers,
const BOARD * aBoard )
private

Generate a layer clause from an LSET.

Parameters
aLayersThe layer set.
aBoardThe board for layer name resolution.
Returns
Layer clause string like "(layer \"F.Cu\" \"B.Cu\")".

Definition at line 218 of file drc_re_rule_saver.cpp.

References LSET::AllCuMask(), LSET::ExternalCuMask(), BOARD::GetLayerName(), LSET::InternalCuMask(), and LSET::Seq().

Referenced by generateMergedRuleText(), and generateRuleText().

◆ generateMergedRuleText()

wxString DRC_RULE_SAVER::generateMergedRuleText ( const std::vector< const DRC_RE_LOADED_PANEL_ENTRY * > & aEntries,
const BOARD * aBoard )
private

Generate a merged rule text from multiple panel entries with the same name/condition.

Combines constraint clauses from multiple entries into a single rule.

Parameters
aEntriesVector of entries to merge (must have same name and condition).
aBoardOptional board for layer name resolution.
Returns
Merged rule text.

Definition at line 251 of file drc_re_rule_saver.cpp.

References DRC_RE_LOADED_PANEL_ENTRY::condition, RULE_GENERATION_CONTEXT::conditionExpression, RULE_GENERATION_CONTEXT::constraintCode, CTX_QUOTED_STR, EscapeString(), generateLayerClause(), generateSeverityClause(), RULE_GENERATION_CONTEXT::layerClause, RPT_SEVERITY_ERROR, RPT_SEVERITY_UNDEFINED, DRC_RE_LOADED_PANEL_ENTRY::ruleName, RULE_GENERATION_CONTEXT::ruleName, and DRC_RE_BASE_CONSTRAINT_DATA::sanitizeRuleName().

Referenced by GenerateRulesText().

◆ GenerateRulesText()

wxString DRC_RULE_SAVER::GenerateRulesText ( const std::vector< DRC_RE_LOADED_PANEL_ENTRY > & aEntries,
const BOARD * aBoard = nullptr )

◆ generateRuleText()

◆ generateSeverityClause()

wxString DRC_RULE_SAVER::generateSeverityClause ( SEVERITY aSeverity)
private

Generate a severity clause.

Parameters
aSeverityThe severity level.
Returns
Severity clause string like "(severity warning)".

Definition at line 238 of file drc_re_rule_saver.cpp.

References RPT_SEVERITY_ERROR, RPT_SEVERITY_EXCLUSION, RPT_SEVERITY_IGNORE, and RPT_SEVERITY_WARNING.

Referenced by generateMergedRuleText(), and generateRuleText().

◆ SaveFile()

bool DRC_RULE_SAVER::SaveFile ( const wxString & aPath,
const std::vector< DRC_RE_LOADED_PANEL_ENTRY > & aEntries,
const BOARD * aBoard = nullptr )

Save all panel entries to a file.

Parameters
aPathPath to the output file.
aEntriesVector of panel entries to save.
aBoardOptional board for layer name resolution.
Returns
True if the file was saved successfully.

Definition at line 60 of file drc_re_rule_saver.cpp.

References GenerateRulesText().

Referenced by DIALOG_DRC_RULE_EDITOR::SaveRulesToFile().


The documentation for this class was generated from the following files: