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

The rules of one constraint type, in evaluation order, with an editor that opens in place. More...

#include <constraint_rules_list.h>

Inheritance diagram for CONSTRAINT_RULES_LIST:
CONSTRAINT_RULES_LIST_BASE

Public Member Functions

 CONSTRAINT_RULES_LIST (wxWindow *aParent, PCB_EDIT_FRAME *aFrame, DRC_RULE_DOCUMENT *aDocument, DRC_RULE_EDITOR_CONSTRAINT_NAME aType, const wxString &aTitle)
 
void RefreshRules ()
 
void SetNetclasses (std::function< std::optional< int >(const NETCLASS &)> aValue, NETCLASS_CONSTRAINT_PART aPart)
 Lists the net class values for this constraint above the rules, where a class can set one.
 
void SetTitleWindow (wxWindow *aWindow)
 A window whose label is the section title.
 
void SetDefaults (std::vector< std::pair< wxString, std::function< wxString()> > > aDefaults)
 The board defaults this constraint falls back to, each with the name the note gives it.
 
void RefreshOverrideNote ()
 Rebuilds the line saying what the rule being edited displaces.
 
bool HasPendingRule () const
 True while the form holds typing that has not been added to the list.
 
bool ApplyPendingRule ()
 Adds or updates the rule the form holds.
 
void DiscardPendingRule ()
 Reloads the form from the document, dropping whatever was typed.
 
bool ConfirmPendingRule ()
 Asks what to do with a rule left in the form.
 
bool EditRule (int aIndex)
 Selects a rule and opens it in the editor. False if a rule left in the form kept it closed.
 
void SetChangeCallback (std::function< void()> aCallback)
 Called after this list changed the document.
 

Static Public Member Functions

static wxString ConstraintText (const DRC_RE_LOADED_PANEL_ENTRY &aEntry, DRC_RULE_EDITOR_CONSTRAINT_NAME aType, UNITS_PROVIDER *aUnits)
 The constraint a rule sets, written the way the rule table shows it.
 

Protected Attributes

wxListCtrl * m_list
 
wxStaticText * m_emptyLabel
 
wxButton * m_upBtn
 
wxButton * m_downBtn
 
wxButton * m_duplicateBtn
 
wxButton * m_removeBtn
 
wxPanel * m_editorHost
 
wxBoxSizer * m_editorSizer
 
wxButton * m_primaryBtn
 
wxButton * m_newBtn
 

Private Member Functions

void onPrimary (wxCommandEvent &aEvent)
 
void onNewRule (wxCommandEvent &aEvent)
 
void onMoveUp (wxCommandEvent &aEvent)
 
void onMoveDown (wxCommandEvent &aEvent)
 
void onDuplicate (wxCommandEvent &aEvent)
 
void onRemove (wxCommandEvent &aEvent)
 
void moveSelected (int aDelta)
 
void buildEditor (const std::shared_ptr< DRC_RE_BASE_CONSTRAINT_DATA > &aData, DRC_RULE_EDITOR_CONSTRAINT_NAME aPanelType)
 
void showNewRule ()
 
void showRule (int aIndex)
 
void addRule ()
 
void applyRule ()
 
int indexOf (const std::shared_ptr< DRC_RE_BASE_CONSTRAINT_DATA > &aData) const
 
int editingIndex () const
 
void notifyChanged ()
 
int showMatches ()
 
int selectedIndex () const
 
void selectIndex (int aIndex)
 
void updateButtons ()
 
void relayout ()
 
void reportError (const wxString &aMessage)
 
void fitColumns ()
 
void showOverrideNote ()
 
int addNetclassRows ()
 Fills the leading rows with the net class values, and returns how many it added.
 
wxString sharedWithText (int aIndex) const
 

Static Private Member Functions

static void copyRuleData (DRC_RE_BASE_CONSTRAINT_DATA &aTarget, const DRC_RE_BASE_CONSTRAINT_DATA &aSource)
 Copies everything the form edits, the rule name included.
 
