Commit 2fb2ab0d authored by Wayne Stambaugh's avatar Wayne Stambaugh

Refactor PCBNew selection clarification menu text code.

* Move menu text code from base board item object to the appropriate
  object.
* Add helper to get board layer to base board item object.
parent 9a51dc75
......@@ -151,17 +151,6 @@ public:
}
/**
* Function MenuText
* returns the text to use in any menu type UI control which must uniquely
* identify this item.
* @param aPcb The PCB in which this item resides, needed for Net lookup.
* @return wxString
* @todo: maybe: make this virtual and split into each derived class
*/
wxString MenuText( const BOARD* aPcb ) const;
/**
* Function MenuIcon
* @return const char** - The XPM to use in any UI control which can help
......@@ -224,8 +213,17 @@ public:
* returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
*/
virtual BOARD* GetBoard() const;
/**
* Function GetLayerName
* returns the name of the PCB layer on which the item resides.
*
* @return wxString containing the layer name associated with this item.
*/
wxString GetLayerName() const;
};
class NETCLASS;
/**
......
......@@ -14,9 +14,7 @@
#include "bitmaps.h"
/********************************************************/
wxString BOARD_ITEM::ShowShape( Track_Shapes aShape )
/********************************************************/
{
switch( aShape )
{
......@@ -31,213 +29,11 @@ wxString BOARD_ITEM::ShowShape( Track_Shapes aShape )
}
/**
* return a specific comment for "this". Used in pop up menus
* @param aPcb = the parent board
*/
wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
{
wxString text;
wxString msg;
wxString temp;
NETINFO_ITEM* net;
const BOARD_ITEM* item = this;
D_PAD * pad;
switch( item->Type() )
{
case TYPE_MODULE:
text << _( "Footprint" ) << wxT( " " ) << ( (MODULE*) item )->GetReference();
text << wxT( " (" ) << aPcb->GetLayerName( item->m_Layer ).Trim() << wxT( ")" );
break;
case TYPE_PAD:
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 & LAYER_BACK) == LAYER_BACK )
text << aPcb->GetLayerName( LAYER_N_BACK ).Trim();
else if( (pad->m_Masque_Layer & LAYER_FRONT) == LAYER_FRONT )
text << aPcb->GetLayerName( LAYER_N_FRONT );
else
text << _("???");
text << _( ") of " ) << ( (MODULE*) GetParent() )->GetReference();
break;
case TYPE_DRAWSEGMENT:
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();
break;
case TYPE_TEXTE:
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( ".." );
text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim();
break;
case TYPE_TEXTE_MODULE:
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 TYPE_EDGE_MODULE:
text << _( "Graphic" ) << wxT( " " );
text << ShowShape( (Track_Shapes) ( (EDGE_MODULE*) item )->m_Shape );
text << wxT( " (" ) << aPcb->GetLayerName( ((EDGE_MODULE*) item )->m_Layer ).Trim() << wxT( ")" );
text << _( " of " )
<< ( (MODULE*) GetParent() )->GetReference();
break;
case TYPE_TRACK:
// deleting tracks requires all the information we can get to
// disambiguate all the choices under the cursor!
text << _( "Track" ) << wxT( " " ) << ((TRACK*)item)->ShowWidth();
net = aPcb->FindNet( ((TRACK*)item)->GetNet() );
if( net )
{
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
}
text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim()
<< wxT(" ") << _("Net:") << ((TRACK*)item)->GetNet()
<< wxT(" ") << _("Length:") << valeur_param( (int) ((TRACK*)item)->GetLength(), temp );
break;
case TYPE_ZONE_CONTAINER:
text = _( "Zone Outline" );
{
ZONE_CONTAINER* area = (ZONE_CONTAINER*) this;
int ncont = area->m_Poly->GetContour(area->m_CornerSelection);
if( ncont )
text << wxT(" ") << _("(Cutout)");
}
text << wxT( " " );
{
wxString TimeStampText;
TimeStampText.Printf( wxT( "(%8.8X)" ), item->m_TimeStamp );
text << TimeStampText;
}
if ( !((ZONE_CONTAINER*) item)->IsOnCopperLayer() )
{
text << wxT( " [" ) << _("Not on copper layer") << wxT( "]" );
}
else if( ((ZONE_CONTAINER*) item)->GetNet() >= 0 )
{
net = aPcb->FindNet( ( (ZONE_CONTAINER*) item )->GetNet() );
if( net )
{
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
}
}
else // A netcode < 0 is an error flag (Netname not found or area not initialised)
{
text << wxT( " [" ) << ( (ZONE_CONTAINER*) item )->m_Netname << wxT( "]" );
text << wxT(" <") << _("Not Found") << wxT(">");
}
text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim();
break;
case TYPE_ZONE:
text = _( "Zone" );
text << wxT( " " );
{
wxString TimeStampText;
TimeStampText.Printf( wxT( "(%8.8X)" ), item->m_TimeStamp );
text << TimeStampText;
}
net = aPcb->FindNet( ( (SEGZONE*) item )->GetNet() );
if( net )
{
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
}
text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim();
break;
case TYPE_VIA:
{
SEGVIA* via = (SEGVIA*) item;
text << _( "Via" ) << wxT( " " ) << via->ShowWidth();
int shape = via->Shape();
if( shape == VIA_BLIND_BURIED )
text << wxT(" ") << _( "Blind/Buried" );
else if( shape == VIA_MICROVIA )
text << wxT(" ") << _("Micro Via");
// else say nothing about normal (through) vias
net = aPcb->FindNet( via->GetNet() );
if( net )
{
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
}
text << wxChar(' ') << _("Net:") << via->GetNet();
if( shape != VIA_THROUGH )
{
// say which layers, only two for now
int topLayer;
int botLayer;
via->ReturnLayerPair( &topLayer, &botLayer );
text << _( " on " ) << aPcb->GetLayerName( topLayer).Trim() << wxT(" <-> ")
<< aPcb->GetLayerName( botLayer ).Trim();
}
}
break;
case TYPE_MARKER_PCB:
text << _( "Marker" ) << wxT( " @(" ) << ((MARKER_PCB*)item)->GetPos().x
<< wxT(",") << ((MARKER_PCB*)item)->GetPos().y << wxT(")");
break;
case TYPE_DIMENSION:
text << _( "Dimension" ) << wxT( " \"" ) << ( (DIMENSION*) item )->GetText() << wxT( "\"" );
break;
case TYPE_MIRE:
valeur_param( ((MIREPCB*)item)->m_Size, msg );
text << _( "Target" ) << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim()
<< wxT( " " ) << _( "size" ) << wxT( " " ) << msg
;
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)
*/
const char** BOARD_ITEM::MenuIcon() const
{
const char** xpm;
const BOARD_ITEM* item = this;
......@@ -301,6 +97,7 @@ const char** BOARD_ITEM::MenuIcon() const
return (const char**) xpm;
}
void BOARD_ITEM::UnLink()
{
DLIST<BOARD_ITEM>* list = (DLIST<BOARD_ITEM>*) GetList();
......@@ -323,3 +120,17 @@ BOARD* BOARD_ITEM::GetBoard() const
return NULL;
}
wxString BOARD_ITEM::GetLayerName() const
{
wxString layerName;
BOARD* board = GetBoard();
if( board != NULL )
return board->GetLayerName( m_Layer ).Trim();
wxFAIL_MSG( wxT( "No board found for board item type " ) + GetClass() );
layerName = _( "** undefined layer **" );
return layerName;
}
......@@ -42,7 +42,7 @@ void DIMENSION::SetText( const wxString& NewText )
/* Return the dimension text
*/
wxString DIMENSION::GetText( void )
wxString DIMENSION::GetText( void ) const
{
return m_Text->m_Text;
}
......@@ -430,7 +430,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
/* Init layer : */
m_Text->SetLayer( GetLayer() );
/* calculate the size of the cdimension
/* calculate the size of the dimension
* (text + line above the text) */
ii = m_Text->m_Size.y +
m_Text->m_Thickness + (m_Width * 3);
......@@ -777,3 +777,13 @@ EDA_RECT DIMENSION::GetBoundingBox() const
return bBox;
}
wxString DIMENSION::GetSelectMenuText() const
{
wxString text;
text << _( "Dimension" ) << wxT( " \"" ) << GetText() << wxT( "\"" );
return text;
}
......@@ -59,7 +59,7 @@ public:
bool Save( FILE* aFile ) const;
void SetText( const wxString& NewText );
wxString GetText( void );
wxString GetText( void ) const;
void Copy( DIMENSION* source );
......@@ -134,6 +134,8 @@ public:
}
EDA_RECT GetBoundingBox() const;
virtual wxString GetSelectMenuText() const;
};
#endif // #define DIMENSION_H
......@@ -495,6 +495,19 @@ bool DRAWSEGMENT::HitTest( EDA_RECT& refArea )
}
wxString DRAWSEGMENT::GetSelectMenuText() const
{
wxString text;
wxString temp;
text << _( "Pcb Graphic" ) << wxT(": ") << ShowShape( (Track_Shapes)m_Shape )
<< wxChar(' ') << _("Length:") << valeur_param( GetLength(), temp )
<< _( " on " ) << GetLayerName();
return text;
}
#if defined(DEBUG)
/**
* Function Show
......
......@@ -169,13 +169,13 @@ public:
* clearance when the circle is approxiamted by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer,
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
int aClearanceValue,
int
aCircleToSegmentsCount,
int aCircleToSegmentsCount,
double aCorrectionFactor );
virtual wxString GetSelectMenuText() const;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
......
......@@ -601,8 +601,20 @@ bool EDGE_MODULE::HitTest( EDA_RECT& refArea )
return false;
}
#if defined(DEBUG)
wxString EDGE_MODULE::GetSelectMenuText() const
{
wxString text;
text << _( "Graphic" ) << wxT( " " ) << ShowShape( (Track_Shapes) m_Shape );
text << wxT( " (" ) << GetLayerName() << wxT( ")" );
text << _( " of " ) << ( (MODULE*) GetParent() )->GetReference();
return text;
}
#if defined(DEBUG)
/**
* Function Show
......
......@@ -145,16 +145,16 @@ public:
* @param aClearanceValue = the clearance around the pad
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aCorrectionFactor = the correction to apply to circles radius to keep
* clearance when the circle is approxiamted by segment bigger or equal
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer,
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
int aClearanceValue,
int
aCircleToSegmentsCount,
int aCircleToSegmentsCount,
double aCorrectionFactor );
virtual wxString GetSelectMenuText() const;
#if defined(DEBUG)
/**
......
/*****************************************************************************/
/* Functions to handle markers used to show somthing (usually a drc problem) */
/* Functions to handle markers used to show something (usually a drc problem) */
/*****************************************************************************/
/* file class_marker.cpp */
......@@ -93,7 +93,7 @@ void MARKER_PCB::Rotate(const wxPoint& aRotCentre, int aAngle)
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* this function has not reeally sense for a marker.
* this function has not really sense for a marker.
* It moves just the marker to keep its position on board, when the board is flipped
* @param aCentre - the rotation point.
*/
......@@ -102,3 +102,12 @@ void MARKER_PCB::Flip(const wxPoint& aCentre )
m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y);
}
wxString MARKER_PCB::GetSelectMenuText() const
{
wxString text;
text << _( "Marker" ) << wxT( " @(" ) << GetPos().x << wxT( "," ) << GetPos().y << wxT( ")" );
return text;
}
......@@ -114,6 +114,8 @@ public:
// "pure" virtual-ness
return true;
}
virtual wxString GetSelectMenuText() const;
};
......
......@@ -234,3 +234,17 @@ EDA_RECT MIREPCB::GetBoundingBox() const
return bBox;
}
wxString MIREPCB::GetSelectMenuText() const
{
wxString text;
wxString msg;
valeur_param( m_Size, msg );
text << _( "Target" ) << _( " on " ) << GetLayerName() << wxT( " " ) << _( "size" )
<< wxT( " " ) << msg;
return text;
}
......@@ -88,6 +88,8 @@ public:
bool HitTest( EDA_RECT& refArea );
EDA_RECT GetBoundingBox() const;
virtual wxString GetSelectMenuText() const;
};
......
......@@ -720,7 +720,7 @@ EDA_RECT MODULE::GetFootPrintRect() const
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() )
{
if( edge->Type() != TYPE_EDGE_MODULE ) // Shoud not occur
if( edge->Type() != TYPE_EDGE_MODULE ) // Should not occur
continue;
area.Merge( edge->GetBoundingBox() );
......@@ -1004,6 +1004,17 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
}
wxString MODULE::GetSelectMenuText() const
{
wxString text;
text << _( "Footprint" ) << wxT( " " ) << GetReference();
text << wxT( " (" ) << GetLayerName() << wxT( ")" );
return text;
}
#if defined(DEBUG)
/**
......
......@@ -274,7 +274,7 @@ public:
* Function GetReference
* @return const wxString& - the reference designator text.
*/
const wxString& GetReference()
const wxString& GetReference() const
{
return m_Reference->m_Text;
}
......@@ -328,6 +328,7 @@ public:
return wxT( "MODULE" );
}
virtual wxString GetSelectMenuText() const;
#if defined(DEBUG)
......
......@@ -144,7 +144,7 @@ const wxPoint D_PAD::ReturnShapePos()
/* Return pad name as string in a wxString
*/
wxString D_PAD::ReturnStringPadName()
wxString D_PAD::ReturnStringPadName() const
{
wxString name;
......@@ -155,7 +155,7 @@ wxString D_PAD::ReturnStringPadName()
/* Return pad name as string in a buffer
*/
void D_PAD::ReturnStringPadName( wxString& text )
void D_PAD::ReturnStringPadName( wxString& text ) const
{
int ii;
......@@ -871,7 +871,7 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )
#if defined(DEBUG)
// @todo: could this be useable elsewhere also?
// @todo: could this be usable elsewhere also?
static const char* ShowPadType( int aPadType )
{
switch( aPadType )
......@@ -916,6 +916,27 @@ static const char* ShowPadAttr( int aPadAttr )
}
wxString D_PAD::GetSelectMenuText() const
{
wxString text;
text << _( "Pad" ) << wxT( " \"" ) << ReturnStringPadName() << wxT( "\" (" );
if ( (m_Masque_Layer & ALL_CU_LAYERS) == ALL_CU_LAYERS )
text << _("all copper layers");
else if( (m_Masque_Layer & LAYER_BACK) == LAYER_BACK )
text << GetLayerName();
else if( (m_Masque_Layer & LAYER_FRONT) == LAYER_FRONT )
text << GetLayerName();
else
text << _( "???" );
text << _( ") of " ) << ( (MODULE*) GetParent() )->GetReference();
return text;
}
/**
* Function Show
* is used to output the object tree, currently for debugging only.
......
......@@ -26,7 +26,7 @@ class Pcb3D_GLCanvas;
#define PAD_HOLE_NOT_PLATED_DEFAULT_LAYERS LAYER_BACK | SILKSCREEN_LAYER_FRONT | \
SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT
// Helper class to staore parameters used to draw a pad
// Helper class to store parameters used to draw a pad
class PAD_DRAWINFO
{
public:
......@@ -177,7 +177,7 @@ public:
* @param aClearanceValue = the clearance around the pad
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aCorrectionFactor = the correction to apply to circles radius to keep
* clearance when the circle is approxiamted by segment bigger or equal
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
......@@ -276,8 +276,8 @@ public:
// others
void SetPadName( const wxString& name ); // Change pad name
wxString ReturnStringPadName(); // Return pad name as string in a wxString
void ReturnStringPadName( wxString& text ); // Return pad name as string in a buffer
wxString ReturnStringPadName() const; // Return pad name as string in a wxString
void ReturnStringPadName( wxString& text ) const; // Return pad name as string in a buffer
void ComputeShapeMaxRadius(); // compute radius
int GetMaxRadius() const;
......@@ -357,6 +357,8 @@ public:
}
virtual wxString GetSelectMenuText() const;
#if defined(DEBUG)
/**
......
......@@ -329,6 +329,23 @@ void TEXTE_PCB::Flip(const wxPoint& aCentre )
}
wxString TEXTE_PCB::GetSelectMenuText() const
{
wxString text;
text << _( "Pcb Text" ) << wxT( " " );
if( m_Text.Len() < 12 )
text << m_Text;
else
text += m_Text.Left( 10 ) + wxT( ".." );
text << _( " on " ) << GetLayerName();
return text;
}
#if defined(DEBUG)
/**
......
......@@ -124,12 +124,13 @@ public:
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygon(
std::vector <CPolyPt>& aCornerBuffer,
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
int aClearanceValue,
int aCircleToSegmentsCount,
double aCorrectionFactor );
virtual wxString GetSelectMenuText() const;
#if defined(DEBUG)
/**
* Function Show
......
......@@ -409,7 +409,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const w
size, m_HJustify, m_VJustify, width, m_Italic, m_Bold );
}
/* Rraws a line from the TEXTE_MODULE origin to parent MODULE origin.
/* Draws a line from the TEXTE_MODULE origin to parent MODULE origin.
*/
void TEXTE_MODULE::DrawUmbilical( EDA_DRAW_PANEL* aPanel,
wxDC* aDC,
......@@ -544,6 +544,31 @@ bool TEXTE_MODULE::IsOnLayer( int aLayer ) const
*/
wxString TEXTE_MODULE::GetSelectMenuText() const
{
wxString text;
switch( m_Type )
{
case TEXT_is_REFERENCE:
text << _( "Reference" ) << wxT( " " ) << m_Text;
break;
case TEXT_is_VALUE:
text << _( "Value" ) << wxT( " " ) << m_Text << _( " of " )
<< ( (MODULE*) GetParent() )->GetReference();
break;
default: // wrap this one in quotes:
text << _( "Text" ) << wxT( " \"" ) << m_Text << wxT( "\"" ) << _( " of " )
<< ( (MODULE*) GetParent() )->GetReference();
break;
}
return text;
}
#if defined(DEBUG)
/**
......
......@@ -159,6 +159,8 @@ public: TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS );
}
virtual wxString GetSelectMenuText() const;
#if defined(DEBUG)
/**
......
......@@ -43,9 +43,7 @@ TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
}
/***************************/
wxString TRACK::ShowWidth()
/***************************/
wxString TRACK::ShowWidth() const
{
wxString msg;
......@@ -61,12 +59,82 @@ SEGZONE::SEGZONE( BOARD_ITEM* aParent ) :
}
wxString SEGZONE::GetSelectMenuText() const
{
wxString text;
NETINFO_ITEM* net;
BOARD* board = GetBoard();
text << _( "Zone" ) << wxT( " " ) << wxString::Format( wxT( "(%8.8X)" ), m_TimeStamp );
if( board )
{
net = board->FindNet( GetNet() );
if( net )
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
}
else
{
text << _( "** BOARD NOT DEFINED **" );
}
text << _( " on " ) << GetLayerName();
return text;
}
SEGVIA::SEGVIA( BOARD_ITEM* aParent ) :
TRACK( aParent, TYPE_VIA )
{
}
wxString SEGVIA::GetSelectMenuText() const
{
wxString text;
NETINFO_ITEM* net;
BOARD* board = GetBoard();
text << _( "Via" ) << wxT( " " ) << ShowWidth();
int shape = Shape();
if( shape == VIA_BLIND_BURIED )
text << wxT( " " ) << _( "Blind/Buried" );
else if( shape == VIA_MICROVIA )
text << wxT( " " ) << _( "Micro Via" );
// else say nothing about normal (through) vias
if( board )
{
net = board->FindNet( GetNet() );
if( net )
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
text << wxChar( ' ' ) << _( "Net:" ) << GetNet();
if( shape != VIA_THROUGH )
{
// say which layers, only two for now
int topLayer;
int botLayer;
ReturnLayerPair( &topLayer, &botLayer );
text << _( " on " ) << board->GetLayerName( topLayer ).Trim() << wxT( " <-> " )
<< board->GetLayerName( botLayer ).Trim();
}
}
else
{
text << _( "** BOARD NOT DEFINED **" );
}
return text;
}
// Copy constructor
TRACK::TRACK( const TRACK& Source ) :
BOARD_CONNECTED_ITEM( Source )
......@@ -1131,6 +1199,36 @@ bool TRACK::HitTest( EDA_RECT& refArea )
}
wxString TRACK::GetSelectMenuText() const
{
wxString text;
wxString temp;
NETINFO_ITEM* net;
BOARD* board = GetBoard();
// deleting tracks requires all the information we can get to
// disambiguate all the choices under the cursor!
text << _( "Track" ) << wxT( " " ) << ShowWidth();
if( board )
{
net = board->FindNet( GetNet() );
if( net )
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
}
else
{
text << _( "** BOARD NOT DEFINED ** " );
}
text << _( " on " ) << GetLayerName() << wxT(" ") << _("Net:") << GetNet()
<< wxT(" ") << _("Length:") << valeur_param( GetLength(), temp );
return text;
}
#if defined(DEBUG)
/**
......
......@@ -9,10 +9,10 @@
#include "PolyLine.h"
// Via attributes (m_Shape parmeter)
// Via attributes (m_Shape parameter)
#define VIA_THROUGH 3 /* Always a through hole via */
#define VIA_BLIND_BURIED 2 /* this via can be on internal layers */
#define VIA_MICROVIA 1 /* this via which connect from an external layer to the near neightbour internal layer */
#define VIA_MICROVIA 1 /* this via which connect from an external layer to the near neighbor internal layer */
#define VIA_NOT_DEFINED 0 /* not yet used */
/***/
......@@ -52,7 +52,7 @@ public:
* will copy this object whether it is a TRACK or a SEGVIA returning
* the corresponding type.
* @return - TRACK*, SEGVIA*, or SEGZONE*, declared as the least common
* demoninator: TRACK
* denominator: TRACK
*/
TRACK* Copy() const;
......@@ -156,7 +156,7 @@ public:
* @param aClearanceValue = the clearance around the pad
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
* @param aCorrectionFactor = the correction to apply to circles radius to keep
* clearance when the circle is approxiamted by segment bigger or equal
* clearance when the circle is approximated by segment bigger or equal
* to the real clearance value (usually near from 1.0)
*/
void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
......@@ -228,7 +228,7 @@ public:
* Function ShowWidth
* returns the width of the track in displayable user units.
*/
wxString ShowWidth();
wxString ShowWidth() const;
/**
* Function Visit
......@@ -285,6 +285,7 @@ public:
*/
virtual int GetClearance( BOARD_CONNECTED_ITEM* aItem = NULL ) const;
virtual wxString GetSelectMenuText() const;
#if defined (DEBUG)
......@@ -326,6 +327,9 @@ public:
SEGZONE* Next() const { return (SEGZONE*) Pnext; }
virtual wxString GetSelectMenuText() const;
};
......@@ -380,6 +384,8 @@ public:
}
virtual wxString GetSelectMenuText() const;
#if defined (DEBUG)
/**
......
......@@ -113,12 +113,12 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const
if( ret < 3 )
return false;
// Save the ouline layer info
// Save the outline layer info
ret = fprintf( aFile, "ZLayer %d\n", m_Layer );
if( ret < 1 )
return false;
// Save the ouline aux info
// Save the outline aux info
switch( m_Poly->GetHatchStyle() )
{
default:
......@@ -364,7 +364,7 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader )
m_IsFilled = (fillstate == 'S') ? true : false;
}
else if( strnicmp( Line, "ZClearance", 10 ) == 0 ) // Clearence and pad options info found
else if( strnicmp( Line, "ZClearance", 10 ) == 0 ) // Clearance and pad options info found
{
int clearance = 200;
char padoption;
......@@ -622,11 +622,11 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
if( (corner->end_contour) || (ic == imax) ) // the last corner of a filled area is found: draw it
{
/* Draw the current filled area: draw segments ouline first
* Curiously, draw segments ouline first and after draw filled polygons
* with oulines thickness = 0 is a faster than
* just draw filled polygons but with oulines thickness = m_ZoneMinThickness
* So DO NOT use draw filled polygons with oulines having a thickness > 0
/* Draw the current filled area: draw segments outline first
* Curiously, draw segments outline first and after draw filled polygons
* with outlines thickness = 0 is a faster than
* just draw filled polygons but with outlines thickness = m_ZoneMinThickness
* So DO NOT use draw filled polygons with outlines having a thickness > 0
* Note: Extra segments ( added by kbool to joint holes with external outline) are not drawn
*/
{
......@@ -719,7 +719,7 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, in
* Draws the zone outline when ir is created.
* The moving edges (last segment and the closing edge segment) are in XOR graphic mode,
* old segment in OR graphic mode
* The closing edge has its owm shape
* The closing edge has its own shape
* @param panel = current Draw Panel
* @param DC = current Device Context
* @param draw_mode = draw mode: OR, XOR ..
......@@ -762,7 +762,7 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, in
else
current_gr_mode = draw_mode;
}
else // Draw the line from last corner to the first corner of the current coutour
else // Draw the line from last corner to the first corner of the current contour
{
is_close_segment = true;
current_gr_mode = GR_XOR;
......@@ -947,7 +947,7 @@ bool ZONE_CONTAINER::HitTestFilledArea( const wxPoint& aRefPos )
break;
}
// Prepare test of next area which starts after the current indexend (if exists)
// Prepare test of next area which starts after the current index end (if exists)
indexstart = indexend + 1;
}
}
......@@ -997,7 +997,7 @@ void ZONE_CONTAINER::DisplayInfo( EDA_DRAW_FRAME* frame )
else
frame->AppendMsgPanel( _( "Non Copper Zone" ), wxEmptyString, RED );
/* Display net code : (usefull in test or debug) */
/* Display net code : (useful in test or debug) */
msg.Printf( wxT( "%d" ), GetNet() );
frame->AppendMsgPanel( _( "NetCode" ), msg, RED );
......@@ -1176,7 +1176,7 @@ void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref )
/**
* Function copy
* copy usefull data from the source.
* copy useful data from the source.
* flags and linked list pointers are NOT copied
*/
void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src )
......@@ -1221,3 +1221,51 @@ bool ZONE_CONTAINER::SetNetNameFromNetCode( void )
return false;
}
wxString ZONE_CONTAINER::GetSelectMenuText() const
{
wxString text;
NETINFO_ITEM* net;
BOARD* board = GetBoard();
text = _( "Zone Outline" );
int ncont = m_Poly->GetContour( m_CornerSelection );
if( ncont )
text << wxT( " " ) << _( "(Cutout)" );
text << wxT( " " );
text << wxString::Format( wxT( "(%8.8X)" ), m_TimeStamp );
if ( !IsOnCopperLayer() )
{
text << wxT( " [" ) << _( "Not on copper layer" ) << wxT( "]" );
}
else if( GetNet() >= 0 )
{
if( board )
{
net = board->FindNet( GetNet() );
if( net )
{
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
}
}
else
{
text << _( "** NO BOARD DEFINED **" );
}
}
else // A netcode < 0 is an error flag (Netname not found or area not initialised)
{
text << wxT( " [" ) << m_Netname << wxT( "]" );
text << wxT( " <" ) << _( "Not Found" ) << wxT( ">" );
}
text << _( " on " ) << GetLayerName();
return text;
}
......@@ -47,8 +47,8 @@ public:
int m_ArcToSegmentsCount; // number of segments to convert a circle to a polygon
// (uses ARC_APPROX_SEGMENTS_COUNT_LOW_DEF or ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF)
int m_PadOption; //
int m_ThermalReliefGapValue; // tickness of the gap in thermal reliefs
int m_ThermalReliefCopperBridgeValue; // tickness of the copper bridge in thermal reliefs
int m_ThermalReliefGapValue; // thickness of the gap in thermal reliefs
int m_ThermalReliefCopperBridgeValue; // thickness of the copper bridge in thermal reliefs
int utility, utility2; // flags used in polygon calculations
bool m_IsFilled; // true when a zone was filled, false after deleting the filled areas
std::vector <CPolyPt> m_FilledPolysList; /* set of filled polygons used to draw a zone as a filled area.
......@@ -56,7 +56,7 @@ public:
* In very simple cases m_FilledPolysList is same as m_Poly
* In less simple cases (when m_Poly has holes) m_FilledPolysList is a polygon equivalent to m_Poly, without holes
* but with extra outline segment connecting "holes" with external main outline
* In complex cases an ouline decribed by m_Poly can have many filled areas
* In complex cases an outline described by m_Poly can have many filled areas
*/
std::vector <SEGMENT> m_FillSegmList; /* set of segments used to fill area, when fill zone by segment is used.
* ( m_FillMode == 1 )
......@@ -88,7 +88,7 @@ public:
/**
* Function copy
* copy usefull data from the source.
* copy useful data from the source.
* flags and linked list pointers are NOT copied
*/
void Copy( ZONE_CONTAINER* src );
......@@ -125,7 +125,7 @@ public:
* Function DrawWhileCreateOutline
* Draws the zone outline when ir is created.
* The moving edges are in XOR graphic mode, old segment in draw_mode graphic mode (usually GR_OR)
* The closing edge has its owm shape
* The closing edge has its own shape
* @param panel = current Draw Panel
* @param DC = current Device Context
* @param draw_mode = draw mode: OR, XOR ..
......@@ -141,7 +141,7 @@ public:
/**
* Function Test_For_Copper_Island_And_Remove__Insulated_Islands
* Remove insulated copper islands found in m_FilledPolysList.
* @param aPcb = the board to analyse
* @param aPcb = the board to analyze
*/
void Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD* aPcb );
......@@ -159,7 +159,7 @@ public:
* Function IsOnCopperLayer
* @return true if this zone is on a copper layer, false if on a technical layer
*/
bool IsOnCopperLayer( void )
bool IsOnCopperLayer( void ) const
{
return ( GetLayer() < FIRST_NO_COPPER_LAYER ) ? true : false;
}
......@@ -183,7 +183,7 @@ public:
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* For zones, this means near an ouline segment
* For zones, this means near an outline segment
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
......@@ -211,13 +211,13 @@ public:
/**
* Function AddClearanceAreasPolygonsToPolysList
* Add non copper areas polygons (pads and tracks with clearence)
* Add non copper areas polygons (pads and tracks with clearance)
* to a filled copper area
* used in BuildFilledPolysListData when calculating filled areas in a zone
* Non copper areas are pads and track and their clearance area
* The filled copper area must be computed before
* BuildFilledPolysListData() call this function just after creating the
* filled copper area polygon (without clearence areas
* filled copper area polygon (without clearance areas
* @param aPcb: the current board
*/
void AddClearanceAreasPolygonsToPolysList( BOARD* aPcb );
......@@ -341,7 +341,7 @@ public:
}
/** Acces to m_Poly parameters
/** Access to m_Poly parameters
*/
int GetNumCorners( void ) const
......@@ -417,6 +417,9 @@ public:
};
unsigned int GetCornerRadius() const { return cornerRadius; };
virtual wxString GetSelectMenuText() const;
};
......
......@@ -197,7 +197,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
item = (*m_Collector)[i];
text = item->MenuText( m_Pcb );
text = item->GetSelectMenuText();
xpm = item->MenuIcon();
ADD_MENUITEM( &itemMenu, ID_POPUP_PCB_ITEM_SELECTION_START + i, text, xpm );
......
......@@ -483,7 +483,8 @@ void DRC::testUnconnected()
D_PAD* padEnd = rat->m_PadEnd;
DRC_ITEM* uncItem = new DRC_ITEM( DRCE_UNCONNECTED_PADS,
padStart->MenuText( m_pcb ), padEnd->MenuText( m_pcb ),
padStart->GetSelectMenuText(),
padEnd->GetSelectMenuText(),
padStart->GetPosition(), padEnd->GetPosition() );
m_unconnected.push_back( uncItem );
......
......@@ -42,7 +42,7 @@
MARKER_PCB* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKER_PCB* fillMe )
{
wxString textA = aTrack->MenuText( m_pcb );
wxString textA = aTrack->GetSelectMenuText();
wxString textB;
wxPoint position;
......@@ -50,7 +50,7 @@ MARKER_PCB* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, M
if( aItem ) // aItem might be NULL
{
textB = aItem->MenuText( m_pcb );
textB = aItem->GetSelectMenuText();
posB = aItem->GetPosition();
if( aItem->Type() == TYPE_PAD )
......@@ -108,8 +108,8 @@ MARKER_PCB* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, M
MARKER_PCB* DRC::fillMarker( D_PAD* aPad, D_PAD* bPad, int aErrorCode, MARKER_PCB* fillMe )
{
wxString textA = aPad->MenuText( m_pcb );
wxString textB = bPad->MenuText( m_pcb );
wxString textA = aPad->GetSelectMenuText();
wxString textB = bPad->GetSelectMenuText();
wxPoint posA = aPad->GetPosition();
wxPoint posB = bPad->GetPosition();
......@@ -125,7 +125,7 @@ MARKER_PCB* DRC::fillMarker( D_PAD* aPad, D_PAD* bPad, int aErrorCode, MARKER_PC
MARKER_PCB* DRC::fillMarker( ZONE_CONTAINER* aArea, int aErrorCode, MARKER_PCB* fillMe )
{
wxString textA = aArea->MenuText( m_pcb );
wxString textA = aArea->GetSelectMenuText();
wxPoint posA = aArea->GetPosition();
......@@ -143,7 +143,7 @@ MARKER_PCB* DRC::fillMarker( const ZONE_CONTAINER* aArea,
int aErrorCode,
MARKER_PCB* fillMe )
{
wxString textA = aArea->MenuText( m_pcb );
wxString textA = aArea->GetSelectMenuText();
wxPoint posA = aPos;
......
......@@ -99,7 +99,7 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
item = (*m_Collector)[ii];
text = item->MenuText( GetBoard() );
text = item->GetSelectMenuText();
xpm = item->MenuIcon();
ADD_MENUITEM( &itemMenu,
......
......@@ -617,7 +617,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu
sub_menu_footprint = new wxMenu;
msg = aModule->MenuText( GetBoard() );
msg = aModule->GetSelectMenuText();
ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_footprint, -1, msg, module_xpm );
if( !flags )
......@@ -657,7 +657,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* me
wxMenu* sub_menu_Fp_text;
int flags = FpText->m_Flags;
wxString msg = FpText->MenuText( GetBoard() );
wxString msg = FpText->GetSelectMenuText();
sub_menu_Fp_text = new wxMenu;
......@@ -717,7 +717,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu )
updateTraceWidthSelectBox();
updateViaSizeSelectBox();
wxString msg = Pad->MenuText( GetBoard() );
wxString msg = Pad->GetSelectMenuText();
sub_menu_Pad = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_Pad, -1, msg, pad_xpm );
......@@ -767,7 +767,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu )
wxMenu* sub_menu_Text;
int flags = Text->m_Flags;
wxString msg = Text->MenuText( GetBoard() );
wxString msg = Text->GetSelectMenuText();
sub_menu_Text = new wxMenu;
......
......@@ -896,9 +896,10 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E
// COPPERAREA_COPPERAREA error: copper area ref corner inside copper area
if( aCreate_Markers )
{
wxString msg1 = Area_Ref->MenuText( this );
wxString msg2 = Area_To_Test->MenuText( this );
MARKER_PCB* marker = new MARKER_PCB( COPPERAREA_INSIDE_COPPERAREA, wxPoint( x, y ),
wxString msg1 = Area_Ref->GetSelectMenuText();
wxString msg2 = Area_To_Test->GetSelectMenuText();
MARKER_PCB* marker = new MARKER_PCB( COPPERAREA_INSIDE_COPPERAREA,
wxPoint( x, y ),
msg1, wxPoint( x, y ),
msg2, wxPoint( x, y ) );
Add( marker );
......@@ -917,9 +918,10 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E
// COPPERAREA_COPPERAREA error: copper area corner inside copper area ref
if( aCreate_Markers )
{
wxString msg1 = Area_To_Test->MenuText( this );
wxString msg2 = Area_Ref->MenuText( this );
MARKER_PCB* marker = new MARKER_PCB( COPPERAREA_INSIDE_COPPERAREA, wxPoint( x, y ),
wxString msg1 = Area_To_Test->GetSelectMenuText();
wxString msg2 = Area_Ref->GetSelectMenuText();
MARKER_PCB* marker = new MARKER_PCB( COPPERAREA_INSIDE_COPPERAREA,
wxPoint( x, y ),
msg1, wxPoint( x, y ),
msg2, wxPoint( x, y ) );
Add( marker );
......@@ -985,8 +987,8 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E
// COPPERAREA_COPPERAREA error : intersect or too close
if( aCreate_Markers )
{
wxString msg1 = Area_Ref->MenuText( this );
wxString msg2 = Area_To_Test->MenuText( this );
wxString msg1 = Area_Ref->GetSelectMenuText();
wxString msg2 = Area_To_Test->GetSelectMenuText();
MARKER_PCB* marker = new MARKER_PCB( COPPERAREA_CLOSE_TO_COPPERAREA,
wxPoint( x, y ),
msg1, wxPoint( x, y ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment