Commit 0d2ee0c0 authored by charras's avatar charras
Browse files

See changelog. work in progress about ERC and markers in eeschema

parent f467074c
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -4,6 +4,22 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with
email address.


2009-july-06 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++All:
    Use a common class for markers in pcbnew and eeschema:
    created a basic class called MARKER_BASE
    class DRC_ITEM is also common to pcbnew and eeschema
    class MARKER (in pcbnew) and class MARKER_SCH (eeschema) are derived
    from this basic class.
    The main goal is to use a common class for pcbnew and eeschema to handle
    errors and to have similar dialogs
    and have more comprehensive ERC messages errors in eeschema
    This is a work in progress



2009-july-05 UPDATE Jerry Jacobs <jerkejacobs@gmail.com
================================================================================
+ Closing bug 2802441, No single error messages any more, 2009-06-07 over2there.
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ set(COMMON_SRCS
    bezier_curves.cpp
    block_commande.cpp
    class_drawpickedstruct.cpp
    class_marker_base.cpp
    common.cpp
    common_plot_functions.cpp
    common_plotHPGL_functions.cpp
+175 −0
Original line number Diff line number Diff line
/**********************************************************************************
* class MARKER_BASE; markers are used to show something (usually a drc/erc problem)
* Markers in pcbnew and eeschema are derived from this basic class
**********************************************************************************/

/* file class_marker_base.cpp
*/

#include "fctsys.h"
#include "gr_basic.h"
#include "class_base_screen.h"
#include "common.h"
#include "class_drawpanel.h"
#include "class_marker_base.h"


/* Default bitmap shape for markers */
static char Default_MarkerBitmap[] =
{
    12, 12,                                 /* x and y size of the bitmap */
    1,  1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,    /* bitmap: 1 = color, 0 = notrace */
    1,  1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0,
    1,  1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0,
    1,  0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
    1,  1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
    1,  1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0,
    1,  1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0,
    0,  0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
    0,  0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0,
    0,  0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0,
    0,  0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
    0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0
};


/*******************/
/* Classe MARKER_BASE */
/*******************/

void MARKER_BASE::init()
{
    m_Bitmap = NULL;
    m_MarkerType   = 0;
    m_Color  = RED;
    m_Bitmap = Default_MarkerBitmap;
    m_Size.x = Default_MarkerBitmap[0];
    m_Size.y = Default_MarkerBitmap[1];
}

MARKER_BASE::MARKER_BASE( )
{
    init();
}


MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
               const wxString& aText, const wxPoint& aPos,
               const wxString& bText, const wxPoint& bPos )
{
    init();

    SetData( aErrorCode,aMarkerPos,
         aText, aPos,
         bText, bPos );
}

MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
           const wxString& aText, const wxPoint& aPos )
{
    init();

    SetData( aErrorCode, aMarkerPos, aText, aPos );
}


/* Effacement memoire de la structure */
MARKER_BASE::~MARKER_BASE()
{
}


void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos,
         const wxString& aText, const wxPoint& aPos,
         const wxString& bText, const wxPoint& bPos )
{
    m_Pos = aMarkerPos;
    m_drc.SetData( aErrorCode,
             aText, bText, aPos, bPos );

    // @todo: switch on error code to set error code specific color, and possibly bitmap.
    m_Color = WHITE;
}


void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos,
         const wxString& aText, const wxPoint& aPos )
{
    m_Pos = aMarkerPos;
    m_drc.SetData( aErrorCode,
             aText, aPos );

    // @todo: switch on error code to set error code specific color, and possibly bitmap.
    m_Color = WHITE;
}



/**********************************************/
bool MARKER_BASE::HitTestMarker( const wxPoint& refPos )
/**********************************************/
{
    // the MARKER_BASE is 12 pixels by 12 pixels, but is not resized with zoom, so
    // as zoom changes, the effective real size (in user units) of the MARKER_BASE changes.

    wxSize TrueSize = m_Size;
    if ( ActiveScreen )
    {
        ActiveScreen->Unscale( TrueSize );
    }

    wxPoint pos = m_Pos;

    int dx = refPos.x - pos.x;
    int dy = refPos.y - pos.y;

    /* is refPos in the box: Marker size to right an bottom,
    or size/2 to left or top */
    if( dx <= TrueSize.x  && dy <= TrueSize.y &&
        dx >= -TrueSize.x/2  && dy >= -TrueSize.y/2 )
        return true;
    else
        return false;
}



/**********************************************************************/
void MARKER_BASE::DrawMarker( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode,
                                                const wxPoint& offset )
/**********************************************************************/

