Browse Source

Harmonize rotate APIs.

newinvert
Jeff Young 2 years ago
parent
commit
c5ed80af52
  1. 6
      eeschema/sch_bitmap.cpp
  2. 2
      eeschema/sch_bitmap.h
  3. 6
      eeschema/sch_bus_entry.cpp
  4. 2
      eeschema/sch_bus_entry.h
  5. 4
      eeschema/sch_field.cpp
  6. 2
      eeschema/sch_field.h
  7. 6
      eeschema/sch_io/easyeda/sch_easyeda_parser.cpp
  8. 18
      eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp
  9. 16
      eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp
  10. 2
      eeschema/sch_item.h
  11. 4
      eeschema/sch_junction.cpp
  12. 2
      eeschema/sch_junction.h
  13. 6
      eeschema/sch_label.cpp
  14. 2
      eeschema/sch_label.h
  15. 6
      eeschema/sch_line.cpp
  16. 2
      eeschema/sch_line.h
  17. 2
      eeschema/sch_marker.cpp
  18. 2
      eeschema/sch_marker.h
  19. 4
      eeschema/sch_no_connect.cpp
  20. 2
      eeschema/sch_no_connect.h
  21. 2
      eeschema/sch_pin.h
  22. 4
      eeschema/sch_shape.cpp
  23. 2
      eeschema/sch_shape.h
  24. 8
      eeschema/sch_sheet.cpp
  25. 2
      eeschema/sch_sheet.h
  26. 2
      eeschema/sch_sheet_path.cpp
  27. 4
      eeschema/sch_sheet_pin.cpp
  28. 2
      eeschema/sch_sheet_pin.h
  29. 6
      eeschema/sch_symbol.cpp
  30. 2
      eeschema/sch_symbol.h
  31. 4
      eeschema/sch_table.cpp
  32. 2
      eeschema/sch_table.h
  33. 4
      eeschema/sch_text.cpp
  34. 2
      eeschema/sch_text.h
  35. 4
      eeschema/sch_textbox.cpp
  36. 2
      eeschema/sch_textbox.h
  37. 10
      eeschema/tools/sch_drawing_tools.cpp
  38. 29
      eeschema/tools/sch_edit_tool.cpp
  39. 32
      qa/tests/eeschema/test_ee_item.cpp

6
eeschema/sch_bitmap.cpp

@ -162,10 +162,10 @@ void SCH_BITMAP::MirrorHorizontally( int aCenter )
}
void SCH_BITMAP::Rotate( const VECTOR2I& aCenter )
void SCH_BITMAP::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
RotatePoint( m_pos, aCenter, ANGLE_90 );
m_bitmapBase->Rotate( false );
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
m_bitmapBase->Rotate( aRotateCCW );
}

2
eeschema/sch_bitmap.h

@ -133,7 +133,7 @@ public:
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override
{

6
eeschema/sch_bus_entry.cpp

@ -305,10 +305,10 @@ void SCH_BUS_ENTRY_BASE::MirrorHorizontally( int aCenter )
}
void SCH_BUS_ENTRY_BASE::Rotate( const VECTOR2I& aCenter )
void SCH_BUS_ENTRY_BASE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
RotatePoint( m_pos, aCenter, ANGLE_90 );
RotatePoint( &m_size.x, &m_size.y, ANGLE_90 );
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_270 : ANGLE_90 );
}

2
eeschema/sch_bus_entry.h

@ -102,7 +102,7 @@ public:
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
bool IsDangling() const override;

4
eeschema/sch_field.cpp

@ -892,10 +892,10 @@ bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
}
void SCH_FIELD::Rotate( const VECTOR2I& aCenter )
void SCH_FIELD::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
VECTOR2I pt = GetPosition();
RotatePoint( pt, aCenter, ANGLE_90 );
RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
SetPosition( pt );
}

2
eeschema/sch_field.h

