Move board functions to BOARD_EDITOR_CONTROL.

This commit is contained in:
Jeff Young 2025-05-23 22:38:59 +01:00
parent a3ac56e1a6
commit e03cb736f2
20 changed files with 334 additions and 412 deletions

View File

@ -35,9 +35,7 @@
enum gerbview_ids
{
ID_MAIN_MENUBAR = ID_END_LIST,
ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE,
ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE = ID_END_LIST,
ID_TOOLBARH_GERBER_DATA_TEXT_BOX,
ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE,

View File

@ -34,9 +34,7 @@
enum pl_editor_ids
{
ID_MAIN_MENUBAR = ID_END_LIST,
ID_SELECT_COORDINATE_ORIGIN,
ID_SELECT_COORDINATE_ORIGIN = ID_END_LIST,
ID_SELECT_PAGE_NUMBER,
ID_APPEND_DESCR_FILE,

View File

@ -33,6 +33,7 @@
#include <project.h>
#include <wildcards_and_files_ext.h>
#include <footprint.h>
#include <tools/board_editor_control.h>
#include <wx/listimpl.cpp>
#include <wx/filedlg.h>
@ -69,29 +70,29 @@ WX_DECLARE_LIST( BOM_ENTRY, BOM_ENTRY_LIST );
WX_DEFINE_LIST( BOM_ENTRY_LIST )
void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
int BOARD_EDITOR_CONTROL::GenBOMFileFromBoard( const TOOL_EVENT& aEvent )
{
BOARD* board = m_frame->GetBoard();
wxFileName fn;
FILE* fp_bom;
wxString msg;
if( GetBoard()->Footprints().empty() )
if( board->Footprints().empty() )
{
ShowInfoBarError( _( "Cannot export BOM: there are no footprints on the PCB." ) );
return;
m_frame->ShowInfoBarError( _( "Cannot export BOM: there are no footprints on the PCB." ) );
return 0;
}
/* Set the file extension: */
fn = GetBoard()->GetFileName();
fn = board->GetFileName();
fn.SetExt( FILEEXT::CsvFileExtension );
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
wxString pro_dir = wxPathOnly( m_frame->Prj().GetProjectFullName() );
wxFileDialog dlg( this, _( "Save Bill of Materials" ), pro_dir, fn.GetFullName(),
wxFileDialog dlg( m_frame, _( "Save Bill of Materials" ), pro_dir, fn.GetFullName(),
FILEEXT::CsvFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return;
return 0;
fn = dlg.GetPath();
@ -99,13 +100,12 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
if( fp_bom == nullptr )
{
msg.Printf( _( "Failed to create file '%s'." ), fn.GetFullPath() );
DisplayError( this, msg );
return;
DisplayError( m_frame, wxString::Format( _( "Failed to create file '%s'." ), fn.GetFullPath() ) );
return 0;
}
// Write header:
msg = wxT( "\"" );
wxString msg = wxT( "\"" );
msg << _( "Id" ) << wxT( "\";\"" );
msg << _( "Designator" ) << wxT( "\";\"" );
msg << _( "Footprint" ) << wxT( "\";\"" );
@ -118,7 +118,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
BOM_ENTRY_LIST list;
int i = 1;
for( FOOTPRINT* footprint : GetBoard()->Footprints() )
for( FOOTPRINT* footprint : board->Footprints() )
{
if( footprint->GetAttributes() & FP_EXCLUDE_FROM_BOM )
continue;
@ -130,8 +130,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
{
BOM_ENTRY* curEntry = *iter;
if( curEntry->m_Val == footprint->GetValue()
&& curEntry->m_FPID == footprint->GetFPID() )
if( curEntry->m_Val == footprint->GetValue() && curEntry->m_FPID == footprint->GetFPID() )
{
curEntry->m_Ref.Append( wxT( ", " ), 1 );
curEntry->m_Ref.Append( footprint->Reference().GetShownText( false ) );
@ -160,7 +159,6 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
{
BOM_ENTRY* curEntry = *list.begin(); // Because the first object will be removed
// from list, all objects will be get here
msg.Empty();
msg << curEntry->m_Id << wxT( ";\"" );
@ -176,4 +174,6 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
}
fclose( fp_bom );
return 0;
}

View File

@ -27,6 +27,7 @@
#include <widgets/text_ctrl_eval.h>
#include <dialog_export_idf.h>
#include <pcbnew_settings.h>
#include <tools/board_editor_control.h>
#include <project/project_file.h> // LAST_PATH_TYPE
#include <kidialog.h>
@ -146,23 +147,25 @@ bool DIALOG_EXPORT_IDF3::TransferDataFromWindow()
}
void PCB_EDIT_FRAME::OnExportIDF3( wxCommandEvent& event )
int BOARD_EDITOR_CONTROL::ExportIDF( const TOOL_EVENT& aEvent )
{
BOARD* board = m_frame->GetBoard();
// Build default output file name
wxString path = GetLastPath( LAST_PATH_IDF );
wxString path = m_frame->GetLastPath( LAST_PATH_IDF );
if( path.IsEmpty() )
{
wxFileName brdFile = GetBoard()->GetFileName();
wxFileName brdFile = board->GetFileName();
brdFile.SetExt( wxT( "emn" ) );
path = brdFile.GetFullPath();
}
DIALOG_EXPORT_IDF3 dlg( this );
DIALOG_EXPORT_IDF3 dlg( m_frame );
dlg.FilePicker()->SetPath( path );
if ( dlg.ShowModal() != wxID_OK )
return;
return 0;
bool thou = dlg.GetThouOption();
double aXRef;
@ -170,8 +173,7 @@ void PCB_EDIT_FRAME::OnExportIDF3( wxCommandEvent& event )
if( dlg.GetAutoAdjustOffset() )
{
BOX2I bbox = GetBoard()->GetBoardEdgesBoundingBox();
BOX2I bbox = board->GetBoardEdgesBoundingBox();
aXRef = bbox.Centre().x * pcbIUScale.MM_PER_IU;
aYRef = bbox.Centre().y * pcbIUScale.MM_PER_IU;
}
@ -186,20 +188,19 @@ void PCB_EDIT_FRAME::OnExportIDF3( wxCommandEvent& event )
aXRef *= 25.4;
aYRef *= 25.4;
}
}
wxBusyCursor dummy;
wxString fullFilename = dlg.FilePicker()->GetPath();
SetLastPath( LAST_PATH_IDF, fullFilename );
m_frame->SetLastPath( LAST_PATH_IDF, fullFilename );
if( !Export_IDF3( GetBoard(), fullFilename, thou, aXRef, aYRef, !dlg.GetNoUnspecifiedOption(),
!dlg.GetNoDNPOption() ) )
if( !m_frame->Export_IDF3( board, fullFilename, thou, aXRef, aYRef, !dlg.GetNoUnspecifiedOption(),
!dlg.GetNoDNPOption() ) )
{
wxString msg = wxString::Format( _( "Failed to create file '%s'." ), fullFilename );
wxMessageBox( msg );
return;
wxMessageBox( wxString::Format( _( "Failed to create file '%s'." ), fullFilename ) );
}
return 0;
}

View File

@ -41,6 +41,7 @@
#include <math/vector3.h>
#include <pcb_edit_frame.h>
#include <pcbnew_settings.h>
#include <tools/board_editor_control.h>
#include <project/project_file.h> // LAST_PATH_TYPE
#include <reporter.h>
#include <trace_helpers.h>
@ -392,42 +393,44 @@ DIALOG_EXPORT_STEP::STEP_ORIGIN_OPTION DIALOG_EXPORT_STEP::GetOriginOption()
}
void PCB_EDIT_FRAME::OnExportSTEP( wxCommandEvent& event )
int BOARD_EDITOR_CONTROL::ExportSTEP( const TOOL_EVENT& aEvent )
{
wxFileName brdFile = GetBoard()->GetFileName();
BOARD* board = m_frame->GetBoard();
wxFileName brdFile = board->GetFileName();
// The project filename (.kicad_pro) of the auto saved board filename, if it is created
wxFileName autosaveProjFile;
if( GetScreen()->IsContentModified() || brdFile.GetFullPath().empty() )
if( m_frame->GetScreen()->IsContentModified() || brdFile.GetFullPath().empty() )
{
if( !doAutoSave() )
if( !m_frame->DoAutoSave() )
{
DisplayErrorMessage( this, _( "STEP export failed! "
"Please save the PCB and try again" ) );
return;
DisplayErrorMessage( m_frame, _( "STEP export failed! Please save the PCB and try again" ) );
return 0;
}
wxString autosaveFileName = FILEEXT::AutoSaveFilePrefix + brdFile.GetName();
// Create a dummy .kicad_pro file for this auto saved board file.
// this is useful to use some settings (like project path and name)
// Because doAutoSave() works, the target directory exists and is writable
// Because DoAutoSave() works, the target directory exists and is writable
autosaveProjFile = brdFile;
autosaveProjFile.SetName( autosaveFileName );
autosaveProjFile.SetExt( "kicad_pro" );
// Use auto-saved board for export
GetSettingsManager()->SaveProjectCopy( autosaveProjFile.GetFullPath(), GetBoard()->GetProject() );
m_frame->GetSettingsManager()->SaveProjectCopy( autosaveProjFile.GetFullPath(), board->GetProject() );
brdFile.SetName( autosaveFileName );
}
DIALOG_EXPORT_STEP dlg( this, brdFile.GetFullPath() );
DIALOG_EXPORT_STEP dlg( m_frame, brdFile.GetFullPath() );
dlg.ShowModal();
// If a dummy .kicad_pro file is created, delete it now it is useless.
if( !autosaveProjFile.GetFullPath().IsEmpty() )
wxRemoveFile( autosaveProjFile.GetFullPath() );
return 0;
}

View File

@ -34,6 +34,7 @@
#include <kiface_base.h>
#include <pcb_edit_frame.h>
#include <pcbnew_settings.h>
#include <tools/board_editor_control.h>
#include <project/project_file.h> // LAST_PATH_TYPE
#include <wx/msgdlg.h>
@ -145,17 +146,19 @@ double DIALOG_EXPORT_VRML::GetYRef()
}
void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
int BOARD_EDITOR_CONTROL::ExportVRML( const TOOL_EVENT& aEvent )
{
// These variables are static to keep info during the session.
static wxString subDirFor3Dshapes;
BOARD* board = m_frame->GetBoard();
// Build default output file name
wxString path = GetLastPath( LAST_PATH_VRML );
wxString path = m_frame->GetLastPath( LAST_PATH_VRML );
if( path.IsEmpty() )
{
wxFileName brdFile = GetBoard()->GetFileName();
wxFileName brdFile = board->GetFileName();
brdFile.SetExt( wxT( "wrl" ) );
path = brdFile.GetFullPath();
}
@ -168,12 +171,12 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
// this is the mm to VRML scaling factor for mm, 0.1 inch, and inch
double scaleList[4] = { 1.0, 0.001, 10.0/25.4, 1.0/25.4 };
DIALOG_EXPORT_VRML dlg( this );
DIALOG_EXPORT_VRML dlg( m_frame );
dlg.FilePicker()->SetPath( path );
dlg.SetSubdir( subDirFor3Dshapes );
if( dlg.ShowModal() != wxID_OK )
return;
return 0;
double aXRef = dlg.GetXRef();
double aYRef = dlg.GetYRef();
@ -188,8 +191,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
if( dlg.GetOriginChoice() == 1 )
{
// Origin = board center:
BOARD* pcb = GetBoard();
BOX2I bbox = pcb->ComputeBoundingBox( true );
BOX2I bbox = board->ComputeBoundingBox( true );
aXRef = pcbIUScale.IUTomm( bbox.GetCenter().x );
aYRef = pcbIUScale.IUTomm( bbox.GetCenter().y );
}
@ -201,7 +203,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
bool useRelativePaths = dlg.GetUseRelativePathsOption();
path = dlg.FilePicker()->GetPath();
SetLastPath( LAST_PATH_VRML, path );
m_frame->SetLastPath( LAST_PATH_VRML, path );
wxFileName modelPath = path;
wxBusyCursor dummy;
@ -213,18 +215,18 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
{
if( !modelPath.Mkdir() )
{
wxString msg = wxString::Format( _( "Failed to create folder '%s'." ),
modelPath.GetPath() );
DisplayErrorMessage( this, msg );
return;
DisplayErrorMessage( m_frame, wxString::Format( _( "Failed to create folder '%s'." ),
modelPath.GetPath() ) );
return 0;
}
}
if( !ExportVRML_File( path, scale, includeUnspecified, includeDNP, export3DFiles,
useRelativePaths, modelPath.GetPath(), aXRef, aYRef ) )
if( !m_frame->ExportVRML_File( path, scale, includeUnspecified, includeDNP, export3DFiles,
useRelativePaths, modelPath.GetPath(), aXRef, aYRef ) )
{
wxString msg = wxString::Format( _( "Failed to create file '%s'." ), path );
DisplayErrorMessage( this, msg );
return;
DisplayErrorMessage( m_frame, wxString::Format( _( "Failed to create file '%s'." ),
path ) );
}
return 0;
}

View File

@ -585,56 +585,46 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
}
void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
int BOARD_EDITOR_CONTROL::GenFootprintsReport( const TOOL_EVENT& aEvent )
{
BOARD* board = m_frame->GetBoard();
wxFileName fn;
wxString boardFilePath = ( (wxFileName) GetBoard()->GetFileName() ).GetPath();
wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath );
wxString boardFilePath = ( (wxFileName) board->GetFileName() ).GetPath();
wxDirDialog dirDialog( m_frame, _( "Select Output Directory" ), boardFilePath );
if( dirDialog.ShowModal() == wxID_CANCEL )
return;
return 0;
fn = GetBoard()->GetFileName();
fn = board->GetFileName();
fn.SetPath( dirDialog.GetPath() );
fn.SetExt( wxT( "rpt" ) );
bool unitMM = GetUserUnits() == EDA_UNITS::MM;
bool success = DoGenFootprintsReport( fn.GetFullPath(), unitMM );
wxString msg;
if( success )
{
msg.Printf( _( "Footprint report file created:\n'%s'." ), fn.GetFullPath() );
wxMessageBox( msg, _( "Footprint Report" ), wxICON_INFORMATION );
}
else
{
msg.Printf( _( "Failed to create file '%s'." ), fn.GetFullPath() );
DisplayError( this, msg );
}
}
bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM )
{
FILE* rptfile = wxFopen( aFullFilename, wxT( "wt" ) );
FILE* rptfile = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( rptfile == nullptr )
return false;
{
wxMessageBox( wxString::Format( _( "Footprint report file created:\n'%s'." ), fn.GetFullPath() ),
_( "Footprint Report" ), wxICON_INFORMATION );
return 0;
}
std::string data;
PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM,
false, false, // SMD aOnlySMD, aNoTHItems
false, // aExcludeDNP
true, true, // aTopSide, aBottomSide
false, true, false // aFormatCSV, aUseAuxOrigin, aNegateBottomX
);
PLACE_FILE_EXPORTER exporter( board, m_frame->GetUserUnits() == EDA_UNITS::MM,
false, false, // SMD aOnlySMD, aNoTHItems
false, // aExcludeDNP
true, true, // aTopSide, aBottomSide
false, true, false ); // aFormatCSV, aUseAuxOrigin, aNegateBottomX
data = exporter.GenReportData();
fputs( data.c_str(), rptfile );
fclose( rptfile );
return true;
wxMessageBox( wxString::Format( _( "Footprint report file created:\n'%s'." ), fn.GetFullPath() ),
_( "Footprint Report" ), wxICON_INFORMATION );
return 0;
}

