2011-10-27 13:34:28 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-04-26 16:32:16 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2024-03-17 13:02:07 +00:00
|
|
|
* Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-27 13:34:28 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2017-11-17 17:00:04 +00:00
|
|
|
#include <project.h>
|
2023-02-19 03:40:07 +00:00
|
|
|
#include <math/vector2wx.h>
|
2017-11-17 17:00:04 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2019-06-19 10:31:21 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2023-09-28 03:04:53 +00:00
|
|
|
#include <project_sch.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2023-12-24 00:31:24 +00:00
|
|
|
#include <sch_io/kicad_legacy/sch_io_kicad_legacy.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_sheet.h>
|
2015-06-07 20:31:55 +00:00
|
|
|
#include <sch_sheet_path.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_view.h>
|
2020-04-14 12:25:00 +00:00
|
|
|
#include <sch_painter.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2019-07-29 19:59:31 +00:00
|
|
|
#include <symbol_lib_table.h>
|
2020-10-06 13:17:45 +00:00
|
|
|
#include <dialogs/dialog_sheet_properties.h>
|
2019-06-19 10:31:21 +00:00
|
|
|
#include <tool/actions.h>
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2021-05-01 07:50:29 +00:00
|
|
|
#include <wx/clipbrd.h>
|
|
|
|
#include <wx/dcmemory.h>
|
2021-06-03 12:11:15 +00:00
|
|
|
#include <wx/log.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2024-01-28 15:21:14 +00:00
|
|
|
bool SCH_EDIT_FRAME::CheckSheetForRecursion( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurrentSheet )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2024-01-28 15:21:14 +00:00
|
|
|
wxASSERT( aSheet && aCurrentSheet );
|
2019-07-29 19:59:31 +00:00
|
|
|
|
|
|
|
wxString msg;
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // The full schematic sheet hierarchy.
|
2019-07-29 19:59:31 +00:00
|
|
|
SCH_SHEET_LIST sheetHierarchy( aSheet ); // This is the hierarchy of the loaded file.
|
|
|
|
|
2024-01-28 15:21:14 +00:00
|
|
|
wxString destFilePath = aCurrentSheet->LastScreen()->GetFileName();
|
|
|
|
|
|
|
|
if( destFilePath.IsEmpty() )
|
|
|
|
{
|
|
|
|
// If file is unsaved then there can't (yet) be any recursion.
|
|
|
|
return false;
|
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
|
|
|
|
// SCH_SCREEN object file paths are expected to be absolute. If this assert fires,
|
|
|
|
// something is seriously broken.
|
2024-01-28 15:21:14 +00:00
|
|
|
wxASSERT( wxFileName( destFilePath ).IsAbsolute() );
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2024-01-28 15:21:14 +00:00
|
|
|
if( hierarchy.TestForRecursion( sheetHierarchy, destFilePath ) )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
|
|
|
msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
|
2021-06-28 23:44:07 +00:00
|
|
|
"has the sheet '%s' or one of its subsheets as a parent somewhere in the "
|
|
|
|
"schematic hierarchy." ),
|
2024-01-28 15:21:14 +00:00
|
|
|
destFilePath );
|
2019-07-29 19:59:31 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_EDIT_FRAME::checkForNoFullyDefinedLibIds( SCH_SHEET* aSheet )
|
|
|
|
{
|
|
|
|
wxASSERT( aSheet && aSheet->GetScreen() );
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
SCH_SCREENS newScreens( aSheet );
|
|
|
|
|
|
|
|
if( newScreens.HasNoFullyDefinedLibIds() )
|
|
|
|
{
|
Fix source comment/doc typos (follow-up)
Found via `codespell -q 3 -S *.po,./thirdparty -L aactual,acount,aline,alocation,alog,anormal,anumber,aother,apoints,aparent,aray,dout,einstance,modul,ot,overide,serie,te,,tesselate,tesselator,tht`
2021-07-03 22:37:31 +00:00
|
|
|
msg.Printf( _( "The schematic '%s' has not had its symbol library links remapped "
|
2019-07-29 19:59:31 +00:00
|
|
|
"to the symbol library table. The project this schematic belongs to "
|
|
|
|
"must first be remapped before it can be imported into the current "
|
2021-06-16 22:35:00 +00:00
|
|
|
"project." ),
|
|
|
|
aSheet->GetScreen()->GetFileName() );
|
2019-07-29 19:59:31 +00:00
|
|
|
DisplayInfoMessage( this, msg );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-31 22:03:27 +00:00
|
|
|
void SCH_EDIT_FRAME::InitSheet( SCH_SHEET* aSheet, const wxString& aNewFilename )
|
2019-05-03 11:49:59 +00:00
|
|
|
{
|
2023-11-13 20:29:53 +00:00
|
|
|
SCH_SCREEN* newScreen = new SCH_SCREEN( &Schematic() );
|
|
|
|
aSheet->SetScreen( newScreen );
|
2021-05-28 19:07:04 +00:00
|
|
|
aSheet->GetScreen()->SetContentModified();
|
2019-05-31 22:03:27 +00:00
|
|
|
aSheet->GetScreen()->SetFileName( aNewFilename );
|
2023-11-13 20:29:53 +00:00
|
|
|
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
wxCHECK( cfg, /* void */ );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_paper )
|
|
|
|
newScreen->SetPageSettings( GetScreen()->GetPageSettings() );
|
|
|
|
|
|
|
|
const TITLE_BLOCK& tb1 = GetScreen()->GetTitleBlock();
|
|
|
|
TITLE_BLOCK tb2 = newScreen->GetTitleBlock();
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_revision )
|
|
|
|
tb2.SetRevision( tb1.GetRevision() );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_date )
|
|
|
|
tb2.SetDate( tb1.GetDate() );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_title )
|
|
|
|
tb2.SetTitle( tb1.GetTitle() );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_company )
|
|
|
|
tb2.SetCompany( tb1.GetCompany() );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_comment1 )
|
|
|
|
tb2.SetComment( 0, tb1.GetComment( 0 ) );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_comment2 )
|
|
|
|
tb2.SetComment( 1, tb1.GetComment( 1 ) );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_comment3 )
|
|
|
|
tb2.SetComment( 2, tb1.GetComment( 2 ) );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_comment4 )
|
|
|
|
tb2.SetComment( 3, tb1.GetComment( 3 ) );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_comment5 )
|
|
|
|
tb2.SetComment( 4, tb1.GetComment( 4 ) );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_comment6 )
|
|
|
|
tb2.SetComment( 5, tb1.GetComment( 5 ) );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_comment7 )
|
|
|
|
tb2.SetComment( 6, tb1.GetComment( 6 ) );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_comment8 )
|
|
|
|
tb2.SetComment( 7, tb1.GetComment( 7 ) );
|
|
|
|
|
|
|
|
if( cfg->m_PageSettings.export_comment9 )
|
|
|
|
tb2.SetComment( 8, tb1.GetComment( 8 ) );
|
|
|
|
|
|
|
|
newScreen->SetTitleBlock( tb2 );
|
2019-05-31 22:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-28 15:21:14 +00:00
|
|
|
bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurrentSheet,
|
2019-07-29 19:59:31 +00:00
|
|
|
const wxString& aFileName )
|
2019-05-31 22:03:27 +00:00
|
|
|
{
|
2024-01-28 15:21:14 +00:00
|
|
|
wxASSERT( aSheet && aCurrentSheet );
|
2019-07-29 19:59:31 +00:00
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
wxFileName currentSheetFileName;
|
|
|
|
bool libTableChanged = false;
|
2023-08-26 19:28:53 +00:00
|
|
|
|
2020-04-16 16:43:50 +00:00
|
|
|
SCH_IO_MGR::SCH_FILE_T schFileType = SCH_IO_MGR::GuessPluginTypeFromSchPath( aFileName );
|
2023-08-26 19:28:53 +00:00
|
|
|
|
|
|
|
if( schFileType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
|
|
|
|
schFileType = SCH_IO_MGR::SCH_KICAD;
|
|
|
|
|
2023-12-27 20:39:29 +00:00
|
|
|
IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( schFileType ) );
|
2022-12-25 16:04:45 +00:00
|
|
|
std::unique_ptr< SCH_SHEET> tmpSheet = std::make_unique<SCH_SHEET>( &Schematic() );
|
2019-05-31 22:03:27 +00:00
|
|
|
|
2022-12-25 16:04:45 +00:00
|
|
|
// This will cause the sheet UUID to be set to the UUID of the aSheet argument. This is
|
|
|
|
// required to ensure all of the sheet paths in any sub-sheets are correctly generated when
|
|
|
|
// using the temporary SCH_SHEET object that the file is loaded into..
|
|
|
|
const_cast<KIID&>( tmpSheet->m_Uuid ) = aSheet->m_Uuid;
|
2020-04-26 20:53:29 +00:00
|
|
|
|
2019-07-29 19:59:31 +00:00
|
|
|
wxFileName fileName( aFileName );
|
2019-05-31 22:03:27 +00:00
|
|
|
|
2020-04-22 20:00:48 +00:00
|
|
|
if( !fileName.IsAbsolute() && !fileName.MakeAbsolute() )
|
2019-05-31 22:03:27 +00:00
|
|
|
{
|
2021-06-07 12:02:29 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( "Cannot make file name '%s' path absolute.", aFileName ) );
|
2020-04-22 20:00:48 +00:00
|
|
|
return false;
|
2019-05-31 22:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString fullFilename = fileName.GetFullPath();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2019-07-29 19:59:31 +00:00
|
|
|
if( aSheet->GetScreen() != nullptr )
|
|
|
|
{
|
2023-08-26 19:28:53 +00:00
|
|
|
tmpSheet.reset( pi->LoadSchematicFile( fullFilename, &Schematic() ) );
|
2019-07-29 19:59:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-25 16:04:45 +00:00
|
|
|
tmpSheet->SetFileName( fullFilename );
|
2023-08-26 19:28:53 +00:00
|
|
|
pi->LoadSchematicFile( fullFilename, &Schematic(), tmpSheet.get() );
|
2019-07-29 19:59:31 +00:00
|
|
|
}
|
2019-05-31 22:03:27 +00:00
|
|
|
|
|
|
|
if( !pi->GetError().IsEmpty() )
|
|
|
|
{
|
2019-07-29 19:59:31 +00:00
|
|
|
msg = _( "The entire schematic could not be loaded. Errors occurred attempting "
|
|
|
|
"to load hierarchical sheet schematics." );
|
|
|
|
|
|
|
|
wxMessageDialog msgDlg1( this, msg, _( "Schematic Load Error" ),
|
|
|
|
wxOK | wxCANCEL | wxCANCEL_DEFAULT |
|
|
|
|
wxCENTER | wxICON_QUESTION );
|
|
|
|
msgDlg1.SetOKLabel( wxMessageDialog::ButtonLabel( _( "Use partial schematic" ) ) );
|
|
|
|
msgDlg1.SetExtendedMessage( pi->GetError() );
|
|
|
|
|
|
|
|
if( msgDlg1.ShowModal() == wxID_CANCEL )
|
|
|
|
return false;
|
2019-05-31 22:03:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
2021-06-26 11:33:37 +00:00
|
|
|
msg.Printf( _( "Error loading schematic '%s'." ), fullFilename );
|
2019-05-31 22:03:27 +00:00
|
|
|
DisplayErrorMessage( this, msg, ioe.What() );
|
|
|
|
|
2021-06-08 14:52:49 +00:00
|
|
|
msg.Printf( _( "Failed to load '%s'." ), fullFilename );
|
2020-12-08 05:34:36 +00:00
|
|
|
SetMsgPanel( wxEmptyString, msg );
|
2019-05-31 22:03:27 +00:00
|
|
|
|
2019-07-29 19:59:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the loaded schematic is in a different folder from the current project and
|
|
|
|
// it contains hierarchical sheets, the hierarchical sheet paths need to be updated.
|
2022-12-25 16:04:45 +00:00
|
|
|
if( fileName.GetPathWithSep() != Prj().GetProjectPath() && tmpSheet->CountSheets() )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-12-25 16:04:45 +00:00
|
|
|
SCH_SHEET_LIST loadedSheets( tmpSheet.get() );
|
2019-08-13 20:33:57 +00:00
|
|
|
|
2022-11-30 20:44:47 +00:00
|
|
|
for( const SCH_SHEET_PATH& sheetPath : loadedSheets )
|
|
|
|
{
|
|
|
|
// Skip the loaded sheet since the user already determined if the file path should
|
|
|
|
// be relative or absolute.
|
|
|
|
if( sheetPath.size() == 1 )
|
|
|
|
continue;
|
2022-10-01 12:44:21 +00:00
|
|
|
|
2022-11-30 20:44:47 +00:00
|
|
|
wxString lastSheetPath = fileName.GetPathWithSep();
|
2022-10-01 12:44:21 +00:00
|
|
|
|
2022-11-30 20:44:47 +00:00
|
|
|
for( unsigned i = 1; i < sheetPath.size(); i++ )
|
|
|
|
{
|
|
|
|
SCH_SHEET* sheet = sheetPath.at( i );
|
|
|
|
wxCHECK2( sheet, continue );
|
2022-10-01 12:44:21 +00:00
|
|
|
|
2022-11-30 20:44:47 +00:00
|
|
|
SCH_SCREEN* screen = sheet->GetScreen();
|
|
|
|
wxCHECK2( screen, continue );
|
|
|
|
|
|
|
|
// Use the screen file name which should always be absolute.
|
|
|
|
wxFileName loadedSheetFileName = screen->GetFileName();
|
|
|
|
wxCHECK2( loadedSheetFileName.IsAbsolute(), continue );
|
2022-10-01 12:44:21 +00:00
|
|
|
|
2022-11-30 20:44:47 +00:00
|
|
|
wxFileName tmp = loadedSheetFileName;
|
|
|
|
wxString sheetFileName;
|
2022-10-01 12:44:21 +00:00
|
|
|
|
2022-11-30 20:44:47 +00:00
|
|
|
if( tmp.MakeRelativeTo( lastSheetPath ) )
|
|
|
|
sheetFileName = tmp.GetFullPath();
|
|
|
|
else
|
|
|
|
sheetFileName = loadedSheetFileName.GetFullPath();
|
2022-10-01 12:44:21 +00:00
|
|
|
|
2022-11-30 20:44:47 +00:00
|
|
|
sheetFileName.Replace( wxT( "\\" ), wxT( "/" ) );
|
|
|
|
sheet->SetFileName( sheetFileName );
|
|
|
|
lastSheetPath = loadedSheetFileName.GetPath();
|
|
|
|
}
|
2022-10-01 12:44:21 +00:00
|
|
|
}
|
2019-05-31 22:03:27 +00:00
|
|
|
}
|
|
|
|
|
2022-12-25 16:04:45 +00:00
|
|
|
SCH_SHEET_LIST sheetHierarchy( tmpSheet.get() ); // This is the hierarchy of the loaded file.
|
2022-10-01 12:44:21 +00:00
|
|
|
SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // This is the schematic sheet hierarchy.
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-10-01 12:44:21 +00:00
|
|
|
// Make sure any new sheet changes do not cause any recursion issues.
|
2024-01-28 15:21:14 +00:00
|
|
|
if( CheckSheetForRecursion( tmpSheet.get(), aCurrentSheet )
|
2022-12-25 16:04:45 +00:00
|
|
|
|| checkForNoFullyDefinedLibIds( tmpSheet.get() ) )
|
2020-11-15 13:58:21 +00:00
|
|
|
{
|
2019-07-29 19:59:31 +00:00
|
|
|
return false;
|
2020-11-15 13:58:21 +00:00
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
|
|
|
|
// Make a valiant attempt to warn the user of all possible scenarios where there could
|
|
|
|
// be broken symbol library links.
|
|
|
|
wxArrayString names;
|
|
|
|
wxArrayString newLibNames;
|
2022-12-25 16:04:45 +00:00
|
|
|
SCH_SCREENS newScreens( tmpSheet.get() ); // All screens associated with the import.
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SCREENS prjScreens( &Schematic().Root() );
|
2019-07-29 19:59:31 +00:00
|
|
|
|
|
|
|
newScreens.GetLibNicknames( names );
|
|
|
|
|
|
|
|
wxMessageDialog::ButtonLabel okButtonLabel( _( "Continue Load" ) );
|
|
|
|
wxMessageDialog::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) );
|
|
|
|
|
2022-10-01 12:44:21 +00:00
|
|
|
// Prior to schematic file format 20221002, all symbol instance data was saved in the root
|
|
|
|
// sheet so loading a hierarchical sheet that is not the root sheet will have no symbol
|
|
|
|
// instance data. Give the user a chance to go back and save the project that contains this
|
|
|
|
// hierarchical sheet so the symbol instance data will be correct on load.
|
2022-12-25 16:04:45 +00:00
|
|
|
if( ( tmpSheet->GetScreen()->GetFileFormatVersionAtLoad() < 20221002 )
|
|
|
|
&& tmpSheet->GetScreen()->GetSymbolInstances().empty() )
|
2022-10-01 12:44:21 +00:00
|
|
|
{
|
2023-01-01 23:40:18 +00:00
|
|
|
msg = _( "There are hierarchical sheets in the loaded schematic file from an older "
|
2022-10-01 12:44:21 +00:00
|
|
|
"file version resulting in missing symbol instance data. This will "
|
|
|
|
"result in all of the symbols in the loaded schematic to use either the "
|
|
|
|
"default instance setting or fall back to the library symbol settings. "
|
|
|
|
"Loading the project that uses this schematic file and saving to the "
|
|
|
|
"lastest file version will resolve this issue.\n\n"
|
|
|
|
"Do you wish to continue?" );
|
|
|
|
wxMessageDialog msgDlg7( this, msg, _( "Continue Load Schematic" ),
|
|
|
|
wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER | wxICON_QUESTION );
|
|
|
|
msgDlg7.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
|
|
|
|
|
|
|
|
if( msgDlg7.ShowModal() == wxID_CANCEL )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
if( !prjScreens.HasSchematic( fullFilename ) )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
if( fileName.GetPathWithSep() == Prj().GetProjectPath() )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
// A schematic in the current project path that isn't part of the current project.
|
|
|
|
// It's possible the user copied this schematic from another project so the library
|
|
|
|
// links may not be available. Even this is check is no guarantee that all symbol
|
|
|
|
// library links are valid but it's better than nothing.
|
|
|
|
for( const wxString& name : names )
|
|
|
|
{
|
2023-09-28 03:04:53 +00:00
|
|
|
if( !PROJECT_SCH::SchSymbolLibTable( &Prj() )->HasLibrary( name ) )
|
2022-03-21 12:45:43 +00:00
|
|
|
newLibNames.Add( name );
|
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
if( !newLibNames.IsEmpty() )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
msg = _( "There are library names in the selected schematic that are missing "
|
|
|
|
"from the current project library table. This may result in broken "
|
|
|
|
"symbol library references for the loaded schematic.\n\n"
|
2022-03-15 22:16:56 +00:00
|
|
|
"Do you wish to continue?" );
|
2022-03-21 12:45:43 +00:00
|
|
|
wxMessageDialog msgDlg3( this, msg, _( "Continue Load Schematic" ),
|
2019-07-29 19:59:31 +00:00
|
|
|
wxOK | wxCANCEL | wxCANCEL_DEFAULT |
|
|
|
|
wxCENTER | wxICON_QUESTION );
|
2022-03-21 12:45:43 +00:00
|
|
|
msgDlg3.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
if( msgDlg3.ShowModal() == wxID_CANCEL )
|
2019-07-29 19:59:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-21 12:45:43 +00:00
|
|
|
}
|
|
|
|
else if( fileName.GetPathWithSep() != Prj().GetProjectPath() )
|
|
|
|
{
|
|
|
|
// A schematic loaded from a path other than the current project path.
|
|
|
|
|
|
|
|
// If there are symbol libraries in the imported schematic that are not in the
|
|
|
|
// symbol library table of this project, there could be a lot of broken symbol
|
|
|
|
// library links. Attempt to add the missing libraries to the project symbol
|
|
|
|
// library table.
|
|
|
|
wxArrayString duplicateLibNames;
|
|
|
|
|
|
|
|
for( const wxString& name : names )
|
|
|
|
{
|
2023-09-28 03:04:53 +00:00
|
|
|
if( !PROJECT_SCH::SchSymbolLibTable( &Prj() )->HasLibrary( name ) )
|
2022-03-21 12:45:43 +00:00
|
|
|
newLibNames.Add( name );
|
|
|
|
else
|
|
|
|
duplicateLibNames.Add( name );
|
|
|
|
}
|
|
|
|
|
|
|
|
SYMBOL_LIB_TABLE table;
|
|
|
|
wxFileName symLibTableFn( fileName.GetPath(),
|
|
|
|
SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
|
|
|
|
|
|
|
|
// If there are any new or duplicate libraries, check to see if it's possible that
|
|
|
|
// there could be any missing libraries that would cause broken symbol library links.
|
|
|
|
if( !newLibNames.IsEmpty() || !duplicateLibNames.IsEmpty() )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
if( !symLibTableFn.Exists() || !symLibTableFn.IsFileReadable() )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
msg = _( "The selected file was created as part of a different project. "
|
|
|
|
"Linking the file to this project may result in missing or "
|
|
|
|
"incorrect symbol library references.\n\n"
|
|
|
|
"Do you wish to continue?" );
|
|
|
|
wxMessageDialog msgDlg4( this, msg, _( "Continue Load Schematic" ),
|
|
|
|
wxOK | wxCANCEL | wxCANCEL_DEFAULT |
|
|
|
|
wxCENTER | wxICON_QUESTION );
|
|
|
|
msgDlg4.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
|
|
|
|
|
|
|
|
if( msgDlg4.ShowModal() == wxID_CANCEL )
|
|
|
|
return false;
|
2019-07-29 19:59:31 +00:00
|
|
|
}
|
2022-03-21 12:45:43 +00:00
|
|
|
else
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
table.Load( symLibTableFn.GetFullPath() );
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Error loading the symbol library table '%s'." ),
|
|
|
|
symLibTableFn.GetFullPath() );
|
|
|
|
DisplayErrorMessage( nullptr, msg, ioe.What() );
|
|
|
|
return false;
|
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
// Check to see if any of the symbol libraries found in the appended schematic do
|
|
|
|
// not exist in the current project are missing from the appended project symbol
|
|
|
|
// library table.
|
|
|
|
if( !newLibNames.IsEmpty() )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
bool missingLibNames = table.IsEmpty();
|
|
|
|
|
|
|
|
if( !missingLibNames )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
for( const wxString& newLibName : newLibNames )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
if( !table.HasLibrary( newLibName ) )
|
|
|
|
{
|
|
|
|
missingLibNames = true;
|
|
|
|
break;
|
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-21 12:45:43 +00:00
|
|
|
|
|
|
|
if( missingLibNames )
|
|
|
|
{
|
|
|
|
msg = _( "There are symbol library names in the selected schematic that "
|
|
|
|
"are missing from the selected schematic project library table. "
|
|
|
|
"This may result in broken symbol library references.\n\n"
|
|
|
|
"Do you wish to continue?" );
|
|
|
|
wxMessageDialog msgDlg5( this, msg, _( "Continue Load Schematic" ),
|
|
|
|
wxOK | wxCANCEL | wxCANCEL_DEFAULT |
|
|
|
|
wxCENTER | wxICON_QUESTION );
|
|
|
|
msgDlg5.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
|
|
|
|
|
|
|
|
if( msgDlg5.ShowModal() == wxID_CANCEL )
|
|
|
|
return false;
|
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
}
|
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
// The library name already exists in the current project. Check to see if the
|
|
|
|
// duplicate name is the same library in the current project. If it's not, it's
|
|
|
|
// most likely that the symbol library links will be broken.
|
|
|
|
if( !duplicateLibNames.IsEmpty() && !table.IsEmpty() )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
bool libNameConflict = false;
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
for( const wxString& duplicateLibName : duplicateLibNames )
|
|
|
|
{
|
|
|
|
const SYMBOL_LIB_TABLE_ROW* thisRow = nullptr;
|
|
|
|
const SYMBOL_LIB_TABLE_ROW* otherRow = nullptr;
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2023-09-28 03:04:53 +00:00
|
|
|
if( PROJECT_SCH::SchSymbolLibTable( &Prj() )->HasLibrary( duplicateLibName ) )
|
|
|
|
thisRow = PROJECT_SCH::SchSymbolLibTable( &Prj() )->FindRow( duplicateLibName );
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
if( table.HasLibrary( duplicateLibName ) )
|
|
|
|
otherRow = table.FindRow( duplicateLibName );
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
// It's in the global library table so there is no conflict.
|
|
|
|
if( thisRow && !otherRow )
|
|
|
|
continue;
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
if( !thisRow || !otherRow )
|
|
|
|
continue;
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
wxFileName otherUriFileName;
|
|
|
|
wxString thisURI = thisRow->GetFullURI( true );
|
|
|
|
wxString otherURI = otherRow->GetFullURI( false);
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
if( otherURI.Contains( "${KIPRJMOD}" ) || otherURI.Contains( "$(KIPRJMOD)" ) )
|
|
|
|
{
|
|
|
|
// Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
|
|
|
|
// not expand to a valid symbol library path.
|
|
|
|
otherUriFileName.SetPath( fileName.GetPath() );
|
|
|
|
otherUriFileName.SetFullName( otherURI.AfterLast( '}' ) );
|
|
|
|
otherURI = otherUriFileName.GetFullPath();
|
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
if( thisURI != otherURI )
|
|
|
|
{
|
|
|
|
libNameConflict = true;
|
|
|
|
break;
|
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
}
|
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
if( libNameConflict )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
msg = _( "A duplicate library name that references a different library exists "
|
|
|
|
"in the current library table. This conflict cannot be resolved and "
|
|
|
|
"may result in broken symbol library references.\n\n"
|
|
|
|
"Do you wish to continue?" );
|
|
|
|
wxMessageDialog msgDlg6( this, msg, _( "Continue Load Schematic" ),
|
|
|
|
wxOK | wxCANCEL | wxCANCEL_DEFAULT |
|
|
|
|
wxCENTER | wxICON_QUESTION );
|
|
|
|
msgDlg6.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
|
|
|
|
|
|
|
|
if( msgDlg6.ShowModal() == wxID_CANCEL )
|
|
|
|
return false;
|
2019-07-29 19:59:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
// All (most?) of the possible broken symbol library link cases are covered. Map the
|
|
|
|
// new appended schematic project symbol library table entries to the current project
|
|
|
|
// symbol library table.
|
|
|
|
if( !newLibNames.IsEmpty() && !table.IsEmpty() )
|
2019-07-29 19:59:31 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
for( const wxString& libName : newLibNames )
|
2020-07-30 21:55:27 +00:00
|
|
|
{
|
2022-03-21 12:45:43 +00:00
|
|
|
if( !table.HasLibrary( libName )
|
2023-09-28 03:04:53 +00:00
|
|
|
|| PROJECT_SCH::SchSymbolLibTable( &Prj() )->HasLibrary( libName ) )
|
2022-03-21 12:45:43 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
// Don't expand environment variable because KIPRJMOD will not be correct
|
|
|
|
// for a different project.
|
|
|
|
wxString uri = table.GetFullURI( libName, false );
|
|
|
|
wxFileName newLib;
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
if( uri.Contains( "${KIPRJMOD}" ) || uri.Contains( "$(KIPRJMOD)" ) )
|
|
|
|
{
|
|
|
|
// Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
|
|
|
|
// not expand to a valid symbol library path.
|
|
|
|
newLib.SetPath( fileName.GetPath() );
|
|
|
|
newLib.SetFullName( uri.AfterLast( '}' ) );
|
|
|
|
uri = newLib.GetFullPath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
uri = table.GetFullURI( libName );
|
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
// Add the library from the imported project to the current project
|
|
|
|
// symbol library table.
|
|
|
|
const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName );
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
wxCHECK( row, false );
|
2020-11-10 13:50:16 +00:00
|
|
|
|
2022-03-21 12:45:43 +00:00
|
|
|
SYMBOL_LIB_TABLE_ROW* newRow = new SYMBOL_LIB_TABLE_ROW( libName, uri,
|
|
|
|
row->GetType(),
|
|
|
|
row->GetOptions(),
|
|
|
|
row->GetDescr() );
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2023-09-28 03:04:53 +00:00
|
|
|
PROJECT_SCH::SchSymbolLibTable( &Prj() )->InsertRow( newRow );
|
2022-03-21 12:45:43 +00:00
|
|
|
libTableChanged = true;
|
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-25 16:04:45 +00:00
|
|
|
SCH_SCREEN* newScreen = tmpSheet->GetScreen();
|
2019-07-29 19:59:31 +00:00
|
|
|
wxCHECK_MSG( newScreen, false, "No screen defined for sheet." );
|
|
|
|
|
|
|
|
if( libTableChanged )
|
2020-07-30 21:55:27 +00:00
|
|
|
{
|
2023-09-28 03:04:53 +00:00
|
|
|
PROJECT_SCH::SchSymbolLibTable( &Prj() )->Save( Prj().GetProjectPath() +
|
2019-07-29 19:59:31 +00:00
|
|
|
SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
|
2020-07-30 21:55:27 +00:00
|
|
|
}
|
2019-07-29 19:59:31 +00:00
|
|
|
|
2022-10-01 12:44:21 +00:00
|
|
|
// Make the best attempt to set the symbol instance data for the loaded scheamtic.
|
|
|
|
if( newScreen->GetFileFormatVersionAtLoad() < 20221002 )
|
|
|
|
{
|
|
|
|
if( !newScreen->GetSymbolInstances().empty() )
|
|
|
|
{
|
|
|
|
// If the loaded schematic is a root sheet for another project, update the symbol
|
|
|
|
// instances.
|
2022-12-06 14:00:11 +00:00
|
|
|
sheetHierarchy.UpdateSymbolInstanceData( newScreen->GetSymbolInstances());
|
2022-10-01 12:44:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-07 23:40:05 +00:00
|
|
|
newScreen->MigrateSimModels();
|
|
|
|
|
2022-10-01 12:44:21 +00:00
|
|
|
// Attempt to create new symbol instances using the instance data loaded above.
|
2024-01-28 15:21:14 +00:00
|
|
|
sheetHierarchy.AddNewSymbolInstances( *aCurrentSheet );
|
2022-10-01 12:44:21 +00:00
|
|
|
|
|
|
|
// Add new sheet instance data.
|
2024-01-28 15:21:14 +00:00
|
|
|
sheetHierarchy.AddNewSheetInstances( *aCurrentSheet, hierarchy.GetLastVirtualPageNumber() );
|
2022-10-01 12:44:21 +00:00
|
|
|
|
2019-07-29 19:59:31 +00:00
|
|
|
// It is finally safe to add or append the imported schematic.
|
|
|
|
if( aSheet->GetScreen() == nullptr )
|
|
|
|
aSheet->SetScreen( newScreen );
|
|
|
|
else
|
|
|
|
aSheet->GetScreen()->Append( newScreen );
|
|
|
|
|
2022-12-25 16:04:45 +00:00
|
|
|
SCH_SCREENS allLoadedScreens( aSheet );
|
|
|
|
allLoadedScreens.ReplaceDuplicateTimeStamps();
|
2019-07-29 19:59:31 +00:00
|
|
|
|
|
|
|
return true;
|
2019-05-03 11:49:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-12 13:56:44 +00:00
|
|
|
bool SCH_EDIT_FRAME::EditSheetProperties( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
|
2024-03-17 13:02:07 +00:00
|
|
|
bool* aClearAnnotationNewItems,
|
|
|
|
bool* aUpdateHierarchyNavigator )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2021-05-27 18:04:56 +00:00
|
|
|
if( aSheet == nullptr || aHierarchy == nullptr )
|
2009-12-15 21:11:05 +00:00
|
|
|
return false;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-08-05 21:02:41 +00:00
|
|
|
// Get the new texts
|
2024-03-17 13:02:07 +00:00
|
|
|
DIALOG_SHEET_PROPERTIES dlg( this, aSheet, aClearAnnotationNewItems,
|
|
|
|
aUpdateHierarchyNavigator );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return false;
|
|
|
|
|
2024-02-05 19:10:22 +00:00
|
|
|
m_toolManager->ProcessEvent( EVENTS::SelectedItemsModified );
|
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-16 13:42:40 +00:00
|
|
|
void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard()
|
2019-05-28 18:44:14 +00:00
|
|
|
{
|
2023-02-19 03:40:07 +00:00
|
|
|
wxRect drawArea;
|
2019-05-31 17:37:07 +00:00
|
|
|
BASE_SCREEN* screen = GetScreen();
|
2019-05-28 18:44:14 +00:00
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
drawArea.SetSize( ToWxSize( GetPageSizeIU() ) );
|
2019-05-28 18:44:14 +00:00
|
|
|
|
|
|
|
// Calculate a reasonable dc size, in pixels, and the dc scale to fit
|
|
|
|
// the drawings into the dc size
|
|
|
|
// scale is the ratio resolution (in PPI) / internal units
|
|
|
|
double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
|
2022-09-16 23:25:07 +00:00
|
|
|
double inch2Iu = 1000.0 * schIUScale.IU_PER_MILS;
|
2020-06-13 21:42:35 +00:00
|
|
|
double scale = ppi / inch2Iu;
|
2019-05-28 18:44:14 +00:00
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
wxSize dcsize = drawArea.GetSize();
|
2019-05-28 18:44:14 +00:00
|
|
|
|
|
|
|
int maxdim = std::max( dcsize.x, dcsize.y );
|
|
|
|
|
2020-06-13 21:42:35 +00:00
|
|
|
// the max size in pixels of the bitmap used to build the sheet copy
|
|
|
|
const int maxbitmapsize = 5600;
|
2019-05-28 18:44:14 +00:00
|
|
|
|
|
|
|
while( int( maxdim * scale ) > maxbitmapsize )
|
|
|
|
{
|
|
|
|
ppi = ppi / 1.5;
|
|
|
|
scale = ppi / inch2Iu;
|
|
|
|
}
|
|
|
|
|
|
|
|
dcsize.x *= scale;
|
|
|
|
dcsize.y *= scale;
|
|
|
|
|
|
|
|
// Set draw offset, zoom... to values needed to draw in the memory DC
|
|
|
|
// after saving initial values:
|
2022-01-01 01:36:41 +00:00
|
|
|
VECTOR2I tmp_startvisu = screen->m_StartVisu;
|
|
|
|
VECTOR2I old_org = screen->m_DrawOrg;
|
|
|
|
screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
|
2019-05-28 18:44:14 +00:00
|
|
|
screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
|
|
|
|
|
|
|
|
wxMemoryDC dc;
|
|
|
|
wxBitmap image( dcsize );
|
|
|
|
dc.SelectObject( image );
|
2020-06-13 21:42:35 +00:00
|
|
|
dc.Clear();
|
2019-05-28 18:44:14 +00:00
|
|
|
|
|
|
|
GRResetPenAndBrush( &dc );
|
|
|
|
GRForceBlackPen( false );
|
|
|
|
dc.SetUserScale( scale, scale );
|
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
KIGFX::SCH_RENDER_SETTINGS* cfg = GetRenderSettings();
|
|
|
|
|
|
|
|
cfg->SetPrintDC( &dc );
|
|
|
|
|
2021-05-30 22:56:24 +00:00
|
|
|
// Init the color of the layer actually used to print the drawing sheet:
|
2022-10-22 20:32:10 +00:00
|
|
|
cfg->SetLayerColor( LAYER_DRAWINGSHEET, cfg->GetLayerColor( LAYER_SCHEMATIC_DRAWINGSHEET ) );
|
|
|
|
|
|
|
|
cfg->SetDefaultFont( eeconfig()->m_Appearance.default_font );
|
2020-04-14 12:25:00 +00:00
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
PrintPage( cfg );
|
2020-04-14 12:25:00 +00:00
|
|
|
|
2023-06-12 20:26:27 +00:00
|
|
|
// Deselect Bitmap from DC before using the bitmap
|
|
|
|
dc.SelectObject( wxNullBitmap );
|
|
|
|
|
2019-05-28 18:44:14 +00:00
|
|
|
{
|
2021-01-29 19:13:12 +00:00
|
|
|
wxLogNull doNotLog; // disable logging of failed clipboard actions
|
|
|
|
|
|
|
|
if( wxTheClipboard->Open() )
|
|
|
|
{
|
|
|
|
// This data objects are held by the clipboard, so do not delete them in the app.
|
|
|
|
wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
|
|
|
|
wxTheClipboard->SetData( clipbrd_data );
|
2021-05-01 22:00:08 +00:00
|
|
|
wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
|
2021-01-29 19:13:12 +00:00
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
2019-05-28 18:44:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GRForceBlackPen( false );
|
|
|
|
|
|
|
|
screen->m_StartVisu = tmp_startvisu;
|
|
|
|
screen->m_DrawOrg = old_org;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
bool SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes( const wxString& aSchematicFileName )
|
2019-11-17 16:43:05 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SCREENS screens( Schematic().Root() );
|
2019-11-17 16:43:05 +00:00
|
|
|
wxFileName fn = aSchematicFileName;
|
|
|
|
|
|
|
|
wxCHECK( fn.IsAbsolute(), false );
|
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
if( eeconfig()->m_Appearance.show_sheet_filename_case_sensitivity_dialog
|
2019-11-17 16:43:05 +00:00
|
|
|
&& screens.CanCauseCaseSensitivityIssue( aSchematicFileName ) )
|
|
|
|
{
|
2021-06-16 22:35:00 +00:00
|
|
|
msg.Printf( _( "The file name '%s' can cause issues with an existing file name\n"
|
2019-11-17 16:43:05 +00:00
|
|
|
"already defined in the schematic on systems that support case\n"
|
|
|
|
"insensitive file names. This will cause issues if you copy this\n"
|
|
|
|
"project to an operating system that supports case insensitive file\n"
|
|
|
|
"names.\n\nDo you wish to continue?" ),
|
|
|
|
fn.GetName() );
|
|
|
|
|
|
|
|
wxRichMessageDialog dlg( this, msg, _( "Warning" ),
|
|
|
|
wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION );
|
|
|
|
dlg.ShowCheckBox( _( "Do not show this message again." ) );
|
|
|
|
dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Create New Sheet" ) ),
|
2021-05-27 18:04:56 +00:00
|
|
|
wxMessageDialog::ButtonLabel( _( "Discard New Sheet" ) ) );
|
2019-11-17 16:43:05 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_NO )
|
|
|
|
return false;
|
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
eeconfig()->m_Appearance.show_sheet_filename_case_sensitivity_dialog =
|
|
|
|
!dlg.IsCheckBoxChecked();
|
2019-11-17 16:43:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|