@ -226,7 +226,7 @@ public:
Offset( aMoveVector );
}
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
/**
* @copydoc SCH_ITEM::MirrorVertically()

6
eeschema/sch_io/easyeda/sch_easyeda_parser.cpp

@ -1503,16 +1503,16 @@ void SCH_EASYEDA_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aRoot
{
// Lines need special handling for some reason
aSchItem->SetFlags( STARTPOINT );
aSchItem->Rotate( RelPos( cmdAround ) );
aSchItem->Rotate( RelPos( cmdAround ), false );
aSchItem->ClearFlags( STARTPOINT );
aSchItem->SetFlags( ENDPOINT );
aSchItem->Rotate( RelPos( cmdAround ) );
aSchItem->Rotate( RelPos( cmdAround ), false );
aSchItem->ClearFlags( ENDPOINT );
}
else
{
aSchItem->Rotate( RelPos( cmdAround ) );
aSchItem->Rotate( RelPos( cmdAround ), false );
}
}
}

18
eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp

@ -1006,16 +1006,16 @@ void SCH_EASYEDAPRO_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aR
{
// Lines need special handling for some reason
schItem->SetFlags( STARTPOINT );
schItem->Rotate( kstart );
schItem->Rotate( kstart, false );
schItem->ClearFlags( STARTPOINT );
schItem->SetFlags( ENDPOINT );
schItem->Rotate( kstart );
schItem->Rotate( kstart, false );
schItem->ClearFlags( ENDPOINT );
}
else
{
schItem->Rotate( kstart );
schItem->Rotate( kstart, false );
}
}
@ -1050,7 +1050,7 @@ void SCH_EASYEDAPRO_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aR
bitmap->SetPosition( kcenter );
for( double i = angle; i > 0; i -= 90 )
bitmap->Rotate( kstart );
bitmap->Rotate( kstart, false );
if( flipped )
bitmap->MirrorHorizontally( kstart.x );
@ -1129,17 +1129,17 @@ void SCH_EASYEDAPRO_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aR
wxString unitName = component->name;
LIB_ID libId =
EASYEDAPRO::ToKiCadLibID( aLibName, newLibSymbol.GetLibId().GetLibItemName() );
LIB_ID libId = EASYEDAPRO::ToKiCadLibID( aLibName,
newLibSymbol.GetLibId().GetLibItemName() );
std::unique_ptr<SCH_SYMBOL> schSym =
std::make_unique<SCH_SYMBOL>( newLibSymbol, libId, &aSchematic->CurrentSheet(),
auto schSym = std::make_unique<SCH_SYMBOL>( newLibSymbol, libId,
&aSchematic->CurrentSheet(),
esymInfo.partUnits[unitName] );
schSym->SetFootprintFieldText( newLibSymbol.GetFootprintField().GetText() );
for( double i = component->rotation; i > 0; i -= 90 )
schSym->Rotate( VECTOR2I() );
schSym->Rotate( VECTOR2I(), false );
if( component->mirror )
schSym->MirrorHorizontally( 0 );

16
eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp

@ -370,18 +370,16 @@ void SCH_IO_LTSPICE_PARSER::RotateMirrorShape( LTSPICE_SCHEMATIC::LT_SYMBOL& aLT
{
if( aLTSymbol.SymbolOrientation == LTSPICE_SCHEMATIC::ORIENTATION::R90 )
{
aShape->Rotate( VECTOR2I() );
aShape->Rotate( VECTOR2I() );
aShape->Rotate( VECTOR2I() );
aShape->Rotate( VECTOR2I(), true );
}
else if( aLTSymbol.SymbolOrientation == LTSPICE_SCHEMATIC::ORIENTATION::R180 )
{
aShape->Rotate( VECTOR2I() );
aShape->Rotate( VECTOR2I() );
aShape->Rotate( VECTOR2I(), false );
aShape->Rotate( VECTOR2I(), false );
}
else if( aLTSymbol.SymbolOrientation == LTSPICE_SCHEMATIC::ORIENTATION::R270 )
{
aShape->Rotate( VECTOR2I() );
aShape->Rotate( VECTOR2I(), false );
}
else if( aLTSymbol.SymbolOrientation == LTSPICE_SCHEMATIC::ORIENTATION::M0 )
{
@ -390,7 +388,7 @@ void SCH_IO_LTSPICE_PARSER::RotateMirrorShape( LTSPICE_SCHEMATIC::LT_SYMBOL& aLT
else if( aLTSymbol.SymbolOrientation == LTSPICE_SCHEMATIC::ORIENTATION::M90 )
{
aShape->MirrorVertically( 0 );
aShape->Rotate( VECTOR2I() );
aShape->Rotate( VECTOR2I(), false );
}
else if( aLTSymbol.SymbolOrientation == LTSPICE_SCHEMATIC::ORIENTATION::M180 )
{
@ -399,9 +397,7 @@ void SCH_IO_LTSPICE_PARSER::RotateMirrorShape( LTSPICE_SCHEMATIC::LT_SYMBOL& aLT
else if( aLTSymbol.SymbolOrientation == LTSPICE_SCHEMATIC::ORIENTATION::M270 )
{
aShape->MirrorVertically( 0 );
aShape->Rotate( VECTOR2I() );
aShape->Rotate( VECTOR2I() );
aShape->Rotate( VECTOR2I() );
aShape->Rotate( VECTOR2I(), true );
}
}

2
eeschema/sch_item.h

@ -362,7 +362,7 @@ public:
/**
* Rotate the item around \a aCenter 90 degrees in the clockwise direction.
*/
virtual void Rotate( const VECTOR2I& aCenter )
virtual void Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
wxCHECK_MSG( false, /*void*/, wxT( "Rotate not implemented in " ) + GetClass() );
}

