2008-04-17 16:25:29 +00:00
|
|
|
|
/***************************/
|
|
|
|
|
/* EESchema - PinEdit.cpp */
|
|
|
|
|
/***************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
#if defined (__GNUG__) && !defined (NO_GCC_PRAGMA)
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#pragma implementation "pinedit-dialog.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "pinedit-dialog.h"
|
|
|
|
|
|
|
|
|
|
static int CodeOrient[4] =
|
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
PIN_RIGHT,
|
|
|
|
|
PIN_LEFT,
|
|
|
|
|
PIN_UP,
|
|
|
|
|
PIN_DOWN
|
2007-05-06 16:03:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define NBSHAPES 7
|
|
|
|
|
static wxString shape_list[NBSHAPES] =
|
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
_( "line" ), _( "invert" ), _( "clock" ), _( "clock inv" ),
|
|
|
|
|
_( "low in" ), _( "low clock" ), _( "low out" )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
int CodeShape[NBSHAPES] =
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
|
NONE, INVERT, CLOCK, CLOCK | INVERT, LOWLEVEL_IN, LOWLEVEL_IN | CLOCK,
|
|
|
|
|
LOWLEVEL_OUT
|
2007-05-06 16:03:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Routines locales */
|
2008-04-17 16:25:29 +00:00
|
|
|
|
static void CreateImagePins( LibDrawPin* Pin );
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
/* Variables importees */
|
|
|
|
|
|
|
|
|
|
/* Variables locales */
|
|
|
|
|
static wxPoint OldPos, PinPreviousPos;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
static int LastPinType = PIN_INPUT,
|
|
|
|
|
LastPinOrient = PIN_RIGHT,
|
|
|
|
|
LastPinShape = NONE,
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LastPinSize = 300,
|
|
|
|
|
LastPinNameSize = 50,
|
|
|
|
|
LastPinNumSize = 50,
|
2009-05-09 17:29:48 +00:00
|
|
|
|
LastPinCommonConvert = false,
|
|
|
|
|
LastPinCommonUnit = false,
|
|
|
|
|
LastPinNoDraw = false;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "pinedit-dialog.cpp"
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*************************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
/* Met a jour les differents parametres pour le composant en cours d'<27>dition
|
2008-04-17 16:25:29 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
|
|
LastPinType = m_PinElectricalType->GetSelection();
|
|
|
|
|
LastPinShape = CodeShape[m_PinShape->GetSelection()];
|
|
|
|
|
LastPinOrient = CodeOrient[m_PinOrient->GetSelection()];
|
|
|
|
|
LastPinCommonConvert = m_CommonConvert->GetValue();
|
|
|
|
|
LastPinCommonUnit = m_CommonUnit->GetValue();
|
|
|
|
|
LastPinNoDraw = m_NoDraw->GetValue();
|
2008-08-11 18:21:21 +00:00
|
|
|
|
|
|
|
|
|
msg = m_PinSizeCtrl->GetValue();
|
2009-09-02 18:12:45 +00:00
|
|
|
|
LastPinSize = ReturnValueFromString( g_UnitMetric, msg,
|
|
|
|
|
m_Parent->m_InternalUnits );
|
2008-08-11 18:21:21 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
msg = m_PinNameSizeCtrl->GetValue();
|
2009-09-02 18:12:45 +00:00
|
|
|
|
LastPinNameSize = ReturnValueFromString( g_UnitMetric, msg,
|
|
|
|
|
m_Parent->m_InternalUnits );
|
2008-08-11 18:21:21 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
msg = m_PinNumSizeCtrl->GetValue();
|
2009-09-02 18:12:45 +00:00
|
|
|
|
LastPinNumSize = ReturnValueFromString( g_UnitMetric, msg,
|
|
|
|
|
m_Parent->m_InternalUnits );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
if( CurrentDrawItem ) // Set Pin Name & Num
|
|
|
|
|
{
|
|
|
|
|
if( !(CurrentDrawItem->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place
|
|
|
|
|
m_Parent->SaveCopyInUndoList( CurrentLibEntry );
|
|
|
|
|
|
|
|
|
|
SetPinName( m_PinNameCtrl->GetValue(), LastPinNameSize );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
msg = m_PinNumCtrl->GetValue();
|
|
|
|
|
if( msg.IsEmpty() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
msg = wxT( "~" );
|
|
|
|
|
SetPinNum( msg, LastPinNumSize );
|
|
|
|
|
NewSizePin( LastPinSize );
|
|
|
|
|
SetPinShape( LastPinShape );
|
|
|
|
|
SetPinType( LastPinType );
|
|
|
|
|
SetPinOrient( LastPinOrient );
|
2009-05-09 17:29:48 +00:00
|
|
|
|
SetAttributsPin( true, true, true ); // Set all attributes (visibility, common to units and common to convert options)
|
2009-04-05 20:49:15 +00:00
|
|
|
|
CurrentDrawItem->DisplayInfo( m_Parent );
|
2009-05-09 17:29:48 +00:00
|
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2009-05-09 17:29:48 +00:00
|
|
|
|
m_Parent->DrawPanel->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
|
void WinEDA_LibeditFrame::InitEditOnePin()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*********************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2008-08-11 18:21:21 +00:00
|
|
|
|
/* Called when installing the edit pin dialog frame
|
|
|
|
|
* Set pins flags (.m_Flags pins member) to ensure a correctins edition:
|
|
|
|
|
* If 2 or more pins are on the same location (and the same orientation) they are all moved or resized.
|
|
|
|
|
* This is usefull for components which have more than one part per package
|
|
|
|
|
* In this case all parts can be edited at once.
|
|
|
|
|
* Note: if the option "Edit Pin per Pin" (tool of the main toolbar) is activated, only the current part is edited
|
2008-04-17 16:25:29 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* Pin;
|
|
|
|
|
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
|
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry == NULL )
|
|
|
|
|
return;
|
|
|
|
|
if( CurrentPin == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Marquage des pins a traiter,Si edition d'une pin non deja selectionnee */
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin == CurrentPin )
|
|
|
|
|
continue;
|
2009-09-02 18:12:45 +00:00
|
|
|
|
if( ( Pin->m_Pos == CurrentPin->m_Pos )
|
|
|
|
|
&& ( Pin->m_Orient == CurrentPin->m_Orient )
|
|
|
|
|
&& ( !( CurrentPin->m_Flags & IS_NEW ) )
|
|
|
|
|
&& ( g_EditPinByPinIsOn == false ) // This is set by the tool of the main toolbar
|
2008-08-11 18:21:21 +00:00
|
|
|
|
)
|
2008-04-17 16:25:29 +00:00
|
|
|
|
Pin->m_Flags |= IS_LINKED | IN_EDIT;
|
|
|
|
|
else
|
|
|
|
|
Pin->m_Flags = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
CurrentPin->DisplayInfo( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Used to abort the move pin command.
|
2008-04-17 16:25:29 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( CurrentPin && ( CurrentPin->m_Flags & IS_NEW ) )
|
2009-09-04 18:57:37 +00:00
|
|
|
|
CurrentLibEntry->RemoveDrawItem( CurrentPin, Panel, DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
/* clear edit flags */
|
|
|
|
|
LibEDA_BaseStruct* item = CurrentLibEntry->m_Drawings;
|
|
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
|
item->m_Flags = 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
|
|
|
|
CurrentDrawItem = NULL;
|
|
|
|
|
LibItemToRepeat = NULL;
|
|
|
|
|
Panel->Refresh( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/********************************************/
|
|
|
|
|
/* Routine de fin de deplacement de la pin selectionnee */
|
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* Pin;
|
|
|
|
|
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
|
2009-05-09 17:29:48 +00:00
|
|
|
|
bool ask_for_pin = true;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
wxPoint newpos;
|
|
|
|
|
bool status;
|
|
|
|
|
|
|
|
|
|
if( CurrentPin == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
newpos.x = GetScreen()->m_Curseur.x;
|
|
|
|
|
newpos.y = -GetScreen()->m_Curseur.y;
|
|
|
|
|
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
|
|
|
|
|
|
|
|
|
// Tst for an other pin in same new position:
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin == CurrentPin )
|
|
|
|
|
continue;
|
|
|
|
|
if( newpos != Pin->m_Pos )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Flags )
|
|
|
|
|
continue;
|
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;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
status = IsOK( this, _( "Occupied by other pin. Continue?" ) );
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
|
|
|
|
|
CurrentPin->m_Pos = newpos;
|
|
|
|
|
if( CurrentPin->m_Flags & IS_NEW )
|
|
|
|
|
{
|
|
|
|
|
LastPinOrient = CurrentPin->m_Orient;
|
|
|
|
|
LastPinType = CurrentPin->m_PinType;
|
|
|
|
|
LastPinShape = CurrentPin->m_PinShape;
|
|
|
|
|
CreateImagePins( CurrentPin );
|
|
|
|
|
LibItemToRepeat = CurrentPin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Put linked pins in new position, and clear flags */
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
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,
|
|
|
|
|
&showPinText, DefaultTransformMatrix );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
DrawPanel->CursorOn( DC );
|
|
|
|
|
|
|
|
|
|
CurrentDrawItem = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_PinPropertiesFrame::SetPinOrient( int neworient )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***********************************************************/
|
|
|
|
|
/* Routine de Rotation de la pin courante*/
|
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
|
|
|
|
|
LibDrawPin* Pin, * RefPin = CurrentPin;
|
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry == NULL )
|
|
|
|
|
return;
|
|
|
|
|
if( RefPin == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
|
|
|
|
|
|
/* Rotation */
|
|
|
|
|
RefPin->m_Orient = neworient;
|
|
|
|
|
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->m_Flags == 0 )
|
|
|
|
|
continue;
|
|
|
|
|
Pin->m_Orient = RefPin->m_Orient;
|
|
|
|
|
if( CurrentPin == NULL )
|
|
|
|
|
Pin->m_Flags = 0;
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_LibeditFrame::StartMovePin( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Prepare le deplacement d'une pin :
|
2008-04-17 16:25:29 +00:00
|
|
|
|
* Localise la pin pointee par le curseur, et si elle existe active
|
|
|
|
|
* la fonction de gestion curseur ( DrawMovePin() ).
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* Pin;
|
|
|
|
|
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
|
|
|
|
|
wxPoint startPos;
|
|
|
|
|
|
|
|
|
|
/* Marquage des pins a traiter */
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
Pin->m_Flags = 0;
|
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin == CurrentPin )
|
|
|
|
|
continue;
|
2009-09-02 18:12:45 +00:00
|
|
|
|
if( ( Pin->m_Pos == CurrentPin->m_Pos )
|
|
|
|
|
&& ( 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
/* Routine de deplacement de la Pin courante selon position du curseur souris */
|
2009-09-02 18:12:45 +00:00
|
|
|
|
/* Routine normalement appelee par la routine de gestion du curseur */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/******************************************************************************/
|
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
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
|
|
|
|
|
wxPoint pinpos = CurrentPin->m_Pos;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
bool showPinText = true;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
/* Erase pin in old position */
|
2009-09-02 18:12:45 +00:00
|
|
|
|
if( erase || ( CurrentPin->m_Flags & IS_NEW ) )
|
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,
|
|
|
|
|
&showPinText, DefaultTransformMatrix );
|
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;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
CurrentPin->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
|
|
|
|
|
&showPinText, DefaultTransformMatrix );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
PinPreviousPos = CurrentPin->m_Pos;
|
|
|
|
|
|
|
|
|
|
/* Keep the original position for existing pin (for Undo command)
|
|
|
|
|
* and the current position for a new pin */
|
|
|
|
|
if( (CurrentPin->m_Flags & IS_NEW) == 0 )
|
|
|
|
|
CurrentPin->m_Pos = pinpos;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_PinPropertiesFrame::SetPinShape( int newshape )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**********************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Changement de la forme de la pin courante.
|
2008-04-17 16:25:29 +00:00
|
|
|
|
* Le changement est egalement fait sur les autres pins correspondantes
|
|
|
|
|
* des autres unites de la seule forme convert courante
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* Pin;
|
|
|
|
|
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
|
|
|
|
|
|
|
|
|
|
if( CurrentPin )
|
|
|
|
|
{
|
|
|
|
|
CurrentPin->m_PinShape = newshape;
|
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
CurrentPin->DisplayInfo( m_Parent );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Flags == 0 )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Convert != CurrentPin->m_Convert )
|
|
|
|
|
continue;
|
|
|
|
|
Pin->m_PinShape = newshape;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_PinPropertiesFrame::SetPinType( int newtype )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/******************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Changement du type electrique de la pin courante.
|
2008-04-17 16:25:29 +00:00
|
|
|
|
* Le changement est egalement fait sur les autres pins correspondantes
|
|
|
|
|
* des autres unites du boitier
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* Pin;
|
|
|
|
|
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
|
|
|
|
|
|
|
|
|
|
if( CurrentPin == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CurrentPin->m_PinType = newtype;
|
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
|
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Flags == 0 )
|
|
|
|
|
continue;
|
|
|
|
|
Pin->m_PinType = newtype;
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/********************************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_PinPropertiesFrame::SetPinName( const wxString& newname, int newsize )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/********************************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Met a jour le nom et la taille de ce nom de la pin courante
|
2008-04-17 16:25:29 +00:00
|
|
|
|
* si newname == NULL, pas de changement de nom
|
|
|
|
|
* si newsize < 0 : pas de changement de taille
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* Pin;
|
|
|
|
|
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
|
|
|
|
|
wxString buf;
|
|
|
|
|
|
|
|
|
|
buf = newname;
|
|
|
|
|
buf.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
|
|
|
|
|
if( newsize >= 0 )
|
|
|
|
|
CurrentPin->m_PinNameSize = newsize;
|
|
|
|
|
|
|
|
|
|
CurrentPin->m_PinName = buf;
|
|
|
|
|
|
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
|
|
|
|
|
|
/* Traitement des autres pins */
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( (Pin->m_Flags & IS_LINKED) == 0 )
|
|
|
|
|
continue;
|
|
|
|
|
if( newsize >= 0 )
|
|
|
|
|
Pin->m_PinNameSize = newsize;
|
|
|
|
|
Pin->m_PinName = buf;
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/******************************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/******************************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Changement du numero de la pin courante.
|
2008-04-17 16:25:29 +00:00
|
|
|
|
* Le changement est egalement fait sur les autres pins correspondantes
|
|
|
|
|
* a la forme convertie
|
|
|
|
|
* Si newnum == NULL: pas de changement de numero
|
|
|
|
|
* Si newsize < 0 ) pase de changement de taille
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* Pin;
|
|
|
|
|
LibDrawPin* CurrentPin = (LibDrawPin*) CurrentDrawItem;
|
|
|
|
|
wxString buf;
|
|
|
|
|
|
|
|
|
|
buf = newnum;
|
|
|
|
|
buf.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
|
|
|
|
|
if( CurrentPin == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CurrentPin->m_PinNum = 0;
|
|
|
|
|
|
|
|
|
|
if( newsize >= 0 )
|
|
|
|
|
CurrentPin->m_PinNumSize = newsize;
|
|
|
|
|
CurrentPin->SetPinNumFromString( buf );
|
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
|
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
2009-09-02 18:12:45 +00:00
|
|
|
|
if( ( Pin->m_Flags & IS_LINKED ) == 0 )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Unit != CurrentPin->m_Unit )
|
|
|
|
|
continue;
|
|
|
|
|
if( newsize >= 0 )
|
|
|
|
|
Pin->m_PinNumSize = newsize;
|
2009-04-13 05:58:11 +00:00
|
|
|
|
Pin->m_PinNum = CurrentPin->m_PinNum;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************/
|
2009-09-18 14:56:05 +00:00
|
|
|
|
void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
|
|
|
|
|
LIB_COMPONENT* LibEntry,
|
|
|
|
|
LibDrawPin* Pin )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Routine d'effacement de la pin pointee par la souris
|
2009-05-09 17:29:48 +00:00
|
|
|
|
* Si g_EditPinByPinIsOn == false :
|
2008-04-17 16:25:29 +00:00
|
|
|
|
* toutes les pins de meme coordonnee seront effacees.
|
|
|
|
|
* Sinon seule la pin de l'unite en convert courante sera effacee
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibEDA_BaseStruct* DrawItem;
|
|
|
|
|
wxPoint PinPos;
|
|
|
|
|
|
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-04 18:57:37 +00:00
|
|
|
|
LibEntry->RemoveDrawItem( (LibEDA_BaseStruct*) Pin, DrawPanel, DC );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
/* Effacement des autres pins de meme coordonnees */
|
2009-05-09 17:29:48 +00:00
|
|
|
|
if( g_EditPinByPinIsOn == false )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
DrawItem = LibEntry->m_Drawings;
|
|
|
|
|
for( ; DrawItem != NULL; )
|
|
|
|
|
{
|
|
|
|
|
if( DrawItem->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
|
DrawItem = DrawItem->Next();
|
|
|
|
|
continue;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
Pin = (LibDrawPin*) DrawItem;
|
|
|
|
|
DrawItem = DrawItem->Next();
|
|
|
|
|
if( Pin->m_Pos != PinPos )
|
|
|
|
|
continue;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
LibEntry->RemoveDrawItem( (LibEDA_BaseStruct*) Pin );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
GetScreen()->SetModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*********************************************/
|
|
|
|
|
/* Creation d'une nouvelle pin */
|
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibEDA_BaseStruct* DrawItem;
|
2008-08-25 13:26:48 +00:00
|
|
|
|
LibDrawPin* CurrentPin;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
bool showPinText = true;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Effacement des flags */
|
|
|
|
|
DrawItem = CurrentLibEntry->m_Drawings;
|
|
|
|
|
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
|
|
|
|
|
DrawItem->m_Flags = 0;
|
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
|
CurrentPin = new LibDrawPin(CurrentLibEntry);
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
CurrentDrawItem = CurrentPin;
|
|
|
|
|
if( CurrentPin == NULL )
|
|
|
|
|
return;
|
|
|
|
|
CurrentPin->m_Flags = IS_NEW;
|
|
|
|
|
CurrentPin->m_Unit = CurrentUnit;
|
|
|
|
|
CurrentPin->m_Convert = CurrentConvert;
|
|
|
|
|
|
|
|
|
|
/* Marquage des pins a traiter */
|
2009-05-09 17:29:48 +00:00
|
|
|
|
if( g_EditPinByPinIsOn == false )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
CurrentPin->m_Flags |= IS_LINKED;
|
|
|
|
|
|
|
|
|
|
CurrentPin->m_Pos.x = GetScreen()->m_Curseur.x;
|
|
|
|
|
CurrentPin->m_Pos.y = -GetScreen()->m_Curseur.y;
|
|
|
|
|
CurrentPin->m_PinLen = LastPinSize;
|
|
|
|
|
CurrentPin->m_Orient = LastPinOrient;
|
|
|
|
|
CurrentPin->m_PinType = LastPinType;
|
|
|
|
|
CurrentPin->m_PinShape = LastPinShape;
|
|
|
|
|
CurrentPin->m_PinNameSize = LastPinNameSize;
|
|
|
|
|
CurrentPin->m_PinNumSize = LastPinNumSize;
|
|
|
|
|
if( LastPinCommonConvert )
|
|
|
|
|
CurrentPin->m_Convert = 0;
|
|
|
|
|
else
|
|
|
|
|
CurrentPin->m_Convert = CurrentConvert;
|
|
|
|
|
if( LastPinCommonUnit )
|
|
|
|
|
CurrentPin->m_Unit = 0;
|
|
|
|
|
else
|
|
|
|
|
CurrentPin->m_Unit = CurrentUnit;
|
|
|
|
|
if( LastPinNoDraw )
|
|
|
|
|
CurrentPin->m_Attributs |= PINNOTDRAW;
|
|
|
|
|
else
|
|
|
|
|
CurrentPin->m_Attributs &= ~PINNOTDRAW;
|
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
CurrentPin->SetNext( CurrentLibEntry->m_Drawings );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
CurrentLibEntry->m_Drawings = CurrentPin;
|
|
|
|
|
CurrentLibEntry->SortDrawItems();
|
|
|
|
|
|
|
|
|
|
if( DC )
|
2009-09-04 18:57:37 +00:00
|
|
|
|
CurrentPin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
|
|
|
|
|
&showPinText, DefaultTransformMatrix );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2009-05-09 17:29:48 +00:00
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = true;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
InstallPineditFrame( this, DC, wxPoint( -1, -1 ) );
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2009-05-09 17:29:48 +00:00
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = false;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
PinPreviousPos = CurrentPin->m_Pos;
|
|
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = DrawMovePin;
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortPinMove;
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
CurrentPin->DisplayInfo( this );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
GetScreen()->SetModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
|
|
|
|
|
bool unit, bool convert )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*********************************************************/
|
|
|
|
|
|
2009-05-09 17:29:48 +00:00
|
|
|
|
/* si draw == true
|
2008-04-17 16:25:29 +00:00
|
|
|
|
* - Ajuste le flag visible / invisible (.U.Pin.Flags bit 0 ) de la pin
|
|
|
|
|
* editee
|
|
|
|
|
*
|
2009-05-09 17:29:48 +00:00
|
|
|
|
* si unit == true
|
2008-04-17 16:25:29 +00:00
|
|
|
|
* - Modifie l'attribut Commun / Particulier U.Pin.Unit = 0 ou Num Unite
|
|
|
|
|
* de la pin editee
|
|
|
|
|
*
|
2009-05-09 17:29:48 +00:00
|
|
|
|
* si convert == true
|
2008-04-17 16:25:29 +00:00
|
|
|
|
* - Modifie l'attribut Commun / Particulier U.Pin.Convert = 0 ou Num Unite
|
|
|
|
|
* de la pin editee
|
|
|
|
|
*
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibEDA_BaseStruct* DrawItem;
|
|
|
|
|
LibDrawPin* Pin, * CurrentPin = (LibDrawPin*) CurrentDrawItem;
|
|
|
|
|
|
|
|
|
|
if( CurrentPin == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
|
|
|
|
|
|
if( unit )
|
|
|
|
|
{
|
|
|
|
|
if( LastPinCommonUnit )
|
|
|
|
|
CurrentPin->m_Unit = 0;
|
|
|
|
|
else
|
|
|
|
|
CurrentPin->m_Unit = CurrentUnit;
|
|
|
|
|
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
|
|
|
|
|
|
|
|
|
if( CurrentPin->m_Unit == 0 )
|
|
|
|
|
{
|
|
|
|
|
DrawItem = CurrentLibEntry->m_Drawings;
|
|
|
|
|
for( ; DrawItem != NULL; )
|
|
|
|
|
{
|
|
|
|
|
Pin = (LibDrawPin*) DrawItem;
|
|
|
|
|
DrawItem = DrawItem->Next();
|
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Flags == 0 )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin == CurrentPin )
|
|
|
|
|
continue;
|
2009-09-02 18:12:45 +00:00
|
|
|
|
if( CurrentPin->m_Convert
|
|
|
|
|
&& (CurrentPin->m_Convert != Pin->m_Convert) )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
continue;
|
|
|
|
|
if( CurrentPin->m_Pos != Pin->m_Pos )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Orient != CurrentPin->m_Orient )
|
|
|
|
|
continue;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
|
|
|
|
|
CurrentLibEntry->RemoveDrawItem( (LibEDA_BaseStruct*) Pin );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // end if unit
|
|
|
|
|
|
|
|
|
|
if( convert )
|
|
|
|
|
{
|
|
|
|
|
if( LastPinCommonConvert )
|
|
|
|
|
CurrentPin->m_Convert = 0;
|
|
|
|
|
else
|
|
|
|
|
CurrentPin->m_Convert = CurrentConvert;
|
|
|
|
|
|
|
|
|
|
if( CurrentPin->m_Convert == 0 ) /* Effacement des pins redondantes */
|
|
|
|
|
{
|
|
|
|
|
DrawItem = CurrentLibEntry->m_Drawings;
|
|
|
|
|
for( ; DrawItem != NULL; )
|
|
|
|
|
{
|
2009-09-02 18:12:45 +00:00
|
|
|
|
Pin = (LibDrawPin*) DrawItem;
|
|
|
|
|
DrawItem = DrawItem->Next();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Flags == 0 )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin == CurrentPin )
|
|
|
|
|
continue;
|
|
|
|
|
if( CurrentPin->m_Unit && (CurrentPin->m_Unit != Pin->m_Unit) )
|
|
|
|
|
continue;
|
|
|
|
|
if( CurrentPin->m_Pos != Pin->m_Pos )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Orient != CurrentPin->m_Orient )
|
|
|
|
|
continue;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
|
|
|
|
|
CurrentLibEntry->RemoveDrawItem( (LibEDA_BaseStruct*) Pin );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // end if convert
|
|
|
|
|
|
|
|
|
|
if( draw )
|
|
|
|
|
{
|
|
|
|
|
if( LastPinNoDraw )
|
|
|
|
|
CurrentPin->m_Attributs |= PINNOTDRAW;
|
|
|
|
|
else
|
|
|
|
|
CurrentPin->m_Attributs &= ~PINNOTDRAW;
|
|
|
|
|
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->m_Flags == 0 )
|
|
|
|
|
continue;
|
2009-05-09 17:29:48 +00:00
|
|
|
|
if( LastPinNoDraw )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
Pin->m_Attributs |= PINNOTDRAW;
|
2009-05-09 17:29:48 +00:00
|
|
|
|
else
|
|
|
|
|
Pin->m_Attributs &= ~PINNOTDRAW;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_PinPropertiesFrame::NewSizePin( int newsize )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/******************************************************/
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
/* Fonction permettant la mise aux dimensions courantes:
|
|
|
|
|
* - longueur, dimension des textes
|
|
|
|
|
* de la pin courante
|
|
|
|
|
*
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* RefPin, * Pin = (LibDrawPin*) CurrentDrawItem;
|
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry == NULL )
|
|
|
|
|
return;
|
|
|
|
|
if( Pin == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
|
|
|
|
|
|
Pin->m_PinLen = newsize;
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
Pin->DisplayInfo( m_Parent );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
RefPin = Pin;
|
|
|
|
|
|
2009-05-09 17:29:48 +00:00
|
|
|
|
if( g_EditPinByPinIsOn == false )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Pos != RefPin->m_Pos )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Orient != RefPin->m_Orient )
|
|
|
|
|
continue;
|
|
|
|
|
if( Pin->m_Convert == RefPin->m_Convert )
|
|
|
|
|
Pin->m_PinLen = newsize;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/********************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
static void CreateImagePins( LibDrawPin* Pin )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/********************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Creation des autres pins pour les autres unites et pour convert, apres
|
2008-04-17 16:25:29 +00:00
|
|
|
|
* creation d'une pin
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
|
int ii;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* NewPin;
|
2009-05-21 17:42:42 +00:00
|
|
|
|
bool CreateConv = false;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
if( g_EditPinByPinIsOn )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if( g_AsDeMorgan && (Pin->m_Convert != 0 ) )
|
2009-05-09 17:29:48 +00:00
|
|
|
|
CreateConv = true;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
/* Creation de la pin " convert " pour la part courante */
|
2009-05-09 17:29:48 +00:00
|
|
|
|
if( CreateConv == true )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2009-09-02 18:12:45 +00:00
|
|
|
|
NewPin = (LibDrawPin*) Pin->GenCopy();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( Pin->m_Convert > 1 )
|
|
|
|
|
NewPin->m_Convert = 1;
|
|
|
|
|
else
|
|
|
|
|
NewPin->m_Convert = 2;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
NewPin->SetNext( CurrentLibEntry->m_Drawings );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
CurrentLibEntry->m_Drawings = NewPin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( ii = 1; ii <= CurrentLibEntry->m_UnitCount; ii++ )
|
|
|
|
|
{
|
|
|
|
|
if( ii == CurrentUnit )
|
|
|
|
|
continue; /* Deja fait */
|
|
|
|
|
if( Pin->m_Unit == 0 )
|
|
|
|
|
continue; /* Pin commune a toutes les unites */
|
|
|
|
|
|
|
|
|
|
/* Creation pour la representation "normale" */
|
2009-09-02 18:12:45 +00:00
|
|
|
|
NewPin = (LibDrawPin*) Pin->GenCopy();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( CurrentConvert != 0 )
|
|
|
|
|
NewPin->m_Convert = 1;
|
|
|
|
|
NewPin->m_Unit = ii;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
NewPin->SetNext( CurrentLibEntry->m_Drawings );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
CurrentLibEntry->m_Drawings = NewPin;
|
|
|
|
|
|
|
|
|
|
/* Creation pour la representation "Convert" */
|
2009-05-09 17:29:48 +00:00
|
|
|
|
if( CreateConv == false )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
|
NewPin = (LibDrawPin*)Pin->GenCopy();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
NewPin->m_Convert = 2;
|
|
|
|
|
if( Pin->m_Unit != 0 )
|
|
|
|
|
NewPin->m_Unit = ii;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
NewPin->SetNext( CurrentLibEntry->m_Drawings );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
CurrentLibEntry->m_Drawings = NewPin;
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC,
|
|
|
|
|
LibDrawPin* MasterPin, int id )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*************************************************/
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
/* Depending on "id":
|
|
|
|
|
* - Change pin text size (name or num) (range 10 .. 1000 mil)
|
|
|
|
|
* - Change pin lenght.
|
|
|
|
|
*
|
|
|
|
|
* If Pin is selected ( .m_flag == IS_SELECTED ) only the other selected pis are modified
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* Pin;
|
2009-09-02 18:12:45 +00:00
|
|
|
|
bool selected = ( MasterPin->m_Selected & IS_SELECTED ) != 0;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
bool showPinText = true;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
|
if( ( CurrentLibEntry == NULL ) || ( MasterPin == NULL ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
return;
|
|
|
|
|
if( MasterPin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
2009-09-02 18:12:45 +00:00
|
|
|
|
if( ( Pin->m_Convert ) && ( Pin->m_Convert != CurrentConvert ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Is it the "selected mode" ?
|
|
|
|
|
if( selected && (Pin->m_Selected & IS_SELECTED) == 0 )
|
|
|
|
|
continue;
|
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
|
Pin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
|
|
|
|
|
&showPinText, DefaultTransformMatrix );
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
|
Pin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE,
|
|
|
|
|
&showPinText, DefaultTransformMatrix );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/************************************************************************/
|
2008-02-12 21:12:46 +00:00
|
|
|
|
/* Creation d'une nouvelle pin par copie de la pr<70>c<EFBFBD>dente ( fct REPEAT) */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
LibDrawPin* Pin;
|
|
|
|
|
wxString msg;
|
|
|
|
|
int ox = 0, oy = 0;
|
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry == NULL )
|
|
|
|
|
return;
|
|
|
|
|
if( SourcePin == NULL )
|
|
|
|
|
return;
|
|
|
|
|
if( SourcePin->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
return;
|
|
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
|
Pin = (LibDrawPin*)SourcePin->GenCopy();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
Pin->SetNext( CurrentLibEntry->m_Drawings );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
CurrentLibEntry->m_Drawings = Pin;
|
|
|
|
|
Pin->m_Flags = IS_NEW;
|
|
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
|
Pin->m_Pos.x += g_RepeatStep.x;
|
|
|
|
|
ox = Pin->m_Pos.x;
|
|
|
|
|
Pin->m_Pos.y += -g_RepeatStep.y;
|
|
|
|
|
oy = Pin->m_Pos.y; // ici axe Y comme en math
|
2008-04-17 16:25:29 +00:00
|
|
|
|
/*** Increment du numero de label ***/
|
|
|
|
|
IncrementLabelMember( Pin->m_PinName );
|
|
|
|
|
|
|
|
|
|
Pin->ReturnPinStringNum( msg );
|
|
|
|
|
IncrementLabelMember( msg );
|
|
|
|
|
Pin->SetPinNumFromString( msg );
|
|
|
|
|
|
|
|
|
|
CurrentDrawItem = Pin;
|
|
|
|
|
|
|
|
|
|
/* Marquage des pins a traiter */
|
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;
|
|
|
|
|
PlacePin( DC );
|
|
|
|
|
GetScreen()->m_Curseur = savepos;
|
|
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
|
// DrawPanel->MouseToCursorSchema();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
DrawPanel->CursorOn( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
Pin->DisplayInfo( this );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
GetScreen()->SetModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
int sort_by_pin_number( const void* ref, const void* tst )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
const LibDrawPin* Ref = *(LibDrawPin**) ref;
|
|
|
|
|
const LibDrawPin* Tst = *(LibDrawPin**) tst;
|
|
|
|
|
|
|
|
|
|
return Ref->m_PinNum - Tst->m_PinNum;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***************************************************************/
|
2009-09-18 14:56:05 +00:00
|
|
|
|
bool WinEDA_LibeditFrame::TestPins( LIB_COMPONENT* LibEntry )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
// Test des pins ( duplicates...)
|
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
|
int nb_pins, ii, error;
|
|
|
|
|
LibDrawPin* Pin;
|
|
|
|
|
LibDrawPin** PinList;
|
|
|
|
|
wxString msg;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry == NULL )
|
2009-05-09 17:29:48 +00:00
|
|
|
|
return false;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
// Construction de la liste des pins:
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( nb_pins = 0; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
nb_pins++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PinList = (LibDrawPin**) MyZMalloc( (nb_pins + 1) * sizeof(LibDrawPin*) );
|
|
|
|
|
Pin = (LibDrawPin*) CurrentLibEntry->m_Drawings;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ii = 0; Pin != NULL; Pin = Pin->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
PinList[ii++] = Pin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Classement des pins par numero de pin
|
|
|
|
|
qsort( PinList, nb_pins, sizeof(LibDrawPin*), sort_by_pin_number );
|
|
|
|
|
|
|
|
|
|
// Controle des duplicates:
|
|
|
|
|
error = 0;
|
|
|
|
|
for( ii = 1; ii < nb_pins; ii++ )
|
|
|
|
|
{
|
|
|
|
|
wxString aux_msg, StringPinNum;
|
|
|
|
|
LibDrawPin* curr_pin = PinList[ii];
|
|
|
|
|
Pin = PinList[ii - 1];
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( Pin->m_PinNum != curr_pin->m_PinNum )
|
|
|
|
|
continue;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( Pin->m_Convert != curr_pin->m_Convert )
|
|
|
|
|
continue;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( Pin->m_Unit != curr_pin->m_Unit )
|
|
|
|
|
continue;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
error++;
|
|
|
|
|
curr_pin->ReturnPinStringNum( StringPinNum );
|
|
|
|
|
msg.Printf( _( "Duplicate Pin %4.4s (Pin %s loc %d, %d, and Pin %s loc %d, %d)" ),
|
2009-09-04 18:57:37 +00:00
|
|
|
|
StringPinNum.GetData(), curr_pin->m_PinName.GetData(),
|
|
|
|
|
curr_pin->m_Pos.x, -curr_pin->m_Pos.y,
|
|
|
|
|
Pin->m_PinName.GetData(), Pin->m_Pos.x, -Pin->m_Pos.y );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( CurrentLibEntry->m_UnitCount > 1 )
|
|
|
|
|
{
|
|
|
|
|
aux_msg.Printf( _( " Part %d" ), curr_pin->m_Unit );
|
|
|
|
|
msg += aux_msg;
|
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( g_AsDeMorgan )
|
|
|
|
|
{
|
|
|
|
|
if( curr_pin->m_Convert )
|
|
|
|
|
msg += _( " Convert" );
|
|
|
|
|
else
|
|
|
|
|
msg += _( " Normal" );
|
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
DisplayError( this, msg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free( PinList );
|
2009-05-09 17:29:48 +00:00
|
|
|
|
return error ? true : false;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|