61 auto it = std::find_if( aNodes.begin(), aNodes.end(),
64 return node.m_nodeId == aTargetId;
67 if( it != aNodes.end() )
96 if(
Prj().IsReadOnly() )
98 m_infoBar->ShowMessage(
_(
"Project is missing or read-only. Settings will not be "
109 new wxDataViewCtrl(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES | wxDV_SINGLE );
129 SetMinSize( wxSize( 400, 500 ) );
132 wxLogTrace(
"debug_dlg_size",
"DRC TransferDataToWindow: size=%s minSize=%s",
133 GetSize().IsFullySpecified() ? wxString::Format(
"%dx%d", GetSize().x, GetSize().y )
134 : wxString(
"default" ),
135 GetMinSize().IsFullySpecified()
136 ? wxString::Format(
"%dx%d", GetMinSize().x, GetMinSize().y )
137 : wxString(
"default" ) );
156 std::vector<RULE_TREE_NODE>
result;
159 int electricalItemId;
160 int manufacturabilityItemId;
161 int highSpeedDesignId;
180 result.insert(
result.end(), subItemNodes.begin(), subItemNodes.end() );
183 result.insert(
result.end(), subItemNodes.begin(), subItemNodes.end() );
186 result.insert(
result.end(), subItemNodes.begin(), subItemNodes.end() );
189 result.insert(
result.end(), subItemNodes.begin(), subItemNodes.end() );
205 wxFileName rulesFile(
m_frame->GetBoard()->GetDesignRulesPath() );
207 if( !rulesFile.FileExists() )
211 std::vector<DRC_RE_LOADED_PANEL_ENTRY> entries = loader.
LoadFile( rulesFile.GetFullPath() );
216 if( entries.empty() )
219 wxLogTrace( wxS(
"KI_TRACE_DRC_RULE_EDITOR" ),
220 wxS(
"[LoadExistingRules] Loaded %zu entries from %s" ),
221 entries.size(), rulesFile.GetFullPath() );
226 std::unordered_map<int, int> constraintTypeToNodeId;
230 if( node.m_nodeType ==
CONSTRAINT && node.m_nodeTypeMap )
232 constraintTypeToNodeId[*node.m_nodeTypeMap] = node.m_nodeId;
234 wxLogTrace( wxS(
"KI_TRACE_DRC_RULE_EDITOR" ),
235 wxS(
"[LoadExistingRules] Node '%s': nodeId=%d, m_nodeTypeMap=%d" ),
236 wxString( node.m_nodeName ), node.m_nodeId,
237 static_cast<int>( *node.m_nodeTypeMap ) );
252 wxLogTrace( wxS(
"KI_TRACE_DRC_RULE_EDITOR" ),
253 wxS(
"[LoadExistingRules] Processing entry: rule='%s', panelType=%d" ),
254 entry.ruleName,
static_cast<int>( type ) );
256 auto typeIt = constraintTypeToNodeId.find(
static_cast<int>( type ) );
258 if( typeIt == constraintTypeToNodeId.end() )
260 wxLogTrace( wxS(
"KI_TRACE_DRC_RULE_EDITOR" ),
261 wxS(
"[LoadExistingRules] No parent found for panelType=%d, skipping" ),
262 static_cast<int>( type ) );
266 int parentId = typeIt->second;
272 wxLogTrace( wxS(
"KI_TRACE_DRC_RULE_EDITOR" ),
273 wxS(
"[LoadExistingRules] Tree item not found for parentId=%d, skipping" ),
278 wxTreeItemId parentItem = std::get<2>( histIt->second );
280 if( !parentItem.IsOk() )
282 wxLogTrace( wxS(
"KI_TRACE_DRC_RULE_EDITOR" ),
283 wxS(
"[LoadExistingRules] Tree item not valid for parentId=%d, skipping" ),
288 wxLogTrace( wxS(
"KI_TRACE_DRC_RULE_EDITOR" ),
289 wxS(
"[LoadExistingRules] Found parent node: parentId=%d" ), parentId );
294 auto ruleData = std::dynamic_pointer_cast<DRC_RE_BASE_CONSTRAINT_DATA>( entry.constraintData );
299 ruleData->SetParentId( parentId );
300 ruleData->SetOriginalRuleText( entry.originalRuleText );
301 ruleData->SetWasEdited( entry.wasEdited );
302 ruleData->SetOriginalEntryCount( entry.originalEntryCount );
303 ruleData->SetSourceRule( entry.sourceRule );
305 wxString layerSource = entry.layerSource;
308 if( entry.layerCondition.count() == 1 )
310 PCB_LAYER_ID layer = entry.layerCondition.Seq().front();
316 ruleData->SetLayerSource( layerSource );
318 if( !entry.layerSource.IsEmpty() )
319 ruleData->SetLayers( entry.layerCondition.Seq() );
321 ruleData->SetSeverity( entry.severity );
328 wxLogTrace( wxS(
"KI_TRACE_DRC_RULE_EDITOR" ),
329 wxS(
"[LoadExistingRules] Appended rule '%s' to tree under parentId=%d" ),
330 entry.ruleName, parentId );
340 wxTreeItemId treeItemId;
361 auto sourceDataPtr = dynamic_pointer_cast<RULE_EDITOR_DATA_BASE>( sourceTreeNode->
m_nodeData );
367 wxString baseName = sourceDataPtr->GetRuleName();
368 int lastSpace = baseName.Find(
' ',
true );
370 if( lastSpace != wxNOT_FOUND )
372 wxString suffix = baseName.Mid( lastSpace + 1 );
375 if( suffix.ToLong( &num ) )
376 baseName = baseName.Left( lastSpace );
397 std::vector<RULE_TREE_NODE*> ruleNodes;
400 std::vector<DRC_RULE_ROW> rows;
401 rows.reserve( ruleNodes.size() );
406 wxString type = parentNode ? parentNode->
m_nodeName : wxString{};
407 rows.push_back( { type, ruleNode->m_nodeData->GetRuleName(), ruleNode->m_nodeData->GetComment() } );
419 wxString constraintName = paretNodeDetail->
m_nodeName;
424 &constraintName, dynamic_pointer_cast<DRC_RE_BASE_CONSTRAINT_DATA>( nodeDetail->
m_nodeData ) );
430 [
this](
int aNodeId )
436 [
this](
int aNodeId )
442 [
this](
int aNodeId )
448 [
this](
int aNodeId, wxString aRuleName )
454 [
this](
int aNodeId ) ->
int
479 bool isNew = data && data->IsNew();
486 std::vector<RULE_TREE_NODE*> modifiedRules;
489 if( modifiedRules.empty() )
501 if(
result == wxID_CANCEL )
507 std::map<wxString, wxString> errors;
514 if( errors.find( node.m_nodeName ) != errors.end() )
518 wxString msg = wxString::Format(
519 _(
"Cannot save due to validation errors in rule '%s':\n\n%s" ),
520 node.m_nodeName, errors[node.m_nodeName] );
535 std::vector<int> newRuleNodeIds;
539 if( node.m_nodeType ==
RULE && node.m_nodeData && node.m_nodeData->IsNew() )
540 newRuleNodeIds.push_back( node.m_nodeId );
543 for(
int nodeId : newRuleNodeIds )
569 auto constraintData =
570 std::dynamic_pointer_cast<DRC_RE_BASE_CONSTRAINT_DATA>( nodeDetail->
m_nodeData );
573 constraintData->SetWasEdited(
true );
595 default:
return true;
608 if(
OKOrCancelDialog(
this,
_(
"Confirmation" ),
"",
_(
"Are you sure you want to delete?" ),
_(
"Delete" ) )
632 std::vector<RULE_TREE_NODE>
result;
662 std::vector<RULE_TREE_NODE>
result;
706 std::vector<RULE_TREE_NODE>
result;
725 std::vector<RULE_TREE_NODE>
result;
770bool nodeExists(
const std::vector<RULE_TREE_NODE>& aRuleTreeNodes,
const wxString& aTargetName )
772 for(
const auto& node : aRuleTreeNodes )
785 const wxString& aBaseName )
788 using ConstraintDataFactory =
792 static const std::unordered_map<DRC_RULE_EDITOR_CONSTRAINT_NAME, ConstraintDataFactory> s_constraintFactories = {
796 return std::make_shared<DRC_RE_VIA_STYLE_CONSTRAINT_DATA>( data );
801 return std::make_shared<DRC_RE_MINIMUM_TEXT_HEIGHT_THICKNESS_CONSTRAINT_DATA>( data );
806 return std::make_shared<DRC_RE_ROUTING_DIFF_PAIR_CONSTRAINT_DATA>( data );
811 return std::make_shared<DRC_RE_ROUTING_WIDTH_CONSTRAINT_DATA>( data );
816 return std::make_shared<DRC_RE_PERMITTED_LAYERS_CONSTRAINT_DATA>( data );
821 return std::make_shared<DRC_RE_ALLOWED_ORIENTATION_CONSTRAINT_DATA>( data );
826 return std::make_shared<DRC_RE_CUSTOM_RULE_CONSTRAINT_DATA>( data );
831 return std::make_shared<DRC_RE_ABSOLUTE_LENGTH_TWO_CONSTRAINT_DATA>( data );
836 return std::make_shared<DRC_RE_MATCHED_LENGTH_DIFF_PAIR_CONSTRAINT_DATA>( data );
841 return std::make_shared<DRC_RE_VIAS_UNDER_SMD_CONSTRAINT_DATA>( data );
850 treeItemData = aRuleTreeItemData;
861 wxString base = aBaseName.IsEmpty() ? nodeDetail->
m_nodeName : aBaseName;
873 nodeName = base + wxString::Format(
" %d", loop );
887 if( s_constraintFactories.find( nodeType ) != s_constraintFactories.end() )
889 newRuleNode.
m_nodeData = s_constraintFactories.at( nodeType )( clearanceData );
897 newRuleNode.
m_nodeData = std::make_shared<DRC_RE_BOOL_INPUT_CONSTRAINT_DATA>( clearanceData );
901 wxLogWarning(
"No factory found for constraint type: %d", nodeType );
902 newRuleNode.
m_nodeData = std::make_shared<DRC_RE_BASE_CONSTRAINT_DATA>( clearanceData );
905 std::static_pointer_cast<DRC_RE_BASE_CONSTRAINT_DATA>( newRuleNode.
m_nodeData )
920 return node.m_nodeId == aNodeId;
974 std::shared_ptr<DRC_RE_BASE_CONSTRAINT_DATA> constraintData =
m_ruleEditorPanel->GetConstraintData();
975 std::shared_ptr<DRC_RULE> selectedRule;
977 wxString ruleText = constraintData->GetGeneratedRule();
979 if( ruleText.IsEmpty() )
986 wxString fullText = wxS(
"(version 2)\n" ) + ruleText;
990 std::vector<std::shared_ptr<DRC_RULE>> rules;
992 parser.
Parse( rules,
nullptr );
1001 selectedRule = rules[0];
1002 condition = selectedRule->m_Condition ? selectedRule->m_Condition->GetExpression() : wxString();
1004 if( selectedRule->m_Condition && !selectedRule->m_Condition->GetExpression().IsEmpty()
1005 && !selectedRule->m_Condition->Compile(
nullptr ) )
1015 wxLogTrace( wxS(
"KI_TRACE_DRC_RULE_EDITOR" ), wxS(
"[ShowMatches] nodeId=%d, condition='%s'" ), aNodeId,
1020 std::vector<BOARD_ITEM*> allMatches;
1025 std::vector<BOARD_ITEM*> matches;
1029 switch( item->Type() )
1037 matches.push_back( item );
1042 int matchCount =
static_cast<int>( matches.size() );
1044 wxLogTrace( wxS(
"KI_TRACE_DRC_RULE_EDITOR" ), wxS(
"[ShowMatches] matched_count=%d (filtered from %zu)" ),
1045 matchCount, allMatches.size() );
1050 if( matches.size() > 0 )
1052 std::vector<EDA_ITEM*> selectItems;
1055 selectItems.push_back( item );
1062 m_frame->FocusOnItems( matches );
1074 return node.m_nodeName == aRuleName && node.m_nodeId != aNodeId
1075 && node.m_nodeType == RULE;
1094 return node.m_nodeId == aNodeId;
1107 std::vector<RULE_TREE_NODE> children;
1110 for(
const auto& child : children )
1115 aResult.push_back( childNode );
1126 if( node.m_nodeType !=
RULE )
1129 if( node.m_nodeData && node.m_nodeData->IsNew() )
1131 aResult.push_back( &node );
1135 auto constraintData = std::dynamic_pointer_cast<DRC_RE_BASE_CONSTRAINT_DATA>( node.m_nodeData );
1137 if( constraintData && constraintData->WasEdited() )
1138 aResult.push_back( &node );
1145 bool allValid =
true;
1151 std::map<std::pair<wxString, wxString>, std::set<wxString>> ruleConditions;
1155 if( node.m_nodeType !=
RULE )
1158 if( node.m_nodeData && node.m_nodeData->IsNew() )
1161 auto constraintData = std::dynamic_pointer_cast<DRC_RE_BASE_CONSTRAINT_DATA>( node.m_nodeData );
1163 if( constraintData )
1172 for(
const wxString& err :
result.errors )
1174 if( !errorMsg.IsEmpty() )
1175 errorMsg += wxS(
"\n" );
1180 aErrors[node.m_nodeName] = errorMsg;
1184 wxString ruleName = constraintData->GetRuleName();
1185 wxString condition = constraintData->GetRuleCondition();
1186 wxString layerSource = constraintData->GetLayerSource();
1187 ruleConditions[std::make_pair( ruleName, layerSource )].insert( condition );
1192 for(
const auto& [key, conditions] : ruleConditions )
1194 if( conditions.size() > 1 )
1196 wxString errorMsg =
_(
"Multiple rules with the same name have different conditions. "
1197 "Rules with the same name must have identical conditions to be merged." );
1198 aErrors[key.first] = errorMsg;
1209 std::vector<RULE_TREE_NODE*> modifiedRules;
1212 if( modifiedRules.empty() )
1215 wxString
message =
_(
"The following rules have unsaved changes:\n\n" );
1218 message += wxString::Format( wxS(
" \u2022 %s\n" ), rule->m_nodeName );
1220 message +=
_(
"\nDo you want to save your changes?" );
1223 wxYES_NO | wxCANCEL | wxICON_QUESTION,
this );
1227 else if(
result == wxNO )
1237 wxTreeItemIdValue cookie;
1240 std::function<wxTreeItemId( wxTreeItemId )> findItem =
1241 [&]( wxTreeItemId parent ) -> wxTreeItemId
1243 wxTreeItemId item =
m_ruleTreeCtrl->GetFirstChild( parent, cookie );
1245 while( item.IsOk() )
1250 if( data && data->
GetNodeId() == aNodeId )
1253 wxTreeItemId found = findItem( item );
1261 return wxTreeItemId();
1264 wxTreeItemId itemId = findItem( root );
1273 const std::optional<DRC_RULE_EDITOR_CONSTRAINT_NAME>& aConstraintType,
1274 const std::vector<RULE_TREE_NODE>& aChildNodes,
const std::optional<int>&
id )
1293 baseData.
SetId( newId );
1301 .m_nodeName = aName,
1302 .m_nodeType = aNodeType,
1304 .m_nodeTypeMap = aConstraintType,
1305 .m_childNodes = aChildNodes,
1306 .m_nodeData = std::make_shared<RULE_EDITOR_DATA_BASE>( baseData ) };
1311 const std::optional<int>& aParentId )
1317 auto baseData = std::dynamic_pointer_cast<DRC_RE_BASE_CONSTRAINT_DATA>( node.
m_nodeData );
1344 std::vector<DRC_RE_LOADED_PANEL_ENTRY> entries;
1348 if( node.m_nodeType !=
RULE )
1351 auto data = std::dynamic_pointer_cast<DRC_RE_BASE_CONSTRAINT_DATA>( node.m_nodeData );
1356 if( node.m_nodeData->IsNew() )
1361 if( node.m_nodeTypeMap )
1367 entry.
ruleName = data->GetRuleName();
1368 entry.
condition = data->GetRuleCondition();
1373 entry.
severity = data->GetSeverity();
1377 entries.push_back( entry );
1385 m_frame->GetBoard()->GetDesignSettings().m_DRCEngine->InitEngine(
m_frame->GetBoard()->GetDesignRulesPath() );
1389 wxLogError(
_(
"Failed to reload DRC rules: %s" ), pe.
What() );
static TOOL_ACTION zoomFitSelection
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
std::vector< RULE_TREE_NODE > m_ruleTreeNodeDatas
PANEL_DRC_GROUP_HEADER * m_groupHeaderPanel
bool validateAllRules(std::map< wxString, wxString > &aErrors)
Validates all rules and returns any that have validation errors.
~DIALOG_DRC_RULE_EDITOR()
std::vector< RULE_TREE_NODE > buildElectricalRuleTreeNodes(int &aParentId)
std::vector< RULE_TREE_NODE > buildHighspeedDesignRuleTreeNodes(int &aParentId)
void UpdateRuleTypeTreeItemData(RULE_TREE_ITEM_DATA *aCurrentRuleTreeItemData) override
Updates the rule tree item data by transferring data from the rule editor panel and updating the item...
void collectChildRuleNodes(int aParentId, std::vector< RULE_TREE_NODE * > &aResult)
Collects all child rule nodes for a given parent node ID.
DRC_RE_FILE_TRIVIA m_rulesFileTrivia
int highlightMatchingItems(int aNodeId)
Highlights board items matching the current rule.
RULE_TREE_NODE buildRuleTreeNodeData(const wxString &aName, const DRC_RULE_EDITOR_ITEM_TYPE &aNodeType, const std::optional< int > &aParentId=std::nullopt, const std::optional< DRC_RULE_EDITOR_CONSTRAINT_NAME > &aConstraintType=std::nullopt, const std::vector< RULE_TREE_NODE > &aChildNodes={}, const std::optional< int > &aId=std::nullopt)
Creates a new rule tree node with the specified parameters, generating a new ID if not provided.
RULE_TREE_NODE buildRuleTreeNode(RULE_TREE_ITEM_DATA *aRuleTreeItemData, const wxString &aBaseName=wxEmptyString)
Creates a new rule tree node with a unique name and assigns the appropriate constraint data.
RC_TREE_MODEL * m_markersTreeModel
void saveRule(int aNodeId)
Saves the rule after validating the rule editor panel.
void AddNewRule(RULE_TREE_ITEM_DATA *aRuleTreeItemData) override
Adds a new rule to the rule tree, either as a child or under the parent, based on the node type (CONS...
void RuleTreeItemSelectionChanged(RULE_TREE_ITEM_DATA *aCurrentRuleTreeItemData) override
Handles rule tree item selection changes, updating the content panel with appropriate editor or heade...
int promptUnsavedChanges()
Shows a prompt for unsaved changes when closing with modifications.
RULE_TREE_NODE buildRuleNodeFromKicadDrc(const wxString &aName, const wxString &aCode, const std::optional< int > &aParentId=std::nullopt)
Build a rule tree node from a constraint keyword loaded from a .kicad_drc file.
std::vector< RULE_TREE_NODE > GetDefaultRuleTreeItems() override
Pure virtual method to get the default rule tree items.
bool TransferDataFromWindow() override
std::shared_ptr< RC_ITEMS_PROVIDER > m_markersProvider
std::vector< RULE_TREE_NODE > buildManufacturabilityRuleTreeNodes(int &aParentId)
wxDataViewCtrl * m_markerDataView
void RemoveRule(int aNodeId) override
Removes a rule from the rule tree after confirmation, deleting the item and associated data.
void OnCancel(wxCommandEvent &aEvent) override
bool TransferDataToWindow() override
std::vector< RULE_TREE_NODE > buildFootprintsRuleTreeNodes(int &aParentId)
RULE_TREE_NODE * getRuleTreeNodeInfo(const int &aNodeId)
Retrieves the rule tree node for a given ID.
void selectRuleNode(int aNodeId)
Selects a rule node in the tree by its ID.
bool validateRuleName(int aNodeId, const wxString &aRuleName)
Validates if the rule name is unique for the given node ID.
PANEL_DRC_RULE_EDITOR * m_ruleEditorPanel
void collectModifiedRules(std::vector< RULE_TREE_NODE * > &aResult)
Collects all rule nodes that have unsaved changes (new or edited).
bool deleteTreeNodeData(const int &aNodeId)
Deletes a rule tree node by its ID.
bool isEnabled(RULE_TREE_ITEM_DATA *aRuleTreeItemData, RULE_EDITOR_TREE_CONTEXT_OPT aOption) override
Verifies if a context menu option should be enabled based on the rule tree item type.
void closeRuleEntryView(int aNodeId)
Closes the rule entry view and re-enables controls.
void OnSave(wxCommandEvent &aEvent) override
void DuplicateRule(RULE_TREE_ITEM_DATA *aRuleTreeItemData) override
Duplicates a rule from the source tree node and appends it as a new item under the same parent.
void Parse(std::vector< std::shared_ptr< DRC_RULE > > &aRules, REPORTER *aReporter)
static bool IsNumericInputType(const DRC_RULE_EDITOR_CONSTRAINT_NAME &aConstraintType)
static wxString ConstraintToKicadDrc(DRC_RULE_EDITOR_CONSTRAINT_NAME aType)
Convert a constraint type into the keyword used in a .kicad_drc file.
static bool ConstraintFromKicadDrc(const wxString &aCode, DRC_RE_BASE_CONSTRAINT_DATA *aData)
Populate a constraint data object using a keyword from a .kicad_drc file.
static std::optional< DRC_RULE_EDITOR_CONSTRAINT_NAME > GetConstraintTypeFromCode(const wxString &aCode)
Resolve a constraint keyword from a rules file into the corresponding rule tree enumeration value.
static std::shared_ptr< DRC_RE_NUMERIC_INPUT_CONSTRAINT_DATA > CreateNumericConstraintData(DRC_RULE_EDITOR_CONSTRAINT_NAME aType)
static bool IsBoolInputType(const DRC_RULE_EDITOR_CONSTRAINT_NAME &aConstraintType)
Loads DRC rules from .kicad_dru files and converts them to panel entries.
const DRC_RE_FILE_TRIVIA & GetFileTrivia() const
std::vector< DRC_RE_LOADED_PANEL_ENTRY > LoadFile(const wxString &aPath)
Load all rules from a .kicad_dru file.
Saves DRC panel entries back to .kicad_dru files.
bool SaveFile(const wxString &aPath, const std::vector< DRC_RE_LOADED_PANEL_ENTRY > &aEntries, const BOARD *aBoard=nullptr, const DRC_RE_FILE_TRIVIA &aTrivia={})
Save all panel entries to a file.
virtual const wxString What() const
A composite of Problem() and Where()
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
LSET is a set of PCB_LAYER_IDs.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
The main frame for Pcbnew.
virtual void AdvancePhase() override
Use the next available virtual zone of the dialog progress bar.
PROGRESS_REPORTER_BASE(int aNumPhases)
virtual void SetCurrentProgress(double aProgress) override
Set the progress value to aProgress (0..1).
std::atomic_bool m_cancelled
virtual void AdvancePhase()=0
Use the next available virtual zone of the dialog progress bar.
Concrete class representing the base data structure for a rule editor.
bool IsNew()
Check if the rule is marked as new.
int GetId()
Get the unique ID of the rule.
void SetIsNew(bool aIsNew)
Mark the rule as new or not.
void SetId(int aId)
Set the unique ID of the rule.
void SetParentId(int aParentId)
Set the parent ID of the rule.
void CopyFrom(const ICopyable &aSource) override
Implementation of the polymorphic CopyFrom method.
wxString GetRuleName()
Get the name of the rule.
void DeleteRuleTreeItem(wxTreeItemId aItemId, const int &aNodeId)
Deletes a tree item and removes its corresponding node from history.
void UpdateRuleTreeItemText(wxTreeItemId aItemId, wxString aItemText)
Updates the text of a specified rule tree item.
void SetModified()
Marks the dialog as modified, indicating unsaved changes.
void AppendNewRuleTreeItem(const RULE_TREE_NODE &aRuleTreeNode, wxTreeItemId aParentTreeItemId)
Adds a new rule tree item under the specified parent and updates the tree history.
void InitRuleTreeItems(const std::vector< RULE_TREE_NODE > &aRuleTreeNodes)
Initializes the rule tree by adding nodes, setting up the structure, and saving its state.
void SetContentPanel(wxPanel *aContentPanel)
Replaces the current content panel with a new one based on the selected constraint type.
wxTreeCtrl * m_ruleTreeCtrl
wxScrolledWindow * m_scrolledContentWin
void ClearModified()
Clears the modified flag, typically after saving.
bool TransferDataToWindow() override
RULE_EDITOR_DIALOG_BASE(wxWindow *aParent, const wxString &aTitle, const wxSize &aInitialSize=wxDefaultSize)
friend class DIALOG_DRC_RULE_EDITOR
bool m_suppressSelectionEvents
std::unordered_map< int, std::tuple< wxString, std::vector< int >, wxTreeItemId > > m_treeHistoryData
bool IsModified() const
Returns whether the dialog has unsaved changes.
bool TransferDataFromWindow() override
void getRuleTreeChildNodes(const std::vector< RULE_TREE_NODE > &aNodes, int aParentId, std::vector< RULE_TREE_NODE > &aResult)
Retrieves child nodes of a given parent node.
RULE_TREE_ITEM_DATA * GetCurrentlySelectedRuleTreeItemData()
Retrieves the currently selected rule tree item data.
void SetControlsEnabled(bool aEnable)
Enables or disables controls within the rule editor dialog.
A class representing additional data associated with a wxTree item.
wxTreeItemId GetTreeItemId() const
wxTreeItemId GetParentTreeItemId() const
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
bool nodeExists(const RULE_TREE_NODE &aRuleTreeNode, const wxString &aTargetName)
Checks if a node with the given name exists in the rule tree or its child nodes.
const RULE_TREE_NODE * FindNodeById(const std::vector< RULE_TREE_NODE > &aNodes, int aTargetId)
#define DIALOG_DRC_RULE_EDITOR_WINDOW_NAME
SIM_MODEL::PARAM::CATEGORY CATEGORY
DRC_RULE_EDITOR_CONSTRAINT_NAME
@ SILK_TO_SOLDERMASK_CLEARANCE
@ MINIMUM_CONNECTION_WIDTH
@ MINIMUM_THERMAL_RELIEF_SPOKE_COUNT
@ MINIMUM_TEXT_HEIGHT_AND_THICKNESS
@ COPPER_TO_HOLE_CLEARANCE
@ MATCHED_LENGTH_DIFF_PAIR
@ COPPER_TO_EDGE_CLEARANCE
@ MINIMUM_SOLDERMASK_SLIVER
DRC_RULE_EDITOR_ITEM_TYPE
PCB_LAYER_ID
A quick note on layer IDs:
RULE_EDITOR_TREE_CONTEXT_OPT
Enumeration representing the available context menu options for the rule editor tree.
static wxString nodeName(const wxString &aSymbolPin)
Represents a rule loaded from a .kicad_dru file and mapped to a panel.
int sourceRule
Index of the rule in the loaded file, or -1 for a new rule.
wxString originalRuleText
wxString layerSource
Original layer text: "inner", "outer", or layer name.
std::shared_ptr< DRC_RE_BASE_CONSTRAINT_DATA > constraintData
DRC_RULE_EDITOR_CONSTRAINT_NAME panelType
A filename or source description, a problem input line, a line number, a byte offset,...
Structure representing a node in a rule tree, collection of this used for building the rule tree.
std::shared_ptr< RULE_EDITOR_DATA_BASE > m_nodeData
std::optional< int > m_nodeTypeMap
std::vector< RULE_TREE_NODE > m_childNodes
Result of a validation operation.
wxString result
Test unit parsing edge cases and error handling.
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net