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
|
2021-01-08 23:24:12 +00:00
|
|
|
* Copyright (C) 2019-2021 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>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_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>
|
2020-08-03 21:12:29 +00:00
|
|
|
#include <dialogs/dialog_pin_properties.h>
|
2020-04-12 23:09:17 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_editor/symbol_editor_settings.h>
|
2020-04-12 23:09:17 +00:00
|
|
|
#include <pgm_base.h>
|
2021-06-03 12:11:15 +00:00
|
|
|
#include <wx/log.h>
|
2020-12-12 03:13:52 +00:00
|
|
|
#include "symbol_editor_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
|
|
|
{
|
2020-10-31 01:27:16 +00:00
|
|
|
auto* settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
2020-04-12 23:09:17 +00:00
|
|
|
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
|
|
|
{
|
2020-10-31 01:27:16 +00:00
|
|
|
auto* settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
2020-04-12 23:09:17 +00:00
|
|
|
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
|
|
|
{
|
2020-10-31 01:27:16 +00:00
|
|
|
auto* settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
2020-04-12 23:09:17 +00:00
|
|
|
g_LastPinNumSize = Mils2iu( settings->m_Defaults.pin_num_size );
|
|
|
|
}
|
2019-05-07 18:49:53 +00:00
|
|
|
|
|
|
|
return g_LastPinNumSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-04 12:48:32 +00:00
|
|
|
extern bool IncrementLabelMember( wxString& name, int aIncrement );
|
2019-05-07 18:49:53 +00:00
|
|
|
|
|
|
|
|
2020-12-12 03:13:52 +00:00
|
|
|
SYMBOL_EDITOR_PIN_TOOL::SYMBOL_EDITOR_PIN_TOOL() :
|
2020-10-31 01:27:16 +00:00
|
|
|
EE_TOOL_BASE<SYMBOL_EDIT_FRAME>( "eeschema.PinEditing" )
|
2019-05-07 18:49:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-12 03:13:52 +00:00
|
|
|
bool SYMBOL_EDITOR_PIN_TOOL::Init()
|
2019-05-07 18:49:53 +00:00
|
|
|
{
|
2019-05-12 11:49:58 +00:00
|
|
|
EE_TOOL_BASE::Init();
|
2019-05-07 18:49:53 +00:00
|
|
|
|
2021-01-08 23:24:12 +00:00
|
|
|
auto canEdit =
|
|
|
|
[&]( const SELECTION& sel )
|
|
|
|
{
|
|
|
|
SYMBOL_EDIT_FRAME* editor = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
|
|
|
|
wxCHECK( editor, false );
|
|
|
|
|
2021-02-10 22:56:26 +00:00
|
|
|
return editor->IsSymbolEditable() && !editor->IsSymbolAlias();
|
2021-01-08 23:24:12 +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();
|
|
|
|
|
2021-01-17 18:19:02 +00:00
|
|
|
selToolMenu.AddSeparator( 250 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::pushPinLength, canEdit && singlePinCondition, 250 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::pushPinNameSize, canEdit && singlePinCondition, 250 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::pushPinNumSize, canEdit && singlePinCondition, 250 );
|
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
|
|
|
|
2020-12-12 03:13:52 +00:00
|
|
|
bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-12-18 23:16:30 +00:00
|
|
|
LIB_PIN original_pin( *aPin );
|
2020-08-03 21:12:29 +00:00
|
|
|
DIALOG_PIN_PROPERTIES dlg( m_frame, aPin );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2020-08-03 21:12:29 +00:00
|
|
|
if( aPin->GetEditFlags() == 0 )
|
|
|
|
m_frame->SaveCopyInUndoList( aPin->GetParent() );
|
2009-12-01 15:14:18 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
{
|
2020-08-03 21:12:29 +00:00
|
|
|
if( aPin->GetEditFlags() == 0 )
|
|
|
|
m_frame->PopCommandFromUndoList();
|
|
|
|
|
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
|
|
|
|
2020-08-03 21:12:29 +00:00
|
|
|
aPin->SetModified();
|
|
|
|
|
|
|
|
if( !aPin->IsNew() && m_frame->SynchronizePins() && aPin->GetParent() )
|
|
|
|
{
|
|
|
|
LIB_PINS pinList;
|
|
|
|
aPin->GetParent()->GetPins( pinList );
|
2020-12-18 23:16:30 +00:00
|
|
|
|
2021-07-20 14:49:32 +00:00
|
|
|
// a pin can have a unit id = 0 (common to all units) to unit count
|
|
|
|
// So we need a buffer size = GetUnitCount()+1 to store a value in a vector
|
|
|
|
// when using the unit id of a pin as index
|
2021-10-30 12:52:13 +00:00
|
|
|
std::vector<bool> got_unit( aPin->GetParent()->GetUnitCount() + 1 );
|
2021-07-20 14:49:32 +00:00
|
|
|
|
|
|
|
got_unit[static_cast<size_t>(aPin->GetUnit())] = true;
|
2020-08-03 21:12:29 +00:00
|
|
|
|
|
|
|
for( LIB_PIN* other : pinList )
|
|
|
|
{
|
|
|
|
if( other == aPin )
|
|
|
|
continue;
|
|
|
|
|
2020-12-18 23:16:30 +00:00
|
|
|
/// Only change one pin per unit to allow stacking pins
|
|
|
|
/// If you change all units on the position, then pins are not
|
|
|
|
/// uniquely editable
|
2021-07-20 14:49:32 +00:00
|
|
|
if( got_unit[static_cast<size_t>( other->GetUnit() )] )
|
2020-12-18 23:16:30 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if( other->GetPosition() == original_pin.GetPosition()
|
|
|
|
&& other->GetOrientation() == original_pin.GetOrientation()
|
|
|
|
&& other->GetType() == original_pin.GetType()
|
|
|
|
&& other->IsVisible() == original_pin.IsVisible()
|
|
|
|
&& other->GetName() == original_pin.GetName() )
|
2020-08-03 21:12:29 +00:00
|
|
|
{
|
|
|
|
if( aPin->GetConvert() == 0 )
|
|
|
|
{
|
|
|
|
if( !aPin->GetUnit() || other->GetUnit() == aPin->GetUnit() )
|
|
|
|
aPin->GetParent()->RemoveDrawItem( other );
|
|
|
|
}
|
|
|
|
else if( other->GetConvert() == aPin->GetConvert() )
|
|
|
|
{
|
|
|
|
other->SetPosition( aPin->GetPosition() );
|
|
|
|
other->SetLength( aPin->GetLength() );
|
|
|
|
other->SetShape( aPin->GetShape() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aPin->GetUnit() == 0 )
|
|
|
|
{
|
|
|
|
if( !aPin->GetConvert() || other->GetConvert() == aPin->GetConvert() )
|
|
|
|
aPin->GetParent()->RemoveDrawItem( other );
|
|
|
|
}
|
|
|
|
|
|
|
|
other->SetOrientation( aPin->GetOrientation() );
|
|
|
|
other->SetType( aPin->GetType() );
|
|
|
|
other->SetVisible( aPin->IsVisible() );
|
|
|
|
other->SetName( aPin->GetName() );
|
|
|
|
other->SetNameTextSize( aPin->GetNameTextSize() );
|
|
|
|
other->SetNumberTextSize( aPin->GetNumberTextSize() );
|
|
|
|
|
|
|
|
other->SetModified();
|
2021-07-20 14:49:32 +00:00
|
|
|
got_unit[static_cast<size_t>( other->GetUnit() )] = true;
|
2020-08-03 21:12:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-06 03:10:20 +00:00
|
|
|
m_frame->UpdateItem( aPin, false, true );
|
2019-05-08 18:56:03 +00:00
|
|
|
m_frame->OnModify( );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2021-09-26 23:22:32 +00:00
|
|
|
std::vector<MSG_PANEL_ITEM> items;
|
2020-04-24 13:36:10 +00:00
|
|
|
aPin->GetMsgPanelInfo( m_frame, items );
|
2019-05-08 18:56:03 +00:00
|
|
|
m_frame->SetMsgPanel( items );
|
2009-12-03 19:11:34 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-12 03:13:52 +00:00
|
|
|
bool SYMBOL_EDITOR_PIN_TOOL::PlacePin( LIB_PIN* aPin )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
|
2021-06-10 18:51:46 +00:00
|
|
|
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
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
for( LIB_PIN* test = symbol->GetNextPin(); test; test = symbol->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
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
symbol->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
|
2021-06-10 18:51:46 +00:00
|
|
|
for( LIB_PIN* pin = symbol->GetNextPin(); pin; pin = symbol->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.
|
|
|
|
*/
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::CreatePin( const VECTOR2I& aPosition, LIB_SYMBOL* aSymbol )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
aSymbol->ClearTempFlags();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_PIN* pin = new LIB_PIN( aSymbol );
|
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
|
|
|
|
2020-12-12 03:13:52 +00:00
|
|
|
void SYMBOL_EDITOR_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;
|
2022-02-08 23:14:18 +00:00
|
|
|
unknownNum.Printf( wxT( "%s-U%c" ), aPin->GetNumber(), wxChar( 'A' + ii - 1 ) );
|
2018-01-08 09:48:33 +00:00
|
|
|
newPin->SetNumber( unknownNum );
|
2015-10-27 13:52:54 +00:00
|
|
|
|
2018-01-08 09:48:33 +00:00
|
|
|
newPin->SetUnit( ii );
|
2020-12-20 18:23:50 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
aPin->GetParent()->AddDrawItem( newPin );
|
|
|
|
}
|
|
|
|
catch( const boost::bad_pointer& e )
|
|
|
|
{
|
2022-02-08 23:14:18 +00:00
|
|
|
wxLogError( wxT( "Cannot add new pin to symbol. Boost pointer error %s occurred." ),
|
2020-12-20 18:23:50 +00:00
|
|
|
e.what() );
|
|
|
|
delete newPin;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-16 00:21:50 +00:00
|
|
|
newPin->ClearFlags( IS_NEW );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-12 03:13:52 +00:00
|
|
|
int SYMBOL_EDITOR_PIN_TOOL::PushPinProperties( const TOOL_EVENT& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
|
2019-06-08 21:48:22 +00:00
|
|
|
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
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
saveCopyInUndoList( symbol, UNDO_REDO::LIBEDIT );
|
2015-02-25 19:43:37 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
for( LIB_PIN* pin = symbol->GetNextPin(); pin; pin = symbol->GetNextPin( pin ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
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 ) )
|
2020-08-03 21:12:29 +00:00
|
|
|
{
|
|
|
|
if( !pin->GetConvert() || pin->GetConvert() == m_frame->GetConvert() )
|
|
|
|
pin->SetLength( sourcePin->GetLength() );
|
|
|
|
}
|
2019-05-10 17:19:48 +00:00
|
|
|
else if( aEvent.IsAction( &EE_ACTIONS::pushPinNameSize ) )
|
2020-08-03 21:12:29 +00:00
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
pin->SetNameTextSize( sourcePin->GetNameTextSize() );
|
2020-08-03 21:12:29 +00:00
|
|
|
}
|
2019-05-10 17:19:48 +00:00
|
|
|
else if( aEvent.IsAction( &EE_ACTIONS::pushPinNumSize ) )
|
2020-08-03 21:12:29 +00:00
|
|
|
{
|
2019-05-08 18:56:03 +00:00
|
|
|
pin->SetNumberTextSize( sourcePin->GetNumberTextSize() );
|
2020-08-03 21:12:29 +00:00
|
|
|
}
|
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.
|
2020-12-12 03:13:52 +00:00
|
|
|
LIB_PIN* SYMBOL_EDITOR_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-10-31 01:27:16 +00:00
|
|
|
auto* settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
2020-04-12 23:09:17 +00:00
|
|
|
|
2015-04-22 11:39:00 +00:00
|
|
|
switch( pin->GetOrientation() )
|
|
|
|
{
|
2020-12-29 13:28:37 +00:00
|
|
|
case PIN_UP: step.x = Mils2iu(settings->m_Repeat.pin_step); break;
|
|
|
|
case PIN_DOWN: step.x = Mils2iu(settings->m_Repeat.pin_step); break;
|
|
|
|
case PIN_LEFT: step.y = Mils2iu(-settings->m_Repeat.pin_step); break;
|
|
|
|
case PIN_RIGHT: step.y = Mils2iu(-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
|
|
|
|
2020-12-12 03:13:52 +00:00
|
|
|
void SYMBOL_EDITOR_PIN_TOOL::setTransitions()
|
2019-05-08 18:56:03 +00:00
|
|
|
{
|
2020-12-12 03:13:52 +00:00
|
|
|
Go( &SYMBOL_EDITOR_PIN_TOOL::PushPinProperties, EE_ACTIONS::pushPinLength.MakeEvent() );
|
|
|
|
Go( &SYMBOL_EDITOR_PIN_TOOL::PushPinProperties, EE_ACTIONS::pushPinNameSize.MakeEvent() );
|
|
|
|
Go( &SYMBOL_EDITOR_PIN_TOOL::PushPinProperties, EE_ACTIONS::pushPinNumSize.MakeEvent() );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|