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"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
|
2007-10-26 06:08:19 +00:00
|
|
|
#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;
|
2008-02-23 04:53:44 +00:00
|
|
|
m_Size.x = Default_MarkerBitmap[0];
|
2007-10-26 06:08:19 +00:00
|
|
|
m_Size.y = Default_MarkerBitmap[1];
|
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
MARKER::MARKER( BOARD_ITEM* aParent ) :
|
|
|
|
BOARD_ITEM( aParent, TYPE_MARKER ),
|
2007-12-01 03:42:52 +00:00
|
|
|
m_drc()
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-23 04:53:44 +00:00
|
|
|
MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos,
|
|
|
|
const wxString& aText, const wxPoint& aPos,
|
2007-12-01 03:42:52 +00:00
|
|
|
const wxString& bText, const wxPoint& bPos ) :
|
2008-12-04 04:28:11 +00:00
|
|
|
BOARD_ITEM( NULL, TYPE_MARKER ) // parent set during BOARD::Add()
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
|
2008-02-23 04:53:44 +00:00
|
|
|
SetData( aErrorCode, aMarkerPos,
|
2007-12-01 03:42:52 +00:00
|
|
|
aText, aPos,
|
|
|
|
bText, bPos );
|
|
|
|
}
|
|
|
|
|
2008-02-23 04:53:44 +00:00
|
|
|
MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos,
|
2008-01-12 20:31:56 +00:00
|
|
|
const wxString& aText, const wxPoint& aPos ) :
|
2008-12-04 04:28:11 +00:00
|
|
|
BOARD_ITEM( NULL, TYPE_MARKER ) // parent set during BOARD::Add()
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
|
2008-02-23 04:53:44 +00:00
|
|
|
SetData( aErrorCode, aMarkerPos,
|
2008-01-12 20:31:56 +00:00
|
|
|
aText, aPos );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-23 04:53:44 +00:00
|
|
|
void MARKER::SetData( int aErrorCode, const wxPoint& aMarkerPos,
|
|
|
|
const wxString& aText, const wxPoint& aPos,
|
2007-12-01 03:42:52 +00:00
|
|
|
const wxString& bText, const wxPoint& bPos )
|
|
|
|
{
|
2008-02-23 04:53:44 +00:00
|
|
|
m_drc.SetData( aErrorCode, aMarkerPos,
|
2007-12-01 03:42:52 +00:00
|
|
|
aText, bText,
|
|
|
|
aPos, bPos );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
// @todo: switch on error code to set error code specific color, and possibly bitmap.
|
|
|
|
m_Color = WHITE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-23 04:53:44 +00:00
|
|
|
void MARKER::SetData( int aErrorCode, const wxPoint& aMarkerPos,
|
2008-01-12 20:31:56 +00:00
|
|
|
const wxString& aText, const wxPoint& aPos )
|
|
|
|
{
|
2008-02-23 04:53:44 +00:00
|
|
|
m_drc.SetData( aErrorCode, aMarkerPos,
|
2008-01-12 20:31:56 +00:00
|
|
|
aText, aPos );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
// @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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
void MARKER::DisplayInfo( 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;
|
2008-02-23 04:53:44 +00:00
|
|
|
|
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;
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2008-01-10 20:53:41 +00:00
|
|
|
errorTxt << _("ErrType") << wxT("(") << rpt.GetErrorCode() << wxT(")- ") << rpt.GetErrorText() << wxT(":");
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-01 05:37:44 +00:00
|
|
|
text_pos = 5;
|
|
|
|
Affiche_1_Parametre( frame, text_pos, errorTxt, wxEmptyString, RED );
|
|
|
|
|
|
|
|
wxString txtA;
|
|
|
|
txtA << DRC_ITEM::ShowCoord( rpt.GetPointA() ) << wxT(": ") << rpt.GetTextA();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-01 05:37:44 +00:00
|
|
|
wxString txtB;
|
2008-02-23 04:53:44 +00:00
|
|
|
if ( rpt.HasSecondItem() )
|
|
|
|
txtB << DRC_ITEM::ShowCoord( rpt.GetPointB() ) << wxT(": ") << rpt.GetTextB();
|
|
|
|
|
2008-01-10 20:53:41 +00:00
|
|
|
text_pos = 25;
|
|
|
|
Affiche_1_Parametre( frame, text_pos, txtA, txtB, DARKBROWN );
|
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.
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-10-26 06:08:19 +00:00
|
|
|
wxSize TrueSize = m_Size;
|
2008-02-23 04:53:44 +00:00
|
|
|
if ( ActiveScreen )
|
|
|
|
{
|
2009-01-29 14:26:20 +00:00
|
|
|
ActiveScreen->Unscale( TrueSize );
|
2008-02-23 04:53:44 +00:00
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
|
|
|
|
wxPoint pos = GetPosition();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
int dx = refPos.x - pos.x;
|
|
|
|
int dy = refPos.y - pos.y;
|
2008-02-23 04:53:44 +00:00
|
|
|
|
|
|
|
/* is refPos in the box: Marker size to right an bottom,
|
|
|
|
or size/2 to left or top */
|
2007-10-26 06:08:19 +00:00
|
|
|
if( dx <= TrueSize.x && dy <= TrueSize.y &&
|
2008-02-23 04:53:44 +00:00
|
|
|
dx >= -TrueSize.x/2 && dy >= -TrueSize.y/2 )
|
2007-10-26 06:08:19 +00:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
2008-04-01 05:21:50 +00:00
|
|
|
void MARKER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode, const wxPoint& offset )
|
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 );
|
|
|
|
|
2008-02-23 04:53:44 +00:00
|
|
|
px = GRMapX( GetPosition().x );
|
2007-12-01 03:42:52 +00:00
|
|
|
py = GRMapY( GetPosition().y );
|
2007-10-26 06:08:19 +00:00
|
|
|
|
|
|
|
/* Get the bitmap size */
|
2008-02-23 04:53:44 +00:00
|
|
|
m_Size.x = *(pt_bitmap++);
|
2007-10-26 06:08:19 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|