2008-09-13 18:59:57 +00:00
|
|
|
/*****************/
|
|
|
|
/* class_pin.cpp */
|
|
|
|
/*****************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "gr_basic.h"
|
2009-06-13 17:06:07 +00:00
|
|
|
#include "trigo.h"
|
2008-09-13 18:59:57 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "drawtxt.h"
|
2008-09-13 18:59:57 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
2008-09-13 19:06:31 +00:00
|
|
|
#include "plot_common.h"
|
2008-09-13 18:59:57 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
2009-06-13 17:06:07 +00:00
|
|
|
const wxChar* MsgPinElectricType[] =
|
|
|
|
{
|
|
|
|
wxT( "input" ),
|
|
|
|
wxT( "output" ),
|
|
|
|
wxT( "BiDi" ),
|
|
|
|
wxT( "3state" ),
|
|
|
|
wxT( "passive" ),
|
|
|
|
wxT( "unspc" ),
|
|
|
|
wxT( "power_in" ),
|
|
|
|
wxT( "power_out" ),
|
|
|
|
wxT( "openCol" ),
|
|
|
|
wxT( "openEm" ),
|
|
|
|
wxT( "?????" )
|
|
|
|
};
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
LibDrawPin::LibDrawPin(EDA_LibComponentStruct * aParent) :
|
|
|
|
LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE, aParent )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
m_PinLen = 300; /* default Pin len */
|
|
|
|
m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */
|
|
|
|
m_PinShape = NONE; /* Bit a bit: Pin shape (voir enum prec) */
|
|
|
|
m_PinType = PIN_UNSPECIFIED; /* electrical type of pin */
|
|
|
|
m_Attributs = 0; /* bit 0 != 0: pin invisible */
|
2009-09-04 18:57:37 +00:00
|
|
|
m_PinNum = 0; /*pin number ( i.e. 4 codes ASCII ) */
|
2009-04-05 20:49:15 +00:00
|
|
|
m_PinNumSize = 50;
|
2009-04-06 10:56:17 +00:00
|
|
|
m_PinNameSize = 50; /* Default size for pin name and num */
|
|
|
|
m_Width = 0;
|
|
|
|
m_typeName = _( "Pin" );
|
2009-06-13 17:06:07 +00:00
|
|
|
m_PinNumShapeOpt = 0;
|
|
|
|
m_PinNameShapeOpt = 0;
|
|
|
|
m_PinNumPositionOpt = 0;
|
|
|
|
m_PinNamePositionOpt = 0;
|
|
|
|
}
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2009-06-13 17:06:07 +00:00
|
|
|
/**
|
|
|
|
* Function HitTest
|
|
|
|
* tests if the given wxPoint is within the bounds of this object.
|
|
|
|
* @param aRefPos A wxPoint to test
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
|
|
|
bool LibDrawPin::HitTest( const wxPoint& aRefPos )
|
|
|
|
{
|
|
|
|
int mindist = m_Width ? m_Width / 2 : g_DrawDefaultLineThickness / 2;
|
|
|
|
|
|
|
|
// Have a minimal tolerance for hit test
|
|
|
|
if( mindist < 3 )
|
|
|
|
mindist = 3; // = 3 mils
|
|
|
|
|
|
|
|
return HitTest( aRefPos, mindist, DefaultTransformMatrix );
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Function HitTest
|
|
|
|
* @return true if the point aPosRef is near a pin
|
|
|
|
* @param aRefPos = a wxPoint to test
|
|
|
|
* @param aThreshold = max distance to a segment
|
|
|
|
* @param aTransMat = the transform matrix
|
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
bool LibDrawPin::HitTest( wxPoint aRefPos, int aThreshold,
|
|
|
|
const int aTransMat[2][2] )
|
2009-06-13 17:06:07 +00:00
|
|
|
{
|
|
|
|
wxPoint pinPos = TransformCoordinate( aTransMat, m_Pos );
|
|
|
|
wxPoint pinEnd = TransformCoordinate( aTransMat, ReturnPinEndPoint() );
|
|
|
|
|
|
|
|
return TestSegmentHit( aRefPos, pinPos, pinEnd, aThreshold );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool LibDrawPin::Save( FILE* ExportFile ) const
|
|
|
|
{
|
|
|
|
wxString StringPinNum;
|
|
|
|
int Etype;
|
|
|
|
|
|
|
|
switch( m_PinType )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case PIN_INPUT:
|
|
|
|
Etype = 'I';
|
|
|
|
break;
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case PIN_OUTPUT:
|
|
|
|
Etype = 'O';
|
|
|
|
break;
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case PIN_BIDI:
|
|
|
|
Etype = 'B';
|
|
|
|
break;
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case PIN_TRISTATE:
|
|
|
|
Etype = 'T';
|
|
|
|
break;
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case PIN_PASSIVE:
|
|
|
|
Etype = 'P';
|
|
|
|
break;
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case PIN_UNSPECIFIED:
|
|
|
|
Etype = 'U';
|
|
|
|
break;
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case PIN_POWER_IN:
|
|
|
|
Etype = 'W';
|
|
|
|
break;
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case PIN_POWER_OUT:
|
|
|
|
Etype = 'w';
|
|
|
|
break;
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case PIN_OPENCOLLECTOR:
|
|
|
|
Etype = 'C';
|
|
|
|
break;
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case PIN_OPENEMITTER:
|
|
|
|
Etype = 'E';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnPinStringNum( StringPinNum );
|
|
|
|
if( StringPinNum.IsEmpty() )
|
|
|
|
StringPinNum = wxT( "~" );
|
|
|
|
|
|
|
|
if( !m_PinName.IsEmpty() )
|
|
|
|
fprintf( ExportFile, "X %s", CONV_TO_UTF8( m_PinName ) );
|
|
|
|
else
|
|
|
|
fprintf( ExportFile, "X ~" );
|
|
|
|
|
|
|
|
fprintf( ExportFile, " %s %d %d %d %c %d %d %d %d %c",
|
|
|
|
CONV_TO_UTF8( StringPinNum ), m_Pos.x, m_Pos.y,
|
|
|
|
(int) m_PinLen, (int) m_Orient, m_PinNumSize, m_PinNameSize,
|
|
|
|
m_Unit, m_Convert, Etype );
|
|
|
|
|
|
|
|
if( (m_PinShape) || (m_Attributs & PINNOTDRAW) )
|
|
|
|
fprintf( ExportFile, " " );
|
|
|
|
if( m_Attributs & PINNOTDRAW )
|
|
|
|
fprintf( ExportFile, "N" );
|
|
|
|
if( m_PinShape & INVERT )
|
|
|
|
fprintf( ExportFile, "I" );
|
|
|
|
if( m_PinShape & CLOCK )
|
|
|
|
fprintf( ExportFile, "C" );
|
|
|
|
if( m_PinShape & LOWLEVEL_IN )
|
|
|
|
fprintf( ExportFile, "L" );
|
|
|
|
if( m_PinShape & LOWLEVEL_OUT )
|
|
|
|
fprintf( ExportFile, "V" );
|
|
|
|
|
|
|
|
fprintf( ExportFile, "\n" );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool LibDrawPin::Load( char* line, wxString& errorMsg )
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
int i, j;
|
2009-04-05 20:49:15 +00:00
|
|
|
char pinAttrs[64];
|
|
|
|
char pinName[256];
|
|
|
|
char pinNum[64];
|
|
|
|
char pinOrient[64];
|
|
|
|
char pinType[64];
|
|
|
|
|
|
|
|
*pinAttrs = 0;
|
|
|
|
|
|
|
|
i = sscanf( line + 2, "%s %s %d %d %d %s %d %d %d %d %s %s", pinName,
|
|
|
|
pinNum, &m_Pos.x, &m_Pos.y, &m_PinLen, pinOrient, &m_PinNumSize,
|
|
|
|
&m_PinNameSize, &m_Unit, &m_Convert, pinType, pinAttrs );
|
|
|
|
|
|
|
|
if( i < 11 )
|
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
errorMsg.Printf( wxT( "pin only had %d parameters of the required 11 or 12" ), i );
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Orient = pinOrient[0] & 255;
|
|
|
|
strncpy( (char*) &m_PinNum, pinNum, 4 );
|
|
|
|
m_PinName = CONV_FROM_UTF8( pinName );
|
|
|
|
|
|
|
|
switch( *pinType & 255 )
|
|
|
|
{
|
|
|
|
case 'I':
|
|
|
|
m_PinType = PIN_INPUT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'O':
|
|
|
|
m_PinType = PIN_OUTPUT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'B':
|
|
|
|
m_PinType = PIN_BIDI;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T':
|
|
|
|
m_PinType = PIN_TRISTATE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'P':
|
|
|
|
m_PinType = PIN_PASSIVE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'U':
|
|
|
|
m_PinType = PIN_UNSPECIFIED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'W':
|
|
|
|
m_PinType = PIN_POWER_IN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'w':
|
|
|
|
m_PinType = PIN_POWER_OUT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C':
|
|
|
|
m_PinType = PIN_OPENCOLLECTOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'E':
|
|
|
|
m_PinType = PIN_OPENEMITTER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
errorMsg.Printf( wxT( "unknown pin type [%c]" ), *pinType & 255 );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
if( i == 12 ) /* Special Symbol defined */
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
for( j = strlen( pinAttrs ); j > 0; )
|
|
|
|
{
|
|
|
|
switch( pinAttrs[--j] )
|
|
|
|
{
|
|
|
|
case '~':
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'N':
|
|
|
|
m_Attributs |= PINNOTDRAW;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'I':
|
|
|
|
m_PinShape |= INVERT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C':
|
|
|
|
m_PinShape |= CLOCK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'L':
|
|
|
|
m_PinShape |= LOWLEVEL_IN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'V':
|
|
|
|
m_PinShape |= LOWLEVEL_OUT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
errorMsg.Printf( wxT( "unknown pin attribute [%c]" ),
|
|
|
|
pinAttrs[j] );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-30 17:57:27 +00:00
|
|
|
/** Function GetPenSize
|
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
2009-09-04 18:57:37 +00:00
|
|
|
int LibDrawPin::GetPenSize()
|
2009-06-30 17:57:27 +00:00
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
return ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
|
2009-06-30 17:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
|
|
|
|
wxDC* aDC,
|
|
|
|
const wxPoint& aOffset,
|
|
|
|
int aColor,
|
|
|
|
int aDrawMode,
|
|
|
|
void* aData,
|
|
|
|
const int aTransformMatrix[2][2] )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2009-09-02 18:12:45 +00:00
|
|
|
// Invisible pins are only drawn on request. In libedit they are drawn
|
|
|
|
// in g_InvisibleItemColor because we must see them.
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_SchematicFrame* frame =
|
|
|
|
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
|
|
|
|
|
2008-09-19 08:19:15 +00:00
|
|
|
if( ( m_Attributs & PINNOTDRAW ) )
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
if( frame->m_LibeditFrame && frame->m_LibeditFrame->IsActive() )
|
2008-09-19 08:19:15 +00:00
|
|
|
aColor = g_InvisibleItemColor;
|
2009-04-29 17:09:00 +00:00
|
|
|
else if( !frame->m_ShowAllPins )
|
2008-09-19 08:19:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
EDA_LibComponentStruct* Entry = GetParent();
|
|
|
|
bool DrawPinText = true;
|
|
|
|
|
|
|
|
if( ( aData != NULL ) && ( (bool*) aData == false ) )
|
|
|
|
DrawPinText = false;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
/* Calculate pin orient taking in account the component orientation. */
|
2009-09-04 18:57:37 +00:00
|
|
|
int orient = ReturnPinDrawOrient( aTransformMatrix );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
/* Calculate the pin position */
|
|
|
|
wxPoint pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
|
|
|
|
|
|
|
|
/* Dessin de la pin et du symbole special associe */
|
|
|
|
DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor );
|
|
|
|
|
|
|
|
if( DrawPinText )
|
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
DrawPinTexts( aPanel, aDC, pos1, orient, Entry->m_TextInside,
|
2008-12-08 15:27:13 +00:00
|
|
|
Entry->m_DrawPinNum, Entry->m_DrawPinName,
|
|
|
|
aColor, aDrawMode );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/** Function DrawPinSymbol
|
|
|
|
* Draw the pin symbol (without texts)
|
2008-09-13 18:59:57 +00:00
|
|
|
* if Color != 0 draw with Color, else with the normal pin color
|
|
|
|
*/
|
2009-04-06 10:56:17 +00:00
|
|
|
void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel,
|
|
|
|
wxDC* aDC,
|
|
|
|
const wxPoint& aPinPos,
|
|
|
|
int aOrient,
|
|
|
|
int aDrawMode,
|
|
|
|
int aColor )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
int MapX1, MapY1, x1, y1;
|
|
|
|
int color;
|
2009-06-30 17:57:27 +00:00
|
|
|
int width = GetPenSize( );
|
2009-04-06 10:56:17 +00:00
|
|
|
int posX = aPinPos.x, posY = aPinPos.y, len = m_PinLen;
|
2009-04-05 20:49:15 +00:00
|
|
|
BASE_SCREEN* screen = aPanel->GetScreen();
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
color = ReturnLayerColor( LAYER_PIN );
|
|
|
|
if( aColor < 0 ) // Used normal color or selected color
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
if( (m_Selected & IS_SELECTED) )
|
2008-09-13 18:59:57 +00:00
|
|
|
color = g_ItemSelectetColor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
color = aColor;
|
|
|
|
|
|
|
|
GRSetDrawMode( aDC, aDrawMode );
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
MapX1 = MapY1 = 0; x1 = posX; y1 = posY;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
switch( aOrient )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
2009-04-06 10:56:17 +00:00
|
|
|
y1 = posY - len; MapY1 = 1;
|
2008-09-13 18:59:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_DOWN:
|
2009-04-06 10:56:17 +00:00
|
|
|
y1 = posY + len; MapY1 = -1;
|
2008-09-13 18:59:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_LEFT:
|
2009-04-06 10:56:17 +00:00
|
|
|
x1 = posX - len, MapX1 = 1;
|
2008-09-13 18:59:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_RIGHT:
|
2009-04-06 10:56:17 +00:00
|
|
|
x1 = posX + len; MapX1 = -1;
|
2008-09-13 18:59:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_PinShape & INVERT )
|
|
|
|
{
|
|
|
|
GRCircle( &aPanel->m_ClipBox, aDC, MapX1 * INVERT_PIN_RADIUS + x1,
|
2009-04-06 10:56:17 +00:00
|
|
|
MapY1 * INVERT_PIN_RADIUS + y1,
|
|
|
|
INVERT_PIN_RADIUS, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
GRMoveTo( MapX1 * INVERT_PIN_RADIUS * 2 + x1,
|
2008-12-08 15:27:13 +00:00
|
|
|
MapY1 * INVERT_PIN_RADIUS * 2 + y1 );
|
2008-09-13 18:59:57 +00:00
|
|
|
GRLineTo( &aPanel->m_ClipBox, aDC, posX, posY, width, color );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GRMoveTo( x1, y1 );
|
|
|
|
GRLineTo( &aPanel->m_ClipBox, aDC, posX, posY, width, color );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_PinShape & CLOCK )
|
|
|
|
{
|
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
|
|
|
GRMoveTo( x1, y1 + CLOCK_PIN_DIM );
|
2009-04-06 10:56:17 +00:00
|
|
|
GRLineTo( &aPanel->m_ClipBox,
|
|
|
|
aDC,
|
|
|
|
x1 - MapX1 * CLOCK_PIN_DIM,
|
|
|
|
y1,
|
|
|
|
width,
|
|
|
|
color );
|
|
|
|
GRLineTo( &aPanel->m_ClipBox,
|
|
|
|
aDC,
|
|
|
|
x1,
|
|
|
|
y1 - CLOCK_PIN_DIM,
|
|
|
|
width,
|
2008-12-08 15:27:13 +00:00
|
|
|
color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
|
|
|
GRMoveTo( x1 + CLOCK_PIN_DIM, y1 );
|
2009-04-06 10:56:17 +00:00
|
|
|
GRLineTo( &aPanel->m_ClipBox,
|
|
|
|
aDC,
|
|
|
|
x1,
|
|
|
|
y1 - MapY1 * CLOCK_PIN_DIM,
|
|
|
|
width,
|
|
|
|
color );
|
|
|
|
GRLineTo( &aPanel->m_ClipBox,
|
|
|
|
aDC,
|
|
|
|
x1 - CLOCK_PIN_DIM,
|
|
|
|
y1,
|
|
|
|
width,
|
2008-12-08 15:27:13 +00:00
|
|
|
color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_PinShape & LOWLEVEL_IN ) /* IEEE symbol "Active Low Input" */
|
|
|
|
{
|
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
|
|
|
GRMoveTo( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 );
|
2009-04-06 10:56:17 +00:00
|
|
|
GRLineTo( &aPanel->m_ClipBox,
|
|
|
|
aDC,
|
2008-12-08 15:27:13 +00:00
|
|
|
x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
|
2009-04-06 10:56:17 +00:00
|
|
|
y1 - IEEE_SYMBOL_PIN_DIM,
|
|
|
|
width,
|
|
|
|
color );
|
2008-09-13 18:59:57 +00:00
|
|
|
GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1, width, color );
|
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
|
|
|
GRMoveTo( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 );
|
|
|
|
GRLineTo( &aPanel->m_ClipBox, aDC, x1 - IEEE_SYMBOL_PIN_DIM,
|
2008-12-08 15:27:13 +00:00
|
|
|
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1, width, color );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( m_PinShape & LOWLEVEL_OUT ) /* IEEE symbol "Active Low Output" */
|
|
|
|
{
|
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
|
|
|
GRMoveTo( x1, y1 - IEEE_SYMBOL_PIN_DIM );
|
2009-04-06 10:56:17 +00:00
|
|
|
GRLineTo( &aPanel->m_ClipBox,
|
|
|
|
aDC,
|
|
|
|
x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
|
|
|
|
y1,
|
|
|
|
width,
|
|
|
|
color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
|
|
|
GRMoveTo( x1 - IEEE_SYMBOL_PIN_DIM, y1 );
|
2009-04-06 10:56:17 +00:00
|
|
|
GRLineTo( &aPanel->m_ClipBox,
|
|
|
|
aDC,
|
|
|
|
x1,
|
|
|
|
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2,
|
|
|
|
width,
|
|
|
|
color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/* Draw the pin end target (active end of the pin)
|
|
|
|
* Draw but do not print the pin end target 1 pixel width
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !screen->m_IsPrinting )
|
2009-04-06 10:56:17 +00:00
|
|
|
GRCircle( &aPanel->m_ClipBox,
|
|
|
|
aDC,
|
|
|
|
posX,
|
|
|
|
posY,
|
|
|
|
TARGET_PIN_DIAM,
|
|
|
|
0,
|
|
|
|
color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Put out pin number and pin text info, given the pin line coordinates.
|
|
|
|
* The line must be vertical or horizontal.
|
|
|
|
* If PinText == NULL nothing is printed. If PinNum = 0 no number is printed.
|
|
|
|
* Current Zoom factor is taken into account.
|
|
|
|
* If TextInside then the text is been put inside,otherwise all is drawn outside.
|
2009-09-02 18:12:45 +00:00
|
|
|
* Pin Name: substring beteween '~' is negated
|
2008-09-13 18:59:57 +00:00
|
|
|
*****************************************************************************/
|
2009-04-06 10:56:17 +00:00
|
|
|
void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
wxPoint& pin_pos,
|
|
|
|
int orient,
|
|
|
|
int TextInside,
|
|
|
|
bool DrawPinNum,
|
|
|
|
bool DrawPinName,
|
|
|
|
int Color,
|
|
|
|
int DrawMode )
|
2008-09-13 18:59:57 +00:00
|
|
|
/* DrawMode = GR_OR, XOR ... */
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
int x, y, x1, y1;
|
|
|
|
wxString StringPinNum;
|
|
|
|
EDA_Colors NameColor, NumColor;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
wxSize PinNameSize( m_PinNameSize, m_PinNameSize );
|
|
|
|
wxSize PinNumSize( m_PinNumSize, m_PinNumSize );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-06-30 17:57:27 +00:00
|
|
|
int nameLineWidth = GetPenSize( );
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2009-06-02 07:26:49 +00:00
|
|
|
nameLineWidth = Clamp_Text_PenSize( nameLineWidth, m_PinNameSize, false );
|
2009-06-30 17:57:27 +00:00
|
|
|
int numLineWidth = GetPenSize( );
|
2009-06-02 07:26:49 +00:00
|
|
|
numLineWidth = Clamp_Text_PenSize( numLineWidth, m_PinNumSize, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
|
|
|
/* Get the num and name colors */
|
|
|
|
if( (Color < 0) && (m_Selected & IS_SELECTED) )
|
|
|
|
Color = g_ItemSelectetColor;
|
2009-05-12 12:12:34 +00:00
|
|
|
NameColor = (EDA_Colors) ( Color == -1 ? ReturnLayerColor( LAYER_PINNAM ) : Color );
|
|
|
|
NumColor = (EDA_Colors) ( Color == -1 ? ReturnLayerColor( LAYER_PINNUM ) : Color );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
/* Create the pin num string */
|
|
|
|
ReturnPinStringNum( StringPinNum );
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
x1 = pin_pos.x; y1 = pin_pos.y;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
switch( orient )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
2009-04-06 10:56:17 +00:00
|
|
|
y1 -= m_PinLen; break;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
case PIN_DOWN:
|
2009-04-06 10:56:17 +00:00
|
|
|
y1 += m_PinLen; break;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
case PIN_LEFT:
|
2009-04-06 10:56:17 +00:00
|
|
|
x1 -= m_PinLen; break;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
case PIN_RIGHT:
|
2009-04-06 10:56:17 +00:00
|
|
|
x1 += m_PinLen; break;
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
2009-05-29 07:29:55 +00:00
|
|
|
if( m_PinName.IsEmpty() )
|
2008-09-13 18:59:57 +00:00
|
|
|
DrawPinName = FALSE;
|
|
|
|
|
|
|
|
if( TextInside ) /* Draw the text inside, but the pin numbers outside. */
|
|
|
|
{
|
|
|
|
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
// It is an horizontal line
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
if( orient == PIN_RIGHT )
|
|
|
|
{
|
|
|
|
x = x1 + TextInside;
|
2009-04-05 20:49:15 +00:00
|
|
|
DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor,
|
2009-04-06 10:56:17 +00:00
|
|
|
m_PinName,
|
|
|
|
TEXT_ORIENT_HORIZ,
|
|
|
|
PinNameSize,
|
2008-12-08 15:27:13 +00:00
|
|
|
GR_TEXT_HJUSTIFY_LEFT,
|
2009-06-02 07:26:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
|
2009-05-28 17:39:40 +00:00
|
|
|
false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
else // Orient == PIN_LEFT
|
|
|
|
{
|
|
|
|
x = x1 - TextInside;
|
2009-04-05 20:49:15 +00:00
|
|
|
DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor,
|
2009-04-06 10:56:17 +00:00
|
|
|
m_PinName,
|
|
|
|
TEXT_ORIENT_HORIZ,
|
|
|
|
PinNameSize,
|
2008-12-08 15:27:13 +00:00
|
|
|
GR_TEXT_HJUSTIFY_RIGHT,
|
2009-06-02 07:26:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
|
2009-05-28 17:39:40 +00:00
|
|
|
false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
DrawGraphicText( panel, DC,
|
|
|
|
wxPoint( (x1 + pin_pos.x) / 2,
|
2009-09-02 18:12:45 +00:00
|
|
|
y1 - TXTMARGE ), NumColor,
|
2009-04-06 10:56:17 +00:00
|
|
|
StringPinNum,
|
|
|
|
TEXT_ORIENT_HORIZ, PinNumSize,
|
2008-12-08 15:27:13 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
2009-06-02 07:26:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
|
|
|
|
false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Its a vertical line. */
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
// Text is drawn from bottom to top (i.e. to negative value for Y axis)
|
2009-05-12 12:12:34 +00:00
|
|
|
if( orient == PIN_DOWN )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2009-05-12 12:12:34 +00:00
|
|
|
y = y1 + TextInside;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinName )
|
2009-04-05 20:49:15 +00:00
|
|
|
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor,
|
2009-04-06 10:56:17 +00:00
|
|
|
m_PinName,
|
|
|
|
TEXT_ORIENT_VERT, PinNameSize,
|
2009-05-12 12:12:34 +00:00
|
|
|
GR_TEXT_HJUSTIFY_RIGHT,
|
2009-06-02 07:26:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
|
2009-05-28 17:39:40 +00:00
|
|
|
false, false );
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinNum )
|
|
|
|
DrawGraphicText( panel, DC,
|
|
|
|
wxPoint( x1 - TXTMARGE,
|
|
|
|
(y1 + pin_pos.y) / 2 ), NumColor,
|
|
|
|
StringPinNum,
|
|
|
|
TEXT_ORIENT_VERT, PinNumSize,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
2009-06-02 07:26:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
|
2009-06-13 17:06:07 +00:00
|
|
|
false, false );
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
|
|
|
else /* PIN_UP */
|
|
|
|
{
|
|
|
|
y = y1 - TextInside;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinName )
|
2009-04-05 20:49:15 +00:00
|
|
|
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor,
|
2009-04-06 10:56:17 +00:00
|
|
|
m_PinName,
|
|
|
|
TEXT_ORIENT_VERT, PinNameSize,
|
2009-05-12 12:12:34 +00:00
|
|
|
GR_TEXT_HJUSTIFY_LEFT,
|
2009-06-02 07:26:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_CENTER, nameLineWidth,
|
2009-05-28 17:39:40 +00:00
|
|
|
false, false );
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinNum )
|
|
|
|
DrawGraphicText( panel, DC,
|
|
|
|
wxPoint( x1 - TXTMARGE,
|
|
|
|
(y1 + pin_pos.y) / 2 ), NumColor,
|
|
|
|
StringPinNum,
|
|
|
|
TEXT_ORIENT_VERT, PinNumSize,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
2009-06-02 07:26:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
|
2009-06-13 17:06:07 +00:00
|
|
|
false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /**** Draw num & text pin outside ****/
|
|
|
|
{
|
|
|
|
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
/* Its an horizontal line. */
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
x = (x1 + pin_pos.x) / 2;
|
2009-09-02 18:12:45 +00:00
|
|
|
DrawGraphicText( panel, DC, wxPoint( x, y1 - TXTMARGE ),
|
2009-04-06 10:56:17 +00:00
|
|
|
NameColor, m_PinName,
|
|
|
|
TEXT_ORIENT_HORIZ, PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
2009-06-02 07:26:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth,
|
2009-05-28 17:39:40 +00:00
|
|
|
false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
|
|
|
x = (x1 + pin_pos.x) / 2;
|
2009-09-02 18:12:45 +00:00
|
|
|
DrawGraphicText( panel, DC, wxPoint( x, y1 + TXTMARGE ),
|
2009-04-06 10:56:17 +00:00
|
|
|
NumColor, StringPinNum,
|
|
|
|
TEXT_ORIENT_HORIZ, PinNumSize,
|
2009-05-12 12:12:34 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
2009-06-02 07:26:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_TOP, numLineWidth,
|
2009-06-13 17:06:07 +00:00
|
|
|
false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Its a vertical line. */
|
|
|
|
{
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
y = (y1 + pin_pos.y) / 2;
|
2009-09-02 18:12:45 +00:00
|
|
|
DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, y ),
|
2009-04-06 10:56:17 +00:00
|
|
|
NameColor, m_PinName,
|
|
|
|
TEXT_ORIENT_VERT, PinNameSize,
|
2009-05-12 12:12:34 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
2009-06-02 07:26:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth,
|
|
|
|
false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawGraphicText( panel, DC,
|
2009-09-02 18:12:45 +00:00
|
|
|
wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
|
2009-04-06 10:56:17 +00:00
|
|
|
NumColor, StringPinNum,
|
|
|
|
TEXT_ORIENT_VERT, PinNumSize,
|
2009-05-12 12:12:34 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
2009-06-02 07:26:49 +00:00
|
|
|
GR_TEXT_VJUSTIFY_TOP, numLineWidth,
|
|
|
|
false, false );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2008-09-13 19:06:31 +00:00
|
|
|
/*****************************************************************************
|
2009-09-02 18:12:45 +00:00
|
|
|
* Plot pin number and pin text info, given the pin line coordinates. *
|
2008-09-13 19:06:31 +00:00
|
|
|
* Same as DrawPinTexts((), but output is the plotter
|
2009-09-02 18:12:45 +00:00
|
|
|
* The line must be vertical or horizontal. *
|
|
|
|
* If PinNext == NULL nothing is printed. *
|
|
|
|
* Current Zoom factor is taken into account. *
|
|
|
|
* If TextInside then the text is been put inside (moving from x1, y1 in *
|
|
|
|
* the opposite direction to x2,y2), otherwise all is drawn outside. *
|
2008-09-13 19:06:31 +00:00
|
|
|
*****************************************************************************/
|
2009-08-29 10:20:48 +00:00
|
|
|
void LibDrawPin::PlotPinTexts( PLOTTER *plotter,
|
2009-09-02 18:12:45 +00:00
|
|
|
wxPoint& pin_pos,
|
2009-06-13 17:06:07 +00:00
|
|
|
int orient,
|
|
|
|
int TextInside,
|
|
|
|
bool DrawPinNum,
|
|
|
|
bool DrawPinName,
|
|
|
|
int aWidth )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
int x, y, x1, y1;
|
|
|
|
wxString StringPinNum;
|
|
|
|
EDA_Colors NameColor, NumColor;
|
|
|
|
wxSize PinNameSize = wxSize( m_PinNameSize, m_PinNameSize );
|
|
|
|
wxSize PinNumSize = wxSize( m_PinNumSize, m_PinNumSize );
|
2008-09-13 19:06:31 +00:00
|
|
|
|
|
|
|
/* Get the num and name colors */
|
2009-06-28 16:50:42 +00:00
|
|
|
NameColor = ReturnLayerColor( LAYER_PINNAM );
|
|
|
|
NumColor = ReturnLayerColor( LAYER_PINNUM );
|
2008-09-13 19:06:31 +00:00
|
|
|
|
|
|
|
/* Create the pin num string */
|
|
|
|
ReturnPinStringNum( StringPinNum );
|
2009-04-06 10:56:17 +00:00
|
|
|
x1 = pin_pos.x; y1 = pin_pos.y;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
|
|
|
switch( orient )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
2009-04-06 10:56:17 +00:00
|
|
|
y1 -= m_PinLen; break;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
|
|
|
case PIN_DOWN:
|
2009-04-06 10:56:17 +00:00
|
|
|
y1 += m_PinLen; break;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
|
|
|
case PIN_LEFT:
|
2009-04-06 10:56:17 +00:00
|
|
|
x1 -= m_PinLen; break;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
|
|
|
case PIN_RIGHT:
|
2009-04-06 10:56:17 +00:00
|
|
|
x1 += m_PinLen; break;
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
|
2009-05-29 07:29:55 +00:00
|
|
|
if( m_PinName.IsEmpty() )
|
2008-09-13 19:06:31 +00:00
|
|
|
DrawPinName = FALSE;
|
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( TextInside ) /* Draw the text inside, but the pin numbers outside. */
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) /* Its an horizontal line. */
|
|
|
|
{
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
|
|
|
if( orient == PIN_RIGHT )
|
|
|
|
{
|
|
|
|
x = x1 + TextInside;
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x, y1 ), NameColor,
|
2009-09-02 18:12:45 +00:00
|
|
|
m_PinName,
|
|
|
|
TEXT_ORIENT_HORIZ,
|
|
|
|
PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_LEFT,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
else // orient == PIN_LEFT
|
|
|
|
{
|
|
|
|
x = x1 - TextInside;
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinName )
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x, y1 ),
|
2009-09-02 18:12:45 +00:00
|
|
|
NameColor, m_PinName, TEXT_ORIENT_HORIZ,
|
|
|
|
PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_RIGHT,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
aWidth, false, false );
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2009-09-02 18:12:45 +00:00
|
|
|
plotter->text( wxPoint( (x1 + pin_pos.x) / 2,
|
|
|
|
y1 - TXTMARGE ),
|
|
|
|
NumColor, StringPinNum,
|
|
|
|
TEXT_ORIENT_HORIZ, PinNumSize,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Its a vertical line. */
|
|
|
|
{
|
2009-05-12 12:12:34 +00:00
|
|
|
if( orient == PIN_DOWN )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2009-05-12 12:12:34 +00:00
|
|
|
y = y1 + TextInside;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinName )
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x1, y ), NameColor,
|
2009-09-02 18:12:45 +00:00
|
|
|
m_PinName,
|
|
|
|
TEXT_ORIENT_VERT, PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_RIGHT,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
aWidth, false, false );
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinNum )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x1 - TXTMARGE,
|
2009-09-02 18:12:45 +00:00
|
|
|
(y1 + pin_pos.y) / 2 ),
|
|
|
|
NumColor, StringPinNum,
|
|
|
|
TEXT_ORIENT_VERT, PinNumSize,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
aWidth, false, false );
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* PIN_UP */
|
|
|
|
{
|
|
|
|
y = y1 - TextInside;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinName )
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x1, y ), NameColor,
|
2009-09-02 18:12:45 +00:00
|
|
|
m_PinName,
|
|
|
|
TEXT_ORIENT_VERT, PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_LEFT,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
aWidth, false, false );
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x1 - TXTMARGE,
|
2009-09-02 18:12:45 +00:00
|
|
|
(y1 + pin_pos.y) / 2 ),
|
|
|
|
NumColor, StringPinNum,
|
|
|
|
TEXT_ORIENT_VERT, PinNumSize,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Draw num & text pin outside */
|
|
|
|
{
|
|
|
|
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
/* Its an horizontal line. */
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
|
|
|
x = (x1 + pin_pos.x) / 2;
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x, y1 - TXTMARGE ),
|
2009-09-02 18:12:45 +00:00
|
|
|
NameColor, m_PinName,
|
|
|
|
TEXT_ORIENT_HORIZ, PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2009-04-06 10:56:17 +00:00
|
|
|
x = (x1 + pin_pos.x) / 2;
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x, y1 + TXTMARGE ),
|
2009-09-02 18:12:45 +00:00
|
|
|
NumColor, StringPinNum,
|
|
|
|
TEXT_ORIENT_HORIZ, PinNumSize,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_TOP,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Its a vertical line. */
|
|
|
|
{
|
2009-04-13 05:58:11 +00:00
|
|
|
if( DrawPinName )
|
2008-09-13 19:06:31 +00:00
|
|
|
{
|
|
|
|
y = (y1 + pin_pos.y) / 2;
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x1 - TXTMARGE, y ),
|
2009-09-02 18:12:45 +00:00
|
|
|
NameColor, m_PinName,
|
|
|
|
TEXT_ORIENT_VERT, PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
|
2009-09-02 18:12:45 +00:00
|
|
|
NumColor, StringPinNum,
|
|
|
|
TEXT_ORIENT_VERT, PinNumSize,
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_TOP,
|
|
|
|
aWidth, false, false );
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/******************************************/
|
|
|
|
wxPoint LibDrawPin::ReturnPinEndPoint()
|
|
|
|
/******************************************/
|
|
|
|
|
2008-09-14 04:27:22 +00:00
|
|
|
/* return the pin end position, for a component in normal orient
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
wxPoint pos = m_Pos;
|
|
|
|
|
|
|
|
switch( m_Orient )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
2009-04-06 10:56:17 +00:00
|
|
|
pos.y += m_PinLen; break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_DOWN:
|
2009-04-06 10:56:17 +00:00
|
|
|
pos.y -= m_PinLen; break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_LEFT:
|
2009-04-06 10:56:17 +00:00
|
|
|
pos.x -= m_PinLen; break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_RIGHT:
|
2009-04-06 10:56:17 +00:00
|
|
|
pos.x += m_PinLen; break;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/** Function ReturnPinDrawOrient
|
2008-09-26 19:51:36 +00:00
|
|
|
* Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT),
|
|
|
|
* according to its orientation and the matrix transform (rot, mirror) TransMat
|
|
|
|
* @param TransMat = transform matrix
|
2008-09-14 04:27:22 +00:00
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
int LibDrawPin::ReturnPinDrawOrient( const int TransMat[2][2] )
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
int orient;
|
2009-04-06 10:56:17 +00:00
|
|
|
wxPoint end; // position of a end pin starting at 0,0 according to its orientation, lenght = 1
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
switch( m_Orient )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
2009-04-06 10:56:17 +00:00
|
|
|
end.y = 1; break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_DOWN:
|
2009-04-06 10:56:17 +00:00
|
|
|
end.y = -1; break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_LEFT:
|
2009-04-06 10:56:17 +00:00
|
|
|
end.x = -1; break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_RIGHT:
|
2009-04-06 10:56:17 +00:00
|
|
|
end.x = 1; break;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
end = TransformCoordinate( TransMat, end ); // = pos of end point, according to the component orientation
|
2008-09-14 04:27:22 +00:00
|
|
|
orient = PIN_UP;
|
2008-09-26 19:51:36 +00:00
|
|
|
if( end.x == 0 )
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
if( end.y > 0 )
|
2008-09-14 04:27:22 +00:00
|
|
|
orient = PIN_DOWN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
orient = PIN_RIGHT;
|
2008-09-26 19:51:36 +00:00
|
|
|
if( end.x < 0 )
|
2008-09-14 04:27:22 +00:00
|
|
|
orient = PIN_LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return orient;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/** Function ReturnPinStringNum
|
2009-07-05 12:09:41 +00:00
|
|
|
* fill a buffer with pin num as a wxString
|
|
|
|
* Pin num is coded as a long or 4 ascii chars
|
2008-09-14 04:27:22 +00:00
|
|
|
* Used to print/draw the pin num
|
2009-07-05 12:09:41 +00:00
|
|
|
* @param aStringBuffer = the wxString to store the pin num as an unicode string
|
2008-09-14 04:27:22 +00:00
|
|
|
*/
|
2009-07-05 12:09:41 +00:00
|
|
|
void LibDrawPin::ReturnPinStringNum( wxString& aStringBuffer ) const
|
|
|
|
{
|
|
|
|
aStringBuffer = ReturnPinStringNum( m_PinNum );
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Function ReturnPinStringNum (static function)
|
|
|
|
* Pin num is coded as a long or 4 ascii chars
|
|
|
|
* @param aPinNum = a long containing a pin num
|
|
|
|
* @return aStringBuffer = the wxString to store the pin num as an unicode string
|
|
|
|
*/
|
|
|
|
wxString LibDrawPin::ReturnPinStringNum( long aPinNum )
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
|
|
|
char ascii_buf[5];
|
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
memcpy( ascii_buf, &aPinNum, 4 );
|
2008-09-14 04:27:22 +00:00
|
|
|
ascii_buf[4] = 0;
|
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
wxString buffer = CONV_FROM_UTF8( ascii_buf );
|
|
|
|
|
|
|
|
return buffer;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/** Function LibDrawPin::SetPinNumFromString()
|
2009-04-05 20:49:15 +00:00
|
|
|
* fill the buffer with pin num as a wxString
|
2008-09-14 04:27:22 +00:00
|
|
|
* Pin num is coded as a long
|
|
|
|
* Used to print/draw the pin num
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
void LibDrawPin::SetPinNumFromString( wxString& buffer )
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
|
|
|
char ascii_buf[4];
|
|
|
|
unsigned ii, len = buffer.Len();
|
|
|
|
|
|
|
|
ascii_buf[0] = ascii_buf[1] = ascii_buf[2] = ascii_buf[3] = 0;
|
|
|
|
if( len > 4 )
|
|
|
|
len = 4;
|
|
|
|
for( ii = 0; ii < len; ii++ )
|
|
|
|
{
|
2009-05-12 12:12:34 +00:00
|
|
|
ascii_buf[ii] = buffer.GetChar( ii );
|
2009-04-13 05:58:11 +00:00
|
|
|
ascii_buf[ii] &= 0xFF;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
strncpy( (char*) &m_PinNum, ascii_buf, 4 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/*************************************/
|
2009-09-02 18:12:45 +00:00
|
|
|
LibEDA_BaseStruct* LibDrawPin::DoGenCopy()
|
2009-04-06 10:56:17 +00:00
|
|
|
/*************************************/
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
LibDrawPin* newpin = new LibDrawPin( GetParent() );
|
2008-09-14 04:27:22 +00:00
|
|
|
|
2009-06-13 17:06:07 +00:00
|
|
|
newpin->m_Pos = m_Pos;
|
|
|
|
newpin->m_PinLen = m_PinLen;
|
|
|
|
newpin->m_Orient = m_Orient;
|
|
|
|
newpin->m_PinShape = m_PinShape;
|
|
|
|
newpin->m_PinType = m_PinType;
|
|
|
|
newpin->m_Attributs = m_Attributs;
|
|
|
|
newpin->m_PinNum = m_PinNum;
|
|
|
|
newpin->m_PinNumSize = m_PinNumSize;
|
|
|
|
newpin->m_PinNameSize = m_PinNameSize;
|
|
|
|
newpin->m_PinNumShapeOpt = m_PinNumShapeOpt;
|
|
|
|
newpin->m_PinNameShapeOpt = m_PinNameShapeOpt;
|
|
|
|
newpin->m_PinNumPositionOpt = m_PinNumPositionOpt;
|
|
|
|
newpin->m_PinNamePositionOpt = m_PinNamePositionOpt;
|
|
|
|
newpin->m_Unit = m_Unit;
|
|
|
|
newpin->m_Convert = m_Convert;
|
|
|
|
newpin->m_Flags = m_Flags;
|
|
|
|
newpin->m_Width = m_Width;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
newpin->m_PinName = m_PinName;
|
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
return (LibEDA_BaseStruct*) newpin;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/** Function LibDrawPin::DisplayInfo
|
2009-09-04 18:57:37 +00:00
|
|
|
* Displays info (pin num and name, orientation ...
|
2009-04-06 10:56:17 +00:00
|
|
|
* on the Info window
|
2009-04-05 20:49:15 +00:00
|
|
|
*/
|
|
|
|
void LibDrawPin::DisplayInfo( WinEDA_DrawFrame* frame )
|
|
|
|
{
|
|
|
|
wxString Text;
|
|
|
|
int ii;
|
|
|
|
|
|
|
|
LibEDA_BaseStruct::DisplayInfo( frame );
|
|
|
|
|
|
|
|
/* Affichage du nom */
|
|
|
|
frame->MsgPanel->Affiche_1_Parametre( 30, _( "PinName" ), m_PinName,
|
|
|
|
DARKCYAN );
|
|
|
|
|
|
|
|
/* Affichage du numero */
|
|
|
|
if( m_PinNum == 0 )
|
|
|
|
Text = wxT( "?" );
|
|
|
|
else
|
|
|
|
ReturnPinStringNum( Text );
|
|
|
|
|
|
|
|
frame->MsgPanel->Affiche_1_Parametre( 38, _( "PinNum" ), Text, DARKCYAN );
|
|
|
|
|
|
|
|
/* Affichage du type */
|
|
|
|
ii = m_PinType;
|
|
|
|
frame->MsgPanel->Affiche_1_Parametre( 44, _( "PinType" ),
|
|
|
|
MsgPinElectricType[ii], RED );
|
|
|
|
|
|
|
|
/* Affichage de la visiblite */
|
|
|
|
ii = m_Attributs;
|
|
|
|
if( ii & 1 )
|
|
|
|
Text = _( "no" );
|
|
|
|
else
|
|
|
|
Text = _( "yes" );
|
|
|
|
frame->MsgPanel->Affiche_1_Parametre( 50, _( "Display" ), Text, DARKGREEN );
|
|
|
|
|
|
|
|
/* Display pin length */
|
|
|
|
Text = ReturnStringFromValue( g_UnitMetric, m_PinLen,
|
|
|
|
EESCHEMA_INTERNAL_UNIT, true );
|
|
|
|
frame->MsgPanel->Affiche_1_Parametre( 56, _( "Length" ), Text, MAGENTA );
|
|
|
|
|
|
|
|
/* Affichage de l'orientation */
|
|
|
|
switch( m_Orient )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
|
|
|
Text = _( "Up" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_DOWN:
|
|
|
|
Text = _( "Down" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_LEFT:
|
|
|
|
Text = _( "Left" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_RIGHT:
|
|
|
|
Text = _( "Right" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Text = wxT( "??" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
frame->MsgPanel->Affiche_1_Parametre( 62, _( "Orient" ), Text, MAGENTA );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/** Function LibDrawPin::GetBoundingBox
|
|
|
|
* @return the boundary box for this, in schematic coordinates
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
EDA_Rect LibDrawPin::GetBoundingBox()
|
|
|
|
{
|
|
|
|
wxPoint pt = m_Pos;
|
2009-04-06 10:56:17 +00:00
|
|
|
|
|
|
|
pt.y *= -1; // Reverse the Y axis, according to the schematic orientation
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
return EDA_Rect( pt, wxSize( 1, 1 ) );
|
|
|
|
}
|