enum class SHEET_SIDE

This commit is contained in:
Marek Roszko 2021-05-30 21:20:43 -04:00
parent 5c543b62c5
commit 3ac5aa5369
10 changed files with 68 additions and 68 deletions

View File

@ -1691,10 +1691,10 @@ void SCH_PAINTER::draw( const SCH_SHEET *aSheet, int aLayer )
// For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2 // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
switch( sheetPin->GetEdge() ) switch( sheetPin->GetEdge() )
{ {
case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break; case SHEET_SIDE::TOP: offset_pos.y += KiROUND( width / 2.0 ); break;
case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break; case SHEET_SIDE::BOTTOM: offset_pos.y -= KiROUND( width / 2.0 ); break;
case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break; case SHEET_SIDE::RIGHT: offset_pos.x -= KiROUND( width / 2.0 ); break;
case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break; case SHEET_SIDE::LEFT: offset_pos.x += KiROUND( width / 2.0 ); break;
default: break; default: break;
} }

View File

@ -1387,22 +1387,22 @@ void SCH_ALTIUM_PLUGIN::ParseSheetEntry( const std::map<wxString, wxString>& aPr
case ASCH_SHEET_ENTRY_SIDE::LEFT: case ASCH_SHEET_ENTRY_SIDE::LEFT:
sheetPin->SetPosition( { pos.x, pos.y + elem.distanceFromTop } ); sheetPin->SetPosition( { pos.x, pos.y + elem.distanceFromTop } );
sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::LEFT ); sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::LEFT );
sheetPin->SetEdge( SHEET_SIDE::SHEET_LEFT_SIDE ); sheetPin->SetEdge( SHEET_SIDE::LEFT );
break; break;
case ASCH_SHEET_ENTRY_SIDE::RIGHT: case ASCH_SHEET_ENTRY_SIDE::RIGHT:
sheetPin->SetPosition( { pos.x + size.x, pos.y + elem.distanceFromTop } ); sheetPin->SetPosition( { pos.x + size.x, pos.y + elem.distanceFromTop } );
sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT ); sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT );
sheetPin->SetEdge( SHEET_SIDE::SHEET_RIGHT_SIDE ); sheetPin->SetEdge( SHEET_SIDE::RIGHT );
break; break;
case ASCH_SHEET_ENTRY_SIDE::TOP: case ASCH_SHEET_ENTRY_SIDE::TOP:
sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y } ); sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y } );
sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::UP ); sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::UP );
sheetPin->SetEdge( SHEET_SIDE::SHEET_TOP_SIDE ); sheetPin->SetEdge( SHEET_SIDE::TOP );
break; break;
case ASCH_SHEET_ENTRY_SIDE::BOTTOM: case ASCH_SHEET_ENTRY_SIDE::BOTTOM:
sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y + size.y } ); sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y + size.y } );
sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM ); sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM );
sheetPin->SetEdge( SHEET_SIDE::SHEET_BOTTOM_SIDE ); sheetPin->SetEdge( SHEET_SIDE::BOTTOM );
break; break;
} }

View File

@ -1820,13 +1820,13 @@ SCH_SHEET_PIN* SCH_SEXPR_PARSER::parseSchSheetPin( SCH_SHEET* aSheet )
double angle = parseDouble( "sheet pin angle (side)" ); double angle = parseDouble( "sheet pin angle (side)" );
if( angle == 0.0 ) if( angle == 0.0 )
sheetPin->SetEdge( SHEET_RIGHT_SIDE ); sheetPin->SetEdge( SHEET_SIDE::RIGHT );
else if( angle == 90.0 ) else if( angle == 90.0 )
sheetPin->SetEdge( SHEET_TOP_SIDE ); sheetPin->SetEdge( SHEET_SIDE::TOP );
else if( angle == 180.0 ) else if( angle == 180.0 )
sheetPin->SetEdge( SHEET_LEFT_SIDE ); sheetPin->SetEdge( SHEET_SIDE::LEFT );
else if( angle == 270.0 ) else if( angle == 270.0 )
sheetPin->SetEdge( SHEET_BOTTOM_SIDE ); sheetPin->SetEdge( SHEET_SIDE::BOTTOM );
else else
Expecting( "0, 90, 180, or 270" ); Expecting( "0, 90, 180, or 270" );

View File

