Gerbview: support of %TA.AperFunction (aperture attribute) and better support of %TO (currently work in progress) object attribute.

This commit is contained in:
jean-pierre charras 2016-08-16 12:56:20 +02:00
parent 2f4c9b7263
commit f1226afc89
19 changed files with 560 additions and 223 deletions

View File

@ -1,112 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef ATTRIBUTES_H
#define ATTRIBUTES_H
// this class handle info which can be added in a gerber file as attribute
// of an obtect
// the GBR_INFO_TYPE types can be OR'ed to add 2 (or more) attributes
// There are only 3 net attributes attached to an object by the %TO command
// %TO.CN
// %TO.N
// %TO.C
// the .CN attribute can be used only for flashed pads (using the D03 command)
// and only for external copper layers, if the component is on a external copper layer
// for other copper layer items (pads on internal layers, tracks ... ), only .N and .C
// can be used
class GBR_NETLIST_METADATA
{
public:
enum GBR_NETINFO_TYPE
{
GBR_NETINFO_UNSPECIFIED, ///< idle command (no command)
GBR_NETINFO_FLASHED_PAD, ///< print info associated to a flashed pad (TO.CN attribute)
GBR_NETINFO_NET, ///< print info associated to a net (TO.N attribute)
GBR_NETINFO_COMPONENT, ///< print info associated to a footprint (TO.C attribute)
GBR_NETINFO_NET_AND_CMP ///< combine GBR_INFO_NET and GBR_INFO_NET_AND_COMPONENT
///< to add both TO.N and TO.C attributes
};
// these members are used in the %TO object attributes command.
GBR_NETINFO_TYPE m_NetAttribType; ///< the type of net info
///< (used to define the gerber string to create)
wxString m_Padname; ///< for a flashed pad: the pad name ((TO.CN attribute)
wxString m_ComponentRef; ///< the footprint reference parent of the data
wxString m_Netname; ///< for items associated to a net: the netname
GBR_NETLIST_METADATA(): m_NetAttribType( GBR_NETINFO_UNSPECIFIED )
{
}
/*
* remove the net attribute specified by aName
* If aName == NULL or empty, remove all attributes
*/
void ClearAttribute( const wxString* aName )
{
if( m_NetAttribType == GBR_NETLIST_METADATA::GBR_NETINFO_UNSPECIFIED )
return;
if( !aName || aName->IsEmpty() )
{
m_NetAttribType = GBR_NETLIST_METADATA::GBR_NETINFO_UNSPECIFIED;
m_Padname.clear();
m_ComponentRef.clear();
m_Netname.clear();
}
if( aName && *aName == ".CN" )
{
m_NetAttribType = GBR_NETLIST_METADATA::GBR_NETINFO_UNSPECIFIED;
m_Padname.clear();
m_ComponentRef.clear();
m_Netname.clear();
}
if( aName && *aName == ".C" )
{
if( m_NetAttribType == GBR_NETINFO_COMPONENT )
m_NetAttribType = GBR_NETLIST_METADATA::GBR_NETINFO_UNSPECIFIED;
else
m_NetAttribType = GBR_NETLIST_METADATA::GBR_NETINFO_NET;
m_ComponentRef.clear();
}
if( aName && *aName == ".N" )
{
if( m_NetAttribType == GBR_NETINFO_NET )
m_NetAttribType = GBR_NETLIST_METADATA::GBR_NETINFO_UNSPECIFIED;
else
m_NetAttribType = GBR_NETLIST_METADATA::GBR_NETINFO_COMPONENT;
m_Netname.clear();
}
}
};
#endif // #define ATTRIBUTES_H

View File

@ -82,7 +82,8 @@ public:
const wxString& GetAttribute();
/**
* @return the number of parameters read in TF command.
* @return the number of parameters read in %TF
* (or similar like %TA %TO ...) command.
*/
int GetPrmCount() { return int( m_Prms.GetCount() ); }

View File

@ -99,6 +99,23 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
{
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
// Collect the highlight selections
wxString cmpHighlight;
if( gerbFrame->m_SelComponentBox->GetSelection() > 0 )
cmpHighlight = gerbFrame->m_SelComponentBox->GetStringSelection();
wxString netHighlight;
if( gerbFrame->m_SelNetnameBox->GetSelection() > 0 )
netHighlight = gerbFrame->m_SelNetnameBox->GetStringSelection();
wxString aperAttrHighlight = gerbFrame->m_SelAperAttributesBox->GetStringSelection();
if( gerbFrame->m_SelAperAttributesBox->GetSelection() > 0 )
aperAttrHighlight = gerbFrame->m_SelAperAttributesBox->GetStringSelection();
// Because Images can be negative (i.e with background filled in color) items are drawn
// graphic layer per graphic layer, after the background is filled
// to a temporary bitmap
@ -280,6 +297,18 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
if( dcode_highlight && dcode_highlight == item->m_DCode )
DrawModeAddHighlight( &drawMode);
if( !aperAttrHighlight.IsEmpty() && item->GetDcodeDescr() &&
item->GetDcodeDescr()->m_AperFunction == aperAttrHighlight )
DrawModeAddHighlight( &drawMode);
if( !cmpHighlight.IsEmpty() &&
cmpHighlight == item->GetNetAttributes().m_Cmpref )
DrawModeAddHighlight( &drawMode);
if( !netHighlight.IsEmpty() &&
netHighlight == item->GetNetAttributes().m_Netname )
DrawModeAddHighlight( &drawMode);
item->Draw( aPanel, plotDC, drawMode, wxPoint(0,0), aDisplayOptions );
doBlit = true;
}

