KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_re_rule_loader.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef DRC_RE_RULE_LOADER_H_
21#define DRC_RE_RULE_LOADER_H_
22
23#include <memory>
24#include <set>
25#include <vector>
26
27#include <wx/string.h>
28
29#include <drc/drc_rule.h>
30
31#include "drc_re_loaded_rule.h"
33
34
44{
45public:
47
58 std::vector<DRC_RE_LOADED_PANEL_ENTRY> LoadRule( const DRC_RULE& aRule,
59 const wxString& aOriginalText );
60
67 std::vector<DRC_RE_LOADED_PANEL_ENTRY> LoadFile( const wxString& aPath );
68
75 std::vector<DRC_RE_LOADED_PANEL_ENTRY> LoadFromString( const wxString& aRulesText );
76
84 static wxString ExtractRuleText( const wxString& aContent, const wxString& aRuleName );
85
93 static wxString ExtractRuleBody( const wxString& aOriginalText );
94
102 static wxString ExtractRuleComment( const wxString& aOriginalText );
103
104private:
113 std::shared_ptr<DRC_RE_BASE_CONSTRAINT_DATA>
115 const DRC_RULE& aRule,
116 const std::set<DRC_CONSTRAINT_T>& aClaimedConstraints );
117
125 const DRC_CONSTRAINT* findConstraint( const DRC_RULE& aRule, DRC_CONSTRAINT_T aType );
126
130 double toMM( int aValue );
131
136 wxString cleanStrippedCondition( const wxString& aCondition );
137
139};
140
141
142#endif // DRC_RE_RULE_LOADER_H_
Maps DRC rule constraints to appropriate editor panels.
double toMM(int aValue)
Convert internal units (nanometers) to millimeters.
DRC_PANEL_MATCHER m_matcher
std::vector< DRC_RE_LOADED_PANEL_ENTRY > LoadRule(const DRC_RULE &aRule, const wxString &aOriginalText)
Load a single DRC_RULE and convert it to panel entries.
std::vector< DRC_RE_LOADED_PANEL_ENTRY > LoadFromString(const wxString &aRulesText)
Load rules from a text string.
const DRC_CONSTRAINT * findConstraint(const DRC_RULE &aRule, DRC_CONSTRAINT_T aType)
Find a constraint of a specific type in a rule.
static wxString ExtractRuleComment(const wxString &aOriginalText)
Extract comment lines from a rule.
static wxString ExtractRuleBody(const wxString &aOriginalText)
Extract the body of a rule from its original text, stripping the (rule "name" ...) wrapper.
static wxString ExtractRuleText(const wxString &aContent, const wxString &aRuleName)
Extract the complete original text of a rule from file content.
std::vector< DRC_RE_LOADED_PANEL_ENTRY > LoadFile(const wxString &aPath)
Load all rules from a .kicad_dru file.
wxString cleanStrippedCondition(const wxString &aCondition)
Clean up a condition string after auto-generated tokens have been removed.
std::shared_ptr< DRC_RE_BASE_CONSTRAINT_DATA > createConstraintData(DRC_RULE_EDITOR_CONSTRAINT_NAME aPanel, const DRC_RULE &aRule, const std::set< DRC_CONSTRAINT_T > &aClaimedConstraints)
Create the appropriate constraint data object for a panel type.
DRC_CONSTRAINT_T
Definition drc_rule.h:49
DRC_RULE_EDITOR_CONSTRAINT_NAME