Move more stuff to ACTIONs framework.
This commit is contained in:
+1
-5
@@ -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)
|
||||
|
||||
+2
-59
@@ -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 <eda_base_frame.h>
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -89,6 +89,8 @@
|
||||
#define EDITORS_CAPTION _( "Editors" )
|
||||
#define PROJECT_FILES_CAPTION _( "Project Files" )
|
||||
|
||||
#define ID_INIT_WATCHED_PATHS 52913
|
||||
|
||||
#define SEP() wxFileName::GetPathSeparator()
|
||||
|
||||
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -169,7 +169,7 @@ HANDLER_RESULT<Empty> 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<Empty> API_HANDLER_PCB::handleSaveCopyOfDocument(
|
||||
|
||||
if( board->GetFileName().Matches( boardPath.GetFullPath() ) )
|
||||
{
|
||||
frame()->Files_io_from_id( ID_SAVE_BOARD );
|
||||
frame()->SaveBoard();
|
||||
return Empty();
|
||||
}
|
||||
|
||||
|
||||
-173
@@ -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 <[email protected]>
|
||||
* Copyright (C) 2015 Wayne Stambaugh <[email protected]>
|
||||
* 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 <kiface_base.h>
|
||||
#include <confirm.h>
|
||||
#include <gestfich.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
#include <pcbnew_id.h>
|
||||
#include <board.h>
|
||||
#include <footprint.h>
|
||||
#include <pad.h>
|
||||
#include <zone.h>
|
||||
#include <pcb_group.h>
|
||||
#include <pcb_generator.h>
|
||||
#include <pcb_target.h>
|
||||
#include <pcb_dimension.h>
|
||||
#include <pcb_textbox.h>
|
||||
#include <pcb_table.h>
|
||||
#include <pcb_shape.h>
|
||||
#include <dialog_drc.h>
|
||||
#include <connectivity/connectivity_data.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
#include <tools/drc_tool.h>
|
||||
#include <dialogs/dialog_dimension_properties.h>
|
||||
#include <dialogs/dialog_table_properties.h>
|
||||
#include <pcb_layer_box_selector.h>
|
||||
|
||||
// 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<PCB_TEXT*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_TEXTBOX_T:
|
||||
ShowTextBoxPropertiesDialog( static_cast<PCB_TEXTBOX*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_TABLE_T:
|
||||
{
|
||||
DIALOG_TABLE_PROPERTIES dlg( this, static_cast<PCB_TABLE*>( aItem ) );
|
||||
|
||||
//QuasiModal required for Scintilla auto-complete
|
||||
dlg.ShowQuasiModal();
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_PAD_T:
|
||||
ShowPadPropertiesDialog( static_cast<PAD*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_FOOTPRINT_T:
|
||||
ShowFootprintPropertiesDialog( static_cast<FOOTPRINT*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_TARGET_T:
|
||||
ShowTargetOptionsDialog( static_cast<PCB_TARGET*>( 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<PCB_DIMENSION_BASE*>( aItem ) );
|
||||
|
||||
// TODO: why is this QuasiModal?
|
||||
dlg.ShowQuasiModal();
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_SHAPE_T:
|
||||
ShowGraphicItemPropertiesDialog( static_cast<PCB_SHAPE*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_ZONE_T:
|
||||
Edit_Zone_Params( static_cast<ZONE*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_GROUP_T:
|
||||
m_toolManager->RunAction( ACTIONS::groupProperties, static_cast<PCB_GROUP*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_GENERATOR_T:
|
||||
static_cast<PCB_GENERATOR*>( aItem )->ShowPropertiesDialog( this );
|
||||
break;
|
||||
|
||||
case PCB_MARKER_T:
|
||||
m_toolManager->GetTool<DRC_TOOL>()->CrossProbe( static_cast<PCB_MARKER*>( aItem ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+146
-159
@@ -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<wxString>( 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<wxString>( 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<wxString>( 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<wxString>( 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<wxString>( 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<wxString>( 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<wxString>( 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<wxString>( 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
+109
-101
@@ -41,16 +41,13 @@
|
||||
#include <dialog_footprint_properties.h>
|
||||
#include <dialogs/dialog_exchange_footprints.h>
|
||||
#include <dialog_board_setup.h>
|
||||
#include <invoke_pcb_dialog.h>
|
||||
#include <dialogs/dialog_dimension_properties.h>
|
||||
#include <dialogs/dialog_table_properties.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <board.h>
|
||||
#include <board_design_settings.h>
|
||||
#include <footprint.h>
|
||||
#include <pcb_target.h>
|
||||
#include <layer_pairs.h>
|
||||
#include <drawing_sheet/ds_proxy_view_item.h>
|
||||
#include <connectivity/connectivity_data.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <pcb_draw_panel_gal.h>
|
||||
#include <functional>
|
||||
#include <pcb_painter.h>
|
||||
#include <project/project_file.h>
|
||||
@@ -92,13 +89,10 @@
|
||||
#include <microwave/microwave_tool.h>
|
||||
#include <tools/position_relative_tool.h>
|
||||
#include <tools/zone_filler_tool.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
#include <tools/multichannel_tool.h>
|
||||
#include <router/router_tool.h>
|
||||
#include <autorouter/autoplace_tool.h>
|
||||
#include <python/scripting/pcb_scripting_tool.h>
|
||||
#include <gestfich.h>
|
||||
#include <executable_names.h>
|
||||
#include <netlist_reader/netlist_reader.h>
|
||||
#include <wx/socket.h>
|
||||
#include <wx/wupdlock.h>
|
||||
@@ -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<wxString>( 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<PCB_TEXT*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_TEXTBOX_T:
|
||||
ShowTextBoxPropertiesDialog( static_cast<PCB_TEXTBOX*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_TABLE_T:
|
||||
{
|
||||
DIALOG_TABLE_PROPERTIES dlg( this, static_cast<PCB_TABLE*>( aItem ) );
|
||||
|
||||
//QuasiModal required for Scintilla auto-complete
|
||||
dlg.ShowQuasiModal();
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_PAD_T:
|
||||
ShowPadPropertiesDialog( static_cast<PAD*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_FOOTPRINT_T:
|
||||
ShowFootprintPropertiesDialog( static_cast<FOOTPRINT*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_TARGET_T:
|
||||
ShowTargetOptionsDialog( static_cast<PCB_TARGET*>( 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<PCB_DIMENSION_BASE*>( aItem ) );
|
||||
|
||||
// TODO: why is this QuasiModal?
|
||||
dlg.ShowQuasiModal();
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_SHAPE_T:
|
||||
ShowGraphicItemPropertiesDialog( static_cast<PCB_SHAPE*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_ZONE_T:
|
||||
Edit_Zone_Params( static_cast<ZONE*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_GROUP_T:
|
||||
m_toolManager->RunAction( ACTIONS::groupProperties, static_cast<PCB_GROUP*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_GENERATOR_T:
|
||||
static_cast<PCB_GENERATOR*>( aItem )->ShowPropertiesDialog( this );
|
||||
break;
|
||||
|
||||
case PCB_MARKER_T:
|
||||
m_toolManager->GetTool<DRC_TOOL>()->CrossProbe( static_cast<PCB_MARKER*>( aItem ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-23
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -327,8 +327,8 @@ std::optional<TOOLBAR_CONFIGURATION> 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 );
|
||||
|
||||
|
||||
@@ -29,8 +29,10 @@
|
||||
#include <memory>
|
||||
|
||||
#include <pgm_base.h>
|
||||
#include <executable_names.h>
|
||||
#include <advanced_config.h>
|
||||
#include <bitmaps.h>
|
||||
#include <gestfich.h>
|
||||
#include <pcb_painter.h>
|
||||
#include <board.h>
|
||||
#include <board_commit.h>
|
||||
@@ -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<wxString>( 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() );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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 )
|
||||
|
||||
+20
-14
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user