/*
 *  Trace un repere sur l'ecran au point de coordonnees PCB pos
 *  Le marqueur est defini par un tableau de 2 + (lig*col) elements:
 *   1er element: dim nbre ligne
 *   2er element: dim nbre col
 *   suite: lig * col elements a 0 ou 1 : si 1 mise a color du pixel
 */
{
    int   ii, jj;
    char* pt_bitmap = m_Bitmap;

    if( pt_bitmap == NULL ) return;

    GRSetDrawMode( DC, DrawMode );

    wxPoint pos = m_Pos;
    pos.x = GRMapX( pos.x );
    pos.y = GRMapY( pos.y );

    /* Get the bitmap size */
    m_Size.x = *(pt_bitmap++);
    m_Size.y = *(pt_bitmap++);

    /* Draw the bitmap */
    for( ii = 0; ii < m_Size.x; ii++ )
    {
        for( jj = 0; jj < m_Size.y; jj++, pt_bitmap++ )
        {
            if( *pt_bitmap )
                GRSPutPixel( &panel->m_ClipBox, DC,
                             pos.x + ii, pos.y + jj, m_Color );
        }
    }
}
+6 −6
Original line number Diff line number Diff line
@@ -640,7 +640,7 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
    SCH_COMPONENT*                 DrawLibItem;
    DrawSheetStruct*               DrawSheet;
    Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
    DrawMarkerStruct*              DrawMarker;
    MARKER_SCH*              DrawMarker;
    DrawNoConnectStruct*           DrawNoConnect;
    SCH_TEXT* DrawText;
    wxPoint px;
@@ -692,7 +692,7 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
        break;

    case DRAW_MARKER_STRUCT_TYPE:
        DrawMarker = (DrawMarkerStruct*) DrawStruct;
        DrawMarker = (MARKER_SCH*) DrawStruct;
        MirrorYPoint( DrawMarker->m_Pos, Center );
        break;

@@ -1198,7 +1198,7 @@ void MoveOneStruct( SCH_ITEM* DrawStruct, const wxPoint& move_vector )
    SCH_COMPONENT*                 DrawLibItem;
    DrawSheetStruct*               DrawSheet;
    Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
    DrawMarkerStruct*              DrawMarker;
    MARKER_SCH*              DrawMarker;
    DrawNoConnectStruct*           DrawNoConnect;

    if( !DrawStruct )
@@ -1241,7 +1241,7 @@ void MoveOneStruct( SCH_ITEM* DrawStruct, const wxPoint& move_vector )
        break;

    case DRAW_MARKER_STRUCT_TYPE:
        DrawMarker = (DrawMarkerStruct*) DrawStruct;
        DrawMarker = (MARKER_SCH*) DrawStruct;
        DrawMarker->m_Pos += move_vector;
        break;

@@ -1337,7 +1337,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
        break;

    case DRAW_MARKER_STRUCT_TYPE:
        NewDrawStruct = ( (DrawMarkerStruct*) DrawStruct )->GenCopy();
        NewDrawStruct = ( (MARKER_SCH*) DrawStruct )->GenCopy();
        break;

    case DRAW_NOCONNECT_STRUCT_TYPE:
@@ -1672,7 +1672,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )

        case DRAW_MARKER_STRUCT_TYPE:
                #undef STRUCT
                #define STRUCT ( (DrawMarkerStruct*) Struct )
                #define STRUCT ( (MARKER_SCH*) Struct )
            if( Struct->m_Flags & SELECTED )
                break; /* Already in list */
            if( STRUCT->m_Pos != position )
+21 −65
Original line number Diff line number Diff line
@@ -363,73 +363,33 @@ void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,


/**************************/
/* class DrawMarkerStruct */
/* class MARKER_SCH */
/**************************/

char marq_bitmap[] =
{
    12, 12, 0, 0,                           /* Dimensions x et y, offsets x et y du bitmap de marqueurs*/
    YELLOW,                                 /* Couleur */
    1,  1,  1, 1, 1, 1, 1, 1, 0, 0, 0, 0,   /* bitmap: >= 1 : color, */
    1,  1,  1, 0, 1, 0, 1, 1, 0, 0, 0, 0,   /*  0 = notrace */
    1,  1,  1, 1, 0, 0, 0, 1, 0, 0, 0, 0,
    1,  0,  1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
    1,  1,  0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
    1,  1,  0, 0, 1, 1, 1, 0, 0, 0, 0, 0,
    1,  1,  1, 0, 0, 1, 1, 1, 0, 0, 0, 0,
    0,  0,  0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
    0,  0,  0, 0, 0, 0, 0, 1, 1, 1, 0, 0,
    0,  0,  0, 0, 0, 0, 0, 0, 1, 1, 1, 0,
    0,  0,  0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
    0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 1, 0
};

