2007-09-25 19:39:00 +00:00
|
|
|
/*****************************************/
|
|
|
|
/* class BOARD_ITEM: som basic functions */
|
|
|
|
/*****************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
#include "id.h"
|
|
|
|
#include "collectors.h"
|
|
|
|
|
|
|
|
#include "bitmaps.h"
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2008-05-05 19:52:09 +00:00
|
|
|
|
|
|
|
/********************************************************/
|
|
|
|
wxString BOARD_ITEM::ShowShape( Track_Shapes aShape )
|
|
|
|
/********************************************************/
|
|
|
|
{
|
|
|
|
switch( aShape )
|
|
|
|
{
|
|
|
|
case S_SEGMENT: return _( "Line" );
|
|
|
|
case S_RECT: return _( "Rect" );
|
|
|
|
case S_ARC: return _( "Arc" );
|
|
|
|
case S_CIRCLE: return _( "Circle" );
|
2009-06-25 20:45:27 +00:00
|
|
|
case S_CURVE: return _( "Bezier Curve" );
|
2008-05-05 19:52:09 +00:00
|
|
|
|
|
|
|
// used in Gerbview:
|
|
|
|
case S_ARC_RECT: return wxT( "arc_rect" );
|
|
|
|
case S_SPOT_OVALE: return wxT( "spot_oval" );
|
|
|
|
case S_SPOT_CIRCLE: return wxT( "spot_circle" );
|
|
|
|
case S_SPOT_RECT: return wxT( "spot_rect" );
|
|
|
|
case S_POLYGON: return wxT( "polygon" );
|
|
|
|
default: return wxT( "??" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-25 19:39:00 +00:00
|
|
|
/********************************************************/
|
|
|
|
wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
|
|
|
|
/********************************************************/
|
|
|
|
|
|
|
|
/** return a specific comment for "this". Used in pop up menus
|
|
|
|
* @param aPcb = the parent board
|
|
|
|
*/
|
|
|
|
{
|
2008-05-05 19:52:09 +00:00
|
|
|
wxString text;
|
|
|
|
wxString msg;
|
|
|
|
wxString temp;
|
2009-05-24 18:28:36 +00:00
|
|
|
NETINFO_ITEM* net;
|
2008-05-05 19:52:09 +00:00
|
|
|
const BOARD_ITEM* item = this;
|
|
|
|
D_PAD * pad;
|
2007-09-25 19:39:00 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MODULE:
|
2007-09-25 19:39:00 +00:00
|
|
|
text << _( "Footprint" ) << wxT( " " ) << ( (MODULE*) item )->GetReference();
|
2008-02-19 00:30:10 +00:00
|
|
|
text << wxT( " (" ) << aPcb->GetLayerName( item->m_Layer ).Trim() << wxT( ")" );
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_PAD:
|
2008-02-14 01:07:52 +00:00
|
|
|
pad = (D_PAD *) this;
|
2007-10-13 12:17:17 +00:00
|
|
|
text << _( "Pad" ) << wxT( " \"" ) << pad->ReturnStringPadName()
|
2008-02-14 01:07:52 +00:00
|
|
|
<< wxT( "\" (" );
|
|
|
|
if ( (pad->m_Masque_Layer & ALL_CU_LAYERS) == ALL_CU_LAYERS )
|
|
|
|
text << _("all copper layers");
|
|
|
|
else if( (pad->m_Masque_Layer & CUIVRE_LAYER) == CUIVRE_LAYER )
|
2008-02-19 00:30:10 +00:00
|
|
|
text << aPcb->GetLayerName( COPPER_LAYER_N ).Trim();
|
2008-02-14 01:07:52 +00:00
|
|
|
else if( (pad->m_Masque_Layer & CMP_LAYER) == CMP_LAYER )
|
2008-02-19 00:30:10 +00:00
|
|
|
text << aPcb->GetLayerName( LAYER_CMP_N );
|
2008-02-14 01:07:52 +00:00
|
|
|
else text << _("???");
|
|
|
|
text << _( ") of " ) << ( (MODULE*) GetParent() )->GetReference();
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_DRAWSEGMENT:
|
2008-05-05 19:52:09 +00:00
|
|
|
text << _( "Pcb Graphic" ) << wxT(": ")
|
|
|
|
<< ShowShape( (Track_Shapes) ((DRAWSEGMENT*)item)->m_Shape )
|
|
|
|
<< wxChar(' ') << _("Length:") << valeur_param( (int) ((DRAWSEGMENT*)item)->GetLength(), temp )
|
|
|
|
<< _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim();
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE:
|
2007-09-25 19:39:00 +00:00
|
|
|
text << _( "Pcb Text" ) << wxT( " " );;
|
|
|
|
if( ( (TEXTE_PCB*) item )->m_Text.Len() < 12 )
|
|
|
|
text << ( (TEXTE_PCB*) item )->m_Text;
|
|
|
|
else
|
|
|
|
text += ( (TEXTE_PCB*) item )->m_Text.Left( 10 ) + wxT( ".." );
|
2008-02-19 00:30:10 +00:00
|
|
|
text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim();
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
2007-09-25 19:39:00 +00:00
|
|
|
switch( ( (TEXTE_MODULE*) item )->m_Type )
|
|
|
|
{
|
|
|
|
case TEXT_is_REFERENCE:
|
|
|
|
text << _( "Reference" ) << wxT( " " ) << ( (TEXTE_MODULE*) item )->m_Text;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEXT_is_VALUE:
|
|
|
|
text << _( "Value" ) << wxT( " " ) << ( (TEXTE_MODULE*) item )->m_Text << _( " of " )
|
|
|
|
<< ( (MODULE*) GetParent() )->GetReference();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: // wrap this one in quotes:
|
|
|
|
text << _( "Text" ) << wxT( " \"" ) << ( (TEXTE_MODULE*) item )->m_Text <<
|
|
|
|
wxT( "\"" ) << _( " of " )
|
|
|
|
<< ( (MODULE*) GetParent() )->GetReference();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_EDGE_MODULE:
|
2007-09-25 19:39:00 +00:00
|
|
|
text << _( "Graphic" ) << wxT( " " );
|
2008-05-05 19:52:09 +00:00
|
|
|
text << ShowShape( (Track_Shapes) ( (EDGE_MODULE*) item )->m_Shape );
|
2008-02-19 00:30:10 +00:00
|
|
|
text << wxT( " (" ) << aPcb->GetLayerName( ((EDGE_MODULE*) item )->m_Layer ).Trim() << wxT( ")" );
|
2008-02-14 01:07:52 +00:00
|
|
|
text << _( " of " )
|
2007-09-25 19:39:00 +00:00
|
|
|
<< ( (MODULE*) GetParent() )->GetReference();
|
|
|
|
break;
|
2008-05-05 19:52:09 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TRACK:
|
2008-02-14 01:07:52 +00:00
|
|
|
// deleting tracks requires all the information we can get to
|
2008-05-05 19:52:09 +00:00
|
|
|
// disambiguate all the choices under the cursor!
|
|
|
|
text << _( "Track" ) << wxT( " " ) << ((TRACK*)item)->ShowWidth();
|
|
|
|
net = aPcb->FindNet( ((TRACK*)item)->GetNet() );
|
|
|
|
if( net )
|
2007-09-25 19:39:00 +00:00
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
|
2007-09-25 19:39:00 +00:00
|
|
|
}
|
2008-05-05 19:52:09 +00:00
|
|
|
text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim()
|
|
|
|
<< wxT(" ") << _("Net:") << ((TRACK*)item)->GetNet()
|
|
|
|
<< wxT(" ") << _("Length:") << valeur_param( (int) ((TRACK*)item)->GetLength(), temp );
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_ZONE_CONTAINER:
|
2007-12-29 19:15:58 +00:00
|
|
|
text = _( "Zone Outline" );
|
2008-02-14 01:07:52 +00:00
|
|
|
{
|
2008-02-19 00:30:10 +00:00
|
|
|
ZONE_CONTAINER* area = (ZONE_CONTAINER*) this;
|
|
|
|
int ncont = area->m_Poly->GetContour(area->m_CornerSelection);
|
|
|
|
if( ncont )
|
|
|
|
text << wxT(" ") << _("(Cutout)");
|
2008-02-14 01:07:52 +00:00
|
|
|
}
|
|
|
|
text << wxT( " " );
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
|
|
|
wxString TimeStampText;
|
|
|
|
TimeStampText.Printf( wxT( "(%8.8X)" ), item->m_TimeStamp );
|
|
|
|
text << TimeStampText;
|
|
|
|
}
|
2008-09-26 19:51:36 +00:00
|
|
|
if ( !((ZONE_CONTAINER*) item)->IsOnCopperLayer() )
|
|
|
|
{
|
|
|
|
text << wxT( " [" ) << _("Not on copper layer") << wxT( "]" );
|
|
|
|
}
|
|
|
|
else if( ((ZONE_CONTAINER*) item)->GetNet() >= 0 )
|
2008-02-14 01:07:52 +00:00
|
|
|
{
|
|
|
|
net = aPcb->FindNet( ( (ZONE_CONTAINER*) item )->GetNet() );
|
|
|
|
if( net )
|
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
|
2008-02-14 01:07:52 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-19 00:30:10 +00:00
|
|
|
else // A netcode < 0 is an error flag (Netname not found or area not initialised)
|
2008-02-14 01:07:52 +00:00
|
|
|
{
|
|
|
|
text << wxT( " [" ) << ( (ZONE_CONTAINER*) item )->m_Netname << wxT( "]" );
|
|
|
|
text << wxT(" <") << _("Not Found") << wxT(">");
|
|
|
|
}
|
2008-02-19 00:30:10 +00:00
|
|
|
text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim();
|
2008-02-14 01:07:52 +00:00
|
|
|
break;
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_ZONE:
|
2008-02-14 01:07:52 +00:00
|
|
|
text = _( "Zone" );
|
|
|
|
text << wxT( " " );
|
2007-09-27 07:41:34 +00:00
|
|
|
{
|
|
|
|
wxString TimeStampText;
|
|
|
|
TimeStampText.Printf( wxT( "(%8.8X)" ), item->m_TimeStamp );
|
|
|
|
text << TimeStampText;
|
|
|
|
}
|
2007-10-13 06:18:44 +00:00
|
|
|
net = aPcb->FindNet( ( (SEGZONE*) item )->GetNet() );
|
2007-09-27 07:41:34 +00:00
|
|
|
if( net )
|
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
|
2007-09-27 07:41:34 +00:00
|
|
|
}
|
2008-02-19 00:30:10 +00:00
|
|
|
text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim();
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_VIA:
|
2007-09-25 19:39:00 +00:00
|
|
|
{
|
2007-10-01 04:14:29 +00:00
|
|
|
SEGVIA* via = (SEGVIA*) item;
|
2007-10-11 00:11:59 +00:00
|
|
|
text << _( "Via" ) << wxT( " " ) << via->ShowWidth();
|
2008-02-14 01:07:52 +00:00
|
|
|
|
|
|
|
int shape = via->Shape();
|
2008-01-12 20:31:56 +00:00
|
|
|
if( shape == VIA_BLIND_BURIED )
|
|
|
|
text << wxT(" ") << _( "Blind/Buried" );
|
|
|
|
else if( shape == VIA_MICROVIA )
|
|
|
|
text << wxT(" ") << _("Micro Via");
|
2007-10-29 15:51:48 +00:00
|
|
|
// else say nothing about normal (through) vias
|
2008-02-14 01:07:52 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
net = aPcb->FindNet( via->GetNet() );
|
2007-10-01 04:14:29 +00:00
|
|
|
if( net )
|
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
|
2007-10-01 04:14:29 +00:00
|
|
|
}
|
2008-02-14 01:07:52 +00:00
|
|
|
text << wxChar(' ') << _("Net:") << via->GetNet();
|
|
|
|
|
2007-10-19 16:24:44 +00:00
|
|
|
if( shape != VIA_THROUGH )
|
2007-10-01 12:58:02 +00:00
|
|
|
{
|
|
|
|
// say which layers, only two for now
|
|
|
|
int topLayer;
|
|
|
|
int botLayer;
|
|
|
|
via->ReturnLayerPair( &topLayer, &botLayer );
|
2008-02-19 00:30:10 +00:00
|
|
|
text << _( " on " ) << aPcb->GetLayerName( topLayer).Trim() << wxT(" <-> ")
|
|
|
|
<< aPcb->GetLayerName( botLayer ).Trim();
|
2007-10-01 12:58:02 +00:00
|
|
|
}
|
2007-09-25 19:39:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MARKER:
|
2008-02-14 01:07:52 +00:00
|
|
|
text << _( "Marker" ) << wxT( " @(" ) << ((MARKER*)item)->GetPos().x
|
2007-12-01 03:42:52 +00:00
|
|
|
<< wxT(",") << ((MARKER*)item)->GetPos().y << wxT(")");
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_COTATION:
|
2007-09-27 07:41:34 +00:00
|
|
|
text << _( "Dimension" ) << wxT( " \"" ) << ( (COTATION*) item )->GetText() << wxT( "\"" );
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MIRE:
|
2008-02-14 01:07:52 +00:00
|
|
|
valeur_param( ((MIREPCB*)item)->m_Size, msg );
|
2008-02-19 00:30:10 +00:00
|
|
|
text << _( "Target" ) << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim()
|
2007-10-29 15:51:48 +00:00
|
|
|
<< wxT( " " ) << _( "size" ) << wxT( " " ) << msg
|
2007-10-10 14:08:26 +00:00
|
|
|
;
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_ZONE_UNUSED:
|
2008-01-31 20:53:44 +00:00
|
|
|
text << wxT( "Unused" );
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
text << item->GetClass() << wxT( " Unexpected item type: BUG!!" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************/
|
|
|
|
const char** BOARD_ITEM::MenuIcon() const
|
|
|
|
/*****************************************/
|
|
|
|
|
|
|
|
/** return a specific icon pointer (an xpm icon) for "this". Used in pop up menus
|
|
|
|
* @return an icon pointer (can be NULL)
|
|
|
|
*/
|
|
|
|
{
|
2007-10-31 08:34:05 +00:00
|
|
|
const char** xpm;
|
2007-09-25 19:39:00 +00:00
|
|
|
const BOARD_ITEM* item = this;
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MODULE:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = module_xpm;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_PAD:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = pad_xpm;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_DRAWSEGMENT:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = add_dashed_line_xpm;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = add_text_xpm;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = footprint_text_xpm;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_EDGE_MODULE:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = show_mod_edge_xpm;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TRACK:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = showtrack_xpm;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_ZONE_CONTAINER:
|
|
|
|
case TYPE_ZONE:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = add_zone_xpm;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_VIA:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = pad_sketch_xpm;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MARKER:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = pad_xpm; // @todo: create and use marker xpm
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_COTATION:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = add_cotation_xpm;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MIRE:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = add_mires_xpm;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_ZONE_UNUSED:
|
2008-01-31 20:53:44 +00:00
|
|
|
xpm = 0; // unused
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
xpm = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (const char**) xpm;
|
|
|
|
}
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
void BOARD_ITEM::UnLink()
|
|
|
|
{
|
|
|
|
DLIST<BOARD_ITEM>* list = (DLIST<BOARD_ITEM>*) GetList();
|
|
|
|
wxASSERT( list );
|
|
|
|
if( list )
|
|
|
|
list->Remove( this );
|
|
|
|
}
|
|
|
|
|