KiCad PCB EDA Suite
DRC_TEXTVAR_TESTER Class Reference

#include <drc_textvar_tester.h>

Inheritance diagram for DRC_TEXTVAR_TESTER:
DRC_TEST_PROVIDER

Public Types

using MARKER_HANDLER = std::function< void(MARKER_PCB *)>
 A callable that can handle a single generated PCB_MARKER. More...
 

Public Member Functions

 DRC_TEXTVAR_TESTER (MARKER_HANDLER aMarkerHandler, KIGFX::WS_PROXY_VIEW_ITEM *aWorksheet)
 
virtual ~DRC_TEXTVAR_TESTER ()
 
bool RunDRC (EDA_UNITS aUnits, BOARD &aBoard) override
 Runs this provider against the given PCB with configured options (if any). More...
 

Protected Member Functions

void HandleMarker (MARKER_PCB *aMarker) const
 Pass a given marker to the marker handler. More...
 

Private Attributes

EDA_UNITS m_units
 
BOARDm_board
 
KIGFX::WS_PROXY_VIEW_ITEMm_worksheet
 

Detailed Description

Definition at line 34 of file drc_textvar_tester.h.

Member Typedef Documentation

◆ MARKER_HANDLER

using DRC_TEST_PROVIDER::MARKER_HANDLER = std::function<void( MARKER_PCB* )>
inherited

A callable that can handle a single generated PCB_MARKER.

Definition at line 47 of file drc_provider.h.

Constructor & Destructor Documentation

◆ DRC_TEXTVAR_TESTER()

DRC_TEXTVAR_TESTER::DRC_TEXTVAR_TESTER ( MARKER_HANDLER  aMarkerHandler,
KIGFX::WS_PROXY_VIEW_ITEM aWorksheet 
)

Definition at line 32 of file drc_textvar_tester.cpp.

33  :
34  DRC_TEST_PROVIDER( std::move( aMarkerHandler ) ),
36  m_board( nullptr ),
37  m_worksheet( aWorksheet )
38 {
39 }
DRC_TEST_PROVIDER(MARKER_HANDLER aMarkerHandler)
Definition: drc_provider.h:60
KIGFX::WS_PROXY_VIEW_ITEM * m_worksheet

◆ ~DRC_TEXTVAR_TESTER()

virtual DRC_TEXTVAR_TESTER::~DRC_TEXTVAR_TESTER ( )
inlinevirtual

Definition at line 39 of file drc_textvar_tester.h.

39 {};

Member Function Documentation

◆ HandleMarker()

void DRC_TEST_PROVIDER::HandleMarker ( MARKER_PCB aMarker) const
inlineprotectedinherited

◆ RunDRC()

bool DRC_TEXTVAR_TESTER::RunDRC ( EDA_UNITS  aUnits,
BOARD aBoard 
)
overridevirtual

Runs this provider against the given PCB with configured options (if any).

Note: Board is non-const, as some DRC functions modify the board (e.g. zone fill or polygon coalescing)

Implements DRC_TEST_PROVIDER.

Definition at line 42 of file drc_textvar_tester.cpp.

