Refactor pin orientation to be an enum class
Add various LIB_PIN properties
This commit is contained in:
parent
000fa28ffc
commit
148e111579
|
@ -533,6 +533,10 @@ target_include_directories( common SYSTEM PUBLIC
|
||||||
$<TARGET_PROPERTY:nanodbc,INTERFACE_INCLUDE_DIRECTORIES>
|
$<TARGET_PROPERTY:nanodbc,INTERFACE_INCLUDE_DIRECTORIES>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_include_directories( common PUBLIC
|
||||||
|
$<TARGET_PROPERTY:magic_enum,INTERFACE_INCLUDE_DIRECTORIES>
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
set( PCB_COMMON_SRCS
|
set( PCB_COMMON_SRCS
|
||||||
fp_lib_table.cpp
|
fp_lib_table.cpp
|
||||||
|
|
|
@ -234,14 +234,14 @@ protected:
|
||||||
*/
|
*/
|
||||||
SIDE getPinSide( SCH_PIN* aPin )
|
SIDE getPinSide( SCH_PIN* aPin )
|
||||||
{
|
{
|
||||||
int pin_orient = aPin->GetLibPin()->PinDrawOrient( m_symbol->GetTransform() );
|
PIN_ORIENTATION pin_orient = aPin->GetLibPin()->PinDrawOrient( m_symbol->GetTransform() );
|
||||||
|
|
||||||
switch( pin_orient )
|
switch( pin_orient )
|
||||||
{
|
{
|
||||||
case PIN_RIGHT: return SIDE_LEFT;
|
case PIN_ORIENTATION::PIN_RIGHT: return SIDE_LEFT;
|
||||||
case PIN_LEFT: return SIDE_RIGHT;
|
case PIN_ORIENTATION::PIN_LEFT: return SIDE_RIGHT;
|
||||||
case PIN_UP: return SIDE_BOTTOM;
|
case PIN_ORIENTATION::PIN_UP: return SIDE_BOTTOM;
|
||||||
case PIN_DOWN: return SIDE_TOP;
|
case PIN_ORIENTATION::PIN_DOWN: return SIDE_TOP;
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( wxS( "Invalid pin orientation" ) );
|
wxFAIL_MSG( wxS( "Invalid pin orientation" ) );
|
||||||
return SIDE_LEFT;
|
return SIDE_LEFT;
|
||||||
|
|
|
@ -329,10 +329,15 @@ public:
|
||||||
|
|
||||||
auto* cfg = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
auto* cfg = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
||||||
|
|
||||||
if( last->GetOrientation() == PIN_LEFT || last->GetOrientation() == PIN_RIGHT )
|
if( last->GetOrientation() == PIN_ORIENTATION::PIN_LEFT
|
||||||
|
|| last->GetOrientation() == PIN_ORIENTATION::PIN_RIGHT )
|
||||||
|
{
|
||||||
pos.y -= schIUScale.MilsToIU( cfg->m_Repeat.pin_step );
|
pos.y -= schIUScale.MilsToIU( cfg->m_Repeat.pin_step );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
pos.x += schIUScale.MilsToIU( cfg->m_Repeat.pin_step );
|
pos.x += schIUScale.MilsToIU( cfg->m_Repeat.pin_step );
|
||||||
|
}
|
||||||
|
|
||||||
newPin->SetPosition( pos );
|
newPin->SetPosition( pos );
|
||||||
|
|
||||||
|
@ -957,10 +962,15 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow( wxCommandEvent& event )
|
||||||
|
|
||||||
SYMBOL_EDITOR_SETTINGS* cfg = m_editFrame->GetSettings();
|
SYMBOL_EDITOR_SETTINGS* cfg = m_editFrame->GetSettings();
|
||||||
|
|
||||||
if( last->GetOrientation() == PIN_LEFT || last->GetOrientation() == PIN_RIGHT )
|
if( last->GetOrientation() == PIN_ORIENTATION::PIN_LEFT
|
||||||
|
|| last->GetOrientation() == PIN_ORIENTATION::PIN_RIGHT )
|
||||||
|
{
|
||||||
pos.y -= schIUScale.MilsToIU( cfg->m_Repeat.pin_step );
|
pos.y -= schIUScale.MilsToIU( cfg->m_Repeat.pin_step );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
pos.x += schIUScale.MilsToIU( cfg->m_Repeat.pin_step );
|
pos.x += schIUScale.MilsToIU( cfg->m_Repeat.pin_step );
|
||||||
|
}
|
||||||
|
|
||||||
newPin->SetPosition( pos );
|
newPin->SetPosition( pos );
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,7 +392,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||||
|
|
||||||
pin->SetPosition( MILS_POINT( p.x - 300, p.y + 100 ) );
|
pin->SetPosition( MILS_POINT( p.x - 300, p.y + 100 ) );
|
||||||
pin->SetLength( schIUScale.MilsToIU( 100 ) );
|
pin->SetLength( schIUScale.MilsToIU( 100 ) );
|
||||||
pin->SetOrientation( PIN_RIGHT );
|
pin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT );
|
||||||
pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
|
pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
|
||||||
pin->SetNumber( wxT( "1" ) );
|
pin->SetNumber( wxT( "1" ) );
|
||||||
pin->SetName( wxT( "-" ) );
|
pin->SetName( wxT( "-" ) );
|
||||||
|
@ -404,7 +404,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||||
|
|
||||||
pin->SetPosition( MILS_POINT( p.x - 300, p.y - 100 ) );
|
pin->SetPosition( MILS_POINT( p.x - 300, p.y - 100 ) );
|
||||||
pin->SetLength( schIUScale.MilsToIU( 100 ) );
|
pin->SetLength( schIUScale.MilsToIU( 100 ) );
|
||||||
pin->SetOrientation( PIN_RIGHT );
|
pin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT );
|
||||||
pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
|
pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
|
||||||
pin->SetNumber( wxT( "2" ) );
|
pin->SetNumber( wxT( "2" ) );
|
||||||
pin->SetName( wxT( "+" ) );
|
pin->SetName( wxT( "+" ) );
|
||||||
|
@ -416,7 +416,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||||
|
|
||||||
pin->SetPosition( MILS_POINT( p.x + 300, p.y ) );
|
pin->SetPosition( MILS_POINT( p.x + 300, p.y ) );
|
||||||
pin->SetLength( schIUScale.MilsToIU( 100 ) );
|
pin->SetLength( schIUScale.MilsToIU( 100 ) );
|
||||||
pin->SetOrientation( PIN_LEFT );
|
pin->SetOrientation( PIN_ORIENTATION::PIN_LEFT );
|
||||||
pin->SetType( ELECTRICAL_PINTYPE::PT_OUTPUT );
|
pin->SetType( ELECTRICAL_PINTYPE::PT_OUTPUT );
|
||||||
pin->SetNumber( wxT( "3" ) );
|
pin->SetNumber( wxT( "3" ) );
|
||||||
pin->SetName( wxT( "OUT" ) );
|
pin->SetName( wxT( "OUT" ) );
|
||||||
|
|
|
@ -96,7 +96,7 @@ static int externalPinDecoSize( const RENDER_SETTINGS* aSettings, const LIB_PIN
|
||||||
|
|
||||||
LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent ) :
|
LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent ) :
|
||||||
LIB_ITEM( LIB_PIN_T, aParent ),
|
LIB_ITEM( LIB_PIN_T, aParent ),
|
||||||
m_orientation( PIN_RIGHT ),
|
m_orientation( PIN_ORIENTATION::PIN_RIGHT ),
|
||||||
m_shape( GRAPHIC_PINSHAPE::LINE ),
|
m_shape( GRAPHIC_PINSHAPE::LINE ),
|
||||||
m_type( ELECTRICAL_PINTYPE::PT_UNSPECIFIED ),
|
m_type( ELECTRICAL_PINTYPE::PT_UNSPECIFIED ),
|
||||||
m_attributes( 0 )
|
m_attributes( 0 )
|
||||||
|
@ -122,8 +122,9 @@ LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent ) :
|
||||||
|
|
||||||
|
|
||||||
LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aNumber,
|
LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aNumber,
|
||||||
int aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength, int aNameTextSize,
|
PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength,
|
||||||
int aNumTextSize, int aConvert, const VECTOR2I& aPos, int aUnit ) :
|
int aNameTextSize, int aNumTextSize, int aConvert, const VECTOR2I& aPos,
|
||||||
|
int aUnit ) :
|
||||||
LIB_ITEM( LIB_PIN_T, aParent ),
|
LIB_ITEM( LIB_PIN_T, aParent ),
|
||||||
m_position( aPos ),
|
m_position( aPos ),
|
||||||
m_length( aLength ),
|
m_length( aLength ),
|
||||||
|
@ -186,10 +187,10 @@ VECTOR2I LIB_PIN::GetPinRoot() const
|
||||||
switch( m_orientation )
|
switch( m_orientation )
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case PIN_RIGHT: return VECTOR2I( m_position.x + m_length, -( m_position.y ) );
|
case PIN_ORIENTATION::PIN_RIGHT: return VECTOR2I( m_position.x + m_length, -( m_position.y ) );
|
||||||
case PIN_LEFT: return VECTOR2I( m_position.x - m_length, -( m_position.y ) );
|
case PIN_ORIENTATION::PIN_LEFT: return VECTOR2I( m_position.x - m_length, -( m_position.y ) );
|
||||||
case PIN_UP: return VECTOR2I( m_position.x, -( m_position.y + m_length ) );
|
case PIN_ORIENTATION::PIN_UP: return VECTOR2I( m_position.x, -( m_position.y + m_length ) );
|
||||||
case PIN_DOWN: return VECTOR2I( m_position.x, -( m_position.y - m_length ) );
|
case PIN_ORIENTATION::PIN_DOWN: return VECTOR2I( m_position.x, -( m_position.y - m_length ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +208,7 @@ void LIB_PIN::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||||
wxCHECK( part && opts, /* void */ );
|
wxCHECK( part && opts, /* void */ );
|
||||||
|
|
||||||
/* Calculate pin orient taking in account the symbol orientation. */
|
/* Calculate pin orient taking in account the symbol orientation. */
|
||||||
int orient = PinDrawOrient( aTransform );
|
PIN_ORIENTATION orient = PinDrawOrient( aTransform );
|
||||||
|
|
||||||
/* Calculate the pin position */
|
/* Calculate the pin position */
|
||||||
VECTOR2I pos1 = aTransform.TransformCoordinate( m_position ) + aOffset;
|
VECTOR2I pos1 = aTransform.TransformCoordinate( m_position ) + aOffset;
|
||||||
|
@ -248,7 +249,8 @@ void LIB_PIN::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_PIN::printPinSymbol( const RENDER_SETTINGS* aSettings, const VECTOR2I& aPos, int aOrient, bool aDimmed )
|
void LIB_PIN::printPinSymbol( const RENDER_SETTINGS* aSettings, const VECTOR2I& aPos,
|
||||||
|
PIN_ORIENTATION aOrient, bool aDimmed )
|
||||||
{
|
{
|
||||||
wxDC* DC = aSettings->GetPrintDC();
|
wxDC* DC = aSettings->GetPrintDC();
|
||||||
int MapX1, MapY1, x1, y1;
|
int MapX1, MapY1, x1, y1;
|
||||||
|
@ -275,10 +277,10 @@ void LIB_PIN::printPinSymbol( const RENDER_SETTINGS* aSettings, const VECTOR2I&
|
||||||
|
|
||||||
switch( aOrient )
|
switch( aOrient )
|
||||||
{
|
{
|
||||||
case PIN_UP: y1 = posY - len; MapY1 = 1; break;
|
case PIN_ORIENTATION::PIN_UP: y1 = posY - len; MapY1 = 1; break;
|
||||||
case PIN_DOWN: y1 = posY + len; MapY1 = -1; break;
|
case PIN_ORIENTATION::PIN_DOWN: y1 = posY + len; MapY1 = -1; break;
|
||||||
case PIN_LEFT: x1 = posX - len; MapX1 = 1; break;
|
case PIN_ORIENTATION::PIN_LEFT: x1 = posX - len; MapX1 = 1; break;
|
||||||
case PIN_RIGHT: x1 = posX + len; MapX1 = -1; break;
|
case PIN_ORIENTATION::PIN_RIGHT: x1 = posX + len; MapX1 = -1; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_shape == GRAPHIC_PINSHAPE::INVERTED || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK )
|
if( m_shape == GRAPHIC_PINSHAPE::INVERTED || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK )
|
||||||
|
@ -372,8 +374,9 @@ void LIB_PIN::printPinSymbol( const RENDER_SETTINGS* aSettings, const VECTOR2I&
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos, int aPinOrient,
|
void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos,
|
||||||
int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed )
|
PIN_ORIENTATION aPinOrient, int aTextInside, bool aDrawPinNum,
|
||||||
|
bool aDrawPinName, bool aDimmed )
|
||||||
{
|
{
|
||||||
if( !aDrawPinName && !aDrawPinNum )
|
if( !aDrawPinName && !aDrawPinNum )
|
||||||
return;
|
return;
|
||||||
|
@ -417,10 +420,10 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
|
||||||
|
|
||||||
switch( aPinOrient )
|
switch( aPinOrient )
|
||||||
{
|
{
|
||||||
case PIN_UP: y1 -= m_length; break;
|
case PIN_ORIENTATION::PIN_UP: y1 -= m_length; break;
|
||||||
case PIN_DOWN: y1 += m_length; break;
|
case PIN_ORIENTATION::PIN_DOWN: y1 += m_length; break;
|
||||||
case PIN_LEFT: x1 -= m_length; break;
|
case PIN_ORIENTATION::PIN_LEFT: x1 -= m_length; break;
|
||||||
case PIN_RIGHT: x1 += m_length; break;
|
case PIN_ORIENTATION::PIN_RIGHT: x1 += m_length; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString name = GetShownName();
|
wxString name = GetShownName();
|
||||||
|
@ -434,12 +437,13 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
|
||||||
|
|
||||||
if( aTextInside ) // Draw the text inside, but the pin numbers outside.
|
if( aTextInside ) // Draw the text inside, but the pin numbers outside.
|
||||||
{
|
{
|
||||||
if(( aPinOrient == PIN_LEFT) || ( aPinOrient == PIN_RIGHT) )
|
if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
|
||||||
|
|| ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
|
||||||
{
|
{
|
||||||
// It is an horizontal line
|
// It is an horizontal line
|
||||||
if( aDrawPinName )
|
if( aDrawPinName )
|
||||||
{
|
{
|
||||||
if( aPinOrient == PIN_RIGHT )
|
if( aPinOrient == PIN_ORIENTATION::PIN_RIGHT )
|
||||||
{
|
{
|
||||||
x = x1 + aTextInside;
|
x = x1 + aTextInside;
|
||||||
GRPrintText( DC, VECTOR2I( x, y1 ), nameColor, name, ANGLE_HORIZONTAL,
|
GRPrintText( DC, VECTOR2I( x, y1 ), nameColor, name, ANGLE_HORIZONTAL,
|
||||||
|
@ -465,7 +469,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
|
||||||
else /* Its a vertical line. */
|
else /* Its a vertical line. */
|
||||||
{
|
{
|
||||||
// Text is drawn from bottom to top (i.e. to negative value for Y axis)
|
// Text is drawn from bottom to top (i.e. to negative value for Y axis)
|
||||||
if( aPinOrient == PIN_DOWN )
|
if( aPinOrient == PIN_ORIENTATION::PIN_DOWN )
|
||||||
{
|
{
|
||||||
y = y1 + aTextInside;
|
y = y1 + aTextInside;
|
||||||
|
|
||||||
|
@ -505,7 +509,8 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
|
||||||
}
|
}
|
||||||
else /**** Draw num & text pin outside ****/
|
else /**** Draw num & text pin outside ****/
|
||||||
{
|
{
|
||||||
if( ( aPinOrient == PIN_LEFT) || ( aPinOrient == PIN_RIGHT) )
|
if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
|
||||||
|
|| ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
|
||||||
{
|
{
|
||||||
/* Its an horizontal line. */
|
/* Its an horizontal line. */
|
||||||
if( aDrawPinName )
|
if( aDrawPinName )
|
||||||
|
@ -544,9 +549,8 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECTOR2I& aPosition,
|
void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECTOR2I& aPosition,
|
||||||
int aOrientation, bool aDimmed )
|
PIN_ORIENTATION aOrientation, bool aDimmed )
|
||||||
{
|
{
|
||||||
wxDC* DC = aSettings->GetPrintDC();
|
wxDC* DC = aSettings->GetPrintDC();
|
||||||
wxString typeName = GetElectricalTypeName();
|
wxString typeName = GetElectricalTypeName();
|
||||||
|
@ -586,22 +590,22 @@ void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECT
|
||||||
|
|
||||||
switch( aOrientation )
|
switch( aOrientation )
|
||||||
{
|
{
|
||||||
case PIN_UP:
|
case PIN_ORIENTATION::PIN_UP:
|
||||||
txtpos.y += offset;
|
txtpos.y += offset;
|
||||||
orient = ANGLE_VERTICAL;
|
orient = ANGLE_VERTICAL;
|
||||||
hjustify = GR_TEXT_H_ALIGN_RIGHT;
|
hjustify = GR_TEXT_H_ALIGN_RIGHT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIN_DOWN:
|
case PIN_ORIENTATION::PIN_DOWN:
|
||||||
txtpos.y -= offset;
|
txtpos.y -= offset;
|
||||||
orient = ANGLE_VERTICAL;
|
orient = ANGLE_VERTICAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIN_LEFT:
|
case PIN_ORIENTATION::PIN_LEFT:
|
||||||
txtpos.x += offset;
|
txtpos.x += offset;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIN_RIGHT:
|
case PIN_ORIENTATION::PIN_RIGHT:
|
||||||
txtpos.x -= offset;
|
txtpos.x -= offset;
|
||||||
hjustify = GR_TEXT_H_ALIGN_RIGHT;
|
hjustify = GR_TEXT_H_ALIGN_RIGHT;
|
||||||
break;
|
break;
|
||||||
|
@ -612,8 +616,8 @@ void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_PIN::PlotSymbol( PLOTTER *aPlotter, const VECTOR2I &aPosition, int aOrientation,
|
void LIB_PIN::PlotSymbol( PLOTTER *aPlotter, const VECTOR2I &aPosition,
|
||||||
bool aDimmed ) const
|
PIN_ORIENTATION aOrientation, bool aDimmed ) const
|
||||||
{
|
{
|
||||||
int MapX1, MapY1, x1, y1;
|
int MapX1, MapY1, x1, y1;
|
||||||
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( LAYER_PIN );
|
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( LAYER_PIN );
|
||||||
|
@ -637,10 +641,10 @@ void LIB_PIN::PlotSymbol( PLOTTER *aPlotter, const VECTOR2I &aPosition, int aOri
|
||||||
|
|
||||||
switch( aOrientation )
|
switch( aOrientation )
|
||||||
{
|
{
|
||||||
case PIN_UP: y1 = aPosition.y - m_length; MapY1 = 1; break;
|
case PIN_ORIENTATION::PIN_UP: y1 = aPosition.y - m_length; MapY1 = 1; break;
|
||||||
case PIN_DOWN: y1 = aPosition.y + m_length; MapY1 = -1; break;
|
case PIN_ORIENTATION::PIN_DOWN: y1 = aPosition.y + m_length; MapY1 = -1; break;
|
||||||
case PIN_LEFT: x1 = aPosition.x - m_length; MapX1 = 1; break;
|
case PIN_ORIENTATION::PIN_LEFT: x1 = aPosition.x - m_length; MapX1 = 1; break;
|
||||||
case PIN_RIGHT: x1 = aPosition.x + m_length; MapX1 = -1; break;
|
case PIN_ORIENTATION::PIN_RIGHT: x1 = aPosition.x + m_length; MapX1 = -1; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_shape == GRAPHIC_PINSHAPE::INVERTED || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK )
|
if( m_shape == GRAPHIC_PINSHAPE::INVERTED || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK )
|
||||||
|
@ -755,8 +759,10 @@ void LIB_PIN::PlotSymbol( PLOTTER *aPlotter, const VECTOR2I &aPosition, int aOri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LIB_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, int aPinOrient,
|
|
||||||
int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed ) const
|
void LIB_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient,
|
||||||
|
int aTextInside, bool aDrawPinNum, bool aDrawPinName,
|
||||||
|
bool aDimmed ) const
|
||||||
{
|
{
|
||||||
RENDER_SETTINGS* settings = aPlotter->RenderSettings();
|
RENDER_SETTINGS* settings = aPlotter->RenderSettings();
|
||||||
KIFONT::FONT* font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), false, false );
|
KIFONT::FONT* font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), false, false );
|
||||||
|
@ -801,10 +807,10 @@ void LIB_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, int aPin
|
||||||
|
|
||||||
switch( aPinOrient )
|
switch( aPinOrient )
|
||||||
{
|
{
|
||||||
case PIN_UP: y1 -= m_length; break;
|
case PIN_ORIENTATION::PIN_UP: y1 -= m_length; break;
|
||||||
case PIN_DOWN: y1 += m_length; break;
|
case PIN_ORIENTATION::PIN_DOWN: y1 += m_length; break;
|
||||||
case PIN_LEFT: x1 -= m_length; break;
|
case PIN_ORIENTATION::PIN_LEFT: x1 -= m_length; break;
|
||||||
case PIN_RIGHT: x1 += m_length; break;
|
case PIN_ORIENTATION::PIN_RIGHT: x1 += m_length; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto plotText =
|
auto plotText =
|
||||||
|
@ -826,12 +832,14 @@ void LIB_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, int aPin
|
||||||
/* Draw the text inside, but the pin numbers outside. */
|
/* Draw the text inside, but the pin numbers outside. */
|
||||||
if( aTextInside )
|
if( aTextInside )
|
||||||
{
|
{
|
||||||
if( ( aPinOrient == PIN_LEFT) || ( aPinOrient == PIN_RIGHT) ) /* Its an horizontal line. */
|
if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
|
||||||
|
|| ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) ) /* Its an horizontal line. */
|
||||||
{
|
{
|
||||||
if( aDrawPinName )
|
if( aDrawPinName )
|
||||||
{
|
{
|
||||||
GR_TEXT_H_ALIGN_T hjustify;
|
GR_TEXT_H_ALIGN_T hjustify;
|
||||||
if( aPinOrient == PIN_RIGHT )
|
|
||||||
|
if( aPinOrient == PIN_ORIENTATION::PIN_RIGHT )
|
||||||
{
|
{
|
||||||
x = x1 + aTextInside;
|
x = x1 + aTextInside;
|
||||||
hjustify = GR_TEXT_H_ALIGN_LEFT;
|
hjustify = GR_TEXT_H_ALIGN_LEFT;
|
||||||
|
@ -855,7 +863,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, int aPin
|
||||||
}
|
}
|
||||||
else /* Its a vertical line. */
|
else /* Its a vertical line. */
|
||||||
{
|
{
|
||||||
if( aPinOrient == PIN_DOWN )
|
if( aPinOrient == PIN_ORIENTATION::PIN_DOWN )
|
||||||
{
|
{
|
||||||
y = y1 + aTextInside;
|
y = y1 + aTextInside;
|
||||||
|
|
||||||
|
@ -893,7 +901,8 @@ void LIB_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, int aPin
|
||||||
}
|
}
|
||||||
else /* Draw num & text pin outside */
|
else /* Draw num & text pin outside */
|
||||||
{
|
{
|
||||||
if(( aPinOrient == PIN_LEFT) || ( aPinOrient == PIN_RIGHT) )
|
if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
|
||||||
|
|| ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
|
||||||
{
|
{
|
||||||
/* Its an horizontal line. */
|
/* Its an horizontal line. */
|
||||||
if( aDrawPinName )
|
if( aDrawPinName )
|
||||||
|
@ -929,34 +938,34 @@ void LIB_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, int aPin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const
|
PIN_ORIENTATION LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const
|
||||||
{
|
{
|
||||||
int orient;
|
PIN_ORIENTATION orient;
|
||||||
VECTOR2I end; // position of pin end starting at 0,0 according to its orientation, length = 1
|
VECTOR2I end; // position of pin end starting at 0,0 according to its orientation, length = 1
|
||||||
|
|
||||||
switch( m_orientation )
|
switch( m_orientation )
|
||||||
{
|
{
|
||||||
case PIN_UP: end.y = 1; break;
|
case PIN_ORIENTATION::PIN_UP: end.y = 1; break;
|
||||||
case PIN_DOWN: end.y = -1; break;
|
case PIN_ORIENTATION::PIN_DOWN: end.y = -1; break;
|
||||||
case PIN_LEFT: end.x = -1; break;
|
case PIN_ORIENTATION::PIN_LEFT: end.x = -1; break;
|
||||||
case PIN_RIGHT: end.x = 1; break;
|
case PIN_ORIENTATION::PIN_RIGHT: end.x = 1; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// = pos of end point, according to the symbol orientation.
|
// = pos of end point, according to the symbol orientation.
|
||||||
end = aTransform.TransformCoordinate( end );
|
end = aTransform.TransformCoordinate( end );
|
||||||
orient = PIN_UP;
|
orient = PIN_ORIENTATION::PIN_UP;
|
||||||
|
|
||||||
if( end.x == 0 )
|
if( end.x == 0 )
|
||||||
{
|
{
|
||||||
if( end.y > 0 )
|
if( end.y > 0 )
|
||||||
orient = PIN_DOWN;
|
orient = PIN_ORIENTATION::PIN_DOWN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
orient = PIN_RIGHT;
|
orient = PIN_ORIENTATION::PIN_RIGHT;
|
||||||
|
|
||||||
if( end.x < 0 )
|
if( end.x < 0 )
|
||||||
orient = PIN_LEFT;
|
orient = PIN_ORIENTATION::PIN_LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return orient;
|
return orient;
|
||||||
|
@ -1000,7 +1009,7 @@ int LIB_PIN::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||||
return m_length - tmp->m_length;
|
return m_length - tmp->m_length;
|
||||||
|
|
||||||
if( m_orientation != tmp->m_orientation )
|
if( m_orientation != tmp->m_orientation )
|
||||||
return m_orientation - tmp->m_orientation;
|
return static_cast<int>( m_orientation ) - static_cast<int>( tmp->m_orientation );
|
||||||
|
|
||||||
if( m_shape != tmp->m_shape )
|
if( m_shape != tmp->m_shape )
|
||||||
return static_cast<int>( m_shape ) - static_cast<int>( tmp->m_shape );
|
return static_cast<int>( m_shape ) - static_cast<int>( tmp->m_shape );
|
||||||
|
@ -1054,16 +1063,16 @@ void LIB_PIN::ChangeLength( int aLength )
|
||||||
|
|
||||||
switch( m_orientation )
|
switch( m_orientation )
|
||||||
{
|
{
|
||||||
case PIN_RIGHT:
|
case PIN_ORIENTATION::PIN_RIGHT:
|
||||||
offsetX = lengthChange;
|
offsetX = lengthChange;
|
||||||
break;
|
break;
|
||||||
case PIN_LEFT:
|
case PIN_ORIENTATION::PIN_LEFT:
|
||||||
offsetX = -1 * lengthChange;
|
offsetX = -1 * lengthChange;
|
||||||
break;
|
break;
|
||||||
case PIN_UP:
|
case PIN_ORIENTATION::PIN_UP:
|
||||||
offsetY = lengthChange;
|
offsetY = lengthChange;
|
||||||
break;
|
break;
|
||||||
case PIN_DOWN:
|
case PIN_ORIENTATION::PIN_DOWN:
|
||||||
offsetY = -1 * lengthChange;
|
offsetY = -1 * lengthChange;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1092,10 +1101,10 @@ void LIB_PIN::MirrorHorizontal( const VECTOR2I& aCenter )
|
||||||
m_position.x *= -1;
|
m_position.x *= -1;
|
||||||
m_position.x += aCenter.x;
|
m_position.x += aCenter.x;
|
||||||
|
|
||||||
if( m_orientation == PIN_RIGHT )
|
if( m_orientation == PIN_ORIENTATION::PIN_RIGHT )
|
||||||
m_orientation = PIN_LEFT;
|
m_orientation = PIN_ORIENTATION::PIN_LEFT;
|
||||||
else if( m_orientation == PIN_LEFT )
|
else if( m_orientation == PIN_ORIENTATION::PIN_LEFT )
|
||||||
m_orientation = PIN_RIGHT;
|
m_orientation = PIN_ORIENTATION::PIN_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1105,10 +1114,10 @@ void LIB_PIN::MirrorVertical( const VECTOR2I& aCenter )
|
||||||
m_position.y *= -1;
|
m_position.y *= -1;
|
||||||
m_position.y += aCenter.y;
|
m_position.y += aCenter.y;
|
||||||
|
|
||||||
if( m_orientation == PIN_UP )
|
if( m_orientation == PIN_ORIENTATION::PIN_UP )
|
||||||
m_orientation = PIN_DOWN;
|
m_orientation = PIN_ORIENTATION::PIN_DOWN;
|
||||||
else if( m_orientation == PIN_DOWN )
|
else if( m_orientation == PIN_ORIENTATION::PIN_DOWN )
|
||||||
m_orientation = PIN_UP;
|
m_orientation = PIN_ORIENTATION::PIN_UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1122,20 +1131,20 @@ void LIB_PIN::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
|
||||||
{
|
{
|
||||||
switch( m_orientation )
|
switch( m_orientation )
|
||||||
{
|
{
|
||||||
case PIN_RIGHT: m_orientation = PIN_UP; break;
|
case PIN_ORIENTATION::PIN_RIGHT: m_orientation = PIN_ORIENTATION::PIN_UP; break;
|
||||||
case PIN_UP: m_orientation = PIN_LEFT; break;
|
case PIN_ORIENTATION::PIN_UP: m_orientation = PIN_ORIENTATION::PIN_LEFT; break;
|
||||||
case PIN_LEFT: m_orientation = PIN_DOWN; break;
|
case PIN_ORIENTATION::PIN_LEFT: m_orientation = PIN_ORIENTATION::PIN_DOWN; break;
|
||||||
case PIN_DOWN: m_orientation = PIN_RIGHT; break;
|
case PIN_ORIENTATION::PIN_DOWN: m_orientation = PIN_ORIENTATION::PIN_RIGHT; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch( m_orientation )
|
switch( m_orientation )
|
||||||
{
|
{
|
||||||
case PIN_RIGHT: m_orientation = PIN_DOWN; break;
|
case PIN_ORIENTATION::PIN_RIGHT: m_orientation = PIN_ORIENTATION::PIN_DOWN; break;
|
||||||
case PIN_UP: m_orientation = PIN_RIGHT; break;
|
case PIN_ORIENTATION::PIN_UP: m_orientation = PIN_ORIENTATION::PIN_RIGHT; break;
|
||||||
case PIN_LEFT: m_orientation = PIN_UP; break;
|
case PIN_ORIENTATION::PIN_LEFT: m_orientation = PIN_ORIENTATION::PIN_UP; break;
|
||||||
case PIN_DOWN: m_orientation = PIN_LEFT; break;
|
case PIN_ORIENTATION::PIN_DOWN: m_orientation = PIN_ORIENTATION::PIN_LEFT; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1147,7 +1156,7 @@ void LIB_PIN::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset
|
||||||
if( !IsVisible() || aBackground )
|
if( !IsVisible() || aBackground )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int orient = PinDrawOrient( aTransform );
|
PIN_ORIENTATION orient = PinDrawOrient( aTransform );
|
||||||
VECTOR2I pos = aTransform.TransformCoordinate( m_position ) + aOffset;
|
VECTOR2I pos = aTransform.TransformCoordinate( m_position ) + aOffset;
|
||||||
|
|
||||||
PlotSymbol( aPlotter, pos, orient, aDimmed );
|
PlotSymbol( aPlotter, pos, orient, aDimmed );
|
||||||
|
@ -1171,8 +1180,7 @@ void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
|
||||||
// Display pin length
|
// Display pin length
|
||||||
aList.emplace_back( _( "Length" ), aFrame->MessageTextFromValue( m_length, true ) );
|
aList.emplace_back( _( "Length" ), aFrame->MessageTextFromValue( m_length, true ) );
|
||||||
|
|
||||||
int i = PinOrientationIndex( m_orientation );
|
aList.emplace_back( _( "Orientation" ), PinOrientationName( m_orientation ) );
|
||||||
aList.emplace_back( _( "Orientation" ), PinOrientationName( (unsigned) i ) );
|
|
||||||
|
|
||||||
VECTOR2I pinpos = GetPosition();
|
VECTOR2I pinpos = GetPosition();
|
||||||
pinpos.y = -pinpos.y; // Display coords are top to bottom; lib item coords are bottom to top
|
pinpos.y = -pinpos.y; // Display coords are top to bottom; lib item coords are bottom to top
|
||||||
|
@ -1326,30 +1334,30 @@ const BOX2I LIB_PIN::GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, calculate boundary box corners position for the actual pin orientation
|
// Now, calculate boundary box corners position for the actual pin orientation
|
||||||
int orient = PinDrawOrient( DefaultTransform );
|
PIN_ORIENTATION orient = PinDrawOrient( DefaultTransform );
|
||||||
|
|
||||||
/* Calculate the pin position */
|
/* Calculate the pin position */
|
||||||
switch( orient )
|
switch( orient )
|
||||||
{
|
{
|
||||||
case PIN_UP:
|
case PIN_ORIENTATION::PIN_UP:
|
||||||
// Pin is rotated and texts positions are mirrored
|
// Pin is rotated and texts positions are mirrored
|
||||||
RotatePoint( begin, VECTOR2I( 0, 0 ), -ANGLE_90 );
|
RotatePoint( begin, VECTOR2I( 0, 0 ), -ANGLE_90 );
|
||||||
RotatePoint( end, VECTOR2I( 0, 0 ), -ANGLE_90 );
|
RotatePoint( end, VECTOR2I( 0, 0 ), -ANGLE_90 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIN_DOWN:
|
case PIN_ORIENTATION::PIN_DOWN:
|
||||||
RotatePoint( begin, VECTOR2I( 0, 0 ), ANGLE_90 );
|
RotatePoint( begin, VECTOR2I( 0, 0 ), ANGLE_90 );
|
||||||
RotatePoint( end, VECTOR2I( 0, 0 ), ANGLE_90 );
|
RotatePoint( end, VECTOR2I( 0, 0 ), ANGLE_90 );
|
||||||
begin.x = -begin.x;
|
begin.x = -begin.x;
|
||||||
end.x = -end.x;
|
end.x = -end.x;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIN_LEFT:
|
case PIN_ORIENTATION::PIN_LEFT:
|
||||||
begin.x = -begin.x;
|
begin.x = -begin.x;
|
||||||
end.x = -end.x;
|
end.x = -end.x;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIN_RIGHT:
|
case PIN_ORIENTATION::PIN_RIGHT:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1463,17 +1471,88 @@ static struct LIB_PIN_DESC
|
||||||
{
|
{
|
||||||
LIB_PIN_DESC()
|
LIB_PIN_DESC()
|
||||||
{
|
{
|
||||||
|
auto& pinTypeEnum = ENUM_MAP<ELECTRICAL_PINTYPE>::Instance();
|
||||||
|
|
||||||
|
if( pinTypeEnum.Choices().GetCount() == 0 )
|
||||||
|
{
|
||||||
|
pinTypeEnum.Map( ELECTRICAL_PINTYPE::PT_INPUT, _HKI( "Input" ) )
|
||||||
|
.Map( ELECTRICAL_PINTYPE::PT_OUTPUT, _HKI( "Output" ) )
|
||||||
|
.Map( ELECTRICAL_PINTYPE::PT_BIDI, _HKI( "Bidirectional" ) )
|
||||||
|
.Map( ELECTRICAL_PINTYPE::PT_TRISTATE, _HKI( "Tri-state" ) )
|
||||||
|
.Map( ELECTRICAL_PINTYPE::PT_PASSIVE, _HKI( "Passive" ) )
|
||||||
|
.Map( ELECTRICAL_PINTYPE::PT_NIC, _HKI( "Free" ) )
|
||||||
|
.Map( ELECTRICAL_PINTYPE::PT_UNSPECIFIED, _HKI( "Unspecified" ) )
|
||||||
|
.Map( ELECTRICAL_PINTYPE::PT_POWER_IN, _HKI( "Power input" ) )
|
||||||
|
.Map( ELECTRICAL_PINTYPE::PT_POWER_OUT, _HKI( "Power output" ) )
|
||||||
|
.Map( ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR, _HKI( "Open collector" ) )
|
||||||
|
.Map( ELECTRICAL_PINTYPE::PT_OPENEMITTER, _HKI( "Open emitter" ) )
|
||||||
|
.Map( ELECTRICAL_PINTYPE::PT_NC, _HKI( "Unconnected" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& pinShapeEnum = ENUM_MAP<GRAPHIC_PINSHAPE>::Instance();
|
||||||
|
|
||||||
|
if( pinShapeEnum.Choices().GetCount() == 0 )
|
||||||
|
{
|
||||||
|
pinShapeEnum.Map( GRAPHIC_PINSHAPE::LINE, _HKI( "Line" ) )
|
||||||
|
.Map( GRAPHIC_PINSHAPE::INVERTED, _HKI( "Inverted" ) )
|
||||||
|
.Map( GRAPHIC_PINSHAPE::CLOCK, _HKI( "Clock" ) )
|
||||||
|
.Map( GRAPHIC_PINSHAPE::INVERTED_CLOCK, _HKI( "Inverted clock" ) )
|
||||||
|
.Map( GRAPHIC_PINSHAPE::INPUT_LOW, _HKI( "Input low" ) )
|
||||||
|
.Map( GRAPHIC_PINSHAPE::CLOCK_LOW, _HKI( "Clock low" ) )
|
||||||
|
.Map( GRAPHIC_PINSHAPE::OUTPUT_LOW, _HKI( "Output low" ) )
|
||||||
|
.Map( GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK, _HKI( "Falling edge clock" ) )
|
||||||
|
.Map( GRAPHIC_PINSHAPE::NONLOGIC, _HKI( "NonLogic" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& orientationEnum = ENUM_MAP<PIN_ORIENTATION>::Instance();
|
||||||
|
|
||||||
|
if( orientationEnum.Choices().GetCount() == 0 )
|
||||||
|
{
|
||||||
|
orientationEnum.Map( PIN_ORIENTATION::PIN_RIGHT, _( "Right" ) )
|
||||||
|
.Map( PIN_ORIENTATION::PIN_LEFT, _( "Left" ) )
|
||||||
|
.Map( PIN_ORIENTATION::PIN_UP, _( "Up" ) )
|
||||||
|
.Map( PIN_ORIENTATION::PIN_DOWN, _( "Down" ) );
|
||||||
|
}
|
||||||
|
|
||||||
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
||||||
REGISTER_TYPE( LIB_PIN );
|
REGISTER_TYPE( LIB_PIN );
|
||||||
propMgr.InheritsAfter( TYPE_HASH( LIB_PIN ), TYPE_HASH( SCH_ITEM ) );
|
propMgr.InheritsAfter( TYPE_HASH( LIB_PIN ), TYPE_HASH( SCH_ITEM ) );
|
||||||
|
|
||||||
propMgr.AddProperty( new PROPERTY<LIB_PIN, wxString>( _HKI( "Pin Name" ),
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, wxString>( _HKI( "Pin Name" ),
|
||||||
NO_SETTER( LIB_PIN, wxString ), &LIB_PIN::GetName ) );
|
&LIB_PIN::SetName, &LIB_PIN::GetName ) );
|
||||||
|
|
||||||
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Name Text Size" ),
|
||||||
|
&LIB_PIN::SetNameTextSize, &LIB_PIN::GetNameTextSize, PROPERTY_DISPLAY::PT_SIZE ) );
|
||||||
|
|
||||||
propMgr.AddProperty( new PROPERTY<LIB_PIN, wxString>( _HKI( "Pin Number" ),
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, wxString>( _HKI( "Pin Number" ),
|
||||||
NO_SETTER( LIB_PIN, wxString ), &LIB_PIN::GetNumber ) );
|
&LIB_PIN::SetNumber, &LIB_PIN::GetNumber ) );
|
||||||
|
|
||||||
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Number Text Size" ),
|
||||||
|
&LIB_PIN::SetNumberTextSize, &LIB_PIN::GetNumberTextSize,
|
||||||
|
PROPERTY_DISPLAY::PT_SIZE ) );
|
||||||
|
|
||||||
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Length" ),
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Length" ),
|
||||||
NO_SETTER( LIB_PIN, int ), &LIB_PIN::GetLength, PROPERTY_DISPLAY::PT_SIZE ) );
|
&LIB_PIN::SetLength, &LIB_PIN::GetLength, PROPERTY_DISPLAY::PT_SIZE ) );
|
||||||
|
|
||||||
|
propMgr.AddProperty( new PROPERTY_ENUM<LIB_PIN,
|
||||||
|
ELECTRICAL_PINTYPE>( _HKI( "Electrical Type" ),
|
||||||
|
&LIB_PIN::SetType, &LIB_PIN::GetType ) );
|
||||||
|
|
||||||
|
propMgr.AddProperty( new PROPERTY_ENUM<LIB_PIN, GRAPHIC_PINSHAPE>( _HKI( "Graphic Style" ),
|
||||||
|
&LIB_PIN::SetShape, &LIB_PIN::GetShape ) );
|
||||||
|
|
||||||
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Position X" ),
|
||||||
|
&LIB_PIN::SetX, &LIB_PIN::GetX, PROPERTY_DISPLAY::PT_COORD ) );
|
||||||
|
|
||||||
|
propMgr.AddProperty( new PROPERTY<LIB_PIN, int>( _HKI( "Position Y" ),
|
||||||
|
&LIB_PIN::SetY, &LIB_PIN::GetY, PROPERTY_DISPLAY::PT_COORD ) );
|
||||||
|
|
||||||
|
propMgr.AddProperty( new PROPERTY_ENUM<LIB_PIN, PIN_ORIENTATION>( _HKI( "Orientation" ),
|
||||||
|
&LIB_PIN::SetOrientation, &LIB_PIN::GetOrientation ) );
|
||||||
}
|
}
|
||||||
} _LIB_PIN_DESC;
|
} _LIB_PIN_DESC;
|
||||||
|
|
||||||
|
|
||||||
|
ENUM_TO_WXANY( PIN_ORIENTATION )
|
||||||
|
ENUM_TO_WXANY( GRAPHIC_PINSHAPE )
|
||||||
|
ENUM_TO_WXANY( ELECTRICAL_PINTYPE )
|
||||||
|
|
|
@ -38,17 +38,6 @@
|
||||||
#define PIN_INVISIBLE 1 // Set makes pin invisible
|
#define PIN_INVISIBLE 1 // Set makes pin invisible
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The symbol library pin object orientations.
|
|
||||||
*/
|
|
||||||
enum DrawPinOrient {
|
|
||||||
PIN_RIGHT = 'R',
|
|
||||||
PIN_LEFT = 'L',
|
|
||||||
PIN_UP = 'U',
|
|
||||||
PIN_DOWN = 'D'
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class LIB_PIN : public LIB_ITEM
|
class LIB_PIN : public LIB_ITEM
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -76,8 +65,8 @@ public:
|
||||||
return _( "Pin" );
|
return _( "Pin" );
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetOrientation() const { return m_orientation; }
|
PIN_ORIENTATION GetOrientation() const { return m_orientation; }
|
||||||
void SetOrientation( int aOrientation ) { m_orientation = aOrientation; }
|
void SetOrientation( PIN_ORIENTATION aOrientation ) { m_orientation = aOrientation; }
|
||||||
|
|
||||||
GRAPHIC_PINSHAPE GetShape() const { return m_shape; }
|
GRAPHIC_PINSHAPE GetShape() const { return m_shape; }
|
||||||
void SetShape( GRAPHIC_PINSHAPE aShape ) { m_shape = aShape; }
|
void SetShape( GRAPHIC_PINSHAPE aShape ) { m_shape = aShape; }
|
||||||
|
@ -171,13 +160,13 @@ public:
|
||||||
*
|
*
|
||||||
* @param aTransform Transform matrix
|
* @param aTransform Transform matrix
|
||||||
*/
|
*/
|
||||||
int PinDrawOrient( const TRANSFORM& aTransform ) const;
|
PIN_ORIENTATION PinDrawOrient( const TRANSFORM& aTransform ) const;
|
||||||
|
|
||||||
LIB_PIN( LIB_SYMBOL* aParent );
|
LIB_PIN( LIB_SYMBOL* aParent );
|
||||||
|
|
||||||
LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aNumber, int aOrientation,
|
LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aNumber,
|
||||||
ELECTRICAL_PINTYPE aPinType, int aLength, int aNameTextSize, int aNumTextSize,
|
PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength,
|
||||||
int aConvert, const VECTOR2I& aPos, int aUnit );
|
int aNameTextSize, int aNumTextSize, int aConvert, const VECTOR2I& aPos, int aUnit );
|
||||||
|
|
||||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||||
|
|
||||||
|
@ -230,10 +219,10 @@ public:
|
||||||
* If TextInside then the text is been put inside (moving from x1, y1 in
|
* 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.
|
* the opposite direction to x2,y2), otherwise all is drawn outside.
|
||||||
*/
|
*/
|
||||||
void PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, int aPinOrient, int aTextInside,
|
void PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient,
|
||||||
bool aDrawPinNum, bool aDrawPinName, bool aDimmed ) const;
|
int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed ) const;
|
||||||
|
|
||||||
void PlotSymbol( PLOTTER *aPlotter, const VECTOR2I &aPosition, int aOrientation,
|
void PlotSymbol( PLOTTER *aPlotter, const VECTOR2I &aPosition, PIN_ORIENTATION aOrientation,
|
||||||
bool aDimmed ) const;
|
bool aDimmed ) const;
|
||||||
|
|
||||||
void Offset( const VECTOR2I& aOffset ) override;
|
void Offset( const VECTOR2I& aOffset ) override;
|
||||||
|
@ -243,6 +232,12 @@ public:
|
||||||
VECTOR2I GetPosition() const override { return m_position; }
|
VECTOR2I GetPosition() const override { return m_position; }
|
||||||
void SetPosition( const VECTOR2I& aPos ) override { m_position = aPos; }
|
void SetPosition( const VECTOR2I& aPos ) override { m_position = aPos; }
|
||||||
|
|
||||||
|
// For properties system
|
||||||
|
int GetX() const { return m_position.x; }
|
||||||
|
void SetX( int aX ) { m_position.x = aX; }
|
||||||
|
int GetY() const { return m_position.y; }
|
||||||
|
void SetY( int aY ) { m_position.y = aY; }
|
||||||
|
|
||||||
VECTOR2I GetPinRoot() const;
|
VECTOR2I GetPinRoot() const;
|
||||||
|
|
||||||
void MirrorHorizontal( const VECTOR2I& aCenter ) override;
|
void MirrorHorizontal( const VECTOR2I& aCenter ) override;
|
||||||
|
@ -285,8 +280,8 @@ protected:
|
||||||
* Print the pin symbol without text.
|
* Print the pin symbol without text.
|
||||||
* If \a aColor != 0, draw with \a aColor, else with the normal pin color.
|
* If \a aColor != 0, draw with \a aColor, else with the normal pin color.
|
||||||
*/
|
*/
|
||||||
void printPinSymbol( const RENDER_SETTINGS *aSettings, const VECTOR2I &aPos, int aOrientation,
|
void printPinSymbol( const RENDER_SETTINGS *aSettings, const VECTOR2I &aPos,
|
||||||
bool aDimmed );
|
PIN_ORIENTATION aOrientation, bool aDimmed );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put the pin number and pin text info, given the pin line coordinates.
|
* Put the pin number and pin text info, given the pin line coordinates.
|
||||||
|
@ -296,14 +291,15 @@ protected:
|
||||||
* If aTextInside then the text is been put inside,otherwise all is drawn outside.
|
* If aTextInside then the text is been put inside,otherwise all is drawn outside.
|
||||||
* Pin Name: substring between '~' is negated
|
* Pin Name: substring between '~' is negated
|
||||||
*/
|
*/
|
||||||
void printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos, int aPinOrient,
|
void printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos,
|
||||||
int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed );
|
PIN_ORIENTATION aPinOrient, int aTextInside, bool aDrawPinNum,
|
||||||
|
bool aDrawPinName, bool aDimmed );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the electrical type text of the pin (only for the footprint editor)
|
* Draw the electrical type text of the pin (only for the footprint editor)
|
||||||
*/
|
*/
|
||||||
void printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECTOR2I& aPosition,
|
void printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECTOR2I& aPosition,
|
||||||
int aOrientation, bool aDimmed );
|
PIN_ORIENTATION aOrientation, bool aDimmed );
|
||||||
|
|
||||||
bool operator==( const LIB_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) == 0; }
|
bool operator==( const LIB_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) == 0; }
|
||||||
bool operator<( const LIB_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) < 0; }
|
bool operator<( const LIB_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) < 0; }
|
||||||
|
@ -325,7 +321,7 @@ private:
|
||||||
protected:
|
protected:
|
||||||
VECTOR2I m_position; // Position of the pin.
|
VECTOR2I m_position; // Position of the pin.
|
||||||
int m_length; // Length of the pin.
|
int m_length; // Length of the pin.
|
||||||
int m_orientation; // Pin orientation (Up, Down, Left, Right)
|
PIN_ORIENTATION m_orientation; // Pin orientation (Up, Down, Left, Right)
|
||||||
GRAPHIC_PINSHAPE m_shape; // Shape drawn around pin
|
GRAPHIC_PINSHAPE m_shape; // Shape drawn around pin
|
||||||
ELECTRICAL_PINTYPE m_type; // Electrical type of the pin.
|
ELECTRICAL_PINTYPE m_type; // Electrical type of the pin.
|
||||||
int m_attributes; // Set bit 0 to indicate pin is invisible.
|
int m_attributes; // Set bit 0 to indicate pin is invisible.
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <core/arraydim.h>
|
#include <core/arraydim.h>
|
||||||
|
#include <magic_enum.hpp>
|
||||||
#include <lib_pin.h>
|
#include <lib_pin.h>
|
||||||
#include "pgm_base.h"
|
#include "pgm_base.h"
|
||||||
|
|
||||||
|
@ -88,15 +89,6 @@ const std::map<GRAPHIC_PINSHAPE, struct pinShapeStruct> pinShapes = {
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
||||||
static const int pin_orientation_codes[] =
|
|
||||||
{
|
|
||||||
PIN_RIGHT,
|
|
||||||
PIN_LEFT,
|
|
||||||
PIN_UP,
|
|
||||||
PIN_DOWN
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// bitmaps to show pins orientations in dialog editor
|
// bitmaps to show pins orientations in dialog editor
|
||||||
// must have same order than pin_orientation_names
|
// must have same order than pin_orientation_names
|
||||||
static const BITMAPS iconsPinsOrientations[] =
|
static const BITMAPS iconsPinsOrientations[] =
|
||||||
|
@ -108,53 +100,29 @@ static const BITMAPS iconsPinsOrientations[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define PIN_ORIENTATION_CNT arrayDim( pin_orientation_codes )
|
// clang-format off
|
||||||
|
std::map<PIN_ORIENTATION, struct pinShapeStruct> pinOrientations = {
|
||||||
|
{ PIN_ORIENTATION::PIN_RIGHT, { _( "Right" ), BITMAPS::pinorient_right } },
|
||||||
// Helper functions to get the pin orientation name from pin_orientation_codes
|
{ PIN_ORIENTATION::PIN_LEFT, { _( "Left" ), BITMAPS::pinorient_left } },
|
||||||
// Note: the strings are *not* static because they are translated and must be built
|
{ PIN_ORIENTATION::PIN_UP, { _( "Up" ), BITMAPS::pinorient_up } },
|
||||||
// on the fly, to be properly translated
|
{ PIN_ORIENTATION::PIN_DOWN, { _( "Down" ), BITMAPS::pinorient_down } },
|
||||||
|
|
||||||
wxString PinOrientationName( unsigned aPinOrientationCode )
|
|
||||||
{
|
|
||||||
/* 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.
|
|
||||||
*/
|
|
||||||
const wxString pin_orientation_names[] =
|
|
||||||
{
|
|
||||||
_( "Right" ),
|
|
||||||
_( "Left" ),
|
|
||||||
_( "Up" ),
|
|
||||||
_( "Down" ),
|
|
||||||
wxT( "???" )
|
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
if( aPinOrientationCode > PIN_ORIENTATION_CNT )
|
|
||||||
aPinOrientationCode = PIN_ORIENTATION_CNT;
|
|
||||||
|
|
||||||
return pin_orientation_names[ aPinOrientationCode ];
|
PIN_ORIENTATION PinOrientationCode( size_t index )
|
||||||
|
{
|
||||||
|
wxASSERT( index < magic_enum::enum_count<PIN_ORIENTATION>() );
|
||||||
|
return magic_enum::enum_value<PIN_ORIENTATION>( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PinOrientationCode( int index )
|
int PinOrientationIndex( PIN_ORIENTATION code )
|
||||||
{
|
{
|
||||||
if( index >= 0 && index < (int) PIN_ORIENTATION_CNT )
|
auto index = magic_enum::enum_index<PIN_ORIENTATION>( code );
|
||||||
return pin_orientation_codes[ index ];
|
|
||||||
|
|
||||||
return PIN_RIGHT;
|
if( index.has_value() )
|
||||||
}
|
return index.value();
|
||||||
|
|
||||||
|
|
||||||
int PinOrientationIndex( 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;
|
return wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
|
@ -174,10 +142,10 @@ void InitTables()
|
||||||
g_shapeNames.push_back( PinShapeGetText( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
|
g_shapeNames.push_back( PinShapeGetText( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( unsigned i = 0; i < PIN_ORIENTATION_CNT; ++i )
|
for( PIN_ORIENTATION orientation : magic_enum::enum_values<PIN_ORIENTATION>() )
|
||||||
{
|
{
|
||||||
g_orientationIcons.push_back( iconsPinsOrientations[ i ] );
|
g_orientationIcons.push_back( PinOrientationGetBitmap( orientation ) );
|
||||||
g_orientationNames.push_back( PinOrientationName( i ) );
|
g_orientationNames.push_back( PinOrientationName( orientation ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,3 +262,22 @@ BITMAPS PinShapeGetBitmap( GRAPHIC_PINSHAPE aShape )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString PinOrientationName( PIN_ORIENTATION aOrientation )
|
||||||
|
{
|
||||||
|
auto findIt = pinOrientations.find( aOrientation );
|
||||||
|
|
||||||
|
wxCHECK_MSG( findIt != pinOrientations.end(), wxT( "?" ), wxT( "Pin orientation not found!" ) );
|
||||||
|
|
||||||
|
return findIt->second.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BITMAPS PinOrientationGetBitmap( PIN_ORIENTATION aOrientation )
|
||||||
|
{
|
||||||
|
auto findIt = pinOrientations.find( aOrientation );
|
||||||
|
|
||||||
|
wxCHECK_MSG( findIt != pinOrientations.end(), BITMAPS::INVALID_BITMAP,
|
||||||
|
wxT( "Pin orientation not found!" ) );
|
||||||
|
|
||||||
|
return findIt->second.bitmap;
|
||||||
|
}
|
||||||
|
|
|
@ -69,6 +69,16 @@ enum class GRAPHIC_PINSHAPE
|
||||||
|
|
||||||
#define GRAPHIC_PINSHAPES_TOTAL ( static_cast<int>( GRAPHIC_PINSHAPE::LAST_OPTION ) + 1 )
|
#define GRAPHIC_PINSHAPES_TOTAL ( static_cast<int>( GRAPHIC_PINSHAPE::LAST_OPTION ) + 1 )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The symbol library pin object orientations.
|
||||||
|
*/
|
||||||
|
enum class PIN_ORIENTATION {
|
||||||
|
PIN_RIGHT = 'R',
|
||||||
|
PIN_LEFT = 'L',
|
||||||
|
PIN_UP = 'U',
|
||||||
|
PIN_DOWN = 'D',
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
|
|
||||||
|
@ -78,9 +88,10 @@ BITMAPS PinShapeGetBitmap( GRAPHIC_PINSHAPE shape );
|
||||||
wxString ElectricalPinTypeGetText( ELECTRICAL_PINTYPE );
|
wxString ElectricalPinTypeGetText( ELECTRICAL_PINTYPE );
|
||||||
BITMAPS ElectricalPinTypeGetBitmap( ELECTRICAL_PINTYPE );
|
BITMAPS ElectricalPinTypeGetBitmap( ELECTRICAL_PINTYPE );
|
||||||
|
|
||||||
wxString PinOrientationName( unsigned aPinOrientationCode );
|
wxString PinOrientationName( PIN_ORIENTATION aPinOrientation );
|
||||||
int PinOrientationCode( int index );
|
BITMAPS PinOrientationGetBitmap( PIN_ORIENTATION aPinOrientation );
|
||||||
int PinOrientationIndex( int code );
|
PIN_ORIENTATION PinOrientationCode( size_t index );
|
||||||
|
int PinOrientationIndex( PIN_ORIENTATION code );
|
||||||
|
|
||||||
const wxArrayString& PinTypeNames();
|
const wxArrayString& PinTypeNames();
|
||||||
const std::vector<BITMAPS>& PinTypeIcons();
|
const std::vector<BITMAPS>& PinTypeIcons();
|
||||||
|
|
|
@ -1350,27 +1350,27 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
|
||||||
VECTOR2I p0;
|
VECTOR2I p0;
|
||||||
VECTOR2I dir;
|
VECTOR2I dir;
|
||||||
int len = aPin->GetLength();
|
int len = aPin->GetLength();
|
||||||
int orient = aPin->GetOrientation();
|
PIN_ORIENTATION orient = aPin->GetOrientation();
|
||||||
|
|
||||||
switch( orient )
|
switch( orient )
|
||||||
{
|
{
|
||||||
case PIN_UP:
|
case PIN_ORIENTATION::PIN_UP:
|
||||||
p0 = VECTOR2I( pos.x, pos.y - len );
|
p0 = VECTOR2I( pos.x, pos.y - len );
|
||||||
dir = VECTOR2I( 0, 1 );
|
dir = VECTOR2I( 0, 1 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIN_DOWN:
|
case PIN_ORIENTATION::PIN_DOWN:
|
||||||
p0 = VECTOR2I( pos.x, pos.y + len );
|
p0 = VECTOR2I( pos.x, pos.y + len );
|
||||||
dir = VECTOR2I( 0, -1 );
|
dir = VECTOR2I( 0, -1 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIN_LEFT:
|
case PIN_ORIENTATION::PIN_LEFT:
|
||||||
p0 = VECTOR2I( pos.x - len, pos.y );
|
p0 = VECTOR2I( pos.x - len, pos.y );
|
||||||
dir = VECTOR2I( 1, 0 );
|
dir = VECTOR2I( 1, 0 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case PIN_RIGHT:
|
case PIN_ORIENTATION::PIN_RIGHT:
|
||||||
p0 = VECTOR2I( pos.x + len, pos.y );
|
p0 = VECTOR2I( pos.x + len, pos.y );
|
||||||
dir = VECTOR2I( -1, 0 );
|
dir = VECTOR2I( -1, 0 );
|
||||||
break;
|
break;
|
||||||
|
@ -1701,7 +1701,7 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
|
||||||
|
|
||||||
switch( orient )
|
switch( orient )
|
||||||
{
|
{
|
||||||
case PIN_LEFT:
|
case PIN_ORIENTATION::PIN_LEFT:
|
||||||
if( size[INSIDE] )
|
if( size[INSIDE] )
|
||||||
{
|
{
|
||||||
drawText( INSIDE, pos + VECTOR2D( -insideOffset - (float) len, 0 ),
|
drawText( INSIDE, pos + VECTOR2D( -insideOffset - (float) len, 0 ),
|
||||||
|
@ -1724,7 +1724,7 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIN_RIGHT:
|
case PIN_ORIENTATION::PIN_RIGHT:
|
||||||
if( size[INSIDE] )
|
if( size[INSIDE] )
|
||||||
{
|
{
|
||||||
drawText( INSIDE, pos + VECTOR2D( insideOffset + (float) len, 0 ),
|
drawText( INSIDE, pos + VECTOR2D( insideOffset + (float) len, 0 ),
|
||||||
|
@ -1747,7 +1747,7 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIN_DOWN:
|
case PIN_ORIENTATION::PIN_DOWN:
|
||||||
if( size[INSIDE] )
|
if( size[INSIDE] )
|
||||||
{
|
{
|
||||||
drawText( INSIDE, pos + VECTOR2D( 0, insideOffset + (float) len ),
|
drawText( INSIDE, pos + VECTOR2D( 0, insideOffset + (float) len ),
|
||||||
|
@ -1770,7 +1770,7 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIN_UP:
|
case PIN_ORIENTATION::PIN_UP:
|
||||||
if( size[INSIDE] )
|
if( size[INSIDE] )
|
||||||
{
|
{
|
||||||
drawText( INSIDE, pos + VECTOR2D( 0, -insideOffset - (float) len ),
|
drawText( INSIDE, pos + VECTOR2D( 0, -insideOffset - (float) len ),
|
||||||
|
|
|
@ -132,7 +132,7 @@ GRAPHIC_PINSHAPE SCH_PIN::GetShape() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_PIN::GetOrientation() const
|
PIN_ORIENTATION SCH_PIN::GetOrientation() const
|
||||||
{
|
{
|
||||||
return m_libPin->GetOrientation();
|
return m_libPin->GetOrientation();
|
||||||
}
|
}
|
||||||
|
@ -224,8 +224,7 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
|
||||||
|
|
||||||
aList.emplace_back( _( "Length" ), aFrame->MessageTextFromValue( GetLength() ), true );
|
aList.emplace_back( _( "Length" ), aFrame->MessageTextFromValue( GetLength() ), true );
|
||||||
|
|
||||||
int i = PinOrientationIndex( GetOrientation() );
|
aList.emplace_back( _( "Orientation" ), PinOrientationName( GetOrientation() ) );
|
||||||
aList.emplace_back( _( "Orientation" ), PinOrientationName( (unsigned) i ) );
|
|
||||||
|
|
||||||
SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
|
SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
|
||||||
SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
|
SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
|
||||||
|
|
|
@ -151,7 +151,7 @@ public:
|
||||||
|
|
||||||
GRAPHIC_PINSHAPE GetShape() const;
|
GRAPHIC_PINSHAPE GetShape() const;
|
||||||
|
|
||||||
int GetOrientation() const;
|
PIN_ORIENTATION GetOrientation() const;
|
||||||
|
|
||||||
int GetLength() const;
|
int GetLength() const;
|
||||||
|
|
||||||
|
|
|
@ -909,22 +909,22 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map<wxString, wxString>& aPropertie
|
||||||
switch( elem.orientation )
|
switch( elem.orientation )
|
||||||
{
|
{
|
||||||
case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
|
case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
|
||||||
pin->SetOrientation( DrawPinOrient::PIN_LEFT );
|
pin->SetOrientation( PIN_ORIENTATION::PIN_LEFT );
|
||||||
pinLocation.x += elem.pinlength;
|
pinLocation.x += elem.pinlength;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ASCH_RECORD_ORIENTATION::UPWARDS:
|
case ASCH_RECORD_ORIENTATION::UPWARDS:
|
||||||
pin->SetOrientation( DrawPinOrient::PIN_DOWN );
|
pin->SetOrientation( PIN_ORIENTATION::PIN_DOWN );
|
||||||
pinLocation.y -= elem.pinlength;
|
pinLocation.y -= elem.pinlength;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ASCH_RECORD_ORIENTATION::LEFTWARDS:
|
case ASCH_RECORD_ORIENTATION::LEFTWARDS:
|
||||||
pin->SetOrientation( DrawPinOrient::PIN_RIGHT );
|
pin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT );
|
||||||
pinLocation.x -= elem.pinlength;
|
pinLocation.x -= elem.pinlength;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ASCH_RECORD_ORIENTATION::DOWNWARDS:
|
case ASCH_RECORD_ORIENTATION::DOWNWARDS:
|
||||||
pin->SetOrientation( DrawPinOrient::PIN_UP );
|
pin->SetOrientation( PIN_ORIENTATION::PIN_UP );
|
||||||
pinLocation.y += elem.pinlength;
|
pinLocation.y += elem.pinlength;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -3303,13 +3303,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int
|
||||||
angle.Normalize180();
|
angle.Normalize180();
|
||||||
|
|
||||||
if( angle >= -ANGLE_45 && angle <= ANGLE_45 )
|
if( angle >= -ANGLE_45 && angle <= ANGLE_45 )
|
||||||
pin->SetOrientation( 'R' ); // 0 degrees
|
pin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT ); // 0 degrees
|
||||||
else if( angle >= ANGLE_45 && angle <= ANGLE_135 )
|
else if( angle >= ANGLE_45 && angle <= ANGLE_135 )
|
||||||
pin->SetOrientation( 'U' ); // 90 degrees
|
pin->SetOrientation( PIN_ORIENTATION::PIN_UP ); // 90 degrees
|
||||||
else if( angle >= ANGLE_135 || angle <= -ANGLE_135 )
|
else if( angle >= ANGLE_135 || angle <= -ANGLE_135 )
|
||||||
pin->SetOrientation( 'L' ); // 180 degrees
|
pin->SetOrientation( PIN_ORIENTATION::PIN_LEFT ); // 180 degrees
|
||||||
else
|
else
|
||||||
pin->SetOrientation( 'D' ); // -90 degrees
|
pin->SetOrientation( PIN_ORIENTATION::PIN_DOWN ); // -90 degrees
|
||||||
};
|
};
|
||||||
|
|
||||||
if( uniqueSegments.count( pin->GetPosition() ) )
|
if( uniqueSegments.count( pin->GetPosition() ) )
|
||||||
|
|
|
@ -2302,10 +2302,10 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlN
|
||||||
|
|
||||||
switch( roti )
|
switch( roti )
|
||||||
{
|
{
|
||||||
case 0: pin->SetOrientation( 'R' ); break;
|
case 0: pin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT ); break;
|
||||||
case 90: pin->SetOrientation( 'U' ); break;
|
case 90: pin->SetOrientation( PIN_ORIENTATION::PIN_UP ); break;
|
||||||
case 180: pin->SetOrientation( 'L' ); break;
|
case 180: pin->SetOrientation( PIN_ORIENTATION::PIN_LEFT ); break;
|
||||||
case 270: pin->SetOrientation( 'D' ); break;
|
case 270: pin->SetOrientation( PIN_ORIENTATION::PIN_DOWN ); break;
|
||||||
default: wxFAIL_MSG( wxString::Format( wxT( "Unhandled orientation (%d degrees)." ), roti ) );
|
default: wxFAIL_MSG( wxString::Format( wxT( "Unhandled orientation (%d degrees)." ), roti ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3382,10 +3382,10 @@ void SCH_EAGLE_PLUGIN::addImplicitConnections( SCH_SYMBOL* aSymbol, SCH_SCREEN*
|
||||||
|
|
||||||
switch( pin->GetOrientation() )
|
switch( pin->GetOrientation() )
|
||||||
{
|
{
|
||||||
case PIN_LEFT: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT ); break;
|
case PIN_ORIENTATION::PIN_LEFT: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT ); break;
|
||||||
case PIN_RIGHT: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT ); break;
|
case PIN_ORIENTATION::PIN_RIGHT: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT ); break;
|
||||||
case PIN_UP: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::UP ); break;
|
case PIN_ORIENTATION::PIN_UP: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::UP ); break;
|
||||||
case PIN_DOWN: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::BOTTOM ); break;
|
case PIN_ORIENTATION::PIN_DOWN: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::BOTTOM ); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
aScreen->Append( netLabel );
|
aScreen->Append( netLabel );
|
||||||
|
|
|
@ -1395,10 +1395,10 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
|
||||||
|
|
||||||
switch( parseInt( "pin orientation" ) )
|
switch( parseInt( "pin orientation" ) )
|
||||||
{
|
{
|
||||||
case 0: pin->SetOrientation( PIN_RIGHT ); break;
|
case 0: pin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT ); break;
|
||||||
case 90: pin->SetOrientation( PIN_UP ); break;
|
case 90: pin->SetOrientation( PIN_ORIENTATION::PIN_UP ); break;
|
||||||
case 180: pin->SetOrientation( PIN_LEFT ); break;
|
case 180: pin->SetOrientation( PIN_ORIENTATION::PIN_LEFT ); break;
|
||||||
case 270: pin->SetOrientation( PIN_DOWN ); break;
|
case 270: pin->SetOrientation( PIN_ORIENTATION::PIN_DOWN ); break;
|
||||||
default: Expecting( "0, 90, 180, or 270" );
|
default: Expecting( "0, 90, 180, or 270" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,14 +149,14 @@ const char* getPinShapeToken( GRAPHIC_PINSHAPE aShape )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EDA_ANGLE getPinAngle( int aOrientation )
|
EDA_ANGLE getPinAngle( PIN_ORIENTATION aOrientation )
|
||||||
{
|
{
|
||||||
switch( aOrientation )
|
switch( aOrientation )
|
||||||
{
|
{
|
||||||
case PIN_RIGHT: return ANGLE_0;
|
case PIN_ORIENTATION::PIN_RIGHT: return ANGLE_0;
|
||||||
case PIN_LEFT: return ANGLE_180;
|
case PIN_ORIENTATION::PIN_LEFT: return ANGLE_180;
|
||||||
case PIN_UP: return ANGLE_90;
|
case PIN_ORIENTATION::PIN_UP: return ANGLE_90;
|
||||||
case PIN_DOWN: return ANGLE_270;
|
case PIN_ORIENTATION::PIN_DOWN: return ANGLE_270;
|
||||||
default: wxFAIL_MSG( "Missing symbol library pin orientation type" ); return ANGLE_0;
|
default: wxFAIL_MSG( "Missing symbol library pin orientation type" ); return ANGLE_0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ extern const char* getPinElectricalTypeToken( ELECTRICAL_PINTYPE aType );
|
||||||
|
|
||||||
extern const char* getPinShapeToken( GRAPHIC_PINSHAPE aShape );
|
extern const char* getPinShapeToken( GRAPHIC_PINSHAPE aShape );
|
||||||
|
|
||||||
extern EDA_ANGLE getPinAngle( int aOrientation );
|
extern EDA_ANGLE getPinAngle( PIN_ORIENTATION aOrientation );
|
||||||
|
|
||||||
extern const char* getSheetPinShapeToken( LABEL_FLAG_SHAPE aShape );
|
extern const char* getSheetPinShapeToken( LABEL_FLAG_SHAPE aShape );
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <magic_enum.hpp>
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
|
|
||||||
#include <lib_shape.h>
|
#include <lib_shape.h>
|
||||||
|
@ -1068,7 +1069,12 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
pos += tmp.size() + 1;
|
pos += tmp.size() + 1;
|
||||||
int orientation = tmp[0];
|
|
||||||
|
PIN_ORIENTATION orientation = PIN_ORIENTATION::PIN_RIGHT;
|
||||||
|
std::optional<PIN_ORIENTATION> optVal = magic_enum::enum_cast<PIN_ORIENTATION>( tmp[0] );
|
||||||
|
|
||||||
|
if( optVal.has_value() )
|
||||||
|
orientation = optVal.value();
|
||||||
|
|
||||||
tmp = tokens.GetNextToken();
|
tmp = tokens.GetNextToken();
|
||||||
|
|
||||||
|
|
|
@ -1231,22 +1231,22 @@ void LTSPICE_SCH_PARSER::CreatePin( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int
|
||||||
{
|
{
|
||||||
case LTSPICE_SCHEMATIC::JUSTIFICATION::LEFT:
|
case LTSPICE_SCHEMATIC::JUSTIFICATION::LEFT:
|
||||||
case LTSPICE_SCHEMATIC::JUSTIFICATION::VLEFT:
|
case LTSPICE_SCHEMATIC::JUSTIFICATION::VLEFT:
|
||||||
aPin->SetOrientation( PIN_RIGHT );
|
aPin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LTSPICE_SCHEMATIC::JUSTIFICATION::RIGHT:
|
case LTSPICE_SCHEMATIC::JUSTIFICATION::RIGHT:
|
||||||
case LTSPICE_SCHEMATIC::JUSTIFICATION::VRIGHT:
|
case LTSPICE_SCHEMATIC::JUSTIFICATION::VRIGHT:
|
||||||
aPin->SetOrientation( PIN_LEFT );
|
aPin->SetOrientation( PIN_ORIENTATION::PIN_LEFT );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LTSPICE_SCHEMATIC::JUSTIFICATION::BOTTOM:
|
case LTSPICE_SCHEMATIC::JUSTIFICATION::BOTTOM:
|
||||||
case LTSPICE_SCHEMATIC::JUSTIFICATION::VBOTTOM:
|
case LTSPICE_SCHEMATIC::JUSTIFICATION::VBOTTOM:
|
||||||
aPin->SetOrientation( PIN_UP );
|
aPin->SetOrientation( PIN_ORIENTATION::PIN_UP );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LTSPICE_SCHEMATIC::JUSTIFICATION::TOP:
|
case LTSPICE_SCHEMATIC::JUSTIFICATION::TOP:
|
||||||
case LTSPICE_SCHEMATIC::JUSTIFICATION::VTOP:
|
case LTSPICE_SCHEMATIC::JUSTIFICATION::VTOP:
|
||||||
aPin->SetOrientation( PIN_DOWN );
|
aPin->SetOrientation( PIN_ORIENTATION::PIN_DOWN );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
|
|
|
@ -576,19 +576,19 @@ TEXT_SPIN_STYLE SCH_SCREEN::GetLabelOrientationForPoint( const VECTOR2I& a
|
||||||
{
|
{
|
||||||
if( pin->GetPosition() == aPosition )
|
if( pin->GetPosition() == aPosition )
|
||||||
{
|
{
|
||||||
if( pin->GetOrientation() == PIN_RIGHT )
|
if( pin->GetOrientation() == PIN_ORIENTATION::PIN_RIGHT )
|
||||||
{
|
{
|
||||||
ret = TEXT_SPIN_STYLE::LEFT;
|
ret = TEXT_SPIN_STYLE::LEFT;
|
||||||
}
|
}
|
||||||
else if( pin->GetOrientation() == PIN_LEFT )
|
else if( pin->GetOrientation() == PIN_ORIENTATION::PIN_LEFT )
|
||||||
{
|
{
|
||||||
ret = TEXT_SPIN_STYLE::RIGHT;
|
ret = TEXT_SPIN_STYLE::RIGHT;
|
||||||
}
|
}
|
||||||
else if( pin->GetOrientation() == PIN_UP )
|
else if( pin->GetOrientation() == PIN_ORIENTATION::PIN_UP )
|
||||||
{
|
{
|
||||||
ret = TEXT_SPIN_STYLE::BOTTOM;
|
ret = TEXT_SPIN_STYLE::BOTTOM;
|
||||||
}
|
}
|
||||||
else if( pin->GetOrientation() == PIN_DOWN )
|
else if( pin->GetOrientation() == PIN_ORIENTATION::PIN_DOWN )
|
||||||
{
|
{
|
||||||
ret = TEXT_SPIN_STYLE::UP;
|
ret = TEXT_SPIN_STYLE::UP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,10 +485,10 @@ static TEXT_SPIN_STYLE orientLabel( SCH_PIN* aPin )
|
||||||
// Initial orientation from the pin
|
// Initial orientation from the pin
|
||||||
switch( aPin->GetLibPin()->GetOrientation() )
|
switch( aPin->GetLibPin()->GetOrientation() )
|
||||||
{
|
{
|
||||||
case PIN_UP: spin = TEXT_SPIN_STYLE::BOTTOM; break;
|
case PIN_ORIENTATION::PIN_UP: spin = TEXT_SPIN_STYLE::BOTTOM; break;
|
||||||
case PIN_DOWN: spin = TEXT_SPIN_STYLE::UP; break;
|
case PIN_ORIENTATION::PIN_DOWN: spin = TEXT_SPIN_STYLE::UP; break;
|
||||||
case PIN_LEFT: spin = TEXT_SPIN_STYLE::RIGHT; break;
|
case PIN_ORIENTATION::PIN_LEFT: spin = TEXT_SPIN_STYLE::RIGHT; break;
|
||||||
case PIN_RIGHT: spin = TEXT_SPIN_STYLE::LEFT; break;
|
case PIN_ORIENTATION::PIN_RIGHT: spin = TEXT_SPIN_STYLE::LEFT; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reorient based on the actual symbol orientation now
|
// Reorient based on the actual symbol orientation now
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
|
|
||||||
static ELECTRICAL_PINTYPE g_LastPinType = ELECTRICAL_PINTYPE::PT_INPUT;
|
static ELECTRICAL_PINTYPE g_LastPinType = ELECTRICAL_PINTYPE::PT_INPUT;
|
||||||
static int g_LastPinOrient = PIN_RIGHT;
|
static PIN_ORIENTATION g_LastPinOrient = PIN_ORIENTATION::PIN_RIGHT;
|
||||||
static GRAPHIC_PINSHAPE g_LastPinShape = GRAPHIC_PINSHAPE::LINE;
|
static GRAPHIC_PINSHAPE g_LastPinShape = GRAPHIC_PINSHAPE::LINE;
|
||||||
static bool g_LastPinCommonConvert = false;
|
static bool g_LastPinCommonConvert = false;
|
||||||
static bool g_LastPinCommonUnit = false;
|
static bool g_LastPinCommonUnit = false;
|
||||||
|
@ -419,10 +419,10 @@ LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::RepeatPin( const LIB_PIN* aSourcePin )
|
||||||
|
|
||||||
switch( pin->GetOrientation() )
|
switch( pin->GetOrientation() )
|
||||||
{
|
{
|
||||||
case PIN_UP: step.x = schIUScale.MilsToIU(settings->m_Repeat.pin_step); break;
|
case PIN_ORIENTATION::PIN_UP: step.x = schIUScale.MilsToIU(settings->m_Repeat.pin_step); break;
|
||||||
case PIN_DOWN: step.x = schIUScale.MilsToIU(settings->m_Repeat.pin_step); break;
|
case PIN_ORIENTATION::PIN_DOWN: step.x = schIUScale.MilsToIU(settings->m_Repeat.pin_step); break;
|
||||||
case PIN_LEFT: step.y = schIUScale.MilsToIU(-settings->m_Repeat.pin_step); break;
|
case PIN_ORIENTATION::PIN_LEFT: step.y = schIUScale.MilsToIU(-settings->m_Repeat.pin_step); break;
|
||||||
case PIN_RIGHT: step.y = schIUScale.MilsToIU(-settings->m_Repeat.pin_step); break;
|
case PIN_ORIENTATION::PIN_RIGHT: step.y = schIUScale.MilsToIU(-settings->m_Repeat.pin_step); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pin->Offset( step );
|
pin->Offset( step );
|
||||||
|
|
Loading…
Reference in New Issue