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"
|
|
|
|
#include "add_cotation.xpm"
|
|
|
|
#include "Add_Mires.xpm"
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************/
|
|
|
|
wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
|
|
|
|
/********************************************************/
|
|
|
|
|
|
|
|
/** return a specific comment for "this". Used in pop up menus
|
|
|
|
* @param aPcb = the parent board
|
|
|
|
*/
|
|
|
|
{
|
2007-10-29 15:51:48 +00:00
|
|
|
wxString text, msg;
|
2007-09-25 19:39:00 +00:00
|
|
|
const BOARD_ITEM* item = this;
|
|
|
|
EQUIPOT* net;
|
2007-10-13 12:17:17 +00:00
|
|
|
D_PAD * pad;
|
2007-09-25 19:39:00 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_EQUIPOT_STRUCT_TYPE:
|
|
|
|
text << _( "Net" ) << ( (EQUIPOT*) item )->m_Netname << wxT( " " ) <<
|
2007-10-13 06:18:44 +00:00
|
|
|
( (EQUIPOT*) item )->GetNet();
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEMODULE:
|
|
|
|
text << _( "Footprint" ) << wxT( " " ) << ( (MODULE*) item )->GetReference();
|
2007-10-01 04:14:29 +00:00
|
|
|
text << wxT( " (" ) << ReturnPcbLayerName( item->m_Layer ).Trim() << wxT( ")" );
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEPAD:
|
2007-10-13 12:17:17 +00:00
|
|
|
pad = (D_PAD *) this;
|
|
|
|
text << _( "Pad" ) << wxT( " \"" ) << pad->ReturnStringPadName()
|
|
|
|
<< 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 )
|
2007-10-16 19:05:33 +00:00
|
|
|
text << _("copper layer");
|
2007-10-13 12:17:17 +00:00
|
|
|
else if( (pad->m_Masque_Layer & CMP_LAYER) == CMP_LAYER )
|
2007-10-16 19:05:33 +00:00
|
|
|
text << _("cmp layer");
|
2007-10-13 12:17:17 +00:00
|
|
|
else text << _("???");
|
|
|
|
text << _( ") of " ) << ( (MODULE*) GetParent() )->GetReference();
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEDRAWSEGMENT:
|
2007-10-01 04:14:29 +00:00
|
|
|
text << _( "Pcb Graphic" ) << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); // @todo: extend text
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPETEXTE:
|
|
|
|
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( ".." );
|
2007-10-01 04:14:29 +00:00
|
|
|
text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim();
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPETEXTEMODULE:
|
|
|
|
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;
|
|
|
|
|
|
|
|
case TYPEEDGEMODULE:
|
|
|
|
text << _( "Graphic" ) << wxT( " " );
|
|
|
|
const wxChar* cp;
|
|
|
|
|
|
|
|
switch( ( (EDGE_MODULE*) item )->m_Shape )
|
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
|
|
|
cp = _( "Line" ); break;
|
|
|
|
|
|
|
|
case S_RECT:
|
|
|
|
cp = _( "Rect" ); break;
|
|
|
|
|
|
|
|
case S_ARC:
|
|
|
|
cp = _( "Arc" ); break;
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
|
|
|
cp = _( "Circle" ); break;
|
|
|
|
|
|
|
|
/* used in Gerbview: */
|
|
|
|
case S_ARC_RECT:
|
|
|
|
cp = wxT( "arc_rect" ); break;
|
|
|
|
|
|
|
|
case S_SPOT_OVALE:
|
|
|
|
cp = wxT( "spot_oval" ); break;
|
|
|
|
|
|
|
|
case S_SPOT_CIRCLE:
|
|
|
|
cp = wxT( "spot_circle" ); break;
|
|
|
|
|
|
|
|
case S_SPOT_RECT:
|
|
|
|
cp = wxT( "spot_rect" ); break;
|
|
|
|
|
|
|
|
case S_POLYGON:
|
|
|
|
cp = wxT( "polygon" ); break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
cp = wxT( "??EDGE??" ); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
text << *cp << _( " of " )
|
|
|
|
<< ( (MODULE*) GetParent() )->GetReference();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPETRACK:
|
2007-10-13 06:18:44 +00:00
|
|
|
// deleting tracks requires all the information we can get to
|
|
|
|
// disambiguate all the crap under the cursor!
|
2007-09-25 19:39:00 +00:00
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
wxString txt;
|
|
|
|
|
|
|
|
text << _( "Track" ) << wxT( " " ) << ((TRACK*)item)->ShowWidth();
|
|
|
|
net = aPcb->FindNet( ((TRACK*)item)->GetNet() );
|
|
|
|
if( net )
|
|
|
|
{
|
|
|
|
text << wxT( " [" ) << net->m_Netname << wxT( "]" );
|
|
|
|
}
|
|
|
|
text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim()
|
|
|
|
<< wxT(" ") << _("Net:") << ((TRACK*)item)->GetNet()
|
|
|
|
<< wxT(" ") << _("Length:") << valeur_param( (int) ((TRACK*)item)->GetLength(), txt );
|
2007-09-25 19:39:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
case TYPEZONE_CONTAINER:
|
|
|
|
text = _( "Zone Outline" );
|
|
|
|
text << wxT( " " );
|
|
|
|
{
|
|
|
|
wxString TimeStampText;
|
|
|
|
TimeStampText.Printf( wxT( "(%8.8X)" ), item->m_TimeStamp );
|
|
|
|
text << TimeStampText;
|
|
|
|
}
|
|
|
|
net = aPcb->FindNet( ( (ZONE_CONTAINER*) item )->GetNet() );
|
|
|
|
if( net )
|
|
|
|
{
|
|
|
|
text << wxT( " [" ) << net->m_Netname << wxT( "]" );
|
|
|
|
}
|
|
|
|
text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEZONE:
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
text << wxT( " [" ) << net->m_Netname << wxT( "]" );
|
|
|
|
}
|
2007-10-01 04:14:29 +00:00
|
|
|
text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim();
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEVIA:
|
|
|
|
{
|
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();
|
2007-10-01 04:14:29 +00:00
|
|
|
|
|
|
|
int shape = via->Shape();
|
2007-10-19 16:24:44 +00:00
|
|
|
if( shape == VIA_BURIED )
|
2007-10-01 04:14:29 +00:00
|
|
|
text << wxT(" ") << _( "Blind" );
|
2007-10-19 16:24:44 +00:00
|
|
|
else if( shape == VIA_BLIND )
|
2007-10-01 04:14:29 +00:00
|
|
|
text << wxT(" ") << _("Buried");
|
2007-10-29 15:51:48 +00:00
|
|
|
// else say nothing about normal (through) vias
|
2007-10-01 04:14:29 +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 )
|
|
|
|
{
|
|
|
|
text << wxT( " [" ) << net->m_Netname << wxT( "]" );
|
|
|
|
}
|
|
|
|
|
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 );
|
|
|
|
text << _( " on " ) << ReturnPcbLayerName( topLayer).Trim() << wxT(" <-> ")
|
|
|
|
<< ReturnPcbLayerName( botLayer ).Trim();
|
|
|
|
}
|
2007-09-25 19:39:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-11-27 22:49:35 +00:00
|
|
|
case TYPEMARKER:
|
2007-12-01 03:42:52 +00:00
|
|
|
text << _( "Marker" ) << wxT( " @(" ) << ((MARKER*)item)->GetPos().x
|
|
|
|
<< wxT(",") << ((MARKER*)item)->GetPos().y << wxT(")");
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPECOTATION:
|
2007-09-27 07:41:34 +00:00
|
|
|
text << _( "Dimension" ) << wxT( " \"" ) << ( (COTATION*) item )->GetText() << wxT( "\"" );
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEMIRE:
|
2007-10-29 15:51:48 +00:00
|
|
|
valeur_param( ((MIREPCB*)item)->m_Size, msg );
|
|
|
|
text << _( "Target" ) << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim()
|
|
|
|
<< wxT( " " ) << _( "size" ) << wxT( " " ) << msg
|
2007-10-10 14:08:26 +00:00
|
|
|
;
|
2007-09-25 19:39:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEEDGEZONE:
|
2007-10-01 04:14:29 +00:00
|
|
|
text << _( "Edge Zone" ) << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); // @todo: extend text
|
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() )
|
|
|
|
{
|
|
|
|
case PCB_EQUIPOT_STRUCT_TYPE:
|
|
|
|
xpm = general_ratsnet_xpm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEMODULE:
|
|
|
|
xpm = module_xpm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEPAD:
|
|
|
|
xpm = pad_xpm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEDRAWSEGMENT:
|
|
|
|
xpm = add_dashed_line_xpm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPETEXTE:
|
|
|
|
xpm = add_text_xpm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPETEXTEMODULE:
|
|
|
|
xpm = footprint_text_xpm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEEDGEMODULE:
|
|
|
|
xpm = show_mod_edge_xpm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPETRACK:
|
|
|
|
xpm = showtrack_xpm;
|
|
|
|
break;
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
case TYPEZONE_CONTAINER:
|
2007-09-25 19:39:00 +00:00
|
|
|
case TYPEZONE:
|
|
|
|
xpm = add_zone_xpm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEVIA:
|
|
|
|
xpm = pad_sketch_xpm;
|
|
|
|
break;
|
|
|
|
|
2007-11-27 22:49:35 +00:00
|
|
|
case TYPEMARKER:
|
2007-09-25 19:39:00 +00:00
|
|
|
xpm = pad_xpm; // @todo: create and use marker xpm
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPECOTATION:
|
|
|
|
xpm = add_cotation_xpm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEMIRE:
|
|
|
|
xpm = add_mires_xpm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEEDGEZONE:
|
|
|
|
xpm = show_mod_edge_xpm; // @todo: pcb edge xpm
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
xpm = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (const char**) xpm;
|
|
|
|
}
|
2007-10-03 15:21:13 +00:00
|
|
|
|