Recompute local coordinates when an object is added to MODULE.

This commit is contained in:
Maciej Suminski 2016-06-03 17:07:13 +02:00
parent b5bfa14057
commit 0bf553b06c
2 changed files with 21 additions and 2 deletions

View File

@ -282,6 +282,27 @@ void MODULE::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode )
aBoardItem->SetParent( this ); aBoardItem->SetParent( this );
SetLastEditTime(); SetLastEditTime();
// Update relative coordinates, it can be done only after there is a parent object assigned
switch( aBoardItem->Type() )
{
case PCB_MODULE_TEXT_T:
static_cast<TEXTE_MODULE*>( aBoardItem )->SetLocalCoord();
break;
case PCB_MODULE_EDGE_T:
static_cast<EDGE_MODULE*>( aBoardItem )->SetLocalCoord();
break;
case PCB_PAD_T:
static_cast<D_PAD*>( aBoardItem )->SetLocalCoord();
break;
default:
// Huh? It should have been filtered out by the previous switch
assert(false);
break;
}
} }

View File

@ -264,7 +264,6 @@ bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule )
converted = new EDGE_MODULE( aModule ); converted = new EDGE_MODULE( aModule );
*static_cast<DRAWSEGMENT*>( converted ) = *static_cast<DRAWSEGMENT*>( item ); *static_cast<DRAWSEGMENT*>( converted ) = *static_cast<DRAWSEGMENT*>( item );
aModule->Add( converted ); aModule->Add( converted );
static_cast<EDGE_MODULE*>( converted )->SetLocalCoord();
delete item; delete item;
break; break;
} }
@ -274,7 +273,6 @@ bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule )
converted = new TEXTE_MODULE( aModule ); converted = new TEXTE_MODULE( aModule );
*static_cast<TEXTE_PCB*>( converted ) = *static_cast<TEXTE_PCB*>( item ); *static_cast<TEXTE_PCB*>( converted ) = *static_cast<TEXTE_PCB*>( item );
aModule->Add( converted ); aModule->Add( converted );
static_cast<TEXTE_MODULE*>( converted )->SetLocalCoord();
delete item; delete item;
break; break;
} }