Commit b653da5e authored by jean-pierre charras's avatar jean-pierre charras

change name TEXTE_MODULE::MirrorWithModule to...

change name TEXTE_MODULE::MirrorWithModule to TEXTE_MODULE::MirrorTransformWithModule, because it is a function specific  to a footprint transform in modedit.
change also name TEXTE_MODULE::RotateWithModule to TEXTE_MODULE::RotateTransformWithModule for same reason.
Pcbnew: fix Bug #1374484 (text changes position when module is flipped and rotated). Fix also some bugs in modedit, in block commands.
parent 92d141a8
...@@ -400,6 +400,11 @@ void CopyMarkedItems( MODULE* module, wxPoint offset ) ...@@ -400,6 +400,11 @@ void CopyMarkedItems( MODULE* module, wxPoint offset )
if( module == NULL ) if( module == NULL )
return; return;
// Reference and value cannot be copied, they are unique.
// Ensure they are not selected
module->Reference().ClearFlags();
module->Value().ClearFlags();
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() ) for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
{ {
if( !pad->IsSelected() ) if( !pad->IsSelected() )
...@@ -440,6 +445,12 @@ void MoveMarkedItems( MODULE* module, wxPoint offset ) ...@@ -440,6 +445,12 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
if( module == NULL ) if( module == NULL )
return; return;
if( module->Reference().IsSelected() )
module->Reference().MoveTransformWithModule( offset );
if( module->Value().IsSelected() )
module->Value().MoveTransformWithModule( offset );
D_PAD* pad = module->Pads(); D_PAD* pad = module->Pads();
for( ; pad != NULL; pad = pad->Next() ) for( ; pad != NULL; pad = pad->Next() )
...@@ -461,7 +472,7 @@ void MoveMarkedItems( MODULE* module, wxPoint offset ) ...@@ -461,7 +472,7 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
static_cast<TEXTE_MODULE*>( item )->Move( offset ); static_cast<TEXTE_MODULE*>( item )->MoveTransformWithModule( offset );
break; break;
case PCB_MODULE_EDGE_T: case PCB_MODULE_EDGE_T:
...@@ -477,9 +488,9 @@ void MoveMarkedItems( MODULE* module, wxPoint offset ) ...@@ -477,9 +488,9 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
default: default:
; ;
} }
item->ClearFlags();
} }
ClearMarkItems( module );
} }
...@@ -518,6 +529,9 @@ void DeleteMarkedItems( MODULE* module ) ...@@ -518,6 +529,9 @@ void DeleteMarkedItems( MODULE* module )
item->DeleteStructure(); item->DeleteStructure();
} }
// Ref and value can be flagged, but cannot be deleted
ClearMarkItems( module );
} }
...@@ -534,6 +548,12 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all ) ...@@ -534,6 +548,12 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
if( module == NULL ) if( module == NULL )
return; return;
if( module->Reference().IsSelected() || force_all )
module->Reference().MirrorTransformWithModule( offset.x );
if( module->Value().IsSelected() || force_all )
module->Value().MirrorTransformWithModule( offset.x );
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() ) for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
{ {
// Skip pads not selected, i.e. not inside the block to mirror: // Skip pads not selected, i.e. not inside the block to mirror:
...@@ -584,15 +604,15 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all ) ...@@ -584,15 +604,15 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
break; break;
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
static_cast<TEXTE_MODULE*>( item )->MirrorWithModule( offset.x ); static_cast<TEXTE_MODULE*>( item )->MirrorTransformWithModule( offset.x );
break; break;
default: default:
break; break;
} }
item->ClearFlags();
} }
ClearMarkItems( module );
} }
...@@ -607,6 +627,12 @@ void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all ) ...@@ -607,6 +627,12 @@ void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
if( module == NULL ) if( module == NULL )
return; return;
if( module->Reference().IsSelected() || force_all )
module->Reference().RotateTransformWithModule( offset, 900 );
if( module->Value().IsSelected() || force_all )
module->Value().RotateTransformWithModule( offset, 900 );
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() ) for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
{ {
if( !pad->IsSelected() && !force_all ) if( !pad->IsSelected() && !force_all )
...@@ -622,7 +648,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all ) ...@@ -622,7 +648,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() ) for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
{ {
if( !item->IsSelected() && !force_all) if( !item->IsSelected() && !force_all )
continue; continue;
switch( item->Type() ) switch( item->Type() )
...@@ -644,26 +670,27 @@ void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all ) ...@@ -644,26 +670,27 @@ void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
break; break;
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
static_cast<TEXTE_MODULE*>( item )->RotateWithModule( wxPoint( 0, 0 ), 900 ); static_cast<TEXTE_MODULE*>( item )->RotateTransformWithModule( offset, 900 );
break; break;
default: default:
break; break;
} }
item->ClearFlags();
} }
ClearMarkItems( module );
} }
void ClearMarkItems( MODULE* module ) void ClearMarkItems( MODULE* module )
{ {
EDA_ITEM* item;
if( module == NULL ) if( module == NULL )
return; return;
item = module->GraphicalItems(); module->Reference().ClearFlags();
module->Value().ClearFlags();
EDA_ITEM* item = module->GraphicalItems();
for( ; item != NULL; item = item->Next() ) for( ; item != NULL; item = item->Next() )
{ {
...@@ -692,6 +719,24 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect ) ...@@ -692,6 +719,24 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
if( module == NULL ) if( module == NULL )
return 0; return 0;
ClearMarkItems( module ); // Just in case ...
pos = module->Reference().GetTextPosition();
if( Rect.Contains( pos ) )
{
module->Reference().SetFlags( SELECTED );
ItemsCount++;
}
pos = module->Value().GetTextPosition();
if( Rect.Contains( pos ) )
{
module->Value().SetFlags( SELECTED );
ItemsCount++;
}
pad = module->Pads(); pad = module->Pads();
for( ; pad != NULL; pad = pad->Next() ) for( ; pad != NULL; pad = pad->Next() )
......
...@@ -105,33 +105,45 @@ void TEXTE_MODULE::Flip(const wxPoint& aCentre ) ...@@ -105,33 +105,45 @@ void TEXTE_MODULE::Flip(const wxPoint& aCentre )
void TEXTE_MODULE::FlipWithModule( int aOffset ) void TEXTE_MODULE::FlipWithModule( int aOffset )
{ {
// flipping the footprint is relative to the X axis
m_Pos.y = aOffset - (m_Pos.y - aOffset); m_Pos.y = aOffset - (m_Pos.y - aOffset);
NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient ); NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient );
wxPoint tmp = GetPos0();
tmp.y = -tmp.y;
SetPos0( tmp );
SetLayer( FlipLayer( GetLayer() ) ); SetLayer( FlipLayer( GetLayer() ) );
m_Mirror = IsBackLayer( GetLayer() ); m_Mirror = IsBackLayer( GetLayer() );
} }
void TEXTE_MODULE::MirrorWithModule( int aOffset ) void TEXTE_MODULE::MirrorTransformWithModule( int aOffset )
{ {
wxPoint tmp = GetTextPosition(); // Used in modedit, to transform the footprint
tmp.x = aOffset - (tmp.x - aOffset); // the mirror is relative to the Y axis
SetTextPosition( tmp ); // the position is mirrored, but the text itself is not mirrored
tmp.y = GetPos0().y; // Note also in module editor, m_Pos0 = m_Pos
SetPos0( tmp ); m_Pos.x = aOffset - (m_Pos.x - aOffset);
m_Pos0 = m_Pos;
NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient ); NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient );
} }
void TEXTE_MODULE::RotateWithModule( const wxPoint& aOffset, double aAngle ) void TEXTE_MODULE::RotateTransformWithModule( const wxPoint& aOffset, double aAngle )
{ {
wxPoint pos = GetTextPosition(); // Used in modedit, to transform the footprint
RotatePoint( &pos, aOffset, aAngle ); // Note also in module editor, m_Pos0 = m_Pos
SetTextPosition( pos ); RotatePoint( &m_Pos, aOffset, aAngle );
SetPos0( GetTextPosition() ); m_Pos0 = m_Pos;
SetOrientation( GetOrientation() + aAngle ); SetOrientation( GetOrientation() + aAngle );
} }
void TEXTE_MODULE::MoveTransformWithModule( const wxPoint& aMoveVector )
{
// Used in modedit, to transform the footprint
// Note also in module editor, m_Pos0 = m_Pos
m_Pos0 += aMoveVector;
m_Pos = m_Pos0;
}
void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
{ {
......
...@@ -94,17 +94,21 @@ public: ...@@ -94,17 +94,21 @@ public:
void Flip( const wxPoint& aCentre ); void Flip( const wxPoint& aCentre );
/// Rotate entity during module rotation /// Rotate text during module rotation transform, in footprint editor
void RotateWithModule( const wxPoint& aOffset, double aAngle ); void RotateTransformWithModule( const wxPoint& aOffset, double aAngle );
/// Flip entity during module flip /// Flip entity during module flip
void FlipWithModule( int aOffset ); void FlipWithModule( int aOffset );
/// Mirror entiry during module mirroring /// Mirror text during module mirroring transform, in footprint editor
void MirrorWithModule( int aOffset ); /// the text itself is not mirrored, only position.
void MirrorTransformWithModule( int aOffset );
/// move text during module mirroring transform, in footprint editor
void MoveTransformWithModule( const wxPoint& aMoveVector );
/// @deprecated it seems (but the type is used to 'protect' /// @deprecated it seems (but the type is used to 'protect'
//reference and value from deletion, and for identification) // reference and value from deletion, and for identification)
void SetType( TEXT_TYPE aType ) { m_Type = aType; } void SetType( TEXT_TYPE aType ) { m_Type = aType; }
TEXT_TYPE GetType() const { return m_Type; } TEXT_TYPE GetType() const { return m_Type; }
......
...@@ -826,17 +826,10 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) ...@@ -826,17 +826,10 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
switch( transform ) switch( transform )
{ {
case ID_MODEDIT_MODULE_ROTATE: case ID_MODEDIT_MODULE_ROTATE:
module->Reference().RotateWithModule( wxPoint(0,0), angle );
module->Value().RotateWithModule( wxPoint(0,0), angle );
RotateMarkedItems( module, wxPoint(0,0), true ); RotateMarkedItems( module, wxPoint(0,0), true );
break; break;
case ID_MODEDIT_MODULE_MIRROR: case ID_MODEDIT_MODULE_MIRROR:
module->Reference().MirrorWithModule( 0 );
module->Value().MirrorWithModule( 0 );
// Mirror pads and graphic items of the footprint:
MirrorMarkedItems( module, wxPoint(0,0), true ); MirrorMarkedItems( module, wxPoint(0,0), true );
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment