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

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

parent 2ee890d7
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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;
+11 −0
Original line number Diff line number Diff line
@@ -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 */
+32 −0
Original line number Diff line number Diff line
@@ -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;
+8 −1
Original line number Diff line number Diff line
@@ -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();
    }


+2 −3
Original line number Diff line number Diff line
@@ -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;
Loading