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 );
82 m_textEditor->SetZoom(
Pgm().GetCommonSettings()->m_Appearance.text_editor_zoom );
92 Pgm().GetCommonSettings()->m_Appearance.text_editor_zoom =
m_textEditor->GetZoom();
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 std::stack<wxString> sexprs;
245 int expr_context =
NONE;
247 for(
int i = startPos; i < currentPos; ++i )
255 else if( context ==
STRING )
263 if( expr_context ==
STRING )
273 partial = wxEmptyString;
278 partial = wxEmptyString;
279 expr_context = STRUCT_REF;
290 partial = wxEmptyString;
295 if( context == SEXPR_OPEN && !partial.IsEmpty() )
298 sexprs.push( partial );
301 partial = wxEmptyString;
302 context = SEXPR_OPEN;
306 while( !sexprs.empty() && ( sexprs.top() == wxT(
"assertion" )
307 || sexprs.top() == wxT(
"disallow" )
308 || isDisallowToken( sexprs.top() )
309 || sexprs.top() == wxT(
"min_resolved_spokes" )
310 || sexprs.top() == wxT(
"zone_connection" ) ) )
315 if( !sexprs.empty() )
322 if( context == SEXPR_OPEN && !partial.IsEmpty() )
325 sexprs.push( partial );
327 if( partial == wxT(
"constraint" )
328 || partial == wxT(
"layer" )
329 || partial == wxT(
"severity" ) )
331 context = SEXPR_TOKEN;
333 else if( partial == wxT(
"rule" )
334 || partial == wxT(
"condition" ) )
336 context = SEXPR_STRING;
343 partial = wxEmptyString;
346 else if( partial == wxT(
"disallow" )
347 || isDisallowToken( partial )
348 || partial == wxT(
"min_resolved_spokes" )
349 || partial == wxT(
"zone_connection" ) )
352 sexprs.push( partial );
354 partial = wxEmptyString;
355 context = SEXPR_TOKEN;
358 else if( partial == wxT(
"assertion" ) )
361 sexprs.push( partial );
363 partial = wxEmptyString;
364 context = SEXPR_STRING;
378 if( context == SEXPR_OPEN )
382 tokens = wxT(
"rule|"
385 else if( sexprs.top() == wxT(
"rule" ) )
387 tokens = wxT(
"condition|"
392 else if( sexprs.top() == wxT(
"constraint" ) )
394 tokens = wxT(
"max|min|opt" );
397 else if( context == SEXPR_TOKEN )
403 else if( sexprs.top() == wxT(
"constraint" ) )
405 tokens = wxT(
"annular_width|"
409 "courtyard_clearance|"
411 "diff_pair_uncoupled|"
418 "min_resolved_spokes|"
419 "physical_clearance|"
420 "physical_hole_clearance|"
425 "thermal_relief_gap|"
426 "thermal_spoke_width|"
432 else if( sexprs.top() == wxT(
"disallow" ) || isDisallowToken( sexprs.top() ) )
434 tokens = wxT(
"buried_via|"
445 else if( sexprs.top() == wxT(
"zone_connection" ) )
447 tokens = wxT(
"none|solid|thermal_reliefs" );
449 else if( sexprs.top() == wxT(
"min_resolved_spokes" ) )
451 tokens = wxT(
"0|1|2|3|4" );
453 else if( sexprs.top() == wxT(
"layer" ) )
455 tokens = wxT(
"inner|outer|\"x\"" );
457 else if( sexprs.top() == wxT(
"severity" ) )
459 tokens = wxT(
"warning|error|ignore|exclusion" );
462 else if( context == SEXPR_STRING && !sexprs.empty()
463 && ( sexprs.top() == wxT(
"condition" ) || sexprs.top() == wxT(
"assertion" ) ) )
467 else if( context ==
STRING && !sexprs.empty()
468 && ( sexprs.top() == wxT(
"condition" ) || sexprs.top() == wxT(
"assertion" ) ) )
470 if( expr_context == STRUCT_REF )
473 std::set<wxString> propNames;
484 if( prop->IsHiddenFromRulesEditor() )
487 wxString ref( prop->Name() );
488 ref.Replace( wxT(
" " ), wxT(
"_" ) );
489 propNames.insert( ref );
493 for(
const wxString& propName : propNames )
494 tokens += wxT(
"|" ) + propName;
500 if( !funcSig.Contains(
"DEPRECATED" ) )
501 tokens += wxT(
"|" ) + funcSig;
504 else if( expr_context ==
STRING )
509 std::shared_ptr<NET_SETTINGS>& netSettings = bds.
m_NetSettings;
511 for(
const auto& [
name, netclass ] : netSettings->m_NetClasses )
512 tokens += wxT(
"|" ) +
name;
519 tokens += wxT(
"|" ) + netnameCandidate;
523 tokens = wxT(
"Bitmap|"
539 tokens = wxT(
"Through|"
545 tokens = wxT(
"Through-hole|"
548 "NPTH, mechanical" );
552 tokens = wxT(
"Input|"
567 tokens = wxT(
"None|"
569 "Fiducial, global to board|"
570 "Fiducial, local to footprint|"
577 tokens = wxT(
"Segment|"
586 tokens = wxT(
"Circle|"
591 "Chamfered rectangle|"
596 tokens = wxT(
"Inherited|"
600 "Thermal reliefs for PTH" );
604 tokens = wxT(
"Inherited|"
611 tokens = wxT(
"Default|"
620 tokens = wxT(
"Left|"
633 if( !tokens.IsEmpty() )
644 std::vector<std::shared_ptr<DRC_RULE>> dummyRules;
652 wxString msg = wxString::Format( wxT(
"%s <a href='%d:%d'>%s</a>%s" ),
668 wxString link =
event.GetLinkInfo().GetHref();
670 long line = 0, offset = 0;
674 if( parts.size() > 1 )
676 parts[0].ToLong( &line );
677 parts[1].ToLong( &offset );
680 int pos =
m_textEditor->PositionFromLine( line - 1 ) + ( offset - 1 );
692 if( rulesFile.FileExists() )
694 wxTextFile file( rulesFile.GetFullPath() );
698 for ( wxString str = file.GetFirstLine(); !file.Eof(); str = file.GetNextLine() )
706 wxCommandEvent
dummy;
716 m_textEditor->AddText(
_(
"Design rules cannot be added without a project" ) );
766 msg.Replace( wxT(
"Ctrl+" ), wxT(
"Cmd+" ) );
775 html_txt.Replace( wxS(
"<td" ), wxS(
"<td valign=top" ) );
791 if( absFile.FileExists() )
793 wxTextFile file( absFile.GetFullPath() );
797 for ( wxString str = file.GetFirstLine(); !file.Eof(); str = file.GetNextLine() )
806 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 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
std::vector< PROPERTY_BASE * > PROPERTY_LIST
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
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.