Browse Source

CHANGED: Design rules files now use .kicad_dru extension

Fixes https://gitlab.com/kicad/code/kicad/-/issues/5763
Fixes https://gitlab.com/kicad/code/kicad/-/issues/5444
pull/16/head
Jon Evans 5 years ago
parent
commit
0783669633
  1. 1
      common/project/project_archiver.cpp
  2. 1
      common/wildcards_and_files_ext.cpp
  3. 1
      include/wildcards_and_files_ext.h
  4. 1
      kicad/tree_project_frame.cpp
  5. 2
      pcbnew/dialogs/dialog_drc.cpp
  6. 5
      pcbnew/dialogs/panel_setup_rules.cpp
  7. 32
      pcbnew/pcb_base_edit_frame.cpp
  8. 7
      pcbnew/pcb_base_edit_frame.h
  9. 6
      pcbnew/swig/pcbnew_scripting_helpers.cpp
  10. 4
      pcbnew/tools/pcb_inspection_tool.cpp

1
common/project/project_archiver.cpp

@ -165,6 +165,7 @@ bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFi
wxT( "*.cmp" ),
wxT( "*.brd" ), wxT( "*.kicad_pcb" ), // Brd files
wxT( "*.mod" ), wxT( "*.kicad_mod" ), // fp files
wxT( "*.kicad_dru" ),
wxT( "*.gb?" ), wxT( "*.gbrjob" ), // Gerber files
wxT( "*.gko" ), wxT( "*.gm1" ),
wxT( "*.gm2" ), wxT( "*.g?" ),

1
common/wildcards_and_files_ext.cpp

@ -140,6 +140,7 @@ const std::string ArchiveFileExtension( "zip" );
const std::string LegacyPcbFileExtension( "brd" );
const std::string KiCadPcbFileExtension( "kicad_pcb" );
const std::string PageLayoutDescrFileExtension( "kicad_wks" );
const std::string DesignRulesFileExtension( "kicad_dru" );
const std::string PdfFileExtension( "pdf" );
const std::string MacrosFileExtension( "mcr" );

1
include/wildcards_and_files_ext.h

@ -132,6 +132,7 @@ extern const std::string KiCadPcbFileExtension;
#define PcbFileExtension KiCadPcbFileExtension // symlink choice
extern const std::string KiCadSymbolLibFileExtension;
extern const std::string PageLayoutDescrFileExtension;
extern const std::string DesignRulesFileExtension;
extern const std::string LegacyFootprintLibPathExtension;
extern const std::string PdfFileExtension;

1
kicad/tree_project_frame.cpp