43 {
44  bool success = true;
45 
46  m_units = aUnits;
47  m_board = &aBoard;
48 
49  for( MODULE* module : m_board->Modules() )
50  {
51  module->RunOnChildren(
52  [&]( BOARD_ITEM* child )
53  {
54  if( child->Type() == PCB_MODULE_TEXT_T )
55  {
56  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( child );
57 
58  if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
59  {
61  drcItem->SetItems( text );
62 
63  HandleMarker( new MARKER_PCB( drcItem, text->GetPosition() ) );
64  success = false;
65  }
66  }
67  } );
68  }
69 
70  for( BOARD_ITEM* drawing : m_board->Drawings() )
71  {
72  if( drawing->Type() == PCB_TEXT_T )
73  {
74  TEXTE_PCB* text = static_cast<TEXTE_PCB*>( drawing );
75 
76  if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
77  {
79  drcItem->SetItems( text );
80 
81  HandleMarker( new MARKER_PCB( drcItem, text->GetPosition() ) );
82  success = false;
83  }
84  }
85  }
86 
87  WS_DRAW_ITEM_LIST wsItems;
88 
89  if( m_worksheet )
90  {
91  wsItems.SetMilsToIUfactor( IU_PER_MILS );
94 
95  for( WS_DRAW_ITEM_BASE* item = wsItems.GetFirst(); item; item = wsItems.GetNext() )
96  {
97  if( WS_DRAW_ITEM_TEXT* text = dynamic_cast<WS_DRAW_ITEM_TEXT*>( item ) )
98  {
99  if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
100  {
102  drcItem->SetErrorMessage( _( "Unresolved text variable in worksheet." ) );
103 
104  HandleMarker( new MARKER_PCB( drcItem, text->GetPosition() ) );
105  success = false;
106  }
107  }
108  }
109  }
110 
111  // JEY TODO: Test text vars in worksheet...
112 
113  return success;
114 }
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void SetItems(EDA_ITEM *aItem, EDA_ITEM *bItem=nullptr, EDA_ITEM *cItem=nullptr, EDA_ITEM *dItem=nullptr)
Definition: rc_item.h:119
WS_DRAW_ITEM_BASE * GetNext()
Definition: ws_draw_item.h:477
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
WS_DRAW_ITEM_BASE * GetFirst()
Definition: ws_draw_item.h:467
void BuildWorkSheetGraphicList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Function BuildWorkSheetGraphicList is a core function for drawing or plotting the page layout with th...
MODULES & Modules()
Definition: class_board.h:266
void HandleMarker(MARKER_PCB *aMarker) const
Pass a given marker to the marker handler.
Definition: drc_provider.h:68
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
void SetMilsToIUfactor(double aScale)
Function SetMilsToIUfactor Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ws_draw_item.h:433
const TITLE_BLOCK & GetTitleBlock()
static DRC_ITEM * Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:197
virtual const wxPoint GetPosition() const override
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
virtual wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
#define _(s)
Definition: 3d_actions.cpp:33
virtual const wxPoint GetPosition() const override
#define IU_PER_MILS
Definition: plotter.cpp:138
void SetErrorMessage(const wxString &aMessage)
Definition: rc_item.h:117
KIGFX::WS_PROXY_VIEW_ITEM * m_worksheet
DRAWINGS & Drawings()
Definition: class_board.h:275
const PAGE_INFO & GetPageInfo()
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References _, WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), DRC_ITEM::Create(), BOARD::Drawings(), DRCE_UNRESOLVED_VARIABLE, WS_DRAW_ITEM_LIST::GetFirst(), WS_DRAW_ITEM_LIST::GetNext(), KIGFX::WS_PROXY_VIEW_ITEM::GetPageInfo(), TEXTE_PCB::GetPosition(), TEXTE_MODULE::GetPosition(), TEXTE_PCB::GetShownText(), TEXTE_MODULE::GetShownText(), KIGFX::WS_PROXY_VIEW_ITEM::GetTitleBlock(), DRC_TEST_PROVIDER::HandleMarker(), IU_PER_MILS, m_board, m_units, m_worksheet, BOARD::Modules(), PCB_MODULE_TEXT_T, PCB_TEXT_T, RC_ITEM::SetErrorMessage(), RC_ITEM::SetItems(), WS_DRAW_ITEM_LIST::SetMilsToIUfactor(), and EDA_ITEM::Type().

Referenced by DRC::RunTests().

Member Data Documentation

◆ m_board

BOARD* DRC_TEXTVAR_TESTER::m_board
private

Definition at line 45 of file drc_textvar_tester.h.

Referenced by RunDRC().

◆ m_units

EDA_UNITS DRC_TEXTVAR_TESTER::m_units
private

Definition at line 44 of file drc_textvar_tester.h.

Referenced by RunDRC().

◆ m_worksheet

KIGFX::WS_PROXY_VIEW_ITEM* DRC_TEXTVAR_TESTER::m_worksheet
private

Definition at line 46 of file drc_textvar_tester.h.

Referenced by RunDRC().


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