From 3ac5aa5369e94aa1ed4ea4ae37ec0679f0bead79 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sun, 30 May 2021 21:20:43 -0400 Subject: [PATCH] enum class SHEET_SIDE --- eeschema/sch_painter.cpp | 8 ++-- .../sch_plugins/altium/sch_altium_plugin.cpp | 8 ++-- .../sch_plugins/kicad/sch_sexpr_parser.cpp | 8 ++-- .../sch_plugins/kicad/sch_sexpr_plugin.cpp | 12 +++--- .../sch_plugins/legacy/sch_legacy_plugin.cpp | 16 ++++---- eeschema/sch_sheet.cpp | 16 ++++---- eeschema/sch_sheet_pin.cpp | 40 +++++++++---------- eeschema/sch_sheet_pin.h | 12 +++--- eeschema/tools/ee_point_editor.cpp | 10 ++--- eeschema/tools/sch_line_wire_bus_tool.cpp | 6 +-- 10 files changed, 68 insertions(+), 68 deletions(-) diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 99d7f6bbcb..27d26726a6 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -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 switch( sheetPin->GetEdge() ) { - case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break; - case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break; - case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break; - case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break; + case SHEET_SIDE::TOP: offset_pos.y += KiROUND( width / 2.0 ); break; + case SHEET_SIDE::BOTTOM: offset_pos.y -= KiROUND( width / 2.0 ); break; + case SHEET_SIDE::RIGHT: offset_pos.x -= KiROUND( width / 2.0 ); break; + case SHEET_SIDE::LEFT: offset_pos.x += KiROUND( width / 2.0 ); break; default: break; } diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index eb594bc662..7490fd9348 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -1387,22 +1387,22 @@ void SCH_ALTIUM_PLUGIN::ParseSheetEntry( const std::map& aPr case ASCH_SHEET_ENTRY_SIDE::LEFT: sheetPin->SetPosition( { pos.x, pos.y + elem.distanceFromTop } ); sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::LEFT ); - sheetPin->SetEdge( SHEET_SIDE::SHEET_LEFT_SIDE ); + sheetPin->SetEdge( SHEET_SIDE::LEFT ); break; case ASCH_SHEET_ENTRY_SIDE::RIGHT: sheetPin->SetPosition( { pos.x + size.x, pos.y + elem.distanceFromTop } ); sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT ); - sheetPin->SetEdge( SHEET_SIDE::SHEET_RIGHT_SIDE ); + sheetPin->SetEdge( SHEET_SIDE::RIGHT ); break; case ASCH_SHEET_ENTRY_SIDE::TOP: sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y } ); sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::UP ); - sheetPin->SetEdge( SHEET_SIDE::SHEET_TOP_SIDE ); + sheetPin->SetEdge( SHEET_SIDE::TOP ); break; case ASCH_SHEET_ENTRY_SIDE::BOTTOM: sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y + size.y } ); sheetPin->SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM ); - sheetPin->SetEdge( SHEET_SIDE::SHEET_BOTTOM_SIDE ); + sheetPin->SetEdge( SHEET_SIDE::BOTTOM ); break; } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 105da27da8..afcdeb6e16 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -1820,13 +1820,13 @@ SCH_SHEET_PIN* SCH_SEXPR_PARSER::parseSchSheetPin( SCH_SHEET* aSheet ) double angle = parseDouble( "sheet pin angle (side)" ); if( angle == 0.0 ) - sheetPin->SetEdge( SHEET_RIGHT_SIDE ); + sheetPin->SetEdge( SHEET_SIDE::RIGHT ); else if( angle == 90.0 ) - sheetPin->SetEdge( SHEET_TOP_SIDE ); + sheetPin->SetEdge( SHEET_SIDE::TOP ); else if( angle == 180.0 ) - sheetPin->SetEdge( SHEET_LEFT_SIDE ); + sheetPin->SetEdge( SHEET_SIDE::LEFT ); else if( angle == 270.0 ) - sheetPin->SetEdge( SHEET_BOTTOM_SIDE ); + sheetPin->SetEdge( SHEET_SIDE::BOTTOM ); else Expecting( "0, 90, 180, or 270" ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 511cab1734..2e38314695 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -213,12 +213,12 @@ static double getSheetPinAngle( SHEET_SIDE aSide ) switch( aSide ) { - case SHEET_UNDEFINED_SIDE: - case SHEET_LEFT_SIDE: retv = 180.0; break; - case SHEET_RIGHT_SIDE: retv = 0.0; break; - case SHEET_TOP_SIDE: retv = 90.0; break; - case SHEET_BOTTOM_SIDE: retv = 270.0; break; - default: wxFAIL; retv = 0.0; break; + case SHEET_SIDE::UNDEFINED: + case SHEET_SIDE::LEFT: retv = 180.0; break; + case SHEET_SIDE::RIGHT: retv = 0.0; break; + case SHEET_SIDE::TOP: retv = 90.0; break; + case SHEET_SIDE::BOTTOM: retv = 270.0; break; + default: wxFAIL; retv = 0.0; break; } return retv; diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index 5ae5c08202..e192df3f8d 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -1054,10 +1054,10 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( LINE_READER& aReader ) switch( parseChar( aReader, line, &line ) ) { - case 'R': sheetPin->SetEdge( SHEET_RIGHT_SIDE ); break; - case 'T': sheetPin->SetEdge( SHEET_TOP_SIDE ); break; - case 'B': sheetPin->SetEdge( SHEET_BOTTOM_SIDE ); break; - case 'L': sheetPin->SetEdge( SHEET_LEFT_SIDE ); break; + case 'R': sheetPin->SetEdge( SHEET_SIDE::RIGHT ); break; + case 'T': sheetPin->SetEdge( SHEET_SIDE::TOP ); break; + case 'B': sheetPin->SetEdge( SHEET_SIDE::BOTTOM ); break; + case 'L': sheetPin->SetEdge( SHEET_SIDE::LEFT ); break; default: SCH_PARSE_ERROR( "invalid sheet pin side", aReader, line ); } @@ -2218,10 +2218,10 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet ) switch( pin->GetEdge() ) { default: - case SHEET_LEFT_SIDE: side = 'L'; break; - case SHEET_RIGHT_SIDE: side = 'R'; break; - case SHEET_TOP_SIDE: side = 'T'; break; - case SHEET_BOTTOM_SIDE: side = 'B'; break; + case SHEET_SIDE::LEFT: side = 'L'; break; + case SHEET_SIDE::RIGHT: side = 'R'; break; + case SHEET_SIDE::TOP: side = 'T'; break; + case SHEET_SIDE::BOTTOM: side = 'B'; break; } switch( pin->GetShape() ) diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 24474087bd..ebfdde4018 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -357,10 +357,10 @@ bool SCH_SHEET::IsVerticalOrientation() const { switch( pin->GetEdge() ) { - case SHEET_LEFT_SIDE: leftRight++; break; - case SHEET_RIGHT_SIDE: leftRight++; break; - case SHEET_TOP_SIDE: topBottom++; break; - case SHEET_BOTTOM_SIDE: topBottom++; break; + case SHEET_SIDE::LEFT: leftRight++; break; + case SHEET_SIDE::RIGHT: leftRight++; break; + case SHEET_SIDE::TOP: topBottom++; break; + case SHEET_SIDE::BOTTOM: topBottom++; break; default: break; } } @@ -407,9 +407,9 @@ int SCH_SHEET::GetMinWidth( bool aFromLeft ) const 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(); @@ -441,9 +441,9 @@ int SCH_SHEET::GetMinHeight( bool aFromTop ) const 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(); diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index a0eef8261a..e56c54d4f3 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -40,7 +40,7 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) : SCH_HIERLABEL( pos, text, SCH_SHEET_PIN_T ), - m_edge( SHEET_UNDEFINED_SIDE ) + m_edge( SHEET_SIDE::UNDEFINED ) { SetParent( parent ); wxASSERT( parent ); @@ -49,9 +49,9 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr SetTextPos( pos ); if( parent->IsVerticalOrientation() ) - SetEdge( SHEET_TOP_SIDE ); + SetEdge( SHEET_SIDE::TOP ); else - SetEdge( SHEET_LEFT_SIDE ); + SetEdge( SHEET_SIDE::LEFT ); m_shape = PINSHEETLABEL_SHAPE::PS_INPUT; m_isDangling = true; @@ -117,25 +117,25 @@ void SCH_SHEET_PIN::SetEdge( SHEET_SIDE aEdge ) switch( aEdge ) { - case SHEET_LEFT_SIDE: + case SHEET_SIDE::LEFT: m_edge = aEdge; SetTextX( Sheet->m_pos.x ); SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT ); // Orientation horiz inverse break; - case SHEET_RIGHT_SIDE: + case SHEET_SIDE::RIGHT: m_edge = aEdge; SetTextX( Sheet->m_pos.x + Sheet->m_size.x ); SetLabelSpinStyle( LABEL_SPIN_STYLE::LEFT ); // Orientation horiz normal break; - case SHEET_TOP_SIDE: + case SHEET_SIDE::TOP: m_edge = aEdge; SetTextY( Sheet->m_pos.y ); SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM ); // Orientation vert BOTTOM break; - case SHEET_BOTTOM_SIDE: + case SHEET_SIDE::BOTTOM: m_edge = aEdge; SetTextY( Sheet->m_pos.y + Sheet->m_size.y ); SetLabelSpinStyle( LABEL_SPIN_STYLE::UP ); // Orientation vert UP @@ -175,17 +175,17 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos ) switch( sheetEdge.NearestSegment( Pos ) ) { - case 0: SetEdge( SHEET_TOP_SIDE ); break; - case 1: SetEdge( SHEET_RIGHT_SIDE ); break; - case 2: SetEdge( SHEET_BOTTOM_SIDE ); break; - case 3: SetEdge( SHEET_LEFT_SIDE ); break; + case 0: SetEdge( SHEET_SIDE::TOP ); break; + case 1: SetEdge( SHEET_SIDE::RIGHT ); break; + case 2: SetEdge( SHEET_SIDE::BOTTOM ); break; + case 3: SetEdge( SHEET_SIDE::LEFT ); break; default: wxASSERT( "Invalid segment number" ); } switch( GetEdge() ) { - case SHEET_RIGHT_SIDE: - case SHEET_LEFT_SIDE: + case SHEET_SIDE::RIGHT: + case SHEET_SIDE::LEFT: SetTextY( Pos.y ); if( GetTextPos().y < topSide ) @@ -196,8 +196,8 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos ) break; - case SHEET_BOTTOM_SIDE: - case SHEET_TOP_SIDE: + case SHEET_SIDE::BOTTOM: + case SHEET_SIDE::TOP: SetTextX( Pos.x ); if( GetTextPos().x < leftSide ) @@ -208,7 +208,7 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos ) break; - case SHEET_UNDEFINED_SIDE: + case SHEET_SIDE::UNDEFINED: wxASSERT( "Undefined sheet side" ); } } @@ -222,8 +222,8 @@ void SCH_SHEET_PIN::MirrorVertically( int aCenter ) switch( m_edge ) { - case SHEET_TOP_SIDE: SetEdge( SHEET_BOTTOM_SIDE ); break; - case SHEET_BOTTOM_SIDE: SetEdge( SHEET_TOP_SIDE ); break; + case SHEET_SIDE::TOP: SetEdge( SHEET_SIDE::BOTTOM ); break; + case SHEET_SIDE::BOTTOM: SetEdge( SHEET_SIDE::TOP ); break; default: break; } } @@ -237,8 +237,8 @@ void SCH_SHEET_PIN::MirrorHorizontally( int aCenter ) switch( m_edge ) { - case SHEET_LEFT_SIDE: SetEdge( SHEET_RIGHT_SIDE ); break; - case SHEET_RIGHT_SIDE: SetEdge( SHEET_LEFT_SIDE ); break; + case SHEET_SIDE::LEFT: SetEdge( SHEET_SIDE::RIGHT ); break; + case SHEET_SIDE::RIGHT: SetEdge( SHEET_SIDE::LEFT ); break; default: break; } } diff --git a/eeschema/sch_sheet_pin.h b/eeschema/sch_sheet_pin.h index d3638b9342..1e81fb5b87 100644 --- a/eeschema/sch_sheet_pin.h +++ b/eeschema/sch_sheet_pin.h @@ -42,13 +42,13 @@ class SCH_SHEET; * * For compatibility reasons, this does not follow same values as text orientation. */ -enum SHEET_SIDE +enum class SHEET_SIDE { - SHEET_LEFT_SIDE = 0, - SHEET_RIGHT_SIDE, - SHEET_TOP_SIDE, - SHEET_BOTTOM_SIDE, - SHEET_UNDEFINED_SIDE + LEFT = 0, + RIGHT, + TOP, + BOTTOM, + UNDEFINED }; diff --git a/eeschema/tools/ee_point_editor.cpp b/eeschema/tools/ee_point_editor.cpp index 77e05b53b6..9b4b856119 100644 --- a/eeschema/tools/ee_point_editor.cpp +++ b/eeschema/tools/ee_point_editor.cpp @@ -591,11 +591,11 @@ void EE_POINT_EDITOR::updateParentItem() const switch( pin->GetEdge() ) { - case SHEET_LEFT_SIDE: pos.x = topLeft.x; break; - case SHEET_RIGHT_SIDE: pos.x = topRight.x; break; - case SHEET_TOP_SIDE: pos.y = topLeft.y; break; - case SHEET_BOTTOM_SIDE: pos.y = botLeft.y; break; - case SHEET_UNDEFINED_SIDE: break; + case SHEET_SIDE::LEFT: pos.x = topLeft.x; break; + case SHEET_SIDE::RIGHT: pos.x = topRight.x; break; + case SHEET_SIDE::TOP: pos.y = topLeft.y; break; + case SHEET_SIDE::BOTTOM: pos.y = botLeft.y; break; + case SHEET_SIDE::UNDEFINED: break; } pin->SetPosition( pos ); diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 199829eac8..cdcabf88d4 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -420,13 +420,13 @@ void SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint( const std::pairGetEndPoint().y - segment->GetStartPoint().y; 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 { - int direction = ( force == SHEET_LEFT_SIDE ) ? -1 : 1; + int direction = ( force == SHEET_SIDE::LEFT ) ? -1 : 1; aPosition.x += KiROUND( getView()->GetGAL()->GetGridSize().x * direction ); }