2010-10-22 12:11:52 +00:00
|
|
|
/***************/
|
|
|
|
/* lib_pin.cpp */
|
|
|
|
/***************/
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
#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"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "macros.h"
|
2009-06-13 17:06:07 +00:00
|
|
|
#include "trigo.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "drawtxt.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "plot_common.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
2011-03-25 19:16:05 +00:00
|
|
|
#include "bitmaps.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "libeditframe.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"
|
2010-10-20 20:24:26 +00:00
|
|
|
#include "transform.h"
|
2011-03-25 19:16:05 +00:00
|
|
|
#include "sch_component.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* Note: The following name lists are sentence capitalized per the GNOME UI
|
|
|
|
* standards for list controls. Please do not change the capitalization
|
|
|
|
* of these strings unless the GNOME UI standards are changed.
|
|
|
|
*/
|
|
|
|
static const wxString pin_orientation_names[] =
|
|
|
|
{
|
|
|
|
_( "Right" ),
|
|
|
|
_( "Left" ),
|
|
|
|
_( "Up" ),
|
|
|
|
_( "Down" )
|
|
|
|
};
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2010-03-04 09:32:51 +00:00
|
|
|
// bitmaps to show pins orientations in dialog editor
|
|
|
|
// must have same order than pin_orientation_names
|
2011-04-18 20:22:17 +00:00
|
|
|
static const char** s_icons_Pins_Orientations[] =
|
2010-03-04 09:32:51 +00:00
|
|
|
{
|
|
|
|
pinorient_right_xpm,
|
|
|
|
pinorient_left_xpm,
|
|
|
|
pinorient_up_xpm,
|
|
|
|
pinorient_down_xpm,
|
|
|
|
};
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
static const int pin_orientation_codes[] =
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
|
|
|
PIN_RIGHT,
|
|
|
|
PIN_LEFT,
|
|
|
|
PIN_UP,
|
|
|
|
PIN_DOWN
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
#define PIN_ORIENTATION_CNT ( sizeof( pin_orientation_names ) / \
|
|
|
|
sizeof( wxString ) )
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
static const wxString pin_style_names[] =
|
|
|
|
{
|
|
|
|
_( "Line" ),
|
|
|
|
_( "Inverted" ),
|
|
|
|
_( "Clock" ),
|
|
|
|
_( "Inverted clock" ),
|
|
|
|
_( "Input low" ),
|
|
|
|
_( "Clock low" ),
|
2010-09-24 16:00:40 +00:00
|
|
|
_( "Output low" ),
|
|
|
|
_( "Falling edge clock" ),
|
|
|
|
_( "NonLogic" )
|
2009-10-30 19:26:25 +00:00
|
|
|
};
|
|
|
|
|
2010-03-04 09:32:51 +00:00
|
|
|
// bitmaps to show pins shapes in dialog editor
|
|
|
|
// must have same order than pin_style_names
|
2011-04-18 20:22:17 +00:00
|
|
|
static const char** s_icons_Pins_Shapes[] =
|
2010-03-04 09:32:51 +00:00
|
|
|
{
|
|
|
|
pinshape_normal_xpm,
|
|
|
|
pinshape_invert_xpm,
|
|
|
|
pinshape_clock_normal_xpm,
|
|
|
|
pinshape_clock_invert_xpm,
|
|
|
|
pinshape_active_low_input_xpm,
|
|
|
|
pinshape_clock_active_low_xpm,
|
|
|
|
pinshape_active_low_output_xpm,
|
2010-09-24 16:00:40 +00:00
|
|
|
pinshape_clock_fall_xpm,
|
|
|
|
pinshape_nonlogic_xpm
|
2010-03-04 09:32:51 +00:00
|
|
|
};
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
#define PIN_STYLE_CNT ( sizeof( pin_style_names ) / sizeof( wxString ) )
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
static const int pin_style_codes[] =
|
|
|
|
{
|
|
|
|
NONE,
|
|
|
|
INVERT,
|
|
|
|
CLOCK,
|
|
|
|
CLOCK | INVERT,
|
|
|
|
LOWLEVEL_IN,
|
|
|
|
LOWLEVEL_IN | CLOCK,
|
2010-09-24 16:00:40 +00:00
|
|
|
LOWLEVEL_OUT,
|
|
|
|
CLOCK_FALL,
|
|
|
|
NONLOGIC
|
2009-10-30 19:26:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static const wxString pin_electrical_type_names[] =
|
|
|
|
{
|
|
|
|
_( "Input" ),
|
|
|
|
_( "Output" ),
|
|
|
|
_( "Bidirectional" ),
|
|
|
|
_( "Tri-state" ),
|
|
|
|
_( "Passive" ),
|
|
|
|
_( "Unspecified" ),
|
|
|
|
_( "Power input" ),
|
|
|
|
_( "Power output" ),
|
|
|
|
_( "Open collector" ),
|
|
|
|
_( "Open emitter" ),
|
|
|
|
_( "Not connected" )
|
|
|
|
};
|
|
|
|
|
2010-03-04 09:32:51 +00:00
|
|
|
// bitmaps to show pins electrical type in dialog editor
|
|
|
|
// must have same order than pin_electrical_type_names
|
2011-04-18 20:22:17 +00:00
|
|
|
static const char** s_icons_Pins_Electrical_Type[] =
|
2010-03-04 09:32:51 +00:00
|
|
|
{
|
|
|
|
pintype_input_xpm,
|
|
|
|
pintype_output_xpm,
|
|
|
|
pintype_bidi_xpm,
|
|
|
|
pintype_3states_xpm,
|
|
|
|
pintype_passive_xpm,
|
|
|
|
pintype_notspecif_xpm,
|
|
|
|
pintype_powerinput_xpm,
|
|
|
|
pintype_poweroutput_xpm,
|
|
|
|
pintype_opencoll_xpm,
|
|
|
|
pintype_openemit_xpm,
|
|
|
|
pintype_noconnect_xpm
|
|
|
|
};
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
|
|
|
|
#define PIN_ELECTRICAL_TYPE_CNT ( sizeof( pin_electrical_type_names ) / sizeof( wxString ) )
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
|
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" ),
|
2010-10-22 07:52:55 +00:00
|
|
|
wxT( "NotConnected" ),
|
2009-06-13 17:06:07 +00:00
|
|
|
wxT( "?????" )
|
|
|
|
};
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) :
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM( LIB_PIN_T, aParent )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-04-18 20:22:17 +00:00
|
|
|
m_length = 300; /* default Pin len */
|
|
|
|
m_orientation = PIN_RIGHT; /* Pin orient: Up, Down, Left, Right */
|
|
|
|
m_shape = NONE; /* Pin shape, bitwise. */
|
|
|
|
m_type = PIN_UNSPECIFIED; /* electrical type of pin */
|
|
|
|
m_attributes = 0; /* bit 0 != 0: pin invisible */
|
|
|
|
m_number = 0; /* pin number ( i.e. 4 codes ASCII ) */
|
|
|
|
m_PinNumSize = 50;
|
|
|
|
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
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PIN::LIB_PIN( const LIB_PIN& pin ) : LIB_ITEM( pin )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-04-18 20:22:17 +00:00
|
|
|
m_position = pin.m_position;
|
|
|
|
m_length = pin.m_length;
|
|
|
|
m_orientation = pin.m_orientation;
|
|
|
|
m_shape = pin.m_shape;
|
|
|
|
m_type = pin.m_type;
|
2010-12-07 16:10:42 +00:00
|
|
|
m_attributes = pin.m_attributes;
|
|
|
|
m_number = pin.m_number;
|
2009-09-25 18:49:04 +00:00
|
|
|
m_PinNumSize = pin.m_PinNumSize;
|
|
|
|
m_PinNameSize = pin.m_PinNameSize;
|
|
|
|
m_PinNumShapeOpt = pin.m_PinNumShapeOpt;
|
|
|
|
m_PinNameShapeOpt = pin.m_PinNameShapeOpt;
|
|
|
|
m_PinNumPositionOpt = pin.m_PinNumPositionOpt;
|
|
|
|
m_PinNamePositionOpt = pin.m_PinNamePositionOpt;
|
2011-04-18 20:22:17 +00:00
|
|
|
m_width = pin.m_width;
|
|
|
|
m_name = pin.m_name;
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
void LIB_PIN::SetName( const wxString& aName )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
wxString tmp = ( aName.IsEmpty() ) ? wxT( "~" ) : aName;
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
tmp.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_name != tmp )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name = tmp;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_name == m_name )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
pinList[i]->m_name = m_name;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_PIN::SetNameTextSize( int size )
|
|
|
|
{
|
|
|
|
if( size != m_PinNameSize )
|
|
|
|
{
|
|
|
|
m_PinNameSize = size;
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_PinNameSize == size )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
pinList[i]->m_PinNameSize = size;
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_PIN::SetNumber( const wxString& number )
|
|
|
|
{
|
|
|
|
wxString tmp = ( number.IsEmpty() ) ? wxT( "~" ) : number;
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
tmp.Replace( wxT( " " ), wxT( "_" ) );
|
2011-04-18 20:22:17 +00:00
|
|
|
long oldNumber = m_number;
|
2009-10-30 19:26:25 +00:00
|
|
|
SetPinNumFromString( tmp );
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_number != oldNumber )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
|
|
|
m_Flags |= IS_CHANGED;
|
|
|
|
}
|
2010-03-04 09:32:51 +00:00
|
|
|
|
2010-02-25 19:45:34 +00:00
|
|
|
/* Others pin numbers marked by EnableEditMode() are not modified
|
|
|
|
* because each pin has its own number
|
|
|
|
*/
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_PIN::SetNumberTextSize( int size )
|
|
|
|
{
|
|
|
|
if( size != m_PinNumSize )
|
|
|
|
{
|
|
|
|
m_PinNumSize = size;
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_PinNumSize == size )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
pinList[i]->m_PinNumSize = size;
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_PIN::SetOrientation( int orientation )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_orientation != orientation )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_orientation = orientation;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_orientation == orientation )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
pinList[i]->m_orientation = orientation;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
void LIB_PIN::SetShape( int aShape )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_shape != aShape )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_shape = aShape;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2011-02-16 10:14:02 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0
|
2011-04-18 20:22:17 +00:00
|
|
|
|| pinList[i]->m_Convert != m_Convert
|
|
|
|
|| pinList[i]->m_shape == aShape )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
pinList[i]->m_shape = aShape;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
void LIB_PIN::SetType( int aType )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_type != aType )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = aType;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_type == aType )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
pinList[i]->m_type = aType;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_PIN::SetLength( int length )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_length != length )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_length = length;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0
|
2011-04-18 20:22:17 +00:00
|
|
|
|| pinList[i]->m_Convert != m_Convert
|
|
|
|
|| pinList[i]->m_length == length )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
pinList[i]->m_length = length;
|
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_PIN::SetPartNumber( int part )
|
|
|
|
{
|
|
|
|
if( m_Unit == part )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_Unit = part;
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
if( m_Unit == 0 )
|
|
|
|
{
|
|
|
|
LIB_PIN* pin;
|
|
|
|
LIB_PIN* tmp = GetParent()->GetNextPin();
|
|
|
|
|
|
|
|
while( tmp != NULL )
|
|
|
|
{
|
|
|
|
pin = tmp;
|
|
|
|
tmp = GetParent()->GetNextPin( pin );
|
|
|
|
|
|
|
|
if( pin->m_Flags == 0 || pin == this
|
2011-04-18 20:22:17 +00:00
|
|
|
|| ( m_Convert && ( m_Convert != pin->m_Convert ) )
|
|
|
|
|| ( m_position != pin->m_position )
|
|
|
|
|| ( pin->m_orientation != m_orientation ) )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
GetParent()->RemoveDrawItem( (LIB_ITEM*) pin );
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_PIN::SetConversion( int style )
|
|
|
|
{
|
|
|
|
if( m_Convert == style )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_Convert = style;
|
2011-04-18 20:22:17 +00:00
|
|
|
m_Flags |= IS_CHANGED;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
if( style == 0 )
|
|
|
|
{
|
|
|
|
LIB_PIN* pin;
|
|
|
|
LIB_PIN* tmp = GetParent()->GetNextPin();
|
|
|
|
|
|
|
|
while( tmp != NULL )
|
|
|
|
{
|
|
|
|
pin = tmp;
|
|
|
|
tmp = GetParent()->GetNextPin( pin );
|
|
|
|
|
|
|
|
if( ( pin->m_Flags & IS_LINKED ) == 0
|
2011-04-18 20:22:17 +00:00
|
|
|
|| ( pin == this )
|
|
|
|
|| ( m_Unit && ( m_Unit != pin->m_Unit ) )
|
|
|
|
|| ( m_position != pin->m_position )
|
|
|
|
|| ( pin->m_orientation != m_orientation ) )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
GetParent()->RemoveDrawItem( (LIB_ITEM*) pin );
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_PIN::SetVisible( bool visible )
|
|
|
|
{
|
|
|
|
if( visible == IsVisible() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( visible )
|
2011-05-06 13:56:26 +00:00
|
|
|
m_attributes &= ~PIN_INVISIBLE;
|
2009-10-30 19:26:25 +00:00
|
|
|
else
|
2011-05-06 13:56:26 +00:00
|
|
|
m_attributes |= PIN_INVISIBLE;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->IsVisible() == visible )
|
2009-10-30 19:26:25 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if( visible )
|
2011-05-06 13:56:26 +00:00
|
|
|
pinList[i]->m_attributes &= ~PIN_INVISIBLE;
|
2009-10-30 19:26:25 +00:00
|
|
|
else
|
2011-05-06 13:56:26 +00:00
|
|
|
pinList[i]->m_attributes |= PIN_INVISIBLE;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
SetModified();
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin )
|
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
if( GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
GetParent()->GetPins( pinList );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
|
|
|
if( pinList[i] == this )
|
|
|
|
continue;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( ( pinList[i]->m_position == m_position )
|
2011-04-18 20:22:17 +00:00
|
|
|
&& ( pinList[i]->m_orientation == m_orientation )
|
|
|
|
&& !IsNew()
|
|
|
|
&& editPinByPin == false
|
|
|
|
&& enable )
|
2009-10-30 19:26:25 +00:00
|
|
|
pinList[i]->m_Flags |= IS_LINKED | IN_EDIT;
|
|
|
|
else
|
|
|
|
pinList[i]->m_Flags &= ~( IS_LINKED | IN_EDIT );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
bool LIB_PIN::HitTest( const wxPoint& aPosition )
|
2009-06-13 17:06:07 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
return HitTest( aPosition, 0, DefaultTransform );
|
2009-06-13 17:06:07 +00:00
|
|
|
}
|
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
bool LIB_PIN::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform )
|
2009-06-13 17:06:07 +00:00
|
|
|
{
|
2011-05-25 10:42:56 +00:00
|
|
|
if( aThreshold < 0 )
|
|
|
|
aThreshold = 0;
|
|
|
|
|
2011-05-05 17:45:35 +00:00
|
|
|
TRANSFORM transform = DefaultTransform;
|
|
|
|
DefaultTransform = aTransform;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
EDA_RECT rect = GetBoundingBox();
|
|
|
|
rect.Inflate( aThreshold );
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2011-05-05 17:45:35 +00:00
|
|
|
//Restore matrix
|
|
|
|
DefaultTransform = transform;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
return rect.Contains( aPosition );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
bool LIB_PIN::Save( FILE* ExportFile )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
wxString StringPinNum;
|
|
|
|
int Etype;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
switch( m_type )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
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;
|
2010-10-22 07:52:55 +00:00
|
|
|
|
|
|
|
case PIN_NC:
|
|
|
|
Etype = 'N';
|
|
|
|
break;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnPinStringNum( StringPinNum );
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( StringPinNum.IsEmpty() )
|
|
|
|
StringPinNum = wxT( "~" );
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( !m_name.IsEmpty() )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
if( fprintf( ExportFile, "X %s", TO_UTF8( m_name ) ) < 0 )
|
2009-09-14 13:24:17 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
else
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
if( fprintf( ExportFile, "X ~" ) < 0 )
|
|
|
|
return false;
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
if( fprintf( ExportFile, " %s %d %d %d %c %d %d %d %d %c",
|
2011-02-28 18:36:19 +00:00
|
|
|
TO_UTF8( StringPinNum ), m_position.x, m_position.y,
|
2010-12-07 16:10:42 +00:00
|
|
|
(int) m_length, (int) m_orientation, m_PinNumSize, m_PinNameSize,
|
2009-09-14 13:24:17 +00:00
|
|
|
m_Unit, m_Convert, Etype ) < 0 )
|
|
|
|
return false;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-05-06 13:56:26 +00:00
|
|
|
if( m_shape || !IsVisible() )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
if( fprintf( ExportFile, " " ) < 0 )
|
|
|
|
return false;
|
|
|
|
}
|
2011-05-06 13:56:26 +00:00
|
|
|
if( !IsVisible() && fprintf( ExportFile, "N" ) < 0 )
|
2009-09-14 13:24:17 +00:00
|
|
|
return false;
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_shape & INVERT
|
2009-09-14 13:24:17 +00:00
|
|
|
&& fprintf( ExportFile, "I" ) < 0 )
|
|
|
|
return false;
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_shape & CLOCK
|
2009-09-14 13:24:17 +00:00
|
|
|
&& fprintf( ExportFile, "C" ) < 0 )
|
|
|
|
return false;
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_shape & LOWLEVEL_IN
|
2009-09-14 13:24:17 +00:00
|
|
|
&& fprintf( ExportFile, "L" ) < 0 )
|
|
|
|
return false;
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_shape & LOWLEVEL_OUT
|
2009-09-14 13:24:17 +00:00
|
|
|
&& fprintf( ExportFile, "V" ) < 0 )
|
|
|
|
return false;
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_shape & CLOCK_FALL
|
2010-09-26 05:35:29 +00:00
|
|
|
&& fprintf( ExportFile, "F" ) < 0 )
|
|
|
|
return false;
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_shape & NONLOGIC
|
2010-09-26 05:35:29 +00:00
|
|
|
&& fprintf( ExportFile, "X" ) < 0 )
|
|
|
|
return false;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
if( fprintf( ExportFile, "\n" ) < 0 )
|
|
|
|
return false;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
m_Flags &= ~IS_CHANGED;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
bool LIB_PIN::Load( char* line, wxString& errorMsg )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
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,
|
2010-12-07 16:10:42 +00:00
|
|
|
pinNum, &m_position.x, &m_position.y, &m_length, pinOrient, &m_PinNumSize,
|
2009-04-05 20:49:15 +00:00
|
|
|
&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;
|
|
|
|
}
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
m_orientation = pinOrient[0] & 255;
|
|
|
|
strncpy( (char*) &m_number, pinNum, 4 );
|
2011-02-28 18:36:19 +00:00
|
|
|
m_name = FROM_UTF8( pinName );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
switch( *pinType & 255 )
|
|
|
|
{
|
|
|
|
case 'I':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = PIN_INPUT;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'O':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = PIN_OUTPUT;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'B':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = PIN_BIDI;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = PIN_TRISTATE;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'P':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = PIN_PASSIVE;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'U':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = PIN_UNSPECIFIED;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'W':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = PIN_POWER_IN;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'w':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = PIN_POWER_OUT;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = PIN_OPENCOLLECTOR;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'E':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = PIN_OPENEMITTER;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
2010-10-22 07:52:55 +00:00
|
|
|
case 'N':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_type = PIN_NC;
|
2010-10-22 07:52:55 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
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':
|
2011-05-06 13:56:26 +00:00
|
|
|
m_attributes |= PIN_INVISIBLE;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'I':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_shape |= INVERT;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_shape |= CLOCK;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'L':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_shape |= LOWLEVEL_IN;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'V':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_shape |= LOWLEVEL_OUT;
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
2010-09-26 05:35:29 +00:00
|
|
|
case 'F':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_shape |= CLOCK_FALL;
|
2010-09-26 05:35:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'X':
|
2010-12-07 16:10:42 +00:00
|
|
|
m_shape |= NONLOGIC;
|
2010-09-26 05:35:29 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
default:
|
2010-11-18 21:10:52 +00:00
|
|
|
errorMsg.Printf( wxT( "unknown pin attribute [%c]" ), pinAttrs[j] );
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function GetPenSize
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
2011-04-18 20:22:17 +00:00
|
|
|
int LIB_PIN::GetPenSize() const
|
2009-06-30 17:57:27 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
return ( m_width == 0 ) ? g_DrawDefaultLineThickness : m_width;
|
2009-06-30 17:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
|
|
|
|
wxDC* aDC,
|
|
|
|
const wxPoint& aOffset,
|
|
|
|
int aColor,
|
|
|
|
int aDrawMode,
|
|
|
|
void* aData,
|
|
|
|
const TRANSFORM& aTransform )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2011-05-06 13:56:26 +00:00
|
|
|
// Invisible pins are only drawn on request.
|
|
|
|
// They are drawn in g_InvisibleItemColor.
|
|
|
|
// in schematic, they are drawn only if m_ShowAllPins is true.
|
|
|
|
// In other windows, they are always drawn because we must see them.
|
|
|
|
if( ! IsVisible() )
|
2008-09-19 08:19:15 +00:00
|
|
|
{
|
2011-05-06 13:56:26 +00:00
|
|
|
EDA_DRAW_FRAME* frame = NULL;
|
|
|
|
if( aPanel && aPanel->GetParent() )
|
|
|
|
frame = (EDA_DRAW_FRAME*)aPanel->GetParent();
|
|
|
|
|
|
|
|
if( frame && frame->m_Ident == SCHEMATIC_FRAME &&
|
|
|
|
! ((SCH_EDIT_FRAME*)frame)->m_ShowAllPins )
|
2008-09-19 08:19:15 +00:00
|
|
|
return;
|
2011-05-06 13:56:26 +00:00
|
|
|
|
|
|
|
aColor = g_InvisibleItemColor;
|
2008-09-19 08:19:15 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
LIB_COMPONENT* Entry = GetParent();
|
2011-04-18 20:22:17 +00:00
|
|
|
bool DrawPinText = true;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
|
|
|
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. */
|
2011-04-18 20:22:17 +00:00
|
|
|
int orient = ReturnPinDrawOrient( aTransform );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
/* Calculate the pin position */
|
2010-12-07 16:10:42 +00:00
|
|
|
wxPoint pos1 = aTransform.TransformCoordinate( m_position ) + aOffset;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/* Drawing from the pin and the special symbol combination */
|
2008-09-13 18:59:57 +00:00
|
|
|
DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor );
|
|
|
|
|
|
|
|
if( DrawPinText )
|
|
|
|
{
|
2010-06-24 18:31:43 +00:00
|
|
|
DrawPinTexts( aPanel, aDC, pos1, orient, Entry->GetPinNameOffset(),
|
|
|
|
Entry->ShowPinNumbers(), Entry->ShowPinNames(),
|
2008-12-08 15:27:13 +00:00
|
|
|
aColor, aDrawMode );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
2009-10-01 14:17:47 +00:00
|
|
|
|
|
|
|
/* Set to one (1) to draw bounding box around pin to validate bounding
|
|
|
|
* box calculation. */
|
|
|
|
#if 0
|
2011-04-18 20:22:17 +00:00
|
|
|
EDA_RECT* clipbox = aPanel ? &aPanel->m_ClipBox : NULL;
|
2011-05-05 17:45:35 +00:00
|
|
|
TRANSFORM transform = DefaultTransform;
|
|
|
|
DefaultTransform = aTransform;
|
2011-04-18 20:22:17 +00:00
|
|
|
EDA_RECT bBox = GetBoundingBox();
|
|
|
|
bBox.Move( aOffset );
|
2011-05-05 17:45:35 +00:00
|
|
|
//Restore matrix
|
|
|
|
DefaultTransform = transform;
|
2011-04-18 20:22:17 +00:00
|
|
|
GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA );
|
2009-10-01 14:17:47 +00:00
|
|
|
#endif
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function DrawPinSymbol
|
2009-04-06 10:56:17 +00:00
|
|
|
* 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
|
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
|
|
|
|
wxDC* aDC,
|
|
|
|
const wxPoint& aPinPos,
|
|
|
|
int aOrient,
|
|
|
|
int aDrawMode,
|
|
|
|
int aColor )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2011-04-18 20:22:17 +00:00
|
|
|
int MapX1, MapY1, x1, y1;
|
|
|
|
int color;
|
|
|
|
int width = GetPenSize();
|
|
|
|
int posX = aPinPos.x, posY = aPinPos.y, len = m_length;
|
|
|
|
EDA_RECT* clipbox = aPanel ? &aPanel->m_ClipBox : NULL;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
color = ReturnLayerColor( LAYER_PIN );
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
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 );
|
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
MapX1 = MapY1 = 0;
|
2011-04-18 20:22:17 +00:00
|
|
|
x1 = posX;
|
|
|
|
y1 = posY;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
switch( aOrient )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
2011-04-18 20:22:17 +00:00
|
|
|
y1 = posY - len;
|
2010-11-18 21:10:52 +00:00
|
|
|
MapY1 = 1;
|
2008-09-13 18:59:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_DOWN:
|
2011-04-18 20:22:17 +00:00
|
|
|
y1 = posY + len;
|
2010-11-18 21:10:52 +00:00
|
|
|
MapY1 = -1;
|
2008-09-13 18:59:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_LEFT:
|
2011-04-18 20:22:17 +00:00
|
|
|
x1 = posX - len;
|
2010-11-18 21:10:52 +00:00
|
|
|
MapX1 = 1;
|
2008-09-13 18:59:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_RIGHT:
|
2011-04-18 20:22:17 +00:00
|
|
|
x1 = posX + len;
|
2010-11-18 21:10:52 +00:00
|
|
|
MapX1 = -1;
|
2008-09-13 18:59:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_shape & INVERT )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2011-04-18 20:22:17 +00:00
|
|
|
GRCircle( 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 );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox, aDC, posX, posY, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
2010-12-07 16:10:42 +00:00
|
|
|
else if( m_shape & CLOCK_FALL ) /* an alternative for Inverted Clock */
|
2010-09-24 16:00:40 +00:00
|
|
|
{
|
|
|
|
GRMoveTo( x1 + MapY1 * CLOCK_PIN_DIM,
|
|
|
|
y1 - MapX1 * CLOCK_PIN_DIM );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox,
|
2010-09-24 16:00:40 +00:00
|
|
|
aDC,
|
|
|
|
x1 + MapX1 * CLOCK_PIN_DIM,
|
|
|
|
y1 + MapY1 * CLOCK_PIN_DIM,
|
|
|
|
width,
|
|
|
|
color );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox,
|
2010-09-24 16:00:40 +00:00
|
|
|
aDC,
|
|
|
|
x1 - MapY1 * CLOCK_PIN_DIM,
|
|
|
|
y1 + MapX1 * CLOCK_PIN_DIM,
|
|
|
|
width,
|
|
|
|
color );
|
|
|
|
GRMoveTo( MapX1 * CLOCK_PIN_DIM + x1,
|
|
|
|
MapY1 * CLOCK_PIN_DIM + y1 );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox, aDC, posX, posY, width, color );
|
2010-09-24 16:00:40 +00:00
|
|
|
}
|
2008-09-13 18:59:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
GRMoveTo( x1, y1 );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox, aDC, posX, posY, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_shape & CLOCK )
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
|
|
|
GRMoveTo( x1, y1 + CLOCK_PIN_DIM );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox,
|
2009-04-06 10:56:17 +00:00
|
|
|
aDC,
|
|
|
|
x1 - MapX1 * CLOCK_PIN_DIM,
|
|
|
|
y1,
|
|
|
|
width,
|
|
|
|
color );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox,
|
2009-04-06 10:56:17 +00:00
|
|
|
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 );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox,
|
2009-04-06 10:56:17 +00:00
|
|
|
aDC,
|
|
|
|
x1,
|
|
|
|
y1 - MapY1 * CLOCK_PIN_DIM,
|
|
|
|
width,
|
|
|
|
color );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox,
|
2009-04-06 10:56:17 +00:00
|
|
|
aDC,
|
|
|
|
x1 - CLOCK_PIN_DIM,
|
|
|
|
y1,
|
|
|
|
width,
|
2008-12-08 15:27:13 +00:00
|
|
|
color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
if( m_shape & LOWLEVEL_IN ) /* IEEE symbol "Active Low Input" */
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
|
|
|
GRMoveTo( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox,
|
2009-04-06 10:56:17 +00:00
|
|
|
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 );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox, aDC, x1, y1, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
|
|
|
GRMoveTo( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox, aDC, x1 - IEEE_SYMBOL_PIN_DIM,
|
2008-12-08 15:27:13 +00:00
|
|
|
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2, width, color );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox, aDC, x1, y1, width, color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
if( m_shape & LOWLEVEL_OUT ) /* IEEE symbol "Active Low Output" */
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
|
|
|
GRMoveTo( x1, y1 - IEEE_SYMBOL_PIN_DIM );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox,
|
2009-04-06 10:56:17 +00:00
|
|
|
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 );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox,
|
2009-04-06 10:56:17 +00:00
|
|
|
aDC,
|
|
|
|
x1,
|
|
|
|
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2,
|
|
|
|
width,
|
|
|
|
color );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
2010-12-07 16:10:42 +00:00
|
|
|
else if( m_shape & NONLOGIC ) /* NonLogic pin symbol */
|
2010-09-24 16:00:40 +00:00
|
|
|
{
|
|
|
|
GRMoveTo( x1 - (MapX1 + MapY1) * NONLOGIC_PIN_DIM,
|
|
|
|
y1 - (MapY1 - MapX1) * NONLOGIC_PIN_DIM );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox,
|
2010-09-24 16:00:40 +00:00
|
|
|
aDC,
|
|
|
|
x1 + (MapX1 + MapY1) * NONLOGIC_PIN_DIM,
|
|
|
|
y1 + (MapY1 - MapX1) * NONLOGIC_PIN_DIM,
|
|
|
|
width,
|
|
|
|
color );
|
|
|
|
GRMoveTo( x1 - (MapX1 - MapY1) * NONLOGIC_PIN_DIM,
|
|
|
|
y1 - (MapY1 + MapX1) * NONLOGIC_PIN_DIM );
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLineTo( clipbox,
|
2010-09-24 16:00:40 +00:00
|
|
|
aDC,
|
|
|
|
x1 + (MapX1 - MapY1) * NONLOGIC_PIN_DIM,
|
|
|
|
y1 + (MapY1 + MapX1) * NONLOGIC_PIN_DIM,
|
|
|
|
width,
|
|
|
|
color );
|
|
|
|
}
|
|
|
|
|
2009-04-06 10:56:17 +00:00
|
|
|
/* Draw the pin end target (active end of the pin)
|
|
|
|
*/
|
2011-04-18 20:22:17 +00:00
|
|
|
BASE_SCREEN* screen = aPanel ? aPanel->GetScreen() : NULL;
|
2011-05-25 10:42:56 +00:00
|
|
|
#define NCSYMB_PIN_DIM TARGET_PIN_RADIUS
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_type == PIN_NC ) // Draw a N.C. symbol
|
2010-10-22 07:52:55 +00:00
|
|
|
{
|
2011-04-18 20:22:17 +00:00
|
|
|
GRLine( clipbox, aDC,
|
|
|
|
posX - NCSYMB_PIN_DIM, posY - NCSYMB_PIN_DIM,
|
|
|
|
posX + NCSYMB_PIN_DIM, posY + NCSYMB_PIN_DIM,
|
|
|
|
width, color );
|
|
|
|
GRLine( clipbox, aDC,
|
|
|
|
posX + NCSYMB_PIN_DIM, posY - NCSYMB_PIN_DIM,
|
|
|
|
posX - NCSYMB_PIN_DIM, posY + NCSYMB_PIN_DIM,
|
|
|
|
width, color );
|
2010-10-22 07:52:55 +00:00
|
|
|
}
|
|
|
|
/* Draw but do not print the pin end target 1 pixel width
|
2011-04-18 20:22:17 +00:00
|
|
|
*/
|
|
|
|
else if( screen == NULL || !screen->m_IsPrinting )
|
2010-12-07 16:10:42 +00:00
|
|
|
{
|
2011-05-25 10:42:56 +00:00
|
|
|
GRCircle( clipbox, aDC, posX, posY, TARGET_PIN_RADIUS, 0, color );
|
2010-12-07 16:10:42 +00:00
|
|
|
}
|
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
|
2009-10-30 19:26:25 +00:00
|
|
|
* DrawMode = GR_OR, XOR ...
|
2008-09-13 18:59:57 +00:00
|
|
|
*****************************************************************************/
|
2011-01-21 19:30:59 +00:00
|
|
|
void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* 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
|
|
|
{
|
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
|
|
|
|
2011-04-18 20:22:17 +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 );
|
2011-04-18 20:22:17 +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 );
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
x1 = pin_pos.x;
|
|
|
|
y1 = pin_pos.y;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
switch( orient )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
2010-12-07 16:10:42 +00:00
|
|
|
y1 -= m_length;
|
|
|
|
break;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
case PIN_DOWN:
|
2010-12-07 16:10:42 +00:00
|
|
|
y1 += m_length;
|
|
|
|
break;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
case PIN_LEFT:
|
2010-12-07 16:10:42 +00:00
|
|
|
x1 -= m_length;
|
|
|
|
break;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
case PIN_RIGHT:
|
2010-12-07 16:10:42 +00:00
|
|
|
x1 += m_length;
|
|
|
|
break;
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_name.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,
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name,
|
2009-04-06 10:56:17 +00:00
|
|
|
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,
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name,
|
2009-04-06 10:56:17 +00:00
|
|
|
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,
|
2011-04-18 20:22:17 +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,
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name,
|
2009-04-06 10:56:17 +00:00
|
|
|
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,
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name,
|
2009-04-06 10:56:17 +00:00
|
|
|
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 ),
|
2010-12-07 16:10:42 +00:00
|
|
|
NameColor, m_name,
|
2009-04-06 10:56:17 +00:00
|
|
|
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 ),
|
2010-12-07 16:10:42 +00:00
|
|
|
NameColor, m_name,
|
2009-04-06 10:56:17 +00:00
|
|
|
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
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
|
|
|
|
{
|
|
|
|
int MapX1, MapY1, x1, y1;
|
|
|
|
EDA_Colors color = UNSPECIFIED_COLOR;
|
|
|
|
|
|
|
|
color = ReturnLayerColor( LAYER_PIN );
|
|
|
|
|
|
|
|
aPlotter->set_color( color );
|
|
|
|
|
|
|
|
MapX1 = MapY1 = 0;
|
|
|
|
x1 = aPosition.x; y1 = aPosition.y;
|
|
|
|
|
|
|
|
switch( aOrientation )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
|
|
|
y1 = aPosition.y - m_length;
|
|
|
|
MapY1 = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_DOWN:
|
|
|
|
y1 = aPosition.y + m_length;
|
|
|
|
MapY1 = -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_LEFT:
|
|
|
|
x1 = aPosition.x - m_length;
|
|
|
|
MapX1 = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_RIGHT:
|
|
|
|
x1 = aPosition.x + m_length;
|
|
|
|
MapX1 = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_shape & INVERT )
|
|
|
|
{
|
|
|
|
aPlotter->circle( wxPoint( MapX1 * INVERT_PIN_RADIUS + x1,
|
|
|
|
MapY1 * INVERT_PIN_RADIUS + y1 ),
|
|
|
|
INVERT_PIN_RADIUS * 2, // diameter
|
|
|
|
NO_FILL, // fill
|
|
|
|
-1 ); // width
|
|
|
|
|
|
|
|
aPlotter->move_to( wxPoint( MapX1 * INVERT_PIN_RADIUS * 2 + x1,
|
|
|
|
MapY1 * INVERT_PIN_RADIUS * 2 + y1 ) );
|
|
|
|
aPlotter->finish_to( aPosition );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aPlotter->move_to( wxPoint( x1, y1 ) );
|
|
|
|
aPlotter->finish_to( aPosition );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_shape & CLOCK )
|
|
|
|
{
|
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
|
|
|
aPlotter->move_to( wxPoint( x1, y1 + CLOCK_PIN_DIM ) );
|
|
|
|
aPlotter->line_to( wxPoint( x1 - MapX1 * CLOCK_PIN_DIM, y1 ) );
|
|
|
|
aPlotter->finish_to( wxPoint( x1, y1 - CLOCK_PIN_DIM ) );
|
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
|
|
|
aPlotter->move_to( wxPoint( x1 + CLOCK_PIN_DIM, y1 ) );
|
|
|
|
aPlotter->line_to( wxPoint( x1, y1 - MapY1 * CLOCK_PIN_DIM ) );
|
|
|
|
aPlotter->finish_to( wxPoint( x1 - CLOCK_PIN_DIM, y1 ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_shape & LOWLEVEL_IN ) /* IEEE symbol "Active Low Input" */
|
|
|
|
{
|
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
|
|
|
aPlotter->move_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ) );
|
|
|
|
aPlotter->line_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
|
|
|
|
y1 - IEEE_SYMBOL_PIN_DIM ) );
|
|
|
|
aPlotter->finish_to( wxPoint( x1, y1 ) );
|
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
|
|
|
aPlotter->move_to( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
|
|
|
|
aPlotter->line_to( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM,
|
|
|
|
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
|
|
|
|
aPlotter->finish_to( wxPoint( x1, y1 ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( m_shape & LOWLEVEL_OUT ) /* IEEE symbol "Active Low Output" */
|
|
|
|
{
|
|
|
|
if( MapY1 == 0 ) /* MapX1 = +- 1 */
|
|
|
|
{
|
|
|
|
aPlotter->move_to( wxPoint( x1, y1 - IEEE_SYMBOL_PIN_DIM ) );
|
|
|
|
aPlotter->finish_to( wxPoint( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 ) );
|
|
|
|
}
|
|
|
|
else /* MapX1 = 0 */
|
|
|
|
{
|
|
|
|
aPlotter->move_to( wxPoint( x1 - IEEE_SYMBOL_PIN_DIM, y1 ) );
|
|
|
|
aPlotter->finish_to( wxPoint( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
*****************************************************************************/
|
2011-04-18 20:22:17 +00:00
|
|
|
void LIB_PIN::PlotPinTexts( PLOTTER* plotter,
|
2009-10-08 13:19:28 +00:00
|
|
|
wxPoint& pin_pos,
|
|
|
|
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 );
|
2010-11-18 21:10:52 +00:00
|
|
|
x1 = pin_pos.x;
|
|
|
|
y1 = pin_pos.y;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
|
|
|
switch( orient )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
2010-12-07 16:10:42 +00:00
|
|
|
y1 -= m_length;
|
2010-11-18 21:10:52 +00:00
|
|
|
break;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
|
|
|
case PIN_DOWN:
|
2010-12-07 16:10:42 +00:00
|
|
|
y1 += m_length;
|
2010-11-18 21:10:52 +00:00
|
|
|
break;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
|
|
|
case PIN_LEFT:
|
2010-12-07 16:10:42 +00:00
|
|
|
x1 -= m_length;
|
2010-11-18 21:10:52 +00:00
|
|
|
break;
|
2008-09-13 19:06:31 +00:00
|
|
|
|
|
|
|
case PIN_RIGHT:
|
2010-12-07 16:10:42 +00:00
|
|
|
x1 += m_length;
|
2010-11-18 21:10:52 +00:00
|
|
|
break;
|
2008-09-13 19:06:31 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_name.IsEmpty() )
|
2008-09-13 19:06:31 +00:00
|
|
|
DrawPinName = FALSE;
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/* Draw the text inside, but the pin numbers outside. */
|
|
|
|
if( TextInside )
|
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,
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name,
|
2009-09-02 18:12:45 +00:00
|
|
|
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;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
if( DrawPinName )
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x, y1 ),
|
2010-12-07 16:10:42 +00:00
|
|
|
NameColor, m_name, TEXT_ORIENT_HORIZ,
|
2009-09-02 18:12:45 +00:00
|
|
|
PinNameSize,
|
|
|
|
GR_TEXT_HJUSTIFY_RIGHT,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
aWidth, false, false );
|
2009-05-12 12:12:34 +00:00
|
|
|
}
|
2009-09-25 13:59:42 +00:00
|
|
|
}
|
|
|
|
if( DrawPinNum )
|
|
|
|
{
|
|
|
|
plotter->text( wxPoint( (x1 + pin_pos.x) / 2,
|
2011-04-18 20:22:17 +00:00
|
|
|
y1 - TXTMARGE ),
|
2009-09-25 13:59:42 +00:00
|
|
|
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,
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name,
|
2009-09-02 18:12:45 +00:00
|
|
|
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
|
|
|
{
|
2010-11-18 21:10:52 +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_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,
|
2010-12-07 16:10:42 +00:00
|
|
|
m_name,
|
2009-09-02 18:12:45 +00:00
|
|
|
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 )
|
|
|
|
{
|
2010-11-18 21:10:52 +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_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 ),
|
2010-12-07 16:10:42 +00:00
|
|
|
NameColor, m_name,
|
2009-09-02 18:12:45 +00:00
|
|
|
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 )
|
|
|
|
{
|
2010-11-18 21:10:52 +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
|
|
|
{
|
2010-11-18 21:10:52 +00:00
|
|
|
y = ( y1 + pin_pos.y ) / 2;
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->text( wxPoint( x1 - TXTMARGE, y ),
|
2010-12-07 16:10:42 +00:00
|
|
|
NameColor, m_name,
|
2009-09-02 18:12:45 +00:00
|
|
|
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 )
|
|
|
|
{
|
2010-11-18 21:10:52 +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-10-30 19:26:25 +00:00
|
|
|
/* return the pin end position, for a component in normal orient */
|
2010-10-25 15:43:42 +00:00
|
|
|
wxPoint LIB_PIN::ReturnPinEndPoint() const
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
wxPoint pos = m_position;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
switch( m_orientation )
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
|
|
|
case PIN_UP:
|
2010-12-07 16:10:42 +00:00
|
|
|
pos.y += m_length;
|
2010-11-18 21:10:52 +00:00
|
|
|
break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_DOWN:
|
2010-12-07 16:10:42 +00:00
|
|
|
pos.y -= m_length;
|
2010-11-18 21:10:52 +00:00
|
|
|
break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_LEFT:
|
2010-12-07 16:10:42 +00:00
|
|
|
pos.x -= m_length;
|
2010-11-18 21:10:52 +00:00
|
|
|
break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_RIGHT:
|
2010-12-07 16:10:42 +00:00
|
|
|
pos.x += m_length;
|
2010-11-18 21:10:52 +00:00
|
|
|
break;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-25 10:42:56 +00:00
|
|
|
int LIB_PIN::ReturnPinDrawOrient( const TRANSFORM& aTransform ) const
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
int orient;
|
2010-12-07 16:10:42 +00:00
|
|
|
wxPoint end; // position of pin end starting at 0,0 according to its orientation, length = 1
|
2008-09-14 04:27:22 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
switch( m_orientation )
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
|
|
|
case PIN_UP:
|
2010-11-18 21:10:52 +00:00
|
|
|
end.y = 1;
|
|
|
|
break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_DOWN:
|
2010-11-18 21:10:52 +00:00
|
|
|
end.y = -1;
|
|
|
|
break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_LEFT:
|
2010-11-18 21:10:52 +00:00
|
|
|
end.x = -1;
|
|
|
|
break;
|
2008-09-14 04:27:22 +00:00
|
|
|
|
|
|
|
case PIN_RIGHT:
|
2010-11-18 21:10:52 +00:00
|
|
|
end.x = 1;
|
|
|
|
break;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
// = pos of end point, according to the component orientation
|
2011-04-18 20:22:17 +00:00
|
|
|
end = aTransform.TransformCoordinate( end );
|
2008-09-14 04:27:22 +00:00
|
|
|
orient = PIN_UP;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
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;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +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-10-08 13:19:28 +00:00
|
|
|
void LIB_PIN::ReturnPinStringNum( wxString& aStringBuffer ) const
|
2009-07-05 12:09:41 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
aStringBuffer = ReturnPinStringNum( m_number );
|
2009-07-05 12:09:41 +00:00
|
|
|
}
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function ReturnPinStringNum (static function)
|
2009-07-05 12:09:41 +00:00
|
|
|
* 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
|
|
|
|
*/
|
2009-10-08 13:19:28 +00:00
|
|
|
wxString LIB_PIN::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;
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
wxString buffer = FROM_UTF8( ascii_buf );
|
2009-07-05 12:09:41 +00:00
|
|
|
|
|
|
|
return buffer;
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function 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-10-08 13:19:28 +00:00
|
|
|
void LIB_PIN::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;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2008-09-14 04:27:22 +00:00
|
|
|
if( len > 4 )
|
|
|
|
len = 4;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2008-09-14 04:27:22 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
strncpy( (char*) &m_number, ascii_buf, 4 );
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
EDA_ITEM* LIB_PIN::doClone() const
|
2008-09-14 04:27:22 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
return new LIB_PIN( *this );
|
2008-09-14 04:27:22 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
int LIB_PIN::DoCompare( const LIB_ITEM& other ) const
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
wxASSERT( other.Type() == LIB_PIN_T );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
const LIB_PIN* tmp = (LIB_PIN*) &other;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_number != tmp->m_number )
|
|
|
|
return m_number - tmp->m_number;
|
2009-10-01 14:17:47 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
int result = m_name.CmpNoCase( tmp->m_name );
|
2009-10-01 14:17:47 +00:00
|
|
|
|
|
|
|
if( result != 0 )
|
|
|
|
return result;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_position.x != tmp->m_position.x )
|
|
|
|
return m_position.x - tmp->m_position.x;
|
2009-10-01 14:17:47 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_position.y != tmp->m_position.y )
|
|
|
|
return m_position.y - tmp->m_position.y;
|
2009-10-01 14:17:47 +00:00
|
|
|
|
|
|
|
return 0;
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
void LIB_PIN::DoOffset( const wxPoint& offset )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_position += offset;
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
bool LIB_PIN::DoTestInside( EDA_RECT& rect ) const
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
wxPoint end = ReturnPinEndPoint();
|
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
return rect.Contains( m_position.x, -m_position.y ) || rect.Contains( end.x, -end.y );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
void LIB_PIN::DoMove( const wxPoint& newPosition )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_position != newPosition )
|
|
|
|
{
|
|
|
|
m_position = newPosition;
|
|
|
|
SetModified();
|
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
void LIB_PIN::DoMirrorHorizontal( const wxPoint& center )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
m_position.x -= center.x;
|
|
|
|
m_position.x *= -1;
|
|
|
|
m_position.x += center.x;
|
|
|
|
|
|
|
|
if( m_orientation == PIN_RIGHT )
|
|
|
|
m_orientation = PIN_LEFT;
|
|
|
|
else if( m_orientation == PIN_LEFT )
|
|
|
|
m_orientation = PIN_RIGHT;
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
2011-05-20 18:29:35 +00:00
|
|
|
void LIB_PIN::DoMirrorVertical( const wxPoint& center )
|
|
|
|
{
|
|
|
|
m_position.y -= center.y;
|
|
|
|
m_position.y *= -1;
|
|
|
|
m_position.y += center.y;
|
|
|
|
|
|
|
|
if( m_orientation == PIN_UP )
|
|
|
|
m_orientation = PIN_DOWN;
|
|
|
|
else if( m_orientation == PIN_DOWN )
|
|
|
|
m_orientation = PIN_UP;
|
|
|
|
}
|
|
|
|
|
2011-05-22 19:08:34 +00:00
|
|
|
void LIB_PIN::DoRotate( const wxPoint& center, bool aRotateCCW )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
2011-05-22 19:08:34 +00:00
|
|
|
int rot_angle = aRotateCCW ? -900 : 900;
|
2011-05-20 18:29:35 +00:00
|
|
|
|
2011-05-22 19:08:34 +00:00
|
|
|
RotatePoint( &m_position, center, rot_angle );
|
|
|
|
|
|
|
|
if( aRotateCCW )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
2011-05-22 19:08:34 +00:00
|
|
|
switch( m_orientation )
|
|
|
|
{
|
|
|
|
case PIN_RIGHT:
|
|
|
|
m_orientation = PIN_UP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_UP:
|
|
|
|
m_orientation = PIN_LEFT;
|
|
|
|
break;
|
|
|
|
case PIN_LEFT:
|
|
|
|
m_orientation = PIN_DOWN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_DOWN:
|
|
|
|
m_orientation = PIN_RIGHT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( m_orientation )
|
|
|
|
{
|
|
|
|
case PIN_RIGHT:
|
|
|
|
m_orientation = PIN_DOWN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_UP:
|
|
|
|
m_orientation = PIN_RIGHT;
|
|
|
|
break;
|
|
|
|
case PIN_LEFT:
|
|
|
|
m_orientation = PIN_UP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_DOWN:
|
|
|
|
m_orientation = PIN_LEFT;
|
|
|
|
break;
|
|
|
|
}
|
2011-05-20 18:29:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
void LIB_PIN::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
|
2010-10-20 20:24:26 +00:00
|
|
|
const TRANSFORM& aTransform )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2011-05-06 13:56:26 +00:00
|
|
|
if( ! IsVisible() )
|
2009-10-05 17:52:41 +00:00
|
|
|
return;
|
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
int orient = ReturnPinDrawOrient( aTransform );
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
wxPoint pos = aTransform.TransformCoordinate( m_position ) + offset;
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
plotter->set_current_line_width( GetPenSize() );
|
2011-06-17 13:24:22 +00:00
|
|
|
PlotSymbol( plotter, pos, orient );
|
2010-06-24 18:31:43 +00:00
|
|
|
PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(),
|
2011-06-17 13:24:22 +00:00
|
|
|
GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(),
|
|
|
|
GetPenSize() );
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
void LIB_PIN::DoSetWidth( int aWidth )
|
|
|
|
{
|
|
|
|
if( m_width != aWidth )
|
|
|
|
{
|
|
|
|
m_width = aWidth;
|
|
|
|
SetModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function 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
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void LIB_PIN::DisplayInfo( EDA_DRAW_FRAME* frame )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
wxString Text;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM::DisplayInfo( frame );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
frame->AppendMsgPanel( _( "Name" ), m_name, DARKCYAN );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( m_number == 0 )
|
2009-04-05 20:49:15 +00:00
|
|
|
Text = wxT( "?" );
|
|
|
|
else
|
|
|
|
ReturnPinStringNum( Text );
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
frame->AppendMsgPanel( _( "Number" ), Text, DARKCYAN );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
frame->AppendMsgPanel( _( "Type" ),
|
2010-12-07 16:10:42 +00:00
|
|
|
wxGetTranslation( pin_electrical_type_names[ m_type ] ),
|
2010-11-18 21:10:52 +00:00
|
|
|
RED );
|
2011-04-18 20:22:17 +00:00
|
|
|
Text = wxGetTranslation( pin_style_names[ GetStyleCodeIndex( m_shape ) ] );
|
2009-10-30 19:26:25 +00:00
|
|
|
frame->AppendMsgPanel( _( "Style" ), Text, BLUE );
|
|
|
|
if( IsVisible() )
|
|
|
|
Text = _( "Yes" );
|
2009-04-05 20:49:15 +00:00
|
|
|
else
|
2009-10-30 19:26:25 +00:00
|
|
|
Text = _( "No" );
|
|
|
|
frame->AppendMsgPanel( _( "Visible" ), Text, DARKGREEN );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
/* Display pin length */
|
2010-12-07 16:10:42 +00:00
|
|
|
Text = ReturnStringFromValue( g_UserUnit, m_length, EESCHEMA_INTERNAL_UNIT, true );
|
2009-10-14 19:43:31 +00:00
|
|
|
frame->AppendMsgPanel( _( "Length" ), Text, MAGENTA );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
Text = wxGetTranslation( pin_orientation_names[ GetOrientationCodeIndex( m_orientation ) ] );
|
2009-10-30 19:26:25 +00:00
|
|
|
frame->AppendMsgPanel( _( "Orientation" ), Text, DARKMAGENTA );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function GetBoundingBox
|
2009-04-06 10:56:17 +00:00
|
|
|
* @return the boundary box for this, in schematic coordinates
|
2011-05-05 17:45:35 +00:00
|
|
|
* Uses DefaultTransform as transform matrix
|
2009-04-06 10:56:17 +00:00
|
|
|
*/
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT LIB_PIN::GetBoundingBox() const
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-04-18 20:22:17 +00:00
|
|
|
LIB_COMPONENT* entry = (LIB_COMPONENT*) m_Parent;
|
|
|
|
EDA_RECT bbox;
|
|
|
|
wxPoint begin;
|
|
|
|
wxPoint end;
|
2011-04-27 19:44:32 +00:00
|
|
|
int nameTextOffset = 0;
|
|
|
|
bool showName = !m_name.IsEmpty() && (m_name != wxT( "~" ));
|
2011-05-05 17:45:35 +00:00
|
|
|
bool showNum = m_number != 0;
|
2011-05-25 10:42:56 +00:00
|
|
|
int minsizeV = TARGET_PIN_RADIUS;
|
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
if( entry )
|
2011-04-27 19:44:32 +00:00
|
|
|
{
|
|
|
|
if( entry->ShowPinNames() )
|
|
|
|
nameTextOffset = entry->GetPinNameOffset();
|
|
|
|
else
|
|
|
|
showName = false;
|
2011-05-05 17:45:35 +00:00
|
|
|
|
|
|
|
showNum = entry->ShowPinNumbers();
|
2011-04-27 19:44:32 +00:00
|
|
|
}
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
// First, calculate boundary box corners position
|
2011-05-05 17:45:35 +00:00
|
|
|
int numberTextLength = showNum ? m_PinNumSize * GetNumberString().Len() : 0;
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2011-05-25 10:42:56 +00:00
|
|
|
// Actual text height is bigger than text size
|
2011-05-05 17:45:35 +00:00
|
|
|
int numberTextHeight = showNum ? wxRound( m_PinNumSize * 1.1 ) : 0;
|
2011-04-27 19:44:32 +00:00
|
|
|
|
|
|
|
if( m_shape & INVERT )
|
2011-05-25 10:42:56 +00:00
|
|
|
minsizeV = MAX( TARGET_PIN_RADIUS, INVERT_PIN_RADIUS );
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
// calculate top left corner position
|
|
|
|
// for the default pin orientation (PIN_RIGHT)
|
2011-05-25 10:42:56 +00:00
|
|
|
begin.y = MAX( minsizeV, numberTextHeight + TXTMARGE );
|
|
|
|
begin.x = MIN( -TARGET_PIN_RADIUS, m_length - (numberTextLength / 2) );
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
// calculate bottom right corner position and adjust top left corner position
|
2011-04-27 19:44:32 +00:00
|
|
|
int nameTextLength = 0;
|
2011-05-05 17:45:35 +00:00
|
|
|
int nameTextHeight = 0;
|
2011-04-27 19:44:32 +00:00
|
|
|
|
|
|
|
if( showName )
|
|
|
|
{
|
|
|
|
int length = m_name.Len();
|
|
|
|
|
|
|
|
// Don't count the line over text symbol.
|
|
|
|
if( m_name.Left( 1 ) == wxT( "~" ) )
|
|
|
|
length -= 1;
|
|
|
|
|
|
|
|
nameTextLength = ( m_PinNameSize * length ) + nameTextOffset;
|
2011-05-05 17:45:35 +00:00
|
|
|
// Actual text height are bigger than text size
|
2011-05-25 10:42:56 +00:00
|
|
|
nameTextHeight = wxRound( m_PinNameSize * 1.1 ) + TXTMARGE;
|
2011-04-27 19:44:32 +00:00
|
|
|
}
|
|
|
|
|
2011-05-25 10:42:56 +00:00
|
|
|
if( nameTextOffset ) // for values > 0, pin name is inside the body
|
|
|
|
{
|
|
|
|
end.x = m_length + nameTextLength;
|
|
|
|
end.y = MIN( -minsizeV, -nameTextHeight / 2 );
|
|
|
|
}
|
|
|
|
else // if value == 0:
|
|
|
|
// pin name is ouside the body, and above the pin line
|
|
|
|
// pin num is below the pin line
|
|
|
|
{
|
|
|
|
end.x = MAX(m_length, nameTextLength);
|
|
|
|
end.y = -begin.y;
|
|
|
|
begin.y = MAX( minsizeV, nameTextHeight );
|
|
|
|
}
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
// Now, calculate boundary box corners position for the actual pin orientation
|
2011-05-25 10:42:56 +00:00
|
|
|
int orient = ReturnPinDrawOrient( DefaultTransform );
|
|
|
|
|
|
|
|
/* Calculate the pin position */
|
|
|
|
switch( orient )
|
2011-04-18 20:22:17 +00:00
|
|
|
{
|
|
|
|
case PIN_UP:
|
|
|
|
// Pin is rotated and texts positions are mirrored
|
|
|
|
RotatePoint( &begin, wxPoint( 0, 0 ), -900 );
|
|
|
|
RotatePoint( &end, wxPoint( 0, 0 ), -900 );
|
|
|
|
break;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
case PIN_DOWN:
|
|
|
|
RotatePoint( &begin, wxPoint( 0, 0 ), 900 );
|
|
|
|
RotatePoint( &end, wxPoint( 0, 0 ), 900 );
|
|
|
|
NEGATE( begin.x );
|
|
|
|
NEGATE( end.x );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_LEFT:
|
|
|
|
NEGATE( begin.x );
|
|
|
|
NEGATE( end.x );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_RIGHT:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-25 10:42:56 +00:00
|
|
|
// Draw Y axis is reversed in schematic:
|
|
|
|
NEGATE( begin.y );
|
|
|
|
NEGATE( end.y );
|
|
|
|
|
|
|
|
wxPoint pos1 = DefaultTransform.TransformCoordinate( m_position );
|
|
|
|
begin += pos1;
|
|
|
|
end += pos1;
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2011-05-05 17:45:35 +00:00
|
|
|
bbox.SetOrigin( begin );
|
|
|
|
bbox.SetEnd( end );
|
2011-04-18 20:22:17 +00:00
|
|
|
bbox.Normalize();
|
2011-05-05 17:45:35 +00:00
|
|
|
bbox.Inflate( GetPenSize() / 2 );
|
2011-04-18 20:22:17 +00:00
|
|
|
|
|
|
|
return bbox;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxArrayString LIB_PIN::GetOrientationNames( void )
|
|
|
|
{
|
2009-11-16 21:37:53 +00:00
|
|
|
wxArrayString tmp;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2009-11-16 21:37:53 +00:00
|
|
|
for( unsigned ii = 0; ii < PIN_ORIENTATION_CNT; ii++ )
|
2010-11-18 21:10:52 +00:00
|
|
|
tmp.Add( wxGetTranslation( pin_orientation_names[ii] ) );
|
|
|
|
|
2009-11-16 21:37:53 +00:00
|
|
|
return tmp;
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int LIB_PIN::GetOrientationCode( int index )
|
|
|
|
{
|
|
|
|
if( index >= 0 && index < (int) PIN_ORIENTATION_CNT )
|
|
|
|
return pin_orientation_codes[ index ];
|
|
|
|
|
|
|
|
return PIN_RIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int LIB_PIN::GetOrientationCodeIndex( int code )
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for( i = 0; i < PIN_ORIENTATION_CNT; i++ )
|
|
|
|
{
|
|
|
|
if( pin_orientation_codes[i] == code )
|
|
|
|
return (int) i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return wxNOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-28 13:53:49 +00:00
|
|
|
void LIB_PIN::Rotate()
|
|
|
|
{
|
2011-05-05 18:43:56 +00:00
|
|
|
int orient = PIN_RIGHT;
|
2011-02-28 13:53:49 +00:00
|
|
|
|
2011-05-05 18:43:56 +00:00
|
|
|
switch( GetOrientation() )
|
|
|
|
{
|
|
|
|
case PIN_UP:
|
|
|
|
orient = PIN_LEFT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_DOWN:
|
|
|
|
orient = PIN_RIGHT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_LEFT:
|
|
|
|
orient = PIN_DOWN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIN_RIGHT:
|
|
|
|
orient = PIN_UP;
|
|
|
|
break;
|
|
|
|
}
|
2011-02-28 13:53:49 +00:00
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
// Set the new orientation
|
2011-05-05 18:43:56 +00:00
|
|
|
SetOrientation( orient );
|
2011-02-28 13:53:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
wxArrayString LIB_PIN::GetStyleNames( void )
|
|
|
|
{
|
2009-11-16 21:37:53 +00:00
|
|
|
wxArrayString tmp;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2009-11-16 21:37:53 +00:00
|
|
|
for( unsigned ii = 0; ii < PIN_STYLE_CNT; ii++ )
|
2010-11-18 21:10:52 +00:00
|
|
|
tmp.Add( wxGetTranslation( pin_style_names[ii] ) );
|
|
|
|
|
2009-11-16 21:37:53 +00:00
|
|
|
return tmp;
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int LIB_PIN::GetStyleCode( int index )
|
|
|
|
{
|
|
|
|
if( index >= 0 && index < (int) PIN_STYLE_CNT )
|
|
|
|
return pin_style_codes[ index ];
|
|
|
|
|
|
|
|
return NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int LIB_PIN::GetStyleCodeIndex( int code )
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for( i = 0; i < PIN_STYLE_CNT; i++ )
|
|
|
|
{
|
|
|
|
if( pin_style_codes[i] == code )
|
|
|
|
return (int) i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return wxNOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxArrayString LIB_PIN::GetElectricalTypeNames( void )
|
|
|
|
{
|
2009-11-16 21:37:53 +00:00
|
|
|
wxArrayString tmp;
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2009-11-16 21:37:53 +00:00
|
|
|
for( unsigned ii = 0; ii < PIN_ELECTRICAL_TYPE_CNT; ii++ )
|
2010-11-18 21:10:52 +00:00
|
|
|
tmp.Add( wxGetTranslation( pin_electrical_type_names[ii] ) );
|
|
|
|
|
2009-11-16 21:37:53 +00:00
|
|
|
return tmp;
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
2010-03-04 09:32:51 +00:00
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2010-03-04 09:32:51 +00:00
|
|
|
const char*** LIB_PIN::GetElectricalTypeSymbols( void )
|
|
|
|
{
|
|
|
|
return s_icons_Pins_Electrical_Type;
|
|
|
|
}
|
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2010-03-04 09:32:51 +00:00
|
|
|
const char*** LIB_PIN::GetOrientationSymbols()
|
|
|
|
{
|
|
|
|
return s_icons_Pins_Orientations;
|
|
|
|
}
|
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2010-03-04 09:32:51 +00:00
|
|
|
const char*** LIB_PIN::GetStyleSymbols()
|
|
|
|
{
|
|
|
|
return s_icons_Pins_Shapes;
|
|
|
|
}
|
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
const char** LIB_PIN::GetMenuImage() const
|
|
|
|
{
|
|
|
|
return s_icons_Pins_Electrical_Type[m_type];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString LIB_PIN::GetSelectMenuText() const
|
|
|
|
{
|
2011-03-26 10:08:50 +00:00
|
|
|
wxString tmp;
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2011-03-26 10:08:50 +00:00
|
|
|
tmp.Printf( _( "Pin %s, %s, %s" ),
|
|
|
|
GetChars( GetNumberString() ),
|
|
|
|
GetChars( GetTypeString() ),
|
|
|
|
GetChars( wxGetTranslation( pin_style_names[ GetStyleCodeIndex( m_shape ) ] ) )
|
2011-04-18 20:22:17 +00:00
|
|
|
);
|
2011-03-26 10:08:50 +00:00
|
|
|
return tmp;
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
|
2010-08-03 05:11:05 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
|
|
|
|
void LIB_PIN::Show( int nestLevel, std::ostream& os )
|
|
|
|
{
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
|
2010-12-07 16:10:42 +00:00
|
|
|
<< " num=\"" << GetNumberString().mb_str()
|
2010-08-03 05:11:05 +00:00
|
|
|
<< '"' << "/>\n";
|
|
|
|
|
|
|
|
|
|
|
|
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
|
|
|
|
}
|
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
|
2010-08-03 05:11:05 +00:00
|
|
|
#endif
|