static wxString layersText (const DRC_RE_LOADED_PANEL_ENTRY &aEntry)
 
static wxString severityText (const DRC_RE_LOADED_PANEL_ENTRY &aEntry)
 
static wxString inUserUnits (const wxString &aClause, UNITS_PROVIDER *aUnits)
 

Private Attributes

PCB_EDIT_FRAME * m_frame
 
DRC_RULE_DOCUMENT * m_document
 
DRC_RULE_EDITOR_CONSTRAINT_NAME m_type
 
wxString m_title
 
wxWindow * m_titleWindow
 
std::vector< std::pair< wxString, std::function< wxString()> > > m_defaults
 
PANEL_DRC_RULE_EDITOR * m_editor
 
std::shared_ptr< DRC_RE_BASE_CONSTRAINT_DATA > m_editingData
 
DRC_RULE_EDITOR_CONSTRAINT_NAME m_editingType
 
std::function< void()> m_onChanged
 
bool m_refreshing = false
 
int m_fittedWidth = -1
 
std::function< std::optional< int >(const NETCLASS &)> m_netclassValue
 
NETCLASS_CONSTRAINT_PART m_netclassPart = NETCLASS_CONSTRAINT_PART::MINIMUM
 
std::vector< int > m_rowToIndex
 The document index each row shows, or NETCLASS_ROW where the row is a net class value.
 

Static Private Attributes

static constexpr int NETCLASS_ROW = -1
 What m_rowToIndex holds for a row that is not a rule of this document.
 

Detailed Description

The rules of one constraint type, in evaluation order, with an editor that opens in place.

Edits go to the shared DRC_RULE_DOCUMENT. Nothing is written to disk here.

Definition at line 49 of file constraint_rules_list.h.

Constructor & Destructor Documentation

◆ CONSTRAINT_RULES_LIST()

Member Function Documentation

◆ addNetclassRows()

int CONSTRAINT_RULES_LIST::addNetclassRows ( )
private

Fills the leading rows with the net class values, and returns how many it added.

Definition at line 290 of file constraint_rules_list.cpp.

References _, NET_SETTINGS::GetDefaultNetclass(), NET_SETTINGS::GetNetclasses(), m_frame, CONSTRAINT_RULES_LIST_BASE::m_list, m_netclassPart, m_netclassValue, m_rowToIndex, MINIMUM, name, and NETCLASS_ROW.

Referenced by RefreshRules().

◆ addRule()

◆ ApplyPendingRule()

bool CONSTRAINT_RULES_LIST::ApplyPendingRule ( )

Adds or updates the rule the form holds.

False if it does not validate, with the reason already reported.

Definition at line 522 of file constraint_rules_list.cpp.

References addRule(), applyRule(), editingIndex(), HasPendingRule(), m_editor, and reportError().

Referenced by ConfirmPendingRule().

◆ applyRule()

◆ buildEditor()

◆ ConfirmPendingRule()

bool CONSTRAINT_RULES_LIST::ConfirmPendingRule ( )

Asks what to do with a rule left in the form.

False if the user cancels or the rule does not validate, and the form is left as it was.

Definition at line 542 of file constraint_rules_list.cpp.

References _, ApplyPendingRule(), DiscardPendingRule(), editingIndex(), HasPendingRule(), and KICAD_MESSAGE_DIALOG_BASE.

Referenced by EditRule(), onDuplicate(), and onNewRule().

◆ ConstraintText()

◆ copyRuleData()

void CONSTRAINT_RULES_LIST::copyRuleData ( DRC_RE_BASE_CONSTRAINT_DATA & aTarget,
const DRC_RE_BASE_CONSTRAINT_DATA & aSource )
staticprivate

Copies everything the form edits, the rule name included.

Definition at line 737 of file constraint_rules_list.cpp.

References DRC_RE_BASE_CONSTRAINT_DATA::CopyFrom(), RULE_EDITOR_DATA_BASE::GetRuleName(), and RULE_EDITOR_DATA_BASE::SetRuleName().

