Commit 598cc337 authored by charras's avatar charras
Browse files

Code cleaning

parent ada6b6b8
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@ email address.
++Eeschema:
++Eeschema:
    Code cleaning.
    Code cleaning.
    LibDrawPolyline uses now std::vector<wxPoint> to handle corners.
    LibDrawPolyline uses now std::vector<wxPoint> to handle corners.
    DrawPolylineStruct uses now std::vector<wxPoint> to handle corners.






+8 −12
Original line number Original line Diff line number Diff line
@@ -626,7 +626,7 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
/* Given a structure rotate it to 90 degrees refer to the Center point.
/* Given a structure rotate it to 90 degrees refer to the Center point.
 */
 */
{
{
    int dx, ii, * Points;
    int dx;
    DrawPolylineStruct*            DrawPoly;
    DrawPolylineStruct*            DrawPoly;
    DrawJunctionStruct*            DrawConnect;
    DrawJunctionStruct*            DrawConnect;
    EDA_DrawLineStruct*            DrawSegment;
    EDA_DrawLineStruct*            DrawSegment;
@@ -652,13 +652,12 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )


    case DRAW_POLYLINE_STRUCT_TYPE:
    case DRAW_POLYLINE_STRUCT_TYPE:
        DrawPoly = (DrawPolylineStruct*) DrawStruct;
        DrawPoly = (DrawPolylineStruct*) DrawStruct;
        Points   = DrawPoly->m_Points;
        for( unsigned ii = 0; ii < DrawPoly->GetCornerCount(); ii++ )
        for( ii = 0; ii < DrawPoly->m_NumOfPoints; ii++ )
        {
        {
            wxPoint point;
            wxPoint point;
            point.x = Points[ii * 2]; point.y = Points[ii * 2 + 1];
            point = DrawPoly->m_PolyPoints[ii];
            MirrorYPoint( point, Center );
            MirrorYPoint( point, Center );
            Points[ii * 2] = point.x; Points[ii * 2 + 1] = point.y;
            DrawPoly->m_PolyPoints[ii] = point;
        }
        }


        break;
        break;
@@ -740,7 +739,7 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
        MirrorYPoint( DrawLibItem->m_Pos, Center );
        MirrorYPoint( DrawLibItem->m_Pos, Center );
        dx -= DrawLibItem->m_Pos.x;
        dx -= DrawLibItem->m_Pos.x;


        for( ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
        for( int ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
        {
        {
            /* move the fields to the new position because the component itself has moved */
            /* move the fields to the new position because the component itself has moved */
            DrawLibItem->GetField( ii )->m_Pos.x -= dx;
            DrawLibItem->GetField( ii )->m_Pos.x -= dx;
@@ -1194,7 +1193,6 @@ void MoveOneStruct( SCH_ITEM* DrawStruct, const wxPoint& move_vector )
/* Given a structure move it by Dx, Dy.
/* Given a structure move it by Dx, Dy.
 */
 */
{
{
    int ii, * Points;
    DrawPolylineStruct*            DrawPoly;
    DrawPolylineStruct*            DrawPoly;
    DrawJunctionStruct*            DrawConnect;
    DrawJunctionStruct*            DrawConnect;
    EDA_DrawLineStruct*            DrawSegment;
    EDA_DrawLineStruct*            DrawSegment;
@@ -1215,11 +1213,9 @@ void MoveOneStruct( SCH_ITEM* DrawStruct, const wxPoint& move_vector )


    case DRAW_POLYLINE_STRUCT_TYPE:
    case DRAW_POLYLINE_STRUCT_TYPE:
        DrawPoly = (DrawPolylineStruct*) DrawStruct;
        DrawPoly = (DrawPolylineStruct*) DrawStruct;
        Points   = DrawPoly->m_Points;
        for( unsigned ii = 0; ii < DrawPoly->GetCornerCount(); ii++ )
        for( ii = 0; ii < DrawPoly->m_NumOfPoints; ii++ )
        {
        {
            Points[ii * 2]     += move_vector.x;
            DrawPoly->m_PolyPoints[ii] += move_vector;
            Points[ii * 2 + 1] += move_vector.y;
        }
        }


        break;
        break;
@@ -1275,7 +1271,7 @@ void MoveOneStruct( SCH_ITEM* DrawStruct, const wxPoint& move_vector )
    case TYPE_SCH_COMPONENT:
    case TYPE_SCH_COMPONENT:
        DrawLibItem = (SCH_COMPONENT*) DrawStruct;
        DrawLibItem = (SCH_COMPONENT*) DrawStruct;
        DrawLibItem->m_Pos += move_vector;
        DrawLibItem->m_Pos += move_vector;
        for( ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
        for( int ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
        {
        {
            DrawLibItem->GetField( ii )->m_Pos += move_vector;
            DrawLibItem->GetField( ii )->m_Pos += move_vector;
        }
        }
+6 −8
Original line number Original line Diff line number Diff line
@@ -474,24 +474,22 @@ static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool eras


    GRSetDrawMode( DC, g_XorMode );
    GRSetDrawMode( DC, g_XorMode );


    int idx = NewPoly->GetCornerCount() - 1;
    if( g_HVLines )
    if( g_HVLines )
    {
    {
        /* Coerce the line to vertical or horizontal one: */
        /* Coerce the line to vertical or horizontal one: */
        if( ABS( endpos.x - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] ) <
        if( ABS( endpos.x - NewPoly->m_PolyPoints[idx].x ) <
           ABS( endpos.y - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] ) )
           ABS( endpos.y - NewPoly->m_PolyPoints[idx].y ) )
            endpos.x = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2];
            endpos.x = NewPoly->m_PolyPoints[idx].x;
        else
        else
            endpos.y = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1];
            endpos.y = NewPoly->m_PolyPoints[idx].y;
    }
    }


    NewPoly->m_NumOfPoints++;
    if( erase )
    if( erase )
        RedrawOneStruct( panel, DC, NewPoly, g_XorMode, color );
        RedrawOneStruct( panel, DC, NewPoly, g_XorMode, color );


    NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] = endpos.x;
    NewPoly->m_PolyPoints[idx] = endpos;
    NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] = endpos.y;
    RedrawOneStruct( panel, DC, NewPoly, g_XorMode, color );
    RedrawOneStruct( panel, DC, NewPoly, g_XorMode, color );
    NewPoly->m_NumOfPoints--;
}
}




+1 −1
Original line number Original line Diff line number Diff line
@@ -59,7 +59,7 @@ public:
    void          SetFields( const std::vector <LibDrawField> aFields );
    void          SetFields( const std::vector <LibDrawField> aFields );


    void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
    void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
               int aDrawMode, void* aData, int aTransformMatrix[2][2] );
               int aDrawMode, void* aData, const int aTransformMatrix[2][2] );


    /**
    /**
     * Function HitTest
     * Function HitTest
+2 −2
Original line number Original line Diff line number Diff line
@@ -19,7 +19,7 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
                       int               aColor,
                       int               aColor,
                       int               aDrawMode,
                       int               aDrawMode,
                       void*             aData,
                       void*             aData,
                       int               aTransformMatrix[2][2] )
                       const int         aTransformMatrix[2][2] )
/**********************************************************************************************/
/**********************************************************************************************/
{
{
    // Invisibles pins are only drawn on request.
    // Invisibles pins are only drawn on request.
@@ -866,7 +866,7 @@ wxPoint LibDrawPin::ReturnPinEndPoint()




/********************************************************/
/********************************************************/
int LibDrawPin::ReturnPinDrawOrient( int TransMat[2][2] )
int LibDrawPin::ReturnPinDrawOrient( const int TransMat[2][2] )
/********************************************************/
/********************************************************/


/** Function ReturnPinDrawOrient
/** Function ReturnPinDrawOrient
Loading