Commit 953f71df authored by Maciej Suminski's avatar Maciej Suminski

Move() method updates local coordinates in EDGE_MODULE, D_PAD and TEXTE_MODULE classes.

parent 2ee890d7
......@@ -90,6 +90,25 @@ void EDGE_MODULE::Copy( EDGE_MODULE* source )
}
void EDGE_MODULE::SetLocalCoord()
{
MODULE* module = (MODULE*) m_Parent;
if( module == NULL )
{
m_Start0 = m_Start;
m_End0 = m_End;
return;
}
m_Start0 = m_Start - module->GetPosition();
m_End0 = m_End - module->GetPosition();
double angle = module->GetOrientation();
RotatePoint( &m_Start0.x, &m_Start0.y, -angle );
RotatePoint( &m_End0.x, &m_End0.y, -angle );
}
void EDGE_MODULE::SetDrawCoord()
{
MODULE* module = (MODULE*) m_Parent;
......
......@@ -61,12 +61,23 @@ public:
void Copy( EDGE_MODULE* source ); // copy structure
void Move( const wxPoint& aMoveVector )
{
m_Start += aMoveVector;
m_End += aMoveVector;
SetLocalCoord();
}
void SetStart0( const wxPoint& aPoint ) { m_Start0 = aPoint; }
const wxPoint& GetStart0() const { return m_Start0; }
void SetEnd0( const wxPoint& aPoint ) { m_End0 = aPoint; }
const wxPoint& GetEnd0() const { return m_End0; }
///> Set relative coordinates.
void SetLocalCoord();
///> Set absolute coordinates.
void SetDrawCoord();
/* drawing functions */
......
......@@ -228,6 +228,38 @@ const EDA_RECT D_PAD::GetBoundingBox() const
}
void D_PAD::SetDrawCoord()
{
MODULE* module = (MODULE*) m_Parent;
m_Pos = m_Pos0;
if( module == NULL )
return;
double angle = module->GetOrientation();
RotatePoint( &m_Pos.x, &m_Pos.y, angle );
m_Pos += module->GetPosition();
}
void D_PAD::SetLocalCoord()
{
MODULE* module = (MODULE*) m_Parent;
if( module == NULL )
{
m_Pos0 = m_Pos;
return;
}
m_Pos0 = m_Pos - module->GetPosition();
double angle = module->GetOrientation();
RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
}
void D_PAD::SetAttribute( PAD_ATTR_T aAttribute )
{
m_Attribute = aAttribute;
......
......@@ -381,6 +381,12 @@ public:
// Virtual function:
const EDA_RECT GetBoundingBox() const;
///> Set absolute coordinates.
void SetDrawCoord();
///> Set relative coordinates.
void SetLocalCoord();
/**
* Function Compare
* compares two pads and return 0 if they are equal.
......@@ -391,6 +397,7 @@ public:
void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
SetLocalCoord();
}
......
......@@ -129,7 +129,7 @@ int TEXTE_MODULE::GetLength() const
return m_Text.Len();
}
// Update draw coordinates
void TEXTE_MODULE::SetDrawCoord()
{
MODULE* module = (MODULE*) m_Parent;
......@@ -146,8 +146,6 @@ void TEXTE_MODULE::SetDrawCoord()
}
// Update "local" coordinates (coordinates relatives to the footprint
// anchor point)
void TEXTE_MODULE::SetLocalCoord()
{
MODULE* module = (MODULE*) m_Parent;
......@@ -163,6 +161,7 @@ void TEXTE_MODULE::SetLocalCoord()
RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
}
bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) const
{
wxPoint rel_pos;
......
......@@ -71,7 +71,6 @@ public:
return aItem && PCB_MODULE_TEXT_T == aItem->Type();
}
virtual const wxPoint& GetPosition() const
{
return m_Pos;
......@@ -117,9 +116,11 @@ public:
// Virtual function
const EDA_RECT GetBoundingBox() const;
void SetDrawCoord(); // Set absolute coordinates.
///> Set absolute coordinates.
void SetDrawCoord();
void SetLocalCoord(); // Set relative coordinates.
///> Set relative coordinates.
void SetLocalCoord();
/* drawing functions */
void Draw( EDA_DRAW_PANEL* panel,
......
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