2011-10-15 13:25:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-07-26 10:03:24 +00:00
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2020-01-19 18:01:09 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-15 13:25:57 +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
|
|
|
|
*/
|
|
|
|
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <base_units.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <class_library.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <confirm.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <connection_graph.h>
|
|
|
|
#include <dialog_symbol_remap.h>
|
|
|
|
#include <dialogs/dialog_schematic_find.h>
|
|
|
|
#include <eeschema_config.h>
|
|
|
|
#include <eeschema_id.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <executable_names.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <general.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gestfich.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <gr_basic.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <hierarch.h>
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
#include <html_messagebox.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <invoke_sch_dialog.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <kiface_i.h>
|
|
|
|
#include <kiway.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <lib_edit_frame.h>
|
|
|
|
#include <lib_view_frame.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <pgm_base.h>
|
2019-04-11 03:29:17 +00:00
|
|
|
#include <profile.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <project.h>
|
2020-06-20 14:36:16 +00:00
|
|
|
#include <project/project_file.h>
|
2018-02-17 11:43:56 +00:00
|
|
|
#include <reporter.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <sch_edit_frame.h>
|
|
|
|
#include <sch_painter.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_sheet.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2020-06-20 14:36:16 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <advanced_config.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <sim/sim_plot_frame.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <symbol_lib_table.h>
|
2020-08-06 23:03:58 +00:00
|
|
|
#include <tool/action_manager.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
|
|
|
#include <tool/common_control.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <tool/common_tools.h>
|
2020-08-06 23:03:58 +00:00
|
|
|
#include <tool/editor_conditions.h>
|
2019-07-15 23:44:01 +00:00
|
|
|
#include <tool/picker_tool.h>
|
2020-08-06 23:03:58 +00:00
|
|
|
#include <tool/selection.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
|
|
|
#include <tool/tool_manager.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <tool/zoom_tool.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <tools/ee_actions.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <tools/ee_inspection_tool.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <tools/ee_point_editor.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <tools/ee_selection_tool.h>
|
2019-05-07 18:49:53 +00:00
|
|
|
#include <tools/sch_drawing_tools.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <tools/sch_edit_tool.h>
|
|
|
|
#include <tools/sch_editor_control.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <tools/sch_line_wire_bus_tool.h>
|
|
|
|
#include <tools/sch_move_tool.h>
|
2020-05-20 01:31:47 +00:00
|
|
|
#include <widgets/infobar.h>
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2020-04-19 18:28:36 +00:00
|
|
|
#include <wx/cmdline.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// non-member so it can be moved easily, and kept REALLY private.
|
|
|
|
// Do NOT Clear() in here.
|
|
|
|
static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
|
|
|
|
{
|
|
|
|
for( unsigned i=0; i<aSrc.GetCount(); ++i )
|
|
|
|
aDst->AddPaths( aSrc[i], aIndex );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----<SCH "data on demand" functions>-------------------------------------------
|
|
|
|
|
|
|
|
SEARCH_STACK* PROJECT::SchSearchS()
|
|
|
|
{
|
|
|
|
SEARCH_STACK* ss = (SEARCH_STACK*) GetElem( PROJECT::ELEM_SCH_SEARCH_STACK );
|
|
|
|
|
|
|
|
wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
|
|
|
|
|
|
|
|
if( !ss )
|
|
|
|
{
|
|
|
|
ss = new SEARCH_STACK();
|
|
|
|
|
|
|
|
// Make PROJECT the new SEARCH_STACK owner.
|
|
|
|
SetElem( PROJECT::ELEM_SCH_SEARCH_STACK, ss );
|
|
|
|
|
|
|
|
// to the empty SEARCH_STACK for SchSearchS(), add project dir as first
|
|
|
|
ss->AddPaths( m_project_name.GetPath() );
|
|
|
|
|
|
|
|
// next add the paths found in *.pro, variable "LibDir"
|
|
|
|
wxString libDir;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
PART_LIBS::LibNamesAndPaths( this, false, &libDir );
|
|
|
|
}
|
2020-08-18 14:17:16 +00:00
|
|
|
catch( const IO_ERROR& )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !!libDir )
|
|
|
|
{
|
|
|
|
wxArrayString paths;
|
|
|
|
|
|
|
|
SEARCH_STACK::Split( &paths, libDir );
|
|
|
|
|
|
|
|
for( unsigned i =0; i<paths.GetCount(); ++i )
|
|
|
|
{
|
|
|
|
wxString path = AbsolutePath( paths[i] );
|
|
|
|
|
|
|
|
ss->AddPaths( path ); // at the end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// append all paths from aSList
|
|
|
|
add_search_paths( ss, Kiface().KifaceSearch(), -1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ss;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PART_LIBS* PROJECT::SchLibs()
|
|
|
|
{
|
2018-09-15 11:05:54 +00:00
|
|
|
PART_LIBS* libs = (PART_LIBS*) GetElem( PROJECT::ELEM_SCH_PART_LIBS );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2018-09-15 11:05:54 +00:00
|
|
|
wxASSERT( !libs || libs->Type() == PART_LIBS_T );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
if( !libs )
|
|
|
|
{
|
|
|
|
libs = new PART_LIBS();
|
|
|
|
|
|
|
|
// Make PROJECT the new PART_LIBS owner.
|
|
|
|
SetElem( PROJECT::ELEM_SCH_PART_LIBS, libs );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
libs->LoadAllLibraries( this );
|
|
|
|
}
|
|
|
|
catch( const PARSE_ERROR& pe )
|
|
|
|
{
|
|
|
|
wxString lib_list = UTF8( pe.inputLine );
|
2018-09-13 20:05:24 +00:00
|
|
|
wxWindow* parent = Pgm().App().GetTopWindow();
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
// parent of this dialog cannot be NULL since that breaks the Kiway() chain.
|
|
|
|
HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
|
|
|
|
|
|
|
|
dlg.MessageSet( _( "The following libraries were not found:" ) );
|
|
|
|
|
|
|
|
dlg.ListSet( lib_list );
|
|
|
|
|
|
|
|
dlg.Layout();
|
|
|
|
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
2018-09-13 20:05:24 +00:00
|
|
|
wxWindow* parent = Pgm().App().GetTopWindow();
|
|
|
|
|
|
|
|
DisplayError( parent, ioe.What() );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return libs;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----</SCH "data on demand" functions>------------------------------------------
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
|
|
|
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, EDA_DRAW_FRAME::OnSockRequestServer )
|
|
|
|
EVT_SOCKET( ID_EDA_SOCKET_EVENT, EDA_DRAW_FRAME::OnSockRequest )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_CLOSE( SCH_EDIT_FRAME::OnCloseWindow )
|
|
|
|
EVT_SIZE( SCH_EDIT_FRAME::OnSize )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2018-08-20 13:46:38 +00:00
|
|
|
EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, SCH_EDIT_FRAME::OnLoadFile )
|
2020-02-25 15:46:56 +00:00
|
|
|
EVT_MENU( ID_FILE_LIST_CLEAR, SCH_EDIT_FRAME::OnClearFileHistory )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2013-01-24 17:46:37 +00:00
|
|
|
EVT_MENU( ID_APPEND_PROJECT, SCH_EDIT_FRAME::OnAppendProject )
|
2017-09-20 14:20:38 +00:00
|
|
|
EVT_MENU( ID_IMPORT_NON_KICAD_SCH, SCH_EDIT_FRAME::OnImportProject )
|
2013-01-24 17:46:37 +00:00
|
|
|
|
2019-05-26 22:22:03 +00:00
|
|
|
EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
|
2019-06-25 04:44:34 +00:00
|
|
|
EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2018-09-04 00:00:17 +00:00
|
|
|
EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings )
|
2007-05-06 16:03:28 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
|
2014-04-19 18:47:20 +00:00
|
|
|
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
|
2020-05-24 14:46:05 +00:00
|
|
|
m_highlightedConn( nullptr ),
|
2019-07-02 20:09:23 +00:00
|
|
|
m_item_to_repeat( nullptr )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-06-20 14:36:16 +00:00
|
|
|
m_schematic = new SCHEMATIC( nullptr );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_showBorderAndTitleBlock = true; // true to show sheet references
|
2011-10-15 13:25:57 +00:00
|
|
|
m_hasAutoSave = true;
|
2019-05-13 18:33:30 +00:00
|
|
|
m_AboutTitle = "Eeschema";
|
2013-06-07 20:56:55 +00:00
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
m_findReplaceDialog = nullptr;
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
// Give an icon
|
2011-09-09 19:30:59 +00:00
|
|
|
wxIcon icon;
|
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
|
|
|
|
SetIcon( icon );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2020-05-10 22:02:58 +00:00
|
|
|
LoadSettings( eeconfig() );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2020-06-20 14:36:16 +00:00
|
|
|
// Also links the schematic to the loaded project
|
2015-08-06 00:10:52 +00:00
|
|
|
CreateScreens();
|
|
|
|
|
2020-06-20 14:36:16 +00:00
|
|
|
// After schematic has been linked to project, SCHEMATIC_SETTINGS works
|
|
|
|
m_defaults = &m_schematic->Settings();
|
|
|
|
LoadProjectSettings();
|
|
|
|
|
2019-05-13 20:42:40 +00:00
|
|
|
setupTools();
|
2020-08-06 23:03:58 +00:00
|
|
|
setupUIConditions();
|
2008-02-26 01:07:38 +00:00
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
ReCreateOptToolbar();
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2020-05-21 17:22:12 +00:00
|
|
|
// Create the infobar
|
|
|
|
m_infoBar = new WX_INFOBAR( this, &m_auimgr );
|
2020-05-18 23:44:58 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
// Initialize common print setup dialog settings.
|
|
|
|
m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
|
|
|
|
m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
|
|
|
|
m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
|
|
|
|
m_pageSetupData.GetPrintData().SetNoCopies( 1 );
|
2010-02-02 15:01:09 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2020-05-18 23:44:58 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar,
|
|
|
|
EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
|
|
|
m_auimgr.AddPane( m_optionsToolBar,
|
|
|
|
EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
|
|
|
|
m_auimgr.AddPane( m_drawToolBar,
|
|
|
|
EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(2) );
|
2020-05-21 17:22:12 +00:00
|
|
|
m_auimgr.AddPane( m_infoBar,
|
|
|
|
EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
|
|
|
|
m_auimgr.AddPane( GetCanvas(),
|
2020-05-18 23:44:58 +00:00
|
|
|
EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
|
|
|
m_auimgr.AddPane( m_messagePanel,
|
|
|
|
EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
|
|
|
|
|
2020-05-21 17:22:12 +00:00
|
|
|
// Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
|
|
|
|
// hidding it.
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
// We don't want the infobar displayed right away
|
|
|
|
m_auimgr.GetPane( "InfoBar" ).Hide();
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2011-04-12 12:41:13 +00:00
|
|
|
|
2019-07-20 12:26:46 +00:00
|
|
|
GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
|
2016-03-31 06:28:16 +00:00
|
|
|
|
2020-08-20 14:33:12 +00:00
|
|
|
// This is used temporarily to fix a client size issue on GTK that causes zoom to fit
|
|
|
|
// to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
|
|
|
|
Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
if( GetCanvas() )
|
2020-04-23 11:44:56 +00:00
|
|
|
{
|
|
|
|
GetCanvas()->GetGAL()->SetAxesEnabled( false );
|
2020-05-13 02:00:37 +00:00
|
|
|
|
|
|
|
if( auto p = dynamic_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() ) )
|
|
|
|
p->SetSchematic( m_schematic );
|
2020-04-23 11:44:56 +00:00
|
|
|
}
|
2018-09-07 16:13:20 +00:00
|
|
|
|
2019-06-25 04:44:34 +00:00
|
|
|
InitExitKey();
|
|
|
|
|
2016-03-31 06:28:16 +00:00
|
|
|
// Net list generator
|
|
|
|
DefaultExecFlags();
|
2017-08-12 12:09:39 +00:00
|
|
|
|
2019-03-15 12:09:04 +00:00
|
|
|
UpdateTitle();
|
2019-12-19 14:11:11 +00:00
|
|
|
|
|
|
|
// Default shutdown reason until a file is loaded
|
|
|
|
SetShutdownBlockReason( _( "New schematic file is unsaved" ) );
|
2020-04-17 23:32:29 +00:00
|
|
|
|
|
|
|
// Ensure the window is on top
|
|
|
|
Raise();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-02-03 14:00:48 +00:00
|
|
|
// Shutdown all running tools
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ShutdownAllTools();
|
|
|
|
|
2019-05-10 16:48:46 +00:00
|
|
|
delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
|
2013-08-05 21:02:41 +00:00
|
|
|
|
2011-02-05 02:21:11 +00:00
|
|
|
SetScreen( NULL );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
delete m_schematic;
|
2020-08-08 20:52:57 +00:00
|
|
|
|
|
|
|
// Close the project if we are standalone, so it gets cleaned up properly
|
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
GetSettingsManager()->UnloadProject( &Prj() );
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2014-09-07 19:01:26 +00:00
|
|
|
|
2019-05-04 11:23:04 +00:00
|
|
|
void SCH_EDIT_FRAME::setupTools()
|
|
|
|
{
|
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
2020-05-23 15:50:08 +00:00
|
|
|
m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
|
2020-06-12 10:58:56 +00:00
|
|
|
GetCanvas()->GetViewControls(), config(), this );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_actions = new EE_ACTIONS();
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
|
|
|
|
|
|
|
// Register tools
|
2019-06-09 21:57:23 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
|
|
|
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolManager->RegisterTool( new EE_SELECTION_TOOL );
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolManager->RegisterTool( new PICKER_TOOL );
|
2019-05-07 18:49:53 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_DRAWING_TOOLS );
|
2019-06-16 13:42:40 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_LINE_WIRE_BUS_TOOL );
|
2019-05-04 13:02:05 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_MOVE_TOOL );
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_EDIT_TOOL );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolManager->RegisterTool( new EE_INSPECTION_TOOL );
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_EDITOR_CONTROL );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolManager->RegisterTool( new EE_POINT_EDITOR );
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
|
|
|
// Run the selection tool, it is supposed to be always active
|
2019-06-03 01:46:08 +00:00
|
|
|
m_toolManager->RunAction( EE_ACTIONS::selectionActivate );
|
2019-05-04 11:23:04 +00:00
|
|
|
|
|
|
|
GetCanvas()->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
void SCH_EDIT_FRAME::setupUIConditions()
|
|
|
|
{
|
|
|
|
SCH_BASE_FRAME::setupUIConditions();
|
|
|
|
|
|
|
|
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
|
|
|
|
EDITOR_CONDITIONS cond( this );
|
|
|
|
|
|
|
|
wxASSERT( mgr );
|
|
|
|
|
2020-08-20 23:05:21 +00:00
|
|
|
auto hasElements =
|
|
|
|
[ this ] ( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return !GetScreen()->Items().empty();
|
|
|
|
};
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
|
|
|
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::save, ENABLE( cond.ContentModified() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
|
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::acceleratedGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::standardGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) );
|
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::cut, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
|
|
|
|
mgr->SetConditions( ACTIONS::copy, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
|
|
|
|
mgr->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::Idle ) );
|
|
|
|
mgr->SetConditions( ACTIONS::pasteSpecial, ENABLE( SELECTION_CONDITIONS::Idle ) );
|
|
|
|
mgr->SetConditions( ACTIONS::doDelete, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
|
|
|
|
mgr->SetConditions( ACTIONS::duplicate, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
|
2020-08-20 23:05:21 +00:00
|
|
|
mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
|
|
|
|
|
|
|
auto showHiddenPinsCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return GetShowAllPins();
|
|
|
|
};
|
|
|
|
|
|
|
|
auto forceHVCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return eeconfig()->m_Drawing.hv_lines_only;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto remapSymbolsCondition =
|
|
|
|
[&]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
SCH_SCREENS schematic( Schematic().Root() );
|
|
|
|
|
|
|
|
// The remapping can only be performed on legacy projects.
|
|
|
|
return schematic.HasNoFullyDefinedLibIds();
|
|
|
|
};
|
|
|
|
|
|
|
|
auto belowRootSheetCondition =
|
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return GetCurrentSheet().Last() != &Schematic().Root();
|
|
|
|
};
|
|
|
|
|
|
|
|
mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleForceHV, CHECK( forceHVCond ) );
|
|
|
|
|
|
|
|
|
|
|
|
#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
|
|
|
|
|
|
|
|
CURRENT_TOOL( ACTIONS::deleteTool );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::highlightNetTool );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeSymbol );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placePower );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawWire );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawBus );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeBusWireEntry );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeNoConnect );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeJunction );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeLabel );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeGlobalLabel );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeHierLabel );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawSheet );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::importSheetPin );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawLines );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeSchematicText );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeImage );
|
|
|
|
|
|
|
|
#undef CURRENT_TOOL
|
|
|
|
#undef CHECK
|
|
|
|
#undef ENABLE
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-10 16:48:46 +00:00
|
|
|
void SCH_EDIT_FRAME::SaveCopyForRepeatItem( SCH_ITEM* aItem )
|
2013-08-05 21:02:41 +00:00
|
|
|
{
|
|
|
|
// we cannot store a pointer to an item in the display list here since
|
2019-07-02 20:09:23 +00:00
|
|
|
// that item may be deleted, such as part of a line concatenation or other.
|
2013-08-05 21:02:41 +00:00
|
|
|
// So simply always keep a copy of the object which is to be repeated.
|
|
|
|
|
2019-07-11 17:23:11 +00:00
|
|
|
if( aItem )
|
|
|
|
{
|
|
|
|
delete m_item_to_repeat;
|
2013-08-05 21:02:41 +00:00
|
|
|
|
2019-07-11 17:23:11 +00:00
|
|
|
m_item_to_repeat = (SCH_ITEM*) aItem->Clone();
|
|
|
|
// Clone() preserves the flags, we want 'em cleared.
|
|
|
|
m_item_to_repeat->ClearFlags();
|
|
|
|
}
|
2013-08-05 21:02:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
EDA_ITEM* SCH_EDIT_FRAME::GetItem( const KIID& aId )
|
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
return Schematic().GetSheets().GetItem( aId );
|
2020-04-24 13:36:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::SetSheetNumberAndCount()
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2015-11-03 19:44:05 +00:00
|
|
|
SCH_SCREEN* screen;
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SCREENS s_list( Schematic().Root() );
|
2008-04-30 17:04:22 +00:00
|
|
|
|
2020-02-22 21:39:59 +00:00
|
|
|
// Set the sheet count, and the sheet number (1 for root sheet)
|
2020-05-13 02:00:37 +00:00
|
|
|
int sheet_count = Schematic().Root().CountSheets();
|
|
|
|
int sheet_number = 1;
|
|
|
|
const KIID_PATH& current_sheetpath = GetCurrentSheet().Path();
|
2009-01-04 18:52:57 +00:00
|
|
|
|
|
|
|
// Examine all sheets path to find the current sheets path,
|
2009-11-04 20:46:53 +00:00
|
|
|
// and count them from root to the current sheet path:
|
2020-05-13 02:00:37 +00:00
|
|
|
for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
|
2008-04-30 17:04:22 +00:00
|
|
|
{
|
2020-02-22 21:39:59 +00:00
|
|
|
if( sheet.Path() == current_sheetpath ) // Current sheet path found
|
2009-01-04 18:52:57 +00:00
|
|
|
break;
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
sheet_number++; // Not found, increment before this current path
|
2008-04-30 17:04:22 +00:00
|
|
|
}
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
GetCurrentSheet().SetPageNumber( sheet_number );
|
2018-02-18 22:02:06 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
|
2012-05-27 00:19:12 +00:00
|
|
|
screen->m_NumberOfScreens = sheet_count;
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
GetScreen()->m_ScreenNumber = sheet_number;
|
2009-01-04 18:52:57 +00:00
|
|
|
}
|
2008-04-30 17:04:22 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_SCREEN* SCH_EDIT_FRAME::GetScreen() const
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
return GetCurrentSheet().LastScreen();
|
|
|
|
}
|
|
|
|
|
2019-05-20 18:54:44 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCHEMATIC& SCH_EDIT_FRAME::Schematic() const
|
|
|
|
{
|
|
|
|
return *m_schematic;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
|
2013-09-11 09:34:10 +00:00
|
|
|
wxString SCH_EDIT_FRAME::GetScreenDesc() const
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
wxString s = GetCurrentSheet().PathHumanReadable();
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
return s;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::CreateScreens()
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
m_schematic->Reset();
|
2020-06-08 02:19:46 +00:00
|
|
|
m_schematic->SetProject( &Prj() );
|
2020-07-03 03:42:36 +00:00
|
|
|
m_schematic->SetTemplateFieldNames( &m_templateFieldNames );
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
m_schematic->SetRoot( new SCH_SHEET( m_schematic ) );
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
m_defaults = &m_schematic->Settings();
|
|
|
|
|
2020-05-21 02:27:48 +00:00
|
|
|
SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
|
2020-05-13 02:00:37 +00:00
|
|
|
m_schematic->Root().SetScreen( rootScreen );
|
|
|
|
SetScreen( Schematic().RootScreen() );
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
m_schematic->RootScreen()->SetFileName( wxEmptyString );
|
2012-01-09 08:35:06 +00:00
|
|
|
|
2011-02-05 02:21:11 +00:00
|
|
|
if( GetScreen() == NULL )
|
2015-08-06 00:10:52 +00:00
|
|
|
{
|
2020-05-21 02:27:48 +00:00
|
|
|
SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
|
2015-08-06 00:10:52 +00:00
|
|
|
SetScreen( screen );
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SHEET_PATH& SCH_EDIT_FRAME::GetCurrentSheet() const
|
2011-12-08 21:05:43 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
return m_schematic->CurrentSheet();
|
2011-12-08 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::SetCurrentSheet( const SCH_SHEET_PATH& aSheet )
|
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
if( aSheet != GetCurrentSheet() )
|
2018-10-17 01:03:50 +00:00
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
FocusOnItem( nullptr );
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
Schematic().SetCurrentSheet( aSheet );
|
|
|
|
GetCanvas()->DisplaySheet( aSheet.LastScreen() );
|
2018-10-17 01:03:50 +00:00
|
|
|
}
|
2011-12-08 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-17 11:14:09 +00:00
|
|
|
void SCH_EDIT_FRAME::HardRedraw()
|
|
|
|
{
|
2020-07-27 20:55:08 +00:00
|
|
|
RecalculateConnections( LOCAL_CLEANUP );
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
FocusOnItem( nullptr );
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->ForceRefresh();
|
2018-10-17 11:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-12-19 14:11:11 +00:00
|
|
|
// Shutdown blocks must be determined and vetoed as early as possible
|
|
|
|
if( SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
|
2020-05-13 02:00:37 +00:00
|
|
|
&& Schematic().GetSheets().IsModified() )
|
2019-12-19 14:11:11 +00:00
|
|
|
{
|
|
|
|
aEvent.Veto();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
{
|
|
|
|
LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
|
|
|
|
if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
|
|
|
|
return;
|
|
|
|
|
|
|
|
LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
|
|
|
|
if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
|
|
|
|
return;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
|
2018-10-24 14:18:19 +00:00
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
|
|
|
|
return;
|
|
|
|
}
|
2011-04-07 17:48:26 +00:00
|
|
|
|
2016-08-29 17:47:08 +00:00
|
|
|
SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
|
|
|
|
|
|
|
|
if( simFrame && !simFrame->Close() ) // Can close the simulator?
|
|
|
|
return;
|
|
|
|
|
2020-08-11 22:56:47 +00:00
|
|
|
// We may have gotten multiple events; don't clean up twice
|
|
|
|
if( !Schematic().IsValid() )
|
|
|
|
return;
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
|
|
|
|
|
|
|
|
if( sheetlist.IsModified() )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
wxFileName fileName = Schematic().RootScreen()->GetFileName();
|
2019-06-17 15:59:39 +00:00
|
|
|
wxString msg = _( "Save changes to \"%s\" before closing?" );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2019-06-17 15:59:39 +00:00
|
|
|
if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
|
2018-08-11 20:46:03 +00:00
|
|
|
[&]()->bool { return SaveProject(); } ) )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2018-08-01 23:06:12 +00:00
|
|
|
aEvent.Veto();
|
|
|
|
return;
|
2008-02-26 01:07:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-11 23:06:48 +00:00
|
|
|
//
|
|
|
|
// OK, we're really closing now. No more returns after this.
|
|
|
|
//
|
2020-08-21 18:12:51 +00:00
|
|
|
m_shuttingDown = true;
|
2020-05-11 23:06:48 +00:00
|
|
|
|
|
|
|
// Shutdown all running tools ( and commit any pending change )
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ShutdownAllTools();
|
|
|
|
|
2014-08-29 17:49:49 +00:00
|
|
|
// Close the find dialog and preserve it's setting if it is displayed.
|
2019-05-19 21:04:04 +00:00
|
|
|
if( m_findReplaceDialog )
|
2011-11-10 17:01:33 +00:00
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
m_findStringHistoryList = m_findReplaceDialog->GetFindEntries();
|
|
|
|
m_replaceStringHistoryList = m_findReplaceDialog->GetReplaceEntries();
|
|
|
|
|
2019-05-23 17:31:10 +00:00
|
|
|
m_findReplaceDialog->Destroy();
|
|
|
|
m_findReplaceDialog = nullptr;
|
2011-11-10 17:01:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-08 14:01:22 +00:00
|
|
|
if( FindHierarchyNavigator() )
|
|
|
|
FindHierarchyNavigator()->Close( true );
|
2019-10-24 17:07:01 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SCREENS screens( Schematic().Root() );
|
2011-10-15 13:25:57 +00:00
|
|
|
wxFileName fn;
|
|
|
|
|
|
|
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
|
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
fn = Prj().AbsolutePath( screen->GetFileName() );
|
2011-10-15 13:25:57 +00:00
|
|
|
|
2019-03-18 12:22:33 +00:00
|
|
|
// Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
|
|
|
|
fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
|
2011-10-15 13:25:57 +00:00
|
|
|
|
|
|
|
if( fn.FileExists() && fn.IsFileWritable() )
|
|
|
|
wxRemoveFile( fn.GetFullPath() );
|
|
|
|
}
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
sheetlist.ClearModifyStatus();
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
UpdateFileHistory( fileName );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
Schematic().RootScreen()->Clear();
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2014-01-29 17:01:42 +00:00
|
|
|
// all sub sheets are deleted, only the main sheet is usable
|
2020-05-13 02:00:37 +00:00
|
|
|
GetCurrentSheet().clear();
|
2014-01-29 17:01:42 +00:00
|
|
|
|
2020-08-08 20:52:57 +00:00
|
|
|
// Clear view before destroying schematic as repaints depend on schematic being valid
|
|
|
|
SetScreen( nullptr );
|
|
|
|
|
2020-07-03 13:40:31 +00:00
|
|
|
GetSettingsManager()->SaveProject();
|
|
|
|
Schematic().SetTemplateFieldNames( nullptr );
|
|
|
|
Schematic().Reset();
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2019-11-13 19:15:11 +00:00
|
|
|
// Filename is rootSheetName-sheetName-...-sheetName
|
|
|
|
// Note that we need to fetch the rootSheetName out of its filename, as the root SCH_SHEET's
|
|
|
|
// name is just a timestamp.
|
2009-01-08 20:29:07 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
wxFileName rootFn( GetCurrentSheet().at( 0 )->GetFileName() );
|
2019-11-13 19:15:11 +00:00
|
|
|
wxString filename = rootFn.GetName();
|
2013-05-19 19:35:49 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
for( unsigned i = 1; i < GetCurrentSheet().size(); i++ )
|
|
|
|
filename += wxT( "-" ) + GetCurrentSheet().at( i )->GetName();
|
2009-01-08 20:29:07 +00:00
|
|
|
|
|
|
|
return filename;
|
|
|
|
}
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2011-10-15 13:25:57 +00:00
|
|
|
|
2011-10-28 20:30:50 +00:00
|
|
|
void SCH_EDIT_FRAME::OnModify()
|
2010-02-18 20:07:29 +00:00
|
|
|
{
|
2020-02-07 09:02:47 +00:00
|
|
|
wxASSERT( GetScreen() );
|
|
|
|
|
|
|
|
if( !GetScreen() )
|
|
|
|
return;
|
|
|
|
|
2010-10-26 20:25:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2011-10-15 13:25:57 +00:00
|
|
|
GetScreen()->SetSave();
|
2010-02-18 20:07:29 +00:00
|
|
|
|
2019-04-29 21:44:49 +00:00
|
|
|
if( ADVANCED_CFG::GetCfg().m_realTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
|
2019-11-10 23:24:27 +00:00
|
|
|
RecalculateConnections( NO_CLEANUP );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-05-31 17:37:07 +00:00
|
|
|
GetCanvas()->Refresh();
|
2010-02-18 20:07:29 +00:00
|
|
|
}
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-12-21 20:21:15 +00:00
|
|
|
|
2016-01-29 10:24:39 +00:00
|
|
|
void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
|
2018-02-16 18:26:11 +00:00
|
|
|
{
|
2019-05-23 18:25:07 +00:00
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
{
|
2019-07-02 20:09:23 +00:00
|
|
|
DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
|
|
|
|
" in stand-alone mode. In order to create/update PCBs from"
|
|
|
|
" schematics, launch the Kicad shell and create a project." ) );
|
2019-05-23 18:25:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-10 16:59:06 +00:00
|
|
|
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
|
2019-05-23 18:25:07 +00:00
|
|
|
|
2020-07-10 16:59:06 +00:00
|
|
|
if( !frame )
|
2019-05-24 19:41:29 +00:00
|
|
|
{
|
2020-07-10 16:59:06 +00:00
|
|
|
wxFileName fn = Prj().GetProjectFullName();
|
|
|
|
fn.SetExt( PcbFileExtension );
|
|
|
|
|
|
|
|
frame = Kiway().Player( FRAME_PCB_EDITOR, true );
|
2019-05-24 19:41:29 +00:00
|
|
|
frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
|
|
|
|
}
|
|
|
|
|
2020-07-10 16:59:06 +00:00
|
|
|
if( !frame->IsVisible() )
|
|
|
|
frame->Show( true );
|
|
|
|
|
2019-05-23 18:25:07 +00:00
|
|
|
// On Windows, Raise() does not bring the window on screen, when iconized
|
|
|
|
if( frame->IsIconized() )
|
|
|
|
frame->Iconize( false );
|
|
|
|
|
|
|
|
frame->Raise();
|
|
|
|
|
2019-03-27 22:37:26 +00:00
|
|
|
std::string payload;
|
2019-09-05 22:00:47 +00:00
|
|
|
Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE, payload, this );
|
2016-01-29 10:24:39 +00:00
|
|
|
}
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
wxFindReplaceData* SCH_EDIT_FRAME::GetFindReplaceData()
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
if( m_findReplaceDialog && m_findReplaceDialog->IsVisible()
|
|
|
|
&& !m_findReplaceData->GetFindString().IsEmpty() )
|
|
|
|
{
|
|
|
|
return m_findReplaceData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-01-08 14:01:22 +00:00
|
|
|
|
|
|
|
HIERARCHY_NAVIG_DLG* SCH_EDIT_FRAME::FindHierarchyNavigator()
|
2019-10-24 17:07:01 +00:00
|
|
|
{
|
2020-01-08 14:01:22 +00:00
|
|
|
wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
|
2019-10-24 17:07:01 +00:00
|
|
|
|
2020-01-08 14:01:22 +00:00
|
|
|
return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aForceUpdate )
|
|
|
|
{
|
2019-10-24 17:07:01 +00:00
|
|
|
if( aForceUpdate )
|
|
|
|
{
|
2020-01-08 14:01:22 +00:00
|
|
|
if( FindHierarchyNavigator() )
|
|
|
|
FindHierarchyNavigator()->Close();
|
|
|
|
|
|
|
|
HIERARCHY_NAVIG_DLG* hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
|
2019-10-24 17:07:01 +00:00
|
|
|
|
2020-01-08 14:01:22 +00:00
|
|
|
hierarchyDialog->Show( true );
|
2019-10-24 17:07:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-08 14:01:22 +00:00
|
|
|
if( FindHierarchyNavigator() )
|
|
|
|
FindHierarchyNavigator()->UpdateHierarchyTree();
|
2019-10-24 17:07:01 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2020-01-08 14:01:22 +00:00
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace )
|
|
|
|
{
|
2019-05-23 17:31:10 +00:00
|
|
|
if( m_findReplaceDialog )
|
|
|
|
m_findReplaceDialog->Destroy();
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2019-05-23 17:31:10 +00:00
|
|
|
m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition,
|
|
|
|
wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
|
2011-11-10 17:01:33 +00:00
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
m_findReplaceDialog->SetFindEntries( m_findStringHistoryList );
|
|
|
|
m_findReplaceDialog->SetReplaceEntries( m_replaceStringHistoryList );
|
|
|
|
m_findReplaceDialog->Show( true );
|
2010-03-16 18:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-20 01:31:47 +00:00
|
|
|
void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2020-05-20 01:31:47 +00:00
|
|
|
// Prepare the infobar, since we don't know its state
|
|
|
|
m_infoBar->RemoveAllButtons();
|
|
|
|
m_infoBar->AddCloseButton();
|
2011-02-03 21:57:02 +00:00
|
|
|
|
2020-05-20 01:31:47 +00:00
|
|
|
m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
|
2019-05-19 21:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::ClearFindReplaceStatus()
|
|
|
|
{
|
2020-05-20 01:31:47 +00:00
|
|
|
m_infoBar->Dismiss();
|
2019-05-19 21:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnFindDialogClose()
|
|
|
|
{
|
|
|
|
m_findStringHistoryList = m_findReplaceDialog->GetFindEntries();
|
|
|
|
m_replaceStringHistoryList = m_findReplaceDialog->GetReplaceEntries();
|
2019-05-23 17:31:10 +00:00
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
m_findReplaceDialog->Destroy();
|
2019-05-23 17:31:10 +00:00
|
|
|
m_findReplaceDialog = nullptr;
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
|
2008-02-27 19:38:16 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
if( fn.size() )
|
|
|
|
OpenProjectFiles( std::vector<wxString>( 1, fn ) );
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
2008-05-07 15:08:16 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2020-02-25 15:46:56 +00:00
|
|
|
void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
ClearFileHistory();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-24 23:36:31 +00:00
|
|
|
void SCH_EDIT_FRAME::NewProject()
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2015-09-25 19:38:09 +00:00
|
|
|
wxString pro_dir = m_mruPath;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2020-03-16 13:04:50 +00:00
|
|
|
wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
|
|
|
|
LegacySchematicFileWildcard(), wxFD_SAVE );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_CANCEL )
|
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// Enforce the extension, wxFileDialog is inept.
|
|
|
|
wxFileName create_me = dlg.GetPath();
|
2020-04-16 16:43:50 +00:00
|
|
|
create_me.SetExt( KiCadSchematicFileExtension );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
if( create_me.FileExists() )
|
|
|
|
{
|
2018-09-09 21:06:38 +00:00
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpenProjectFiles() requires absolute
|
2018-09-09 21:06:38 +00:00
|
|
|
wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
|
2015-09-25 19:38:09 +00:00
|
|
|
m_mruPath = create_me.GetPath();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2019-05-24 23:36:31 +00:00
|
|
|
void SCH_EDIT_FRAME::LoadProject()
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2015-09-25 19:38:09 +00:00
|
|
|
wxString pro_dir = m_mruPath;
|
2020-04-16 16:43:50 +00:00
|
|
|
wxString wildcards = KiCadSchematicFileWildcard();
|
2020-03-25 15:27:15 +00:00
|
|
|
|
2020-04-16 16:43:50 +00:00
|
|
|
wildcards += "|" + LegacySchematicFileWildcard();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2020-03-16 13:04:50 +00:00
|
|
|
wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
|
2020-03-25 15:27:15 +00:00
|
|
|
wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_CANCEL )
|
|
|
|
{
|
|
|
|
OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
|
2015-09-25 19:38:09 +00:00
|
|
|
m_mruPath = Prj().GetProjectPath();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2015-07-19 14:38:02 +00:00
|
|
|
if( kicad_board.IsOk() )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2015-07-19 14:38:02 +00:00
|
|
|
kicad_board.SetExt( PcbFileExtension );
|
|
|
|
wxFileName legacy_board( kicad_board );
|
|
|
|
legacy_board.SetExt( LegacyPcbFileExtension );
|
2019-05-20 10:23:32 +00:00
|
|
|
wxFileName& boardfn = legacy_board;
|
|
|
|
|
|
|
|
if( !legacy_board.FileExists() || kicad_board.FileExists() )
|
|
|
|
boardfn = kicad_board;
|
2010-05-11 14:35:13 +00:00
|
|
|
|
2014-04-20 04:35:34 +00:00
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
{
|
2015-07-19 14:38:02 +00:00
|
|
|
wxString filename = QuoteFullPath( boardfn );
|
2014-04-20 04:35:34 +00:00
|
|
|
ExecuteFile( this, PCBNEW_EXE, filename );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-10 16:59:06 +00:00
|
|
|
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
|
2014-04-20 04:35:34 +00:00
|
|
|
|
2020-07-10 16:59:06 +00:00
|
|
|
if( !frame )
|
2014-04-20 04:35:34 +00:00
|
|
|
{
|
2020-07-10 16:59:06 +00:00
|
|
|
frame = Kiway().Player( FRAME_PCB_EDITOR, true );
|
2015-07-19 14:38:02 +00:00
|
|
|
frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
|
2014-04-20 04:35:34 +00:00
|
|
|
}
|
2015-06-23 10:59:38 +00:00
|
|
|
|
2020-07-10 16:59:06 +00:00
|
|
|
if( !frame->IsVisible() )
|
|
|
|
frame->Show( true );
|
|
|
|
|
2015-06-23 10:59:38 +00:00
|
|
|
// On Windows, Raise() does not bring the window on screen, when iconized
|
|
|
|
if( frame->IsIconized() )
|
|
|
|
frame->Iconize( false );
|
|
|
|
|
|
|
|
frame->Raise();
|
2014-04-20 04:35:34 +00:00
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
else
|
2011-10-28 20:30:50 +00:00
|
|
|
{
|
2008-02-27 19:38:16 +00:00
|
|
|
ExecuteFile( this, PCBNEW_EXE );
|
2011-10-28 20:30:50 +00:00
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.SetExt( NetlistFileExtension );
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2020-05-23 17:14:05 +00:00
|
|
|
if( !ReadyToNetlist() )
|
2017-11-27 16:11:12 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
try
|
2011-10-28 20:30:50 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
|
|
|
|
|
|
|
|
if( !player )
|
|
|
|
{
|
|
|
|
player = Kiway().Player( FRAME_CVPCB, true );
|
|
|
|
player->Show( true );
|
|
|
|
}
|
2015-04-08 12:50:36 +00:00
|
|
|
|
2019-03-17 19:15:08 +00:00
|
|
|
sendNetlistToCvpcb();
|
2015-06-07 18:18:45 +00:00
|
|
|
|
2015-09-08 18:45:11 +00:00
|
|
|
player->Raise();
|
2011-10-28 20:30:50 +00:00
|
|
|
}
|
2018-04-18 07:10:29 +00:00
|
|
|
catch( const IO_ERROR& )
|
2017-11-27 16:11:12 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Could not open CvPcb" ) );
|
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2014-02-21 00:06:37 +00:00
|
|
|
|
2019-05-26 22:22:03 +00:00
|
|
|
void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
|
|
|
|
{
|
2019-06-25 04:44:34 +00:00
|
|
|
if( event.GetId() == wxID_EXIT )
|
|
|
|
Kiway().OnKiCadExit();
|
|
|
|
|
|
|
|
if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
|
|
|
|
Close( false );
|
2019-05-26 22:22:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
void SCH_EDIT_FRAME::PrintPage( RENDER_SETTINGS* aSettings )
|
2011-03-28 19:26:31 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY );
|
|
|
|
GetScreen()->Print( aSettings );
|
|
|
|
PrintWorkSheet( aSettings, GetScreen(), IU_PER_MILS, fileName );
|
2011-03-28 19:26:31 +00:00
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
|
2011-10-15 13:25:57 +00:00
|
|
|
bool SCH_EDIT_FRAME::isAutoSaveRequired() const
|
|
|
|
{
|
2014-08-23 15:22:50 +00:00
|
|
|
// In case this event happens before g_RootSheet is initialized which does happen
|
|
|
|
// on mingw64 builds.
|
2016-02-15 20:19:22 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
if( Schematic().IsValid() )
|
2014-08-23 15:22:50 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SCREENS screenList( Schematic().Root() );
|
2016-02-15 20:19:22 +00:00
|
|
|
|
2017-07-26 10:03:24 +00:00
|
|
|
for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
|
|
|
|
{
|
|
|
|
if( screen->IsSave() )
|
|
|
|
return true;
|
|
|
|
}
|
2014-08-23 15:22:50 +00:00
|
|
|
}
|
2014-08-23 19:36:22 +00:00
|
|
|
|
|
|
|
return false;
|
2011-10-15 13:25:57 +00:00
|
|
|
}
|
2012-01-04 22:08:46 +00:00
|
|
|
|
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_SCREEN* aScreen, SCH_ITEM* aItem,
|
|
|
|
bool aUndoAppend )
|
2012-01-04 22:08:46 +00:00
|
|
|
{
|
2019-07-02 20:09:23 +00:00
|
|
|
wxCHECK_RET( aItem != NULL, wxT( "Cannot add null item to list." ) );
|
2012-01-04 22:08:46 +00:00
|
|
|
|
2018-10-24 15:08:21 +00:00
|
|
|
SCH_SHEET* parentSheet = nullptr;
|
|
|
|
SCH_COMPONENT* parentComponent = nullptr;
|
2019-04-15 14:34:58 +00:00
|
|
|
SCH_ITEM* undoItem = aItem;
|
2012-01-04 22:08:46 +00:00
|
|
|
|
2019-04-15 14:34:58 +00:00
|
|
|
if( aItem->Type() == SCH_SHEET_PIN_T )
|
2012-01-04 22:08:46 +00:00
|
|
|
{
|
2019-04-15 14:34:58 +00:00
|
|
|
parentSheet = (SCH_SHEET*) aItem->GetParent();
|
2012-01-04 22:08:46 +00:00
|
|
|
|
2018-10-24 15:08:21 +00:00
|
|
|
wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
|
2012-01-04 22:08:46 +00:00
|
|
|
wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
|
|
|
|
|
2018-10-24 15:08:21 +00:00
|
|
|
undoItem = parentSheet;
|
2012-01-04 22:08:46 +00:00
|
|
|
}
|
|
|
|
|
2019-04-15 14:34:58 +00:00
|
|
|
else if( aItem->Type() == SCH_FIELD_T )
|
2012-10-23 16:37:19 +00:00
|
|
|
{
|
2019-04-15 14:34:58 +00:00
|
|
|
parentComponent = (SCH_COMPONENT*) aItem->GetParent();
|
2012-10-23 16:37:19 +00:00
|
|
|
|
2018-10-24 15:08:21 +00:00
|
|
|
wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
|
2012-10-23 16:37:19 +00:00
|
|
|
wxT( "Cannot place field in invalid schematic component object." ) );
|
|
|
|
|
2018-10-24 15:08:21 +00:00
|
|
|
undoItem = parentComponent;
|
2012-10-23 16:37:19 +00:00
|
|
|
}
|
|
|
|
|
2019-04-15 14:34:58 +00:00
|
|
|
if( aItem->IsNew() )
|
2012-01-04 22:08:46 +00:00
|
|
|
{
|
2019-05-03 11:49:59 +00:00
|
|
|
if( aItem->Type() == SCH_SHEET_PIN_T )
|
2018-10-24 15:08:21 +00:00
|
|
|
{
|
|
|
|
// Sheet pins are owned by their parent sheet.
|
2020-07-13 11:21:40 +00:00
|
|
|
SaveCopyInUndoList( aScreen, undoItem, UR_CHANGED, aUndoAppend );
|
2018-10-24 15:08:21 +00:00
|
|
|
|
2019-04-15 14:34:58 +00:00
|
|
|
parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
|
2018-10-24 15:08:21 +00:00
|
|
|
}
|
2019-04-15 14:34:58 +00:00
|
|
|
else if( aItem->Type() == SCH_FIELD_T )
|
2018-10-24 15:08:21 +00:00
|
|
|
{
|
|
|
|
// Component fields are also owned by their parent, but new component fields
|
|
|
|
// are handled elsewhere.
|
|
|
|
wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
|
|
|
|
}
|
2012-01-04 22:08:46 +00:00
|
|
|
else
|
|
|
|
{
|
2020-07-13 11:21:40 +00:00
|
|
|
if( !aScreen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
|
|
|
|
AddToScreen( aItem, aScreen );
|
2018-10-24 15:08:21 +00:00
|
|
|
|
2019-05-10 16:48:46 +00:00
|
|
|
SaveCopyForRepeatItem( aItem );
|
2020-07-13 11:21:40 +00:00
|
|
|
SaveCopyInUndoList( aScreen, undoItem, UR_NEW, aUndoAppend );
|
2012-01-04 22:08:46 +00:00
|
|
|
}
|
2018-09-03 10:11:39 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
// Update connectivity info for new item
|
2019-04-28 16:36:31 +00:00
|
|
|
if( !aItem->IsMoving() )
|
2019-11-10 23:24:27 +00:00
|
|
|
RecalculateConnections( LOCAL_CLEANUP );
|
2012-01-04 22:08:46 +00:00
|
|
|
}
|
|
|
|
|
2019-09-11 12:36:00 +00:00
|
|
|
aItem->ClearFlags( IS_NEW );
|
2018-10-14 22:09:59 +00:00
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
aScreen->SetModify();
|
2020-08-10 11:40:58 +00:00
|
|
|
UpdateItem( aItem );
|
2018-10-18 09:50:43 +00:00
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
if( !aItem->IsMoving() && aItem->IsConnectable() )
|
2017-11-27 19:27:24 +00:00
|
|
|
{
|
|
|
|
std::vector< wxPoint > pts;
|
2019-04-15 14:34:58 +00:00
|
|
|
aItem->GetConnectionPoints( pts );
|
2018-10-25 13:12:34 +00:00
|
|
|
|
2017-12-01 22:53:23 +00:00
|
|
|
for( auto i = pts.begin(); i != pts.end(); i++ )
|
2017-11-27 19:27:24 +00:00
|
|
|
{
|
2017-12-01 22:53:23 +00:00
|
|
|
for( auto j = i + 1; j != pts.end(); j++ )
|
2019-05-11 10:06:28 +00:00
|
|
|
TrimWire( *i, *j );
|
2017-12-01 22:53:23 +00:00
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
if( aScreen->IsJunctionNeeded( *i, true ) )
|
|
|
|
AddJunction( aScreen, *i, true, false );
|
2017-11-27 19:27:24 +00:00
|
|
|
}
|
2018-10-25 13:12:34 +00:00
|
|
|
|
2018-10-16 13:11:33 +00:00
|
|
|
TestDanglingEnds();
|
2019-08-21 14:02:16 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
for( SCH_ITEM* item : aItem->ConnectedItems( GetCurrentSheet() ) )
|
2020-08-10 11:40:58 +00:00
|
|
|
UpdateItem( item );
|
2017-11-27 19:27:24 +00:00
|
|
|
}
|
2012-01-04 22:08:46 +00:00
|
|
|
|
2019-09-11 12:36:00 +00:00
|
|
|
aItem->ClearEditFlags();
|
2018-10-16 13:11:33 +00:00
|
|
|
GetCanvas()->Refresh();
|
2012-01-04 22:08:46 +00:00
|
|
|
}
|
2012-01-14 11:52:46 +00:00
|
|
|
|
2014-02-21 00:06:37 +00:00
|
|
|
|
2012-01-14 11:52:46 +00:00
|
|
|
void SCH_EDIT_FRAME::UpdateTitle()
|
|
|
|
{
|
|
|
|
wxString title;
|
|
|
|
|
2019-11-15 11:28:35 +00:00
|
|
|
if( GetScreen()->GetFileName().IsEmpty() )
|
2012-01-14 11:52:46 +00:00
|
|
|
{
|
2019-11-15 11:28:35 +00:00
|
|
|
title.Printf( _( "Eeschema" ) + wxT( " \u2014" ) + _( " [no file]" ) );
|
2012-01-14 11:52:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
|
|
|
|
wxFileName fn = fileName;
|
2012-01-14 11:52:46 +00:00
|
|
|
|
2018-03-12 19:54:07 +00:00
|
|
|
title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s [%s] \u2014 %s" ),
|
2019-07-02 20:09:23 +00:00
|
|
|
fn.GetFullName(),
|
2020-05-13 02:00:37 +00:00
|
|
|
GetCurrentSheet().PathHumanReadable(),
|
2019-03-15 12:09:04 +00:00
|
|
|
fn.GetPath() );
|
2012-01-14 11:52:46 +00:00
|
|
|
|
|
|
|
if( fn.FileExists() )
|
|
|
|
{
|
|
|
|
if( !fn.IsFileWritable() )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
title += _( " [Read Only]" );
|
2012-01-14 11:52:46 +00:00
|
|
|
}
|
|
|
|
else
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
title += _( " [no file]" );
|
2012-01-14 11:52:46 +00:00
|
|
|
}
|
2012-05-10 06:25:27 +00:00
|
|
|
|
|
|
|
SetTitle( title );
|
2012-01-14 11:52:46 +00:00
|
|
|
}
|
2017-12-24 17:57:57 +00:00
|
|
|
|
|
|
|
|
2019-11-10 23:24:27 +00:00
|
|
|
void SCH_EDIT_FRAME::RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SHEET_LIST list = Schematic().GetSheets();
|
2019-11-10 23:24:27 +00:00
|
|
|
PROF_COUNTER timer;
|
2019-04-11 03:29:17 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
// Ensure schematic graph is accurate
|
2019-11-10 23:24:27 +00:00
|
|
|
if( aCleanupFlags == LOCAL_CLEANUP )
|
|
|
|
{
|
|
|
|
SchematicCleanUp( GetScreen() );
|
|
|
|
}
|
|
|
|
else if( aCleanupFlags == GLOBAL_CLEANUP )
|
2019-04-13 02:46:12 +00:00
|
|
|
{
|
|
|
|
for( const auto& sheet : list )
|
2019-05-11 10:06:28 +00:00
|
|
|
SchematicCleanUp( sheet.LastScreen() );
|
2019-04-13 02:46:12 +00:00
|
|
|
}
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-04-11 03:29:17 +00:00
|
|
|
timer.Stop();
|
|
|
|
wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
Schematic().ConnectionGraph()->Recalculate( list, true );
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2018-01-08 04:05:03 +00:00
|
|
|
{
|
2020-07-17 20:04:14 +00:00
|
|
|
SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
|
|
|
|
2020-08-05 21:50:58 +00:00
|
|
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
|
|
|
GetCanvas()->Refresh();
|
2018-01-08 04:05:03 +00:00
|
|
|
|
2019-07-20 15:52:30 +00:00
|
|
|
RecreateToolbars();
|
2018-01-08 04:05:03 +00:00
|
|
|
Layout();
|
|
|
|
SendSizeEvent();
|
|
|
|
}
|
2018-06-30 22:38:04 +00:00
|
|
|
|
|
|
|
|
2018-11-20 14:11:22 +00:00
|
|
|
void SCH_EDIT_FRAME::OnPageSettingsChange()
|
|
|
|
{
|
|
|
|
// Rebuild the sheet view (draw area and any other items):
|
|
|
|
DisplayCurrentSheet();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-30 22:38:04 +00:00
|
|
|
void SCH_EDIT_FRAME::ShowChangedLanguage()
|
|
|
|
{
|
|
|
|
// call my base class
|
|
|
|
SCH_BASE_FRAME::ShowChangedLanguage();
|
|
|
|
|
|
|
|
// tooltips in toolbars
|
2019-07-20 15:52:30 +00:00
|
|
|
RecreateToolbars();
|
2018-06-30 22:38:04 +00:00
|
|
|
|
|
|
|
// status bar
|
|
|
|
UpdateMsgPanel();
|
2019-02-25 18:26:14 +00:00
|
|
|
|
|
|
|
// This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
|
|
|
|
// windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
|
|
|
|
// wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
|
|
|
|
// toolbar to update correctly.
|
|
|
|
#if defined( __WXMSW__ )
|
|
|
|
PostSizeEvent();
|
|
|
|
#endif
|
2018-06-30 22:38:04 +00:00
|
|
|
}
|
|
|
|
|
2018-11-04 16:37:29 +00:00
|
|
|
|
2020-08-13 21:30:30 +00:00
|
|
|
void SCH_EDIT_FRAME::UpdateNetHighlightStatus()
|
|
|
|
{
|
|
|
|
if( const SCH_CONNECTION* conn = GetHighlightedConnection() )
|
|
|
|
{
|
|
|
|
SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
|
|
|
|
UnescapeString( conn->Name() ) ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetStatusText( wxT( "" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
void SCH_EDIT_FRAME::SetScreen( BASE_SCREEN* aScreen )
|
|
|
|
{
|
2019-04-17 19:09:48 +00:00
|
|
|
SCH_BASE_FRAME::SetScreen( aScreen );
|
2019-05-31 17:37:07 +00:00
|
|
|
GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-11-04 16:37:29 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
const BOX2I SCH_EDIT_FRAME::GetDocumentExtents() const
|
|
|
|
{
|
|
|
|
int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
|
|
|
|
int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
|
|
|
|
|
|
|
|
return BOX2I( VECTOR2I(0, 0), VECTOR2I( sizeX, sizeY ) );
|
|
|
|
}
|
2019-06-23 15:12:25 +00:00
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::FixupJunctions()
|
|
|
|
{
|
2019-06-25 15:26:01 +00:00
|
|
|
// Save the current sheet, to retrieve it later
|
2020-07-05 18:25:38 +00:00
|
|
|
SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
|
2019-06-23 15:12:25 +00:00
|
|
|
|
2020-02-04 22:37:14 +00:00
|
|
|
bool modified = false;
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SHEET_LIST sheetList = Schematic().GetSheets();
|
2019-06-23 15:12:25 +00:00
|
|
|
|
2019-07-02 20:09:23 +00:00
|
|
|
for( const SCH_SHEET_PATH& sheet : sheetList )
|
2019-06-23 15:12:25 +00:00
|
|
|
{
|
2020-01-19 18:01:09 +00:00
|
|
|
// We require a set here to avoid adding multiple junctions to the same spot
|
|
|
|
std::set<wxPoint> junctions;
|
2019-06-23 15:12:25 +00:00
|
|
|
|
2019-07-02 20:09:23 +00:00
|
|
|
SetCurrentSheet( sheet );
|
2019-06-23 15:12:25 +00:00
|
|
|
GetCurrentSheet().UpdateAllScreenReferences();
|
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
|
2020-01-17 02:33:16 +00:00
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
for( auto aItem : screen->Items().OfType( SCH_COMPONENT_T ) )
|
2019-06-23 15:12:25 +00:00
|
|
|
{
|
2020-04-24 13:36:10 +00:00
|
|
|
auto cmp = static_cast<SCH_COMPONENT*>( aItem );
|
2019-06-23 15:12:25 +00:00
|
|
|
|
2020-08-21 15:54:24 +00:00
|
|
|
for( const SCH_PIN* pin : cmp->GetPins( &sheet ) )
|
2019-06-25 23:39:58 +00:00
|
|
|
{
|
2020-04-24 13:36:10 +00:00
|
|
|
auto pos = pin->GetPosition();
|
2019-06-25 16:23:28 +00:00
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
// Test if a _new_ junction is needed, and add it if missing
|
|
|
|
if( screen->IsJunctionNeeded( pos, true ) )
|
2020-01-19 18:01:09 +00:00
|
|
|
junctions.insert( pos );
|
2019-06-23 15:12:25 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-25 23:39:58 +00:00
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
for( const wxPoint& pos : junctions )
|
|
|
|
AddJunction( screen, pos, false, false );
|
2020-02-04 22:37:14 +00:00
|
|
|
|
|
|
|
if( junctions.size() )
|
|
|
|
modified = true;
|
2019-06-23 15:12:25 +00:00
|
|
|
}
|
2019-06-25 15:26:01 +00:00
|
|
|
|
2020-02-04 22:37:14 +00:00
|
|
|
if( modified )
|
|
|
|
OnModify();
|
|
|
|
|
2019-06-25 15:26:01 +00:00
|
|
|
// Reselect the initial sheet:
|
2020-07-05 18:25:38 +00:00
|
|
|
SetCurrentSheet( oldsheetpath );
|
2019-06-25 15:26:01 +00:00
|
|
|
GetCurrentSheet().UpdateAllScreenReferences();
|
|
|
|
SetScreen( GetCurrentSheet().LastScreen() );
|
2019-08-01 17:26:21 +00:00
|
|
|
}
|
2019-12-19 15:34:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool SCH_EDIT_FRAME::IsContentModified()
|
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
return Schematic().GetSheets().IsModified();
|
2019-12-19 15:34:01 +00:00
|
|
|
}
|
2020-04-18 07:57:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool SCH_EDIT_FRAME::GetShowAllPins() const
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
return cfg->m_Appearance.show_hidden_pins;
|
|
|
|
}
|
2020-05-07 13:26:43 +00:00
|
|
|
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
void SCH_EDIT_FRAME::FocusOnItem( SCH_ITEM* aItem )
|
|
|
|
{
|
|
|
|
static KIID lastBrightenedItemID( niluuid );
|
|
|
|
|
|
|
|
SCH_SHEET_LIST sheetList = Schematic().GetSheets();
|
|
|
|
SCH_SHEET_PATH dummy;
|
|
|
|
SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
|
|
|
|
|
|
|
|
if( lastItem && lastItem != aItem )
|
|
|
|
{
|
|
|
|
lastItem->ClearBrightened();
|
|
|
|
|
2020-08-10 11:40:58 +00:00
|
|
|
UpdateItem( lastItem );
|
2020-05-13 02:00:37 +00:00
|
|
|
lastBrightenedItemID = niluuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aItem )
|
|
|
|
{
|
|
|
|
aItem->SetBrightened();
|
|
|
|
|
2020-08-10 11:40:58 +00:00
|
|
|
UpdateItem( aItem );
|
2020-05-13 02:00:37 +00:00
|
|
|
lastBrightenedItemID = aItem->m_Uuid;
|
|
|
|
|
|
|
|
FocusOnLocation( aItem->GetFocusPosition() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-07 13:26:43 +00:00
|
|
|
void SCH_EDIT_FRAME::ConvertTimeStampUuids()
|
|
|
|
{
|
|
|
|
// Remove this once this method is fully implemented. Otherwise, don't use it.
|
|
|
|
wxCHECK( false, /* void */ );
|
|
|
|
|
|
|
|
// Replace sheet and symbol time stamps with real UUIDs and update symbol instance
|
|
|
|
// sheet paths using the new UUID based sheet paths.
|
|
|
|
|
|
|
|
// Save the time stamp sheet paths.
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SHEET_LIST timeStampSheetPaths = Schematic().GetSheets();
|
2020-05-07 13:26:43 +00:00
|
|
|
|
|
|
|
std::vector<KIID_PATH> oldSheetPaths = timeStampSheetPaths.GetPaths();
|
|
|
|
|
|
|
|
// The root sheet now gets a permanent UUID.
|
2020-05-13 02:00:37 +00:00
|
|
|
const_cast<KIID&>( Schematic().Root().m_Uuid ).ConvertTimestampToUuid();
|
2020-05-07 13:26:43 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SCREENS schematic( Schematic().Root() );
|
2020-05-07 13:26:43 +00:00
|
|
|
|
|
|
|
// Change the sheet and symbol time stamps to UUIDs.
|
|
|
|
for( SCH_SCREEN* screen = schematic.GetFirst(); screen; screen = schematic.GetNext() )
|
|
|
|
{
|
|
|
|
for( auto sheet : screen->Items().OfType( SCH_SHEET_T ) )
|
|
|
|
const_cast<KIID&>( sheet->m_Uuid ).ConvertTimestampToUuid();
|
|
|
|
|
|
|
|
for( auto symbol : screen->Items().OfType( SCH_COMPONENT_T ) )
|
|
|
|
const_cast<KIID&>( symbol->m_Uuid ).ConvertTimestampToUuid();
|
|
|
|
}
|
|
|
|
|
|
|
|
timeStampSheetPaths.ReplaceLegacySheetPaths( oldSheetPaths );
|
|
|
|
}
|
2020-05-16 23:08:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxString SCH_EDIT_FRAME::GetCurrentFileName() const
|
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
return Schematic().GetFileName();
|
2020-05-16 23:08:01 +00:00
|
|
|
}
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
SELECTION& SCH_EDIT_FRAME::GetCurrentSelection()
|
|
|
|
{
|
|
|
|
return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
|
|
|
|
}
|
2020-08-20 14:33:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( IsShown() )
|
|
|
|
{
|
|
|
|
// We only need this until the frame is done resizing and the final client size is
|
|
|
|
// established.
|
|
|
|
Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
|
|
|
|
GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Skip() is called in the base class.
|
|
|
|
EDA_DRAW_FRAME::OnSize( aEvent );
|
|
|
|
}
|