47 m_scintillaTricks( nullptr ),
48 m_helpWindow( nullptr )
52 [
this]( wxKeyEvent& aEvent )
55 wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
58 [
this]( wxStyledTextEvent& aEvent )
67 m_typeRegex.Compile(
"^Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
68 m_viaTypeRegex.Compile(
"^Via_Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
69 m_padTypeRegex.Compile(
"^Pad_Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
70 m_pinTypeRegex.Compile(
"^Pin_Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
71 m_fabPropRegex.Compile(
"^Fabrication_Property\\s*[!=]=\\s*$", wxRE_ADVANCED );
72 m_shapeRegex.Compile(
"^Shape\\s*[!=]=\\s*$", wxRE_ADVANCED );
77 m_hJustRegex.Compile(
"^Horizontal_Justification\\s*[!=]=\\s*$", wxRE_ADVANCED );
78 m_vJustRegex.Compile(
"^Vertical_Justification\\s*[!=]=\\s*$", wxRE_ADVANCED );
103 if( aEvent.GetKeyCode() == WXK_ESCAPE && !
m_textEditor->AutoCompActive() )
107 if(
IsOK( wxGetTopLevelParent(
this ),
_(
"Cancel Changes?" ) ) )
125 menu.Append( wxID_UNDO,
_(
"Undo" ) );
126 menu.Append( wxID_REDO,
_(
"Redo" ) );
128 menu.AppendSeparator();
130 menu.Append( 1,
_(
"Cut" ) );
131 menu.Append( 2,
_(
"Copy" ) );
132 menu.Append( 3,
_(
"Paste" ) );
133 menu.Append( 4,
_(
"Delete" ) );
135 menu.AppendSeparator();
137 menu.Append( 5,
_(
"Select All" ) );
139 menu.AppendSeparator();
141 menu.Append( wxID_ZOOM_IN,
_(
"Zoom In" ) );
142 menu.Append( wxID_ZOOM_OUT,
_(
"Zoom Out" ) );
145 switch( GetPopupMenuSelectionFromUser( menu ) )
190 if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKey() ==
' ' )
205 for(
int line =
m_textEditor->LineFromPosition( currentPos ); line > 0; line-- )
208 wxString beginning =
m_textEditor->GetTextRange( lineStart, lineStart + 10 );
210 if( beginning.StartsWith( wxT(
"(rule " ) ) )
212 startPos = lineStart;
227 auto isDisallowToken =
228 [](
const wxString& token ) ->
bool
230 return token == wxT(
"buried_via" )
231 || token == wxT(
"graphic" )
232 || token == wxT(
"hole" )
233 || token == wxT(
"micro_via" )
234 || token == wxT(
"pad" )
235 || token == wxT(
"text" )
236 || token == wxT(
"track" )
237 || token == wxT(
"via" )
238 || token == wxT(
"zone" );
241 auto isConstraintTypeToken =
242 [](
const wxString& token ) ->
bool
244 return token == wxT(
"annular_width" )
245 || token == wxT(
"assertion" )
246 || token == wxT(
"clearance" )
247 || token == wxT(
"connection_width" )
248 || token == wxT(
"courtyard_clearance" )
249 || token == wxT(
"diff_pair_gap" )
250 || token == wxT(
"diff_pair_uncoupled" )
251 || token == wxT(
"disallow" )
252 || token == wxT(
"edge_clearance" )
253 || token == wxT(
"length" )
254 || token == wxT(
"hole_clearance" )
255 || token == wxT(
"hole_size" )
256 || token == wxT(
"hole_to_hole" )
257 || token == wxT(
"min_resolved_spokes" )
258 || token == wxT(
"physical_clearance" )
259 || token == wxT(
"physical_hole_clearance" )
260 || token == wxT(
"silk_clearance" )
261 || token == wxT(
"skew" )
262 || token == wxT(
"text_height" )
263 || token == wxT(
"text_thickness" )
264 || token == wxT(
"thermal_relief_gap" )
265 || token == wxT(
"thermal_spoke_width" )
266 || token == wxT(
"track_width" )
267 || token == wxT(
"via_count" )
268 || token == wxT(
"via_diameter" )
269 || token == wxT(
"zone_connection" );
272 std::stack<wxString> sexprs;
275 wxString constraintType;
277 int expr_context =
NONE;
279 for(
int i = startPos; i < currentPos; ++i )
287 else if( context ==
STRING )
295 if( expr_context ==
STRING )
305 partial = wxEmptyString;
310 partial = wxEmptyString;
311 expr_context = STRUCT_REF;
322 partial = wxEmptyString;
327 if( context == SEXPR_OPEN && !partial.IsEmpty() )
330 sexprs.push( partial );
333 partial = wxEmptyString;
334 context = SEXPR_OPEN;
338 while( !sexprs.empty() && ( sexprs.top() == wxT(
"assertion" )
339 || sexprs.top() == wxT(
"disallow" )
340 || isDisallowToken( sexprs.top() )
341 || sexprs.top() == wxT(
"min_resolved_spokes" )
342 || sexprs.top() == wxT(
"zone_connection" ) ) )
347 if( !sexprs.empty() )
350 if( partial == wxT(
"within_diff_pairs" ) )
352 partial = wxEmptyString;
356 if( sexprs.top() == wxT(
"constraint" ) )
358 constraintType = wxEmptyString;
369 if( context == SEXPR_OPEN && !partial.IsEmpty() )
372 sexprs.push( partial );
374 if( partial == wxT(
"constraint" )
375 || partial == wxT(
"layer" )
376 || partial == wxT(
"severity" ) )
378 context = SEXPR_TOKEN;
380 else if( partial == wxT(
"rule" )
381 || partial == wxT(
"condition" ) )
383 context = SEXPR_STRING;
390 partial = wxEmptyString;
393 else if( partial == wxT(
"disallow" )
394 || isDisallowToken( partial )
395 || partial == wxT(
"min_resolved_spokes" )
396 || partial == wxT(
"zone_connection" ) )
399 sexprs.push( partial );
401 partial = wxEmptyString;
402 context = SEXPR_TOKEN;
405 else if( partial == wxT(
"assertion" ) )
408 sexprs.push( partial );
410 partial = wxEmptyString;
411 context = SEXPR_STRING;
414 else if( isConstraintTypeToken( partial ) )
416 constraintType = partial;
429 if( context == SEXPR_OPEN )
433 tokens = wxT(
"rule|"
436 else if( sexprs.top() == wxT(
"rule" ) )
438 tokens = wxT(
"condition|"
443 else if( sexprs.top() == wxT(
"constraint" ) )
445 if( constraintType == wxT(
"skew" ) )
446 tokens = wxT(
"max|min|opt|within_diff_pairs" );
448 tokens = wxT(
"max|min|opt" );
451 else if( context == SEXPR_TOKEN )
457 else if( sexprs.top() == wxT(
"constraint" ) )
459 tokens = wxT(
"annular_width|"
463 "courtyard_clearance|"
465 "diff_pair_uncoupled|"
472 "min_resolved_spokes|"
473 "physical_clearance|"
474 "physical_hole_clearance|"
479 "thermal_relief_gap|"
480 "thermal_spoke_width|"
486 else if( sexprs.top() == wxT(
"disallow" ) || isDisallowToken( sexprs.top() ) )
488 tokens = wxT(
"buried_via|"
499 else if( sexprs.top() == wxT(
"zone_connection" ) )
501 tokens = wxT(
"none|solid|thermal_reliefs" );
503 else if( sexprs.top() == wxT(
"min_resolved_spokes" ) )
505 tokens = wxT(
"0|1|2|3|4" );
507 else if( sexprs.top() == wxT(
"layer" ) )
509 tokens = wxT(
"inner|outer|\"x\"" );
511 else if( sexprs.top() == wxT(
"severity" ) )
513 tokens = wxT(
"warning|error|ignore|exclusion" );
516 else if( context == SEXPR_STRING && !sexprs.empty()
517 && ( sexprs.top() == wxT(
"condition" ) || sexprs.top() == wxT(
"assertion" ) ) )
521 else if( context ==
STRING && !sexprs.empty()
522 && ( sexprs.top() == wxT(
"condition" ) || sexprs.top() == wxT(
"assertion" ) ) )
524 if( expr_context == STRUCT_REF )
527 std::set<wxString> propNames;
538 if( prop->IsHiddenFromRulesEditor() )
541 wxString ref( prop->Name() );
542 ref.Replace( wxT(
" " ), wxT(
"_" ) );
543 propNames.insert( ref );
547 for(
const wxString& propName : propNames )
548 tokens += wxT(
"|" ) + propName;
554 if( !funcSig.Contains(
"DEPRECATED" ) )
555 tokens += wxT(
"|" ) + funcSig;
558 else if( expr_context ==
STRING )
563 std::shared_ptr<NET_SETTINGS>& netSettings = bds.
m_NetSettings;
565 for(
const auto& [
name, netclass] : netSettings->GetNetclasses() )
566 tokens += wxT(
"|" ) +
name;
573 tokens += wxT(
"|" ) + netnameCandidate;
577 tokens = wxT(
"Bitmap|"
593 tokens = wxT(
"Through|"
599 tokens = wxT(
"Through-hole|"
602 "NPTH, mechanical" );
606 tokens = wxT(
"Input|"
621 tokens = wxT(
"None|"
623 "Fiducial, global to board|"
624 "Fiducial, local to footprint|"
631 tokens = wxT(
"Segment|"
640 tokens = wxT(
"Circle|"
645 "Chamfered rectangle|"
650 tokens = wxT(
"Inherited|"
654 "Thermal reliefs for PTH" );
658 tokens = wxT(
"Inherited|"
665 tokens = wxT(
"Default|"
674 tokens = wxT(
"Left|"
687 if( !tokens.IsEmpty() )
698 std::vector<std::shared_ptr<DRC_RULE>> dummyRules;
706 wxString msg = wxString::Format( wxT(
"%s <a href='%d:%d'>%s</a>%s" ),
722 wxString link =
event.GetLinkInfo().GetHref();
724 long line = 0, offset = 0;
728 if( parts.size() > 1 )
730 parts[0].ToLong( &line );
731 parts[1].ToLong( &offset );
734 int pos =
m_textEditor->PositionFromLine( line - 1 ) + ( offset - 1 );
746 if( rulesFile.FileExists() )
748 wxTextFile file( rulesFile.GetFullPath() );
752 for ( wxString str = file.GetFirstLine(); !file.Eof(); str = file.GetNextLine() )
760 wxCommandEvent
dummy;
774 m_textEditor->AddText(
_(
"Design rules cannot be added without a project" ) );
824 msg.Replace( wxT(
"Ctrl+" ), wxT(
"Cmd+" ) );
833 html_txt.Replace( wxS(
"<td" ), wxS(
"<td valign=top" ) );
849 if( absFile.FileExists() )
851 wxTextFile file( absFile.GetFullPath() );
857 for ( wxString str = file.GetFirstLine(); !file.Eof(); str = file.GetNextLine() )
865 wxCommandEvent
dummy;
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Container for design settings for a BOARD object.
std::shared_ptr< NET_SETTINGS > m_NetSettings
std::shared_ptr< DRC_ENGINE > m_DRCEngine
Information pertinent to a Pcbnew printed circuit board.
std::set< wxString > GetNetClassAssignmentCandidates() const
Return the set of netname candidates for netclass assignment.
const wxString & GetFileName() const
PROJECT * GetProject() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void Parse(std::vector< std::shared_ptr< DRC_RULE > > &aRules, REPORTER *aReporter)
void SetDialogSizeInDU(int aWidth, int aHeight)
Set the dialog size, using a "logical" value.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
void ShowModeless()
Show a modeless version of the dialog (without an OK button).
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
Class PANEL_SETUP_RULES_BASE.
STD_BITMAP_BUTTON * m_compileButton
wxStyledTextCtrl * m_textEditor
WX_HTML_REPORT_BOX * m_errorsReport
bool TransferDataToWindow() override
void OnErrorLinkClicked(wxHtmlLinkEvent &event) override
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
void ImportSettingsFrom(BOARD *aBoard)
void OnContextMenu(wxMouseEvent &event) override
~PANEL_SETUP_RULES() override
HTML_MESSAGE_BOX * m_helpWindow
void OnCompile(wxCommandEvent &event) override
wxRegEx m_padConnectionsRegex
wxRegEx m_zoneConnStyleRegex
bool TransferDataFromWindow() override
void OnSyntaxHelp(wxHyperlinkEvent &aEvent) override
PANEL_SETUP_RULES(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame)
void onCharHook(wxKeyEvent &aEvent)
SCINTILLA_TRICKS * m_scintillaTricks
const wxArrayString GetSignatures() const
static PCBEXPR_BUILTIN_FUNCTIONS & Instance()
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
The main frame for Pcbnew.
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Provide class metadata.Helper macro to map type hashes to names.
CLASSES_INFO GetAllClasses()
const PROPERTY_LIST & GetProperties(TYPE_ID aType) const
Return all properties for a specific type.
static PROPERTY_MANAGER & Instance()
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
void DoAutocomplete(const wxString &aPartial, const wxArrayString &aTokens)
void Clear()
Delete the stored messages.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
void Flush()
Build the HTML messages page.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
This file is part of the common library.
static const std::string DesignRulesFileExtension
PGM_BASE & Pgm()
The global Program "get" accessor.
std::vector< PROPERTY_BASE * > PROPERTY_LIST
@ NONE
No connection to this item.
std::vector< FAB_LAYER_COLOR > dummy
bool ConvertSmartQuotesAndDashes(wxString *aString)
Convert curly quotes and em/en dashes to straight quotes and dashes.
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
A filename or source description, a problem input line, a line number, a byte offset,...
int lineNumber
at which line number, 1 based index.
const wxString ParseProblem()
int byteIndex
at which byte offset within the line, 1 based index
Definition of file extensions used in Kicad.