View File

@ -46,6 +46,7 @@
#include <cctype>
#include <math/util.h> // for KiROUND
#include <export_d356.h>
#include <tools/board_editor_control.h>
#include <wx/filedlg.h>
#include <wx/msgdlg.h>
@ -380,35 +381,36 @@ bool IPC356D_WRITER::Write( const wxString& aFilename )
}
void PCB_EDIT_FRAME::GenD356File( wxCommandEvent& aEvent )
int BOARD_EDITOR_CONTROL::GenD356File( const TOOL_EVENT& aEvent )
{
wxFileName fn = GetBoard()->GetFileName();
wxFileName fn = m_frame->GetBoard()->GetFileName();
wxString ext, wildcard, msg;
ext = FILEEXT::IpcD356FileExtension;
wildcard = FILEEXT::IpcD356FileWildcard();
fn.SetExt( ext );
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
wxString pro_dir = wxPathOnly( m_frame->Prj().GetProjectFullName() );
wxFileDialog dlg( this, _( "Generate IPC-D-356 netlist file" ), pro_dir, fn.GetFullName(),
wxFileDialog dlg( m_frame, _( "Generate IPC-D-356 netlist file" ), pro_dir, fn.GetFullName(),
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return;
return 0;
IPC356D_WRITER writer( GetBoard() );
IPC356D_WRITER writer( m_frame->GetBoard() );
bool success = writer.Write( dlg.GetPath() );
if( success )
if( writer.Write( dlg.GetPath() ) )
{
msg.Printf( _( "IPC-D-356 netlist file created:\n'%s'." ), dlg.GetPath() );
wxMessageBox( msg, _( "IPC-D-356 Netlist File" ), wxICON_INFORMATION );
wxMessageBox( wxString::Format( _( "IPC-D-356 netlist file created:\n'%s'." ),
dlg.GetPath() ),
_( "IPC-D-356 Netlist File" ), wxICON_INFORMATION );
}
else
{
msg.Printf( _( "Failed to create file '%s'." ), dlg.GetPath() );
DisplayError( this, msg );
DisplayError( m_frame, wxString::Format( _( "Failed to create file '%s'." ),
dlg.GetPath() ) );
}
return 0;
}

View File

@ -29,6 +29,7 @@
#include <footprint.h>
#include <project.h>
#include <wildcards_and_files_ext.h>
#include <tools/board_editor_control.h>
#include <wx/filedlg.h>
@ -62,24 +63,27 @@ bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName )
}
void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
int BOARD_EDITOR_CONTROL::ExportCmpFile( const TOOL_EVENT& aEvent )
{
// Build the .cmp file name from the board name
wxString projectDir = wxPathOnly( Prj().GetProjectFullName() );
wxFileName fn = GetBoard()->GetFileName();
BOARD* board = m_frame->GetBoard();
wxString projectDir = wxPathOnly( m_frame->Prj().GetProjectFullName() );
wxFileName fn = board->GetFileName();
fn.SetExt( FILEEXT::FootprintAssignmentFileExtension );
wxFileDialog dlg( this, _( "Save Footprint Association File" ), projectDir, fn.GetFullName(),
wxFileDialog dlg( m_frame, _( "Save Footprint Association File" ), projectDir, fn.GetFullName(),
FILEEXT::FootprintAssignmentFileWildcard(),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return;
return 0;
wxString path = dlg.GetPath();
if( !RecreateCmpFile( GetBoard(), path ) )
DisplayError( this, wxString::Format( _( "Failed to create file '%s'." ), path ) );
if( !RecreateCmpFile( board, path ) )
DisplayError( m_frame, wxString::Format( _( "Failed to create file '%s'." ), path ) );
return 0;
}

View File

@ -33,31 +33,32 @@
#include <confirm.h>
#include <dialogs/dialog_gencad_export_options.h>
#include <pcb_edit_frame.h>
#include <tools/board_editor_control.h>
#include <project/project_file.h> // LAST_PATH_TYPE
#include <export_gencad_writer.h>
/* Driver function: processing starts here */
void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
int BOARD_EDITOR_CONTROL::ExportGenCAD( const TOOL_EVENT& aEvent )
{
// Build default output file name
wxString path = GetLastPath( LAST_PATH_GENCAD );
wxString path = m_frame->GetLastPath( LAST_PATH_GENCAD );
if( path.IsEmpty() )
{
wxFileName brdFile = GetBoard()->GetFileName();
wxFileName brdFile = m_frame->GetBoard()->GetFileName();
brdFile.SetExt( wxT( "cad" ) );
path = brdFile.GetFullPath();
}
DIALOG_GENCAD_EXPORT_OPTIONS optionsDialog( this, path );
DIALOG_GENCAD_EXPORT_OPTIONS optionsDialog( m_frame, path );
if( optionsDialog.ShowModal() == wxID_CANCEL )
return;
return 0;
path = optionsDialog.GetFileName();
SetLastPath( LAST_PATH_GENCAD, path );
m_frame->SetLastPath( LAST_PATH_GENCAD, path );
// Get options
bool flipBottomPads = optionsDialog.GetOption( FLIP_BOTTOM_PADS );
@ -66,13 +67,13 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
bool storeOriginCoords = optionsDialog.GetOption( STORE_ORIGIN_COORDS );
// No idea on *why* this should be needed... maybe to fix net names?
Compile_Ratsnest( true );
m_frame->Compile_Ratsnest( true );
GENCAD_EXPORTER exporter( GetBoard() );
GENCAD_EXPORTER exporter( m_frame->GetBoard() );
// This is the export origin (the auxiliary axis)
VECTOR2I GencadOffset;
VECTOR2I auxOrigin = m_pcb->GetDesignSettings().GetAuxOrigin();
VECTOR2I auxOrigin = m_frame->GetBoard()->GetDesignSettings().GetAuxOrigin();
GencadOffset.x = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.x : 0;
GencadOffset.y = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.y : 0;
@ -85,9 +86,8 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
bool success = exporter.WriteFile( path );
if( !success )
{
DisplayError( this, wxString::Format( _( "Failed to create file '%s'." ), path ) );
return;
}
DisplayError( m_frame, wxString::Format( _( "Failed to create file '%s'." ), path ) );
return 0;
}

View File

@ -38,8 +38,10 @@
#include <locale_io.h>
#include <reporter.h>
#include <richio.h>
#include <tools/board_editor_control.h>
#include <exporters/board_exporter_base.h>
#include <wx/log.h>
#include <wx/filedlg.h>
static double iu2hyp( double iu )
{
@ -661,10 +663,30 @@ bool HYPERLYNX_EXPORTER::Run()
}
bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath )
int BOARD_EDITOR_CONTROL::ExportHyperlynx( const TOOL_EVENT& aEvent )
{
wxString wildcard = wxT( "*.hyp" );
BOARD* board = m_frame->GetBoard();
wxFileName fn = board->GetFileName();
fn.SetExt( wxT("hyp") );
wxFileDialog dlg( m_frame, _( "Export Hyperlynx Layout" ), fn.GetPath(), fn.GetFullName(),
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() != wxID_OK )
return 0;
fn = dlg.GetPath();
// always enforce filename extension, user may not have entered it.
fn.SetExt( wxT( "hyp" ) );
HYPERLYNX_EXPORTER exporter;
exporter.SetBoard( aBoard );
exporter.SetOutputFilename( aPath );
return exporter.Run();
exporter.SetBoard( board );
exporter.SetOutputFilename( fn );
exporter.Run();
return 0;
}

View File

@ -67,6 +67,7 @@
#include <jobs/job_export_pcb_odb.h>
#include <dialogs/dialog_import_choose_project.h>
#include <tools/pcb_actions.h>
#include <tools/board_editor_control.h>
#include "footprint_info_impl.h"
#include <board_commit.h>
#include <zone_filler.h>
@ -266,36 +267,38 @@ void PCB_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
}
bool PCB_EDIT_FRAME::LoadBoard()
int BOARD_EDITOR_CONTROL::Open( const TOOL_EVENT& aEvent )
{
// Only standalone mode can directly load a new document
if( !Kiface().IsSingle() )
return false;
int open_ctl = KICTL_KICAD_ONLY;
wxString fileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
wxString fileName = m_frame->Prj().AbsolutePath( m_frame->GetBoard()->GetFileName() );
return AskLoadBoardFileName( this, &fileName, open_ctl )
&& OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
if( AskLoadBoardFileName( m_frame, &fileName, open_ctl ) )
m_frame->OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
return 0;
}
bool PCB_EDIT_FRAME::ImportNonKicadBoard()
int BOARD_EDITOR_CONTROL::OpenNonKicadBoard( const TOOL_EVENT& aEvent )
{
// Note: we explicitly allow this even if not in standalone mode for now, even though it is dangerous.
int open_ctl = KICTL_NONKICAD_ONLY;
wxString fileName; // = Prj().AbsolutePath( GetBoard()->GetFileName() );
return AskLoadBoardFileName( this, &fileName, open_ctl )
&& OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
if( AskLoadBoardFileName( m_frame, &fileName, open_ctl ) )
m_frame->OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
return 0;
}
bool PCB_EDIT_FRAME::RecoverAutosave()
int BOARD_EDITOR_CONTROL::RescueAutosave( const TOOL_EVENT& aEvent )
{
wxString msg;
wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() );
wxFileName currfn = m_frame->Prj().AbsolutePath( m_frame->GetBoard()->GetFileName() );
wxFileName fn = currfn;
wxString rec_name = FILEEXT::AutoSaveFilePrefix + fn.GetName();
@ -303,89 +306,85 @@ bool PCB_EDIT_FRAME::RecoverAutosave()
if( !fn.FileExists() )
{
msg.Printf( _( "Recovery file '%s' not found." ), fn.GetFullPath() );
DisplayInfoMessage( this, msg );
return false;
DisplayError( m_frame, wxString::Format( _( "Recovery file '%s' not found." ), fn.GetFullPath() ) );
return 0;
}
msg.Printf( _( "OK to load recovery file '%s'?" ), fn.GetFullPath() );
if( !IsOK( this, msg ) )
if( !IsOK( m_frame, wxString::Format( _( "OK to load recovery file '%s'?" ), fn.GetFullPath() ) ) )
return false;
GetScreen()->SetContentModified( false ); // do not prompt the user for changes
m_frame->GetScreen()->SetContentModified( false ); // do not prompt the user for changes
if( OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
if( m_frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
{
// Re-set the name since name or extension was changed
GetBoard()->SetFileName( currfn.GetFullPath() );
UpdateTitle();
return true;
m_frame->GetBoard()->SetFileName( currfn.GetFullPath() );
m_frame->UpdateTitle();
}
return false;
return 0;
}
bool PCB_EDIT_FRAME::RevertBoard()
int BOARD_EDITOR_CONTROL::Revert( const TOOL_EVENT& aEvent )
{
wxFileName fn = Prj().AbsolutePath( GetBoard()->GetFileName() );
wxFileName fn = m_frame->Prj().AbsolutePath( m_frame->GetBoard()->GetFileName() );
if( !IsOK( this, wxString::Format( _( "Revert '%s' to last version saved?" ), fn.GetFullPath() ) ) )
if( !IsOK( m_frame, wxString::Format( _( "Revert '%s' to last version saved?" ), fn.GetFullPath() ) ) )
return false;
GetScreen()->SetContentModified( false ); // do not prompt the user for changes
m_frame->GetScreen()->SetContentModified( false ); // do not prompt the user for changes
ReleaseFile();
m_frame->ReleaseFile();
return OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ), KICTL_REVERT );
m_frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ), KICTL_REVERT );
return 0;
}
bool PCB_EDIT_FRAME::NewBoard()
int BOARD_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
{
// Only standalone mode can directly load a new document
if( !Kiface().IsSingle() )
return false;
if( IsContentModified() )
if( m_frame->IsContentModified() )
{
wxFileName fileName = GetBoard()->GetFileName();
wxFileName fileName = m_frame->GetBoard()->GetFileName();
wxString saveMsg = _( "Current board will be closed, save changes to '%s' before "
"continuing?" );
if( !HandleUnsavedChanges( this, wxString::Format( saveMsg, fileName.GetFullName() ),
if( !HandleUnsavedChanges( m_frame, wxString::Format( saveMsg, fileName.GetFullName() ),
[&]()->bool
{
return SaveBoard();
return m_frame->SaveBoard();
} ) )
{
return false;
}
}
else if( !GetBoard()->IsEmpty() )
else if( !m_frame->GetBoard()->IsEmpty() )
{
if( !IsOK( this, _( "Current Board will be closed. Continue?" ) ) )
if( !IsOK( m_frame, _( "Current Board will be closed. Continue?" ) ) )
return false;
}
SaveProjectLocalSettings();
m_frame->SaveProjectLocalSettings();
GetBoard()->ClearProject();
m_frame->GetBoard()->ClearProject();
m_frame->GetSettingsManager()->UnloadProject( &m_frame->Prj() );
SETTINGS_MANAGER* mgr = GetSettingsManager();
mgr->UnloadProject( &mgr->Prj() );
if( !Clear_Pcb( false ) )
if( !m_frame->Clear_Pcb( false ) )
return false;
LoadProjectSettings();
LoadDrawingSheet();
m_frame->LoadProjectSettings();
m_frame->LoadDrawingSheet();
onBoardLoaded();
m_frame->OnBoardLoaded();
m_frame->OnModify();
OnModify();
return true;
return 0;
}
@ -947,7 +946,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
GetBoard()->GetLengthCalculation()->SynchronizeTimeDomainProperties();
// Syncs the UI (appearance panel, etc) with the loaded board and project
onBoardLoaded();
OnBoardLoaded();
// Refresh the 3D view, if any
EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
@ -1189,7 +1188,7 @@ bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName, bool aCreateProject
}
bool PCB_EDIT_FRAME::doAutoSave()
bool PCB_EDIT_FRAME::DoAutoSave()
{
wxFileName tmpFileName;
@ -1289,12 +1288,12 @@ bool PCB_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType,
}
void PCB_EDIT_FRAME::GenIPC2581File( wxCommandEvent& event )
int BOARD_EDITOR_CONTROL::GenIPC2581File( const TOOL_EVENT& aEvent )
{
DIALOG_EXPORT_2581 dlg( this );
DIALOG_EXPORT_2581 dlg( m_frame );
if( dlg.ShowModal() != wxID_OK )
return;
return 0;
wxFileName pcbFileName = dlg.GetOutputPath();
@ -1303,23 +1302,21 @@ void PCB_EDIT_FRAME::GenIPC2581File( wxCommandEvent& event )
if( pcbFileName.GetName().empty() )
{
DisplayError( this, _( "The board must be saved before generating IPC-2581 file." ) );
return;
DisplayError( m_frame, _( "The board must be saved before generating IPC-2581 file." ) );
return 0;
}
if( !IsWritable( pcbFileName ) )
if( !m_frame->IsWritable( pcbFileName ) )
{
wxString msg = wxString::Format( _( "Insufficient permissions to write file '%s'." ),
pcbFileName.GetFullPath() );
DisplayError( this, msg );
return;
DisplayError( m_frame, wxString::Format( _( "Insufficient permissions to write file '%s'." ),
pcbFileName.GetFullPath() ) );
return 0;
}
wxString tempFile = wxFileName::CreateTempFileName( wxS( "pcbnew_ipc" ) );
wxString upperTxt;
wxString lowerTxt;
WX_PROGRESS_REPORTER reporter( this, _( "Generating IPC-2581 file" ), 5 );
WX_PROGRESS_REPORTER reporter( m_frame, _( "Generating IPC-2581 file" ), 5 );
std::map<std::string, UTF8> props;
props["units"] = dlg.GetUnitsString();
@ -1338,19 +1335,18 @@ void PCB_EDIT_FRAME::GenIPC2581File( wxCommandEvent& event )
{
IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( PCB_IO_MGR::IPC2581 ) );
pi->SetProgressReporter( &reporter );
pi->SaveBoard( tempFile, GetBoard(), &props );
pi->SaveBoard( tempFile, m_frame->GetBoard(), &props );
return true;
}
catch( const IO_ERROR& ioe )
{
DisplayError( this,
wxString::Format( _( "Error generating IPC-2581 file '%s'.\n%s" ),
pcbFileName.GetFullPath(),
ioe.What() ) );
DisplayError( m_frame, wxString::Format( _( "Error generating IPC-2581 file '%s'.\n%s" ),
pcbFileName.GetFullPath(),
ioe.What() ) );
lowerTxt.Printf( _( "Failed to create temporary file '%s'." ), tempFile );
SetMsgPanel( upperTxt, lowerTxt );
m_frame->SetMsgPanel( upperTxt, lowerTxt );
// In case we started a file but didn't fully write it, clean up
wxRemoveFile( tempFile );
@ -1374,13 +1370,13 @@ void PCB_EDIT_FRAME::GenIPC2581File( wxCommandEvent& event )
try
{
if( !ret.get() )
return;
return 0;
}
catch( const std::exception& e )
{
wxLogError( "Exception in IPC-2581 generation: %s", e.what() );
GetScreen()->SetContentModified( false );
return;
m_frame->GetScreen()->SetContentModified( false );
return 0;
}
// Preserve the permissions of the current file
@ -1409,43 +1405,47 @@ void PCB_EDIT_FRAME::GenIPC2581File( wxCommandEvent& event )
// If save succeeded, replace the original with what we just wrote
if( !wxRenameFile( tempFile, pcbFileName.GetFullPath() ) )
{
DisplayError( this, wxString::Format( _( "Error generating IPC-2581 file '%s'.\n"
"Failed to rename temporary file '%s." ),
pcbFileName.GetFullPath(),
tempFile ) );
DisplayError( m_frame, wxString::Format( _( "Error generating IPC-2581 file '%s'.\n"
"Failed to rename temporary file '%s." ),
pcbFileName.GetFullPath(),
tempFile ) );
lowerTxt.Printf( _( "Failed to rename temporary file '%s'." ),
tempFile );
SetMsgPanel( upperTxt, lowerTxt );
m_frame->SetMsgPanel( upperTxt, lowerTxt );
}
GetScreen()->SetContentModified( false );
m_frame->GetScreen()->SetContentModified( false );
return 0;
}
void PCB_EDIT_FRAME::GenODBPPFiles( wxCommandEvent& event )
int BOARD_EDITOR_CONTROL::GenerateODBPPFiles( const TOOL_EVENT& aEvent )
{
DIALOG_EXPORT_ODBPP dlg( this );
DIALOG_EXPORT_ODBPP dlg( m_frame );
if( dlg.ShowModal() != wxID_OK )
return;
return 0;
JOB_EXPORT_PCB_ODB job;
job.SetConfiguredOutputPath( dlg.GetOutputPath() );
job.m_filename = GetBoard()->GetFileName();
job.m_filename = m_frame->GetBoard()->GetFileName();
job.m_compressionMode = static_cast<JOB_EXPORT_PCB_ODB::ODB_COMPRESSION>( dlg.GetCompressFormat() );
job.m_precision = dlg.GetPrecision();
job.m_units = dlg.GetUnitsString() == "mm" ? JOB_EXPORT_PCB_ODB::ODB_UNITS::MM
: JOB_EXPORT_PCB_ODB::ODB_UNITS::INCH;
WX_PROGRESS_REPORTER progressReporter( this, _( "Generating ODB++ output files" ), 3, false );
WX_PROGRESS_REPORTER progressReporter( m_frame, _( "Generating ODB++ output files" ), 3, false );
WX_STRING_REPORTER reporter;
DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( job, GetBoard(), this, &progressReporter, &reporter );
DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( job, m_frame->GetBoard(), m_frame, &progressReporter, &reporter );
if( reporter.HasMessage() )
DisplayError( this, reporter.GetMessages() );
DisplayError( m_frame, reporter.GetMessages() );
return 0;
}

View File

@ -122,20 +122,12 @@ void PCB_EDIT_FRAME::doReCreateMenuBar()
submenuExport->SetIcon( BITMAPS::export_file );
submenuExport->Add( PCB_ACTIONS::exportSpecctraDSN, ACTION_MENU::NORMAL, _( "Specctra DSN..." ) );
submenuExport->Add( _( "GenCAD..." ), _( "Export GenCAD board representation" ),
ID_GEN_EXPORT_FILE_GENCADFORMAT, BITMAPS::post_gencad );
submenuExport->Add( _( "VRML..." ), _( "Export VRML 3D board representation" ),
ID_GEN_EXPORT_FILE_VRML, BITMAPS::export3d );
submenuExport->Add( _( "IDFv3..." ), _( "Export IDF 3D board representation" ),
ID_GEN_EXPORT_FILE_IDF3, BITMAPS::export_idf );
submenuExport->Add( _( "STEP / GLB / BREP / XAO / PLY / STL..." ),
_( "Export STEP / GLB / BREP / XAO / PLY / STL 3D board representation" ),
ID_GEN_EXPORT_FILE_STEP, BITMAPS::export_step );
submenuExport->Add( _( "Footprint Association (.cmp) File..." ),
_( "Export footprint association file (*.cmp) for schematic back annotation" ),
ID_PCB_GEN_CMP_FILE, BITMAPS::export_cmp );
submenuExport->Add( _( "Hyperlynx..." ), wxEmptyString,
ID_GEN_EXPORT_FILE_HYPERLYNX, BITMAPS::export_step );
submenuExport->Add( PCB_ACTIONS::exportGenCAD, ACTION_MENU::NORMAL, _( "GenCAD..." ) );
submenuExport->Add( PCB_ACTIONS::exportVRML, ACTION_MENU::NORMAL, _( "VRML..." ) );
submenuExport->Add( PCB_ACTIONS::exportIDF, ACTION_MENU::NORMAL, _( "IDFv3..." ) );
submenuExport->Add( PCB_ACTIONS::exportSTEP, ACTION_MENU::NORMAL, _( "STEP/GLB/BREP/XAO/PLY/STL..." ) );
submenuExport->Add( PCB_ACTIONS::exportCmpFile, ACTION_MENU::NORMAL, _( "Footprint Association (.cmp) File..." ) );
submenuExport->Add( PCB_ACTIONS::exportHyperlynx, ACTION_MENU::NORMAL, _( "Hyperlynx..." ) );
if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist && m_exportNetlistAction )
submenuExport->Add( *m_exportNetlistAction );