View File

@ -62,6 +62,19 @@ GERBER_DRAW_ITEM::~GERBER_DRAW_ITEM()
}
void GERBER_DRAW_ITEM::SetNetAttributes( const GBR_NETLIST_METADATA& aNetAttributes )
{
m_netAttributes = aNetAttributes;
if( ( m_netAttributes.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_CMP ) ||
( m_netAttributes.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_PAD ) )
m_GerberImageFile->m_ComponentsList.insert( std::make_pair( m_netAttributes.m_Cmpref, 0 ) );
if( ( m_netAttributes.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_NET ) )
m_GerberImageFile->m_NetnamesList.insert( std::make_pair( m_netAttributes.m_Netname, 0 ) );
}
int GERBER_DRAW_ITEM::GetLayer() const
{
// returns the layer this item is on, or 0 if the m_GerberImageFile is NULL.
@ -526,38 +539,34 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
aList.push_back( MSG_PANEL_ITEM( _( "AB axis" ), msg, DARKRED ) );
// Display net info, if exists
switch( m_NetAttribute.m_NetAttribType )
if( m_netAttributes.m_NetAttribType == GBR_NETLIST_METADATA::GBR_NETINFO_UNSPECIFIED )
return;
// Build full net info:
wxString net_msg;
wxString cmp_pad_msg;
if( ( m_netAttributes.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_NET ) )
{
default:
case GBR_NETLIST_METADATA::GBR_NETINFO_UNSPECIFIED:
break;
case GBR_NETLIST_METADATA::GBR_NETINFO_FLASHED_PAD: // .CN attribute
msg = _( "Net:" );
msg << " " << m_NetAttribute.m_Netname;
text.Printf( _( "Pad: '%s' (Cmp: '%s')" ), GetChars( m_NetAttribute.m_Padname ),
GetChars( m_NetAttribute.m_ComponentRef ) );
aList.push_back( MSG_PANEL_ITEM( msg, text, CYAN ) );
break;
case GBR_NETLIST_METADATA::GBR_NETINFO_NET: // .N attribute
aList.push_back( MSG_PANEL_ITEM( _( "Net:" ),
m_NetAttribute.m_Netname, CYAN ) );
break;
case GBR_NETLIST_METADATA::GBR_NETINFO_COMPONENT: // .C attribute
aList.push_back( MSG_PANEL_ITEM( _( "Ref:" ),
m_NetAttribute.m_ComponentRef, CYAN ) );
break;
case GBR_NETLIST_METADATA::GBR_NETINFO_NET_AND_CMP: // .C and .N attribute
msg = _( "Net:" );
msg << " " << m_NetAttribute.m_Netname;
text =_( "Ref:" );
text << m_NetAttribute.m_ComponentRef;
aList.push_back( MSG_PANEL_ITEM( msg, text, CYAN ) );
break;
net_msg = _( "Net:" );
net_msg << " " << m_netAttributes.m_Netname;
}
if( ( m_netAttributes.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_PAD ) )
{
cmp_pad_msg.Printf( _( "Cmp: %s; Pad: %s" ),
GetChars( m_netAttributes.m_Cmpref ),
GetChars( m_netAttributes.m_Padname ) );
}
else if( ( m_netAttributes.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_CMP ) )
{
cmp_pad_msg = _( "Cmp:" );
cmp_pad_msg << " " << m_netAttributes.m_Cmpref;
}
aList.push_back( MSG_PANEL_ITEM( net_msg, cmp_pad_msg, CYAN ) );
}

View File

