diff --git a/gerbview/gerbview_id.h b/gerbview/gerbview_id.h index 7748349047..02ccec81e5 100644 --- a/gerbview/gerbview_id.h +++ b/gerbview/gerbview_id.h @@ -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, diff --git a/pagelayout_editor/pl_editor_id.h b/pagelayout_editor/pl_editor_id.h index efbefeb196..6d15cda5aa 100644 --- a/pagelayout_editor/pl_editor_id.h +++ b/pagelayout_editor/pl_editor_id.h @@ -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, diff --git a/pcbnew/build_BOM_from_board.cpp b/pcbnew/build_BOM_from_board.cpp index a85752c6e7..5d63e8119c 100644 --- a/pcbnew/build_BOM_from_board.cpp +++ b/pcbnew/build_BOM_from_board.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -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; } diff --git a/pcbnew/dialogs/dialog_export_idf.cpp b/pcbnew/dialogs/dialog_export_idf.cpp index 700f5acd3e..87fb997b93 100644 --- a/pcbnew/dialogs/dialog_export_idf.cpp +++ b/pcbnew/dialogs/dialog_export_idf.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include // LAST_PATH_TYPE #include @@ -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; } diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index 39ff3098a2..49dcefdadc 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/pcbnew/dialogs/dialog_export_step.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include // LAST_PATH_TYPE #include #include @@ -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; } diff --git a/pcbnew/dialogs/dialog_export_vrml.cpp b/pcbnew/dialogs/dialog_export_vrml.cpp index a65ea29eca..006df19cdd 100644 --- a/pcbnew/dialogs/dialog_export_vrml.cpp +++ b/pcbnew/dialogs/dialog_export_vrml.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include // LAST_PATH_TYPE #include @@ -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; } diff --git a/pcbnew/dialogs/dialog_gen_footprint_position.cpp b/pcbnew/dialogs/dialog_gen_footprint_position.cpp index 8e517af981..e9069b9454 100644 --- a/pcbnew/dialogs/dialog_gen_footprint_position.cpp +++ b/pcbnew/dialogs/dialog_gen_footprint_position.cpp @@ -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; } + + diff --git a/pcbnew/exporters/export_d356.cpp b/pcbnew/exporters/export_d356.cpp index 06328d4134..cfe9037dd9 100644 --- a/pcbnew/exporters/export_d356.cpp +++ b/pcbnew/exporters/export_d356.cpp @@ -46,6 +46,7 @@ #include #include // for KiROUND #include +#include #include #include @@ -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; } diff --git a/pcbnew/exporters/export_footprint_associations.cpp b/pcbnew/exporters/export_footprint_associations.cpp index 37470f20a0..6389d435e2 100644 --- a/pcbnew/exporters/export_footprint_associations.cpp +++ b/pcbnew/exporters/export_footprint_associations.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -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; } diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index 9fd4301779..a1473c2394 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -33,31 +33,32 @@ #include #include #include +#include #include // LAST_PATH_TYPE #include /* 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; } diff --git a/pcbnew/exporters/export_hyperlynx.cpp b/pcbnew/exporters/export_hyperlynx.cpp index de295c79fe..f9b19e487c 100644 --- a/pcbnew/exporters/export_hyperlynx.cpp +++ b/pcbnew/exporters/export_hyperlynx.cpp @@ -38,8 +38,10 @@ #include #include #include +#include #include #include +#include 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; } + diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index d77334c55f..8e824a228d 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include "footprint_info_impl.h" #include #include @@ -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( 1, fileName ), open_ctl ); + if( AskLoadBoardFileName( m_frame, &fileName, open_ctl ) ) + m_frame->OpenProjectFiles( std::vector( 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( 1, fileName ), open_ctl ); + if( AskLoadBoardFileName( m_frame, &fileName, open_ctl ) ) + m_frame->OpenProjectFiles( std::vector( 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( 1, fn.GetFullPath() ) ) ) + if( m_frame->OpenProjectFiles( std::vector( 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( 1, fn.GetFullPath() ), KICTL_REVERT ); + m_frame->OpenProjectFiles( std::vector( 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& 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 props; props["units"] = dlg.GetUnitsString(); @@ -1338,19 +1335,18 @@ void PCB_EDIT_FRAME::GenIPC2581File( wxCommandEvent& event ) { IO_RELEASER 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( 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; } diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index c1a067aa5a..1461903979 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -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 ); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 4f91e39bdb..09c371efd3 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -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& layerEnum = ENUM_MAP::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 { diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 1d9d9cd8ff..704da1b08d 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -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. diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index c55a5f7642..6171b0802b 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -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, diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index 7183d46ef7..f045b5a6dc 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -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; diff --git a/pcbnew/tools/board_editor_control.h b/pcbnew/tools/board_editor_control.h index 00dbcf0753..3c0e09aae6 100644 --- a/pcbnew/tools/board_editor_control.h +++ b/pcbnew/tools/board_editor_control.h @@ -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 ); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 86636b8a37..f03e34e885 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -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" ) diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index cc8ccb7828..6c31a0361f 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -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;