Referenced by addRule(), applyRule(), buildEditor(), and RefreshRules().

◆ DiscardPendingRule()

void CONSTRAINT_RULES_LIST::DiscardPendingRule ( )

Reloads the form from the document, dropping whatever was typed.

Definition at line 573 of file constraint_rules_list.cpp.

References editingIndex(), index, showNewRule(), and showRule().

Referenced by ConfirmPendingRule().

◆ editingIndex()

int CONSTRAINT_RULES_LIST::editingIndex ( ) const
private

◆ EditRule()

bool CONSTRAINT_RULES_LIST::EditRule ( int aIndex)

Selects a rule and opens it in the editor. False if a rule left in the form kept it closed.

Definition at line 819 of file constraint_rules_list.cpp.

References ConfirmPendingRule(), indexOf(), m_document, m_editingData, selectIndex(), and showRule().

◆ fitColumns()

void CONSTRAINT_RULES_LIST::fitColumns ( )
private

Definition at line 247 of file constraint_rules_list.cpp.

References dc, m_fittedWidth, and CONSTRAINT_RULES_LIST_BASE::m_list.

Referenced by RefreshRules().

◆ HasPendingRule()

bool CONSTRAINT_RULES_LIST::HasPendingRule ( ) const

True while the form holds typing that has not been added to the list.

Definition at line 516 of file constraint_rules_list.cpp.

References m_editor.

Referenced by ApplyPendingRule(), and ConfirmPendingRule().

◆ indexOf()

int CONSTRAINT_RULES_LIST::indexOf ( const std::shared_ptr< DRC_RE_BASE_CONSTRAINT_DATA > & aData) const
private

Definition at line 1002 of file constraint_rules_list.cpp.

References m_document.

Referenced by editingIndex(), EditRule(), moveSelected(), and onDuplicate().

◆ inUserUnits()

wxString CONSTRAINT_RULES_LIST::inUserUnits ( const wxString & aClause,
UNITS_PROVIDER * aUnits )
staticprivate

◆ layersText()

wxString CONSTRAINT_RULES_LIST::layersText ( const DRC_RE_LOADED_PANEL_ENTRY & aEntry)
staticprivate

Definition at line 341 of file constraint_rules_list.cpp.

References _, and DRC_RE_LOADED_PANEL_ENTRY::layerSource.

Referenced by RefreshRules().

◆ moveSelected()

void CONSTRAINT_RULES_LIST::moveSelected ( int aDelta)
private

Definition at line 584 of file constraint_rules_list.cpp.

References index, indexOf(), m_document, m_type, notifyChanged(), selectedIndex(), and selectIndex().

Referenced by onMoveDown(), and onMoveUp().

◆ notifyChanged()

void CONSTRAINT_RULES_LIST::notifyChanged ( )
private

Definition at line 1025 of file constraint_rules_list.cpp.

References m_onChanged, and RefreshRules().

Referenced by addRule(), applyRule(), moveSelected(), onDuplicate(), and onRemove().

◆ onDuplicate()

void CONSTRAINT_RULES_LIST::onDuplicate ( wxCommandEvent & aEvent)
private

◆ onMoveDown()

void CONSTRAINT_RULES_LIST::onMoveDown ( wxCommandEvent & aEvent)
private

Definition at line 609 of file constraint_rules_list.cpp.

References moveSelected().

Referenced by CONSTRAINT_RULES_LIST().

◆ onMoveUp()

void CONSTRAINT_RULES_LIST::onMoveUp ( wxCommandEvent & aEvent)
private

Definition at line 603 of file constraint_rules_list.cpp.

References moveSelected().

Referenced by CONSTRAINT_RULES_LIST().

◆ onNewRule()

void CONSTRAINT_RULES_LIST::onNewRule ( wxCommandEvent & aEvent)
private

Definition at line 506 of file constraint_rules_list.cpp.

References ConfirmPendingRule(), RefreshRules(), and showNewRule().