@ -33,7 +33,7 @@
#include <dlist.h>
#include <layers_id_colors_and_visibility.h>
#include <gr_basic.h>
#include <attributes.h>
#include <gbr_netlist_metadata.h>
#include <dcode.h>
class GERBER_FILE_IMAGE;
@ -92,9 +92,6 @@ public:
* so they are stored inside this item if there is no
* redundancy for these parameters
*/
GBR_NETLIST_METADATA m_NetAttribute; ///< the string given by a %TO attribute set in aperture
///< (dcode). Stored in each item, because %TO is
///< a dynamic object attribute
private:
// These values are used to draw this item, according to gerber layers parameters
@ -107,6 +104,9 @@ private:
wxRealPoint m_drawScale; // A and B scaling factor
wxPoint m_layerOffset; // Offset for A and B axis, from OF parameter
double m_lyrRotation; // Fine rotation, from OR parameter, in degrees
GBR_NETLIST_METADATA m_netAttributes; ///< the string given by a %TO attribute set in aperture
///< (dcode). Stored in each item, because %TO is
///< a dynamic object attribute
public:
GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberparams );
@ -115,6 +115,9 @@ public:
GERBER_DRAW_ITEM* Next() const { return static_cast<GERBER_DRAW_ITEM*>( Pnext ); }
GERBER_DRAW_ITEM* Back() const { return static_cast<GERBER_DRAW_ITEM*>( Pback ); }
void SetNetAttributes( const GBR_NETLIST_METADATA& aNetAttributes );
const GBR_NETLIST_METADATA& GetNetAttributes() { return m_netAttributes; }
/**
* Function GetLayer
* returns the layer this item is on.

View File

@ -31,7 +31,7 @@
#include <dcode.h>
#include <class_gerber_draw_item.h>
#include <class_aperture_macro.h>
#include <attributes.h>
#include <gbr_netlist_metadata.h>
// An useful macro used when reading gerber files;
#define IsNumber( x ) ( ( ( (x) >= '0' ) && ( (x) <='9' ) ) \
@ -165,6 +165,10 @@ public:
// add object attribute command.
wxString m_AperFunction; // the aperture function set by a %TA.AperFunction, xxx
// (stores thre xxx value).
std::map<wxString, int> m_ComponentsList; // list of components
std::map<wxString, int> m_NetnamesList; // list of net names
private:
wxArrayString m_messagesList; // A list of messages created when reading a file
int m_hasNegativeItems; // true if the image is negative or has some negative items

View File

@ -52,7 +52,7 @@ bool GERBVIEW_FRAME::Clear_DrawLayers( bool query )
GetGerberLayout()->SetBoundingBox( EDA_RECT() );
setActiveLayer( 0 );
m_LayersManager->UpdateLayerIcons();
ReFillLayerWidget();
syncLayerBox();
return true;
}
@ -72,7 +72,7 @@ void GERBVIEW_FRAME::Erase_Current_DrawLayer( bool query )
GetImagesList()->DeleteImage( layer );
m_LayersManager->UpdateLayerIcons();
ReFillLayerWidget();
syncLayerBox();
m_canvas->Refresh();
}

View File

@ -82,7 +82,7 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EDA_BASE_FRAME::OnSelectPreferredEditor )
// menu Miscellaneous
EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_ERASE_CURR_LAYER, GERBVIEW_FRAME::Process_Special_Functions )
// Menu Help
EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
@ -116,6 +116,17 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EVT_TOOL_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2,
GERBVIEW_FRAME::OnSelectDisplayMode )
// Auxiliary horizontal toolbar
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE, GERBVIEW_FRAME::Process_Special_Functions )
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE, GERBVIEW_FRAME::Process_Special_Functions )
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::Process_Special_Functions )
// Right click context menu
EVT_MENU( ID_HIGHLIGHT_CMP_ITEMS, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_HIGHLIGHT_NET_ITEMS, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_HIGHLIGHT_APER_ATTRIBUTE_ITEMS, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_HIGHLIGHT_REMOVE_ALL, GERBVIEW_FRAME::Process_Special_Functions )
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI( ID_ZOOM_SELECTION, GERBVIEW_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLAR_COORD, GERBVIEW_FRAME::OnUpdateCoordType )
@ -172,6 +183,7 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
INSTALL_UNBUFFERED_DC( dc, m_canvas );
GERBER_DRAW_ITEM* currItem = (GERBER_DRAW_ITEM*) GetScreen()->GetCurItem();
switch( id )
{
@ -184,7 +196,7 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
break;
case ID_GERBVIEW_GLOBAL_DELETE:
case ID_GERBVIEW_ERASE_CURR_LAYER:
Erase_Current_DrawLayer( true );
ClearMsgPanel();
break;
@ -220,6 +232,41 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
HandleBlockEnd( &dc );
break;
case ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE:
case ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE:
case ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE:
m_canvas->Refresh();
break;
case ID_HIGHLIGHT_CMP_ITEMS:
if( m_SelComponentBox->SetStringSelection( currItem->GetNetAttributes().m_Cmpref ) )
m_canvas->Refresh();
break;
case ID_HIGHLIGHT_NET_ITEMS:
if( m_SelNetnameBox->SetStringSelection( currItem->GetNetAttributes().m_Netname ) )
m_canvas->Refresh();
break;
case ID_HIGHLIGHT_APER_ATTRIBUTE_ITEMS:
{
D_CODE* apertDescr = currItem->GetDcodeDescr();
if( m_SelAperAttributesBox->SetStringSelection( apertDescr->m_AperFunction ) )
m_canvas->Refresh();
}
break;
case ID_HIGHLIGHT_REMOVE_ALL:
m_SelComponentBox->SetSelection( 0 );
m_SelNetnameBox->SetSelection( 0 );
m_SelAperAttributesBox->SetSelection( 0 );
if( GetGbrImage( getActiveLayer() ) )
GetGbrImage( getActiveLayer() )->m_Selected_Tool = 0;
m_canvas->Refresh();
break;
default:
wxFAIL_MSG( wxT( "GERBVIEW_FRAME::Process_Special_Functions error" ) );
break;

View File

@ -81,7 +81,6 @@ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event )
Zoom_Automatique( false );
m_canvas->Refresh();
ClearMsgPanel();
ReFillLayerWidget();
break;
case ID_GERBVIEW_LOAD_DRILL_FILE:

View File

@ -60,6 +60,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ),
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME )
{
m_auxiliaryToolBar = NULL;
m_colorsSettings = &g_ColorsSettings;
m_gerberLayout = NULL;
m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1
@ -119,6 +120,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
ReCreateMenuBar();
ReCreateHToolbar();
ReCreateOptToolbar();
ReCreateAuxiliaryToolbar();
m_auimgr.SetManagedWindow( this );
@ -145,6 +147,12 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_auimgr.AddPane( m_mainToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
if( m_auxiliaryToolBar ) // the auxiliary horizontal toolbar, that shows component and netname lists
{
m_auimgr.AddPane( m_auxiliaryToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_auxiliaryToolBar" ) ).Top().Row( 1 ) );
}
if( m_drawToolBar )
m_auimgr.AddPane( m_drawToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right().Row( 1 ) );
@ -321,6 +329,7 @@ void GERBVIEW_FRAME::ReFillLayerWidget()
{
m_LayersManager->ReFill();
m_SelLayerBox->Resync();
ReCreateAuxiliaryToolbar();
wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
@ -419,7 +428,6 @@ void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
void GERBVIEW_FRAME::Liste_D_Codes()
{
int ii, jj;
D_CODE* pt_D_code;
wxString Line;
wxArrayString list;
double scale = g_UserUnit == INCHES ? IU_PER_MILS * 1000 : IU_PER_MM;
@ -446,7 +454,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
{
pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false );
D_CODE* pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false );
if( pt_D_code == NULL )
continue;
@ -454,19 +462,20 @@ void GERBVIEW_FRAME::Liste_D_Codes()
if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
continue;
Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s " ),
Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s attribute '%s'" ),
jj,
pt_D_code->m_Num_Dcode,
pt_D_code->m_Size.y / scale, units,
pt_D_code->m_Size.x / scale, units,
D_CODE::ShowApertureType( pt_D_code->m_Shape )
D_CODE::ShowApertureType( pt_D_code->m_Shape ),
pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : GetChars( pt_D_code->m_AperFunction )
);
if( !pt_D_code->m_Defined )
Line += wxT( "(not defined) " );
Line += wxT( " (not defined)" );
if( pt_D_code->m_InUse )
Line += wxT( "(in use)" );
Line += wxT( " (in use)" );
list.Add( Line );
jj++;

View File

@ -156,13 +156,23 @@ protected:
wxFileHistory m_drillFileHistory;
/// The last filename chosen to be proposed to the user
wxString m_lastFileName;
public:
GBR_LAYER_BOX_SELECTOR* m_SelLayerBox;
wxChoice* m_SelComponentBox; // a choice box to display and highlight component graphic items
wxChoice* m_SelNetnameBox; // a choice box to display and highlight netlist graphic items
wxChoice* m_SelAperAttributesBox; // a choice box to display aperture attributes and highlight items
GBR_LAYER_BOX_SELECTOR* m_SelLayerBox; // The combobox to select the current active graphic layer
// (which is drawn on top on the other layers
DCODE_SELECTION_BOX* m_DCodeSelector; // a list box to select the dcode Id to highlight.
wxTextCtrl* m_TextInfo; // a wxTextCtrl used to display some info about
// gerber data (format..)
wxArrayString m_DCodesList; // an array string containing all decodes Id (10 to 999)
private:
/// Auxiliary tool bar typically shown below the main tool bar at the top of the
/// main window.
wxAuiToolBar* m_auxiliaryToolBar;
// list of PARAM_CFG_xxx to read/write parameters saved in config
PARAM_CFG_ARRAY m_configSettings;
COLORS_DESIGN_SETTINGS* m_colorsSettings;
@ -179,7 +189,11 @@ private:
bool m_show_layer_manager_tools;
// An array sting to store warning messages when reading a gerber file.
void updateComponentListSelectBox();
void updateNetnameListSelectBox();
void updateAperAttributesSelectBox();
// An array string to store warning messages when reading a gerber file.
wxArrayString m_Messages;
public:
@ -193,6 +207,7 @@ public:
// Virtual basic functions:
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void ReCreateHToolbar();
void ReCreateAuxiliaryToolbar();
/**
* Function ReCreateVToolbar
@ -208,9 +223,9 @@ public:
void ReCreateOptToolbar();
void ReCreateMenuBar();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
void OnLeftClick( wxDC* aDC, const wxPoint& aMousePos );
void OnLeftDClick( wxDC* aDC, const wxPoint& aMousePos );
bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu );
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
double BestZoom();
void UpdateStatusBar();

View File

@ -49,6 +49,10 @@ enum gerbview_ids
ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR,
ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE,
ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE,
ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE,
// IDs for drill file history (wxID_FILEnn is already in use)
ID_GERBVIEW_DRILL_FILE,
ID_GERBVIEW_DRILL_FILE1,
@ -62,7 +66,7 @@ enum gerbview_ids
ID_GERBVIEW_DRILL_FILE9,
ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,
ID_GERBVIEW_GLOBAL_DELETE,
ID_GERBVIEW_ERASE_CURR_LAYER,
ID_GERBVIEW_OPTIONS_SETUP,
ID_GERBVIEW_SET_PAGE_BORDER,
ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
@ -75,6 +79,12 @@ enum gerbview_ids
ID_TB_OPTIONS_SHOW_GBR_MODE_1,
ID_TB_OPTIONS_SHOW_GBR_MODE_2,
// Right click context menu
ID_HIGHLIGHT_REMOVE_ALL,
ID_HIGHLIGHT_CMP_ITEMS,
ID_HIGHLIGHT_NET_ITEMS,
ID_HIGHLIGHT_APER_ATTRIBUTE_ITEMS,
ID_GERBER_END_LIST
};

View File

@ -195,39 +195,32 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
// Separator
miscellaneousMenu->AppendSeparator();
// Clear layer
// Erase graphic layer
AddMenuItem( miscellaneousMenu,
ID_GERBVIEW_GLOBAL_DELETE,
_( "&Clear Layer" ),
_( "Clear current layer" ),
KiBitmap( general_deletions_xpm ) );
ID_GERBVIEW_ERASE_CURR_LAYER,
_( "&Clear Current Layer" ),
_( "Erase the graphic layer currently selected" ),
KiBitmap( delete_sheet_xpm ) );
// Separator
miscellaneousMenu->AppendSeparator();
// Text editor
// Text editor (usefull to browse source files)
AddMenuItem( miscellaneousMenu,
ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR,
_( "&Text Editor" ),
_( "Select your preferred text editor" ),
KiBitmap( editor_xpm ) );
// Menu Help
// Help menu
wxMenu* helpMenu = new wxMenu;
// Contents
AddMenuItem( helpMenu,
wxID_HELP,
_( "Gerbview &Manual" ),
_( "Open the GerbView Manual" ),
KiBitmap( online_help_xpm ) );
AddMenuItem( helpMenu,
wxID_INDEX,
_( "&Getting Started in KiCad" ),
_( "Open \"Getting Started in KiCad\" guide for beginners" ),
KiBitmap( help_xpm ) );
AddMenuItem( helpMenu,
ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
_( "&List Hotkeys" ),

View File

@ -34,7 +34,7 @@
/* Process the command triggered by the left button of the mouse
* currently: just display info in the message panel.
*/
void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
void GERBVIEW_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
{
GERBER_DRAW_ITEM* DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE );
@ -52,7 +52,7 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
/* Called on a double click of left mouse button.
*/
void GERBVIEW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
void GERBVIEW_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
{
// Currently: no nothing
}