@ -213,11 +213,11 @@ static double getSheetPinAngle( SHEET_SIDE aSide )
switch( aSide ) switch( aSide )
{ {
case SHEET_UNDEFINED_SIDE: case SHEET_SIDE::UNDEFINED:
case SHEET_LEFT_SIDE: retv = 180.0; break; case SHEET_SIDE::LEFT: retv = 180.0; break;
case SHEET_RIGHT_SIDE: retv = 0.0; break; case SHEET_SIDE::RIGHT: retv = 0.0; break;
case SHEET_TOP_SIDE: retv = 90.0; break; case SHEET_SIDE::TOP: retv = 90.0; break;
case SHEET_BOTTOM_SIDE: retv = 270.0; break; case SHEET_SIDE::BOTTOM: retv = 270.0; break;
default: wxFAIL; retv = 0.0; break; default: wxFAIL; retv = 0.0; break;
} }

View File

@ -1054,10 +1054,10 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( LINE_READER& aReader )
switch( parseChar( aReader, line, &line ) ) switch( parseChar( aReader, line, &line ) )
{ {
case 'R': sheetPin->SetEdge( SHEET_RIGHT_SIDE ); break; case 'R': sheetPin->SetEdge( SHEET_SIDE::RIGHT ); break;
case 'T': sheetPin->SetEdge( SHEET_TOP_SIDE ); break; case 'T': sheetPin->SetEdge( SHEET_SIDE::TOP ); break;
case 'B': sheetPin->SetEdge( SHEET_BOTTOM_SIDE ); break; case 'B': sheetPin->SetEdge( SHEET_SIDE::BOTTOM ); break;
case 'L': sheetPin->SetEdge( SHEET_LEFT_SIDE ); break; case 'L': sheetPin->SetEdge( SHEET_SIDE::LEFT ); break;
default: default:
SCH_PARSE_ERROR( "invalid sheet pin side", aReader, line ); SCH_PARSE_ERROR( "invalid sheet pin side", aReader, line );
} }
@ -2218,10 +2218,10 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet )
switch( pin->GetEdge() ) switch( pin->GetEdge() )
{ {
default: default:
case SHEET_LEFT_SIDE: side = 'L'; break; case SHEET_SIDE::LEFT: side = 'L'; break;
case SHEET_RIGHT_SIDE: side = 'R'; break; case SHEET_SIDE::RIGHT: side = 'R'; break;
case SHEET_TOP_SIDE: side = 'T'; break; case SHEET_SIDE::TOP: side = 'T'; break;
case SHEET_BOTTOM_SIDE: side = 'B'; break; case SHEET_SIDE::BOTTOM: side = 'B'; break;
} }
switch( pin->GetShape() ) switch( pin->GetShape() )

View File

