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 )
if( module == NULL )
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() )
{
if( !pad->IsSelected() )
......@@ -440,6 +445,12 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
if( module == NULL )
return;
if( module->Reference().IsSelected() )
module->Reference().MoveTransformWithModule( offset );
if( module->Value().IsSelected() )
module->Value().MoveTransformWithModule( offset );
D_PAD* pad = module->Pads();
for( ; pad != NULL; pad = pad->Next() )
......@@ -461,7 +472,7 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
static_cast<TEXTE_MODULE*>( item )->Move( offset );
static_cast<TEXTE_MODULE*>( item )->MoveTransformWithModule( offset );
break;
case PCB_MODULE_EDGE_T:
......@@ -477,9 +488,9 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
default:
;
}
item->ClearFlags();
}
ClearMarkItems( module );
}
......@@ -518,6 +529,9 @@ void DeleteMarkedItems( MODULE* module )
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 )
if( module == NULL )
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() )
{
// 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 )
break;
case PCB_MODULE_TEXT_T:
static_cast<TEXTE_MODULE*>( item )->MirrorWithModule( offset.x );
static_cast<TEXTE_MODULE*>( item )->MirrorTransformWithModule( offset.x );
break;
default:
break;
}
item->ClearFlags();
}
ClearMarkItems( module );
}
......@@ -607,6 +627,12 @@ void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
if( module == NULL )
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() )
{
if( !pad->IsSelected() && !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() )
{
if( !item->IsSelected() && !force_all)
if( !item->IsSelected() && !force_all )
continue;
switch( item->Type() )
......@@ -644,26 +670,27 @@ void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
break;
case PCB_MODULE_TEXT_T:
static_cast<TEXTE_MODULE*>( item )->RotateWithModule( wxPoint( 0, 0 ), 900 );
static_cast<TEXTE_MODULE*>( item )->RotateTransformWithModule( offset, 900 );
break;
default:
break;
}
item->ClearFlags();
}
ClearMarkItems( module );
}
void ClearMarkItems( MODULE* module )
{
EDA_ITEM* item;
if( module == NULL )
return;
item = module->GraphicalItems();
module->Reference().ClearFlags();
module->Value().ClearFlags();
EDA_ITEM* item = module->GraphicalItems();
for( ; item != NULL; item = item->Next() )
{
......@@ -692,6 +719,24 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
if( module == NULL )
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();
for( ; pad != NULL; pad = pad->Next() )
......
......@@ -105,33 +105,45 @@ void TEXTE_MODULE::Flip(const wxPoint& aCentre )
void TEXTE_MODULE::FlipWithModule( int aOffset )
{
// flipping the footprint is relative to the X axis
m_Pos.y = aOffset - (m_Pos.y - aOffset);
NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient );
wxPoint tmp = GetPos0();
tmp.y = -tmp.y;
SetPos0( tmp );
SetLayer( FlipLayer( GetLayer() ) );
m_Mirror = IsBackLayer( GetLayer() );
}
void TEXTE_MODULE::MirrorWithModule( int aOffset )
void TEXTE_MODULE::MirrorTransformWithModule( int aOffset )
{
wxPoint tmp = GetTextPosition();
tmp.x = aOffset - (tmp.x - aOffset);
SetTextPosition( tmp );
tmp.y = GetPos0().y;
SetPos0( tmp );
// Used in modedit, to transform the footprint
// the mirror is relative to the Y axis
// the position is mirrored, but the text itself is not mirrored
// Note also in module editor, m_Pos0 = m_Pos
m_Pos.x = aOffset - (m_Pos.x - aOffset);
m_Pos0 = m_Pos;
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();
RotatePoint( &pos, aOffset, aAngle );
SetTextPosition( pos );
SetPos0( GetTextPosition() );
// Used in modedit, to transform the footprint
// Note also in module editor, m_Pos0 = m_Pos
RotatePoint( &m_Pos, aOffset, aAngle );
m_Pos0 = m_Pos;
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 )
{
......
......@@ -94,17 +94,21 @@ public:
void Flip( const wxPoint& aCentre );
/// Rotate entity during module rotation
void RotateWithModule( const wxPoint& aOffset, double aAngle );
/// Rotate text during module rotation transform, in footprint editor
void RotateTransformWithModule( const wxPoint& aOffset, double aAngle );
/// Flip entity during module flip
void FlipWithModule( int aOffset );
/// Mirror entiry during module mirroring
void MirrorWithModule( int aOffset );
/// Mirror text during module mirroring transform, in footprint editor
/// 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'
//reference and value from deletion, and for identification)
// reference and value from deletion, and for identification)
void SetType( TEXT_TYPE aType ) { m_Type = aType; }
TEXT_TYPE GetType() const { return m_Type; }
......
......@@ -826,17 +826,10 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
switch( transform )
{
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 );
break;
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 );
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