Referenced by CONSTRAINT_RULES_LIST().

◆ onPrimary()

void CONSTRAINT_RULES_LIST::onPrimary ( wxCommandEvent & aEvent)
private

Definition at line 499 of file constraint_rules_list.cpp.

References m_editor.

Referenced by CONSTRAINT_RULES_LIST().

◆ onRemove()

void CONSTRAINT_RULES_LIST::onRemove ( wxCommandEvent & aEvent)
private

◆ RefreshOverrideNote()

void CONSTRAINT_RULES_LIST::RefreshOverrideNote ( )
inline

Rebuilds the line saying what the rule being edited displaces.

Definition at line 77 of file constraint_rules_list.h.

References showOverrideNote().

◆ RefreshRules()

◆ relayout()

void CONSTRAINT_RULES_LIST::relayout ( )
private

Definition at line 986 of file constraint_rules_list.cpp.

References PANEL_DRC_RULE_EDITOR::LayoutAncestors().

Referenced by buildEditor(), and RefreshRules().

◆ reportError()

void CONSTRAINT_RULES_LIST::reportError ( const wxString & aMessage)
private

◆ selectedIndex()

int CONSTRAINT_RULES_LIST::selectedIndex ( ) const
private

◆ selectIndex()

void CONSTRAINT_RULES_LIST::selectIndex ( int aIndex)
private

◆ SetChangeCallback()

void CONSTRAINT_RULES_LIST::SetChangeCallback ( std::function< void()> aCallback)
inline

Called after this list changed the document.

The page uses it to refresh every list, since the entries are shared.

Definition at line 108 of file constraint_rules_list.h.

References m_onChanged.

◆ SetDefaults()

void CONSTRAINT_RULES_LIST::SetDefaults ( std::vector< std::pair< wxString, std::function< wxString()> > > aDefaults)
inline

The board defaults this constraint falls back to, each with the name the note gives it.

Definition at line 71 of file constraint_rules_list.h.

References m_defaults.

◆ SetNetclasses()

void CONSTRAINT_RULES_LIST::SetNetclasses ( std::function< std::optional< int >(const NETCLASS &)> aValue,
NETCLASS_CONSTRAINT_PART aPart )

Lists the net class values for this constraint above the rules, where a class can set one.

DRC reads a net class value before any rule the user writes here, so the values belong in the same list, in the order they are read.

Definition at line 282 of file constraint_rules_list.cpp.

References m_netclassPart, and m_netclassValue.

◆ SetTitleWindow()

void CONSTRAINT_RULES_LIST::SetTitleWindow ( wxWindow * aWindow)
inline

A window whose label is the section title.

The list appends the rule count to it.

Definition at line 68 of file constraint_rules_list.h.

References m_titleWindow.

◆ severityText()

wxString CONSTRAINT_RULES_LIST::severityText ( const DRC_RE_LOADED_PANEL_ENTRY & aEntry)
staticprivate

◆ sharedWithText()

◆ showMatches()

◆ showNewRule()

◆ showOverrideNote()

void CONSTRAINT_RULES_LIST::showOverrideNote ( )
private

◆ showRule()

void CONSTRAINT_RULES_LIST::showRule ( int aIndex)
private

◆ updateButtons()

Member Data Documentation

◆ m_defaults

std::vector<std::pair<wxString, std::function<wxString()> > > CONSTRAINT_RULES_LIST::m_defaults
private

Definition at line 161 of file constraint_rules_list.h.

Referenced by SetDefaults(), and showOverrideNote().

◆ m_document

◆ m_downBtn

wxButton* CONSTRAINT_RULES_LIST_BASE::m_downBtn
protectedinherited

◆ m_duplicateBtn

wxButton* CONSTRAINT_RULES_LIST_BASE::m_duplicateBtn
protectedinherited

◆ m_editingData

std::shared_ptr<DRC_RE_BASE_CONSTRAINT_DATA> CONSTRAINT_RULES_LIST::m_editingData
private