4
eeschema/sch_junction.cpp

@ -139,9 +139,9 @@ void SCH_JUNCTION::MirrorHorizontally( int aCenter )
}
void SCH_JUNCTION::Rotate( const VECTOR2I& aCenter )
void SCH_JUNCTION::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
RotatePoint( m_pos, aCenter, ANGLE_90 );
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
}

2
eeschema/sch_junction.h

@ -78,7 +78,7 @@ public:
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;

6
eeschema/sch_label.cpp

@ -425,13 +425,13 @@ void SCH_LABEL_BASE::Move( const VECTOR2I& aMoveVector )
}
void SCH_LABEL_BASE::Rotate( const VECTOR2I& aCenter )
void SCH_LABEL_BASE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
VECTOR2I pt = GetTextPos();
RotatePoint( pt, aCenter, ANGLE_90 );
RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
VECTOR2I offset = pt - GetTextPos();
Rotate90( false );
Rotate90( aRotateCCW );
SetTextPos( GetTextPos() + offset );

2
eeschema/sch_label.h

@ -222,7 +222,7 @@ public:
bool IncrementLabel( int aIncrement );
void Move( const VECTOR2I& aMoveVector ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
void Rotate90( bool aClockwise ) override;
void MirrorSpinStyle( bool aLeftRight ) override;

6
eeschema/sch_line.cpp

@ -409,16 +409,16 @@ void SCH_LINE::MirrorHorizontally( int aCenter )
}
void SCH_LINE::Rotate( const VECTOR2I& aCenter )
void SCH_LINE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
// When we allow off grid items, the
// else if should become a plain if to allow
// rotation around the center of the line
if( m_flags & STARTPOINT )
RotatePoint( m_start, aCenter, ANGLE_90 );
RotatePoint( m_start, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
else if( m_flags & ENDPOINT )
RotatePoint( m_end, aCenter, ANGLE_90 );
RotatePoint( m_end, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
}

2
eeschema/sch_line.h

@ -212,7 +212,7 @@ public:
void MirrorVertically( int aCenter ) override;
void MirrorHorizontally( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
void RotateStart( const VECTOR2I& aCenter );
void RotateEnd( const VECTOR2I& aCenter );

2
eeschema/sch_marker.cpp

@ -328,7 +328,7 @@ BITMAPS SCH_MARKER::GetMenuImage() const
}
void SCH_MARKER::Rotate( const VECTOR2I& aCenter )
void SCH_MARKER::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
// Marker geometry isn't user-editable
}