@ -70,6 +70,7 @@ static const wxChar* s_allowedExtensionsToList[] = {
wxT( "^.*\\.kicad_sch$" ), // S-expr Eeschema files
wxT( "^[^$].*\\.brd$" ), // Legacy Pcbnew files
wxT( "^[^$].*\\.kicad_pcb$" ), // S format Pcbnew board files
wxT( "^[^$].*\\.kicad_dru$" ), // Design rule files
wxT( "^[^$].*\\.kicad_wks$" ), // S format kicad page layout help_textr files
wxT( "^[^$].*\\.kicad_mod$" ), // S format kicad footprint files, currently not listed
wxT( "^.*\\.net$" ), // pcbnew netlist file

2
pcbnew/dialogs/dialog_drc.cpp

@ -210,7 +210,7 @@ void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
// and that they at least parse.
try
{
drcTool->GetDRCEngine()->InitEngine( m_parentFrame->Prj().AbsolutePath( "drc-rules" ) );
drcTool->GetDRCEngine()->InitEngine( m_brdEditor->GetDesignRulesPath() );
}
catch( PARSE_ERROR& pe )
{

5
pcbnew/dialogs/panel_setup_rules.cpp

@ -331,8 +331,7 @@ void PANEL_SETUP_RULES::OnErrorLinkClicked( wxHtmlLinkEvent& event )
bool PANEL_SETUP_RULES::TransferDataToWindow()
{
wxString rulesFilepath = m_frame->Prj().AbsolutePath( "drc-rules" );
wxFileName rulesFile( rulesFilepath );
wxFileName rulesFile( m_frame->GetDesignRulesPath() );
if( rulesFile.FileExists() )
{
@ -373,7 +372,7 @@ bool PANEL_SETUP_RULES::TransferDataFromWindow()
return false;
}
wxString rulesFilepath = m_frame->Prj().AbsolutePath( "drc-rules" );
wxString rulesFilepath = m_frame->GetDesignRulesPath();
try
{

32
pcbnew/pcb_base_edit_frame.cpp

@ -39,6 +39,8 @@
#include <dialogs/eda_view_switcher.h>
#include <layer_widget.h>
#include <class_dimension.h>
#include <wildcards_and_files_ext.h>
PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
FRAME_T aFrameType, const wxString& aTitle,
@ -129,6 +131,17 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
{
bool new_board = ( aBoard != m_Pcb );
if( new_board )
{
if( m_toolManager )
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
GetCanvas()->GetView()->Clear();
GetCanvas()->GetView()->InitPreview();
}
PCB_BASE_FRAME::SetBoard( aBoard );
if( new_board )
{
BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings();
@ -136,23 +149,15 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
try
{
bds.m_DRCEngine->InitEngine( Prj().AbsolutePath( "drc-rules" ) );
bds.m_DRCEngine->InitEngine( GetDesignRulesPath() );
}
catch( PARSE_ERROR& pe )
{
// TODO: We could redirect to Board Setup here and report the error. Or we could
// wait till they run DRC or do an Inspect Clearance. Not sure which is better....
}
if( m_toolManager )
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
GetCanvas()->GetView()->Clear();
GetCanvas()->GetView()->InitPreview();
}
PCB_BASE_FRAME::SetBoard( aBoard );
GetCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetDesignSettings().m_GridOrigin ) );
// update the tool manager with the new board and its view.
@ -217,3 +222,12 @@ COLOR_SETTINGS* PCB_BASE_EDIT_FRAME::GetColorSettings()
}
wxString PCB_BASE_EDIT_FRAME::GetDesignRulesPath()
{
if( !GetBoard() )
return wxEmptyString;
wxFileName fn = GetBoard()->GetFileName();
fn.SetExt( DesignRulesFileExtension );
return Prj().AbsolutePath( fn.GetFullName() );
}

7
pcbnew/pcb_base_edit_frame.h

@ -212,6 +212,13 @@ public:
*/
void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override;
/**
* Returns the absolute path to the design rules file for the currently-loaded board.
* Note that there is no guarantee that this file actually exists and can be opened!
* NOTE: only really makes sense from PcbNew, but is needed in PCB_BASE_EDIT_FRAME::SetBoard
*/
wxString GetDesignRulesPath();
protected:
/// User defined rotation angle (in tenths of a degree).
int m_rotationAngle;

6
pcbnew/swig/pcbnew_scripting_helpers.cpp

@ -323,9 +323,13 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits,
wxCHECK( engine, false );
wxFileName fn = GetBoard()->GetFileName();
fn.SetExt( DesignRulesFileExtension );
wxString drcRulesPath = s_SettingsManager->Prj().AbsolutePath( fn.GetFullName() );
try
{
engine->InitEngine( s_SettingsManager->Prj().AbsolutePath( "drc-rules" ) );
engine->InitEngine( drcRulesPath );
}
catch( PARSE_ERROR& pe )
{

4
pcbnew/tools/pcb_inspection_tool.cpp

@ -191,7 +191,7 @@ void PCB_INSPECTION_TOOL::reportCopperClearance( PCB_LAYER_ID aLayer, BOARD_CONN
try
{
drcEngine.InitEngine( m_frame->Prj().AbsolutePath( "drc-rules" ) );
drcEngine.InitEngine( m_frame->GetDesignRulesPath() );
}
catch( PARSE_ERROR& pe )
{
@ -337,7 +337,7 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
try
{
drcEngine.InitEngine( m_frame->Prj().AbsolutePath( "drc-rules" ) );
drcEngine.InitEngine( m_frame->GetDesignRulesPath() );
}
catch( PARSE_ERROR& pe )
{

Loading…
Cancel
Save