View File

@ -25,6 +25,7 @@
#include <fctsys.h>
#include <class_drawpanel.h>
#include <id.h>
#include <gerbview_id.h>
#include <gerbview.h>
#include <gerbview_frame.h>
@ -34,7 +35,7 @@
/* Prepare the right-click pullup menu.
* The menu already has a list of zoom commands.
*/
bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* aPopMenu )
{
GERBER_DRAW_ITEM* currItem = (GERBER_DRAW_ITEM*) GetScreen()->GetCurItem();
wxString msg;
@ -55,13 +56,13 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
if( GetToolId() != ID_NO_TOOL_SELECTED )
{
if( busy )
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
AddMenuItem( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel" ), KiBitmap( cancel_xpm ) );
else
AddMenuItem( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL,
AddMenuItem( aPopMenu, ID_POPUP_CLOSE_CURRENT_TOOL,
_( "End Tool" ), KiBitmap( cursor_xpm ) );
PopMenu->AppendSeparator();
aPopMenu->AppendSeparator();
}
else
{
@ -69,19 +70,19 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
{
if( BlockActive )
{
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
AddMenuItem( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel Block" ), KiBitmap( cancel_xpm ) );
PopMenu->AppendSeparator();
AddMenuItem( PopMenu, ID_POPUP_PLACE_BLOCK,
aPopMenu->AppendSeparator();
AddMenuItem( aPopMenu, ID_POPUP_PLACE_BLOCK,
_( "Place Block" ), KiBitmap( checked_ok_xpm ) );
}
else
{
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
AddMenuItem( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel" ), KiBitmap( cancel_xpm ) );
}
PopMenu->AppendSeparator();
aPopMenu->AppendSeparator();
}
}
@ -89,7 +90,54 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
return true;
if( currItem )
{
GetScreen()->SetCurItem( currItem );
bool add_separator = false;
// Now, display a context menu
// to allow highlighting items which share the same attributes
// as the selected item (net attributes and aperture attributes)
const GBR_NETLIST_METADATA& net_attr = currItem->GetNetAttributes();
if( ( net_attr.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_PAD ) ||
( net_attr.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_CMP ) )
{
AddMenuItem( aPopMenu, ID_HIGHLIGHT_CMP_ITEMS,
wxString::Format( _( "Highlight items of component '%s'" ),
GetChars( net_attr.m_Cmpref ) ),
KiBitmap( file_footprint_xpm ) );
add_separator = true;
}
if( ( net_attr.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_NET ) )
{
AddMenuItem( aPopMenu, ID_HIGHLIGHT_NET_ITEMS,
wxString::Format( _( "Highlight items of net '%s'" ),
GetChars( net_attr.m_Netname ) ),
KiBitmap( general_ratsnest_xpm ) );
add_separator = true;
}
D_CODE* apertDescr = currItem->GetDcodeDescr();
if( !apertDescr->m_AperFunction.IsEmpty() )
{
AddMenuItem( aPopMenu, ID_HIGHLIGHT_APER_ATTRIBUTE_ITEMS,
wxString::Format( _( "Highlight aperture type '%s'" ),
GetChars( apertDescr->m_AperFunction ) ),
KiBitmap( flag_xpm ) );
add_separator = true;
}
if( add_separator )
aPopMenu->AppendSeparator();
}
AddMenuItem( aPopMenu, ID_HIGHLIGHT_REMOVE_ALL,
_( "Clear highlight" ),
KiBitmap( gerbview_clear_layers_xpm ) );
aPopMenu->AppendSeparator();
return true;
}

View File

@ -118,7 +118,7 @@ void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
aGbrItem->m_DCode = Dcode_index;
aGbrItem->SetLayerPolarity( aLayerNegative );
aGbrItem->m_Flashed = true;
aGbrItem->m_NetAttribute = aGbrItem->m_GerberImageFile->m_NetAttributeDict;
aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
switch( aAperture )
{
@ -175,7 +175,7 @@ void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
aGbrItem->m_DCode = Dcode_index;
aGbrItem->SetLayerPolarity( aLayerNegative );
aGbrItem->m_NetAttribute = aGbrItem->m_GerberImageFile->m_NetAttributeDict;
aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
}
@ -221,7 +221,7 @@ static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index,
aGbrItem->m_Size = aPenSize;
aGbrItem->m_Flashed = false;
aGbrItem->m_NetAttribute = aGbrItem->m_GerberImageFile->m_NetAttributeDict;
aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
if( aMultiquadrant )
center = aStart + aRelCenter;
@ -352,7 +352,7 @@ static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem,
aStart, aEnd, rel_center, wxSize(0, 0),
aClockwise, aMultiquadrant, aLayerNegative );
aGbrItem->m_NetAttribute = aGbrItem->m_GerberImageFile->m_NetAttributeDict;
aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
wxPoint center;
center = dummyGbrItem.m_ArcCentre;

View File

@ -88,15 +88,16 @@ enum RS274X_PARAMETERS {
// X2 extention Net attribute info
// Net attribute options are:
// TO (net attribute data): TO.CN ot TO.N or TO.C
// TO (net attribute data): TO.CN or TO.P TO.N or TO.C
NET_ATTRIBUTE = CODE( 'T', 'O' ),
// X2 extention Aperture attribute TA
APERTURE_ATTRIBUTE = CODE( 'T', 'A' ),
// TD (delete aperture attribute): TD (delete all) or TD.CN or TD.N or TD.C ...
// due to not yet fully defined,
// TD TD.CNr TD.N TD.C are delete all
// TD (delete aperture/object attribute):
// Delete aperture attribute added by %TA or Oblect attribute added b %TO
// TD (delete all) or %TD<attr name> to delete <attr name>.
// eg: TD.P or TD.N or TD.C ...
REMOVE_APERTURE_ATTRIBUTE = CODE( 'T', 'D' ),
// Layer specific parameters
@ -163,7 +164,7 @@ static const wxString fromGerberString( const wxString& aGbrString )
unsigned value = 0;
for( int jj = 0; jj < 4; jj++ )
{
{ // Convert 4 hexa digits to binary value:
ii++;
value <<= 4;
int digit = aGbrString[ii];
@ -171,12 +172,12 @@ static const wxString fromGerberString( const wxString& aGbrString )
if( digit >= '0' && digit <= '9' )
digit -= '0';
else if( digit >= 'A' && digit <= 'F' )
digit -= 'A';
digit -= 'A' - 10;
else if( digit >= 'a' && digit <= 'f' )
digit -= 'a';
digit -= 'a' - 10;
else digit = 0;
value += digit & 0xFF;
value += digit & 0xF;
}
text.Append( wxUniChar( value ) );
@ -434,41 +435,38 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& te
X2_ATTRIBUTE dummy;
dummy.ParseAttribCmd( m_Current_File, buff, GERBER_BUFZ, text );
if( dummy.GetAttribute() == ".AperFunction" )
if( dummy.GetAttribute() == ".AperFunction" )
{
m_AperFunction = dummy.GetPrm( 1 );
// A few function values can have other parameters. Add them
for( int ii = 2; ii < dummy.GetPrmCount(); ii++ )
m_AperFunction << "," << dummy.GetPrm( ii );
}
}
break;
case NET_ATTRIBUTE: // Command %TO currently %TO.CN %TO.N and %TO.C
case NET_ATTRIBUTE: // Command %TO currently %TO.P %TO.N and %TO.C
{
X2_ATTRIBUTE dummy;
dummy.ParseAttribCmd( m_Current_File, buff, GERBER_BUFZ, text );
if( dummy.GetAttribute() == ".CN" )
if( dummy.GetAttribute() == ".N" )
{
m_NetAttributeDict.m_NetAttribType = GBR_NETLIST_METADATA::GBR_NETINFO_FLASHED_PAD;
m_NetAttributeDict.m_ComponentRef = fromGerberString( dummy.GetPrm( 1 ) );
m_NetAttributeDict.m_Padname = fromGerberString( dummy.GetPrm( 2 ) );
m_NetAttributeDict.m_Netname = fromGerberString( dummy.GetPrm( 3 ) );
}
else if( dummy.GetAttribute() == ".N" )
{
if( m_NetAttributeDict.m_NetAttribType == GBR_NETLIST_METADATA::GBR_NETINFO_COMPONENT )
m_NetAttributeDict.m_NetAttribType = GBR_NETLIST_METADATA::GBR_NETINFO_NET_AND_CMP;
else
m_NetAttributeDict.m_NetAttribType = GBR_NETLIST_METADATA::GBR_NETINFO_NET;
m_NetAttributeDict.m_NetAttribType |= GBR_NETLIST_METADATA::GBR_NETINFO_NET;
m_NetAttributeDict.m_Netname = fromGerberString( dummy.GetPrm( 1 ) );
}
else if( dummy.GetAttribute() == ".C" )
{
if( m_NetAttributeDict.m_NetAttribType == GBR_NETLIST_METADATA::GBR_NETINFO_NET )
m_NetAttributeDict.m_NetAttribType = GBR_NETLIST_METADATA::GBR_NETINFO_NET_AND_CMP;
else
m_NetAttributeDict.m_NetAttribType = GBR_NETLIST_METADATA::GBR_NETINFO_COMPONENT;
m_NetAttributeDict.m_ComponentRef = fromGerberString( dummy.GetPrm( 1 ) );
m_NetAttributeDict.m_NetAttribType |= GBR_NETLIST_METADATA::GBR_NETINFO_CMP;
m_NetAttributeDict.m_Cmpref = fromGerberString( dummy.GetPrm( 1 ) );
}
else if( dummy.GetAttribute() == ".P" )
{
m_NetAttributeDict.m_NetAttribType |= GBR_NETLIST_METADATA::GBR_NETINFO_PAD;
m_NetAttributeDict.m_Cmpref = fromGerberString( dummy.GetPrm( 1 ) );
m_NetAttributeDict.m_Padname = fromGerberString( dummy.GetPrm( 2 ) );
}
}
break;

View File

@ -42,6 +42,8 @@
#include <class_DCodeSelectionbox.h>
#include <dialog_helpers.h>
#include <wx/wupdlock.h>
void GERBVIEW_FRAME::ReCreateHToolbar( void )
{
int ii;
@ -121,6 +123,65 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void )
m_mainToolBar->Realize();
}
void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
{
wxWindowUpdateLocker dummy( this );
if( m_auxiliaryToolBar )
{
updateComponentListSelectBox();
updateNetnameListSelectBox();
updateAperAttributesSelectBox();
// combobox sizes can have changed: apply new best sizes
wxSize size;
size = m_SelComponentBox->GetBestSize();
size.x = std::max( size.x, 100 );
m_SelComponentBox->SetMinSize( size );
size = m_SelNetnameBox->GetBestSize();
size.x = std::max( size.x, 100 );
m_SelNetnameBox->SetMinSize( size );
size = m_SelAperAttributesBox->GetBestSize();
size.x = std::max( size.x, 100 );
m_SelAperAttributesBox->SetMinSize( size );
m_auimgr.Update();
return;
}
m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
// Creates box to display and choose components:
m_SelComponentBox = new wxChoice( m_auxiliaryToolBar,
ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE );
m_SelComponentBox->SetToolTip( _("Selected a component and highlight its graphic items") );
updateComponentListSelectBox();
m_auxiliaryToolBar->AddControl( m_SelComponentBox );
m_auxiliaryToolBar->AddSeparator();
// Creates choice box to display net names and highlight selected:
m_SelNetnameBox = new wxChoice( m_auxiliaryToolBar,
ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE );
m_SelNetnameBox->SetToolTip( _("Selected a net name and highlight graphic items belonging to this net") );
m_auxiliaryToolBar->AddControl( m_SelNetnameBox );
updateNetnameListSelectBox();
m_auxiliaryToolBar->AddSeparator();
// Creates choice box to display aperture attributes and highlight selected:
m_SelAperAttributesBox = new wxChoice( m_auxiliaryToolBar,
ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE );
m_SelAperAttributesBox->SetToolTip( _("Selected an aperture attribute and highlight graphic items having this attribute") );
m_auxiliaryToolBar->AddControl( m_SelAperAttributesBox );
updateAperAttributesSelectBox();
m_auxiliaryToolBar->AddSeparator();
// after adding the buttons to the toolbar, must call Realize()
m_auxiliaryToolBar->Realize();
}
void GERBVIEW_FRAME::ReCreateVToolbar( void )
{
@ -233,6 +294,112 @@ void GERBVIEW_FRAME::ReCreateOptToolbar( void )
}
#define NO_SELECTION_STRING _("<No selection>")
void GERBVIEW_FRAME:: updateComponentListSelectBox()
{
m_SelComponentBox->Clear();
// Build the full list of component names from the partial lists stored in each file image
std::map<wxString, int> full_list;
for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
{
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
if( gerber == NULL ) // Graphic layer not yet used
continue;
full_list.insert( gerber->m_ComponentsList.begin(), gerber->m_ComponentsList.end() );
}
// Add an empty string to deselect net highlight
m_SelComponentBox->Append( NO_SELECTION_STRING );
// Now copy the list to the choice box
for( auto ii = full_list.begin(); ii != full_list.end(); ++ii )
{
m_SelComponentBox->Append( ii->first );
}
m_SelComponentBox->SetSelection( 0 );
}
void GERBVIEW_FRAME::updateNetnameListSelectBox()
{
m_SelNetnameBox->Clear();
// Build the full list of netnames from the partial lists stored in each file image
std::map<wxString, int> full_list;
for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
{
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
if( gerber == NULL ) // Graphic layer not yet used
continue;
full_list.insert( gerber->m_NetnamesList.begin(), gerber->m_NetnamesList.end() );
}
// Add an empty string to deselect net highlight
m_SelNetnameBox->Append( NO_SELECTION_STRING );
// Now copy the list to the choice box
for( auto ii = full_list.begin(); ii != full_list.end(); ++ii )
{
m_SelNetnameBox->Append( ii->first );
}
m_SelNetnameBox->SetSelection( 0 );
}
void GERBVIEW_FRAME::updateAperAttributesSelectBox()
{
m_SelAperAttributesBox->Clear();
// Build the full list of netnames from the partial lists stored in each file image
std::map<wxString, int> full_list;
for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
{
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
if( gerber == NULL ) // Graphic layer not yet used
continue;
if( gerber->GetDcodesCount() == 0 )
continue;
for( int ii = 0; ii < TOOLS_MAX_COUNT; ii++ )
{
D_CODE* aperture = gerber->GetDCODE( ii + FIRST_DCODE, false );
if( aperture == NULL )
continue;
if( !aperture->m_InUse && !aperture->m_Defined )
continue;
if( !aperture->m_AperFunction.IsEmpty() )
full_list.insert( std::make_pair( aperture->m_AperFunction, 0 ) );
}
}
// Add an empty string to deselect net highlight
m_SelAperAttributesBox->Append( NO_SELECTION_STRING );
// Now copy the list to the choice box
for( auto ii = full_list.begin(); ii != full_list.end(); ++ii )
{
m_SelAperAttributesBox->Append( ii->first );
}
m_SelAperAttributesBox->SetSelection( 0 );
}
void GERBVIEW_FRAME::OnUpdateDrawMode( wxUpdateUIEvent& aEvent )
{
switch( aEvent.GetId() )

View File

@ -0,0 +1,117 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef GBR_NETLIST_METADATA_H
#define GBR_NETLIST_METADATA_H
// this class handle info which can be added in a gerber file as attribute
// of an obtect
// the GBR_INFO_TYPE types can be OR'ed to add 2 (or more) attributes
// There are only 3 net attributes defined attached to an object by the %TO command
// %TO.P
// %TO.N
// %TO.C
// the .P attribute can be used only for flashed pads (using the D03 command)
// and only for external copper layers, if the component is on a external copper layer
// for other copper layer items (pads on internal layers, tracks ... ), only .N and .C
// can be used
class GBR_NETLIST_METADATA
{
public:
// This enum enables the different net attributes attache to the object
// the values can be ORed for items which can have more than one attribute
// (A flashed pad has all allowed attributes)
enum GBR_NETINFO_TYPE
{
GBR_NETINFO_UNSPECIFIED, ///< idle command (no command)
GBR_NETINFO_PAD = 1, ///< print info associated to a flashed pad (TO.P attribute)
GBR_NETINFO_NET = 2, ///< print info associated to a net (TO.N attribute)
GBR_NETINFO_CMP = 4 ///< print info associated to a component (TO.C attribute)
};
// these members are used in the %TO object attributes command.
int m_NetAttribType; ///< the type of net info
///< (used to define the gerber string to create)
wxString m_Padname; ///< for a flashed pad: the pad name ((TO.P attribute)
wxString m_Cmpref; ///< the component reference parent of the data
wxString m_Netname; ///< for items associated to a net: the netname
GBR_NETLIST_METADATA(): m_NetAttribType( GBR_NETINFO_UNSPECIFIED )
{
}
/**
* remove the net attribute specified by aName
* If aName == NULL or empty, remove all attributes
* @param aName is the name (.CN, .P .N or .C) of the attribute to remove
*/
void ClearAttribute( const wxString* aName )
{
if( m_NetAttribType == GBR_NETINFO_UNSPECIFIED )
{
m_Padname.clear();
m_Cmpref.clear();
m_Netname.clear();
return;
}
if( !aName || aName->IsEmpty() || *aName == ".CN" )
{
m_NetAttribType = GBR_NETINFO_UNSPECIFIED;
m_Padname.clear();
m_Cmpref.clear();
m_Netname.clear();
return;
}
if( *aName == ".C" )
{
m_NetAttribType &= ~GBR_NETINFO_CMP;
m_Cmpref.clear();
return;
}
if( *aName == ".N" )
{
m_NetAttribType &= ~GBR_NETINFO_NET;
m_Netname.clear();
return;
}
if( *aName == ".P" )
{
m_NetAttribType &= ~GBR_NETINFO_PAD;
m_Cmpref.clear();
return;
}
}
};
// Flashed pads use the full attribute set: this is a helper for flashed pads
#define GBR_NETINFO_ALL (GBR_NETLIST_METADATA::GBR_NETINFO_PAD\
| GBR_NETLIST_METADATA::GBR_NETINFO_NET\
| GBR_NETLIST_METADATA::GBR_NETINFO_CMP )
#endif // GBR_NETLIST_METADATA_H