2007-10-26 06:08:19 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Functions to handle markers used to show somthing (usually a drc problem) */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/* file class_marker.cpp */
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "class_marker.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Routines Locales : */
|
|
|
|
|
|
|
|
|
|
|
|
/* Default bitmap shape for markers */
|
|
|
|
static char Default_MarkerBitmap[] =
|
|
|
|
{
|
2007-12-01 05:37:44 +00:00
|
|
|
12, 12, /* x and y size of the bitmap */
|
2007-10-26 06:08:19 +00:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*******************/
|
2007-11-27 22:49:35 +00:00
|
|
|
/* Classe MARKER */
|
2007-10-26 06:08:19 +00:00
|
|
|
/*******************/
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
void MARKER::init()
|
2007-10-26 06:08:19 +00:00
|
|
|
{
|
|
|
|
m_Bitmap = NULL;
|
|
|
|
m_Type = 0;
|
|
|
|
m_Color = RED;
|
|
|
|
m_Bitmap = Default_MarkerBitmap;
|
|
|
|
m_Size.x = Default_MarkerBitmap[0];
|
|
|
|
m_Size.y = Default_MarkerBitmap[1];
|
|
|
|
}
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
MARKER::MARKER( BOARD_ITEM* StructFather ) :
|
|
|
|
BOARD_ITEM( StructFather, TYPEMARKER ),
|
|
|
|
m_drc()
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos,
|
|
|
|
const wxString& aText, const wxPoint& aPos,
|
|
|
|
const wxString& bText, const wxPoint& bPos ) :
|
|
|
|
BOARD_ITEM( NULL, TYPEMARKER ) // parent set during BOARD::Add()
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
|
|
|
|
SetData( aErrorCode, aMarkerPos,
|
|
|
|
aText, aPos,
|
|
|
|
bText, bPos );
|
|
|
|
}
|
|
|
|
|
2007-10-26 06:08:19 +00:00
|
|
|
|
|
|
|
/* Effacement memoire de la structure */
|
2007-11-27 22:49:35 +00:00
|
|
|
MARKER::~MARKER()
|
2007-10-26 06:08:19 +00:00
|
|
|
{
|
2007-11-27 22:49:35 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
printf("MARKER %p deleted\n", this );
|
|
|
|
#endif
|
2007-10-26 06:08:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
void MARKER::SetData( int aErrorCode, const wxPoint& aMarkerPos,
|
|
|
|
const wxString& aText, const wxPoint& aPos,
|
|
|
|
const wxString& bText, const wxPoint& bPos )
|
|
|
|
{
|
|
|
|
m_drc.SetData( aErrorCode, aMarkerPos,
|
|
|
|
aText, bText,
|
|
|
|
aPos, bPos );
|
|
|
|
|
|
|
|
// @todo: switch on error code to set error code specific color, and possibly bitmap.
|
|
|
|
m_Color = WHITE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-26 06:08:19 +00:00
|
|
|
/* supprime du chainage la structure Struct
|
|
|
|
* les structures arrieres et avant sont chainees directement
|
|
|
|
*/
|
2007-11-27 22:49:35 +00:00
|
|
|
void MARKER::UnLink()
|
2007-10-26 06:08:19 +00:00
|
|
|
{
|
2007-11-27 22:49:35 +00:00
|
|
|
wxFAIL_MSG( wxT("MARKER::UnLink is deprecated") );
|
2007-10-26 06:08:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-27 22:49:35 +00:00
|
|
|
void MARKER::Display_Infos( WinEDA_DrawFrame* frame )
|
2007-10-26 06:08:19 +00:00
|
|
|
{
|
|
|
|
int text_pos;
|
|
|
|
|
|
|
|
frame->MsgPanel->EraseMsgBox();
|
|
|
|
|
2007-12-01 05:37:44 +00:00
|
|
|
const DRC_ITEM& rpt = m_drc;
|
|
|
|
|
2007-10-26 06:08:19 +00:00
|
|
|
text_pos = 1;
|
|
|
|
Affiche_1_Parametre( frame, text_pos, _( "Type" ), _("Marker"), DARKCYAN );
|
|
|
|
|
2007-12-01 05:37:44 +00:00
|
|
|
wxString errorTxt;
|
|
|
|
|
|
|
|
errorTxt << _("ErrType") << wxT("(") << rpt.GetErrorCode() << wxT(")- ") << rpt.GetErrorText() << wxT(":");
|
|
|
|
|
|
|
|
text_pos = 5;
|
|
|
|
Affiche_1_Parametre( frame, text_pos, errorTxt, wxEmptyString, RED );
|
|
|
|
|
|
|
|
wxString txtA;
|
|
|
|
txtA << DRC_ITEM::ShowCoord( rpt.GetPointA() ) << wxT(": ") << rpt.GetTextA();
|
|
|
|
|
|
|
|
wxString txtB;
|
|
|
|
txtB << DRC_ITEM::ShowCoord( rpt.GetPointB() ) << wxT(": ") << rpt.GetTextB();
|
|
|
|
|
|
|
|
text_pos = 20; // @todo pick a better color here
|
|
|
|
Affiche_1_Parametre( frame, text_pos, txtA, txtB, BLACK );
|
2007-10-26 06:08:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************/
|
2007-11-27 22:49:35 +00:00
|
|
|
bool MARKER::HitTest( const wxPoint& refPos )
|
2007-10-26 06:08:19 +00:00
|
|
|
/**********************************************/
|
|
|
|
{
|
|
|
|
// the MARKER 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 changes.
|
|
|
|
|
|
|
|
wxSize TrueSize = m_Size;
|
|
|
|
if ( ActiveScreen )
|
|
|
|
{
|
|
|
|
TrueSize.x *= ActiveScreen->GetZoom();
|
|
|
|
TrueSize.y *= ActiveScreen->GetZoom();
|
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
|
|
|
|
wxPoint pos = GetPosition();
|
2007-10-26 06:08:19 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
int dx = refPos.x - pos.x;
|
|
|
|
int dy = refPos.y - pos.y;
|
2007-10-26 06:08:19 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
2007-11-27 22:49:35 +00:00
|
|
|
void MARKER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode )
|
2007-10-26 06:08:19 +00:00
|
|
|
/**********************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 px, py;
|
|
|
|
int ii, jj;
|
|
|
|
char* pt_bitmap = m_Bitmap;
|
|
|
|
|
|
|
|
if( pt_bitmap == NULL ) return;
|
|
|
|
|
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
px = GRMapX( GetPosition().x );
|
|
|
|
py = GRMapY( GetPosition().y );
|
2007-10-26 06:08:19 +00:00
|
|
|
|
|
|
|
/* 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,
|
|
|
|
px + ii, py + jj, m_Color );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|