2011-10-28 13:43:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
2019-05-07 18:49:53 +00:00
|
|
|
* Copyright (C) 2019 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
|
|
|
|
*/
|
|
|
|
|
2019-05-07 18:49:53 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <tools/ee_selection_tool.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <lib_edit_frame.h>
|
2016-10-18 16:59:26 +00:00
|
|
|
#include <confirm.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <ee_actions.h>
|
2019-05-07 18:49:53 +00:00
|
|
|
#include <dialogs/dialog_lib_edit_pin.h>
|
2020-04-12 23:09:17 +00:00
|
|
|
#include <settings/settings_manager.h>
|
|
|
|
#include <libedit/libedit_settings.h>
|
|
|
|
#include <pgm_base.h>
|
2019-05-07 18:49:53 +00:00
|
|
|
#include "lib_pin_tool.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
static ELECTRICAL_PINTYPE g_LastPinType = ELECTRICAL_PINTYPE::PT_INPUT;
|
2019-05-07 18:49:53 +00:00
|
|
|
static int g_LastPinOrient = PIN_RIGHT;
|
2020-01-18 20:51:28 +00:00
|
|
|
static GRAPHIC_PINSHAPE g_LastPinShape = GRAPHIC_PINSHAPE::LINE;
|
2019-05-07 18:49:53 +00:00
|
|
|
static bool g_LastPinCommonConvert = false;
|
|
|
|
static bool g_LastPinCommonUnit = false;
|
|
|
|
static bool g_LastPinVisible = true;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2014-05-12 16:57:46 +00:00
|
|
|
// The -1 is a non-valid value to trigger delayed initialization
|
2019-05-07 18:49:53 +00:00
|
|
|
static int g_LastPinLength = -1;
|
|
|
|
static int g_LastPinNameSize = -1;
|
|
|
|
static int g_LastPinNumSize = -1;
|
2014-05-12 16:57:46 +00:00
|
|
|
|
|
|
|
static int GetLastPinLength()
|
|
|
|
{
|
2019-05-07 18:49:53 +00:00
|
|
|
if( g_LastPinLength == -1 )
|
2020-04-12 23:09:17 +00:00
|
|
|
{
|
|
|
|
LIBEDIT_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
|
|
|
|
g_LastPinLength = Mils2iu( settings->m_Defaults.pin_length );
|
|
|
|
}
|
2014-05-12 16:57:46 +00:00
|
|
|
|
2019-05-07 18:49:53 +00:00
|
|
|
return g_LastPinLength;
|
2014-05-12 16:57:46 +00:00
|
|
|
}
|
2010-11-19 16:28:46 +00:00
|
|
|
|
2014-05-16 13:57:53 +00:00
|
|
|
static int GetLastPinNameSize()
|
|
|
|
{
|
2019-05-07 18:49:53 +00:00
|
|
|
if( g_LastPinNameSize == -1 )
|
2020-04-12 23:09:17 +00:00
|
|
|
{
|
|
|
|
LIBEDIT_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
|
|
|
|
g_LastPinNameSize = Mils2iu( settings->m_Defaults.pin_name_size );
|
|
|
|
}
|
2014-05-16 13:57:53 +00:00
|
|
|
|
2019-05-07 18:49:53 +00:00
|
|
|
return g_LastPinNameSize;
|
2014-05-16 13:57:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int GetLastPinNumSize()
|
|
|
|
{
|
2019-05-07 18:49:53 +00:00
|
|
|
if( g_LastPinNumSize == -1 )
|
2020-04-12 23:09:17 +00:00
|
|
|
{
|
|
|
|
LIBEDIT_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
|
|
|
|
g_LastPinNumSize = Mils2iu( settings->m_Defaults.pin_num_size );
|
|
|
|
}
|
2019-05-07 18:49:53 +00:00
|
|
|
|
|
|
|
return g_LastPinNumSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern void IncrementLabelMember( wxString& name, int aIncrement );
|
|
|
|
|
|
|
|
|
|
|
|
LIB_PIN_TOOL::LIB_PIN_TOOL() :
|
2019-05-12 11:49:58 +00:00
|
|
|
EE_TOOL_BASE<LIB_EDIT_FRAME>( "eeschema.PinEditing" )
|
2019-05-07 18:49:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool LIB_PIN_TOOL::Init()
|
|
|
|
{
|
2019-05-12 11:49:58 +00:00
|
|
|
EE_TOOL_BASE::Init();
|
2019-05-07 18:49:53 +00:00
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
auto singlePinCondition = EE_CONDITIONS::Count( 1 ) && EE_CONDITIONS::OnlyType( LIB_PIN_T );
|
2019-05-08 18:56:03 +00:00
|
|
|
|
|
|
|
CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
|
|
|
|
|
2019-06-15 16:40:14 +00:00
|
|
|
selToolMenu.AddSeparator( 400 );
|
2019-05-10 17:19:48 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::pushPinLength, singlePinCondition, 400 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::pushPinNameSize, singlePinCondition, 400 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::pushPinNumSize, singlePinCondition, 400 );
|
2019-05-08 18:56:03 +00:00
|
|
|
|
2019-05-07 18:49:53 +00:00
|
|
|
return true;
|
2014-05-16 13:57:53 +00:00
|
|
|
}
|
|
|
|
|
2019-05-07 18:49:53 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
bool LIB_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
aPin->EnableEditMode( true, !m_frame->SynchronizePins() );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
DIALOG_LIB_EDIT_PIN dlg( m_frame, aPin );
|
2009-12-01 15:14:18 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
return false;
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
m_frame->RefreshItem( aPin );
|
|
|
|
m_frame->OnModify( );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
MSG_PANEL_ITEMS items;
|
|
|
|
aPin->GetMsgPanelInfo( m_frame->GetUserUnits(), items );
|
|
|
|
m_frame->SetMsgPanel( items );
|
2009-12-03 19:11:34 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
aPin->EnableEditMode( false );
|
2018-05-23 17:41:37 +00:00
|
|
|
|
|
|
|
// Save the pin properties to use for the next new pin.
|
2019-05-08 18:56:03 +00:00
|
|
|
g_LastPinNameSize = aPin->GetNameTextSize();
|
|
|
|
g_LastPinNumSize = aPin->GetNumberTextSize();
|
|
|
|
g_LastPinOrient = aPin->GetOrientation();
|
|
|
|
g_LastPinLength = aPin->GetLength();
|
|
|
|
g_LastPinShape = aPin->GetShape();
|
|
|
|
g_LastPinType = aPin->GetType();
|
|
|
|
g_LastPinCommonConvert = aPin->GetConvert() == 0;
|
|
|
|
g_LastPinCommonUnit = aPin->GetUnit() == 0;
|
|
|
|
g_LastPinVisible = aPin->IsVisible();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
bool LIB_PIN_TOOL::PlacePin( LIB_PIN* aPin )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
LIB_PART* part = m_frame->GetCurPart();
|
|
|
|
bool ask_for_pin = true; // Test for another pin in same position in other units
|
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-05-08 18:56:03 +00:00
|
|
|
for( LIB_PIN* test = part->GetNextPin(); test; test = part->GetNextPin( test ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
if( test == aPin || aPin->GetPosition() != test->GetPosition() || test->GetEditFlags() )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2018-01-09 07:54:24 +00:00
|
|
|
// test for same body style
|
2019-05-08 18:56:03 +00:00
|
|
|
if( test->GetConvert() && test->GetConvert() != aPin->GetConvert() )
|
2018-01-09 07:54:24 +00:00
|
|
|
continue;
|
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
if( ask_for_pin && m_frame->SynchronizePins() )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2018-01-08 09:48:33 +00:00
|
|
|
wxString msg;
|
2018-07-10 14:33:04 +00:00
|
|
|
msg.Printf( _( "This position is already occupied by another pin, in unit %d." ),
|
2019-05-08 18:56:03 +00:00
|
|
|
test->GetUnit() );
|
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-05-08 18:56:03 +00:00
|
|
|
KIDIALOG dlg( m_frame, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
|
2019-05-16 22:50:29 +00:00
|
|
|
dlg.SetOKLabel( _( "Place Pin Anyway" ) );
|
2018-08-29 22:37:20 +00:00
|
|
|
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
|
2018-07-10 14:33:04 +00:00
|
|
|
|
|
|
|
bool status = dlg.ShowModal() == wxID_OK;
|
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
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
if( !status )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
if( aPin->IsNew() )
|
|
|
|
delete aPin;
|
|
|
|
|
|
|
|
return false;
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
else
|
2019-05-08 18:56:03 +00:00
|
|
|
{
|
2009-05-09 17:29:48 +00:00
|
|
|
ask_for_pin = false;
|
2019-05-08 18:56:03 +00:00
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-27 12:12:34 +00:00
|
|
|
if( aPin->IsNew() && !aPin->HasFlag( IS_PASTED ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
g_LastPinOrient = aPin->GetOrientation();
|
|
|
|
g_LastPinType = aPin->GetType();
|
|
|
|
g_LastPinShape = aPin->GetShape();
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
if( m_frame->SynchronizePins() )
|
|
|
|
CreateImagePins( aPin );
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
part->AddDrawItem( aPin );
|
2019-07-03 11:19:32 +00:00
|
|
|
aPin->ClearFlags( IS_NEW );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// Put linked pins in new position, and clear flags
|
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( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2019-06-11 08:29:05 +00:00
|
|
|
if( ( pin->GetEditFlags() & IS_LINKED ) == 0 )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2019-05-09 07:57:07 +00:00
|
|
|
pin->MoveTo( aPin->GetPosition() );
|
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
|
|
|
pin->ClearFlags();
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
m_frame->RebuildView();
|
|
|
|
m_frame->OnModify();
|
2019-05-07 18:49:53 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/*
|
|
|
|
* Create a new pin.
|
|
|
|
*/
|
2019-05-07 18:49:53 +00:00
|
|
|
LIB_PIN* LIB_PIN_TOOL::CreatePin( const VECTOR2I& aPosition, LIB_PART* aPart )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-05-11 10:06:28 +00:00
|
|
|
aPart->ClearTempFlags();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2019-05-07 18:49:53 +00:00
|
|
|
LIB_PIN* pin = new LIB_PIN( aPart );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
pin->SetFlags( IS_NEW );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// Flag pins to consider
|
2019-05-07 18:49:53 +00:00
|
|
|
if( m_frame->SynchronizePins() )
|
2011-12-21 13:42:02 +00:00
|
|
|
pin->SetFlags( IS_LINKED );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2019-05-09 07:57:07 +00:00
|
|
|
pin->MoveTo((wxPoint) aPosition );
|
2014-05-12 16:57:46 +00:00
|
|
|
pin->SetLength( GetLastPinLength() );
|
2019-05-07 18:49:53 +00:00
|
|
|
pin->SetOrientation( g_LastPinOrient );
|
|
|
|
pin->SetType( g_LastPinType );
|
|
|
|
pin->SetShape( g_LastPinShape );
|
2014-05-16 13:57:53 +00:00
|
|
|
pin->SetNameTextSize( GetLastPinNameSize() );
|
|
|
|
pin->SetNumberTextSize( GetLastPinNumSize() );
|
2019-05-07 18:49:53 +00:00
|
|
|
pin->SetConvert( g_LastPinCommonConvert ? 0 : m_frame->GetConvert() );
|
|
|
|
pin->SetUnit( g_LastPinCommonUnit ? 0 : m_frame->GetUnit() );
|
|
|
|
pin->SetVisible( g_LastPinVisible );
|
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
if( !EditPinProperties( pin ) )
|
2009-11-11 02:44:58 +00:00
|
|
|
{
|
2019-05-07 18:49:53 +00:00
|
|
|
delete pin;
|
|
|
|
pin = nullptr;
|
2009-11-11 02:44:58 +00:00
|
|
|
}
|
2019-05-07 18:49:53 +00:00
|
|
|
|
|
|
|
return pin;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
void LIB_PIN_TOOL::CreateImagePins( LIB_PIN* aPin )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
int ii;
|
2018-01-08 09:48:33 +00:00
|
|
|
LIB_PIN* newPin;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2018-06-22 13:05:11 +00:00
|
|
|
// if "synchronize pins editing" option is off, do not create any similar pin for other
|
2018-01-08 09:48:33 +00:00
|
|
|
// units and/or shapes: each unit is edited regardless other units or body
|
2019-05-08 18:56:03 +00:00
|
|
|
if( !m_frame->SynchronizePins() )
|
2008-04-17 16:25:29 +00:00
|
|
|
return;
|
|
|
|
|
2018-01-09 07:54:24 +00:00
|
|
|
if( aPin->GetUnit() == 0 ) // Pin common to all units: no need to create similar pins.
|
|
|
|
return;
|
|
|
|
|
2018-01-08 09:48:33 +00:00
|
|
|
// When units are interchangeable, all units are expected to have similar pins
|
|
|
|
// at the same position
|
2018-06-22 13:05:11 +00:00
|
|
|
// to facilitate pin editing, create pins for all other units for the current body style
|
2018-01-08 09:48:33 +00:00
|
|
|
// at the same position as aPin
|
|
|
|
|
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( ii = 1; ii <= aPin->GetParent()->GetUnitCount(); ii++ )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2018-01-09 07:54:24 +00:00
|
|
|
if( ii == aPin->GetUnit() )
|
2018-01-08 09:48:33 +00:00
|
|
|
continue;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2018-01-08 09:48:33 +00:00
|
|
|
newPin = (LIB_PIN*) aPin->Clone();
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2015-10-27 13:52:54 +00:00
|
|
|
// To avoid mistakes, gives this pin a new pin number because
|
|
|
|
// it does no have the save pin number as the master pin
|
2018-01-08 09:48:33 +00:00
|
|
|
// Because we do not know the actual number, give it a temporary number
|
|
|
|
wxString unknownNum;
|
|
|
|
unknownNum.Printf( "%s-U%c", aPin->GetNumber(), wxChar( 'A' + ii - 1 ) );
|
|
|
|
newPin->SetNumber( unknownNum );
|
2015-10-27 13:52:54 +00:00
|
|
|
|
2018-01-08 09:48:33 +00:00
|
|
|
newPin->SetUnit( ii );
|
|
|
|
aPin->GetParent()->AddDrawItem( newPin );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
int LIB_PIN_TOOL::PushPinProperties( const TOOL_EVENT& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-06-08 21:48:22 +00:00
|
|
|
LIB_PART* part = m_frame->GetCurPart();
|
|
|
|
EE_SELECTION& selection = m_selectionTool->GetSelection();
|
|
|
|
LIB_PIN* sourcePin = dynamic_cast<LIB_PIN*>( selection.Front() );
|
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-05-08 18:56:03 +00:00
|
|
|
if( !sourcePin )
|
|
|
|
return 0;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2019-05-12 11:49:58 +00:00
|
|
|
saveCopyInUndoList( part, UR_LIBEDIT );
|
2015-02-25 19:43:37 +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
|
|
|
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
if( pin->GetConvert() && pin->GetConvert() != m_frame->GetConvert() )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
if( pin == sourcePin )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
if( aEvent.IsAction( &EE_ACTIONS::pushPinLength ) )
|
2019-05-08 18:56:03 +00:00
|
|
|
pin->SetLength( sourcePin->GetLength() );
|
2019-05-10 17:19:48 +00:00
|
|
|
else if( aEvent.IsAction( &EE_ACTIONS::pushPinNameSize ) )
|
2019-05-08 18:56:03 +00:00
|
|
|
pin->SetNameTextSize( sourcePin->GetNameTextSize() );
|
2019-05-10 17:19:48 +00:00
|
|
|
else if( aEvent.IsAction( &EE_ACTIONS::pushPinNumSize ) )
|
2019-05-08 18:56:03 +00:00
|
|
|
pin->SetNumberTextSize( sourcePin->GetNumberTextSize() );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2017-12-03 10:50:50 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
m_frame->RebuildView();
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
return 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// Create a new pin based on the previous pin with an incremented pin number.
|
2019-05-08 18:56:03 +00:00
|
|
|
LIB_PIN* LIB_PIN_TOOL::RepeatPin( const LIB_PIN* aSourcePin )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
LIB_PIN* pin = (LIB_PIN*) aSourcePin->Clone();
|
|
|
|
wxPoint step;
|
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
|
|
|
|
|
|
|
pin->ClearFlags();
|
|
|
|
pin->SetFlags( IS_NEW );
|
2015-04-22 11:39:00 +00:00
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
LIBEDIT_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
|
|
|
|
|
2015-04-22 11:39:00 +00:00
|
|
|
switch( pin->GetOrientation() )
|
|
|
|
{
|
2020-04-12 23:09:17 +00:00
|
|
|
case PIN_UP: step.x = settings->m_Repeat.pin_step; break;
|
|
|
|
case PIN_DOWN: step.x = settings->m_Repeat.pin_step; break;
|
|
|
|
case PIN_LEFT: step.y = -settings->m_Repeat.pin_step; break;
|
|
|
|
case PIN_RIGHT: step.y = -settings->m_Repeat.pin_step; break;
|
2015-04-22 11:39:00 +00:00
|
|
|
}
|
|
|
|
|
2019-05-09 07:57:07 +00:00
|
|
|
pin->Offset( step );
|
2019-05-08 18:56:03 +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 nextName = pin->GetName();
|
2020-04-12 23:09:17 +00:00
|
|
|
IncrementLabelMember( nextName, settings->m_Repeat.label_delta );
|
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
|
|
|
pin->SetName( nextName );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
wxString nextNumber = pin->GetNumber();
|
2020-04-12 23:09:17 +00:00
|
|
|
IncrementLabelMember( nextNumber, settings->m_Repeat.label_delta );
|
2019-05-08 18:56:03 +00:00
|
|
|
pin->SetNumber( nextNumber );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
if( m_frame->SynchronizePins() )
|
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
|
|
|
pin->SetFlags( IS_LINKED );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2020-01-12 01:02:55 +00:00
|
|
|
if( PlacePin( pin ) )
|
|
|
|
return pin;
|
2010-02-16 16:21:52 +00:00
|
|
|
|
2020-01-12 01:02:55 +00:00
|
|
|
return nullptr;
|
2019-05-08 18:56:03 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2018-10-18 09:50:43 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
void LIB_PIN_TOOL::setTransitions()
|
|
|
|
{
|
2019-05-10 17:19:48 +00:00
|
|
|
Go( &LIB_PIN_TOOL::PushPinProperties, EE_ACTIONS::pushPinLength.MakeEvent() );
|
|
|
|
Go( &LIB_PIN_TOOL::PushPinProperties, EE_ACTIONS::pushPinNameSize.MakeEvent() );
|
|
|
|
Go( &LIB_PIN_TOOL::PushPinProperties, EE_ACTIONS::pushPinNumSize.MakeEvent() );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|