@ -357,10 +357,10 @@ bool SCH_SHEET::IsVerticalOrientation() const
{ {
switch( pin->GetEdge() ) switch( pin->GetEdge() )
{ {
case SHEET_LEFT_SIDE: leftRight++; break; case SHEET_SIDE::LEFT: leftRight++; break;
case SHEET_RIGHT_SIDE: leftRight++; break; case SHEET_SIDE::RIGHT: leftRight++; break;
case SHEET_TOP_SIDE: topBottom++; break; case SHEET_SIDE::TOP: topBottom++; break;
case SHEET_BOTTOM_SIDE: topBottom++; break; case SHEET_SIDE::BOTTOM: topBottom++; break;
default: break; default: break;
} }
} }
@ -407,9 +407,9 @@ int SCH_SHEET::GetMinWidth( bool aFromLeft ) const
for( size_t i = 0; i < m_pins.size(); i++ ) for( size_t i = 0; i < m_pins.size(); i++ )
{ {
int edge = m_pins[i]->GetEdge(); SHEET_SIDE edge = m_pins[i]->GetEdge();
if( edge == SHEET_TOP_SIDE || edge == SHEET_BOTTOM_SIDE ) if( edge == SHEET_SIDE::TOP || edge == SHEET_SIDE::BOTTOM )
{ {
EDA_RECT pinRect = m_pins[i]->GetBoundingBox(); EDA_RECT pinRect = m_pins[i]->GetBoundingBox();
@ -441,9 +441,9 @@ int SCH_SHEET::GetMinHeight( bool aFromTop ) const
for( size_t i = 0; i < m_pins.size(); i++ ) for( size_t i = 0; i < m_pins.size(); i++ )
{ {
int edge = m_pins[i]->GetEdge(); SHEET_SIDE edge = m_pins[i]->GetEdge();
if( edge == SHEET_RIGHT_SIDE || edge == SHEET_LEFT_SIDE ) if( edge == SHEET_SIDE::RIGHT || edge == SHEET_SIDE::LEFT )
{ {
EDA_RECT pinRect = m_pins[i]->GetBoundingBox(); EDA_RECT pinRect = m_pins[i]->GetBoundingBox();

View File

@ -40,7 +40,7 @@
SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) : SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) :
SCH_HIERLABEL( pos, text, SCH_SHEET_PIN_T ), SCH_HIERLABEL( pos, text, SCH_SHEET_PIN_T ),
m_edge( SHEET_UNDEFINED_SIDE ) m_edge( SHEET_SIDE::UNDEFINED )
{ {
SetParent( parent ); SetParent( parent );
wxASSERT( parent ); wxASSERT( parent );
@ -49,9 +49,9 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr
SetTextPos( pos ); SetTextPos( pos );
if( parent->IsVerticalOrientation() ) if( parent->IsVerticalOrientation() )
SetEdge( SHEET_TOP_SIDE ); SetEdge( SHEET_SIDE::TOP );
else else
SetEdge( SHEET_LEFT_SIDE ); SetEdge( SHEET_SIDE::LEFT );
m_shape = PINSHEETLABEL_SHAPE::PS_INPUT; m_shape = PINSHEETLABEL_SHAPE::PS_INPUT;
m_isDangling = true; m_isDangling = true;
@ -117,25 +117,25 @@ void SCH_SHEET_PIN::SetEdge( SHEET_SIDE aEdge )
switch( aEdge ) switch( aEdge )
{ {
case SHEET_LEFT_SIDE: case SHEET_SIDE::LEFT:
m_edge = aEdge; m_edge = aEdge;
SetTextX( Sheet->m_pos.x ); SetTextX( Sheet->m_pos.x );
SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT ); // Orientation horiz inverse SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT ); // Orientation horiz inverse
break; break;
case SHEET_RIGHT_SIDE: case SHEET_SIDE::RIGHT:
m_edge = aEdge; m_edge = aEdge;
SetTextX( Sheet->m_pos.x + Sheet->m_size.x ); SetTextX( Sheet->m_pos.x + Sheet->m_size.x );
SetLabelSpinStyle( LABEL_SPIN_STYLE::LEFT ); // Orientation horiz normal SetLabelSpinStyle( LABEL_SPIN_STYLE::LEFT ); // Orientation horiz normal
break; break;
case SHEET_TOP_SIDE: case SHEET_SIDE::TOP:
m_edge = aEdge; m_edge = aEdge;
SetTextY( Sheet->m_pos.y ); SetTextY( Sheet->m_pos.y );
SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM ); // Orientation vert BOTTOM SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM ); // Orientation vert BOTTOM
break; break;
case SHEET_BOTTOM_SIDE: case SHEET_SIDE::BOTTOM:
m_edge = aEdge; m_edge = aEdge;
SetTextY( Sheet->m_pos.y + Sheet->m_size.y ); SetTextY( Sheet->m_pos.y + Sheet->m_size.y );
SetLabelSpinStyle( LABEL_SPIN_STYLE::UP ); // Orientation vert UP SetLabelSpinStyle( LABEL_SPIN_STYLE::UP ); // Orientation vert UP
@ -175,17 +175,17 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos )
switch( sheetEdge.NearestSegment( Pos ) ) switch( sheetEdge.NearestSegment( Pos ) )
{ {
case 0: SetEdge( SHEET_TOP_SIDE ); break; case 0: SetEdge( SHEET_SIDE::TOP ); break;
case 1: SetEdge( SHEET_RIGHT_SIDE ); break; case 1: SetEdge( SHEET_SIDE::RIGHT ); break;
case 2: SetEdge( SHEET_BOTTOM_SIDE ); break; case 2: SetEdge( SHEET_SIDE::BOTTOM ); break;
case 3: SetEdge( SHEET_LEFT_SIDE ); break; case 3: SetEdge( SHEET_SIDE::LEFT ); break;
default: wxASSERT( "Invalid segment number" ); default: wxASSERT( "Invalid segment number" );
} }
switch( GetEdge() ) switch( GetEdge() )
{ {
case SHEET_RIGHT_SIDE: case SHEET_SIDE::RIGHT:
case SHEET_LEFT_SIDE: case SHEET_SIDE::LEFT:
SetTextY( Pos.y ); SetTextY( Pos.y );
if( GetTextPos().y < topSide ) if( GetTextPos().y < topSide )
@ -196,8 +196,8 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos )
break; break;
case SHEET_BOTTOM_SIDE: case SHEET_SIDE::BOTTOM:
case SHEET_TOP_SIDE: case SHEET_SIDE::TOP:
SetTextX( Pos.x ); SetTextX( Pos.x );
if( GetTextPos().x < leftSide ) if( GetTextPos().x < leftSide )
@ -208,7 +208,7 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos )
break; break;
case SHEET_UNDEFINED_SIDE: case SHEET_SIDE::UNDEFINED:
wxASSERT( "Undefined sheet side" ); wxASSERT( "Undefined sheet side" );
} }
} }
@ -222,8 +222,8 @@ void SCH_SHEET_PIN::MirrorVertically( int aCenter )
switch( m_edge ) switch( m_edge )
{ {
case SHEET_TOP_SIDE: SetEdge( SHEET_BOTTOM_SIDE ); break; case SHEET_SIDE::TOP: SetEdge( SHEET_SIDE::BOTTOM ); break;
case SHEET_BOTTOM_SIDE: SetEdge( SHEET_TOP_SIDE ); break; case SHEET_SIDE::BOTTOM: SetEdge( SHEET_SIDE::TOP ); break;
default: break; default: break;
} }
} }
@ -237,8 +237,8 @@ void SCH_SHEET_PIN::MirrorHorizontally( int aCenter )
switch( m_edge ) switch( m_edge )
{ {
case SHEET_LEFT_SIDE: SetEdge( SHEET_RIGHT_SIDE ); break; case SHEET_SIDE::LEFT: SetEdge( SHEET_SIDE::RIGHT ); break;
case SHEET_RIGHT_SIDE: SetEdge( SHEET_LEFT_SIDE ); break; case SHEET_SIDE::RIGHT: SetEdge( SHEET_SIDE::LEFT ); break;
default: break; default: break;
} }
} }

