2011-10-28 13:43:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2014-09-29 10:51:04 +00:00
|
|
|
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-10-06 18:07:43 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2019-04-15 21:09:14 +00:00
|
|
|
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-11-12 17:55:20 +00:00
|
|
|
* Copyright (C) 2017 CERN
|
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
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
|
|
|
|
*/
|
|
|
|
|
2018-01-30 10:49:51 +00:00
|
|
|
#ifndef LIB_EDIT_FRAME_H
|
|
|
|
#define LIB_EDIT_FRAME_H
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2012-01-09 17:24:01 +00:00
|
|
|
#include <sch_base_frame.h>
|
2018-01-30 08:56:43 +00:00
|
|
|
#include <sch_screen.h>
|
2019-08-15 07:09:52 +00:00
|
|
|
#include <lib_item.h>
|
2019-05-10 19:22:26 +00:00
|
|
|
#include <ee_collectors.h>
|
2017-11-13 19:39:36 +00:00
|
|
|
#include <core/optional.h>
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
class SCH_EDIT_FRAME;
|
2017-11-12 17:55:20 +00:00
|
|
|
class SYMBOL_LIB_TABLE;
|
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
|
|
|
class LIB_PART;
|
2010-11-10 15:30:12 +00:00
|
|
|
class LIB_FIELD;
|
2010-11-17 21:47:27 +00:00
|
|
|
class DIALOG_LIB_EDIT_TEXT;
|
2018-07-27 20:47:51 +00:00
|
|
|
class SYMBOL_TREE_PANE;
|
2017-10-06 18:07:43 +00:00
|
|
|
class LIB_ID;
|
2017-11-12 17:55:20 +00:00
|
|
|
class LIB_MANAGER;
|
2017-10-06 18:07:43 +00:00
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
|
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* The symbol library editor main window.
|
2010-02-04 17:46:12 +00:00
|
|
|
*/
|
2012-01-09 17:24:01 +00:00
|
|
|
class LIB_EDIT_FRAME : public SCH_BASE_FRAME
|
2010-02-04 17:46:12 +00:00
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
std::unique_ptr< LIB_PART > m_my_part; // a part I own, it is not in any library, but a copy
|
2019-06-16 18:51:47 +00:00
|
|
|
// could be.
|
|
|
|
wxComboBox* m_unitSelectBox; // a ComboBox to select a unit to edit (if the part
|
|
|
|
// has multiple units)
|
|
|
|
SYMBOL_TREE_PANE* m_treePane; // component search tree widget
|
2019-11-06 19:15:42 +00:00
|
|
|
LIB_MANAGER* m_libMgr; // manager taking care of temporary modifications
|
2011-04-27 19:44:32 +00:00
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
// The unit number to edit and show
|
2019-05-07 23:51:37 +00:00
|
|
|
int m_unit;
|
2011-12-09 16:37:11 +00:00
|
|
|
|
2019-06-16 18:51:47 +00:00
|
|
|
// Show the normal shape ( m_convert <= 1 ) or the converted shape ( m_convert > 1 )
|
2019-05-07 23:51:37 +00:00
|
|
|
int m_convert;
|
2011-12-09 16:37:11 +00:00
|
|
|
|
2019-06-16 18:51:47 +00:00
|
|
|
// True to force DeMorgan/normal tools selection enabled.
|
|
|
|
// They are enabled when the loaded component has graphic items for converted shape
|
|
|
|
// But under some circumstances (New component created) these tools must left enabled
|
2011-12-09 16:37:11 +00:00
|
|
|
static bool m_showDeMorgan;
|
|
|
|
|
2019-06-16 18:51:47 +00:00
|
|
|
static int m_textPinNumDefaultSize; // The default pin num text size setting.
|
|
|
|
static int m_textPinNameDefaultSize; // The default pin name text size setting.
|
|
|
|
static int m_defaultPinLength; // Default pin length
|
2014-08-25 16:31:32 +00:00
|
|
|
|
2015-04-22 11:39:00 +00:00
|
|
|
/// Default repeat offset for pins in repeat place pin
|
|
|
|
int m_repeatPinStep;
|
|
|
|
|
2019-02-05 15:06:36 +00:00
|
|
|
int m_defaultLibWidth;
|
2011-12-09 16:37:11 +00:00
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
public:
|
2019-05-11 14:38:05 +00:00
|
|
|
/**
|
2019-06-16 18:51:47 +00:00
|
|
|
* Set to true to synchronize pins at the same position when editing symbols with multiple
|
|
|
|
* units or multiple body styles. Deleting or moving pins will affect all pins at the same
|
|
|
|
* location.
|
|
|
|
* When units are interchangeable, synchronizing editing of pins is usually the best way,
|
|
|
|
* because if units are interchangeable, it implies that all similar pins are at the same
|
|
|
|
* location.
|
|
|
|
* When units are not interchangeable, do not synchronize editing of pins, because each part
|
|
|
|
* is specific, and there are no (or few) similar pins between units.
|
|
|
|
*
|
|
|
|
* Setting this to false allows editing each pin per part or body style regardless other
|
|
|
|
* pins at the same location. This requires the user to open each part or body style to make
|
|
|
|
* changes to the other pins at the same location.
|
2019-05-11 14:38:05 +00:00
|
|
|
*
|
2019-06-16 18:51:47 +00:00
|
|
|
* To know if others pins must be coupled when editing a pin, use SynchronizePins() instead
|
|
|
|
* of m_syncPinEdit, because SynchronizePins() is more reliable (takes in account the fact
|
|
|
|
* units are interchangeable, there are more than one unit).
|
2019-05-11 14:38:05 +00:00
|
|
|
*/
|
2019-06-16 18:51:47 +00:00
|
|
|
bool m_SyncPinEdit;
|
2019-05-11 14:38:05 +00:00
|
|
|
|
2019-05-07 18:49:53 +00:00
|
|
|
/** Convert of the item currently being drawn. */
|
|
|
|
bool m_DrawSpecificConvert;
|
* 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
|
|
|
|
2019-05-07 18:49:53 +00:00
|
|
|
/**
|
|
|
|
* Specify which component parts the current draw item applies to.
|
|
|
|
*
|
2019-06-16 18:51:47 +00:00
|
|
|
* If true, the item being drawn or edited applies only to the selected part. Otherwise
|
|
|
|
* it applies to all parts in the component.
|
2019-05-07 18:49:53 +00:00
|
|
|
*/
|
|
|
|
bool m_DrawSpecificUnit;
|
|
|
|
|
|
|
|
static int g_LastTextSize;
|
|
|
|
static double g_LastTextAngle;
|
2019-05-07 23:51:37 +00:00
|
|
|
static FILL_T g_LastFillStyle;
|
|
|
|
static int g_LastLineWidth;
|
2019-05-07 18:49:53 +00:00
|
|
|
|
|
|
|
public:
|
2014-05-05 15:15:54 +00:00
|
|
|
LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
~LIB_EDIT_FRAME() override;
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2019-02-24 11:56:17 +00:00
|
|
|
/**
|
|
|
|
* switches currently used canvas ( Cairo / OpenGL).
|
|
|
|
*/
|
2019-05-28 13:51:47 +00:00
|
|
|
void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
|
2019-02-24 11:56:17 +00:00
|
|
|
|
2019-06-13 11:44:12 +00:00
|
|
|
/**
|
|
|
|
* Check if any pending libraries have been modified.
|
|
|
|
*
|
2019-06-16 18:51:47 +00:00
|
|
|
* This only checks for modified libraries. If a new symbol was created and modified
|
|
|
|
* and no libraries have been modified, the return value will be false.
|
2019-06-13 11:44:12 +00:00
|
|
|
*
|
|
|
|
* @return True if there are any pending library modifications.
|
|
|
|
*/
|
|
|
|
bool HasLibModifications() const;
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
/** The nickname of the current library being edited and empty string if none. */
|
2017-11-12 17:55:20 +00:00
|
|
|
wxString GetCurLib() const;
|
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
|
|
|
/** Sets the current library nickname and returns the old library nickname. */
|
|
|
|
wxString 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
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
/**
|
|
|
|
* Return the LIB_ID of the library or symbol selected in the symbol tree.
|
|
|
|
*/
|
2019-06-05 22:29:59 +00:00
|
|
|
LIB_ID GetTreeLIBID( int* aUnit = nullptr ) const;
|
2019-06-05 19:15:57 +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
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Return the current part being edited or NULL if none 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
|
|
|
* This is a LIB_PART that I own, it is at best a copy of one in a library.
|
|
|
|
*/
|
2019-11-06 19:15:42 +00:00
|
|
|
LIB_PART* GetCurPart() { return m_my_part.get(); }
|
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
|
|
|
* Take ownership of aPart and notes that it is the one currently being edited.
|
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 SetCurPart( LIB_PART* aPart );
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
LIB_MANAGER& GetLibManager();
|
|
|
|
|
2014-08-25 16:31:32 +00:00
|
|
|
static int GetPinNumDefaultSize() { return m_textPinNumDefaultSize; }
|
2018-05-14 17:34:18 +00:00
|
|
|
static void SetPinNumDefaultSize( int aSize ) { m_textPinNumDefaultSize = aSize; }
|
2014-08-25 16:31:32 +00:00
|
|
|
|
|
|
|
static int GetPinNameDefaultSize() { return m_textPinNameDefaultSize; }
|
2018-05-14 17:34:18 +00:00
|
|
|
static void SetPinNameDefaultSize( int aSize ) { m_textPinNameDefaultSize = aSize; }
|
2014-08-25 16:31:32 +00:00
|
|
|
|
|
|
|
static int GetDefaultPinLength() { return m_defaultPinLength; }
|
2015-04-22 11:39:00 +00:00
|
|
|
static void SetDefaultPinLength( int aLength ) { m_defaultPinLength = aLength; }
|
|
|
|
|
|
|
|
/**
|
2019-06-02 23:17:27 +00:00
|
|
|
* @return the increment value of the position of a pin for the pin repeat command
|
2015-04-22 11:39:00 +00:00
|
|
|
*/
|
|
|
|
int GetRepeatPinStep() const { return m_repeatPinStep; }
|
|
|
|
void SetRepeatPinStep( int aStep) { m_repeatPinStep = aStep; }
|
2014-08-25 16:31:32 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void ReCreateMenuBar() override;
|
2010-03-18 20:35:29 +00:00
|
|
|
|
2019-06-16 18:51:47 +00:00
|
|
|
// See comments for m_SyncPinEdit.
|
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 SynchronizePins();
|
2011-10-28 13:43:37 +00:00
|
|
|
|
2019-05-10 19:57:24 +00:00
|
|
|
void OnImportBody( wxCommandEvent& aEvent );
|
|
|
|
void OnExportBody( wxCommandEvent& aEvent );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
/**
|
2019-06-02 18:58:09 +00:00
|
|
|
* Creates or adds an existing library to the symbol library table.
|
2017-11-12 17:55:20 +00:00
|
|
|
*/
|
2019-06-02 18:58:09 +00:00
|
|
|
bool AddLibraryFile( bool aCreateNew );
|
2017-11-12 17:55:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new part in the selected library.
|
|
|
|
*/
|
2019-06-02 18:58:09 +00:00
|
|
|
void CreateNewPart();
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2019-06-02 18:58:09 +00:00
|
|
|
void ImportPart();
|
2019-06-05 22:29:59 +00:00
|
|
|
void ExportPart();
|
2017-10-31 11:13:20 +00:00
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
/**
|
2018-07-27 10:46:09 +00:00
|
|
|
* Saves the selected part or library.
|
|
|
|
*/
|
2019-06-05 22:29:59 +00:00
|
|
|
void Save();
|
2018-07-27 10:46:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves the selected part or library to a new name and/or location.
|
2017-11-12 17:55:20 +00:00
|
|
|
*/
|
2019-06-05 22:29:59 +00:00
|
|
|
void SaveAs();
|
2018-07-27 10:46:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves all modified parts and libraries.
|
|
|
|
*/
|
2019-06-05 22:29:59 +00:00
|
|
|
void SaveAll();
|
2017-11-12 17:55:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverts unsaved changes in a part, restoring to the last saved state.
|
|
|
|
*/
|
2019-06-13 11:44:12 +00:00
|
|
|
void Revert( bool aConfirm = true );
|
|
|
|
void RevertAll();
|
2019-06-05 22:29:59 +00:00
|
|
|
|
|
|
|
void DeletePartFromLibrary();
|
2019-06-13 11:44:12 +00:00
|
|
|
|
2019-06-05 22:29:59 +00:00
|
|
|
void CopyPartToClipboard();
|
|
|
|
|
|
|
|
void LoadPart( const wxString& aLibrary, const wxString& aPart, int Unit );
|
2017-11-12 17:55:20 +00:00
|
|
|
|
|
|
|
/**
|
2019-06-05 22:29:59 +00:00
|
|
|
* Inserts a duplicate part. If aFromClipboard is true then action is a paste.
|
2017-11-12 17:55:20 +00:00
|
|
|
*/
|
2019-06-05 22:29:59 +00:00
|
|
|
void DuplicatePart( bool aFromClipboard );
|
2017-11-13 19:39:36 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
void OnSelectUnit( wxCommandEvent& event );
|
2011-08-12 17:43:16 +00:00
|
|
|
|
2017-10-31 11:13:20 +00:00
|
|
|
void OnToggleSearchTree( wxCommandEvent& event );
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
bool IsSearchTreeShown();
|
2019-06-02 23:17:27 +00:00
|
|
|
void FreezeSearchTree();
|
|
|
|
void ThawSearchTree();
|
2011-08-12 17:43:16 +00:00
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
void OnUpdatePartNumber( wxUpdateUIEvent& event );
|
|
|
|
|
2019-05-11 14:38:05 +00:00
|
|
|
void UpdateAfterSymbolProperties( wxString* aOldName, wxArrayString* aOldAliases );
|
2019-05-06 12:32:51 +00:00
|
|
|
void RebuildSymbolUnitsList();
|
2011-08-12 17:43:16 +00:00
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
void OnCloseWindow( wxCloseEvent& Event );
|
2019-11-06 19:15:42 +00:00
|
|
|
void OnExitKiCad( wxCommandEvent& event );
|
2016-09-24 18:53:15 +00:00
|
|
|
void ReCreateHToolbar() override;
|
|
|
|
void ReCreateVToolbar() override;
|
2019-07-20 15:52:30 +00:00
|
|
|
void ReCreateOptToolbar() override;
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void LoadSettings( wxConfigBase* aCfg ) override;
|
|
|
|
void SaveSettings( wxConfigBase* aCfg ) override;
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2010-07-23 14:12:37 +00:00
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro:
|
2010-07-23 14:12:37 +00:00
|
|
|
* <p>
|
2010-11-19 16:28:46 +00:00
|
|
|
* EVT_CLOSE( LIB_EDIT_FRAME::OnCloseWindow )
|
2017-10-06 18:07:43 +00:00
|
|
|
* </p>
|
2010-07-23 14:12:37 +00:00
|
|
|
*/
|
2010-12-14 21:39:31 +00:00
|
|
|
void CloseWindow( wxCommandEvent& event )
|
2010-07-23 14:12:37 +00:00
|
|
|
{
|
|
|
|
// Generate a wxCloseEvent
|
|
|
|
Close( false );
|
|
|
|
}
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Must be called after a schematic change in order to set the "modify" flag of the
|
2019-05-08 18:56:03 +00:00
|
|
|
* current symbol.
|
2010-02-18 20:07:29 +00:00
|
|
|
*/
|
2019-05-08 18:56:03 +00:00
|
|
|
void OnModify() override;
|
2010-02-18 20:07:29 +00:00
|
|
|
|
2019-06-01 19:48:01 +00:00
|
|
|
int GetUnit() const { return m_unit; }
|
|
|
|
void SetUnit( int aUnit ) { m_unit = aUnit; }
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2019-06-01 19:48:01 +00:00
|
|
|
int GetConvert() const { return m_convert; }
|
|
|
|
void SetConvert( int aConvert ) { m_convert = aConvert; }
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2019-06-01 19:48:01 +00:00
|
|
|
bool GetShowDeMorgan() const { return m_showDeMorgan; }
|
2011-10-07 14:41:30 +00:00
|
|
|
void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2019-05-06 12:32:51 +00:00
|
|
|
void ClearMsgPanel() override { DisplayCmpDoc(); }
|
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
private:
|
2019-05-04 11:23:04 +00:00
|
|
|
// Sets up the tool framework
|
|
|
|
void setupTools();
|
|
|
|
|
2018-07-27 10:46:09 +00:00
|
|
|
void savePartAs();
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
/**
|
|
|
|
* Saves the changes to the current library.
|
|
|
|
*
|
|
|
|
* A backup file of the current library is saved with the .bak extension before the
|
|
|
|
* changes made to the library are saved.
|
|
|
|
* @param aLibrary is the library name.
|
|
|
|
* @param aNewFile Ask for a new file name to save the library.
|
|
|
|
* @return True if the library was successfully saved.
|
|
|
|
*/
|
|
|
|
bool saveLibrary( const wxString& aLibrary, bool aNewFile );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2018-10-05 12:55:34 +00:00
|
|
|
/**
|
|
|
|
* Updates the main window title bar with the current library name and read only status
|
|
|
|
* of the library.
|
|
|
|
*/
|
|
|
|
void updateTitle();
|
|
|
|
|
2011-05-28 18:51:32 +00:00
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Set the current active library to \a aLibrary.
|
2011-08-12 17:43:16 +00:00
|
|
|
*
|
2019-06-16 18:51:47 +00:00
|
|
|
* @param aLibrary the nickname of the library in the symbol library table. If empty,
|
|
|
|
* display list of available libraries to select from.
|
2011-05-28 18:51:32 +00:00
|
|
|
*/
|
2017-10-06 18:07:43 +00:00
|
|
|
void SelectActiveLibrary( const wxString& aLibrary = wxEmptyString );
|
2011-05-28 18:51:32 +00:00
|
|
|
|
2019-05-10 19:57:24 +00:00
|
|
|
/**
|
2019-08-20 17:22:30 +00:00
|
|
|
* Display a list of loaded libraries in the symbol library and allows the user to select
|
2019-05-10 19:57:24 +00:00
|
|
|
* a library.
|
|
|
|
*
|
|
|
|
* This list is sorted, with the library cache always at end of the list
|
|
|
|
*
|
|
|
|
* @return the library nickname used in the symbol library table.
|
|
|
|
*/
|
|
|
|
wxString SelectLibraryFromList();
|
|
|
|
|
2011-05-28 18:51:32 +00:00
|
|
|
/**
|
2019-06-16 18:51:47 +00:00
|
|
|
* Loads a symbol from the current active library, optionally setting the selected unit
|
|
|
|
* and convert.
|
2017-10-06 18:07:43 +00:00
|
|
|
*
|
|
|
|
* @param aAliasName The symbol alias name to load from the current library.
|
2017-07-19 17:34:55 +00:00
|
|
|
* @param aUnit Unit to be selected
|
|
|
|
* @param aConvert Convert to be selected
|
2017-10-06 18:07:43 +00:00
|
|
|
* @return true if the symbol loaded correctly.
|
2011-05-28 18:51:32 +00:00
|
|
|
*/
|
2017-10-06 18:07:43 +00:00
|
|
|
bool LoadComponentFromCurrentLib( const wxString& aAliasName, int aUnit = 0, int aConvert = 0 );
|
2011-05-28 18:51:32 +00:00
|
|
|
|
2011-08-12 17:43:16 +00:00
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Create a copy of \a aLibEntry into memory.
|
2011-08-12 17:43:16 +00:00
|
|
|
*
|
2019-11-06 19:15:42 +00:00
|
|
|
* @param aLibEntry A pointer to the LIB_PART object to an already loaded symbol.
|
2017-10-06 18:07:43 +00:00
|
|
|
* @param aLibrary the path to the library file that \a aLibEntry was loaded from. This is
|
|
|
|
* for error messaging purposes only.
|
2018-11-08 21:26:01 +00:00
|
|
|
* @param aUnit the initial unit to show.
|
|
|
|
* @param aConvert the initial DeMorgan variant to show.
|
2017-10-06 18:07:43 +00:00
|
|
|
* @return True if a copy of \a aLibEntry was successfully copied.
|
2011-08-12 17:43:16 +00:00
|
|
|
*/
|
2019-11-06 19:15:42 +00:00
|
|
|
bool LoadOneLibraryPartAux( LIB_PART* aLibEntry, const wxString& aLibrary, int aUnit,
|
2019-06-16 18:51:47 +00:00
|
|
|
int aConvert );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2011-08-12 17:43:16 +00:00
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Display the documentation of the selected component.
|
2011-08-12 17:43:16 +00:00
|
|
|
*/
|
|
|
|
void DisplayCmpDoc();
|
2010-02-04 17:46:12 +00:00
|
|
|
|
|
|
|
// General editing
|
|
|
|
public:
|
2015-01-27 11:01:58 +00:00
|
|
|
/**
|
|
|
|
* Create a copy of the current component, and save it in the undo list.
|
2017-10-06 18:07:43 +00:00
|
|
|
*
|
2018-01-19 18:56:01 +00:00
|
|
|
* Because a component in library editor does not have a lot of primitives,
|
|
|
|
* the full data is duplicated. It is not worth to try to optimize this save function.
|
2015-01-27 11:01:58 +00:00
|
|
|
*/
|
2019-05-12 11:49:58 +00:00
|
|
|
void SaveCopyInUndoList( EDA_ITEM* ItemToCopy, UNDO_REDO_T undoType = UR_LIBEDIT,
|
|
|
|
bool aAppend = false );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
void GetComponentFromUndoList();
|
|
|
|
void GetComponentFromRedoList();
|
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
void RollbackPartFromUndo();
|
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
private:
|
2011-10-07 14:41:30 +00:00
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Read a component symbol file (*.sym ) and add graphic items to the current component.
|
|
|
|
*
|
|
|
|
* A symbol file *.sym has the same format as a library, and contains only one symbol.
|
2011-10-07 14:41:30 +00:00
|
|
|
*/
|
|
|
|
void LoadOneSymbol();
|
|
|
|
|
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Saves the current symbol to a symbol file.
|
|
|
|
*
|
2011-10-07 14:41:30 +00:00
|
|
|
* The symbol file format is similar to the standard component library file format, but
|
|
|
|
* there is only one symbol. Invisible pins are not saved.
|
|
|
|
*/
|
|
|
|
void SaveOneSymbol();
|
|
|
|
|
2017-03-10 15:09:55 +00:00
|
|
|
void refreshSchematic();
|
2017-03-10 13:38:39 +00:00
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
public:
|
2011-05-28 18:51:32 +00:00
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Selects the currently active library and loads the symbol from \a aLibId.
|
2011-08-12 17:43:16 +00:00
|
|
|
*
|
2017-10-06 18:07:43 +00:00
|
|
|
* @param aLibId is the #LIB_ID of the symbol to select.
|
2018-11-08 21:26:01 +00:00
|
|
|
* @param aUnit the unit to show
|
|
|
|
* @param aConvert the DeMorgan variant to show
|
2017-10-06 18:07:43 +00:00
|
|
|
* @return true if the symbol defined by \a aLibId was loaded.
|
2011-05-28 18:51:32 +00:00
|
|
|
*/
|
2018-11-08 21:26:01 +00:00
|
|
|
bool LoadComponentAndSelectLib( const LIB_ID& aLibId, int aUnit, int aConvert );
|
2011-05-28 18:51:32 +00:00
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
/**
|
2017-10-06 18:07:43 +00:00
|
|
|
* Print a page
|
|
|
|
*
|
2010-03-18 20:35:29 +00:00
|
|
|
* @param aDC = wxDC given by the calling print function
|
|
|
|
*/
|
2019-06-01 19:48:01 +00:00
|
|
|
void PrintPage( wxDC* aDC ) override;
|
2010-03-18 20:35:29 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2010-03-28 14:46:49 +00:00
|
|
|
* Creates the SVG print file for the current edited component.
|
2011-08-12 17:43:16 +00:00
|
|
|
*/
|
2013-05-18 09:38:23 +00:00
|
|
|
void SVG_PlotComponent( const wxString& aFullFileName );
|
2010-03-28 14:46:49 +00:00
|
|
|
|
2017-11-22 11:06:17 +00:00
|
|
|
/**
|
2018-08-25 12:21:09 +00:00
|
|
|
* Synchronize the library manager to the symbol library table, and then the symbol tree
|
|
|
|
* to the library manager. Optionally displays a progress dialog.
|
2017-11-22 11:06:17 +00:00
|
|
|
*/
|
2018-08-25 12:21:09 +00:00
|
|
|
void SyncLibraries( bool aShowProgress );
|
2017-11-22 11:06:17 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
/**
|
|
|
|
* Allows Libedit to install its preferences panel into the preferences dialog.
|
|
|
|
*/
|
2019-06-09 21:57:23 +00:00
|
|
|
void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called after the preferences dialog is run.
|
|
|
|
*/
|
2019-06-24 09:22:49 +00:00
|
|
|
void CommonSettingsChanged( bool aEnvVarsChanged ) override;
|
2018-01-08 04:05:03 +00:00
|
|
|
|
2018-06-30 22:38:04 +00:00
|
|
|
void ShowChangedLanguage() override;
|
|
|
|
|
2019-06-10 14:35:01 +00:00
|
|
|
void SyncToolbars() override;
|
2019-05-13 20:42:40 +00:00
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
void SetScreen( BASE_SCREEN* aScreen ) override;
|
2018-08-03 12:17:19 +00:00
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
const BOX2I GetDocumentExtents() const override;
|
2018-08-03 12:17:19 +00:00
|
|
|
|
|
|
|
void RebuildView();
|
|
|
|
|
2018-10-17 11:14:09 +00:00
|
|
|
/**
|
|
|
|
* Rebuild the GAL and redraw the screen. Call when something went wrong.
|
|
|
|
*/
|
|
|
|
void HardRedraw() override;
|
|
|
|
|
2018-08-19 16:53:01 +00:00
|
|
|
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
|
|
|
|
|
2019-06-13 11:44:12 +00:00
|
|
|
///> Restores the empty editor screen, without any part or library selected.
|
|
|
|
void emptyScreen();
|
|
|
|
|
2017-11-13 21:12:49 +00:00
|
|
|
private:
|
2017-11-12 17:55:20 +00:00
|
|
|
///> Helper screen used when no part is loaded
|
|
|
|
SCH_SCREEN* m_dummyScreen;
|
|
|
|
|
2017-11-22 13:02:45 +00:00
|
|
|
/**
|
|
|
|
* Displays a dialog asking the user to select a symbol library table.
|
2018-08-23 11:48:14 +00:00
|
|
|
* @param aOptional if set the Cancel button will be relabelled "Skip".
|
2019-11-06 19:15:42 +00:00
|
|
|
* @return Pointer to the selected symbol library table or nullptr if canceled.
|
2017-11-22 13:02:45 +00:00
|
|
|
*/
|
2018-08-23 11:48:14 +00:00
|
|
|
SYMBOL_LIB_TABLE* selectSymLibTable( bool aOptional = false );
|
2017-11-22 13:02:45 +00:00
|
|
|
|
2017-11-13 14:15:10 +00:00
|
|
|
///> Creates a backup copy of a file with requested extension
|
|
|
|
bool backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt );
|
|
|
|
|
2017-11-13 21:12:49 +00:00
|
|
|
///> Returns currently edited part.
|
2017-11-12 17:55:20 +00:00
|
|
|
LIB_PART* getTargetPart() const;
|
|
|
|
|
2017-11-13 21:12:49 +00:00
|
|
|
///> Returns either the part selected in the component tree, if context menu is active
|
|
|
|
///> or the currently modified part.
|
2017-11-12 17:55:20 +00:00
|
|
|
LIB_ID getTargetLibId() const;
|
|
|
|
|
2017-11-13 21:12:49 +00:00
|
|
|
///> Returns either the library selected in the component tree, if context menu is active
|
|
|
|
///> or the library that is currently modified.
|
|
|
|
wxString getTargetLib() const;
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
/* Returns true when the operation has succeeded (all requested libraries have been saved or
|
2018-02-16 10:27:43 +00:00
|
|
|
* none was selected and confirmed by OK).
|
2018-08-01 13:36:42 +00:00
|
|
|
* @param aRequireConfirmation when true, the user must be asked to confirm.
|
2018-02-16 10:27:43 +00:00
|
|
|
*/
|
2018-08-01 13:36:42 +00:00
|
|
|
bool saveAllLibraries( bool aRequireConfirmation );
|
2017-11-13 09:55:05 +00:00
|
|
|
|
2018-08-11 20:46:03 +00:00
|
|
|
///> Saves the current part.
|
|
|
|
bool saveCurrentPart();
|
|
|
|
|
2017-11-13 21:12:49 +00:00
|
|
|
///> Stores the currently modified part in the library manager buffer.
|
2017-11-12 17:55:20 +00:00
|
|
|
void storeCurrentPart();
|
|
|
|
|
2018-01-19 18:56:01 +00:00
|
|
|
///> Returns true if \a aLibId is an alias for the editor screen part.
|
2017-11-12 17:55:20 +00:00
|
|
|
bool isCurrentPart( const LIB_ID& aLibId ) const;
|
|
|
|
|
2017-11-13 19:39:36 +00:00
|
|
|
///> Renames LIB_PART aliases to avoid conflicts before adding a component to a library
|
|
|
|
void fixDuplicateAliases( LIB_PART* aPart, const wxString& aLibrary );
|
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
2018-01-30 10:49:51 +00:00
|
|
|
#endif // LIB_EDIT_FRAME_H
|