2
eeschema/sch_marker.h

@ -82,7 +82,7 @@ public:
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
/**
* Compare DRC marker main and auxiliary text against search string.

4
eeschema/sch_no_connect.cpp

@ -128,9 +128,9 @@ void SCH_NO_CONNECT::MirrorHorizontally( int aCenter )
}
void SCH_NO_CONNECT::Rotate( const VECTOR2I& aCenter )
void SCH_NO_CONNECT::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
RotatePoint( m_pos, aCenter, ANGLE_90 );
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
}

2
eeschema/sch_no_connect.h

@ -80,7 +80,7 @@ public:
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
bool IsConnectable() const override { return true; }

2
eeschema/sch_pin.h

@ -77,7 +77,7 @@ public:
void MirrorHorizontally( int aCenter ) override {}
void MirrorVertically( int aCenter ) override {}
void Rotate( const VECTOR2I& aCenter ) override {}
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override {}
VECTOR2I GetPosition() const override { return GetTransformedPosition(); }
const VECTOR2I GetLocalPosition() const { return m_position; }

4
eeschema/sch_shape.cpp

@ -105,9 +105,9 @@ void SCH_SHAPE::MirrorVertically( int aCenter )
}
void SCH_SHAPE::Rotate( const VECTOR2I& aCenter )
void SCH_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
rotate( aCenter, ANGLE_90 );
rotate( aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
}

2
eeschema/sch_shape.h

@ -92,7 +92,7 @@ public:
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
void AddPoint( const VECTOR2I& aPosition );

8
eeschema/sch_sheet.cpp

@ -842,12 +842,12 @@ void SCH_SHEET::Move( const VECTOR2I& aMoveVector )
}
void SCH_SHEET::Rotate( const VECTOR2I& aCenter )
void SCH_SHEET::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
VECTOR2I prev = m_pos;
RotatePoint( m_pos, aCenter, ANGLE_90 );
RotatePoint( &m_size.x, &m_size.y, ANGLE_90 );
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_270 : ANGLE_90 );
if( m_size.x < 0 )
{
@ -864,7 +864,7 @@ void SCH_SHEET::Rotate( const VECTOR2I& aCenter )
// Pins must be rotated first as that's how we determine vertical vs horizontal
// orientation for auto-placement
for( SCH_SHEET_PIN* sheetPin : m_pins )
sheetPin->Rotate( aCenter );
sheetPin->Rotate( aCenter, aRotateCCW );
if( m_fieldsAutoplaced == FIELDS_AUTOPLACED_AUTO )
{

2
eeschema/sch_sheet.h

@ -324,7 +324,7 @@ public:
void Move( const VECTOR2I& aMoveVector ) override;
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;

2
eeschema/sch_sheet_path.cpp

@ -78,7 +78,7 @@ public:
void Move( const VECTOR2I& aMoveVector ) override {}
void MirrorHorizontally( int aCenter ) override {}
void MirrorVertically( int aCenter ) override {}
void Rotate( const VECTOR2I& aCenter ) override {}
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override {}
double Similarity( const SCH_ITEM& aOther ) const override
{

4
eeschema/sch_sheet_pin.cpp

@ -252,12 +252,12 @@ void SCH_SHEET_PIN::MirrorHorizontally( int aCenter )
}
void SCH_SHEET_PIN::Rotate( const VECTOR2I& aCenter )
void SCH_SHEET_PIN::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
VECTOR2I pt = GetTextPos();
VECTOR2I delta = pt - aCenter;
RotatePoint( pt, aCenter, ANGLE_90 );
RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
SHEET_SIDE oldSide = GetSide();
ConstrainOnEdge( pt, true );

2
eeschema/sch_sheet_pin.h

@ -165,7 +165,7 @@ public:
void MirrorVertically( int aCenter ) override;
void MirrorHorizontally( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
{

6
eeschema/sch_symbol.cpp

@ -2036,13 +2036,13 @@ void SCH_SYMBOL::MirrorVertically( int aCenter )
}
void SCH_SYMBOL::Rotate( const VECTOR2I& aCenter )
void SCH_SYMBOL::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
VECTOR2I prev = m_pos;
RotatePoint( m_pos, aCenter, ANGLE_90 );
RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
SetOrientation( aRotateCCW ? SYM_ROTATE_CLOCKWISE : SYM_ROTATE_COUNTERCLOCKWISE );
for( SCH_FIELD& field : m_fields )
{

2
eeschema/sch_symbol.h

@ -721,7 +721,7 @@ public:
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;

4
eeschema/sch_table.cpp

@ -200,10 +200,10 @@ void SCH_TABLE::MirrorVertically( int aCenter )
}
void SCH_TABLE::Rotate( const VECTOR2I& aCenter )
void SCH_TABLE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
for( SCH_TABLECELL* cell : m_cells )
cell->Rotate( aCenter );
cell->Rotate( aCenter, aRotateCCW );
Normalize();
}

2
eeschema/sch_table.h

@ -180,7 +180,7 @@ public:
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
const BOX2I GetBoundingBox() const override;

4
eeschema/sch_text.cpp

@ -92,10 +92,10 @@ void SCH_TEXT::MirrorVertically( int aCenter )
}
void SCH_TEXT::Rotate( const VECTOR2I& aCenter )
void SCH_TEXT::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
VECTOR2I pt = GetTextPos();
RotatePoint( pt, aCenter, ANGLE_90 );
RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
VECTOR2I offset = pt - GetTextPos();
Rotate90( false );

2
eeschema/sch_text.h

@ -108,7 +108,7 @@ public:
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
virtual void Rotate90( bool aClockwise );
virtual void MirrorSpinStyle( bool aLeftRight );

4
eeschema/sch_textbox.cpp

@ -105,9 +105,9 @@ void SCH_TEXTBOX::MirrorVertically( int aCenter )
}
void SCH_TEXTBOX::Rotate( const VECTOR2I& aCenter )
void SCH_TEXTBOX::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
{
SCH_SHAPE::Rotate( aCenter );
SCH_SHAPE::Rotate( aCenter, aRotateCCW );
SetTextAngle( GetTextAngle() == ANGLE_VERTICAL ? ANGLE_HORIZONTAL : ANGLE_VERTICAL );
}

2
eeschema/sch_textbox.h

@ -106,7 +106,7 @@ public:
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
virtual void Rotate90( bool aClockwise );

10
eeschema/tools/sch_drawing_tools.cpp

@ -1112,11 +1112,13 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
{
SCH_BUS_ENTRY_BASE* busItem = static_cast<SCH_BUS_ENTRY_BASE*>( previewItem );
// The bus entries only rotate in one direction
if( evt->IsAction( &EE_ACTIONS::rotateCW )
|| evt->IsAction( &EE_ACTIONS::rotateCCW ) )
if( evt->IsAction( &EE_ACTIONS::rotateCW ) )
{
busItem->Rotate( busItem->GetPosition() );
busItem->Rotate( busItem->GetPosition(), false );
}
else if( evt->IsAction( &EE_ACTIONS::rotateCCW ) )
{
busItem->Rotate( busItem->GetPosition(), true );
}
else if( evt->IsAction( &EE_ACTIONS::mirrorV ) )
{

29
eeschema/tools/sch_edit_tool.cpp

@ -692,8 +692,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
{
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( head );
for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
symbol->Rotate( rotPoint );
symbol->Rotate( rotPoint, !clockwise );
if( m_frame->eeconfig()->m_AutoplaceFields.enable )
symbol->AutoAutoplaceFields( m_frame->GetScreen() );
@ -718,8 +717,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( head );
SCH_SHEET* sheet = pin->GetParent();
for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
pin->Rotate( sheet->GetBodyBoundingBox().GetCenter() );
pin->Rotate( sheet->GetBoundingBox().GetCenter(), !clockwise );
break;
}
@ -752,8 +750,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
case SCH_NO_CONNECT_T:
case SCH_BUS_BUS_ENTRY_T:
case SCH_BUS_WIRE_ENTRY_T:
for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
head->Rotate( rotPoint );
head->Rotate( rotPoint, !clockwise );
break;
@ -774,8 +771,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
case SCH_SHAPE_T:
case SCH_TEXTBOX_T:
for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
head->Rotate( rotPoint );
head->Rotate( rotPoint, !clockwise );
break;
@ -786,15 +782,13 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
BOX2I box( table->GetPosition(), table->GetEnd() - table->GetPosition() );
rotPoint = m_frame->GetNearestHalfGridPosition( box.GetCenter() );
for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
head->Rotate( rotPoint );
head->Rotate( rotPoint, !clockwise );
break;
}
case SCH_BITMAP_T:
for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
head->Rotate( rotPoint );
head->Rotate( rotPoint, !clockwise );
// The bitmap is cached in Opengl: clear the cache to redraw
getView()->RecacheAllItems();
@ -804,10 +798,9 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
{
// Rotate the sheet on itself. Sheets do not have an anchor point.
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( head );
rotPoint = m_frame->GetNearestHalfGridPosition( sheet->GetRotationCenter() );
for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
sheet->Rotate( rotPoint );
rotPoint = m_frame->GetNearestHalfGridPosition( sheet->GetRotationCenter() );
sheet->Rotate( rotPoint, !clockwise );
break;
}
@ -864,7 +857,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
SCH_SHEET* sheet = pin->GetParent();
pin->Rotate( sheet->GetBodyBoundingBox().GetCenter() );
pin->Rotate( sheet->GetBodyBoundingBox().GetCenter(), false );
}
}
else if( item->Type() == SCH_FIELD_T )
@ -877,7 +870,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
{
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
field->Rotate( rotPoint );
field->Rotate( rotPoint, false );
if( field->GetTextAngle().IsHorizontal() )
field->SetTextAngle( ANGLE_VERTICAL );
@ -890,7 +883,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
}
else
{
item->Rotate( rotPoint );
item->Rotate( rotPoint, false );
}
}

32
qa/tests/eeschema/test_ee_item.cpp

@ -230,18 +230,18 @@ BOOST_AUTO_TEST_CASE( Rotate )
{
schItem->ClearFieldsAutoplaced();
// Only rotating pins around the center of parent sheet works.
schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter() );
schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter() );
schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter() );
schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter() );
schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
}
if( libItem != nullptr )
{
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter() );
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter() );
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter() );
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter() );
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false );
}
CompareItems( newItem.get(), item.get() );
@ -260,18 +260,18 @@ BOOST_AUTO_TEST_CASE( Rotate )
if( schItem != nullptr )
{
schItem->ClearFieldsAutoplaced();
schItem->Rotate( aRef );
schItem->Rotate( aRef );
schItem->Rotate( aRef );
schItem->Rotate( aRef );
schItem->Rotate( aRef, false );
schItem->Rotate( aRef, false );
schItem->Rotate( aRef, false );
schItem->Rotate( aRef, false );
}
if( libItem != nullptr )
{
libItem->Rotate( aRef );
libItem->Rotate( aRef );
libItem->Rotate( aRef );
libItem->Rotate( aRef );
libItem->Rotate( aRef, false );
libItem->Rotate( aRef, false );
libItem->Rotate( aRef, false );
libItem->Rotate( aRef, false );
}
CompareItems( item.get(), aOriginalItem );

Loading…
Cancel
Save