36 #include <wx/treebook.h> 47 m_scintillaTricks( nullptr ),
48 m_helpWindow( nullptr )
53 wxPostEvent(
m_Parent, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
60 m_typeRegex.Compile(
"^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 );
67 m_textEditor->SetZoom(
Pgm().GetCommonSettings()->m_Appearance.text_editor_zoom );
78 Pgm().GetCommonSettings()->m_Appearance.text_editor_zoom =
m_textEditor->GetZoom();
89 if( aEvent.GetKeyCode() == WXK_ESCAPE && !
m_textEditor->AutoCompActive() )
93 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;
248 expr_context = STRING;
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|" 355 else if( sexprs.top() == wxT(
"constraint" ) )
357 tokens = wxT(
"max|min|opt" );
360 else if( context == SEXPR_TOKEN )
366 else if( sexprs.top() == wxT(
"constraint" ) )
368 tokens = wxT(
"annular_width|" 370 "courtyard_clearance|" 372 "diff_pair_uncoupled|" 385 else if( sexprs.top() == wxT(
"disallow" ) || isDisallowToken( sexprs.top() ) )
387 tokens = wxT(
"buried_via|" 397 else if( sexprs.top() == wxT(
"layer" ) )
399 tokens = wxT(
"inner|outer|\"x\"" );
401 else if( sexprs.top() == wxT(
"severity" ) )
403 tokens = wxT(
"warning|error|ignore|exclusion" );
406 else if( context == STRING && !sexprs.empty() && sexprs.top() == wxT(
"condition" ) )
408 if( expr_context == STRUCT_REF )
411 std::set<wxString> propNames;
419 wxString ref( prop->Name() );
420 ref.Replace( wxT(
" " ), wxT(
"_" ) );
421 propNames.insert( ref );
425 for(
const wxString& propName : propNames )
426 tokens += wxT(
"|" ) + propName;
431 tokens += wxT(
"|" ) + funcSig;
433 else if( expr_context == STRING )
440 for(
const std::pair<const wxString, NETCLASSPTR>& entry : bds.
GetNetClasses() )
441 tokens += wxT(
"|" ) + entry.first;
448 tokens += wxT(
"|" ) + netnameCandidate;
452 tokens = wxT(
"Dimension|" 466 tokens = wxT(
"Through-hole|" 469 "NPTH, mechanical" );
473 tokens = wxT(
"Input|" 488 tokens = wxT(
"None|" 490 "Fiducial, global to board|" 491 "Fiducial, local to footprint|" 499 if( !tokens.IsEmpty() )
510 std::vector<DRC_RULE*> dummyRules;
534 wxString link =
event.GetLinkInfo().GetHref();
536 long line = 0, offset = 0;
540 if( parts.size() > 1 )
542 parts[0].ToLong( &line );
543 parts[1].ToLong( &offset );
546 int pos =
m_textEditor->PositionFromLine( line - 1 ) + ( offset - 1 );
558 if( rulesFile.FileExists() )
560 wxTextFile file( rulesFile.GetFullPath() );
564 for ( wxString str = file.GetFirstLine(); !file.Eof(); str = file.GetNextLine() )
570 wxCommandEvent
dummy;
580 m_textEditor->AddText(
_(
"Design rules cannot be added without a project" ) );
626 #include "dialogs/panel_setup_rules_help_md.h" 630 msg.Replace( wxT(
"Ctrl+" ), wxT(
"Cmd+" ) );
const PROPERTY_LIST & GetProperties(TYPE_ID aType) const
Return all properties for a specific type.
static PROPERTY_MANAGER & Instance()
const wxArrayString GetSignatures() const
bool TransferDataFromWindow() override
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
This file is part of the common library.
void Clear()
Delete the stored messages.
void OnCompile(wxCommandEvent &event) override
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
bool TransferDataToWindow() override
void DoAutocomplete(const wxString &aPartial, const wxArrayString &aTokens)
void Flush()
Build the HTML messages page.
wxBitmapButton * m_compileButton
SCINTILLA_TRICKS * m_scintillaTricks
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
const wxString ParseProblem()
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Class PANEL_SETUP_RULES_BASE.
WX_HTML_REPORT_BOX * m_errorsReport
int lineNumber
at which line number, 1 based index.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
void OnContextMenu(wxMouseEvent &event) override
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
void Parse(std::vector< DRC_RULE * > &aRules, REPORTER *aReporter)
~PANEL_SETUP_RULES() override
std::vector< wxString > GetNetClassAssignmentCandidates() const
Return a list of name candidates for netclass assignment.
PANEL_SETUP_RULES(PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame)
NETCLASSES & GetNetClasses() const
void onCharHook(wxKeyEvent &aEvent)
bool ConvertSmartQuotesAndDashes(wxString *aString)
Convert curly quotes and em/en dashes to straight quotes and dashes.
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
void OnSyntaxHelp(wxHyperlinkEvent &aEvent) override
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void ShowModeless()
Show a modeless version of the dialog (without an OK button).
void SetDialogSizeInDU(int aWidth, int aHeight)
Set the dialog size, using a "logical" value.
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
A filename or source description, a problem input line, a line number, a byte offset,...
std::vector< PROPERTY_BASE * > PROPERTY_LIST
Information pertinent to a Pcbnew printed circuit board.
HTML_MESSAGE_BOX * m_helpWindow
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
The main frame for Pcbnew.
wxStyledTextCtrl * m_textEditor
int byteIndex
at which byte offset within the line, 1 based index
CLASSES_INFO GetAllClasses()
Provide class metadata.Helper macro to map type hashes to names.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
Container for design settings for a BOARD object.
static PCB_EXPR_BUILTIN_FUNCTIONS & Instance()
void OnErrorLinkClicked(wxHtmlLinkEvent &event) override