From 4bb54b3439faa3d9ca7bb7c4e9a3a9e70f463227 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 23 May 2025 13:37:59 +0100 Subject: [PATCH] Move more stuff to ACTIONs framework. --- include/id.h | 6 +- kicad/kicad_id.h | 61 +----- kicad/kicad_manager_frame.cpp | 2 + kicad/project_tree_pane.cpp | 33 +++ pcbnew/CMakeLists.txt | 1 - pcbnew/api/api_handler_pcb.cpp | 4 +- pcbnew/edit.cpp | 173 --------------- pcbnew/files.cpp | 305 ++++++++++++-------------- pcbnew/menubar_pcb_editor.cpp | 20 +- pcbnew/pcb_edit_frame.cpp | 210 +++++++++--------- pcbnew/pcb_edit_frame.h | 29 +-- pcbnew/pcbnew_id.h | 4 - pcbnew/toolbars_pcb_editor.cpp | 4 +- pcbnew/tools/board_editor_control.cpp | 132 ++++++++++- pcbnew/tools/board_editor_control.h | 4 + pcbnew/tools/pcb_actions.cpp | 44 +++- pcbnew/tools/pcb_actions.h | 34 +-- 17 files changed, 492 insertions(+), 574 deletions(-) delete mode 100644 pcbnew/edit.cpp diff --git a/include/id.h b/include/id.h index cd999d0a1e..29fbd45029 100644 --- a/include/id.h +++ b/include/id.h @@ -69,11 +69,7 @@ enum main_id { - ID_LOAD_FILE = wxID_HIGHEST, - ID_NEW_BOARD, - ID_SAVE_BOARD, - ID_SAVE_BOARD_AS, - ID_AUTO_SAVE_TIMER, + ID_AUTO_SAVE_TIMER = wxID_HIGHEST, // ID for menuitems used in our file history management, // when we do not use wxFILE_ID (restricted to 9 items) diff --git a/kicad/kicad_id.h b/kicad/kicad_id.h index f7c388d1c7..eec46362e1 100644 --- a/kicad/kicad_id.h +++ b/kicad/kicad_id.h @@ -21,11 +21,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file kicad/kicad_id.h - * @brief IDs used in KiCad main frame foe menuitems and tools. - */ - #ifndef KICAD_ID_H #define KICAD_ID_H @@ -33,70 +28,18 @@ #include /** - * Command IDs for KiCad. - * - * Please add IDs that are unique to Kicad here and not in the global id.h file. - * This will prevent the entire project from being rebuilt when adding - * new commands to KiCad. - * - * However, now the Kicad manager and other sub applications are running inside - * the same application, these IDs are kept unique inside the whole Kicad code - * See the global id.h which reserves room for the Kicad manager IDs - * and expand this room if needed - * - * We have experienced issues with duplicate menus IDs between frames - * because wxUpdateUIEvent events are sent to parent frames, when a wxUpdateUIEvent - * event function does not exists for some menuitems ID, and therefore - * with duplicate menuitems IDs in different frames, the wrong menuitem can be used - * by a function called by the wxUpdateUIEvent event loop. - * - * The number of items in this list should be less than ROOM_FOR_KICADMANAGER (see id.h) + * Legacy IDs for things that have not yet been moved to ACTIONs. */ enum id_kicad_frm { ID_LEFT_FRAME = ID_KICAD_MANAGER_START, ID_PROJECT_TREE, - ID_PROJECT_TXTEDIT, - ID_PROJECT_SWITCH_TO_OTHER, - ID_PROJECT_NEWDIR, - ID_PROJECT_OPEN_DIR, - ID_PROJECT_DELETE, - ID_PROJECT_RENAME, - ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR, - ID_INIT_WATCHED_PATHS, ID_IMPORT_CADSTAR_ARCHIVE_PROJECT, ID_IMPORT_EAGLE_PROJECT, ID_IMPORT_EASYEDA_PROJECT, ID_IMPORT_EASYEDAPRO_PROJECT, - ID_IMPORT_ALTIUM_PROJECT, - - ID_GIT_INITIALIZE_PROJECT, // Initialize a new git repository in an existing project - ID_GIT_CLONE_PROJECT, // Clone a project from a remote repository - ID_GIT_COMMIT_PROJECT, // Commit all files in the project - ID_GIT_COMMIT_FILE, // Commit a single file - ID_GIT_SYNC_PROJECT, // Sync the project with the remote repository (pull and push -- same as Update) - ID_GIT_FETCH, // Fetch the remote repository (without merging -- this is the same as Refresh) - ID_GIT_PUSH, // Push the local repository to the remote repository - ID_GIT_PULL, // Pull the remote repository to the local repository - ID_GIT_RESOLVE_CONFLICT, // Present the user with a resolve conflicts dialog (ours/theirs/merge) - ID_GIT_REVERT_LOCAL, // Revert the local repository to the last commit - ID_GIT_COMPARE, // Compare the current project to a different branch or commit in the git repository - ID_GIT_REMOVE_VCS, // Remove the git repository data from the project directory (rm .git) - ID_GIT_ADD_TO_INDEX, // Add a file to the git index - ID_GIT_REMOVE_FROM_INDEX, // Remove a file from the git index - ID_GIT_SWITCH_BRANCH, // Switch the local repository to a different branch - ID_GIT_SWITCH_QUICK1, // Switch the local repository to the first quick branch - ID_GIT_SWITCH_QUICK2, // Switch the local repository to the second quick branch - ID_GIT_SWITCH_QUICK3, // Switch the local repository to the third quick branch - ID_GIT_SWITCH_QUICK4, // Switch the local repository to the fourth quick branch - ID_GIT_SWITCH_QUICK5, // Switch the local repository to the fifth quick branch - - ID_JOBS_RUN, - - // Please, verify: the number of items in this list should be - // less than ROOM_FOR_KICADMANAGER (see id.h) - ID_KICADMANAGER_END_LIST + ID_IMPORT_ALTIUM_PROJECT }; #endif diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index e39ea3bba6..2b00161e33 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -89,6 +89,8 @@ #define EDITORS_CAPTION _( "Editors" ) #define PROJECT_FILES_CAPTION _( "Project Files" ) +#define ID_INIT_WATCHED_PATHS 52913 + #define SEP() wxFileName::GetPathSeparator() diff --git a/kicad/project_tree_pane.cpp b/kicad/project_tree_pane.cpp index 70d26b801c..ab1d23ed70 100644 --- a/kicad/project_tree_pane.cpp +++ b/kicad/project_tree_pane.cpp @@ -149,6 +149,39 @@ static const wxChar* s_allowedExtensionsToList[] = { */ +enum project_tree_ids { + ID_PROJECT_TXTEDIT, + ID_PROJECT_SWITCH_TO_OTHER, + ID_PROJECT_NEWDIR, + ID_PROJECT_OPEN_DIR, + ID_PROJECT_DELETE, + ID_PROJECT_RENAME, + + ID_GIT_INITIALIZE_PROJECT, // Initialize a new git repository in an existing project + ID_GIT_CLONE_PROJECT, // Clone a project from a remote repository + ID_GIT_COMMIT_PROJECT, // Commit all files in the project + ID_GIT_COMMIT_FILE, // Commit a single file + ID_GIT_SYNC_PROJECT, // Sync the project with the remote repository (pull and push -- same as Update) + ID_GIT_FETCH, // Fetch the remote repository (without merging -- this is the same as Refresh) + ID_GIT_PUSH, // Push the local repository to the remote repository + ID_GIT_PULL, // Pull the remote repository to the local repository + ID_GIT_RESOLVE_CONFLICT, // Present the user with a resolve conflicts dialog (ours/theirs/merge) + ID_GIT_REVERT_LOCAL, // Revert the local repository to the last commit + ID_GIT_COMPARE, // Compare the current project to a different branch or commit in the git repository + ID_GIT_REMOVE_VCS, // Remove the git repository data from the project directory (rm .git) + ID_GIT_ADD_TO_INDEX, // Add a file to the git index + ID_GIT_REMOVE_FROM_INDEX, // Remove a file from the git index + ID_GIT_SWITCH_BRANCH, // Switch the local repository to a different branch + ID_GIT_SWITCH_QUICK1, // Switch the local repository to the first quick branch + ID_GIT_SWITCH_QUICK2, // Switch the local repository to the second quick branch + ID_GIT_SWITCH_QUICK3, // Switch the local repository to the third quick branch + ID_GIT_SWITCH_QUICK4, // Switch the local repository to the fourth quick branch + ID_GIT_SWITCH_QUICK5, // Switch the local repository to the fifth quick branch + + ID_JOBS_RUN, +}; + + BEGIN_EVENT_TABLE( PROJECT_TREE_PANE, wxSashLayoutWindow ) EVT_TREE_ITEM_ACTIVATED( ID_PROJECT_TREE, PROJECT_TREE_PANE::onSelect ) EVT_TREE_ITEM_EXPANDED( ID_PROJECT_TREE, PROJECT_TREE_PANE::onExpand ) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index a1d67a5efb..06fdc056b8 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -333,7 +333,6 @@ set( PCBNEW_CLASS_SRCS cleanup_item.cpp convert_shape_list_to_polygon.cpp cross-probing.cpp - edit.cpp edit_track_width.cpp files.cpp footprint_info_impl.cpp diff --git a/pcbnew/api/api_handler_pcb.cpp b/pcbnew/api/api_handler_pcb.cpp index 9d35c56b96..bd6c0fbf0d 100644 --- a/pcbnew/api/api_handler_pcb.cpp +++ b/pcbnew/api/api_handler_pcb.cpp @@ -169,7 +169,7 @@ HANDLER_RESULT API_HANDLER_PCB::handleSaveDocument( if( !documentValidation ) return tl::unexpected( documentValidation.error() ); - frame()->Files_io_from_id( ID_SAVE_BOARD ); + frame()->SaveBoard(); return Empty(); } @@ -219,7 +219,7 @@ HANDLER_RESULT API_HANDLER_PCB::handleSaveCopyOfDocument( if( board->GetFileName().Matches( boardPath.GetFullPath() ) ) { - frame()->Files_io_from_id( ID_SAVE_BOARD ); + frame()->SaveBoard(); return Empty(); } diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp deleted file mode 100644 index 16c5a596ec..0000000000 --- a/pcbnew/edit.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2015 Wayne Stambaugh - * Copyright The KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Handles the selection of command events. -void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) -{ - switch( event.GetId() ) // Execute command - { - case ID_MENU_EXPORT_FOOTPRINTS_TO_LIBRARY: - ExportFootprintsToLibrary( false ); - break; - - case ID_MENU_EXPORT_FOOTPRINTS_TO_NEW_LIBRARY: - ExportFootprintsToLibrary( true ); - break; - - default: - break; - } -} - - -void PCB_EDIT_FRAME::SwitchLayer( PCB_LAYER_ID layer ) -{ - PCB_LAYER_ID curLayer = GetActiveLayer(); - const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions(); - - // Check if the specified layer matches the present layer - if( layer == curLayer ) - return; - - // Copper layers cannot be selected unconditionally; how many of those layers are currently - // enabled needs to be checked. - if( IsCopperLayer( layer ) ) - { - if( layer > GetBoard()->GetCopperLayerStackMaxId() ) - return; - } - - // Is yet more checking required? E.g. when the layer to be selected is a non-copper layer, - // or when switching between a copper layer and a non-copper layer, or vice-versa? - - SetActiveLayer( layer ); - - if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL ) - GetCanvas()->Refresh(); -} - - -void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) -{ - switch( aItem->Type() ) - { - case PCB_REFERENCE_IMAGE_T: - ShowReferenceImagePropertiesDialog( aItem ); - break; - - case PCB_FIELD_T: - case PCB_TEXT_T: - ShowTextPropertiesDialog( static_cast( aItem ) ); - break; - - case PCB_TEXTBOX_T: - ShowTextBoxPropertiesDialog( static_cast( aItem ) ); - break; - - case PCB_TABLE_T: - { - DIALOG_TABLE_PROPERTIES dlg( this, static_cast( aItem ) ); - - //QuasiModal required for Scintilla auto-complete - dlg.ShowQuasiModal(); - break; - } - - case PCB_PAD_T: - ShowPadPropertiesDialog( static_cast( aItem ) ); - break; - - case PCB_FOOTPRINT_T: - ShowFootprintPropertiesDialog( static_cast( aItem ) ); - break; - - case PCB_TARGET_T: - ShowTargetOptionsDialog( static_cast( aItem ) ); - break; - - case PCB_DIM_ALIGNED_T: - case PCB_DIM_CENTER_T: - case PCB_DIM_RADIAL_T: - case PCB_DIM_ORTHOGONAL_T: - case PCB_DIM_LEADER_T: - { - DIALOG_DIMENSION_PROPERTIES dlg( this, static_cast( aItem ) ); - - // TODO: why is this QuasiModal? - dlg.ShowQuasiModal(); - break; - } - - case PCB_SHAPE_T: - ShowGraphicItemPropertiesDialog( static_cast( aItem ) ); - break; - - case PCB_ZONE_T: - Edit_Zone_Params( static_cast( aItem ) ); - break; - - case PCB_GROUP_T: - m_toolManager->RunAction( ACTIONS::groupProperties, static_cast( aItem ) ); - break; - - case PCB_GENERATOR_T: - static_cast( aItem )->ShowPropertiesDialog( this ); - break; - - case PCB_MARKER_T: - m_toolManager->GetTool()->CrossProbe( static_cast( aItem ) ); - break; - - default: - break; - } -} - diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 6bca3e0dbb..d77334c55f 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -266,138 +266,135 @@ void PCB_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent ) } -void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) +bool PCB_EDIT_FRAME::LoadBoard() { - int id = event.GetId(); - Files_io_from_id( id ); + // 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() ); + + return AskLoadBoardFileName( this, &fileName, open_ctl ) + && OpenProjectFiles( std::vector( 1, fileName ), open_ctl ); } -bool PCB_EDIT_FRAME::Files_io_from_id( int id ) +bool PCB_EDIT_FRAME::ImportNonKicadBoard() +{ + // 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 ); +} + + +bool PCB_EDIT_FRAME::RecoverAutosave() { wxString msg; - switch( id ) + wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() ); + wxFileName fn = currfn; + + wxString rec_name = FILEEXT::AutoSaveFilePrefix + fn.GetName(); + fn.SetName( rec_name ); + + if( !fn.FileExists() ) { - case ID_LOAD_FILE: - { - // 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() ); - - return AskLoadBoardFileName( this, &fileName, open_ctl ) - && OpenProjectFiles( std::vector( 1, fileName ), open_ctl ); - } - - case ID_IMPORT_NON_KICAD_BOARD: - { - // 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 ); - } - - case ID_MENU_RECOVER_BOARD_AUTOSAVE: - { - wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() ); - wxFileName fn = currfn; - - wxString rec_name = FILEEXT::AutoSaveFilePrefix + fn.GetName(); - fn.SetName( rec_name ); - - if( !fn.FileExists() ) - { - msg.Printf( _( "Recovery file '%s' not found." ), fn.GetFullPath() ); - DisplayInfoMessage( this, msg ); - return false; - } - - msg.Printf( _( "OK to load recovery file '%s'?" ), fn.GetFullPath() ); - - if( !IsOK( this, msg ) ) - return false; - - GetScreen()->SetContentModified( false ); // do not prompt the user for changes - - if( OpenProjectFiles( std::vector( 1, fn.GetFullPath() ) ) ) - { - // Re-set the name since name or extension was changed - GetBoard()->SetFileName( currfn.GetFullPath() ); - UpdateTitle(); - return true; - } - + msg.Printf( _( "Recovery file '%s' not found." ), fn.GetFullPath() ); + DisplayInfoMessage( this, msg ); return false; } - case ID_REVERT_BOARD: + msg.Printf( _( "OK to load recovery file '%s'?" ), fn.GetFullPath() ); + + if( !IsOK( this, msg ) ) + return false; + + GetScreen()->SetContentModified( false ); // do not prompt the user for changes + + if( OpenProjectFiles( std::vector( 1, fn.GetFullPath() ) ) ) { - wxFileName fn = Prj().AbsolutePath( GetBoard()->GetFileName() ); - - msg.Printf( _( "Revert '%s' to last version saved?" ), fn.GetFullPath() ); - - if( !IsOK( this, msg ) ) - return false; - - GetScreen()->SetContentModified( false ); // do not prompt the user for changes - - ReleaseFile(); - - return OpenProjectFiles( std::vector( 1, fn.GetFullPath() ), KICTL_REVERT ); - } - - case ID_NEW_BOARD: - { - // Only standalone mode can directly load a new document - if( !Kiface().IsSingle() ) - return false; - - if( IsContentModified() ) - { - wxFileName fileName = GetBoard()->GetFileName(); - wxString saveMsg = _( "Current board will be closed, save changes to '%s' before " - "continuing?" ); - - if( !HandleUnsavedChanges( this, wxString::Format( saveMsg, fileName.GetFullName() ), - [&]()->bool - { - return Files_io_from_id( ID_SAVE_BOARD ); - } ) ) - { - return false; - } - } - else if( !GetBoard()->IsEmpty() ) - { - if( !IsOK( this, _( "Current Board will be closed. Continue?" ) ) ) - return false; - } - - SaveProjectLocalSettings(); - - GetBoard()->ClearProject(); - - SETTINGS_MANAGER* mgr = GetSettingsManager(); - mgr->UnloadProject( &mgr->Prj() ); - - if( !Clear_Pcb( false ) ) - return false; - - LoadProjectSettings(); - LoadDrawingSheet(); - - onBoardLoaded(); - - OnModify(); + // Re-set the name since name or extension was changed + GetBoard()->SetFileName( currfn.GetFullPath() ); + UpdateTitle(); return true; } - case ID_SAVE_BOARD: + return false; +} + + +bool PCB_EDIT_FRAME::RevertBoard() +{ + wxFileName fn = Prj().AbsolutePath( GetBoard()->GetFileName() ); + + if( !IsOK( this, wxString::Format( _( "Revert '%s' to last version saved?" ), fn.GetFullPath() ) ) ) + return false; + + GetScreen()->SetContentModified( false ); // do not prompt the user for changes + + ReleaseFile(); + + return OpenProjectFiles( std::vector( 1, fn.GetFullPath() ), KICTL_REVERT ); +} + + +bool PCB_EDIT_FRAME::NewBoard() +{ + // Only standalone mode can directly load a new document + if( !Kiface().IsSingle() ) + return false; + + if( IsContentModified() ) + { + wxFileName fileName = GetBoard()->GetFileName(); + wxString saveMsg = _( "Current board will be closed, save changes to '%s' before " + "continuing?" ); + + if( !HandleUnsavedChanges( this, wxString::Format( saveMsg, fileName.GetFullName() ), + [&]()->bool + { + return SaveBoard(); + } ) ) + { + return false; + } + } + else if( !GetBoard()->IsEmpty() ) + { + if( !IsOK( this, _( "Current Board will be closed. Continue?" ) ) ) + return false; + } + + SaveProjectLocalSettings(); + + GetBoard()->ClearProject(); + + SETTINGS_MANAGER* mgr = GetSettingsManager(); + mgr->UnloadProject( &mgr->Prj() ); + + if( !Clear_Pcb( false ) ) + return false; + + LoadProjectSettings(); + LoadDrawingSheet(); + + onBoardLoaded(); + + OnModify(); + return true; +} + + +bool PCB_EDIT_FRAME::SaveBoard( bool aSaveAs, bool aSaveCopy ) +{ + wxString msg; + + if( !aSaveAs ) + { if( !GetBoard()->GetFileName().IsEmpty() ) { if( SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) ) ) @@ -408,56 +405,46 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id ) return false; } + } - KI_FALLTHROUGH; + wxString orig_name; - case ID_COPY_BOARD_AS: - case ID_SAVE_BOARD_AS: + wxFileName::SplitPath( GetBoard()->GetFileName(), nullptr, nullptr, &orig_name, nullptr ); + + if( orig_name.IsEmpty() ) + orig_name = NAMELESS_PROJECT; + + wxFileName savePath( Prj().GetProjectFullName() ); + + if( !savePath.IsOk() || !savePath.IsDirWritable() ) { - bool addToHistory = ( id == ID_SAVE_BOARD_AS ); - wxString orig_name; - - wxFileName::SplitPath( GetBoard()->GetFileName(), nullptr, nullptr, &orig_name, nullptr ); - - if( orig_name.IsEmpty() ) - orig_name = NAMELESS_PROJECT; - - wxFileName savePath( Prj().GetProjectFullName() ); + savePath = GetMruPath(); if( !savePath.IsOk() || !savePath.IsDirWritable() ) - { - savePath = GetMruPath(); - - if( !savePath.IsOk() || !savePath.IsDirWritable() ) - savePath = PATHS::GetDefaultUserProjectsPath(); - } - - wxFileName fn( savePath.GetPath(), orig_name, FILEEXT::KiCadPcbFileExtension ); - wxString filename = fn.GetFullPath(); - bool createProject = false; - bool success = false; - - if( AskSaveBoardFileName( this, &filename, &createProject ) ) - { - if( id == ID_COPY_BOARD_AS ) - { - success = SavePcbCopy( EnsureFileExtension( filename, FILEEXT::KiCadPcbFileExtension ), createProject ); - } - else - { - success = SavePcbFile( filename, addToHistory, createProject ); - - if( success ) - m_autoSaveRequired = false; - } - } - - return success; + savePath = PATHS::GetDefaultUserProjectsPath(); } - default: - return false; + wxFileName fn( savePath.GetPath(), orig_name, FILEEXT::KiCadPcbFileExtension ); + wxString filename = fn.GetFullPath(); + bool createProject = false; + bool success = false; + + if( AskSaveBoardFileName( this, &filename, &createProject ) ) + { + if( aSaveCopy ) + { + success = SavePcbCopy( EnsureFileExtension( filename, FILEEXT::KiCadPcbFileExtension ), createProject ); + } + else + { + success = SavePcbFile( filename, aSaveAs, createProject ); + + if( success ) + m_autoSaveRequired = false; + } } + + return success; } diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 24f523a896..c1a067aa5a 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -101,10 +101,7 @@ void PCB_EDIT_FRAME::doReCreateMenuBar() fileMenu->Add( ACTIONS::revert ); fileMenu->AppendSeparator(); - fileMenu->Add( _( "Resc&ue" ), - _( "Clear board and get last rescue file automatically saved by PCB editor" ), - ID_MENU_RECOVER_BOARD_AUTOSAVE, - BITMAPS::rescue ); + fileMenu->Add( PCB_ACTIONS::rescueAutosave ); // Import submenu ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool ); @@ -114,9 +111,7 @@ void PCB_EDIT_FRAME::doReCreateMenuBar() submenuImport->Add( PCB_ACTIONS::importNetlist, ACTION_MENU::NORMAL, _( "Netlist..." ) ); submenuImport->Add( PCB_ACTIONS::importSpecctraSession, ACTION_MENU::NORMAL, _( "Specctra Session..." ) ); submenuImport->Add( PCB_ACTIONS::placeImportedGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) ); - submenuImport->Add( _( "Non-KiCad Board File..." ), - _( "Import board file from other applications" ), - ID_IMPORT_NON_KICAD_BOARD, BITMAPS::import_brd_file ); + submenuImport->Add( PCB_ACTIONS::openNonKicadBoard ); fileMenu->AppendSeparator(); fileMenu->Add( submenuImport ); @@ -146,15 +141,8 @@ void PCB_EDIT_FRAME::doReCreateMenuBar() submenuExport->Add( *m_exportNetlistAction ); submenuExport->AppendSeparator(); - submenuExport->Add( _( "Footprints to Library..." ), - _( "Add footprints used on board to an existing footprint library\n" - "(does not remove other footprints from this library)" ), - ID_MENU_EXPORT_FOOTPRINTS_TO_LIBRARY, BITMAPS::library_archive ); - - submenuExport->Add( _( "Footprints to New Library..." ), - _( "Create a new footprint library containing the footprints used on board\n" - "(if the library already exists it will be replaced)" ), - ID_MENU_EXPORT_FOOTPRINTS_TO_NEW_LIBRARY, BITMAPS::library_archive_as ); + submenuExport->Add( PCB_ACTIONS::exportFootprints ); + submenuExport->Add( PCB_ACTIONS::exportFootprintsAs ); fileMenu->Add( submenuExport ); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 6945c584fe..f6152367ed 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -41,16 +41,13 @@ #include #include #include -#include +#include +#include #include -#include -#include -#include +#include #include #include -#include #include -#include #include #include #include @@ -92,13 +89,10 @@ #include #include #include -#include #include #include #include #include -#include -#include #include #include #include @@ -152,12 +146,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_SIZE( PCB_EDIT_FRAME::OnSize ) - EVT_TOOL( ID_MENU_RECOVER_BOARD_AUTOSAVE, PCB_EDIT_FRAME::Files_io ) - // Menu Files: - EVT_MENU( ID_MAIN_MENUBAR, PCB_EDIT_FRAME::Process_Special_Functions ) - - EVT_MENU( ID_IMPORT_NON_KICAD_BOARD, PCB_EDIT_FRAME::Files_io ) EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PCB_EDIT_FRAME::OnFileHistory ) EVT_MENU( ID_FILE_LIST_CLEAR, PCB_EDIT_FRAME::OnClearFileHistory ) @@ -167,9 +156,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_GEN_EXPORT_FILE_STEP, PCB_EDIT_FRAME::OnExportSTEP ) EVT_MENU( ID_GEN_EXPORT_FILE_HYPERLYNX, PCB_EDIT_FRAME::OnExportHyperlynx ) - EVT_MENU( ID_MENU_EXPORT_FOOTPRINTS_TO_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions ) - EVT_MENU( ID_MENU_EXPORT_FOOTPRINTS_TO_NEW_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions ) - EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit ) EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit ) @@ -1255,7 +1241,7 @@ bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent ) if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ), [&]() -> bool { - return Files_io_from_id( ID_SAVE_BOARD ); + return SaveBoard(); } ) ) { return false; @@ -2149,89 +2135,6 @@ bool PCB_EDIT_FRAME::FetchNetlistFromSchematic( NETLIST& aNetlist, } -void PCB_EDIT_FRAME::RunEeschema() -{ - wxString msg; - wxFileName schematic( Prj().GetProjectPath(), Prj().GetProjectName(), - FILEEXT::KiCadSchematicFileExtension ); - - if( !schematic.FileExists() ) - { - wxFileName legacySchematic( Prj().GetProjectPath(), Prj().GetProjectName(), - FILEEXT::LegacySchematicFileExtension ); - - if( legacySchematic.FileExists() ) - { - schematic = legacySchematic; - } - else - { - msg.Printf( _( "Schematic file '%s' not found." ), schematic.GetFullPath() ); - DisplayErrorMessage( this, msg ); - return; - } - } - - if( Kiface().IsSingle() ) - { - ExecuteFile( EESCHEMA_EXE, schematic.GetFullPath() ); - } - else - { - KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, false ); - - // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls - // Kiway.Player( FRAME_SCH, true ) - // therefore, the schematic editor is sometimes running, but the schematic project - // is not loaded, if the library editor was called, and the dialog field editor was used. - // On Linux, it happens the first time the schematic editor is launched, if - // library editor was running, and the dialog field editor was open - // On Windows, it happens always after the library editor was called, - // and the dialog field editor was used - if( !frame ) - { - try - { - frame = Kiway().Player( FRAME_SCH, true ); - } - catch( const IO_ERROR& err ) - { - - DisplayErrorMessage( this, _( "Eeschema failed to load." ) + wxS( "\n" ) + err.What() ); - return; - } - } - - wxEventBlocker blocker( this ); - - // If Kiway() cannot create the eeschema frame, it shows a error message, and - // frame is null - if( !frame ) - return; - - if( !frame->IsShownOnScreen() ) // the frame exists, (created by the dialog field editor) - // but no project loaded. - { - frame->OpenProjectFiles( std::vector( 1, schematic.GetFullPath() ) ); - frame->Show( true ); - } - - // On Windows, Raise() does not bring the window on screen, when iconized or not shown - // On Linux, Raise() brings the window on screen, but this code works fine - if( frame->IsIconized() ) - { - frame->Iconize( false ); - - // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough - // to show the frame at its normal size: Maximize should be called. - frame->Maximize( false ); - } - - frame->Raise(); - } -} - - void PCB_EDIT_FRAME::PythonSyncEnvironmentVariables() { const ENV_VAR_MAP& vars = Pgm().GetLocalEnvVariables(); @@ -2888,3 +2791,108 @@ void PCB_EDIT_FRAME::onPluginAvailabilityChanged( wxCommandEvent& aEvt ) aEvt.Skip(); } #endif + + +void PCB_EDIT_FRAME::SwitchLayer( PCB_LAYER_ID layer ) +{ + PCB_LAYER_ID curLayer = GetActiveLayer(); + const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions(); + + // Check if the specified layer matches the present layer + if( layer == curLayer ) + return; + + // Copper layers cannot be selected unconditionally; how many of those layers are currently + // enabled needs to be checked. + if( IsCopperLayer( layer ) ) + { + if( layer > GetBoard()->GetCopperLayerStackMaxId() ) + return; + } + + // Is yet more checking required? E.g. when the layer to be selected is a non-copper layer, + // or when switching between a copper layer and a non-copper layer, or vice-versa? + + SetActiveLayer( layer ); + + if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL ) + GetCanvas()->Refresh(); +} + + +void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) +{ + switch( aItem->Type() ) + { + case PCB_REFERENCE_IMAGE_T: + ShowReferenceImagePropertiesDialog( aItem ); + break; + + case PCB_FIELD_T: + case PCB_TEXT_T: + ShowTextPropertiesDialog( static_cast( aItem ) ); + break; + + case PCB_TEXTBOX_T: + ShowTextBoxPropertiesDialog( static_cast( aItem ) ); + break; + + case PCB_TABLE_T: + { + DIALOG_TABLE_PROPERTIES dlg( this, static_cast( aItem ) ); + + //QuasiModal required for Scintilla auto-complete + dlg.ShowQuasiModal(); + break; + } + + case PCB_PAD_T: + ShowPadPropertiesDialog( static_cast( aItem ) ); + break; + + case PCB_FOOTPRINT_T: + ShowFootprintPropertiesDialog( static_cast( aItem ) ); + break; + + case PCB_TARGET_T: + ShowTargetOptionsDialog( static_cast( aItem ) ); + break; + + case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_RADIAL_T: + case PCB_DIM_ORTHOGONAL_T: + case PCB_DIM_LEADER_T: + { + DIALOG_DIMENSION_PROPERTIES dlg( this, static_cast( aItem ) ); + + // TODO: why is this QuasiModal? + dlg.ShowQuasiModal(); + break; + } + + case PCB_SHAPE_T: + ShowGraphicItemPropertiesDialog( static_cast( aItem ) ); + break; + + case PCB_ZONE_T: + Edit_Zone_Params( static_cast( aItem ) ); + break; + + case PCB_GROUP_T: + m_toolManager->RunAction( ACTIONS::groupProperties, static_cast( aItem ) ); + break; + + case PCB_GENERATOR_T: + static_cast( aItem )->ShowPropertiesDialog( this ); + break; + + case PCB_MARKER_T: + m_toolManager->GetTool()->CrossProbe( static_cast( aItem ) ); + break; + + default: + break; + } +} + diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 0bf2340186..217ff143b8 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -168,8 +168,6 @@ public: void OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent ); void OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent ); - void RunEeschema(); - void UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aShowNetclass, bool aShowEdit ); void UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aShowNetclass, bool aShowEdit ); @@ -373,27 +371,12 @@ public: void OnFileHistory( wxCommandEvent& event ); void OnClearFileHistory( wxCommandEvent& aEvent ); - /** - * Call #Files_io_from_id with the wxCommandEvent id. - * - * @param event is the command event handler. - */ - void Files_io( wxCommandEvent& event ); - - /** - * Read and write board files according to \a aId. - * - * Valid event IDs are: - * - ID_LOAD_FILE - * - ID_MENU_RECOVER_BOARD_AUTOSAVE - * - ID_NEW_BOARD - * - ID_SAVE_BOARD - * - ID_COPY_BOARD_AS - * - ID_SAVE_BOARD_AS - * - * @param aId is an event ID coming from file command events: - */ - bool Files_io_from_id( int aId ); + bool LoadBoard(); + bool ImportNonKicadBoard(); + bool RecoverAutosave(); + bool RevertBoard(); + bool NewBoard(); + bool SaveBoard( bool aSaveAs = false, bool aSaveCopy = false ); /** * Load a KiCad board (.kicad_pcb) from \a aFileName. diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 8f036e83dc..c55a5f7642 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -77,10 +77,6 @@ enum pcbnew_ids ID_POPUP_PCB_SELECT_DIFFPAIR16, ID_POPUP_PCB_SELECT_WIDTH_END_RANGE, - ID_MENU_RECOVER_BOARD_AUTOSAVE, - ID_MENU_EXPORT_FOOTPRINTS_TO_LIBRARY, - ID_MENU_EXPORT_FOOTPRINTS_TO_NEW_LIBRARY, - ID_GEN_EXPORT_FILE_IDF3, ID_GEN_EXPORT_FILE_VRML, ID_GEN_EXPORT_FILE_STEP, diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index fd6986467d..3e51d2809a 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -327,8 +327,8 @@ std::optional PCB_EDIT_TOOLBAR_SETTINGS::DefaultToolbarCo config.AppendAction( PCB_ACTIONS::runDRC ); - config.AppendSeparator() - .AppendAction( PCB_ACTIONS::showEeschema ); + config.AppendSeparator(); + config.AppendAction( PCB_ACTIONS::showEeschema ); config.AppendControl( ACTION_TOOLBAR_CONTROLS::ipcScripting ); diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index 72a62e5fb6..5ef35d54df 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -29,8 +29,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -254,42 +256,70 @@ bool BOARD_EDITOR_CONTROL::Init() int BOARD_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent ) { - m_frame->Files_io_from_id( ID_NEW_BOARD ); + m_frame->NewBoard(); return 0; } int BOARD_EDITOR_CONTROL::Open( const TOOL_EVENT& aEvent ) { - m_frame->Files_io_from_id( ID_LOAD_FILE ); + m_frame->LoadBoard(); return 0; } int BOARD_EDITOR_CONTROL::Save( const TOOL_EVENT& aEvent ) { - m_frame->Files_io_from_id( ID_SAVE_BOARD ); + m_frame->SaveBoard(); return 0; } int BOARD_EDITOR_CONTROL::SaveAs( const TOOL_EVENT& aEvent ) { - m_frame->Files_io_from_id( ID_SAVE_BOARD_AS ); + m_frame->SaveBoard( true ); return 0; } int BOARD_EDITOR_CONTROL::SaveCopy( const TOOL_EVENT& aEvent ) { - m_frame->Files_io_from_id( ID_COPY_BOARD_AS ); + m_frame->SaveBoard( true, true ); return 0; } int BOARD_EDITOR_CONTROL::Revert( const TOOL_EVENT& aEvent ) { - m_frame->Files_io_from_id( ID_REVERT_BOARD ); + 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 ); + return 0; +} + + +int BOARD_EDITOR_CONTROL::ExportFootprintsAs( const TOOL_EVENT& aEvent ) +{ + m_frame->ExportFootprintsToLibrary( true ); return 0; } @@ -665,7 +695,9 @@ int BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB( const TOOL_EVENT& aEvent ) return 0; } - m_frame->RunEeschema(); + TOOL_EVENT dummy; + ShowEeschema( dummy ); + KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_SCH, false ); if( frame ) @@ -683,7 +715,87 @@ int BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB( const TOOL_EVENT& aEvent ) int BOARD_EDITOR_CONTROL::ShowEeschema( const TOOL_EVENT& aEvent ) { - m_frame->RunEeschema(); + wxString msg; + PCB_EDIT_FRAME* boardFrame = m_frame; + PROJECT& project = boardFrame->Prj(); + wxFileName schematic( project.GetProjectPath(), project.GetProjectName(), + FILEEXT::KiCadSchematicFileExtension ); + + if( !schematic.FileExists() ) + { + wxFileName legacySchematic( project.GetProjectPath(), project.GetProjectName(), + FILEEXT::LegacySchematicFileExtension ); + + if( legacySchematic.FileExists() ) + { + schematic = legacySchematic; + } + else + { + msg.Printf( _( "Schematic file '%s' not found." ), schematic.GetFullPath() ); + DisplayErrorMessage( m_frame, msg ); + return 0; + } + } + + if( Kiface().IsSingle() ) + { + ExecuteFile( EESCHEMA_EXE, schematic.GetFullPath() ); + } + else + { + KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_SCH, false ); + + // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls + // Kiway.Player( FRAME_SCH, true ) + // therefore, the schematic editor is sometimes running, but the schematic project + // is not loaded, if the library editor was called, and the dialog field editor was used. + // On Linux, it happens the first time the schematic editor is launched, if + // library editor was running, and the dialog field editor was open + // On Windows, it happens always after the library editor was called, + // and the dialog field editor was used + if( !frame ) + { + try + { + frame = boardFrame->Kiway().Player( FRAME_SCH, true ); + } + catch( const IO_ERROR& err ) + { + + DisplayErrorMessage( boardFrame, _( "Eeschema failed to load." ) + wxS( "\n" ) + err.What() ); + return 0; + } + } + + wxEventBlocker blocker( boardFrame ); + + // If Kiway() cannot create the eeschema frame, it shows a error message, and + // frame is null + if( !frame ) + return 0; + + if( !frame->IsShownOnScreen() ) // the frame exists, (created by the dialog field editor) + // but no project loaded. + { + frame->OpenProjectFiles( std::vector( 1, schematic.GetFullPath() ) ); + frame->Show( true ); + } + + // On Windows, Raise() does not bring the window on screen, when iconized or not shown + // On Linux, Raise() brings the window on screen, but this code works fine + if( frame->IsIconized() ) + { + frame->Iconize( false ); + + // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough + // to show the frame at its normal size: Maximize should be called. + frame->Maximize( false ); + } + + frame->Raise(); + } + return 0; } @@ -1718,6 +1830,10 @@ void BOARD_EDITOR_CONTROL::setTransitions() Go( &BOARD_EDITOR_CONTROL::FindNext, ACTIONS::findNext.MakeEvent() ); Go( &BOARD_EDITOR_CONTROL::FindNext, ACTIONS::findPrevious.MakeEvent() ); + Go( &BOARD_EDITOR_CONTROL::RescueAutosave, PCB_ACTIONS::rescueAutosave.MakeEvent() ); + Go( &BOARD_EDITOR_CONTROL::OpenNonKicadBoard, PCB_ACTIONS::openNonKicadBoard.MakeEvent() ); + Go( &BOARD_EDITOR_CONTROL::ExportFootprints, PCB_ACTIONS::exportFootprints.MakeEvent() ); + Go( &BOARD_EDITOR_CONTROL::ExportFootprintsAs, PCB_ACTIONS::exportFootprintsAs.MakeEvent() ); Go( &BOARD_EDITOR_CONTROL::BoardSetup, PCB_ACTIONS::boardSetup.MakeEvent() ); Go( &BOARD_EDITOR_CONTROL::ImportNetlist, PCB_ACTIONS::importNetlist.MakeEvent() ); Go( &BOARD_EDITOR_CONTROL::ImportSpecctraSession, PCB_ACTIONS::importSpecctraSession.MakeEvent() ); diff --git a/pcbnew/tools/board_editor_control.h b/pcbnew/tools/board_editor_control.h index 10c30ad940..0dd155a0d6 100644 --- a/pcbnew/tools/board_editor_control.h +++ b/pcbnew/tools/board_editor_control.h @@ -57,6 +57,10 @@ public: int SaveAs( const TOOL_EVENT& aEvent ); int SaveCopy( const TOOL_EVENT& aEvent ); int Revert( const TOOL_EVENT& aEvent ); + int RescueAutosave( const TOOL_EVENT& aEvent ); + int OpenNonKicadBoard( const TOOL_EVENT& aEvent ); + int ExportFootprints( const TOOL_EVENT& aEvent ); + int ExportFootprintsAs( const TOOL_EVENT& aEvent ); int PageSettings( const TOOL_EVENT& aEvent ); int Plot( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index a668b75050..86636b8a37 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -1130,6 +1130,43 @@ TOOL_ACTION PCB_ACTIONS::pluginsShowFolder( TOOL_ACTION_ARGS() // BOARD_EDITOR_CONTROL // +TOOL_ACTION PCB_ACTIONS::appendBoard( TOOL_ACTION_ARGS() + .Name( "pcbnew.EditorControl.appendBoard" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Append Board..." ) ) + .Tooltip( _( "Open another board and append its contents to this board" ) ) + .Icon( BITMAPS::add_board ) ); + +TOOL_ACTION PCB_ACTIONS::rescueAutosave( TOOL_ACTION_ARGS() + .Name( "pcbnew.EditorControl.rescueAutosave" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Rescue" ) ) + .Tooltip( _( "Clear board and get last rescue file automatically saved by PCB editor" ) ) + .Icon( BITMAPS::rescue ) ); + +TOOL_ACTION PCB_ACTIONS::openNonKicadBoard( TOOL_ACTION_ARGS() + .Name( "pcbnew.EditorControl.openNonKicadBoard" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Non-KiCad Board File..." ) ) + .Tooltip( _( "Import board file from other applications" ) ) + .Icon( BITMAPS::import_brd_file ) ); + +TOOL_ACTION PCB_ACTIONS::exportFootprints( TOOL_ACTION_ARGS() + .Name( "pcbnew.EditorControl.exportFootprints" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Footprints to Library..." ) ) + .Tooltip( _( "Add footprints used on board to an existing footprint library\n" + "(does not remove other footprints from this library)" ) ) + .Icon( BITMAPS::library_archive ) ); + +TOOL_ACTION PCB_ACTIONS::exportFootprintsAs( TOOL_ACTION_ARGS() + .Name( "pcbnew.EditorControl.exportFootprintsAs" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Footprints to New Library..." ) ) + .Tooltip( _( "Create a new footprint library containing the footprints used on board\n" + "(if the library already exists it will be replaced)" ) ) + .Icon( BITMAPS::library_archive_as ) ); + TOOL_ACTION PCB_ACTIONS::boardSetup( TOOL_ACTION_ARGS() .Name( "pcbnew.EditorControl.boardSetup" ) .Scope( AS_GLOBAL ) @@ -1341,13 +1378,6 @@ TOOL_ACTION PCB_ACTIONS::unlock( TOOL_ACTION_ARGS() .Tooltip( _( "Allow items to be moved and/or resized on the canvas" ) ) .Icon( BITMAPS::unlocked ) ); -TOOL_ACTION PCB_ACTIONS::appendBoard( TOOL_ACTION_ARGS() - .Name( "pcbnew.EditorControl.appendBoard" ) - .Scope( AS_GLOBAL ) - .FriendlyName( _( "Append Board..." ) ) - .Tooltip( _( "Open another board and append its contents to this board" ) ) - .Icon( BITMAPS::add_board ) ); - TOOL_ACTION PCB_ACTIONS::highlightNet( TOOL_ACTION_ARGS() .Name( "pcbnew.EditorControl.highlightNet" ) .Scope( AS_GLOBAL ) diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index e97a30f1c5..cc8ccb7828 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -401,20 +401,13 @@ public: /// Scripting Actions static TOOL_ACTION pluginsShowFolder; - // Global edit tool + // Board editor control + static TOOL_ACTION appendBoard; + static TOOL_ACTION rescueAutosave; + static TOOL_ACTION openNonKicadBoard; + static TOOL_ACTION exportFootprints; + static TOOL_ACTION exportFootprintsAs; static TOOL_ACTION boardSetup; - static TOOL_ACTION editTracksAndVias; - static TOOL_ACTION editTextAndGraphics; - static TOOL_ACTION editTeardrops; - static TOOL_ACTION globalDeletions; - static TOOL_ACTION cleanupTracksAndVias; - static TOOL_ACTION cleanupGraphics; - static TOOL_ACTION updateFootprint; - static TOOL_ACTION updateFootprints; - static TOOL_ACTION changeFootprint; - static TOOL_ACTION changeFootprints; - static TOOL_ACTION swapLayers; - static TOOL_ACTION removeUnusedPads; static TOOL_ACTION importNetlist; @@ -430,6 +423,20 @@ public: static TOOL_ACTION generateD356File; static TOOL_ACTION generateBOM; + // Global edit tool + static TOOL_ACTION editTracksAndVias; + static TOOL_ACTION editTextAndGraphics; + static TOOL_ACTION editTeardrops; + static TOOL_ACTION globalDeletions; + static TOOL_ACTION cleanupTracksAndVias; + static TOOL_ACTION cleanupGraphics; + static TOOL_ACTION updateFootprint; + static TOOL_ACTION updateFootprints; + static TOOL_ACTION changeFootprint; + static TOOL_ACTION changeFootprints; + static TOOL_ACTION swapLayers; + static TOOL_ACTION removeUnusedPads; + static TOOL_ACTION runDRC; static TOOL_ACTION editFpInFpEditor; @@ -537,7 +544,6 @@ public: static TOOL_ACTION drillOrigin; static TOOL_ACTION drillResetOrigin; static TOOL_ACTION drillSetOrigin; - static TOOL_ACTION appendBoard; static TOOL_ACTION showEeschema; static TOOL_ACTION boardStatistics; static TOOL_ACTION boardReannotate;