2008-04-17 16:25:29 +00:00
|
|
|
/***************************/
|
|
|
|
/* EESchema - PinEdit.cpp */
|
|
|
|
/***************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "fctsys.h"
|
2009-10-30 19:26:25 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "class_sch_screen.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "libeditframe.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "eeschema_id.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_libentry.h"
|
2010-10-22 12:11:52 +00:00
|
|
|
#include "lib_pin.h"
|
2009-10-30 19:26:25 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-11-20 10:59:59 +00:00
|
|
|
#include "../common/dialogs/dialog_display_info_HTML_base.h"
|
2009-10-30 19:26:25 +00:00
|
|
|
#include "dialog_lib_edit_pin.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
static void CreateImagePins( LIB_PIN* Pin, int unit, int convert,
|
2009-09-25 18:49:04 +00:00
|
|
|
bool asDeMorgan );
|
2008-04-17 16:25:29 +00:00
|
|
|
static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC );
|
|
|
|
static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
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;
|
|
|
|
static int LastPinLength = 300;
|
|
|
|
static int LastPinNameSize = 50;
|
|
|
|
static int LastPinNumSize = 50;
|
|
|
|
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::OnRotatePin( wxCommandEvent& event )
|
|
|
|
{
|
2010-01-17 20:25:10 +00:00
|
|
|
|
|
|
|
// Check, if the item is a pin, else return
|
|
|
|
if( m_drawItem == NULL || m_drawItem->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// save flags to restore them after rotating
|
|
|
|
int item_flags = m_drawItem->m_Flags;
|
|
|
|
LIB_PIN* pin = (LIB_PIN*) m_drawItem;
|
|
|
|
|
|
|
|
// Save old pin orientation
|
|
|
|
LastPinOrient = pin -> m_Orient;
|
2010-10-23 13:49:14 +00:00
|
|
|
if( !pin->InEditMode() )
|
|
|
|
SaveCopyInUndoList( pin->GetParent() );
|
2010-01-17 20:25:10 +00:00
|
|
|
|
|
|
|
// Get the actual pin orientation index
|
|
|
|
int orientationIndex = pin -> GetOrientationCodeIndex(pin -> m_Orient);
|
|
|
|
|
|
|
|
// Compute the next orientation, swap lower two bits for the right order
|
|
|
|
orientationIndex = ((orientationIndex & 2) >> 1) | ((orientationIndex & 1) << 1);
|
|
|
|
orientationIndex = orientationIndex + 1;
|
|
|
|
orientationIndex = ((orientationIndex & 2) >> 1) | ((orientationIndex & 1) << 1);
|
|
|
|
|
|
|
|
// Set the new orientation
|
|
|
|
pin->SetOrientation(pin->GetOrientationCode(orientationIndex));
|
|
|
|
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2010-01-17 20:25:10 +00:00
|
|
|
pin->DisplayInfo( this );
|
|
|
|
DrawPanel->Refresh();
|
|
|
|
|
|
|
|
// Restore pin flags
|
|
|
|
pin->m_Flags = item_flags;
|
|
|
|
}
|
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
|
|
|
{
|
2009-10-30 19:26:25 +00:00
|
|
|
if( m_drawItem == NULL || m_drawItem->Type() != COMPONENT_PIN_DRAW_TYPE )
|
2009-09-25 18:49:04 +00:00
|
|
|
return;
|
|
|
|
|
2009-12-03 19:11:34 +00:00
|
|
|
int item_flags = m_drawItem->m_Flags; // save flags to restore them after editing
|
2009-10-30 19:26:25 +00:00
|
|
|
LIB_PIN* pin = (LIB_PIN*) m_drawItem;
|
|
|
|
|
|
|
|
DIALOG_LIB_EDIT_PIN dlg( this );
|
|
|
|
|
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() );
|
2009-10-30 19:26:25 +00:00
|
|
|
dlg.SetOrientation( LIB_PIN::GetOrientationCodeIndex( pin->m_Orient ) );
|
2010-10-26 20:25:48 +00:00
|
|
|
dlg.SetStyleList( LIB_PIN::GetStyleNames(), LIB_PIN::GetStyleSymbols() );
|
2009-10-30 19:26:25 +00:00
|
|
|
dlg.SetStyle( LIB_PIN::GetStyleCodeIndex( pin->m_PinShape ) );
|
2010-03-04 09:32:51 +00:00
|
|
|
dlg.SetElectricalTypeList( LIB_PIN::GetElectricalTypeNames(),
|
2010-10-26 20:25:48 +00:00
|
|
|
LIB_PIN::GetElectricalTypeSymbols() );
|
2009-10-30 19:26:25 +00:00
|
|
|
dlg.SetElectricalType( pin->m_PinType );
|
|
|
|
dlg.SetName( pin->m_PinName );
|
2010-07-12 14:07:09 +00:00
|
|
|
dlg.SetNameTextSize( ReturnStringFromValue( g_UserUnit,
|
2009-10-30 19:26:25 +00:00
|
|
|
pin->m_PinNameSize,
|
|
|
|
m_InternalUnits ) );
|
|
|
|
dlg.SetNameTextSizeUnits( units );
|
|
|
|
dlg.SetNumber( pin->GetNumber() );
|
2010-07-12 14:07:09 +00:00
|
|
|
dlg.SetNumberTextSize( ReturnStringFromValue( g_UserUnit,
|
2009-10-30 19:26:25 +00:00
|
|
|
pin->m_PinNumSize,
|
|
|
|
m_InternalUnits ) );
|
|
|
|
dlg.SetNumberTextSizeUnits( units );
|
2010-10-26 20:25:48 +00:00
|
|
|
dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->m_PinLen, m_InternalUnits ) );
|
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() );
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
{
|
|
|
|
if( pin->IsNew() )
|
2009-11-11 02:44:58 +00:00
|
|
|
{
|
|
|
|
pin->m_Flags |= IS_CANCELLED;
|
2009-10-30 19:26:25 +00:00
|
|
|
DrawPanel->UnManageCursor();
|
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
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/* Save the pin properties to use for the next new pin. */
|
2010-07-12 14:07:09 +00:00
|
|
|
LastPinNameSize = ReturnValueFromString( g_UserUnit,
|
2009-10-30 19:26:25 +00:00
|
|
|
dlg.GetNameTextSize(),
|
|
|
|
m_InternalUnits );
|
2010-07-12 14:07:09 +00:00
|
|
|
LastPinNumSize = ReturnValueFromString( g_UserUnit,
|
2009-10-30 19:26:25 +00:00
|
|
|
dlg.GetNumberTextSize(),
|
|
|
|
m_InternalUnits );
|
|
|
|
LastPinOrient = LIB_PIN::GetOrientationCode( dlg.GetOrientation() );
|
2010-10-26 20:25:48 +00:00
|
|
|
LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength(), m_InternalUnits );
|
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();
|
|
|
|
|
|
|
|
pin->EnableEditMode( true, g_EditPinByPinIsOn );
|
|
|
|
pin->SetName( dlg.GetName() );
|
|
|
|
pin->SetNameTextSize( LastPinNameSize );
|
|
|
|
pin->SetNumber( dlg.GetNumber() );
|
|
|
|
pin->SetNumberTextSize( LastPinNumSize );
|
|
|
|
pin->SetOrientation( LastPinOrient );
|
|
|
|
pin->SetLength( LastPinLength );
|
|
|
|
pin->SetElectricalType( LastPinType );
|
|
|
|
pin->SetDrawStyle( LastPinShape );
|
|
|
|
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( );
|
2009-10-30 19:26:25 +00:00
|
|
|
pin->DisplayInfo( this );
|
|
|
|
DrawPanel->Refresh();
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
pin->EnableEditMode( false, g_EditPinByPinIsOn );
|
2009-12-03 19:11:34 +00:00
|
|
|
|
|
|
|
// Restore pin flags, that can be changed by the dialog editor
|
|
|
|
pin->m_Flags = 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
|
|
|
*/
|
2009-09-29 18:38:21 +00:00
|
|
|
static void AbortPinMove( WinEDA_DrawPanel* 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;
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* CurrentPin = (LIB_PIN*) parent->GetDrawItem();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
if( CurrentPin == NULL || CurrentPin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
if( CurrentPin->m_Flags & IS_NEW )
|
|
|
|
delete CurrentPin;
|
|
|
|
else
|
2010-10-23 13:49:14 +00:00
|
|
|
parent->RestoreComponent();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/* clear edit flags */
|
2008-04-17 16:25:29 +00:00
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
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.
|
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::PlacePin( wxDC* DC )
|
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
|
|
|
|
if( (CurrentPin == NULL) || (CurrentPin->Type() != COMPONENT_PIN_DRAW_TYPE) )
|
|
|
|
{
|
2010-11-19 16:28:46 +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
|
|
|
|
|
|
|
newpos.x = GetScreen()->m_Curseur.x;
|
|
|
|
newpos.y = -GetScreen()->m_Curseur.y;
|
|
|
|
|
|
|
|
// Tst for an other pin in same new position:
|
2009-09-29 18:38:21 +00:00
|
|
|
for( Pin = m_component->GetNextPin(); Pin != NULL;
|
2009-12-01 15:14:18 +00:00
|
|
|
Pin = m_component->GetNextPin( Pin ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2009-09-29 18:38:21 +00:00
|
|
|
if( Pin == CurrentPin || newpos != Pin->m_Pos || Pin->m_Flags )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
if( ask_for_pin && !g_EditPinByPinIsOn )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2009-05-09 17:29:48 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = 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?" ) );
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
2009-05-09 17:29:48 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = false;
|
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 );
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2008-04-17 16:25:29 +00:00
|
|
|
CurrentPin->m_Pos = 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
|
|
|
{
|
|
|
|
LastPinOrient = CurrentPin->m_Orient;
|
|
|
|
LastPinType = CurrentPin->m_PinType;
|
|
|
|
LastPinShape = CurrentPin->m_PinShape;
|
2010-02-25 19:45:34 +00:00
|
|
|
if( !g_EditPinByPinIsOn )
|
|
|
|
CreateImagePins( CurrentPin, m_unit, m_convert, m_showDeMorgan );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* 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
|
|
|
{
|
|
|
|
if( Pin->m_Flags == 0 )
|
|
|
|
continue;
|
|
|
|
Pin->m_Pos = CurrentPin->m_Pos;
|
|
|
|
Pin->m_Flags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->CursorOff( DC );
|
2009-09-04 18:57:37 +00:00
|
|
|
bool showPinText = true;
|
|
|
|
CurrentPin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE,
|
2010-10-20 20:24:26 +00:00
|
|
|
&showPinText, DefaultTransform );
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawPanel->CursorOn( DC );
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_drawItem = NULL;
|
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
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* Pin;
|
|
|
|
LIB_PIN* CurrentPin = (LIB_PIN*) m_drawItem;
|
|
|
|
wxPoint startPos;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2010-10-23 13:49:14 +00:00
|
|
|
TempCopyComponent();
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/* Mark pins for moving. */
|
2009-09-29 18:38:21 +00:00
|
|
|
Pin = m_component->GetNextPin();
|
|
|
|
for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
|
|
|
Pin->m_Flags = 0;
|
|
|
|
if( Pin == CurrentPin )
|
|
|
|
continue;
|
2009-09-02 18:12:45 +00:00
|
|
|
if( ( Pin->m_Pos == CurrentPin->m_Pos )
|
2009-10-20 09:17:24 +00:00
|
|
|
&& ( Pin->m_Orient == CurrentPin->m_Orient )
|
|
|
|
&& ( g_EditPinByPinIsOn == false ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
Pin->m_Flags |= IS_LINKED | IS_MOVED;
|
|
|
|
}
|
|
|
|
|
|
|
|
CurrentPin->m_Flags |= IS_LINKED | IS_MOVED;
|
|
|
|
PinPreviousPos = OldPos = CurrentPin->m_Pos;
|
|
|
|
|
|
|
|
startPos.x = OldPos.x;
|
|
|
|
startPos.y = -OldPos.y;
|
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
GetScreen()->m_Curseur = startPos;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
CurrentPin->DisplayInfo( this );
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawPanel->ManageCurseur = DrawMovePin;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortPinMove;
|
|
|
|
|
|
|
|
DrawPanel->CursorOn( DC );
|
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. */
|
2008-04-17 16:25:29 +00:00
|
|
|
static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
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;
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* CurrentPin = (LIB_PIN*) parent->GetDrawItem();
|
2009-09-29 18:38:21 +00:00
|
|
|
|
|
|
|
if( CurrentPin == NULL || CurrentPin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxPoint pinpos = CurrentPin->m_Pos;
|
|
|
|
bool showPinText = true;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
/* Erase pin in old position */
|
2009-12-06 18:04:41 +00:00
|
|
|
if( erase )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
|
|
|
CurrentPin->m_Pos = PinPreviousPos;
|
2009-09-04 18:57:37 +00:00
|
|
|
CurrentPin->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
|
2010-10-20 20:24:26 +00:00
|
|
|
&showPinText, DefaultTransform );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Redraw pin in new position */
|
|
|
|
CurrentPin->m_Pos.x = panel->GetScreen()->m_Curseur.x;
|
|
|
|
CurrentPin->m_Pos.y = -panel->GetScreen()->m_Curseur.y;
|
2010-10-20 20:24:26 +00:00
|
|
|
CurrentPin->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &showPinText, DefaultTransform );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
PinPreviousPos = CurrentPin->m_Pos;
|
|
|
|
|
|
|
|
/* 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() )
|
2008-04-17 16:25:29 +00:00
|
|
|
CurrentPin->m_Pos = pinpos;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/*
|
|
|
|
* Delete pin at the current mouse position.
|
|
|
|
* If g_EditPinByPinIsOn == false:
|
|
|
|
* All pins at the same position will be erased.
|
|
|
|
* Otherwise only the pin of the current unit and convert will be erased.
|
2008-04-17 16:25:29 +00:00
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::DeletePin( wxDC* DC, LIB_COMPONENT* LibEntry, LIB_PIN* Pin )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* tmp;
|
|
|
|
wxPoint PinPos;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
if( LibEntry == NULL || Pin == NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
PinPos = Pin->m_Pos;
|
2009-09-25 18:49:04 +00:00
|
|
|
LibEntry->RemoveDrawItem( (LIB_DRAW_ITEM*) Pin, DrawPanel, DC );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-05-09 17:29:48 +00:00
|
|
|
if( g_EditPinByPinIsOn == false )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2009-09-29 18:38:21 +00:00
|
|
|
tmp = LibEntry->GetNextPin();
|
|
|
|
|
|
|
|
while( tmp != NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2009-09-29 18:38:21 +00:00
|
|
|
Pin = tmp;
|
|
|
|
tmp = LibEntry->GetNextPin( Pin );
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
if( Pin->m_Pos != PinPos )
|
|
|
|
continue;
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
LibEntry->RemoveDrawItem( (LIB_DRAW_ITEM*) Pin );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
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;
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
pin->m_Flags = IS_NEW;
|
|
|
|
pin->SetUnit( m_unit );
|
|
|
|
pin->SetConvert( m_convert );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
/* Flag pins to consider */
|
2009-05-09 17:29:48 +00:00
|
|
|
if( g_EditPinByPinIsOn == false )
|
2009-10-30 19:26:25 +00:00
|
|
|
pin->m_Flags |= IS_LINKED;
|
|
|
|
|
2010-10-26 20:25:48 +00:00
|
|
|
pin->m_Pos = GetScreen()->GetCursorDrawPosition();
|
2009-10-30 19:26:25 +00:00
|
|
|
pin->m_PinLen = LastPinLength;
|
|
|
|
pin->m_Orient = LastPinOrient;
|
|
|
|
pin->m_PinType = LastPinType;
|
|
|
|
pin->m_PinShape = LastPinShape;
|
|
|
|
pin->m_PinNameSize = LastPinNameSize;
|
|
|
|
pin->m_PinNumSize = LastPinNumSize;
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
if( LastPinCommonConvert )
|
2010-10-25 15:43:42 +00:00
|
|
|
pin->SetConvert( 0 );
|
2008-04-17 16:25:29 +00:00
|
|
|
else
|
2010-10-25 15:43:42 +00:00
|
|
|
pin->SetConvert( m_convert );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
if( LastPinCommonUnit )
|
2010-10-25 15:43:42 +00:00
|
|
|
pin->SetUnit( 0 );
|
2008-04-17 16:25:29 +00:00
|
|
|
else
|
2010-10-25 15:43:42 +00:00
|
|
|
pin->SetUnit( m_unit );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
if( LastPinVisible )
|
|
|
|
pin->m_Attributs &= ~PINNOTDRAW;
|
2008-04-17 16:25:29 +00:00
|
|
|
else
|
2009-10-30 19:26:25 +00:00
|
|
|
pin->m_Attributs |= PINNOTDRAW;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
PinPreviousPos = pin->m_Pos;
|
2009-05-09 17:29:48 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = true;
|
2009-10-30 19:26:25 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
2009-05-09 17:29:48 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = false;
|
2009-11-11 02:44:58 +00:00
|
|
|
|
|
|
|
if (pin->m_Flags & IS_CANCELLED)
|
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
DeletePin( NULL, m_component, pin );
|
2009-11-11 02:44:58 +00:00
|
|
|
m_drawItem = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-23 13:49:14 +00:00
|
|
|
ClearTempCopyComponent();
|
2009-11-11 02:44:58 +00:00
|
|
|
DrawPanel->ManageCurseur = DrawMovePin;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortPinMove;
|
2009-12-06 18:04:41 +00:00
|
|
|
if( DC )
|
|
|
|
pin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, wxCOPY, &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
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorgan )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
int ii;
|
|
|
|
LIB_PIN* NewPin;
|
|
|
|
bool CreateConv = false;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
if( g_EditPinByPinIsOn )
|
|
|
|
return;
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
if( asDeMorgan && ( Pin->GetConvert() != 0 ) )
|
2009-05-09 17:29:48 +00:00
|
|
|
CreateConv = true;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/* Create "convert" pin at the current position. */
|
2009-05-09 17:29:48 +00:00
|
|
|
if( CreateConv == true )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
NewPin = (LIB_PIN*) Pin->GenCopy();
|
2010-10-25 15:43:42 +00:00
|
|
|
if( Pin->GetConvert() > 1 )
|
|
|
|
NewPin->SetConvert( 1 );
|
2008-04-17 16:25:29 +00:00
|
|
|
else
|
2010-10-25 15:43:42 +00:00
|
|
|
NewPin->SetConvert( 2 );
|
2009-09-29 18:38:21 +00:00
|
|
|
Pin->GetParent()->AddDrawItem( NewPin );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
for( ii = 1; ii <= Pin->GetParent()->GetPartCount(); ii++ )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
if( ii == unit || Pin->GetUnit() == 0 )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue; /* Pin common to all units. */
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
NewPin = (LIB_PIN*) Pin->GenCopy();
|
2009-09-25 18:49:04 +00:00
|
|
|
if( convert != 0 )
|
2010-10-25 15:43:42 +00:00
|
|
|
NewPin->SetConvert( 1 );
|
|
|
|
NewPin->SetUnit( ii );
|
2009-09-29 18:38:21 +00:00
|
|
|
Pin->GetParent()->AddDrawItem( NewPin );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-05-09 17:29:48 +00:00
|
|
|
if( CreateConv == false )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
NewPin = (LIB_PIN*) Pin->GenCopy();
|
2010-10-25 15:43:42 +00:00
|
|
|
NewPin->SetConvert( 2 );
|
|
|
|
if( Pin->GetUnit() != 0 )
|
|
|
|
NewPin->SetUnit( ii );
|
2009-09-29 18:38:21 +00:00
|
|
|
Pin->GetParent()->AddDrawItem( NewPin );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
/* Depending on "id":
|
2009-10-08 13:19:28 +00:00
|
|
|
* - Change pin text size (name or num) (range 10 .. 1000 mil)
|
|
|
|
* - Change pin lenght.
|
2008-04-17 16:25:29 +00:00
|
|
|
*
|
2009-10-08 13:19:28 +00:00
|
|
|
* If Pin is selected ( .m_flag == IS_SELECTED ) only the other selected
|
|
|
|
* pins are modified
|
2008-04-17 16:25:29 +00:00
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id )
|
2009-10-08 13:19:28 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* Pin;
|
2009-10-20 09:17:24 +00:00
|
|
|
bool selected = ( MasterPin->m_Selected & IS_SELECTED ) != 0;
|
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 ) || ( MasterPin == NULL ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
return;
|
|
|
|
if( MasterPin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
return;
|
|
|
|
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
Pin = m_component->GetNextPin();
|
|
|
|
for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
if( ( Pin->GetConvert() ) && ( Pin->GetConvert() != m_convert ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Is it the "selected mode" ?
|
2009-09-29 18:38:21 +00:00
|
|
|
if( selected && ( Pin->m_Selected & IS_SELECTED ) == 0 )
|
2008-04-17 16:25:29 +00:00
|
|
|
continue;
|
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
Pin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &showPinText, DefaultTransform );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
|
|
|
|
Pin->m_PinNumSize = MasterPin->m_PinNumSize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
|
|
|
|
Pin->m_PinNameSize = MasterPin->m_PinNameSize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
|
|
|
Pin->m_PinLen = MasterPin->m_PinLen;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
( ( LIB_DRAW_ITEM* )Pin )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE,
|
|
|
|
&showPinText, DefaultTransform );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-30 19:26:25 +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
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL || SourcePin == NULL
|
2009-09-22 12:27:57 +00:00
|
|
|
|| SourcePin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
2008-04-17 16:25:29 +00:00
|
|
|
return;
|
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
Pin = (LIB_PIN*) SourcePin->GenCopy();
|
|
|
|
Pin->m_Flags = IS_NEW;
|
2009-09-02 18:12:45 +00:00
|
|
|
Pin->m_Pos.x += g_RepeatStep.x;
|
|
|
|
Pin->m_Pos.y += -g_RepeatStep.y;
|
2008-04-17 16:25:29 +00:00
|
|
|
IncrementLabelMember( Pin->m_PinName );
|
|
|
|
|
|
|
|
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
|
|
|
|
2009-05-09 17:29:48 +00:00
|
|
|
if( g_EditPinByPinIsOn == false )
|
2008-04-17 16:25:29 +00:00
|
|
|
Pin->m_Flags |= IS_LINKED;
|
|
|
|
|
|
|
|
wxPoint savepos = GetScreen()->m_Curseur;
|
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
GetScreen()->m_Curseur.x = Pin->m_Pos.x;
|
|
|
|
GetScreen()->m_Curseur.y = -Pin->m_Pos.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();
|
2008-04-17 16:25:29 +00:00
|
|
|
PlacePin( DC );
|
2009-12-29 10:35:11 +00:00
|
|
|
m_lastDrawItem = Pin;
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->m_Curseur = savepos;
|
|
|
|
DrawPanel->CursorOn( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
Pin->DisplayInfo( this );
|
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
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
/* helper function to sort pins by pin num */
|
|
|
|
bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-20 09:17:24 +00:00
|
|
|
int test = ref->m_PinNum - tst->m_PinNum;
|
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
|
|
|
}
|
|
|
|
if( test == 0 )
|
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
test = ref->GetUnit() - tst->GetUnit();
|
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
|
2009-10-30 19:26:25 +00:00
|
|
|
int dup_error;
|
|
|
|
int offgrid_error;
|
|
|
|
LIB_PIN* Pin;
|
|
|
|
LIB_PIN_LIST 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
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( Pin->m_PinNum != curr_pin->m_PinNum
|
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 );
|
|
|
|
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 ),
|
2009-10-16 17:18:23 +00:00
|
|
|
GetChars( curr_pin->m_PinName ),
|
2009-10-30 19:26:25 +00:00
|
|
|
(float) curr_pin->m_Pos.x / 1000.0,
|
|
|
|
(float) -curr_pin->m_Pos.y / 1000.0,
|
2009-10-20 09:17:24 +00:00
|
|
|
GetChars( stringPinNum ),
|
2009-10-16 17:18:23 +00:00
|
|
|
GetChars( Pin->m_PinName ),
|
2009-10-30 19:26:25 +00:00
|
|
|
(float) Pin->m_Pos.x / 1000.0,
|
|
|
|
(float) -Pin->m_Pos.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;
|
|
|
|
for( unsigned ii = 0; ii < PinList.size(); ii++ )
|
|
|
|
{
|
|
|
|
Pin = PinList[ii];
|
|
|
|
|
|
|
|
if( ( (Pin->m_Pos.x % MIN_GRID_SIZE) == 0 ) &&
|
|
|
|
( (Pin->m_Pos.y % MIN_GRID_SIZE) == 0 ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// A pin is foun here off grid
|
|
|
|
offgrid_error++;
|
|
|
|
wxString stringPinNum;
|
|
|
|
Pin->ReturnPinStringNum( stringPinNum );
|
2009-10-30 19:26:25 +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 ),
|
|
|
|
GetChars( Pin->m_PinName ),
|
2009-10-30 19:26:25 +00:00
|
|
|
(float) Pin->m_Pos.x / 1000.0,
|
|
|
|
(float) -Pin->m_Pos.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 )
|
2009-10-30 19:26:25 +00:00
|
|
|
DisplayInfoMessage( this,
|
|
|
|
_( "No off grid or duplicate pins were found." ) );
|
2009-10-25 15:54:00 +00:00
|
|
|
|
2009-10-20 09:17:24 +00:00
|
|
|
else
|
|
|
|
error_display.ShowModal();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|