2011-10-28 13:43:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-01-01 20:52:37 +00:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-10-06 18:07:43 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2018-01-09 15:58:01 +00:00
|
|
|
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-28 13:43:37 +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
|
|
|
|
*/
|
|
|
|
|
2010-02-16 16:21:52 +00:00
|
|
|
/**
|
2018-01-30 10:49:51 +00:00
|
|
|
* @file lib_edit_frame.cpp
|
|
|
|
* @brief LIB_EDIT_FRAME class is the symbol library editor frame.
|
2011-09-30 18:15:37 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
* 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
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <kiface_i.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawpanel.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <base_screen.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <eda_doc.h>
|
|
|
|
#include <gr_basic.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2017-11-12 17:55:20 +00:00
|
|
|
#include <confirm.h>
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <eeschema_id.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <lib_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_library.h>
|
|
|
|
#include <lib_polyline.h>
|
2013-09-25 19:09:57 +00:00
|
|
|
#include <lib_pin.h>
|
2017-11-12 17:55:20 +00:00
|
|
|
|
|
|
|
#include <lib_manager.h>
|
|
|
|
#include <widgets/cmp_tree_pane.h>
|
|
|
|
#include <widgets/component_tree.h>
|
2017-10-06 18:07:43 +00:00
|
|
|
#include <symbol_lib_table.h>
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <kicad_device_context.h>
|
|
|
|
#include <hotkeys.h>
|
2018-01-08 04:05:03 +00:00
|
|
|
#include <eeschema_config.h>
|
2009-12-20 19:48:58 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialogs/dialog_lib_edit_text.h>
|
|
|
|
#include <dialogs/dialog_edit_component_in_lib.h>
|
2015-03-27 10:26:07 +00:00
|
|
|
#include <dialogs/dialog_lib_edit_pin_table.h>
|
2010-11-17 21:47:27 +00:00
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2017-10-31 11:13:20 +00:00
|
|
|
#include <menus_helpers.h>
|
2017-11-22 11:06:17 +00:00
|
|
|
#include <wx/progdlg.h>
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
wxString LIB_EDIT_FRAME:: m_aliasName;
|
|
|
|
int LIB_EDIT_FRAME:: m_unit = 1;
|
|
|
|
int LIB_EDIT_FRAME:: m_convert = 1;
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* LIB_EDIT_FRAME::m_lastDrawItem = NULL;
|
2017-12-18 05:21:00 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
bool LIB_EDIT_FRAME:: m_showDeMorgan = false;
|
|
|
|
wxSize LIB_EDIT_FRAME:: m_clientSize = wxSize( -1, -1 );
|
2014-05-16 13:57:53 +00:00
|
|
|
int LIB_EDIT_FRAME:: m_textSize = -1;
|
2017-01-23 20:30:11 +00:00
|
|
|
double LIB_EDIT_FRAME:: m_current_text_angle = TEXT_ANGLE_HORIZ;
|
2010-11-19 16:28:46 +00:00
|
|
|
int LIB_EDIT_FRAME:: m_drawLineWidth = 0;
|
2014-08-25 16:31:32 +00:00
|
|
|
|
|
|
|
// these values are overridden when reading the config
|
|
|
|
int LIB_EDIT_FRAME:: m_textPinNumDefaultSize = DEFAULTPINNUMSIZE;
|
|
|
|
int LIB_EDIT_FRAME:: m_textPinNameDefaultSize = DEFAULTPINNAMESIZE;
|
|
|
|
int LIB_EDIT_FRAME:: m_defaultPinLength = DEFAULTPINLENGTH;
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
FILL_T LIB_EDIT_FRAME:: m_drawFillStyle = NO_FILL;
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_CLOSE( LIB_EDIT_FRAME::OnCloseWindow )
|
|
|
|
EVT_SIZE( LIB_EDIT_FRAME::OnSize )
|
|
|
|
EVT_ACTIVATE( LIB_EDIT_FRAME::OnActivate )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
// Library actions
|
|
|
|
EVT_TOOL( ID_LIBEDIT_NEW_LIBRARY, LIB_EDIT_FRAME::OnCreateNewLibrary )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_ADD_LIBRARY, LIB_EDIT_FRAME::OnAddLibrary )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_SAVE_LIBRARY, LIB_EDIT_FRAME::OnSaveLibrary )
|
|
|
|
EVT_MENU( ID_LIBEDIT_SAVE_LIBRARY_AS, LIB_EDIT_FRAME::OnSaveLibrary )
|
|
|
|
EVT_MENU( ID_LIBEDIT_SAVE_ALL_LIBS, LIB_EDIT_FRAME::OnSaveAllLibraries )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_REVERT_LIBRARY, LIB_EDIT_FRAME::OnRevertLibrary )
|
|
|
|
|
|
|
|
// Part actions
|
|
|
|
EVT_TOOL( ID_LIBEDIT_NEW_PART, LIB_EDIT_FRAME::OnCreateNewPart )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_EDIT_PART, LIB_EDIT_FRAME::OnEditPart )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_IMPORT_PART, LIB_EDIT_FRAME::OnImportPart )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnExportPart )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_SAVE_PART, LIB_EDIT_FRAME::OnSavePart )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_REVERT_PART, LIB_EDIT_FRAME::OnRevertPart )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_REMOVE_PART, LIB_EDIT_FRAME::OnRemovePart )
|
2017-11-13 19:39:36 +00:00
|
|
|
EVT_TOOL( ID_LIBEDIT_CUT_PART, LIB_EDIT_FRAME::OnCopyCutPart )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_COPY_PART, LIB_EDIT_FRAME::OnCopyCutPart )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_PASTE_PART, LIB_EDIT_FRAME::OnPasteDuplicatePart )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_DUPLICATE_PART, LIB_EDIT_FRAME::OnPasteDuplicatePart )
|
2017-11-12 17:55:20 +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
|
|
|
// Main horizontal toolbar.
|
2012-02-19 19:53:11 +00:00
|
|
|
EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer )
|
2017-11-20 13:11:50 +00:00
|
|
|
EVT_TOOL( wxID_COPY, LIB_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( wxID_PASTE, LIB_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( wxID_CUT, LIB_EDIT_FRAME::Process_Special_Functions )
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_TOOL( wxID_UNDO, LIB_EDIT_FRAME::GetComponentFromUndoList )
|
|
|
|
EVT_TOOL( wxID_REDO, LIB_EDIT_FRAME::GetComponentFromRedoList )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnEditComponentProperties )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, LIB_EDIT_FRAME::InstallFieldsEditorDialog )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnCheckComponent )
|
|
|
|
EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle )
|
|
|
|
EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnViewEntryDoc )
|
2018-01-23 11:15:19 +00:00
|
|
|
EVT_TOOL( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::Process_Special_Functions )
|
2015-03-27 10:26:07 +00:00
|
|
|
EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_TABLE, LIB_EDIT_FRAME::OnOpenPinTable )
|
2010-11-19 16:28:46 +00:00
|
|
|
|
2011-04-19 19:19:41 +00:00
|
|
|
EVT_COMBOBOX( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnSelectPart )
|
|
|
|
EVT_COMBOBOX( ID_LIBEDIT_SELECT_ALIAS, LIB_EDIT_FRAME::OnSelectAlias )
|
2010-10-04 18:54:14 +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
|
|
|
// Right vertical toolbar.
|
2011-02-24 20:22:12 +00:00
|
|
|
EVT_TOOL( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnSelectTool )
|
2018-04-01 18:58:27 +00:00
|
|
|
EVT_MENU( ID_MENU_ZOOM_SELECTION, LIB_EDIT_FRAME::OnSelectTool )
|
2016-06-08 11:19:53 +00:00
|
|
|
EVT_TOOL( ID_ZOOM_SELECTION, LIB_EDIT_FRAME::OnSelectTool )
|
2011-02-24 20:22:12 +00:00
|
|
|
EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
|
2011-02-21 13:54:29 +00:00
|
|
|
LIB_EDIT_FRAME::OnSelectTool )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2016-11-04 12:59:45 +00:00
|
|
|
// Left vertical toolbar (option toolbar).
|
|
|
|
EVT_TOOL( ID_LIBEDIT_SHOW_ELECTRICAL_TYPE, LIB_EDIT_FRAME::OnShowElectricalType )
|
2017-10-31 11:13:20 +00:00
|
|
|
EVT_TOOL( ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE, LIB_EDIT_FRAME::OnToggleSearchTree )
|
2016-11-04 12:59:45 +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
|
|
|
// menubar commands
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::CloseWindow )
|
|
|
|
EVT_MENU( ID_LIBEDIT_GEN_PNG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
|
|
|
|
EVT_MENU( ID_LIBEDIT_GEN_SVG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
|
2011-04-17 13:54:17 +00:00
|
|
|
EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
|
2011-08-04 18:03:26 +00:00
|
|
|
EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
|
2016-09-24 00:44:52 +00:00
|
|
|
EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
|
2011-05-16 19:32:57 +00:00
|
|
|
EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2014-08-25 16:31:32 +00:00
|
|
|
EVT_MENU( wxID_PREFERENCES, LIB_EDIT_FRAME::OnPreferencesOptions )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
// Multiple item selection context menu commands.
|
2011-04-27 19:44:32 +00:00
|
|
|
EVT_MENU_RANGE( ID_SELECT_ITEM_START, ID_SELECT_ITEM_END, LIB_EDIT_FRAME::OnSelectItem )
|
|
|
|
|
2011-02-23 14:20:01 +00:00
|
|
|
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::Process_Config )
|
2010-10-04 18:54:14 +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
|
|
|
// Context menu events and commands.
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_MENU( ID_LIBEDIT_EDIT_PIN, LIB_EDIT_FRAME::OnEditPin )
|
2011-02-28 13:53:49 +00:00
|
|
|
EVT_MENU( ID_LIBEDIT_ROTATE_ITEM, LIB_EDIT_FRAME::OnRotateItem )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM,
|
2011-02-28 13:53:49 +00:00
|
|
|
ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::Process_Special_Functions )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::Process_Special_Functions )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2016-04-22 14:15:16 +00:00
|
|
|
EVT_MENU_RANGE( ID_LIBEDIT_MIRROR_X, ID_LIBEDIT_ORIENT_NORMAL,
|
|
|
|
LIB_EDIT_FRAME::OnOrient )
|
2017-10-31 11:13:20 +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
|
|
|
// Update user interface elements.
|
2017-11-20 14:38:38 +00:00
|
|
|
EVT_UPDATE_UI( wxID_PASTE, LIB_EDIT_FRAME::OnUpdatePaste )
|
2017-11-13 10:38:20 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_REVERT_LIBRARY, LIB_EDIT_FRAME::OnUpdateLibModified )
|
2017-10-31 11:13:20 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
2017-11-13 10:38:20 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_PART, LIB_EDIT_FRAME::OnUpdatePartModified )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_REVERT_PART, LIB_EDIT_FRAME::OnUpdatePartModified )
|
2017-11-13 19:39:36 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_PASTE_PART, LIB_EDIT_FRAME::OnUpdateClipboardNotEmpty )
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
|
|
|
EVT_UPDATE_UI( wxID_UNDO, LIB_EDIT_FRAME::OnUpdateUndo )
|
|
|
|
EVT_UPDATE_UI( wxID_REDO, LIB_EDIT_FRAME::OnUpdateRedo )
|
2017-11-13 10:38:20 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_LIBRARY, LIB_EDIT_FRAME::OnUpdateSaveLib )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_LIBRARY_AS, LIB_EDIT_FRAME::OnUpdateSaveLibAs )
|
2018-05-02 22:33:53 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_ALL_LIBS, LIB_EDIT_FRAME::OnUpdateSaveAll )
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnUpdateViewDoc )
|
2018-01-23 11:15:19 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnUpdateSyncPinEdit )
|
2015-03-27 10:26:07 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_TABLE, LIB_EDIT_FRAME::OnUpdatePinTable )
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnUpdatePartNumber )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_ALIAS, LIB_EDIT_FRAME::OnUpdateSelectAlias )
|
|
|
|
EVT_UPDATE_UI( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganNormal )
|
|
|
|
EVT_UPDATE_UI( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganConvert )
|
2017-06-10 07:06:25 +00:00
|
|
|
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnUpdateSelectTool )
|
|
|
|
EVT_UPDATE_UI( ID_ZOOM_SELECTION, LIB_EDIT_FRAME::OnUpdateSelectTool )
|
2011-02-24 20:22:12 +00:00
|
|
|
EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::OnUpdateEditingPart )
|
2016-11-04 12:59:45 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SHOW_ELECTRICAL_TYPE, LIB_EDIT_FRAME::OnUpdateElectricalType )
|
2018-05-30 13:37:27 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE, LIB_EDIT_FRAME::OnUpdateSearchTreeTool )
|
2016-11-04 12:59:45 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2014-05-05 15:15:54 +00:00
|
|
|
LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
2014-04-19 18:47:20 +00:00
|
|
|
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ),
|
2015-08-31 06:43:33 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, LIB_EDIT_FRAME_NAME )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-12-14 20:03:15 +00:00
|
|
|
m_showAxis = true; // true to draw axis
|
2009-10-10 17:27:53 +00:00
|
|
|
SetShowDeMorgan( false );
|
2009-10-19 19:00:47 +00:00
|
|
|
m_drawSpecificConvert = true;
|
2009-11-04 20:46:53 +00:00
|
|
|
m_drawSpecificUnit = false;
|
2015-05-19 16:39:05 +00:00
|
|
|
m_hotkeysDescrList = g_Libedit_Hokeys_Descr;
|
2018-01-23 11:15:19 +00:00
|
|
|
m_syncPinEdit = false;
|
2015-04-22 11:39:00 +00:00
|
|
|
m_repeatPinStep = DEFAULT_REPEAT_OFFSET_PIN;
|
2016-11-04 11:13:22 +00:00
|
|
|
SetShowElectricalType( true );
|
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
|
|
|
|
2015-04-30 11:08:35 +00:00
|
|
|
m_my_part = NULL;
|
|
|
|
m_tempCopyComponent = NULL;
|
2017-11-12 17:55:20 +00:00
|
|
|
m_treePane = nullptr;
|
|
|
|
m_libMgr = nullptr;
|
2015-04-30 11:08:35 +00:00
|
|
|
|
2014-05-16 13:57:53 +00:00
|
|
|
// Delayed initialization
|
|
|
|
if( m_textSize == -1 )
|
|
|
|
m_textSize = GetDefaultTextSize();
|
|
|
|
|
2014-02-02 19:51:50 +00:00
|
|
|
// Initialize grid id to the default value 50 mils:
|
2012-05-06 16:55:51 +00:00
|
|
|
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2011-09-08 05:58:45 +00:00
|
|
|
wxIcon icon;
|
2016-09-20 11:22:42 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_libedit_xpm ) );
|
2011-09-08 05:58:45 +00:00
|
|
|
SetIcon( icon );
|
|
|
|
|
2015-08-06 00:10:52 +00:00
|
|
|
LoadSettings( config() );
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
m_dummyScreen = new SCH_SCREEN( aKiway );
|
|
|
|
SetScreen( m_dummyScreen );
|
2009-09-04 18:57:37 +00:00
|
|
|
GetScreen()->m_Center = true;
|
2015-08-06 00:10:52 +00:00
|
|
|
GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2014-03-05 17:40:23 +00:00
|
|
|
// Ensure m_LastGridSizeId is an offset inside the allowed schematic range
|
|
|
|
if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000 )
|
|
|
|
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
|
|
|
|
|
|
|
|
if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_1 - ID_POPUP_GRID_LEVEL_1000 )
|
|
|
|
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1 - ID_POPUP_GRID_LEVEL_1000;
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
2012-05-06 16:55:51 +00:00
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetEnableBlockCommands( true );
|
2009-12-22 20:08:56 +00:00
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
m_libMgr = new LIB_MANAGER( *this );
|
2017-11-30 11:31:36 +00:00
|
|
|
SyncLibraries( true );
|
2017-11-12 17:55:20 +00:00
|
|
|
m_treePane = new CMP_TREE_PANE( this, m_libMgr );
|
|
|
|
|
2010-03-18 20:35:29 +00:00
|
|
|
ReCreateMenuBar();
|
2007-09-15 04:25:54 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
2015-04-30 11:08:35 +00:00
|
|
|
|
|
|
|
// Ensure the current alias name is valid if a part is loaded
|
|
|
|
// Sometimes it is not valid. This is the case
|
|
|
|
// when a part value (the part lib name), or the alias list was modified
|
|
|
|
// during a previous session and the modifications not saved in lib.
|
|
|
|
// Reopen libedit in a new session gives a non valid m_aliasName
|
|
|
|
// because the curr part is reloaded from the library (and this is the unmodified part)
|
|
|
|
// and the old alias name (from the previous edition) can be invalid
|
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
if( part == NULL )
|
|
|
|
m_aliasName.Empty();
|
|
|
|
else if( m_aliasName != part->GetName() )
|
|
|
|
{
|
|
|
|
LIB_ALIAS* alias = part->GetAlias( m_aliasName );
|
|
|
|
|
|
|
|
if( !alias )
|
|
|
|
m_aliasName = part->GetName();
|
|
|
|
}
|
|
|
|
|
2018-01-08 04:05:03 +00:00
|
|
|
ReCreateOptToolbar();
|
2007-09-15 04:25:54 +00:00
|
|
|
DisplayLibInfos();
|
2009-09-18 14:56:05 +00:00
|
|
|
DisplayCmpDoc();
|
2009-09-14 13:24:17 +00:00
|
|
|
UpdateAliasSelectList();
|
|
|
|
UpdatePartSelectList();
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
2011-09-15 18:25:44 +00:00
|
|
|
EDA_PANEINFO horiz;
|
|
|
|
horiz.HorizontalToolbarPane();
|
|
|
|
|
|
|
|
EDA_PANEINFO vert;
|
|
|
|
vert.VerticalToolbarPane();
|
|
|
|
|
|
|
|
EDA_PANEINFO mesg;
|
|
|
|
mesg.MessageToolbarPane();
|
|
|
|
|
2011-12-16 13:32:23 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar,
|
2017-03-10 13:38:39 +00:00
|
|
|
wxAuiPaneInfo( horiz ).Name( "m_mainToolBar" ).Top().Row( 0 ) );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_auimgr.AddPane( m_drawToolBar,
|
2017-03-10 13:38:39 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( "m_VToolBar" ).Right() );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_auimgr.AddPane( m_optionsToolBar,
|
2017-10-31 11:13:20 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( "m_optionsToolBar" ).Left().Row( 0 ) );
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_auimgr.AddPane( m_canvas,
|
2017-03-10 13:38:39 +00:00
|
|
|
wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-12-12 14:02:37 +00:00
|
|
|
m_auimgr.AddPane( m_messagePanel,
|
2017-10-31 11:13:20 +00:00
|
|
|
wxAuiPaneInfo( mesg ).Name( "MsgPanel" ).Bottom().Layer( 10 ) );
|
|
|
|
|
2017-11-13 22:30:07 +00:00
|
|
|
m_auimgr.AddPane( m_treePane, wxAuiPaneInfo().Name( "ComponentTree" ).Left().Row( 1 )
|
|
|
|
.Resizable().MinSize( 250, 400 ).Dock().CloseButton( false ) );
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2015-07-15 12:41:30 +00:00
|
|
|
Raise();
|
2011-04-12 12:41:13 +00:00
|
|
|
Show( true );
|
|
|
|
|
2018-05-03 13:52:43 +00:00
|
|
|
Bind( wxEVT_COMMAND_MENU_SELECTED, &LIB_EDIT_FRAME::OnConfigurePaths, this,
|
|
|
|
ID_PREFERENCES_CONFIGURE_PATHS );
|
|
|
|
|
2017-08-12 16:10:47 +00:00
|
|
|
Bind( wxEVT_COMMAND_MENU_SELECTED, &LIB_EDIT_FRAME::OnEditSymbolLibTable, this,
|
2017-08-12 12:09:39 +00:00
|
|
|
ID_EDIT_SYM_LIB_TABLE );
|
|
|
|
|
2011-02-23 14:20:01 +00:00
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED, ID_ZOOM_PAGE );
|
|
|
|
wxPostEvent( this, evt );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::~LIB_EDIT_FRAME()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2017-08-12 16:10:47 +00:00
|
|
|
Unbind( wxEVT_COMMAND_MENU_SELECTED, &LIB_EDIT_FRAME::OnEditSymbolLibTable, this,
|
2017-08-12 12:09:39 +00:00
|
|
|
ID_EDIT_SYM_LIB_TABLE );
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
// current screen is destroyed in EDA_DRAW_FRAME
|
|
|
|
SetScreen( m_dummyScreen );
|
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
m_lastDrawItem = NULL;
|
|
|
|
SetDrawItem( m_lastDrawItem );
|
2011-02-21 13:54:29 +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
|
|
|
delete m_tempCopyComponent;
|
2017-11-12 17:55:20 +00:00
|
|
|
delete m_libMgr;
|
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
|
|
|
delete m_my_part;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2018-02-16 10:27:43 +00:00
|
|
|
if( saveAllLibraries( true ) )
|
2017-11-13 09:55:05 +00:00
|
|
|
Destroy();
|
|
|
|
else
|
|
|
|
Event.Veto();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-05 12:46:14 +00:00
|
|
|
double LIB_EDIT_FRAME::BestZoom()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2018-02-13 21:19:41 +00:00
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
double defaultLibraryZoom = 7.33;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2018-02-13 21:19:41 +00:00
|
|
|
if( !part )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
SetScrollCenterPosition( wxPoint( 0, 0 ) );
|
2018-02-13 21:19:41 +00:00
|
|
|
return defaultLibraryZoom;
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
|
2018-02-13 21:19:41 +00:00
|
|
|
EDA_RECT boundingBox = part->GetUnitBoundingBox( m_unit, m_convert );
|
2011-04-12 12:41:13 +00:00
|
|
|
|
2018-02-13 21:19:41 +00:00
|
|
|
double sizeX = (double) boundingBox.GetWidth();
|
|
|
|
double sizeY = (double) boundingBox.GetHeight();
|
|
|
|
wxPoint centre = boundingBox.Centre();
|
2011-04-12 12:41:13 +00:00
|
|
|
|
2018-02-13 21:19:41 +00:00
|
|
|
// Reserve a 20% margin around component bounding box.
|
|
|
|
double margin_scale_factor = 1.2;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2018-02-13 21:19:41 +00:00
|
|
|
return bestZoom( sizeX, sizeY, margin_scale_factor, centre);
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::UpdateAliasSelectList()
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_aliasSelectBox == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
m_aliasSelectBox->Clear();
|
2009-09-14 13:24:17 +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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
if( !part )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
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
|
|
|
m_aliasSelectBox->Append( part->GetAliasNames() );
|
2011-12-09 16:37:11 +00:00
|
|
|
m_aliasSelectBox->SetSelection( 0 );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
int index = m_aliasSelectBox->FindString( m_aliasName );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
if( index != wxNOT_FOUND )
|
2011-12-09 16:37:11 +00:00
|
|
|
m_aliasSelectBox->SetSelection( index );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::UpdatePartSelectList()
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_partSelectBox == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_partSelectBox->GetCount() != 0 )
|
|
|
|
m_partSelectBox->Clear();
|
2009-09-14 13:24:17 +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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
if( !part || part->GetUnitCount() <= 1 )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2014-09-02 11:47:57 +00:00
|
|
|
m_unit = 1;
|
2011-12-09 16:37:11 +00:00
|
|
|
m_partSelectBox->Append( wxEmptyString );
|
2009-09-14 13:24:17 +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
|
|
|
for( int i = 0; i < part->GetUnitCount(); i++ )
|
2009-09-14 13:24:17 +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 sub = LIB_PART::SubReference( i+1, false );
|
|
|
|
wxString unit = wxString::Format( _( "Unit %s" ), GetChars( sub ) );
|
|
|
|
m_partSelectBox->Append( unit );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-02 11:47:57 +00:00
|
|
|
// Ensure the current selected unit is compatible with
|
|
|
|
// the number of units of the current part:
|
|
|
|
if( part && part->GetUnitCount() < m_unit )
|
|
|
|
m_unit = 1;
|
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
m_partSelectBox->SetSelection( ( m_unit > 0 ) ? m_unit - 1 : 0 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-04 12:59:45 +00:00
|
|
|
void LIB_EDIT_FRAME::OnShowElectricalType( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
SetShowElectricalType( not GetShowElectricalType() );
|
|
|
|
GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-31 11:13:20 +00:00
|
|
|
void LIB_EDIT_FRAME::OnToggleSearchTree( wxCommandEvent& event )
|
|
|
|
{
|
2017-11-12 17:55:20 +00:00
|
|
|
auto& treePane = m_auimgr.GetPane( m_treePane );
|
2017-10-31 11:13:20 +00:00
|
|
|
treePane.Show( !IsSearchTreeShown() );
|
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
void LIB_EDIT_FRAME::OnEditSymbolLibTable( wxCommandEvent& aEvent )
|
|
|
|
{
|
2018-04-28 09:43:41 +00:00
|
|
|
m_libMgr->GetAdapter()->Freeze();
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
SCH_BASE_FRAME::OnEditSymbolLibTable( aEvent );
|
2017-11-30 11:31:36 +00:00
|
|
|
SyncLibraries( true );
|
2018-04-28 09:43:41 +00:00
|
|
|
|
|
|
|
m_libMgr->GetAdapter()->Thaw();
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-31 11:13:20 +00:00
|
|
|
bool LIB_EDIT_FRAME::IsSearchTreeShown()
|
|
|
|
{
|
2017-11-12 17:55:20 +00:00
|
|
|
return m_auimgr.GetPane( m_treePane ).IsShown();
|
2017-10-31 11:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-20 17:15:46 +00:00
|
|
|
void LIB_EDIT_FRAME::ClearSearchTreeSelection()
|
|
|
|
{
|
|
|
|
m_treePane->GetCmpTree()->Unselect();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-10 07:06:25 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
2018-04-14 15:44:17 +00:00
|
|
|
if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar )
|
2018-04-13 20:41:36 +00:00
|
|
|
aEvent.Check( GetToolId() == aEvent.GetId() );
|
2017-06-10 07:06:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-04 12:59:45 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateElectricalType( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
aEvent.Check( GetShowElectricalType() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-30 13:37:27 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateSearchTreeTool( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( aEvent.GetEventObject() == m_optionsToolBar )
|
|
|
|
aEvent.Check( IsSearchTreeShown() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateEditingPart( wxUpdateUIEvent& aEvent )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2017-11-13 10:38:20 +00:00
|
|
|
LIB_PART* part = GetCurPart();
|
2011-02-21 13:54:29 +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
|
|
|
aEvent.Enable( part != NULL );
|
|
|
|
|
|
|
|
if( part && aEvent.GetEventObject() == m_drawToolBar )
|
2011-02-24 20:22:12 +00:00
|
|
|
aEvent.Check( GetToolId() == aEvent.GetId() );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2017-11-13 10:38:20 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdatePartModified( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
LIB_ID libId = getTargetLibId();
|
|
|
|
const wxString& partName = libId.GetLibItemName();
|
|
|
|
const wxString& libName = libId.GetLibNickname();
|
|
|
|
|
2017-11-14 13:19:11 +00:00
|
|
|
if( aEvent.GetId() == ID_LIBEDIT_SAVE_PART )
|
|
|
|
{
|
|
|
|
bool readOnly = libName.IsEmpty() || m_libMgr->IsLibraryReadOnly( libName );
|
|
|
|
|
2018-02-16 10:27:43 +00:00
|
|
|
aEvent.SetText( readOnly ? _( "&Save Symbol [Read Only]" ) : _( "&Save Symbol" ) );
|
2017-11-14 13:19:11 +00:00
|
|
|
aEvent.Enable( !readOnly && !partName.IsEmpty()
|
|
|
|
&& m_libMgr->IsPartModified( partName, libName ) );
|
|
|
|
}
|
|
|
|
else if( aEvent.GetId() == ID_LIBEDIT_REVERT_PART )
|
|
|
|
{
|
|
|
|
aEvent.Enable( !partName.IsEmpty() && !libName.IsEmpty()
|
|
|
|
&& m_libMgr->IsPartModified( partName, libName ) );
|
|
|
|
}
|
|
|
|
else wxFAIL;
|
2017-11-13 10:38:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-20 14:38:38 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdatePaste( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
event.Enable( m_clipboard.GetCount() > 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-13 10:38:20 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateLibModified( wxUpdateUIEvent& aEvent )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2017-11-13 10:38:20 +00:00
|
|
|
aEvent.Enable( m_libMgr->IsLibraryModified( getTargetLib() ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-13 19:39:36 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateClipboardNotEmpty( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
aEvent.Enable( !!m_copiedPart );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateUndo( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +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
|
|
|
event.Enable( GetCurPart() && GetScreen() &&
|
|
|
|
GetScreen()->GetUndoCommandCount() != 0 && !IsEditingDrawItem() );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateRedo( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +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
|
|
|
event.Enable( GetCurPart() && GetScreen() &&
|
|
|
|
GetScreen()->GetRedoCommandCount() != 0 && !IsEditingDrawItem() );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-13 10:38:20 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateSaveLib( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2017-11-12 17:55:20 +00:00
|
|
|
wxString lib = getTargetLib();
|
2017-12-19 11:11:52 +00:00
|
|
|
bool readOnly = lib.IsEmpty() || m_libMgr->IsLibraryReadOnly( lib );
|
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-02-16 10:27:43 +00:00
|
|
|
event.SetText( readOnly ? _( "&Save Library [Read Only]" ) : _( "&Save Library" ) );
|
2017-11-14 13:19:11 +00:00
|
|
|
event.Enable( !readOnly && m_libMgr->IsLibraryModified( lib ) );
|
2017-10-06 18:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-13 10:38:20 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateSaveLibAs( wxUpdateUIEvent& event )
|
2017-10-06 18:07:43 +00:00
|
|
|
{
|
2017-11-12 17:55:20 +00:00
|
|
|
wxString lib = getTargetLib();
|
2017-10-06 18:07:43 +00:00
|
|
|
|
2017-11-12 13:24:55 +00:00
|
|
|
event.Enable( m_libMgr->LibraryExists( lib ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-02 22:33:53 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateSaveAll( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
int modified = 0;
|
|
|
|
|
|
|
|
for( const auto& lib : m_libMgr->GetLibraryNames() )
|
|
|
|
{
|
|
|
|
if( m_libMgr->IsLibraryModified( lib ) )
|
|
|
|
modified++;
|
|
|
|
|
|
|
|
if( modified > 1 )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-08-25 23:32:09 +00:00
|
|
|
wxString text = modified > 1 ? _( "Save All &Libraries..." ) : _( "Save All &Libraries" );
|
|
|
|
|
|
|
|
event.SetText( AddHotkeyName( text, g_Libedit_Hokeys_Descr, HK_SAVE_ALL_LIBS ) );
|
2018-05-02 22:33:53 +00:00
|
|
|
event.Enable( modified > 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateViewDoc( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
bool enable = false;
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
LIB_PART* part = GetCurPart();
|
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
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
if( part )
|
2009-09-14 13:24:17 +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
|
|
|
LIB_ALIAS* alias = part->GetAlias( m_aliasName );
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
wxCHECK_RET( alias != NULL,
|
2017-12-15 11:37:46 +00:00
|
|
|
wxString::Format( "Alias \"%s\" not found in symbol \"%s\".",
|
2017-10-06 18:07:43 +00:00
|
|
|
m_aliasName, part->GetName() ) );
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
enable = !alias->GetDocFileName().IsEmpty();
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
event.Enable( enable );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-23 11:15:19 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateSyncPinEdit( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2018-01-23 11:15:19 +00:00
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
event.Enable( part && part->IsMulti() && !part->UnitsLocked() );
|
|
|
|
event.Check( m_syncPinEdit );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
2017-03-10 13:38:39 +00:00
|
|
|
|
2015-03-27 10:26:07 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdatePinTable( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
LIB_PART* part = GetCurPart();
|
2015-11-03 19:44:05 +00:00
|
|
|
event.Enable( part != NULL );
|
2015-03-27 10:26:07 +00:00
|
|
|
}
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2017-03-10 13:38:39 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_partSelectBox == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
// Using the typical event.Enable() call doesn't seem to work with wxGTK
|
|
|
|
// so use the pointer to alias combobox to directly enable or disable.
|
|
|
|
m_partSelectBox->Enable( part && part->GetUnitCount() > 1 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-16 13:32:23 +00:00
|
|
|
if( m_mainToolBar == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
event.Check( m_convert <= 1 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateDeMorganConvert( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-16 13:32:23 +00:00
|
|
|
if( m_mainToolBar == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
event.Check( m_convert > 1 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateSelectAlias( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_aliasSelectBox == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
// Using the typical event.Enable() call doesn't seem to work with wxGTK
|
|
|
|
// so use the pointer to alias combobox to directly enable or disable.
|
|
|
|
m_aliasSelectBox->Enable( part && part->GetAliasCount() > 1 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnSelectAlias( wxCommandEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_aliasSelectBox == NULL
|
|
|
|
|| ( m_aliasSelectBox->GetStringSelection().CmpNoCase( m_aliasName ) == 0) )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_lastDrawItem = NULL;
|
2011-12-09 16:37:11 +00:00
|
|
|
m_aliasName = m_aliasSelectBox->GetStringSelection();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
DisplayCmpDoc();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnSelectPart( wxCommandEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
int i = event.GetSelection();
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_lastDrawItem = NULL;
|
|
|
|
m_unit = i + 1;
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2009-09-18 14:56:05 +00:00
|
|
|
DisplayCmpDoc();
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event )
|
2009-09-25 18:49:04 +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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
if( !part )
|
2009-09-25 18:49:04 +00:00
|
|
|
return;
|
|
|
|
|
* 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 fileName;
|
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
|
|
|
LIB_ALIAS* alias = part->GetAlias( m_aliasName );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2017-03-10 13:38:39 +00:00
|
|
|
wxCHECK_RET( alias != NULL, "Alias not found." );
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
fileName = alias->GetDocFileName();
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
if( !fileName.IsEmpty() )
|
* 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
|
|
|
{
|
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
|
|
|
SEARCH_STACK* lib_search = Prj().SchSearchS();
|
* 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
|
|
|
|
|
|
|
GetAssociatedDocument( this, fileName, lib_search );
|
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
if( event.GetId() == ID_DE_MORGAN_NORMAL_BUTT )
|
|
|
|
m_convert = 1;
|
|
|
|
else
|
|
|
|
m_convert = 2;
|
|
|
|
|
|
|
|
m_lastDrawItem = NULL;
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-02-04 17:46:12 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
wxPoint pos;
|
2017-11-13 17:00:21 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
2017-11-20 13:03:10 +00:00
|
|
|
BLOCK_SELECTOR& block = screen->m_BlockLocate;
|
2017-12-18 05:21:00 +00:00
|
|
|
LIB_ITEM* item = screen->GetCurLibItem();
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
wxGetMousePosition( &pos.x, &pos.y );
|
|
|
|
pos.y += 20;
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
switch( id ) // Stop placement commands before handling new command.
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2017-11-20 13:11:50 +00:00
|
|
|
case wxID_COPY:
|
|
|
|
case wxID_CUT:
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
|
2009-10-30 19:26:25 +00:00
|
|
|
case ID_LIBEDIT_EDIT_PIN:
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
2017-07-04 08:08:33 +00:00
|
|
|
case ID_POPUP_DUPLICATE_BLOCK:
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_POPUP_SELECT_ITEMS_BLOCK:
|
2011-05-20 18:29:35 +00:00
|
|
|
case ID_POPUP_MIRROR_X_BLOCK:
|
2009-08-12 10:40:01 +00:00
|
|
|
case ID_POPUP_MIRROR_Y_BLOCK:
|
2011-05-20 18:29:35 +00:00
|
|
|
case ID_POPUP_ROTATE_BLOCK:
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
|
|
|
|
break;
|
|
|
|
|
2009-12-20 19:48:58 +00:00
|
|
|
case ID_POPUP_LIBEDIT_CANCEL_EDITING:
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
|
|
|
m_canvas->EndMouseCapture();
|
2009-12-20 19:48:58 +00:00
|
|
|
else
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
2009-12-20 19:48:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_ITEM:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture();
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(),
|
2017-03-10 13:38:39 +00:00
|
|
|
wxEmptyString );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
switch( id )
|
|
|
|
{
|
2009-12-29 10:35:11 +00:00
|
|
|
case ID_POPUP_LIBEDIT_CANCEL_EDITING:
|
|
|
|
break;
|
|
|
|
|
2018-01-23 11:15:19 +00:00
|
|
|
case ID_LIBEDIT_SYNC_PIN_EDIT:
|
|
|
|
m_syncPinEdit = m_mainToolBar->GetToolToggled( ID_LIBEDIT_SYNC_PIN_EDIT );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
|
|
|
EndDrawGraphicItem( &dc );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( &dc );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
switch( item->Type() )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_ARC_T:
|
|
|
|
case LIB_CIRCLE_T:
|
|
|
|
case LIB_RECTANGLE_T:
|
|
|
|
case LIB_POLYLINE_T:
|
2017-12-18 05:21:00 +00:00
|
|
|
EditGraphicSymbol( &dc, item );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_TEXT_T:
|
2017-12-18 05:21:00 +00:00
|
|
|
EditSymbolText( &dc, item );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( &dc );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
|
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
|
|
|
{
|
|
|
|
// Delete the last created segment, while creating a polyline draw item
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item == NULL )
|
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
|
|
|
break;
|
2010-10-20 20:24:26 +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
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2017-12-18 05:21:00 +00:00
|
|
|
STATUS_FLAGS oldFlags = item->GetFlags();
|
|
|
|
item->ClearFlags();
|
|
|
|
item->Draw( m_canvas, &dc, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode, NULL,
|
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
|
|
|
DefaultTransform );
|
2017-12-18 05:21:00 +00:00
|
|
|
( (LIB_POLYLINE*) item )->DeleteSegment( GetCrossHairPosition( true ) );
|
|
|
|
item->Draw( m_canvas, &dc, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode, NULL,
|
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
|
|
|
DefaultTransform );
|
2017-12-18 05:21:00 +00:00
|
|
|
item->SetFlags( oldFlags );
|
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
|
|
|
m_lastDrawItem = NULL;
|
|
|
|
}
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_ITEM:
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item )
|
2018-04-04 17:19:17 +00:00
|
|
|
deleteItem( &dc, item );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST:
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
2011-04-27 19:44:32 +00:00
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item->Type() == LIB_PIN_T )
|
2018-04-04 17:19:17 +00:00
|
|
|
StartMovePin( item );
|
2007-09-15 04:25:54 +00:00
|
|
|
else
|
2018-04-04 17:19:17 +00:00
|
|
|
StartMoveDrawSymbol( &dc, item );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
case ID_POPUP_LIBEDIT_MODIFY_ITEM:
|
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item == NULL )
|
2010-02-04 17:46:12 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item->Type() == LIB_RECTANGLE_T
|
|
|
|
|| item->Type() == LIB_CIRCLE_T
|
|
|
|
|| item->Type() == LIB_POLYLINE_T
|
|
|
|
|| item->Type() == LIB_ARC_T
|
2010-02-04 17:46:12 +00:00
|
|
|
)
|
|
|
|
{
|
2018-04-04 17:19:17 +00:00
|
|
|
StartModifyDrawSymbol( &dc, item );
|
2010-02-04 17:46:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM:
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( &dc );
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item->Type() == LIB_FIELD_T )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2017-12-18 05:21:00 +00:00
|
|
|
EditField( (LIB_FIELD*) item );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
m_canvas->CrossHairOn( &dc );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
|
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
|
|
|
{
|
2017-12-18 05:21:00 +00:00
|
|
|
if( !item || item->Type() != LIB_PIN_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
|
|
|
break;
|
2011-09-01 12:54:34 +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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
SaveCopyInUndoList( part );
|
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
GlobalSetPins( (LIB_PIN*) item, id );
|
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
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
m_canvas->Refresh();
|
|
|
|
}
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2017-11-20 13:03:10 +00:00
|
|
|
block.SetCommand( BLOCK_ZOOM );
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2017-11-20 13:03:10 +00:00
|
|
|
block.SetCommand( BLOCK_DELETE );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
2017-07-04 08:08:33 +00:00
|
|
|
case ID_POPUP_DUPLICATE_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2017-11-20 13:03:10 +00:00
|
|
|
block.SetCommand( BLOCK_DUPLICATE );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2016-04-22 14:15:16 +00:00
|
|
|
HandleBlockEnd( &dc );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SELECT_ITEMS_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2017-11-20 13:03:10 +00:00
|
|
|
block.SetCommand( BLOCK_SELECT_ITEMS_ONLY );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
case ID_POPUP_MIRROR_Y_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2017-11-20 13:03:10 +00:00
|
|
|
block.SetCommand( BLOCK_MIRROR_Y );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
2011-05-20 18:29:35 +00:00
|
|
|
case ID_POPUP_MIRROR_X_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2017-11-20 13:03:10 +00:00
|
|
|
block.SetCommand( BLOCK_MIRROR_X );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-05-20 18:29:35 +00:00
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ROTATE_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2017-11-20 13:03:10 +00:00
|
|
|
block.SetCommand( BLOCK_ROTATE );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-05-20 18:29:35 +00:00
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
2017-11-20 13:11:50 +00:00
|
|
|
case wxID_COPY:
|
|
|
|
block.SetCommand( BLOCK_COPY );
|
|
|
|
block.SetMessageBlock( this );
|
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_PASTE:
|
|
|
|
HandleBlockBegin( &dc, BLOCK_PASTE, GetCrossHairPosition() );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_CUT:
|
|
|
|
if( block.GetCommand() != BLOCK_MOVE )
|
|
|
|
break;
|
|
|
|
|
|
|
|
block.SetCommand( BLOCK_CUT );
|
|
|
|
block.SetMessageBlock( this );
|
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
default:
|
2017-03-10 13:38:39 +00:00
|
|
|
DisplayError( this, "LIB_EDIT_FRAME::Process_Special_Functions error" );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
2009-09-25 18:49:04 +00:00
|
|
|
m_lastDrawItem = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2009-12-22 20:08:56 +00:00
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnActivate( wxActivateEvent& event )
|
2009-12-22 20:08:56 +00:00
|
|
|
{
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::OnActivate( event );
|
2009-12-22 20:08:56 +00:00
|
|
|
}
|
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
wxString LIB_EDIT_FRAME::GetCurLib() const
|
2009-12-22 20:08:56 +00:00
|
|
|
{
|
2017-10-06 18:07:43 +00:00
|
|
|
wxString libNickname = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_LIB );
|
2009-12-22 20:08:56 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
if( !libNickname.empty() )
|
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
|
|
|
{
|
2017-10-06 18:07:43 +00:00
|
|
|
if( !Prj().SchSymbolLibTable()->HasLibrary( libNickname ) )
|
|
|
|
{
|
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
|
|
|
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
|
2017-10-06 18:07:43 +00:00
|
|
|
libNickname = wxEmptyString;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
return libNickname;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
wxString LIB_EDIT_FRAME::SetCurLib( const wxString& aLibNickname )
|
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
|
|
|
{
|
2017-10-06 18:07:43 +00:00
|
|
|
wxString old = GetCurLib();
|
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
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
if( aLibNickname.empty() || !Prj().SchSymbolLibTable()->HasLibrary( aLibNickname ) )
|
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
|
|
|
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
|
2009-12-22 20:08:56 +00:00
|
|
|
else
|
2017-10-06 18:07:43 +00:00
|
|
|
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, aLibNickname );
|
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
|
|
|
|
2017-11-13 11:19:14 +00:00
|
|
|
m_libMgr->SetCurrentLib( aLibNickname );
|
|
|
|
|
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 old;
|
2009-12-22 20:08:56 +00:00
|
|
|
}
|
2010-03-20 19:57:59 +00:00
|
|
|
|
2010-10-20 20:24:26 +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
|
|
|
void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart )
|
2010-10-23 10:09:23 +00:00
|
|
|
{
|
2018-05-31 06:59:14 +00:00
|
|
|
if( !aPart && !m_my_part )
|
|
|
|
return;
|
2018-04-17 19:19:21 +00:00
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
wxASSERT( m_my_part != aPart );
|
2018-05-31 06:59:14 +00:00
|
|
|
GetScreen()->SetCurItem( nullptr );
|
2017-11-12 17:55:20 +00:00
|
|
|
|
|
|
|
if( m_my_part != aPart )
|
|
|
|
{
|
2018-04-17 19:19:21 +00:00
|
|
|
if( m_my_part )
|
|
|
|
delete m_my_part;
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
m_my_part = aPart;
|
|
|
|
}
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2017-11-14 11:03:19 +00:00
|
|
|
// select the current component in the tree widget
|
|
|
|
if( aPart )
|
|
|
|
m_treePane->GetCmpTree()->SelectLibId( aPart->GetLibId() );
|
|
|
|
|
2017-11-13 11:19:14 +00:00
|
|
|
wxString partName = aPart ? aPart->GetName() : wxString();
|
|
|
|
m_libMgr->SetCurrentPart( partName );
|
|
|
|
|
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
|
|
|
// retain in case this wxFrame is re-opened later on the same PROJECT
|
2017-11-13 11:19:14 +00:00
|
|
|
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_PART, partName );
|
2018-01-22 12:33:24 +00:00
|
|
|
|
2018-01-23 11:15:19 +00:00
|
|
|
// Ensure synchronized pin edit can be enabled only symbols with interchangeable units
|
|
|
|
m_syncPinEdit = aPart && aPart->IsMulti() && !aPart->UnitsLocked();
|
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
|
|
|
}
|
2010-12-10 19:47:44 +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
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::TempCopyComponent()
|
|
|
|
{
|
|
|
|
delete m_tempCopyComponent;
|
|
|
|
|
|
|
|
if( LIB_PART* part = GetCurPart() )
|
|
|
|
// clone it and own the clone.
|
|
|
|
m_tempCopyComponent = new LIB_PART( *part );
|
|
|
|
else
|
|
|
|
// clear it, there was no CurPart
|
|
|
|
m_tempCopyComponent = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::RestoreComponent()
|
|
|
|
{
|
|
|
|
if( m_tempCopyComponent )
|
|
|
|
{
|
|
|
|
// transfer ownership to CurPart
|
|
|
|
SetCurPart( m_tempCopyComponent );
|
|
|
|
m_tempCopyComponent = NULL;
|
|
|
|
}
|
2010-10-20 20:24:26 +00:00
|
|
|
}
|
2010-10-23 13:49:14 +00:00
|
|
|
|
2011-08-12 17:43:16 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::ClearTempCopyComponent()
|
2010-10-23 13:49:14 +00:00
|
|
|
{
|
|
|
|
delete m_tempCopyComponent;
|
|
|
|
m_tempCopyComponent = NULL;
|
|
|
|
}
|
2010-11-17 21:47:27 +00:00
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem )
|
2010-11-17 21:47:27 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if ( ( DrawItem == NULL ) || ( DrawItem->Type() != LIB_TEXT_T ) )
|
2010-11-17 21:47:27 +00:00
|
|
|
return;
|
|
|
|
|
2012-09-02 12:06:47 +00:00
|
|
|
// Deleting old text
|
2010-11-17 21:47:27 +00:00
|
|
|
if( DC && !DrawItem->InEditMode() )
|
2017-02-20 17:48:27 +00:00
|
|
|
DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode, NULL,
|
2013-11-09 16:30:49 +00:00
|
|
|
DefaultTransform );
|
2010-11-17 21:47:27 +00:00
|
|
|
|
|
|
|
DIALOG_LIB_EDIT_TEXT* frame = new DIALOG_LIB_EDIT_TEXT( this, (LIB_TEXT*) DrawItem );
|
|
|
|
frame->ShowModal();
|
|
|
|
frame->Destroy();
|
|
|
|
OnModify();
|
|
|
|
|
2012-09-02 12:06:47 +00:00
|
|
|
// Display new text
|
2010-11-17 21:47:27 +00:00
|
|
|
if( DC && !DrawItem->InEditMode() )
|
2017-03-10 13:38:39 +00:00
|
|
|
DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, GR_DEFAULT_DRAWMODE,
|
|
|
|
NULL, DefaultTransform );
|
2010-11-17 21:47:27 +00:00
|
|
|
}
|
2010-11-18 21:10:52 +00:00
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
|
2010-11-18 21:10:52 +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
|
|
|
bool partLocked = GetCurPart()->UnitsLocked();
|
2017-11-12 17:55:20 +00:00
|
|
|
wxString oldName = GetCurPart()->GetName();
|
2010-11-18 21:10:52 +00:00
|
|
|
|
|
|
|
DIALOG_EDIT_COMPONENT_IN_LIBRARY dlg( this );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
2018-01-08 09:48:33 +00:00
|
|
|
// if m_UnitSelectionLocked has changed, set some edit options or defaults
|
|
|
|
// to the best value
|
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( partLocked != GetCurPart()->UnitsLocked() )
|
2010-11-18 21:10:52 +00:00
|
|
|
{
|
2018-01-23 11:15:19 +00:00
|
|
|
// Enable synchronized pin edit mode for symbols with interchangeable units
|
|
|
|
m_syncPinEdit = !GetCurPart()->UnitsLocked();
|
2018-01-08 09:48:33 +00:00
|
|
|
// also set default edit options to the better value
|
|
|
|
// Usually if units are locked, graphic items are specific to each unit
|
|
|
|
// and if units are interchangeable, graphic items are common to units
|
|
|
|
m_drawSpecificUnit = GetCurPart()->UnitsLocked() ? true : false;
|
2010-11-18 21:10:52 +00:00
|
|
|
}
|
|
|
|
|
2018-01-09 08:37:31 +00:00
|
|
|
if( oldName != GetCurPart()->GetName() )
|
|
|
|
m_libMgr->RemovePart( GetCurLib(), oldName );
|
|
|
|
|
|
|
|
m_libMgr->UpdatePart( GetCurPart(), GetCurLib() );
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
UpdateAliasSelectList();
|
|
|
|
UpdatePartSelectList();
|
|
|
|
DisplayLibInfos();
|
|
|
|
DisplayCmpDoc();
|
|
|
|
OnModify();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2010-11-18 21:10:52 +00:00
|
|
|
}
|
2010-11-19 16:28:46 +00:00
|
|
|
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
int id = aEvent.GetId();
|
2017-06-10 07:06:25 +00:00
|
|
|
int lastToolID = GetToolId();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2017-06-10 07:06:25 +00:00
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED || GetToolId() == ID_ZOOM_SELECTION )
|
2011-02-21 13:54:29 +00:00
|
|
|
m_lastDrawItem = NULL;
|
|
|
|
|
2017-06-10 07:06:25 +00:00
|
|
|
// Stop the current command and deselect the current tool.
|
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
2011-02-21 13:54:29 +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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
switch( id )
|
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( id, m_canvas->GetDefaultCursor(), wxEmptyString );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_ZOOM_SELECTION:
|
2016-06-08 11:19:53 +00:00
|
|
|
case ID_ZOOM_SELECTION:
|
2017-06-10 07:06:25 +00:00
|
|
|
// This tool is located on the main toolbar: switch it on or off on click on it
|
|
|
|
if( lastToolID != ID_ZOOM_SELECTION )
|
|
|
|
SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
|
|
|
|
else
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2016-06-08 11:19:53 +00:00
|
|
|
break;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_LIBEDIT_PIN_BUTT:
|
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( part )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add pin" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetToolID( id, wxCURSOR_ARROW, _( "Set pin options" ) );
|
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
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
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
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_TEXT_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_RECT_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add rectangle" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add circle" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_ARC_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add arc" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_LINE_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add line" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_HAND, _( "Set anchor position" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_IMPORT_BODY_BUTT:
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( id, m_canvas->GetDefaultCursor(), _( "Import" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
LoadOneSymbol();
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_EXPORT_BODY_BUTT:
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( id, m_canvas->GetDefaultCursor(), _( "Export" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
SaveOneSymbol();
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_DELETE_ITEM_BUTT:
|
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( !part )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
2011-02-24 22:29:43 +00:00
|
|
|
|
|
|
|
|
2011-02-28 13:53:49 +00:00
|
|
|
void LIB_EDIT_FRAME::OnRotateItem( wxCommandEvent& aEvent )
|
|
|
|
{
|
2017-12-18 05:21:00 +00:00
|
|
|
LIB_ITEM* item = GetDrawItem();
|
|
|
|
|
|
|
|
if( item == NULL )
|
2011-02-28 13:53:49 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
if( !item->InEditMode() )
|
2011-02-28 13:53:49 +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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
SaveCopyInUndoList( part );
|
2017-12-18 05:21:00 +00:00
|
|
|
item->SetUnit( m_unit );
|
2011-02-28 13:53:49 +00:00
|
|
|
}
|
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
item->Rotate();
|
2011-08-29 03:04:59 +00:00
|
|
|
OnModify();
|
2011-05-05 18:43:56 +00:00
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
if( !item->InEditMode() )
|
|
|
|
item->ClearFlags();
|
2011-05-05 18:43:56 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2011-02-28 13:53:49 +00:00
|
|
|
|
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
|
|
|
m_lastDrawItem = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-22 14:15:16 +00:00
|
|
|
void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
2018-04-09 11:40:15 +00:00
|
|
|
BLOCK_SELECTOR& block = screen->m_BlockLocate;
|
|
|
|
|
|
|
|
// Change the current item to a block selection, if there were no items in the block selector
|
|
|
|
if( screen->GetCurItem() && block.GetState() == STATE_NO_BLOCK )
|
|
|
|
{
|
|
|
|
ITEM_PICKER picker( screen->GetCurItem() );
|
|
|
|
block.PushItem( picker );
|
|
|
|
block.SetState( STATE_BLOCK_INIT );
|
|
|
|
|
|
|
|
const wxPoint& cursorPos = GetCrossHairPosition();
|
|
|
|
block.SetLastCursorPosition( cursorPos );
|
|
|
|
block.SetOrigin( cursorPos );
|
|
|
|
block.SetEnd( cursorPos );
|
|
|
|
}
|
|
|
|
|
2016-04-22 14:15:16 +00:00
|
|
|
// Allows block rotate operation on hot key.
|
2018-04-09 11:40:15 +00:00
|
|
|
if( block.GetState() != STATE_NO_BLOCK )
|
2016-04-22 14:15:16 +00:00
|
|
|
{
|
|
|
|
if( aEvent.GetId() == ID_LIBEDIT_MIRROR_X )
|
|
|
|
{
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2018-04-09 11:40:15 +00:00
|
|
|
block.SetMessageBlock( this );
|
|
|
|
block.SetCommand( BLOCK_MIRROR_X );
|
2016-04-22 14:15:16 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
}
|
|
|
|
else if( aEvent.GetId() == ID_LIBEDIT_MIRROR_Y )
|
|
|
|
{
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2018-04-09 11:40:15 +00:00
|
|
|
block.SetMessageBlock( this );
|
|
|
|
block.SetCommand( BLOCK_MIRROR_Y );
|
2016-04-22 14:15:16 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition,
|
|
|
|
const KICAD_T aFilterList[] )
|
2011-02-28 13:53:49 +00:00
|
|
|
{
|
2017-09-01 22:50:25 +00:00
|
|
|
wxPoint pos;
|
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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
if( !part )
|
2011-02-28 13:53:49 +00:00
|
|
|
return NULL;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* item = locateItem( aPosition, aFilterList );
|
|
|
|
|
2017-09-01 22:50:25 +00:00
|
|
|
// If the user aborted the clarification context menu, don't show it again at the
|
|
|
|
// grid position.
|
|
|
|
if( !item && m_canvas->GetAbortRequest() )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pos = GetNearestGridPosition( aPosition );
|
2011-02-28 13:53:49 +00:00
|
|
|
|
|
|
|
if( item == NULL && aPosition != pos )
|
2011-04-27 19:44:32 +00:00
|
|
|
item = locateItem( pos, aFilterList );
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aFilterList[] )
|
|
|
|
{
|
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
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
if( !part )
|
2011-04-27 19:44:32 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
LIB_ITEM* item = NULL;
|
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
m_collectedItems.Collect( part->GetDrawItems(), aFilterList, aPosition,
|
2011-04-27 19:44:32 +00:00
|
|
|
m_unit, m_convert );
|
|
|
|
|
|
|
|
if( m_collectedItems.GetCount() == 0 )
|
|
|
|
{
|
|
|
|
ClearMsgPanel();
|
|
|
|
}
|
|
|
|
else if( m_collectedItems.GetCount() == 1 )
|
|
|
|
{
|
|
|
|
item = m_collectedItems[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( item == NULL )
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( m_collectedItems.GetCount() <= MAX_SELECT_ITEM_IDS,
|
2017-03-10 13:38:39 +00:00
|
|
|
"Select item clarification context menu size limit exceeded." );
|
2011-04-27 19:44:32 +00:00
|
|
|
|
|
|
|
wxMenu selectMenu;
|
2016-08-15 18:22:54 +00:00
|
|
|
AddMenuItem( &selectMenu, wxID_NONE, _( "Clarify Selection" ),
|
2017-06-02 09:51:11 +00:00
|
|
|
KiBitmap( info_xpm ) );
|
2011-04-27 19:44:32 +00:00
|
|
|
|
|
|
|
selectMenu.AppendSeparator();
|
|
|
|
|
|
|
|
for( int i = 0; i < m_collectedItems.GetCount() && i < MAX_SELECT_ITEM_IDS; i++ )
|
|
|
|
{
|
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 text = m_collectedItems[i]->GetSelectMenuText();
|
|
|
|
BITMAP_DEF xpm = m_collectedItems[i]->GetMenuImage();
|
|
|
|
|
2011-09-08 05:58:45 +00:00
|
|
|
AddMenuItem( &selectMenu, ID_SELECT_ITEM_START + i, text, KiBitmap( xpm ) );
|
2011-04-27 19:44:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set to NULL in case user aborts the clarification context menu.
|
2017-12-18 05:21:00 +00:00
|
|
|
SetDrawItem( NULL );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAbortRequest( true ); // Changed to false if an item is selected
|
2011-04-27 19:44:32 +00:00
|
|
|
PopupMenu( &selectMenu );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2017-12-18 05:21:00 +00:00
|
|
|
item = GetDrawItem();
|
2011-04-27 19:44:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item )
|
2013-01-12 17:32:24 +00:00
|
|
|
{
|
|
|
|
MSG_PANEL_ITEMS items;
|
|
|
|
item->GetMsgPanelInfo( items );
|
|
|
|
SetMsgPanel( items );
|
|
|
|
}
|
2011-04-27 19:44:32 +00:00
|
|
|
else
|
2013-01-12 17:32:24 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
ClearMsgPanel();
|
2013-01-12 17:32:24 +00:00
|
|
|
}
|
2011-02-28 13:53:49 +00:00
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-04 17:19:17 +00:00
|
|
|
void LIB_EDIT_FRAME::deleteItem( wxDC* aDC, LIB_ITEM* aItem )
|
2011-02-24 22:29:43 +00:00
|
|
|
{
|
2018-04-04 17:19:17 +00:00
|
|
|
if( !aItem )
|
|
|
|
return;
|
2011-02-24 22:29:43 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( aDC );
|
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
|
|
|
|
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
SaveCopyInUndoList( part );
|
2011-02-24 22:29:43 +00:00
|
|
|
|
2018-04-04 17:19:17 +00:00
|
|
|
if( aItem->Type() == LIB_PIN_T )
|
2011-02-24 22:29:43 +00:00
|
|
|
{
|
2018-04-04 17:19:17 +00:00
|
|
|
LIB_PIN* pin = static_cast<LIB_PIN*>( aItem );
|
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
|
|
|
wxPoint pos = pin->GetPosition();
|
2011-02-24 22:29:43 +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
|
|
|
part->RemoveDrawItem( (LIB_ITEM*) pin, m_canvas, aDC );
|
2011-02-24 22:29:43 +00:00
|
|
|
|
2018-01-09 07:54:24 +00:00
|
|
|
// when pin edition is synchronized, all pins of the same body style
|
|
|
|
// are removed:
|
2011-10-28 13:43:37 +00:00
|
|
|
if( SynchronizePins() )
|
2011-02-24 22:29:43 +00:00
|
|
|
{
|
2018-01-09 07:54:24 +00:00
|
|
|
int curr_convert = pin->GetConvert();
|
|
|
|
LIB_PIN* next_pin = part->GetNextPin();
|
2011-02-24 22:29:43 +00:00
|
|
|
|
2018-01-09 07:54:24 +00:00
|
|
|
while( next_pin != NULL )
|
2011-02-24 22:29:43 +00:00
|
|
|
{
|
2018-01-09 07:54:24 +00:00
|
|
|
pin = next_pin;
|
|
|
|
next_pin = part->GetNextPin( pin );
|
2011-02-24 22:29:43 +00:00
|
|
|
|
|
|
|
if( pin->GetPosition() != pos )
|
|
|
|
continue;
|
|
|
|
|
2018-01-09 07:54:24 +00:00
|
|
|
if( pin->GetConvert() != curr_convert )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
part->RemoveDrawItem( pin );
|
2011-02-24 22:29:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-28 13:43:37 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2011-02-24 22:29:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2011-10-28 13:43:37 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallEndMouseCapture( aDC );
|
2011-10-28 13:43:37 +00:00
|
|
|
}
|
2011-02-24 22:29:43 +00:00
|
|
|
else
|
2011-10-28 13:43:37 +00:00
|
|
|
{
|
2018-04-04 17:19:17 +00:00
|
|
|
part->RemoveDrawItem( aItem, m_canvas, aDC );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2011-10-28 13:43:37 +00:00
|
|
|
}
|
2011-02-24 22:29:43 +00:00
|
|
|
}
|
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
SetDrawItem( NULL );
|
2011-07-07 12:54:02 +00:00
|
|
|
m_lastDrawItem = NULL;
|
2011-02-24 22:29:43 +00:00
|
|
|
OnModify();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( aDC );
|
2011-02-24 22:29:43 +00:00
|
|
|
}
|
2011-04-27 19:44:32 +00:00
|
|
|
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
void LIB_EDIT_FRAME::OnModify()
|
2017-10-31 11:13:20 +00:00
|
|
|
{
|
2017-11-12 17:55:20 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
storeCurrentPart();
|
|
|
|
m_treePane->GetCmpTree()->Refresh();
|
2017-10-31 11:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
void LIB_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
int id = aEvent.GetId();
|
|
|
|
int index = id - ID_SELECT_ITEM_START;
|
|
|
|
|
|
|
|
if( (id >= ID_SELECT_ITEM_START && id <= ID_SELECT_ITEM_END)
|
|
|
|
&& (index >= 0 && index < m_collectedItems.GetCount()) )
|
|
|
|
{
|
|
|
|
LIB_ITEM* item = m_collectedItems[index];
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAbortRequest( false );
|
2017-12-18 05:21:00 +00:00
|
|
|
SetDrawItem( item );
|
2011-04-27 19:44:32 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-28 13:43:37 +00:00
|
|
|
|
2017-03-10 13:38:39 +00:00
|
|
|
|
2015-03-27 10:26:07 +00:00
|
|
|
void LIB_EDIT_FRAME::OnOpenPinTable( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
LIB_PART* part = GetCurPart();
|
|
|
|
|
|
|
|
DIALOG_LIB_EDIT_PIN_TABLE dlg( this, *part );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2011-10-28 13:43:37 +00:00
|
|
|
|
2017-03-10 13:38:39 +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
|
|
|
bool LIB_EDIT_FRAME::SynchronizePins()
|
2011-10-28 13:43:37 +00:00
|
|
|
{
|
2018-01-23 11:15:19 +00:00
|
|
|
LIB_PART* part = GetCurPart();
|
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-01-23 11:15:19 +00:00
|
|
|
return m_syncPinEdit && part && part->IsMulti() && !part->UnitsLocked();
|
2011-10-28 13:43:37 +00:00
|
|
|
}
|
2017-03-10 13:38:39 +00:00
|
|
|
|
|
|
|
|
2017-03-10 15:09:55 +00:00
|
|
|
void LIB_EDIT_FRAME::refreshSchematic()
|
2017-03-10 13:38:39 +00:00
|
|
|
{
|
|
|
|
// This is not the most effecient way to do this because the changed library may not have
|
|
|
|
// any effect on the schematic symbol links. Since this is not called very often, take the
|
|
|
|
// hit here rather than the myriad other places (including SCH_SCREEN::Draw()) where it was
|
|
|
|
// being called.
|
|
|
|
SCH_SCREENS schematic;
|
|
|
|
|
|
|
|
schematic.UpdateSymbolLinks();
|
2017-03-10 14:36:55 +00:00
|
|
|
schematic.TestDanglingEnds();
|
2017-03-10 13:38:39 +00:00
|
|
|
|
|
|
|
// There may be no parent window so use KIWAY message to refresh the schematic editor
|
|
|
|
// in case any symbols have changed.
|
|
|
|
Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_REFRESH, std::string( "" ), this );
|
|
|
|
}
|
2017-11-12 17:55:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool LIB_EDIT_FRAME::addLibraryFile( bool aCreateNew )
|
|
|
|
{
|
|
|
|
wxFileName fileName = getLibraryFileName( !aCreateNew );
|
|
|
|
wxString libName = fileName.GetName();
|
2017-11-22 12:20:26 +00:00
|
|
|
bool res = false;
|
2017-11-12 17:55:20 +00:00
|
|
|
|
|
|
|
if( libName.IsEmpty() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_libMgr->LibraryExists( libName ) )
|
|
|
|
{
|
|
|
|
DisplayError( this,
|
2017-12-15 11:37:46 +00:00
|
|
|
wxString::Format( _( "Library \"%s\" already exists" ), GetChars( libName ) ) );
|
2017-11-12 17:55:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-22 13:02:45 +00:00
|
|
|
// Select the target library table (global/project)
|
|
|
|
SYMBOL_LIB_TABLE* libTable = selectSymLibTable();
|
|
|
|
|
|
|
|
if( !libTable )
|
|
|
|
return false;
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
if( aCreateNew )
|
2017-11-22 12:20:26 +00:00
|
|
|
{
|
2017-11-22 13:02:45 +00:00
|
|
|
res = m_libMgr->CreateLibrary( fileName.GetFullPath(), libTable );
|
2017-11-22 12:20:26 +00:00
|
|
|
|
2017-11-22 13:02:45 +00:00
|
|
|
if( !res )
|
2017-11-22 12:20:26 +00:00
|
|
|
DisplayError( this, _( "Could not create the library file. Check write permission." ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-22 13:02:45 +00:00
|
|
|
res = m_libMgr->AddLibrary( fileName.GetFullPath(), libTable );
|
2017-11-22 12:20:26 +00:00
|
|
|
|
|
|
|
if( !res )
|
|
|
|
DisplayError( this, _( "Could not open the library file." ) );
|
|
|
|
}
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2018-01-31 09:46:01 +00:00
|
|
|
bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
|
|
|
|
saveSymbolLibTables( globalTable, !globalTable );
|
|
|
|
|
2017-11-22 12:20:26 +00:00
|
|
|
return res;
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxFileName LIB_EDIT_FRAME::getLibraryFileName( bool aExisting )
|
|
|
|
{
|
|
|
|
wxFileName fn = m_libMgr->GetUniqueLibraryName();
|
|
|
|
fn.SetExt( SchematicLibraryFileExtension );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this,
|
|
|
|
aExisting ? _( "Select Library" ) : _( "New Library" ),
|
|
|
|
Prj().GetProjectPath(),
|
|
|
|
aExisting ? wxString( wxEmptyString ) : fn.GetFullName() ,
|
|
|
|
SchematicLibraryFileWildcard(),
|
|
|
|
aExisting ? wxFD_OPEN | wxFD_FILE_MUST_EXIST :
|
|
|
|
wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return wxFileName();
|
|
|
|
|
|
|
|
fn = dlg.GetPath();
|
|
|
|
fn.SetExt( SchematicLibraryFileExtension );
|
|
|
|
|
|
|
|
return fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LIB_PART* LIB_EDIT_FRAME::getTargetPart() const
|
|
|
|
{
|
|
|
|
LIB_ALIAS* alias = nullptr;
|
|
|
|
|
|
|
|
if( m_treePane->GetCmpTree()->IsMenuActive() )
|
|
|
|
{
|
|
|
|
LIB_ID libId = m_treePane->GetCmpTree()->GetSelectedLibId();
|
|
|
|
alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() );
|
|
|
|
}
|
|
|
|
else if( LIB_PART* part = GetCurPart() )
|
|
|
|
{
|
|
|
|
alias = part->GetAlias( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return alias ? alias->GetPart() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LIB_ID LIB_EDIT_FRAME::getTargetLibId() const
|
|
|
|
{
|
2018-05-02 22:33:53 +00:00
|
|
|
LIB_ID id = m_treePane->GetCmpTree()->GetSelectedLibId();
|
|
|
|
wxString nickname = id.GetLibNickname();
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2018-05-02 22:33:53 +00:00
|
|
|
if( nickname.IsEmpty() && GetCurPart() )
|
|
|
|
id = GetCurPart()->GetLibId();
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2018-05-02 22:33:53 +00:00
|
|
|
return id;
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString LIB_EDIT_FRAME::getTargetLib() const
|
|
|
|
{
|
2018-05-02 22:33:53 +00:00
|
|
|
return getTargetLibId().GetLibNickname();
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-30 11:31:36 +00:00
|
|
|
void LIB_EDIT_FRAME::SyncLibraries( bool aProgress )
|
2017-11-22 13:02:45 +00:00
|
|
|
{
|
2018-01-09 12:48:00 +00:00
|
|
|
LIB_ID selected;
|
|
|
|
|
|
|
|
if( m_treePane )
|
|
|
|
selected = m_treePane->GetCmpTree()->GetSelectedLibId();
|
|
|
|
|
2017-11-30 11:31:36 +00:00
|
|
|
if( aProgress )
|
|
|
|
{
|
2018-01-09 15:58:01 +00:00
|
|
|
wxProgressDialog progressDlg( _( "Loading Symbol Libraries" ),
|
2017-11-30 11:31:36 +00:00
|
|
|
wxEmptyString, m_libMgr->GetAdapter()->GetLibrariesCount(), this );
|
2017-11-22 13:02:45 +00:00
|
|
|
|
2017-11-30 11:31:36 +00:00
|
|
|
m_libMgr->Sync( true, [&]( int progress, int max, const wxString& libName ) {
|
2017-12-15 11:37:46 +00:00
|
|
|
progressDlg.Update( progress, wxString::Format( _( "Loading library \"%s\"" ), libName ) );
|
2017-11-30 11:31:36 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_libMgr->Sync( true );
|
|
|
|
}
|
2017-11-22 13:15:51 +00:00
|
|
|
|
2017-11-30 11:31:36 +00:00
|
|
|
if( m_treePane )
|
2018-01-09 12:48:00 +00:00
|
|
|
{
|
|
|
|
wxDataViewItem found;
|
|
|
|
|
|
|
|
if( selected.IsValid() )
|
|
|
|
{
|
|
|
|
// Check if the previously selected item is still valid,
|
|
|
|
// if not - it has to be unselected to prevent crash
|
|
|
|
found = m_libMgr->GetAdapter()->FindItem( selected );
|
|
|
|
|
|
|
|
if( !found )
|
|
|
|
m_treePane->GetCmpTree()->Unselect();
|
|
|
|
}
|
|
|
|
|
2017-11-30 11:31:36 +00:00
|
|
|
m_treePane->Regenerate();
|
2018-01-09 12:48:00 +00:00
|
|
|
|
|
|
|
// Try to select the parent library, in case the part is not found
|
|
|
|
if( !found && selected.IsValid() )
|
|
|
|
{
|
|
|
|
selected.SetLibItemName( "" );
|
|
|
|
found = m_libMgr->GetAdapter()->FindItem( selected );
|
|
|
|
|
|
|
|
if( found )
|
|
|
|
m_treePane->GetCmpTree()->SelectLibId( selected );
|
|
|
|
}
|
|
|
|
}
|
2017-11-22 13:02:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SYMBOL_LIB_TABLE* LIB_EDIT_FRAME::selectSymLibTable()
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
|
|
|
wxArrayString libTableNames;
|
2017-11-14 12:57:58 +00:00
|
|
|
libTableNames.Add( _( "Global" ) );
|
|
|
|
libTableNames.Add( _( "Project" ) );
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2017-11-14 12:57:58 +00:00
|
|
|
switch( SelectSingleOption( this, _( "Select Symbol Library Table" ),
|
|
|
|
_( "Choose the Library Table to add the library:" ), libTableNames ) )
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
|
|
|
case 0: return &SYMBOL_LIB_TABLE::GetGlobalLibTable();
|
|
|
|
case 1: return Prj().SchSymbolLibTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-13 14:15:10 +00:00
|
|
|
bool LIB_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt )
|
|
|
|
{
|
|
|
|
if( aOriginalFile.FileExists() )
|
|
|
|
{
|
|
|
|
wxFileName backupFileName( aOriginalFile );
|
|
|
|
backupFileName.SetExt( "bck" );
|
|
|
|
|
|
|
|
if( backupFileName.FileExists() )
|
|
|
|
wxRemoveFile( backupFileName.GetFullPath() );
|
|
|
|
|
|
|
|
if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Failed to save backup document to file " ) +
|
|
|
|
backupFileName.GetFullPath() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
void LIB_EDIT_FRAME::storeCurrentPart()
|
|
|
|
{
|
|
|
|
if( m_my_part && !GetCurLib().IsEmpty() && GetScreen()->IsModify() )
|
|
|
|
m_libMgr->UpdatePart( m_my_part, GetCurLib() ); // UpdatePart() makes a copy
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool LIB_EDIT_FRAME::isCurrentPart( const LIB_ID& aLibId ) const
|
|
|
|
{
|
2018-01-19 18:56:01 +00:00
|
|
|
// This will return the root part of any alias
|
|
|
|
LIB_PART* part = m_libMgr->GetBufferedPart( aLibId.GetLibItemName(), aLibId.GetLibNickname() );
|
|
|
|
// Now we can compare the libId of the current part and the root part
|
|
|
|
return ( GetCurPart() && part->GetLibId() == GetCurPart()->GetLibId() );
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::emptyScreen()
|
|
|
|
{
|
|
|
|
SetCurLib( wxEmptyString );
|
|
|
|
SetCurPart( nullptr );
|
|
|
|
m_aliasName.Empty();
|
2017-12-18 05:21:00 +00:00
|
|
|
m_lastDrawItem = nullptr;
|
|
|
|
SetDrawItem( NULL );
|
2017-11-12 17:55:20 +00:00
|
|
|
SetScreen( m_dummyScreen );
|
|
|
|
m_dummyScreen->ClearUndoRedoList();
|
|
|
|
Zoom_Automatique( false );
|
|
|
|
Refresh();
|
|
|
|
}
|
2018-01-08 04:05:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
int LIB_EDIT_FRAME::GetIconScale()
|
|
|
|
{
|
|
|
|
int scale = 0;
|
|
|
|
Kiface().KifaceSettings()->Read( LibIconScaleEntry, &scale, 0 );
|
|
|
|
return scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::SetIconScale( int aScale )
|
|
|
|
{
|
|
|
|
Kiface().KifaceSettings()->Write( LibIconScaleEntry, aScale );
|
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateOptToolbar();
|
|
|
|
Layout();
|
|
|
|
SendSizeEvent();
|
|
|
|
}
|