View File

@ -42,13 +42,13 @@ class SCH_SHEET;
* *
* For compatibility reasons, this does not follow same values as text orientation. * For compatibility reasons, this does not follow same values as text orientation.
*/ */
enum SHEET_SIDE enum class SHEET_SIDE
{ {
SHEET_LEFT_SIDE = 0, LEFT = 0,
SHEET_RIGHT_SIDE, RIGHT,
SHEET_TOP_SIDE, TOP,
SHEET_BOTTOM_SIDE, BOTTOM,
SHEET_UNDEFINED_SIDE UNDEFINED
}; };

View File

@ -591,11 +591,11 @@ void EE_POINT_EDITOR::updateParentItem() const
switch( pin->GetEdge() ) switch( pin->GetEdge() )
{ {
case SHEET_LEFT_SIDE: pos.x = topLeft.x; break; case SHEET_SIDE::LEFT: pos.x = topLeft.x; break;
case SHEET_RIGHT_SIDE: pos.x = topRight.x; break; case SHEET_SIDE::RIGHT: pos.x = topRight.x; break;
case SHEET_TOP_SIDE: pos.y = topLeft.y; break; case SHEET_SIDE::TOP: pos.y = topLeft.y; break;
case SHEET_BOTTOM_SIDE: pos.y = botLeft.y; break; case SHEET_SIDE::BOTTOM: pos.y = botLeft.y; break;
case SHEET_UNDEFINED_SIDE: break; case SHEET_SIDE::UNDEFINED: break;
} }
pin->SetPosition( pos ); pin->SetPosition( pos );

View File

@ -420,13 +420,13 @@ void SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint( const std::pair<SCH_LINE*, SCH_L
int iDy = segment->GetEndPoint().y - segment->GetStartPoint().y; int iDy = segment->GetEndPoint().y - segment->GetStartPoint().y;
const SCH_SHEET_PIN* connectedPin = getSheetPin( segment->GetStartPoint() ); const SCH_SHEET_PIN* connectedPin = getSheetPin( segment->GetStartPoint() );
SHEET_SIDE force = connectedPin ? connectedPin->GetEdge() : SHEET_UNDEFINED_SIDE; SHEET_SIDE force = connectedPin ? connectedPin->GetEdge() : SHEET_SIDE::UNDEFINED;
if( force == SHEET_LEFT_SIDE || force == SHEET_RIGHT_SIDE ) if( force == SHEET_SIDE::LEFT || force == SHEET_SIDE::RIGHT )
{ {
if( aPosition.x == connectedPin->GetPosition().x ) // push outside sheet boundary if( aPosition.x == connectedPin->GetPosition().x ) // push outside sheet boundary
{ {
int direction = ( force == SHEET_LEFT_SIDE ) ? -1 : 1; int direction = ( force == SHEET_SIDE::LEFT ) ? -1 : 1;
aPosition.x += KiROUND( getView()->GetGAL()->GetGridSize().x * direction ); aPosition.x += KiROUND( getView()->GetGAL()->GetGridSize().x * direction );
} }