45 m_scintillaTricks( nullptr ),
46 m_helpWindow( nullptr )
52 wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
59 m_typeRegex.Compile(
"^Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
60 m_viaTypeRegex.Compile(
"^Via_Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
61 m_padTypeRegex.Compile(
"^Pad_Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
62 m_pinTypeRegex.Compile(
"^Pin_Type\\s*[!=]=\\s*$", wxRE_ADVANCED );
63 m_fabPropRegex.Compile(
"^Fabrication_Property\\s*[!=]=\\s*$", wxRE_ADVANCED );
64 m_shapeRegex.Compile(
"^Shape\\s*[!=]=\\s*$", wxRE_ADVANCED );
68 m_textEditor->SetZoom(
Pgm().GetCommonSettings()->m_Appearance.text_editor_zoom );
79 Pgm().GetCommonSettings()->m_Appearance.text_editor_zoom =
m_textEditor->GetZoom();
90 if( aEvent.GetKeyCode() == WXK_ESCAPE && !
m_textEditor->AutoCompActive() )
94 if( !
IsOK(
this,
_(
"Cancel Changes?" ) ) )
107 menu.Append( wxID_UNDO,
_(
"Undo" ) );
108 menu.Append( wxID_REDO,
_(
"Redo" ) );
110 menu.AppendSeparator();
112 menu.Append( 1,
_(
"Cut" ) );
113 menu.Append( 2,
_(
"Copy" ) );
114 menu.Append( 3,
_(
"Paste" ) );
115 menu.Append( 4,
_(
"Delete" ) );
117 menu.AppendSeparator();
119 menu.Append( 5,
_(
"Select All" ) );
121 menu.AppendSeparator();
123 menu.Append( wxID_ZOOM_IN,
_(
"Zoom In" ) );
124 menu.Append( wxID_ZOOM_OUT,
_(
"Zoom Out" ) );
127 switch( GetPopupMenuSelectionFromUser( menu ) )
179 for(
int line =
m_textEditor->LineFromPosition( currentPos ); line > 0; line-- )
182 wxString beginning =
m_textEditor->GetTextRange( lineStart, lineStart + 10 );
184 if( beginning.StartsWith( wxT(
"(rule " ) ) )
186 startPos = lineStart;
201 auto isDisallowToken =
202 [](
const wxString& token ) ->
bool
204 return token == wxT(
"buried_via" )
205 || token == wxT(
"graphic" )
206 || token == wxT(
"hole" )
207 || token == wxT(
"micro_via" )
208 || token == wxT(
"pad" )
209 || token == wxT(
"text" )
210 || token == wxT(
"track" )
211 || token == wxT(
"via" )
212 || token == wxT(
"zone" );
215 std::stack<wxString> sexprs;
219 int expr_context =
NONE;
221 for(
int i = startPos; i < currentPos; ++i )
229 else if( context ==
STRING )
237 if( expr_context ==
STRING )
247 partial = wxEmptyString;
252 partial = wxEmptyString;
253 expr_context = STRUCT_REF;
264 partial = wxEmptyString;
269 if( context == SEXPR_OPEN && !partial.IsEmpty() )
272 sexprs.push( partial );
275 partial = wxEmptyString;
276 context = SEXPR_OPEN;
280 while( !sexprs.empty() && ( sexprs.top() == wxT(
"assertion" )
281 || sexprs.top() == wxT(
"disallow" )
282 || isDisallowToken( sexprs.top() )
283 || sexprs.top() == wxT(
"min_resolved_spokes" )
284 || sexprs.top() == wxT(
"zone_connection" ) ) )
289 if( !sexprs.empty() )
296 if( context == SEXPR_OPEN && ( partial == wxT(
"constraint" )
297 || partial == wxT(
"disallow" )
298 || partial == wxT(
"layer" )
299 || partial == wxT(
"severity" ) ) )
302 sexprs.push( partial );
304 partial = wxEmptyString;
305 context = SEXPR_TOKEN;
308 else if( partial == wxT(
"disallow" )
309 || isDisallowToken( partial )
310 || partial == wxT(
"min_resolved_spokes" )
311 || partial == wxT(
"zone_connection" ) )
314 sexprs.push( partial );
316 partial = wxEmptyString;
317 context = SEXPR_TOKEN;
320 else if( partial == wxT(
"rule" )
321 || partial == wxT(
"assertion" )
322 || partial == wxT(
"condition" ) )
325 sexprs.push( partial );
327 partial = wxEmptyString;
328 context = SEXPR_STRING;
342 if( context == SEXPR_OPEN )
346 tokens = wxT(
"rule|"
349 else if( sexprs.top() == wxT(
"rule" ) )
351 tokens = wxT(
"condition|"
356 else if( sexprs.top() == wxT(
"constraint" ) )
358 tokens = wxT(
"max|min|opt" );
361 else if( context == SEXPR_TOKEN )
367 else if( sexprs.top() == wxT(
"constraint" ) )
369 tokens = wxT(
"annular_width|"
373 "courtyard_clearance|"
375 "diff_pair_uncoupled|"
382 "min_resolved_spokes|"
383 "physical_clearance|"
384 "physical_hole_clearance|"
389 "thermal_relief_gap|"
390 "thermal_spoke_width|"
396 else if( sexprs.top() == wxT(
"disallow" ) || isDisallowToken( sexprs.top() ) )
398 tokens = wxT(
"buried_via|"
408 else if( sexprs.top() == wxT(
"zone_connection" ) )
410 tokens = wxT(
"none|solid|thermal_reliefs" );
412 else if( sexprs.top() == wxT(
"min_resolved_spokes" ) )
414 tokens = wxT(
"0|1|2|3|4" );
416 else if( sexprs.top() == wxT(
"layer" ) )
418 tokens = wxT(
"inner|outer|\"x\"" );
420 else if( sexprs.top() == wxT(
"severity" ) )
422 tokens = wxT(
"warning|error|ignore|exclusion" );
425 else if( context == SEXPR_STRING && !sexprs.empty()
426 && ( sexprs.top() == wxT(
"condition" ) || sexprs.top() == wxT(
"assertion" ) ) )
430 else if( context ==
STRING && !sexprs.empty()
431 && ( sexprs.top() == wxT(
"condition" ) || sexprs.top() == wxT(
"assertion" ) ) )
433 if( expr_context == STRUCT_REF )
436 std::set<wxString> propNames;
447 if( prop->IsHiddenFromRulesEditor() )
450 wxString ref( prop->Name() );
451 ref.Replace( wxT(
" " ), wxT(
"_" ) );
452 propNames.insert( ref );
456 for(
const wxString& propName : propNames )
457 tokens += wxT(
"|" ) + propName;
463 if( !funcSig.Contains(
"DEPRECATED" ) )
464 tokens += wxT(
"|" ) + funcSig;
467 else if( expr_context ==
STRING )
472 std::shared_ptr<NET_SETTINGS>& netSettings = bds.
m_NetSettings;
474 for(
const auto& [
name, netclass ] : netSettings->m_NetClasses )
475 tokens += wxT(
"|" ) +
name;
482 tokens += wxT(
"|" ) + netnameCandidate;
486 tokens = wxT(
"Bitmap|"
502 tokens = wxT(
"Through|"
508 tokens = wxT(
"Through-hole|"
511 "NPTH, mechanical" );
515 tokens = wxT(
"Input|"
530 tokens = wxT(
"None|"
532 "Fiducial, global to board|"
533 "Fiducial, local to footprint|"
540 tokens = wxT(
"Segment|"
550 if( !tokens.IsEmpty() )
561 std::vector<std::shared_ptr<DRC_RULE>> dummyRules;
569 wxString msg = wxString::Format( wxT(
"%s <a href='%d:%d'>%s</a>%s" ),
585 wxString link =
event.GetLinkInfo().GetHref();
587 long line = 0, offset = 0;
591 if( parts.size() > 1 )
593 parts[0].ToLong( &line );
594 parts[1].ToLong( &offset );
597 int pos =
m_textEditor->PositionFromLine( line - 1 ) + ( offset - 1 );
609 if( rulesFile.FileExists() )
611 wxTextFile file( rulesFile.GetFullPath() );
615 for ( wxString str = file.GetFirstLine(); !file.Eof(); str = file.GetNextLine() )
623 wxCommandEvent
dummy;
633 m_textEditor->AddText(
_(
"Design rules cannot be added without a project" ) );
683 msg.Replace( wxT(
"Ctrl+" ), wxT(
"Cmd+" ) );
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
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.
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.
wxStyledTextCtrl * m_textEditor
WX_HTML_REPORT_BOX * m_errorsReport
wxBitmapButton * m_compileButton
bool TransferDataToWindow() override
void OnErrorLinkClicked(wxHtmlLinkEvent &event) override
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
void OnContextMenu(wxMouseEvent &event) override
~PANEL_SETUP_RULES() override
HTML_MESSAGE_BOX * m_helpWindow
void OnCompile(wxCommandEvent &event) override
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
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
The main frame for Pcbnew.
const wxArrayString GetSignatures() const
static PCB_EXPR_BUILTIN_FUNCTIONS & Instance()
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.
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