2011-10-28 13:43:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file pinedit.cpp
|
|
|
|
* @brief Eeschema pin edit code.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <class_sch_screen.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <libeditframe.h>
|
|
|
|
#include <eeschema_id.h>
|
|
|
|
#include <class_libentry.h>
|
|
|
|
#include <lib_pin.h>
|
|
|
|
#include <general.h>
|
|
|
|
#include <protos.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <../common/dialogs/dialog_display_info_HTML_base.h>
|
|
|
|
#include <dialog_lib_edit_pin.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2011-07-03 18:51:07 +00:00
|
|
|
extern void IncrementLabelMember( wxString& name );
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC );
|
2011-02-03 19:27:28 +00:00
|
|
|
static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositon, bool aErase );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
static wxPoint OldPos;
|
|
|
|
static wxPoint PinPreviousPos;
|
|
|
|
static int LastPinType = PIN_INPUT;
|
|
|
|
static int LastPinOrient = PIN_RIGHT;
|
|
|
|
static int LastPinShape = NONE;
|
2013-05-19 19:35:49 +00:00
|
|
|
static int LastPinLength = DEFAULT_PIN_LENGTH;
|
|
|
|
static int LastPinNameSize = DEFAULT_TEXT_SIZE;
|
|
|
|
static int LastPinNumSize = DEFAULT_TEXT_SIZE;
|
2009-10-30 19:26:25 +00:00
|
|
|
static bool LastPinCommonConvert = false;
|
|
|
|
static bool LastPinCommonUnit = false;
|
|
|
|
static bool LastPinVisible = true;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( m_drawItem == NULL || m_drawItem->Type() != LIB_PIN_T )
|
2009-09-25 18:49:04 +00:00
|
|
|
return;
|
|
|
|
|
2013-03-28 19:12:46 +00:00
|
|
|
STATUS_FLAGS item_flags = m_drawItem->GetFlags(); // save flags to restore them after editing
|
2009-10-30 19:26:25 +00:00
|
|
|
LIB_PIN* pin = (LIB_PIN*) m_drawItem;
|
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
DIALOG_LIB_EDIT_PIN dlg( this, pin );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
wxString units = GetUnitsLabel( g_UserUnit );
|
2010-10-26 20:25:48 +00:00
|
|
|
dlg.SetOrientationList( LIB_PIN::GetOrientationNames(), LIB_PIN::GetOrientationSymbols() );
|
2010-12-07 16:10:42 +00:00
|
|
|
dlg.SetOrientation( LIB_PIN::GetOrientationCodeIndex( pin->GetOrientation() ) );
|
2010-10-26 20:25:48 +00:00
|
|
|
dlg.SetStyleList( LIB_PIN::GetStyleNames(), LIB_PIN::GetStyleSymbols() );
|
2010-12-07 16:10:42 +00:00
|
|
|
dlg.SetStyle( LIB_PIN::GetStyleCodeIndex( pin->GetShape() ) );
|
2010-03-04 09:32:51 +00:00
|
|
|
dlg.SetElectricalTypeList( LIB_PIN::GetElectricalTypeNames(),
|
2010-10-26 20:25:48 +00:00
|
|
|
LIB_PIN::GetElectricalTypeSymbols() );
|
2010-12-07 16:10:42 +00:00
|
|
|
dlg.SetElectricalType( pin->GetType() );
|
|
|
|
dlg.SetName( pin->GetName() );
|
2012-04-13 18:51:24 +00:00
|
|
|
dlg.SetNameTextSize( ReturnStringFromValue( g_UserUnit, pin->GetNameTextSize() ) );
|
2009-10-30 19:26:25 +00:00
|
|
|
dlg.SetNameTextSizeUnits( units );
|
2011-04-07 17:48:26 +00:00
|
|
|
dlg.SetPadName( pin->GetNumberString() );
|
2012-04-13 18:51:24 +00:00
|
|
|
dlg.SetPadNameTextSize( ReturnStringFromValue( g_UserUnit, pin->GetNumberTextSize() ) );
|
2011-05-05 17:45:35 +00:00
|
|
|
|
2011-04-07 17:48:26 +00:00
|
|
|
dlg.SetPadNameTextSizeUnits( units );
|
2012-04-15 10:33:35 +00:00
|
|
|
dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->GetLength() ) );
|
2009-10-30 19:26:25 +00:00
|
|
|
dlg.SetLengthUnits( units );
|
2010-10-25 15:43:42 +00:00
|
|
|
dlg.SetAddToAllParts( pin->GetUnit() == 0 );
|
|
|
|
dlg.SetAddToAllBodyStyles( pin->GetConvert() == 0 );
|
2009-10-30 19:26:25 +00:00
|
|
|
dlg.SetVisible( pin->IsVisible() );
|
|
|
|
|
2009-12-01 15:14:18 +00:00
|
|
|
/* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier
|
|
|
|
* versions for the flex grid sizer in wxGTK that prevents the last
|
|
|
|
* column from being sized correctly. It doesn't cause any problems
|
|
|
|
* on win32 so it doesn't need to wrapped in ugly #ifdef __WXGTK__
|
|
|
|
* #endif.
|
|
|
|
*/
|
|
|
|
dlg.Layout();
|
|
|
|
dlg.Fit();
|
|
|
|
dlg.SetMinSize( dlg.GetSize() );
|
2012-03-22 07:02:49 +00:00
|
|
|
// dlg.SetLastSizeAndPosition(); // done in DIALOG_SHIM::Show()
|
2009-12-01 15:14:18 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
{
|
|
|
|
if( pin->IsNew() )
|
2009-11-11 02:44:58 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
pin->SetFlags( IS_CANCELLED );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture();
|
2009-11-11 02:44:58 +00:00
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
return;
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// Save the pin properties to use for the next new pin.
|
2012-04-16 17:39:32 +00:00
|
|
|
LastPinNameSize = ReturnValueFromString( g_UserUnit, dlg.GetNameTextSize() );
|
|
|
|
LastPinNumSize = ReturnValueFromString( g_UserUnit, dlg.GetPadNameTextSize() );
|
2009-10-30 19:26:25 +00:00
|
|
|
LastPinOrient = LIB_PIN::GetOrientationCode( dlg.GetOrientation() );
|
2012-04-16 17:39:32 +00:00
|
|
|
LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength() );
|
2009-10-30 19:26:25 +00:00
|
|
|
LastPinShape = LIB_PIN::GetStyleCode( dlg.GetStyle() );
|
|
|
|
LastPinType = dlg.GetElectricalType();
|
|
|
|
LastPinCommonConvert = dlg.GetAddToAllBodyStyles();
|
|
|
|
LastPinCommonUnit = dlg.GetAddToAllParts();
|
|
|
|
LastPinVisible = dlg.GetVisible();
|
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
pin->EnableEditMode( true, m_editPinsPerPartOrConvert );
|
2009-10-30 19:26:25 +00:00
|
|
|
pin->SetName( dlg.GetName() );
|
|
|
|
pin->SetNameTextSize( LastPinNameSize );
|
2011-04-07 17:48:26 +00:00
|
|
|
pin->SetNumber( dlg.GetPadName() );
|
2009-10-30 19:26:25 +00:00
|
|
|
pin->SetNumberTextSize( LastPinNumSize );
|
|
|
|
pin->SetOrientation( LastPinOrient );
|
|
|
|
pin->SetLength( LastPinLength );
|
2010-12-07 16:10:42 +00:00
|
|
|
pin->SetType( LastPinType );
|
|
|
|
pin->SetShape( LastPinShape );
|
2009-10-30 19:26:25 +00:00
|
|
|
pin->SetConversion( ( LastPinCommonConvert ) ? 0 : m_convert );
|
|
|
|
pin->SetPartNumber( ( LastPinCommonUnit ) ? 0 : m_unit );
|
|
|
|
pin->SetVisible( LastPinVisible );
|
|
|
|
|
|
|
|
if( pin->IsModified() || pin->IsNew() )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2010-10-23 13:49:14 +00:00
|
|
|
if( !pin->InEditMode() )
|
2009-10-30 19:26:25 +00:00
|
|
|
SaveCopyInUndoList( pin->GetParent() );
|
|
|
|
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2013-01-12 17:32:24 +00:00
|
|
|
|
|
|
|
MSG_PANEL_ITEMS items;
|
|
|
|
pin->GetMsgPanelInfo( items );
|
|
|
|
SetMsgPanel( items );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
pin->EnableEditMode( false, m_editPinsPerPartOrConvert );
|
2009-12-03 19:11:34 +00:00
|
|
|
|
|
|
|
// Restore pin flags, that can be changed by the dialog editor
|
2011-12-21 13:42:02 +00:00
|
|
|
pin->ClearFlags();
|
|
|
|
pin->SetFlags( item_flags );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
|
|
|
* Clean up after aborting a move pin command.
|
2008-04-17 16:25:29 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) Panel->GetParent();
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
if( parent == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PIN* pin = (LIB_PIN*) parent->GetDrawItem();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
if( pin == NULL || pin->Type() != LIB_PIN_T )
|
2009-09-29 18:38:21 +00:00
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
pin->ClearFlags();
|
|
|
|
|
|
|
|
if( pin->IsNew() )
|
|
|
|
delete pin;
|
2009-09-29 18:38:21 +00:00
|
|
|
else
|
2010-10-23 13:49:14 +00:00
|
|
|
parent->RestoreComponent();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// clear edit flags
|
2009-09-25 18:49:04 +00:00
|
|
|
parent->SetDrawItem( NULL );
|
|
|
|
parent->SetLastDrawItem( NULL );
|
2008-04-17 16:25:29 +00:00
|
|
|
Panel->Refresh( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
|
|
|
* Managed cursor callback for placing component pins.
|
|
|
|
*/
|
2013-02-06 11:54:51 +00:00
|
|
|
void LIB_EDIT_FRAME::PlacePin()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* Pin;
|
|
|
|
LIB_PIN* CurrentPin = (LIB_PIN*) m_drawItem;
|
|
|
|
bool ask_for_pin = true;
|
|
|
|
wxPoint newpos;
|
|
|
|
bool status;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-12-29 10:35:11 +00:00
|
|
|
// Some tests
|
2010-12-10 19:47:44 +00:00
|
|
|
if( (CurrentPin == NULL) || (CurrentPin->Type() != LIB_PIN_T) )
|
2009-12-29 10:35:11 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
wxMessageBox( wxT( "LIB_EDIT_FRAME::PlacePin() error" ) );
|
2008-04-17 16:25:29 +00:00
|
|
|
return;
|
2009-12-29 10:35:11 +00:00
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
newpos = GetScreen()->GetCrossHairPosition( true );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-02-28 13:53:49 +00:00
|
|
|
// Test for an other pin in same new position:
|
2010-12-07 16:10:42 +00:00
|
|
|
for( Pin = m_component->GetNextPin(); Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( Pin == CurrentPin || newpos != Pin->GetPosition() || Pin->GetFlags() )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
if( ask_for_pin && SynchronizePins() )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2009-10-20 09:17:24 +00:00
|
|
|
status =
|
|
|
|
IsOK( this, _( "This position is already occupied by \
|
2009-09-29 18:38:21 +00:00
|
|
|
another pin. Continue?" ) );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
if( !status )
|
|
|
|
return;
|
|
|
|
else
|
2009-05-09 17:29:48 +00:00
|
|
|
ask_for_pin = false;
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-23 13:49:14 +00:00
|
|
|
// Create Undo from GetTempCopyComponent() if exists ( i.e. after a pin move)
|
|
|
|
// or from m_component (pin add ...)
|
|
|
|
if( GetTempCopyComponent() )
|
|
|
|
SaveCopyInUndoList( GetTempCopyComponent() );
|
|
|
|
else
|
|
|
|
SaveCopyInUndoList( m_component );
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
2010-12-07 16:10:42 +00:00
|
|
|
OnModify();
|
2013-03-18 19:36:07 +00:00
|
|
|
CurrentPin->Move( newpos );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
if( CurrentPin->IsNew() )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
LastPinOrient = CurrentPin->GetOrientation();
|
|
|
|
LastPinType = CurrentPin->GetType();
|
|
|
|
LastPinShape = CurrentPin->GetShape();
|
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
if( SynchronizePins() )
|
2010-02-25 19:45:34 +00:00
|
|
|
CreateImagePins( CurrentPin, m_unit, m_convert, m_showDeMorgan );
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_lastDrawItem = CurrentPin;
|
2009-09-29 18:38:21 +00:00
|
|
|
m_component->AddDrawItem( m_drawItem );
|
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
|
2010-10-26 20:25:48 +00:00
|
|
|
for( Pin = m_component->GetNextPin(); Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( Pin->GetFlags() == 0 )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
Pin->Move( CurrentPin->GetPosition() );
|
2011-12-21 13:42:02 +00:00
|
|
|
Pin->ClearFlags();
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_drawItem = NULL;
|
2013-02-06 11:54:51 +00:00
|
|
|
|
|
|
|
m_canvas->Refresh();
|
2010-10-04 12:58:07 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
|
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Prepare the displacement of a pin
|
|
|
|
*
|
|
|
|
* Locate the pin pointed to by the cursor, and set the cursor management
|
|
|
|
* function move the pin.
|
2008-04-17 16:25:29 +00:00
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::StartMovePin( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-02-06 11:54:51 +00:00
|
|
|
LIB_PIN* currentPin = (LIB_PIN*) m_drawItem;
|
2009-10-08 13:19:28 +00:00
|
|
|
wxPoint startPos;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2010-10-23 13:49:14 +00:00
|
|
|
TempCopyComponent();
|
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// Mark pins for moving.
|
2013-02-06 11:54:51 +00:00
|
|
|
LIB_PIN* pin = m_component->GetNextPin();
|
2011-02-28 13:53:49 +00:00
|
|
|
|
2013-02-06 11:54:51 +00:00
|
|
|
for( ; pin != NULL; pin = m_component->GetNextPin( pin ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2013-02-06 11:54:51 +00:00
|
|
|
pin->ClearFlags();
|
2011-02-28 13:53:49 +00:00
|
|
|
|
2013-02-06 11:54:51 +00:00
|
|
|
if( pin == currentPin )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
2011-02-28 13:53:49 +00:00
|
|
|
|
2013-02-06 11:54:51 +00:00
|
|
|
if( ( pin->GetPosition() == currentPin->GetPosition() )
|
|
|
|
&& ( pin->GetOrientation() == currentPin->GetOrientation() )
|
2011-10-28 13:43:37 +00:00
|
|
|
&& SynchronizePins() )
|
2013-02-06 11:54:51 +00:00
|
|
|
pin->SetFlags( IS_LINKED | IS_MOVED );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2013-02-06 11:54:51 +00:00
|
|
|
currentPin->SetFlags( IS_LINKED | IS_MOVED );
|
|
|
|
PinPreviousPos = OldPos = currentPin->GetPosition();
|
2008-04-17 16:25:29 +00:00
|
|
|
startPos.x = OldPos.x;
|
|
|
|
startPos.y = -OldPos.y;
|
2013-02-06 11:54:51 +00:00
|
|
|
// m_canvas->CrossHairOff( DC );
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( startPos );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
MSG_PANEL_ITEMS items;
|
2013-02-06 11:54:51 +00:00
|
|
|
currentPin->GetMsgPanelInfo( items );
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( items );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( DrawMovePin, AbortPinMove );
|
2013-02-06 11:54:51 +00:00
|
|
|
// m_canvas->CrossHairOn( DC );
|
|
|
|
|
|
|
|
// Refresh the screen to avoid color artifacts when drawing
|
|
|
|
// the pin in Edit mode and moving it from its start position
|
|
|
|
m_canvas->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/* Move pin to the current mouse position. This function is called by the
|
|
|
|
* cursor management code. */
|
2011-02-03 19:27:28 +00:00
|
|
|
static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
if( parent == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* CurrentPin = (LIB_PIN*) parent->GetDrawItem();
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( CurrentPin == NULL || CurrentPin->Type() != LIB_PIN_T )
|
2009-09-29 18:38:21 +00:00
|
|
|
return;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
wxPoint pinpos = CurrentPin->GetPosition();
|
2009-09-29 18:38:21 +00:00
|
|
|
bool showPinText = true;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// Erase pin in old position
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aErase )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
CurrentPin->Move( PinPreviousPos );
|
2012-09-02 12:06:47 +00:00
|
|
|
CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
|
2010-10-20 20:24:26 +00:00
|
|
|
&showPinText, DefaultTransform );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// Redraw pin in new position
|
2013-03-18 19:36:07 +00:00
|
|
|
CurrentPin->Move( aPanel->GetScreen()->GetCrossHairPosition( true ) );
|
2013-02-06 11:54:51 +00:00
|
|
|
CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
|
|
|
|
&showPinText, DefaultTransform );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
PinPreviousPos = CurrentPin->GetPosition();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
/* Keep the original position for existing pin (for Undo command)
|
2009-09-29 18:38:21 +00:00
|
|
|
* and the current position for a new pin */
|
2009-10-30 19:26:25 +00:00
|
|
|
if( !CurrentPin->IsNew() )
|
2013-03-18 19:36:07 +00:00
|
|
|
CurrentPin->Move( pinpos );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/*
|
|
|
|
* Create a new pin.
|
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-30 19:26:25 +00:00
|
|
|
LIB_PIN* pin;
|
2009-10-08 13:19:28 +00:00
|
|
|
bool showPinText = true;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
m_component->ClearStatus();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
pin = new LIB_PIN( m_component );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
m_drawItem = pin;
|
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
pin->SetFlags( IS_NEW );
|
2010-10-25 15:43:42 +00:00
|
|
|
pin->SetUnit( m_unit );
|
|
|
|
pin->SetConvert( m_convert );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// Flag pins to consider
|
2011-10-28 13:43:37 +00:00
|
|
|
if( SynchronizePins() )
|
2011-12-21 13:42:02 +00:00
|
|
|
pin->SetFlags( IS_LINKED );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
pin->Move( GetScreen()->GetCrossHairPosition( true ) );
|
2010-12-07 16:10:42 +00:00
|
|
|
pin->SetLength( LastPinLength );
|
|
|
|
pin->SetOrientation( LastPinOrient );
|
|
|
|
pin->SetType( LastPinType );
|
|
|
|
pin->SetShape( LastPinShape );
|
2011-12-08 21:05:43 +00:00
|
|
|
pin->SetNameTextSize( LastPinNameSize );
|
|
|
|
pin->SetNumberTextSize( LastPinNumSize );
|
2010-12-07 16:10:42 +00:00
|
|
|
pin->SetConvert( LastPinCommonConvert ? 0 : m_convert );
|
|
|
|
pin->SetUnit( LastPinCommonUnit ? 0 : m_unit );
|
|
|
|
pin->SetVisible( LastPinVisible );
|
|
|
|
PinPreviousPos = pin->GetPosition();
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2009-10-30 19:26:25 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2009-11-11 02:44:58 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( pin->GetFlags() & IS_CANCELLED )
|
2009-11-11 02:44:58 +00:00
|
|
|
{
|
2011-02-24 22:29:43 +00:00
|
|
|
deleteItem( DC );
|
2009-11-11 02:44:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-23 13:49:14 +00:00
|
|
|
ClearTempCopyComponent();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( DrawMovePin, AbortPinMove );
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2009-12-06 18:04:41 +00:00
|
|
|
if( DC )
|
2012-09-02 12:06:47 +00:00
|
|
|
pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_COPY, &showPinText,
|
2010-10-20 20:24:26 +00:00
|
|
|
DefaultTransform );
|
2009-12-06 18:04:41 +00:00
|
|
|
|
2009-11-11 02:44:58 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
void LIB_EDIT_FRAME::CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bool aDeMorgan )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
int ii;
|
|
|
|
LIB_PIN* NewPin;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
if( !SynchronizePins() )
|
2008-04-17 16:25:29 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// Create "convert" pin at the current position.
|
2011-10-28 13:43:37 +00:00
|
|
|
if( aDeMorgan && ( aPin->GetConvert() != 0 ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2011-10-28 13:43:37 +00:00
|
|
|
NewPin = (LIB_PIN*) aPin->Clone();
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
if( aPin->GetConvert() > 1 )
|
2010-10-25 15:43:42 +00:00
|
|
|
NewPin->SetConvert( 1 );
|
2008-04-17 16:25:29 +00:00
|
|
|
else
|
2010-10-25 15:43:42 +00:00
|
|
|
NewPin->SetConvert( 2 );
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
aPin->GetParent()->AddDrawItem( NewPin );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
for( ii = 1; ii <= aPin->GetParent()->GetPartCount(); ii++ )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2011-10-28 13:43:37 +00:00
|
|
|
if( ii == aUnit || aPin->GetUnit() == 0 )
|
2012-03-22 07:02:49 +00:00
|
|
|
continue; // Pin common to all units.
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
NewPin = (LIB_PIN*) aPin->Clone();
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
if( aConvert != 0 )
|
2010-10-25 15:43:42 +00:00
|
|
|
NewPin->SetConvert( 1 );
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
NewPin->SetUnit( ii );
|
2011-10-28 13:43:37 +00:00
|
|
|
aPin->GetParent()->AddDrawItem( NewPin );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
if( !( aDeMorgan && ( aPin->GetConvert() != 0 ) ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
NewPin = (LIB_PIN*) aPin->Clone();
|
2010-10-25 15:43:42 +00:00
|
|
|
NewPin->SetConvert( 2 );
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
if( aPin->GetUnit() != 0 )
|
2010-10-25 15:43:42 +00:00
|
|
|
NewPin->SetUnit( ii );
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
aPin->GetParent()->AddDrawItem( NewPin );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-01 20:52:37 +00:00
|
|
|
/* aMasterPin is the "template" pin
|
|
|
|
* aId is a param to select what should be mofified:
|
|
|
|
* - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
|
|
|
|
* Change pins text name size
|
|
|
|
* - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
|
|
|
|
* Change pins text num size
|
|
|
|
* - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
|
|
|
* Change pins length.
|
2008-04-17 16:25:29 +00:00
|
|
|
*
|
2013-01-01 20:52:37 +00:00
|
|
|
* If aMasterPin is selected ( .m_flag == IS_SELECTED ),
|
|
|
|
* only the other selected pins are modified
|
2008-04-17 16:25:29 +00:00
|
|
|
*/
|
2013-01-01 20:52:37 +00:00
|
|
|
void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId )
|
2009-10-08 13:19:28 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-01-01 20:52:37 +00:00
|
|
|
bool selected = aMasterPin->IsSelected();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2013-01-01 20:52:37 +00:00
|
|
|
if( ( m_component == NULL ) || ( aMasterPin == NULL ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
return;
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2013-01-01 20:52:37 +00:00
|
|
|
if( aMasterPin->Type() != LIB_PIN_T )
|
2008-04-17 16:25:29 +00:00
|
|
|
return;
|
|
|
|
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2013-01-01 20:52:37 +00:00
|
|
|
LIB_PIN* pin = m_component->GetNextPin();
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2013-01-01 20:52:37 +00:00
|
|
|
for( ; pin != NULL; pin = m_component->GetNextPin( pin ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2013-01-01 20:52:37 +00:00
|
|
|
if( ( pin->GetConvert() ) && ( pin->GetConvert() != m_convert ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Is it the "selected mode" ?
|
2013-01-01 20:52:37 +00:00
|
|
|
if( selected && !pin->IsSelected() )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
|
|
|
|
2013-01-01 20:52:37 +00:00
|
|
|
switch( aId )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
|
2013-01-01 20:52:37 +00:00
|
|
|
pin->SetNumberTextSize( aMasterPin->GetNumberTextSize() );
|
2008-04-17 16:25:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
|
2013-01-01 20:52:37 +00:00
|
|
|
pin->SetNameTextSize( aMasterPin->GetNameTextSize() );
|
2008-04-17 16:25:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
2013-01-01 20:52:37 +00:00
|
|
|
pin->SetLength( aMasterPin->GetLength() );
|
2008-04-17 16:25:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-01 20:52:37 +00:00
|
|
|
// Clear the flag IS_CHANGED, which was set by previous changes (if any)
|
|
|
|
// but not used here.
|
|
|
|
pin->ClearFlags( IS_CHANGED );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
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.
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* Pin;
|
|
|
|
wxString msg;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( m_component == NULL || SourcePin == NULL || SourcePin->Type() != LIB_PIN_T )
|
2008-04-17 16:25:29 +00:00
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
Pin = (LIB_PIN*) SourcePin->Clone();
|
2011-12-21 13:42:02 +00:00
|
|
|
Pin->ClearFlags();
|
|
|
|
Pin->SetFlags( IS_NEW );
|
2013-03-18 19:36:07 +00:00
|
|
|
Pin->Move( Pin->GetPosition() + wxPoint( g_RepeatStep.x, -g_RepeatStep.y ) );
|
2010-12-07 16:10:42 +00:00
|
|
|
wxString nextName = Pin->GetName();
|
|
|
|
IncrementLabelMember( nextName );
|
|
|
|
Pin->SetName( nextName );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
Pin->ReturnPinStringNum( msg );
|
|
|
|
IncrementLabelMember( msg );
|
|
|
|
Pin->SetPinNumFromString( msg );
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_drawItem = Pin;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
if( SynchronizePins() )
|
2011-12-21 13:42:02 +00:00
|
|
|
Pin->SetFlags( IS_LINKED );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
wxPoint savepos = GetScreen()->GetCrossHairPosition();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( DC );
|
2013-02-06 11:54:51 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( wxPoint( Pin->GetPosition().x,
|
|
|
|
-Pin->GetPosition().y ) );
|
2010-02-16 16:21:52 +00:00
|
|
|
|
2009-12-29 10:35:11 +00:00
|
|
|
// Add this new pin in list, and creates pins for others parts if needed
|
|
|
|
m_drawItem = Pin;
|
2010-10-23 13:49:14 +00:00
|
|
|
ClearTempCopyComponent();
|
2013-02-06 11:54:51 +00:00
|
|
|
PlacePin();
|
2009-12-29 10:35:11 +00:00
|
|
|
m_lastDrawItem = Pin;
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( savepos );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
MSG_PANEL_ITEMS items;
|
|
|
|
Pin->GetMsgPanelInfo( items );
|
|
|
|
SetMsgPanel( items );
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// helper function to sort pins by pin num
|
2009-10-20 09:17:24 +00:00
|
|
|
bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
int test = ref->GetNumber() - tst->GetNumber();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
if( test == 0 )
|
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
test = ref->GetConvert() - tst->GetConvert();
|
2009-10-20 09:17:24 +00:00
|
|
|
}
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
if( test == 0 )
|
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
test = ref->GetUnit() - tst->GetUnit();
|
2009-10-20 09:17:24 +00:00
|
|
|
}
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
return test < 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
2009-10-25 15:54:00 +00:00
|
|
|
/* Test for duplicate pins and off grid pins:
|
|
|
|
* Pins are considered off grid when they are not on the 25 mils grid
|
|
|
|
* A grid smaller than 25 mils must be used only to build graphic shapes.
|
2009-10-20 09:17:24 +00:00
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-25 15:54:00 +00:00
|
|
|
#define MIN_GRID_SIZE 25
|
2011-04-27 19:44:32 +00:00
|
|
|
int dup_error;
|
|
|
|
int offgrid_error;
|
|
|
|
LIB_PIN* Pin;
|
|
|
|
LIB_PINS PinList;
|
|
|
|
wxString msg;
|
|
|
|
wxString aux_msg;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL )
|
|
|
|
return;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
m_component->GetPins( PinList );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
if( PinList.size() == 0 )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2009-10-20 09:17:24 +00:00
|
|
|
DisplayInfoMessage( this, _( "No pins!" ) );
|
|
|
|
return;
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
// Sort pins by pin num, so 2 duplicate pins
|
|
|
|
// (pins with the same number) will be consecutive in list
|
|
|
|
sort( PinList.begin(), PinList.end(), sort_by_pin_number );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
// Test for duplicates:
|
2009-10-25 15:54:00 +00:00
|
|
|
dup_error = 0;
|
2009-10-30 19:26:25 +00:00
|
|
|
DIALOG_DISPLAY_HTML_TEXT_BASE error_display( this, wxID_ANY,
|
|
|
|
_( "Marker Information" ),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxSize( 750, 600 ) );
|
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
for( unsigned ii = 1; ii < PinList.size(); ii++ )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2009-10-20 09:17:24 +00:00
|
|
|
wxString stringPinNum, stringCurrPinNum;
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* curr_pin = PinList[ii];
|
2008-04-17 16:25:29 +00:00
|
|
|
Pin = PinList[ii - 1];
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( Pin->GetNumber() != curr_pin->GetNumber()
|
2010-10-25 15:43:42 +00:00
|
|
|
|| Pin->GetConvert() != curr_pin->GetConvert()
|
|
|
|
|| Pin->GetUnit() != curr_pin->GetUnit() )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-10-25 15:54:00 +00:00
|
|
|
dup_error++;
|
2009-10-20 09:17:24 +00:00
|
|
|
Pin->ReturnPinStringNum( stringPinNum );
|
2013-04-09 17:49:01 +00:00
|
|
|
|
|
|
|
/* TODO I dare someone to find a way to make happy translators on
|
|
|
|
this thing! Lorenzo */
|
2009-10-20 09:17:24 +00:00
|
|
|
curr_pin->ReturnPinStringNum( stringCurrPinNum );
|
2009-10-30 19:26:25 +00:00
|
|
|
msg.Printf( _( "<b>Duplicate pin %s</b> \"%s\" at location <b>(%.3f, \
|
|
|
|
%.3f)</b> conflicts with pin %s \"%s\" at location <b>(%.3f, %.3f)</b>" ),
|
2009-10-20 09:17:24 +00:00
|
|
|
GetChars( stringCurrPinNum ),
|
2010-12-07 16:10:42 +00:00
|
|
|
GetChars( curr_pin->GetName() ),
|
2013-05-07 17:31:52 +00:00
|
|
|
curr_pin->GetPosition().x / 1000.0,
|
|
|
|
-curr_pin->GetPosition().y / 1000.0,
|
2009-10-20 09:17:24 +00:00
|
|
|
GetChars( stringPinNum ),
|
2010-12-07 16:10:42 +00:00
|
|
|
GetChars( Pin->GetName() ),
|
2013-05-07 17:31:52 +00:00
|
|
|
Pin->GetPosition().x / 1000.0,
|
|
|
|
-Pin->GetPosition().y / 1000.0 );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
if( m_component->GetPartCount() > 1 )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
aux_msg.Printf( _( " in part %c" ), 'A' + curr_pin->GetUnit() );
|
2008-04-17 16:25:29 +00:00
|
|
|
msg += aux_msg;
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_showDeMorgan )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
if( curr_pin->GetConvert() )
|
2009-09-28 16:14:45 +00:00
|
|
|
msg += _( " of converted" );
|
2008-04-17 16:25:29 +00:00
|
|
|
else
|
2009-09-25 18:49:04 +00:00
|
|
|
msg += _( " of normal" );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
msg += wxT( ".<br>" );
|
2009-10-25 15:54:00 +00:00
|
|
|
error_display.m_htmlWindow->AppendToPage( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test for off grid pins:
|
|
|
|
offgrid_error = 0;
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2009-10-25 15:54:00 +00:00
|
|
|
for( unsigned ii = 0; ii < PinList.size(); ii++ )
|
|
|
|
{
|
|
|
|
Pin = PinList[ii];
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( (Pin->GetPosition().x % MIN_GRID_SIZE) == 0 ) &&
|
|
|
|
( (Pin->GetPosition().y % MIN_GRID_SIZE) == 0 ) )
|
2009-10-25 15:54:00 +00:00
|
|
|
continue;
|
|
|
|
|
2011-02-28 13:53:49 +00:00
|
|
|
// A pin is found here off grid
|
2009-10-25 15:54:00 +00:00
|
|
|
offgrid_error++;
|
|
|
|
wxString stringPinNum;
|
|
|
|
Pin->ReturnPinStringNum( stringPinNum );
|
2010-12-07 16:10:42 +00:00
|
|
|
msg.Printf( _( "<b>Off grid pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>" ),
|
2009-10-25 15:54:00 +00:00
|
|
|
GetChars( stringPinNum ),
|
2010-12-07 16:10:42 +00:00
|
|
|
GetChars( Pin->GetName() ),
|
2013-05-07 17:31:52 +00:00
|
|
|
Pin->GetPosition().x / 1000.0,
|
|
|
|
-Pin->GetPosition().y / 1000.0 );
|
2009-10-25 15:54:00 +00:00
|
|
|
|
|
|
|
if( m_component->GetPartCount() > 1 )
|
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
aux_msg.Printf( _( " in part %c" ), 'A' + Pin->GetUnit() );
|
2009-10-25 15:54:00 +00:00
|
|
|
msg += aux_msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_showDeMorgan )
|
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
if( Pin->GetConvert() )
|
2009-10-25 15:54:00 +00:00
|
|
|
msg += _( " of converted" );
|
|
|
|
else
|
|
|
|
msg += _( " of normal" );
|
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2009-10-25 15:54:00 +00:00
|
|
|
msg += wxT( ".<br>" );
|
2009-10-20 09:17:24 +00:00
|
|
|
error_display.m_htmlWindow->AppendToPage( msg );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2009-10-25 15:54:00 +00:00
|
|
|
if( !dup_error && !offgrid_error )
|
2010-12-07 16:10:42 +00:00
|
|
|
DisplayInfoMessage( this, _( "No off grid or duplicate pins were found." ) );
|
2009-10-20 09:17:24 +00:00
|
|
|
else
|
|
|
|
error_display.ShowModal();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|