char marqERC_bitmap[] =
{
    8, 8, 0, 0, /* Dimensions x et y , offsets x et y du bitmap de marqueurs*/
    -1,         /* Color: -1 = couleur non pr�cis�e */
    1, 1, 1, 1, 1, 0, 0, 0,
    1, 1, 1, 0, 1, 0, 0, 0,
    1, 1, 1, 1, 0, 0, 0, 0,
    1, 0, 1, 1, 1, 0, 0, 0,
    1, 1, 0, 1, 1, 1, 0, 0,
    0, 0, 0, 0, 1, 1, 1, 0,
    0, 0, 0, 0, 0, 1, 1, 1,
    0, 0, 0, 0, 0, 0, 1, 0,
};


DrawMarkerStruct::DrawMarkerStruct( const wxPoint& pos, const wxString& text ) :
    SCH_ITEM( NULL, DRAW_MARKER_STRUCT_TYPE )
MARKER_SCH::MARKER_SCH( const wxPoint& pos, const wxString& text ) :
    SCH_ITEM( NULL, DRAW_MARKER_STRUCT_TYPE ),
    MARKER_BASE(0, pos, text, pos)
{
    m_Pos  = pos;                   /* XY coordinates of marker. */
    m_Type = MARQ_UNSPEC;
    m_MarkFlags = 0;                // complements d'information
    m_Comment   = text;
}


DrawMarkerStruct::~DrawMarkerStruct()
MARKER_SCH::~MARKER_SCH()
{
}


DrawMarkerStruct* DrawMarkerStruct::GenCopy()
MARKER_SCH* MARKER_SCH::GenCopy()
{
    DrawMarkerStruct* newitem = new DrawMarkerStruct( m_Pos, m_Comment );
    MARKER_SCH* newitem = new MARKER_SCH( GetPos(), GetErrorText() );

    newitem->m_Type = m_Type;
    newitem->m_MarkFlags = m_MarkFlags;
    newitem->SetMarkerType( GetMarkerType());
    newitem->SetErrorLevel( GetErrorLevel());

    return newitem;
}


wxString DrawMarkerStruct::GetComment()
{
    return m_Comment;
}


#if defined(DEBUG)

@@ -440,10 +400,10 @@ wxString DrawMarkerStruct::GetComment()
 *          of nesting of this object within the overall tree.
 * @param os The ostream& to output to.
 */
void DrawMarkerStruct::Show( int nestLevel, std::ostream& os )
void MARKER_SCH::Show( int nestLevel, std::ostream& os )
{
    // for now, make it look like XML:
    NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << m_Pos
    NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << GetPos()
                                 << "/>\n";
}

@@ -456,13 +416,13 @@ void DrawMarkerStruct::Show( int nestLevel, std::ostream& os )
 * @param aFile The FILE to write to.
 * @return bool - true if success writing else false.
 */
bool DrawMarkerStruct::Save( FILE* aFile ) const
bool MARKER_SCH::Save( FILE* aFile ) const
{
    bool success = true;

    wxString msg = GetErrorText();
    if( fprintf( aFile, "Kmarq %c %-4d %-4d \"%s\" F=%X\n",
                 int(m_Type) + 'A', m_Pos.x, m_Pos.y,
                 CONV_TO_UTF8( m_Comment ), m_MarkFlags ) == EOF )
                 GetMarkerType() + 'A', GetPos().x, GetPos().y,
                 CONV_TO_UTF8( msg ), GetErrorLevel() ) == EOF )
    {
        success = false;
    }
@@ -471,26 +431,22 @@ bool DrawMarkerStruct::Save( FILE* aFile ) const
}


void DrawMarkerStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
void MARKER_SCH::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                             const wxPoint& offset, int DrawMode, int Color )
{
#define WAR 1   // utilis� aussi dans erc.cpp
#define WAR 1   // see erc.cpp

    if( m_Type == MARQ_ERC )
    if( GetMarkerType() == MARQ_ERC )
    {
        int color = Color;
        if( Color <= 0 )
        {
            color = (m_MarkFlags == WAR ) ?
            Color = (GetErrorLevel() == WAR ) ?
                    g_LayerDescr.LayerColor[LAYER_ERC_WARN] :
                    g_LayerDescr.LayerColor[LAYER_ERC_ERR];
        }

        Draw_Marqueur( panel, DC, m_Pos + offset, marqERC_bitmap, DrawMode,
                       color );
    }
    else
        Draw_Marqueur( panel, DC, m_Pos + offset, marq_bitmap, DrawMode, Color );
    m_Color = Color;
    DrawMarker( panel, DC, DrawMode, offset );
}


Loading