Parse DRC rules when closing Board Setup dialog.
This commit is contained in:
parent
79cdd608af
commit
4138c8554c
|
@ -29,9 +29,11 @@
|
||||||
#include <panel_setup_rules.h>
|
#include <panel_setup_rules.h>
|
||||||
#include <html_messagebox.h>
|
#include <html_messagebox.h>
|
||||||
#include <scintilla_tricks.h>
|
#include <scintilla_tricks.h>
|
||||||
|
#include <drc/drc_rule_parser.h>
|
||||||
|
|
||||||
PANEL_SETUP_RULES::PANEL_SETUP_RULES( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) :
|
PANEL_SETUP_RULES::PANEL_SETUP_RULES( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) :
|
||||||
PANEL_SETUP_RULES_BASE( aParent->GetTreebook() ),
|
PANEL_SETUP_RULES_BASE( aParent->GetTreebook() ),
|
||||||
|
m_Parent( aParent ),
|
||||||
m_frame( aFrame ),
|
m_frame( aFrame ),
|
||||||
m_scintillaTricks( nullptr )
|
m_scintillaTricks( nullptr )
|
||||||
{
|
{
|
||||||
|
@ -174,15 +176,35 @@ bool PANEL_SETUP_RULES::TransferDataToWindow()
|
||||||
if( rulesFile.FileExists() )
|
if( rulesFile.FileExists() )
|
||||||
m_textEditor->LoadFile( rulesFile.GetFullPath() );
|
m_textEditor->LoadFile( rulesFile.GetFullPath() );
|
||||||
|
|
||||||
|
m_originalText = m_textEditor->GetText();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PANEL_SETUP_RULES::TransferDataFromWindow()
|
bool PANEL_SETUP_RULES::TransferDataFromWindow()
|
||||||
{
|
{
|
||||||
|
if( m_originalText == m_textEditor->GetText() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::vector<DRC_SELECTOR*> dummySelectors;
|
||||||
|
std::vector<DRC_RULE*> dummyRules;
|
||||||
|
|
||||||
|
DRC_RULES_PARSER parser( m_frame->GetBoard(), m_textEditor->GetText(), _( "DRC rules" ) );
|
||||||
|
|
||||||
|
parser.Parse( dummySelectors, dummyRules );
|
||||||
|
}
|
||||||
|
catch( PARSE_ERROR& pe )
|
||||||
|
{
|
||||||
|
m_Parent->SetError( pe.What(), this, m_textEditor, pe.lineNumber, pe.byteIndex );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( m_textEditor->SaveFile( m_frame->Prj().AbsolutePath( "drc-rules" ) ) )
|
if( m_textEditor->SaveFile( m_frame->Prj().AbsolutePath( "drc-rules" ) ) )
|
||||||
{
|
{
|
||||||
m_frame->GetToolManager()->GetTool<DRC>()->Reset( TOOL_BASE::MODEL_RELOAD );
|
m_frame->GetToolManager()->GetTool<DRC>()->LoadRules();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,10 @@ class SCINTILLA_TRICKS;
|
||||||
class PANEL_SETUP_RULES : public PANEL_SETUP_RULES_BASE
|
class PANEL_SETUP_RULES : public PANEL_SETUP_RULES_BASE
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
PAGED_DIALOG* m_Parent;
|
||||||
PCB_EDIT_FRAME* m_frame;
|
PCB_EDIT_FRAME* m_frame;
|
||||||
SCINTILLA_TRICKS* m_scintillaTricks;
|
SCINTILLA_TRICKS* m_scintillaTricks;
|
||||||
|
wxString m_originalText;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PANEL_SETUP_RULES( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame );
|
PANEL_SETUP_RULES( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame );
|
||||||
|
|
|
@ -31,11 +31,28 @@
|
||||||
using namespace DRCRULE_T;
|
using namespace DRCRULE_T;
|
||||||
|
|
||||||
|
|
||||||
|
DRC_RULES_PARSER::DRC_RULES_PARSER( BOARD* aBoard, const wxString& aSource,
|
||||||
|
const wxString& aSourceDescr ) :
|
||||||
|
DRC_RULES_LEXER( aSource, aSourceDescr ),
|
||||||
|
m_board( aBoard ),
|
||||||
|
m_requiredVersion( 0 ),
|
||||||
|
m_tooRecent( false )
|
||||||
|
{
|
||||||
|
initLayerMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DRC_RULES_PARSER::DRC_RULES_PARSER( BOARD* aBoard, FILE* aFile, const wxString& aFilename ) :
|
DRC_RULES_PARSER::DRC_RULES_PARSER( BOARD* aBoard, FILE* aFile, const wxString& aFilename ) :
|
||||||
DRC_RULES_LEXER( aFile, aFilename ),
|
DRC_RULES_LEXER( aFile, aFilename ),
|
||||||
m_board( aBoard ),
|
m_board( aBoard ),
|
||||||
m_requiredVersion( 0 ),
|
m_requiredVersion( 0 ),
|
||||||
m_tooRecent( false )
|
m_tooRecent( false )
|
||||||
|
{
|
||||||
|
initLayerMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DRC_RULES_PARSER::initLayerMap()
|
||||||
{
|
{
|
||||||
for( LAYER_NUM layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
|
for( LAYER_NUM layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,11 +40,14 @@ class BOARD_ITEM;
|
||||||
class DRC_RULES_PARSER : public DRC_RULES_LEXER
|
class DRC_RULES_PARSER : public DRC_RULES_LEXER
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
DRC_RULES_PARSER( BOARD* aBoard, const wxString& aSource, const wxString& aSourceDescr );
|
||||||
DRC_RULES_PARSER( BOARD* aBoard, FILE* aFile, const wxString& aFilename );
|
DRC_RULES_PARSER( BOARD* aBoard, FILE* aFile, const wxString& aFilename );
|
||||||
|
|
||||||
void Parse( std::vector<DRC_SELECTOR*>& aSelectors, std::vector<DRC_RULE*>& aRules );
|
void Parse( std::vector<DRC_SELECTOR*>& aSelectors, std::vector<DRC_RULE*>& aRules );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void initLayerMap();
|
||||||
|
|
||||||
DRC_SELECTOR* parseDRC_SELECTOR( wxString* aRuleName );
|
DRC_SELECTOR* parseDRC_SELECTOR( wxString* aRuleName );
|
||||||
|
|
||||||
DRC_RULE* parseDRC_RULE();
|
DRC_RULE* parseDRC_RULE();
|
||||||
|
|
Loading…
Reference in New Issue