View File

@ -139,7 +139,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, PCB_EDIT_FRAME::OnSockRequestServer )
EVT_SOCKET( ID_EDA_SOCKET_EVENT, PCB_EDIT_FRAME::OnSockRequest )
EVT_CHOICE( ID_ON_ZOOM_SELECT, PCB_EDIT_FRAME::OnSelectZoom )
EVT_CHOICE( ID_ON_GRID_SELECT, PCB_EDIT_FRAME::OnSelectGrid )
@ -149,18 +148,9 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PCB_EDIT_FRAME::OnFileHistory )
EVT_MENU( ID_FILE_LIST_CLEAR, PCB_EDIT_FRAME::OnClearFileHistory )
EVT_MENU( ID_GEN_EXPORT_FILE_GENCADFORMAT, PCB_EDIT_FRAME::ExportToGenCAD )
EVT_MENU( ID_GEN_EXPORT_FILE_VRML, PCB_EDIT_FRAME::OnExportVRML )
EVT_MENU( ID_GEN_EXPORT_FILE_IDF3, PCB_EDIT_FRAME::OnExportIDF3 )
EVT_MENU( ID_GEN_EXPORT_FILE_STEP, PCB_EDIT_FRAME::OnExportSTEP )
EVT_MENU( ID_GEN_EXPORT_FILE_HYPERLYNX, PCB_EDIT_FRAME::OnExportHyperlynx )
EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
// menu Postprocess
EVT_MENU( ID_PCB_GEN_CMP_FILE, PCB_EDIT_FRAME::RecreateCmpFileFromBoard )
// Horizontal toolbar
EVT_CHOICE( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
EVT_CHOICE( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
@ -1679,7 +1669,7 @@ void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer, bool aForceRedraw )
}
void PCB_EDIT_FRAME::onBoardLoaded()
void PCB_EDIT_FRAME::OnBoardLoaded()
{
ENUM_MAP<PCB_LAYER_ID>& layerEnum = ENUM_MAP<PCB_LAYER_ID>::Instance();
@ -2618,30 +2608,6 @@ bool PCB_EDIT_FRAME::CanAcceptApiCommands()
}
bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath );
void PCB_EDIT_FRAME::OnExportHyperlynx( wxCommandEvent& event )
{
wxString wildcard = wxT( "*.hyp" );
wxFileName fn = GetBoard()->GetFileName();
fn.SetExt( wxT("hyp") );
wxFileDialog dlg( this, _( "Export Hyperlynx Layout" ), fn.GetPath(), fn.GetFullName(),
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() != wxID_OK )
return;
fn = dlg.GetPath();
// always enforce filename extension, user may not have entered it.
fn.SetExt( wxT( "hyp" ) );
ExportBoardToHyperlynx( GetBoard(), fn );
}
wxString PCB_EDIT_FRAME::GetCurrentFileName() const
{

View File

@ -337,40 +337,9 @@ public:
bool aNoTHItems, bool aExcludeDNP, bool aTopSide, bool aBottomSide,
bool aFormatCSV, bool aUseAuxOrigin, bool aNegateBottomX );
/**
* Call #DoGenFootprintsReport to create a footprint report file
*/
void GenFootprintsReport( wxCommandEvent& event );
/**
* Create and IPC2581 output file
*/
void GenIPC2581File( wxCommandEvent& event );
/**
* Create and Generate ODB++ output files
*/
void GenODBPPFiles( wxCommandEvent& event );
/**
* Create an ASCII footprint report file giving some infos on footprints and board outlines.
*
* @param aFullFilename the full file name of the file to create
* @param aUnitsMM false to use inches, true to use mm in coordinates
* @return true if OK, false if error
*/
bool DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM );
void GenD356File( wxCommandEvent& event );
void OnFileHistory( wxCommandEvent& event );
void OnClearFileHistory( wxCommandEvent& aEvent );
bool LoadBoard();
bool ImportNonKicadBoard();
bool RecoverAutosave();
bool RevertBoard();
bool NewBoard();
bool SaveBoard( bool aSaveAs = false, bool aSaveCopy = false );
/**
@ -441,13 +410,6 @@ public:
///< @copydoc PCB_BASE_FRAME::SetPageSettings()
void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
/**
* Recreates a .cmp file from the current loaded board.
*
* This is the same as created by CvPcb and can be used if this file is lost.
*/
void RecreateCmpFileFromBoard( wxCommandEvent& aEvent );
bool SaveBoardAsDesignBlock( const wxString& aLibraryName );
bool SaveSelectionAsDesignBlock( const wxString& aLibraryName );
@ -472,21 +434,6 @@ public:
void ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName = wxEmptyString,
wxString* aLibPath = nullptr );
/**
* Create a BOM file from the current loaded board.
*/
void RecreateBOMFileFromBoard( wxCommandEvent& aEvent );
/**
* Create a file in GenCAD 1.4 format from the current board.
*/
void ExportToGenCAD( wxCommandEvent& event );
/**
* Export the current BOARD to a VRML file.
*/
void OnExportVRML( wxCommandEvent& event );
/**
* Create the file(s) exporting current BOARD to a VRML file.
*
@ -516,15 +463,10 @@ public:
bool aExport3DFiles, bool aUseRelativePaths,
const wxString& a3D_Subdir, double aXRef, double aYRef );
/**
* Export the current BOARD to a IDFv3 board and lib files.
*/
void OnExportIDF3( wxCommandEvent& event );
/**
* Export the current BOARD to a Hyperlynx HYP file.
*/
void OnExportHyperlynx( wxCommandEvent& event );
void OnExportHyperlynx();
/**
* Create an IDF3 compliant BOARD (*.emn) and LIBRARY (*.emp) file.
@ -545,7 +487,7 @@ public:
/**
* Export the current BOARD to a STEP assembly.
*/
void OnExportSTEP( wxCommandEvent& event );
void OnExportSTEP();
/**
* Export the current BOARD to a specctra dsn file.
@ -690,6 +632,11 @@ public:
void ShowChangedLanguage() override;
/**
* Update the state of the GUI after a new board is loaded or created.
*/
void OnBoardLoaded();
/**
* Set the main window title bar text.
*
@ -728,6 +675,14 @@ public:
DIALOG_BOOK_REPORTER* GetFootprintDiffDialog();
/**
* Perform auto save when the board has been modified and not saved within the
* auto save interval.
*
* @return true if the auto save was successful.
*/
bool DoAutoSave();
DECLARE_EVENT_TABLE()
protected:
@ -800,18 +755,13 @@ protected:
PLUGIN_ACTION_SCOPE PluginActionScope() const override { return PLUGIN_ACTION_SCOPE::PCB; }
/**
* Update the state of the GUI after a new board is loaded or created.
*/
void onBoardLoaded();
/**
* Perform auto save when the board has been modified and not saved within the
* auto save interval.
*
* @return true if the auto save was successful.
*/
bool doAutoSave() override;
bool doAutoSave() override { return DoAutoSave(); }
/**
* Load the given filename but sets the path to the current project path.

View File

@ -13,13 +13,8 @@
enum pcbnew_ids
{
ID_MAIN_MENUBAR = ID_END_LIST,
ID_COPY_BOARD_AS,
ID_REVERT_BOARD,
ID_IMPORT_NON_KICAD_BOARD,
// Tracks and vias sizes general options
ID_AUX_TOOLBAR_PCB_VIA_SIZE,
ID_AUX_TOOLBAR_PCB_VIA_SIZE = ID_END_LIST,
ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
ID_POPUP_PCB_SELECT_WIDTH_START_RANGE,
ID_POPUP_PCB_SELECT_CUSTOM_WIDTH,
@ -77,17 +72,8 @@ enum pcbnew_ids
ID_POPUP_PCB_SELECT_DIFFPAIR16,
ID_POPUP_PCB_SELECT_WIDTH_END_RANGE,
ID_GEN_EXPORT_FILE_IDF3,
ID_GEN_EXPORT_FILE_VRML,
ID_GEN_EXPORT_FILE_STEP,
ID_GEN_EXPORT_FILE_HYPERLYNX,
ID_GEN_EXPORT_FILE_GENCADFORMAT,
ID_TOOLBARH_PCB_ACTION_PLUGIN,
ID_PCB_GEN_CMP_FILE,
ID_PCB_GEN_BOM_FILE_FROM_BOARD,
ID_FPEDIT_SAVE_PNG,
ID_MODVIEW_LIB_FILTER,

View File

@ -254,20 +254,6 @@ bool BOARD_EDITOR_CONTROL::Init()
}
int BOARD_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
{
m_frame->NewBoard();
return 0;
}
int BOARD_EDITOR_CONTROL::Open( const TOOL_EVENT& aEvent )
{
m_frame->LoadBoard();
return 0;
}
int BOARD_EDITOR_CONTROL::Save( const TOOL_EVENT& aEvent )
{
m_frame->SaveBoard();
@ -289,27 +275,6 @@ int BOARD_EDITOR_CONTROL::SaveCopy( const TOOL_EVENT& aEvent )
}
int BOARD_EDITOR_CONTROL::Revert( const TOOL_EVENT& aEvent )
{
m_frame->RevertBoard();
return 0;
}
int BOARD_EDITOR_CONTROL::RescueAutosave( const TOOL_EVENT& aEvent )
{
m_frame->RecoverAutosave();
return 0;
}
int BOARD_EDITOR_CONTROL::OpenNonKicadBoard( const TOOL_EVENT& aEvent )
{
m_frame->ImportNonKicadBoard();
return 0;
}
int BOARD_EDITOR_CONTROL::ExportFootprints( const TOOL_EVENT& aEvent )
{
m_frame->ExportFootprintsToLibrary( false );
@ -546,27 +511,6 @@ int BOARD_EDITOR_CONTROL::GenerateGerbers( const TOOL_EVENT& aEvent )
}
int BOARD_EDITOR_CONTROL::GenerateFabFiles( const TOOL_EVENT& aEvent )
{
wxCommandEvent dummy;
if( aEvent.IsAction( &PCB_ACTIONS::generateReportFile ) )
m_frame->GenFootprintsReport( dummy );
else if( aEvent.IsAction( &PCB_ACTIONS::generateD356File ) )
m_frame->GenD356File( dummy );
else if( aEvent.IsAction( &PCB_ACTIONS::generateBOM ) )
m_frame->RecreateBOMFileFromBoard( dummy );
else if( aEvent.IsAction( &PCB_ACTIONS::generateIPC2581File ) )
m_frame->GenIPC2581File( dummy );
else if( aEvent.IsAction( &PCB_ACTIONS::generateODBPPFile ) )
m_frame->GenODBPPFiles( dummy );
else
wxFAIL_MSG( wxT( "GenerateFabFiles(): unexpected request" ) );
return 0;
}
int BOARD_EDITOR_CONTROL::RepairBoard( const TOOL_EVENT& aEvent )
{
int errors = 0;
@ -1862,11 +1806,18 @@ void BOARD_EDITOR_CONTROL::setTransitions()
Go( &BOARD_EDITOR_CONTROL::GenerateDrillFiles, PCB_ACTIONS::generateDrillFiles.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GenerateGerbers, PCB_ACTIONS::generateGerbers.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GeneratePosFile, PCB_ACTIONS::generatePosFile.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateReportFile.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateD356File.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateBOM.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateIPC2581File.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateODBPPFile.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GenFootprintsReport, PCB_ACTIONS::generateReportFile.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GenD356File, PCB_ACTIONS::generateD356File.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GenBOMFileFromBoard, PCB_ACTIONS::generateBOM.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GenIPC2581File, PCB_ACTIONS::generateIPC2581File.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::GenerateODBPPFiles, PCB_ACTIONS::generateODBPPFile.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ExportGenCAD, PCB_ACTIONS::exportGenCAD.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ExportVRML, PCB_ACTIONS::exportVRML.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ExportIDF, PCB_ACTIONS::exportIDF.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ExportSTEP, PCB_ACTIONS::exportSTEP.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ExportCmpFile, PCB_ACTIONS::exportCmpFile.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ExportHyperlynx, PCB_ACTIONS::exportHyperlynx.MakeEvent() );
// Track & via size control
Go( &BOARD_EDITOR_CONTROL::TrackWidthInc, PCB_ACTIONS::trackWidthInc.MakeEvent() );
@ -1914,5 +1865,3 @@ void BOARD_EDITOR_CONTROL::setTransitions()
Go( &BOARD_EDITOR_CONTROL::RepairBoard, PCB_ACTIONS::repairBoard.MakeEvent() );
}
const int BOARD_EDITOR_CONTROL::WIDTH_STEP = 100000;

View File

@ -76,7 +76,17 @@ public:
int GenerateDrillFiles( const TOOL_EVENT& aEvent );
int GeneratePosFile( const TOOL_EVENT& aEvent );
int GenerateGerbers( const TOOL_EVENT& aEvent );
int GenerateFabFiles( const TOOL_EVENT& aEvent );
int ExportGenCAD( const TOOL_EVENT& aEvent );
int ExportVRML( const TOOL_EVENT& aEvent );
int ExportIDF( const TOOL_EVENT& aEvent );
int ExportSTEP( const TOOL_EVENT& aEvent );
int ExportCmpFile( const TOOL_EVENT& aEvent );
int ExportHyperlynx( const TOOL_EVENT& aEvent );
int GenBOMFileFromBoard( const TOOL_EVENT& aEvent );
int GenFootprintsReport( const TOOL_EVENT& aEvent );
int GenD356File( const TOOL_EVENT& aEvent );
int GenIPC2581File( const TOOL_EVENT& aEvent );
int GenerateODBPPFiles( const TOOL_EVENT& aEvent );
int RepairBoard( const TOOL_EVENT& aEvent );
int UpdatePCBFromSchematic( const TOOL_EVENT& aEvent );

View File

@ -1251,6 +1251,48 @@ TOOL_ACTION PCB_ACTIONS::generateBOM( TOOL_ACTION_ARGS()
.Tooltip( _( "Create bill of materials from board" ) )
.Icon( BITMAPS::post_bom ) );
TOOL_ACTION PCB_ACTIONS::exportGenCAD( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.exportGenCAD" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Export GenCAD..." ) )
.Tooltip( _( "Export GenCAD board representation" ) )
.Icon( BITMAPS::post_gencad ) );
TOOL_ACTION PCB_ACTIONS::exportVRML( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.exportVRML" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Export VRML..." ) )
.Tooltip( _( "Export VRML 3D board representation" ) )
.Icon( BITMAPS::export3d ) );
TOOL_ACTION PCB_ACTIONS::exportIDF( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.exportIDF" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Export IDFv3..." ) )
.Tooltip( _( "Export IDF 3D board representation" ) )
.Icon( BITMAPS::export_idf ) );
TOOL_ACTION PCB_ACTIONS::exportSTEP( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.exportSTEP" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Export STEP/GLB/BREP/XAO/PLY/STL..." ) )
.Tooltip( _( "Export STEP, GLB, BREP, XAO, PLY or STL 3D board representation" ) )
.Icon( BITMAPS::export_step ) );
TOOL_ACTION PCB_ACTIONS::exportCmpFile( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.exportFootprintAssociations" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Export Footprint Association (.cmp) File..." ) )
.Tooltip( _( "Export footprint association file (*.cmp) for schematic back annotation" ) )
.Icon( BITMAPS::export_cmp ) );
TOOL_ACTION PCB_ACTIONS::exportHyperlynx( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.exportHyperlynx" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Hyperlynx..." ) )
.Icon( BITMAPS::export_step ) );
// Track & via size control
TOOL_ACTION PCB_ACTIONS::trackWidthInc( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.trackWidthInc" )

View File

@ -423,6 +423,13 @@ public:
static TOOL_ACTION generateD356File;
static TOOL_ACTION generateBOM;
static TOOL_ACTION exportGenCAD;
static TOOL_ACTION exportVRML;
static TOOL_ACTION exportIDF;
static TOOL_ACTION exportSTEP;
static TOOL_ACTION exportCmpFile;
static TOOL_ACTION exportHyperlynx;
// Global edit tool
static TOOL_ACTION editTracksAndVias;
static TOOL_ACTION editTextAndGraphics;