Definition at line 164 of file constraint_rules_list.h.

Referenced by addRule(), buildEditor(), editingIndex(), EditRule(), and RefreshRules().

◆ m_editingType

DRC_RULE_EDITOR_CONSTRAINT_NAME CONSTRAINT_RULES_LIST::m_editingType
private

Definition at line 165 of file constraint_rules_list.h.

Referenced by buildEditor(), and showOverrideNote().

◆ m_editor

◆ m_editorHost

wxPanel* CONSTRAINT_RULES_LIST_BASE::m_editorHost
protectedinherited

◆ m_editorSizer

wxBoxSizer* CONSTRAINT_RULES_LIST_BASE::m_editorSizer
protectedinherited

◆ m_emptyLabel

wxStaticText* CONSTRAINT_RULES_LIST_BASE::m_emptyLabel
protectedinherited

◆ m_fittedWidth

int CONSTRAINT_RULES_LIST::m_fittedWidth = -1
private

Definition at line 168 of file constraint_rules_list.h.

Referenced by fitColumns().

◆ m_frame

PCB_EDIT_FRAME* CONSTRAINT_RULES_LIST::m_frame
private

◆ m_list

◆ m_netclassPart

NETCLASS_CONSTRAINT_PART CONSTRAINT_RULES_LIST::m_netclassPart = NETCLASS_CONSTRAINT_PART::MINIMUM
private

Definition at line 171 of file constraint_rules_list.h.

Referenced by addNetclassRows(), and SetNetclasses().

◆ m_netclassValue

std::function<std::optional<int>( const NETCLASS& )> CONSTRAINT_RULES_LIST::m_netclassValue
private

Definition at line 170 of file constraint_rules_list.h.

Referenced by addNetclassRows(), and SetNetclasses().

◆ m_newBtn

wxButton* CONSTRAINT_RULES_LIST_BASE::m_newBtn
protectedinherited

◆ m_onChanged

std::function<void()> CONSTRAINT_RULES_LIST::m_onChanged
private

Definition at line 166 of file constraint_rules_list.h.

Referenced by notifyChanged(), and SetChangeCallback().

◆ m_primaryBtn

wxButton* CONSTRAINT_RULES_LIST_BASE::m_primaryBtn
protectedinherited

◆ m_refreshing

bool CONSTRAINT_RULES_LIST::m_refreshing = false
private

Definition at line 167 of file constraint_rules_list.h.

Referenced by RefreshRules().

◆ m_removeBtn

wxButton* CONSTRAINT_RULES_LIST_BASE::m_removeBtn
protectedinherited

◆ m_rowToIndex

std::vector<int> CONSTRAINT_RULES_LIST::m_rowToIndex
private

The document index each row shows, or NETCLASS_ROW where the row is a net class value.

Definition at line 174 of file constraint_rules_list.h.

Referenced by addNetclassRows(), RefreshRules(), selectedIndex(), and selectIndex().

◆ m_title

wxString CONSTRAINT_RULES_LIST::m_title
private

Definition at line 159 of file constraint_rules_list.h.

Referenced by CONSTRAINT_RULES_LIST(), RefreshRules(), and showNewRule().

◆ m_titleWindow

wxWindow* CONSTRAINT_RULES_LIST::m_titleWindow
private

Definition at line 160 of file constraint_rules_list.h.

Referenced by CONSTRAINT_RULES_LIST(), RefreshRules(), and SetTitleWindow().

◆ m_type

DRC_RULE_EDITOR_CONSTRAINT_NAME CONSTRAINT_RULES_LIST::m_type
private

◆ m_upBtn

wxButton* CONSTRAINT_RULES_LIST_BASE::m_upBtn
protectedinherited

◆ NETCLASS_ROW

int CONSTRAINT_RULES_LIST::NETCLASS_ROW = -1
staticconstexprprivate

What m_rowToIndex holds for a row that is not a rule of this document.

Definition at line 177 of file constraint_rules_list.h.

Referenced by addNetclassRows().


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