From e0303a45584f7f31423f6a655635bb8de2a1f9c2 Mon Sep 17 00:00:00 2001 From: Lorenzo Marcantonio Date: Sat, 30 Mar 2013 18:24:04 +0100 Subject: [PATCH] - New typedef LAYER_MSK to encapsulate a layer bitmap - Renamed ReturnMaskLayer to GetLayerMask (since it's a plain getter) --- common/drawframe.cpp | 2 +- common/pcbcommon.cpp | 2 +- eeschema/libedit_plot_component.cpp | 2 +- eeschema/libeditframe.h | 2 +- eeschema/schframe.cpp | 3 +- gerbview/class_gbr_layout.cpp | 2 +- gerbview/class_gbr_layout.h | 5 +- gerbview/class_gbr_screen.h | 1 + gerbview/class_gerber_draw_item.h | 5 +- gerbview/class_gerbview_layer_widget.cpp | 12 ++-- .../dialogs/dialog_print_using_printer.cpp | 8 +-- gerbview/draw_gerber_screen.cpp | 4 +- gerbview/gerbview_frame.cpp | 4 +- gerbview/gerbview_frame.h | 7 ++- include/class_board_design_settings.h | 22 ++++---- include/class_board_item.h | 3 +- include/class_colors_design_settings.h | 1 + include/class_layer_box_selector.h | 1 + include/layers_id_colors_and_visibility.h | 11 ++++ include/pcbcommon.h | 10 +--- include/wxEeschemaStruct.h | 2 +- include/wxPcbStruct.h | 2 +- include/wxstruct.h | 4 +- pcbnew/class_board.cpp | 56 +++++++++---------- pcbnew/class_board.h | 20 +++---- pcbnew/class_board_design_settings.cpp | 14 ++--- pcbnew/class_module.cpp | 2 +- pcbnew/class_module.h | 2 +- pcbnew/class_module_transform_functions.cpp | 4 +- pcbnew/class_pad.cpp | 2 +- pcbnew/class_pad.h | 6 +- pcbnew/class_pad_draw_functions.cpp | 4 +- pcbnew/class_pcb_layer_widget.cpp | 14 ++--- pcbnew/class_track.cpp | 50 +++++++++-------- pcbnew/class_track.h | 12 ++-- pcbnew/collectors.h | 28 ++++++---- pcbnew/connect.cpp | 10 ++-- pcbnew/dialogs/dialog_SVG_print.cpp | 6 +- pcbnew/dialogs/dialog_SVG_print.h | 2 +- pcbnew/dialogs/dialog_global_deletion.cpp | 10 ++-- pcbnew/dialogs/dialog_layers_setup.cpp | 24 ++++---- pcbnew/dialogs/dialog_pad_properties.cpp | 14 ++--- pcbnew/dialogs/dialog_pcb_text_properties.cpp | 6 +- pcbnew/dialogs/dialog_print_using_printer.cpp | 4 +- pcbnew/drag.h | 2 +- pcbnew/dragsegm.cpp | 6 +- pcbnew/drc.cpp | 2 +- pcbnew/drc_clearance_test_functions.cpp | 6 +- pcbnew/eagle_plugin.h | 1 + pcbnew/editrack.cpp | 4 +- pcbnew/export_gencad.cpp | 20 +++---- pcbnew/export_vrml.cpp | 4 +- pcbnew/kicad_plugin.cpp | 6 +- pcbnew/kicad_plugin.h | 3 +- pcbnew/layer_widget.h | 1 + pcbnew/legacy_plugin.cpp | 7 +-- pcbnew/magnetic_tracks_functions.cpp | 4 +- pcbnew/module_editor_frame.h | 2 +- pcbnew/move_or_drag_track.cpp | 10 ++-- pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h | 1 + pcbnew/pcb_parser.cpp | 35 ++++++------ pcbnew/pcb_parser.h | 14 +++-- pcbnew/pcb_plot_params.h | 3 +- pcbnew/pcbnew.h | 1 + pcbnew/pcbplot.cpp | 6 +- pcbnew/pcbplot.h | 5 +- pcbnew/plot_board_layers.cpp | 18 +++--- pcbnew/plot_brditems_plotter.cpp | 6 +- pcbnew/print_board_functions.cpp | 30 +++++----- pcbnew/printout_controler.cpp | 2 +- pcbnew/printout_controler.h | 4 +- pcbnew/protos.h | 2 +- pcbnew/sel_layer.cpp | 8 +-- pcbnew/tr_modif.cpp | 10 ++-- pcbnew/tracepcb.cpp | 6 +- polygon/PolyLine.h | 2 +- 76 files changed, 329 insertions(+), 307 deletions(-) diff --git a/common/drawframe.cpp b/common/drawframe.cpp index e67d5996ff..5c08e7ffe6 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -320,7 +320,7 @@ void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event ) } -void EDA_DRAW_FRAME::PrintPage( wxDC* aDC,int aPrintMask, bool aPrintMirrorMode, void* aData ) +void EDA_DRAW_FRAME::PrintPage( wxDC* aDC,LAYER_MSK aPrintMask, bool aPrintMirrorMode, void* aData ) { wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") ); } diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index 058af23ea9..58441b01c5 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -71,7 +71,7 @@ int GetLayerMask( int aLayerNumber ) /* Look up Table for conversion copper layer count -> general copper layer * mask: */ -int g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = { +LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = { 0x0001, 0x8001, 0x8003, 0x8007, 0x800F, 0x801F, 0x803F, 0x807F, 0x80FF, 0x81FF, 0x83FF, 0x87FF, diff --git a/eeschema/libedit_plot_component.cpp b/eeschema/libedit_plot_component.cpp index 3f0d4e1ad5..90362cc417 100644 --- a/eeschema/libedit_plot_component.cpp +++ b/eeschema/libedit_plot_component.cpp @@ -144,7 +144,7 @@ void LIB_EDIT_FRAME::SVG_Print_Component( const wxString& FullFileName ) plotBW, plotFrameRef ); } -void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData) +void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMask, bool aPrintMirrorMode, void* aData) { if( ! m_component ) return; diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index b991a838ab..439b0d059d 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -637,7 +637,7 @@ public: * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ - virtual void PrintPage( wxDC* aDC, int aPrintMask, + virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMask, bool aPrintMirrorMode, void* aData = NULL ); /** diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index f9102268e6..18b52d2f03 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -848,7 +848,8 @@ void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event ) } } -void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData ) +void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMask, bool aPrintMirrorMode, + void* aData ) { GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE ); TraceWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, diff --git a/gerbview/class_gbr_layout.cpp b/gerbview/class_gbr_layout.cpp index ca18a84e7b..a503a03a98 100644 --- a/gerbview/class_gbr_layout.cpp +++ b/gerbview/class_gbr_layout.cpp @@ -29,7 +29,7 @@ GBR_LAYOUT::~GBR_LAYOUT() */ bool GBR_LAYOUT::IsLayerVisible( int aLayerIndex ) const { - return m_printLayersMask & (1 << aLayerIndex ); + return m_printLayersMask & GetLayerMask( aLayerIndex ); } diff --git a/gerbview/class_gbr_layout.h b/gerbview/class_gbr_layout.h index 3dd34641ea..8967357e38 100644 --- a/gerbview/class_gbr_layout.h +++ b/gerbview/class_gbr_layout.h @@ -15,6 +15,7 @@ #include #include +#include /** * Class GBR_LAYOUT @@ -27,7 +28,7 @@ private: PAGE_INFO m_paper; TITLE_BLOCK m_titles; wxPoint m_originAxisPosition; - int m_printLayersMask; // When printing: the list of layers to print + LAYER_MSK m_printLayersMask; // When printing: the list of layers to print public: DLIST m_Drawings; // linked list of Gerber Items @@ -90,7 +91,7 @@ public: * changes the bit-mask of visible layers * @param aLayerMask = The new bit-mask of visible layers */ - void SetVisibleLayers( int aLayerMask ) + void SetVisibleLayers( LAYER_MSK aLayerMask ) { m_printLayersMask = aLayerMask; } diff --git a/gerbview/class_gbr_screen.h b/gerbview/class_gbr_screen.h index adc14b4567..77640a1a2a 100644 --- a/gerbview/class_gbr_screen.h +++ b/gerbview/class_gbr_screen.h @@ -8,6 +8,7 @@ #include #include +#include #define ZOOM_FACTOR( x ) ( x * IU_PER_DECIMILS ) diff --git a/gerbview/class_gerber_draw_item.h b/gerbview/class_gerber_draw_item.h index 08723f54b4..3d6cfda162 100644 --- a/gerbview/class_gerber_draw_item.h +++ b/gerbview/class_gerber_draw_item.h @@ -31,6 +31,7 @@ #include #include +#include #include class GERBER_IMAGE; @@ -133,9 +134,9 @@ public: */ void SetLayer( int aLayer ) { m_Layer = aLayer; } - int ReturnMaskLayer() + LAYER_MSK GetLayerMask() { - return 1 << m_Layer; + return ::GetLayerMask( m_Layer ); } bool GetLayerPolarity() diff --git a/gerbview/class_gerbview_layer_widget.cpp b/gerbview/class_gerbview_layer_widget.cpp index 64228206f4..eea92f7d16 100644 --- a/gerbview/class_gerbview_layer_widget.cpp +++ b/gerbview/class_gerbview_layer_widget.cpp @@ -163,7 +163,7 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) int rowCount; int menuId = event.GetId(); bool visible = (menuId == ID_SHOW_ALL_COPPERS) ? true : false;; - int visibleLayers = 0; + LAYER_MSK visibleLayers = NO_LAYERS; switch( menuId ) { @@ -181,9 +181,9 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 ); cb->SetValue( loc_visible ); if( loc_visible ) - visibleLayers |= (1 << row); + visibleLayers |= GetLayerMask( row ); else - visibleLayers &= ~(1 << row); + visibleLayers &= ~GetLayerMask( row ); } myframe->SetVisibleLayers( visibleLayers ); @@ -235,12 +235,12 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer ) void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) { - int visibleLayers = myframe->GetVisibleLayers(); + LAYER_MSK visibleLayers = myframe->GetVisibleLayers(); if( isVisible ) - visibleLayers |= (1 << aLayer); + visibleLayers |= GetLayerMask( aLayer ); else - visibleLayers &= ~(1 << aLayer); + visibleLayers &= ~GetLayerMask( aLayer ); myframe->SetVisibleLayers( visibleLayers ); diff --git a/gerbview/dialogs/dialog_print_using_printer.cpp b/gerbview/dialogs/dialog_print_using_printer.cpp index c5619e3d2b..27749d4df4 100644 --- a/gerbview/dialogs/dialog_print_using_printer.cpp +++ b/gerbview/dialogs/dialog_print_using_printer.cpp @@ -188,7 +188,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) { m_BoxSelectLayer[layer]->SetValue( option ); if( option ) - s_SelectedLayers |= 1 << layer; + s_SelectedLayers |= GetLayerMask( layer ); } } } @@ -223,15 +223,15 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) int DIALOG_PRINT_USING_PRINTER::SetLayerMaskFromListSelection() /**************************************************************/ { - int page_count; - s_Parameters.m_PrintMaskLayer = 0; + int page_count = 0; + s_Parameters.m_PrintMaskLayer = NO_LAYERS; int ii; for( ii = 0, page_count = 0; ii < GERBVIEW_LAYER_COUNT; ii++ ) { if( m_BoxSelectLayer[ii]->IsChecked() ) { page_count++; - s_Parameters.m_PrintMaskLayer |= 1 << ii; + s_Parameters.m_PrintMaskLayer |= GetLayerMask( ii ); } } diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index 12eba4be26..42aa4d79dd 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -41,11 +41,11 @@ #include -void GERBVIEW_FRAME::PrintPage( wxDC* aDC, int aPrintMasklayer, +void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer, bool aPrintMirrorMode, void* aData ) { // Save current draw options, because print mode has specific options: - int visiblemask = GetVisibleLayers(); + LAYER_MSK visiblemask = GetVisibleLayers(); GBR_DISPLAY_OPTIONS imgDisplayOptions = m_DisplayOptions; // Set draw options for printing: diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 10c75758c2..b1b9945afb 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -537,7 +537,7 @@ void GERBVIEW_FRAME::SetVisibleAlls() * Returns a bit-mask of all the layers that are visible * @return int - the visible layers in bit-mapped form. */ -int GERBVIEW_FRAME::GetVisibleLayers() const +LAYER_MSK GERBVIEW_FRAME::GetVisibleLayers() const { return -1; // TODO } @@ -549,7 +549,7 @@ int GERBVIEW_FRAME::GetVisibleLayers() const * changes the bit-mask of visible layers * @param aLayerMask = The new bit-mask of visible layers */ -void GERBVIEW_FRAME::SetVisibleLayers( int aLayerMask ) +void GERBVIEW_FRAME::SetVisibleLayers( LAYER_MSK aLayerMask ) { GetLayout()->SetVisibleLayers( aLayerMask ); } diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 6a325020cb..bc69fd4915 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -37,6 +37,7 @@ #include #include #include +#include #define NO_AVAILABLE_LAYERS -1 @@ -299,7 +300,7 @@ public: * Returns a bit-mask of all the layers that are visible * @return int - the visible layers in bit-mapped form. */ - int GetVisibleLayers() const; + LAYER_MSK GetVisibleLayers() const; /** * Function SetVisibleLayers @@ -307,7 +308,7 @@ public: * changes the bit-mask of visible layers * @param aLayerMask = The new bit-mask of visible layers */ - void SetVisibleLayers( int aLayerMask ); + void SetVisibleLayers( LAYER_MSK aLayerMask ); /** * Function IsLayerVisible @@ -716,7 +717,7 @@ public: * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ - virtual void PrintPage( wxDC* aDC, int aPrintMasklayer, bool aPrintMirrorMode, + virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer, bool aPrintMirrorMode, void* aData = NULL ); /** diff --git a/include/class_board_design_settings.h b/include/class_board_design_settings.h index 98854008f9..bcf6e6b651 100644 --- a/include/class_board_design_settings.h +++ b/include/class_board_design_settings.h @@ -56,7 +56,7 @@ public: * returns a bit-mask of all the layers that are visible * @return int - the visible layers in bit-mapped form. */ - int GetVisibleLayers() const; + LAYER_MSK GetVisibleLayers() const; /** * Function SetVisibleAlls @@ -70,7 +70,7 @@ public: * changes the bit-mask of visible layers * @param aMask = The new bit-mask of visible layers */ - void SetVisibleLayers( int aMask ); + void SetVisibleLayers( LAYER_MSK aMask ); /** * Function IsLayerVisible @@ -85,7 +85,7 @@ public: return false; // If a layer is disabled, it is automatically invisible - return (bool) ( m_VisibleLayers & m_EnabledLayers & (1 << aLayerIndex) ); + return bool( m_VisibleLayers & m_EnabledLayers & GetLayerMask( aLayerIndex ) ); } /** @@ -143,7 +143,7 @@ public: * returns a bit-mask of all the layers that are enabled * @return int - the enabled layers in bit-mapped form. */ - inline int GetEnabledLayers() const + inline LAYER_MSK GetEnabledLayers() const { return m_EnabledLayers; } @@ -153,7 +153,7 @@ public: * changes the bit-mask of enabled layers * @param aMask = The new bit-mask of enabled layers */ - void SetEnabledLayers( int aMask ); + void SetEnabledLayers( LAYER_MSK aMask ); /** * Function IsLayerEnabled @@ -163,7 +163,7 @@ public: */ bool IsLayerEnabled( int aLayerIndex ) const { - return bool( m_EnabledLayers & (1 << aLayerIndex) ); + return bool( m_EnabledLayers & GetLayerMask( aLayerIndex ) ); } /** @@ -194,11 +194,11 @@ public: void SetBoardThickness( int aThickness ) { m_boardThickness = aThickness; } private: - int m_CopperLayerCount; ///< Number of copper layers for this design - int m_EnabledLayers; ///< Bit-mask for layer enabling - int m_VisibleLayers; ///< Bit-mask for layer visibility - int m_VisibleElements; ///< Bit-mask for element category visibility - int m_boardThickness; ///< Board thickness for 3D viewer + int m_CopperLayerCount; ///< Number of copper layers for this design + LAYER_MSK m_EnabledLayers; ///< Bit-mask for layer enabling + LAYER_MSK m_VisibleLayers; ///< Bit-mask for layer visibility + int m_VisibleElements; ///< Bit-mask for element category visibility + int m_boardThickness; ///< Board thickness for 3D viewer }; #endif // BOARD_DESIGN_SETTINGS_H_ diff --git a/include/class_board_item.h b/include/class_board_item.h index 2c64957d48..99b36d54f7 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -34,7 +34,8 @@ #include #include #include - +#include +#include /// Abbrevation for fomatting internal units to a string. #define FMT_IU BOARD_ITEM::FormatInternalUnits diff --git a/include/class_colors_design_settings.h b/include/class_colors_design_settings.h index fe606cb389..b2149a1149 100644 --- a/include/class_colors_design_settings.h +++ b/include/class_colors_design_settings.h @@ -5,6 +5,7 @@ #ifndef _COLORS_DESIGN_SETTING_H #define _COLORS_DESIGN_SETTING_H +#include #define LAYERSCOLORSBUFFERSIZE 32 #define ITEMSCOLORSBUFFERSIZE 32 diff --git a/include/class_layer_box_selector.h b/include/class_layer_box_selector.h index 4ee711981c..23ba970766 100644 --- a/include/class_layer_box_selector.h +++ b/include/class_layer_box_selector.h @@ -3,6 +3,7 @@ #include #include +#include class wxAuiToolBar; diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index 6b7fd7ef38..70038f0299 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -51,6 +51,7 @@ #define LAYER_COUNT 32 // Masks to identify a layer by a bit map +typedef unsigned LAYER_MSK; #define LAYER_BACK (1 << LAYER_N_BACK) ///< bit mask for copper layer #define LAYER_2 (1 << LAYER_N_2) ///< bit mask for layer 2 #define LAYER_3 (1 << LAYER_N_3) ///< bit mask for layer 3 @@ -92,6 +93,16 @@ #define ALL_CU_LAYERS 0x0000FFFF #define INTERNAL_LAYERS 0x00007FFE #define EXTERNAL_LAYERS 0x00008001 +#define NO_LAYERS 0x00000000 + +/** return a one bit layer mask from a layer number + * aLayerNumber = the layer number to convert (0 .. LAYERS-1) + */ +inline LAYER_MSK GetLayerMask( unsigned aLayerNumber ) +{ + return 1 << aLayerNumber; +} + // layers order in dialogs (plot, print and toolbars) diff --git a/include/pcbcommon.h b/include/pcbcommon.h index 4e7d1f7882..6ce9572123 100644 --- a/include/pcbcommon.h +++ b/include/pcbcommon.h @@ -18,16 +18,8 @@ class TRACK; class BOARD; class DISPLAY_OPTIONS; - -/** - * Function GetLayerMask - * @return a one bit layer mask from a layer number - * @param aLayerNumber = the layer number to convert (0 .. LAYER_COUNT-1) - */ -int GetLayerMask( int aLayerNumber ); - /// Look up Table for conversion copper layer count -> general copper layer mask: -extern int g_TabAllCopperLayerMask[NB_COPPER_LAYERS]; +extern LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS]; extern DISPLAY_OPTIONS DisplayOpt; diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index aadf337054..921dd26ec0 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -1219,7 +1219,7 @@ public: * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ - virtual void PrintPage( wxDC* aDC, int aPrintMask, + virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMask, bool aPrintMirrorMode, void* aData = NULL ); void SetSimulatorCommand( const wxString& aCommand ) { m_simulatorCommand = aCommand; } diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 7fdae7f55e..fdd36da6a0 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -270,7 +270,7 @@ public: * @param aPrintMirrorMode = true to plot mirrored * @param aData = a pointer on an auxiliary data (NULL if not used) */ - virtual void PrintPage( wxDC* aDC, int aPrintMaskLayer, bool aPrintMirrorMode, + virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMaskLayer, bool aPrintMirrorMode, void * aData = NULL ); void GetKicadAbout( wxCommandEvent& event ); diff --git a/include/wxstruct.h b/include/wxstruct.h index a359981191..ad5230d8db 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -43,7 +43,9 @@ #include #include +#include #include +#include #ifdef USE_WX_OVERLAY #include @@ -880,7 +882,7 @@ public: * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ - virtual void PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData = NULL ); + virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMask, bool aPrintMirrorMode, void* aData = NULL ); /** * Function CoordinateToString diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 0e8fe450b5..7ccfdb71d8 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -127,7 +127,7 @@ void BOARD::Move( const wxPoint& aMoveVector ) // overload } -void BOARD::chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* aList ) +void BOARD::chainMarkedSegments( wxPoint aPosition, LAYER_MSK aLayerMask, TRACK_PTRS* aList ) { TRACK* segment; // The current segment being analyzed. TRACK* via; // The via identified, eventually destroy @@ -166,7 +166,7 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* if( via ) { - aLayerMask = via->ReturnMaskLayer(); + aLayerMask = via->GetLayerMask(); aList->push_back( via ); } @@ -212,7 +212,7 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* * candidate: * we must analyze connections to its other end */ - aLayerMask = candidate->ReturnMaskLayer(); + aLayerMask = candidate->GetLayerMask(); if( aPosition == candidate->GetStart() ) { @@ -227,7 +227,7 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* /* flag this item an push it in list of selected items */ aList->push_back( candidate ); - candidate->SetState( BUSY, ON ); + candidate->SetState( BUSY, true ); } else { @@ -542,25 +542,25 @@ void BOARD::SetCopperLayerCount( int aCount ) } -int BOARD::GetEnabledLayers() const +LAYER_MSK BOARD::GetEnabledLayers() const { return m_designSettings.GetEnabledLayers(); } -int BOARD::GetVisibleLayers() const +LAYER_MSK BOARD::GetVisibleLayers() const { return m_designSettings.GetVisibleLayers(); } -void BOARD::SetEnabledLayers( int aLayerMask ) +void BOARD::SetEnabledLayers( LAYER_MSK aLayerMask ) { m_designSettings.SetEnabledLayers( aLayerMask ); } -void BOARD::SetVisibleLayers( int aLayerMask ) +void BOARD::SetVisibleLayers( LAYER_MSK aLayerMask ) { m_designSettings.SetVisibleLayers( aLayerMask ); } @@ -1557,7 +1557,7 @@ TRACK* BOARD::GetViaByPosition( const wxPoint& aPosition, int aLayerMask ) } -D_PAD* BOARD::GetPad( const wxPoint& aPosition, int aLayerMask ) +D_PAD* BOARD::GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask ) { D_PAD* pad = NULL; @@ -1578,7 +1578,7 @@ D_PAD* BOARD::GetPad( TRACK* aTrace, int aEndPoint ) D_PAD* pad = NULL; wxPoint aPosition; - int aLayerMask = GetLayerMask( aTrace->GetLayer() ); + LAYER_MSK aLayerMask = GetLayerMask( aTrace->GetLayer() ); if( aEndPoint == FLG_START ) { @@ -1601,7 +1601,7 @@ D_PAD* BOARD::GetPad( TRACK* aTrace, int aEndPoint ) } -D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, int aLayerMask ) +D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, LAYER_MSK aLayerMask ) { for( unsigned i=0; i& aPadList, const wxPoint& aPosition, int aLayerMask ) +D_PAD* BOARD::GetPad( std::vector& aPadList, const wxPoint& aPosition, LAYER_MSK aLayerMask ) { // Search the aPoint coordinates in aPadList // aPadList is sorted by X then Y values, and a fast binary search is used @@ -1643,7 +1643,7 @@ D_PAD* BOARD::GetPad( std::vector& aPadList, const wxPoint& aPosition, i if( pad->GetPosition() == aPosition ) // candidate found { // The pad must match the layer mask: - if( (aLayerMask & pad->GetLayerMask()) != 0 ) + if( aLayerMask & pad->GetLayerMask()) return pad; // More than one pad can be at aPosition @@ -1747,7 +1747,7 @@ void BOARD::GetSortedPadListByXthenYCoord( std::vector& aVector, int aNe } -TRACK* BOARD::GetTrace( TRACK* aTrace, const wxPoint& aPosition, int aLayerMask ) +TRACK* BOARD::GetTrace( TRACK* aTrace, const wxPoint& aPosition, LAYER_MSK aLayerMask ) { for( TRACK* track = aTrace; track; track = track->Next() ) { @@ -1798,11 +1798,11 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount, // Ensure the flag BUSY of all tracks of the board is cleared // because we use it to mark segments of the track for( TRACK* track = m_Track; track; track = track->Next() ) - track->SetState( BUSY, OFF ); + track->SetState( BUSY, false ); /* Set flags of the initial track segment */ - aTrace->SetState( BUSY, ON ); - int layerMask = aTrace->ReturnMaskLayer(); + aTrace->SetState( BUSY, true ); + LAYER_MSK layerMask = aTrace->GetLayerMask(); trackList.push_back( aTrace ); @@ -1838,13 +1838,13 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount, if( Segm1 ) // search for others segments connected to the initial segment start point { - layerMask = Segm1->ReturnMaskLayer(); + layerMask = Segm1->GetLayerMask(); chainMarkedSegments( aTrace->GetStart(), layerMask, &trackList ); } if( Segm2 ) // search for others segments connected to the initial segment end point { - layerMask = Segm2->ReturnMaskLayer(); + layerMask = Segm2->GetLayerMask(); chainMarkedSegments( aTrace->GetStart(), layerMask, &trackList ); } } @@ -1869,9 +1869,9 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount, if( via == aTrace ) continue; - via->SetState( BUSY, ON ); // Try to flag it. the flag will be cleared later if needed + via->SetState( BUSY, true ); // Try to flag it. the flag will be cleared later if needed - layerMask = via->ReturnMaskLayer(); + layerMask = via->GetLayerMask(); TRACK* track = ::GetTrace( m_Track, NULL, via->GetStart(), layerMask ); @@ -1901,7 +1901,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount, { // The via connects segments of an other track: it is removed // from list because it is member of an other track - via->SetState( BUSY, OFF ); + via->SetState( BUSY, false ); break; } } @@ -1984,7 +1984,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount, if( track->GetState( BUSY ) ) { NbSegmBusy++; - track->SetState( BUSY, OFF ); + track->SetState( BUSY, false ); full_len += track->GetLength(); // Add now length die. @@ -2096,7 +2096,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, int aActiveLayer, } -BOARD_CONNECTED_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, int aLayerMask ) +BOARD_CONNECTED_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, LAYER_MSK aLayerMask ) { for( MODULE* module = m_Modules; module; module = module->Next() ) { @@ -2155,7 +2155,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS // The new segment begins at the new point, newTrack->SetStart(lockPoint); newTrack->start = aSegment; - newTrack->SetState( BEGIN_ONPAD, OFF ); + newTrack->SetState( BEGIN_ONPAD, false ); DLIST* list = (DLIST*)aSegment->GetList(); wxASSERT( list ); @@ -2177,16 +2177,16 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS // Old track segment now ends at new point. aSegment->SetEnd(lockPoint); aSegment->end = newTrack; - aSegment->SetState( END_ONPAD, OFF ); + aSegment->SetState( END_ONPAD, false ); D_PAD * pad = GetPad( newTrack, FLG_START ); if ( pad ) { newTrack->start = pad; - newTrack->SetState( BEGIN_ONPAD, ON ); + newTrack->SetState( BEGIN_ONPAD, true ); aSegment->end = pad; - aSegment->SetState( END_ONPAD, ON ); + aSegment->SetState( END_ONPAD, true ); } aPosition = lockPoint; diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 218fee5ef5..c397e3d05b 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -234,7 +234,7 @@ private: * @param aLayerMask The allowed layers for segments to search. * @param aList The track list to fill with points of flagged segments. */ - void chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* aList ); + void chainMarkedSegments( wxPoint aPosition, LAYER_MSK aLayerMask, TRACK_PTRS* aList ); void formatNetClass( NETCLASS* aNetClass, OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const @@ -425,7 +425,7 @@ public: * Returns a bit-mask of all the layers that are enabled * @return int - the enabled layers in bit-mapped form. */ - int GetEnabledLayers() const; + LAYER_MSK GetEnabledLayers() const; /** * Function SetEnabledLayers @@ -433,7 +433,7 @@ public: * Changes the bit-mask of enabled layers * @param aLayerMask = The new bit-mask of enabled layers */ - void SetEnabledLayers( int aLayerMask ); + void SetEnabledLayers( LAYER_MSK aLayerMask ); /** * Function IsLayerEnabled @@ -465,7 +465,7 @@ public: * Returns a bit-mask of all the layers that are visible * @return int - the visible layers in bit-mapped form. */ - int GetVisibleLayers() const; + LAYER_MSK GetVisibleLayers() const; /** * Function SetVisibleLayers @@ -473,7 +473,7 @@ public: * changes the bit-mask of visible layers * @param aLayerMask = The new bit-mask of visible layers */ - void SetVisibleLayers( int aLayerMask ); + void SetVisibleLayers( LAYER_MSK aLayerMask ); // these 2 functions are not tidy at this time, since there are PCB_VISIBLEs that // are not stored in the bitmap. @@ -1223,7 +1223,7 @@ public: * @param aLayerMask A layer or layers to mask the hit test. * @return A pointer to a D_PAD object if found or NULL if not found. */ - D_PAD* GetPad( const wxPoint& aPosition, int aLayerMask = ALL_LAYERS ); + D_PAD* GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask = ALL_LAYERS ); /** * Function GetPad @@ -1245,7 +1245,7 @@ public: * @param aLayer A layer or layers to mask the hit test. * @return A pointer to a D_PAD object if found or NULL if not found. */ - D_PAD* GetPadFast( const wxPoint& aPosition, int aLayer ); + D_PAD* GetPadFast( const wxPoint& aPosition, LAYER_MSK aLayerMask ); /** * Function GetPad @@ -1262,7 +1262,7 @@ public: * @param aLayerMask A layer or layers to mask the hit test. * @return a D_PAD object pointer to the connected pad. */ - D_PAD* GetPad( std::vector& aPadList, const wxPoint& aPosition, int aLayerMask ); + D_PAD* GetPad( std::vector& aPadList, const wxPoint& aPosition, LAYER_MSK aLayerMask ); /** * Function GetSortedPadListByXthenYCoord @@ -1289,7 +1289,7 @@ public: * layer mask. * @return A TRACK object pointer if found otherwise NULL. */ - TRACK* GetTrace( TRACK* aTrace, const wxPoint& aPosition, int aLayerMask ); + TRACK* GetTrace( TRACK* aTrace, const wxPoint& aPosition, LAYER_MSK aLayerMask ); /** * Function MarkTrace @@ -1348,7 +1348,7 @@ public: * layer mask. * @return A pointer to a BOARD_ITEM object if found otherwise NULL. */ - BOARD_CONNECTED_ITEM* GetLockPoint( const wxPoint& aPosition, int aLayerMask ); + BOARD_CONNECTED_ITEM* GetLockPoint( const wxPoint& aPosition, LAYER_MSK aLayerMask ); /** * Function CreateLockPoint diff --git a/pcbnew/class_board_design_settings.cpp b/pcbnew/class_board_design_settings.cpp index d5e8b5c226..a7764d807f 100644 --- a/pcbnew/class_board_design_settings.cpp +++ b/pcbnew/class_board_design_settings.cpp @@ -171,7 +171,7 @@ void BOARD_DESIGN_SETTINGS::AppendConfigs( PARAM_CFG_ARRAY* aResult ) // see pcbstruct.h -int BOARD_DESIGN_SETTINGS::GetVisibleLayers() const +LAYER_MSK BOARD_DESIGN_SETTINGS::GetVisibleLayers() const { return m_VisibleLayers; } @@ -184,7 +184,7 @@ void BOARD_DESIGN_SETTINGS::SetVisibleAlls() } -void BOARD_DESIGN_SETTINGS::SetVisibleLayers( int aMask ) +void BOARD_DESIGN_SETTINGS::SetVisibleLayers( LAYER_MSK aMask ) { // Although Pcbnew uses only 29, GerbView uses all 32 layers m_VisibleLayers = aMask & m_EnabledLayers & FULL_LAYERS; @@ -198,9 +198,9 @@ void BOARD_DESIGN_SETTINGS::SetLayerVisibility( int aLayerIndex, bool aNewState return; if( aNewState && IsLayerEnabled( aLayerIndex ) ) - m_VisibleLayers |= 1 << aLayerIndex; + m_VisibleLayers |= GetLayerMask( aLayerIndex ); else - m_VisibleLayers &= ~( 1 << aLayerIndex ); + m_VisibleLayers &= ~GetLayerMask( aLayerIndex ); } @@ -229,12 +229,12 @@ void BOARD_DESIGN_SETTINGS::SetCopperLayerCount( int aNewLayerCount ) if( m_CopperLayerCount > 1 ) m_EnabledLayers |= LAYER_FRONT; - for( int ii = 1; ii < aNewLayerCount - 1; ii++ ) - m_EnabledLayers |= 1 << ii; + for( int ii = LAYER_N_2; ii < aNewLayerCount - 1; ++ii ) + m_EnabledLayers |= GetLayerMask( ii ); } -void BOARD_DESIGN_SETTINGS::SetEnabledLayers( int aMask ) +void BOARD_DESIGN_SETTINGS::SetEnabledLayers( LAYER_MSK aMask ) { // Back and front layers are always enabled. aMask |= LAYER_BACK | LAYER_FRONT; diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 5d1a9b183f..c6eaac88f0 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -573,7 +573,7 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const } -D_PAD* MODULE::GetPad( const wxPoint& aPosition, int aLayerMask ) +D_PAD* MODULE::GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask ) { for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) { diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 74041b7050..507d38e0b1 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -312,7 +312,7 @@ public: * @param aLayerMask A layer or layers to mask the hit test. * @return A pointer to a D_PAD object if found otherwise NULL. */ - D_PAD* GetPad( const wxPoint& aPosition, int aLayerMask = ALL_LAYERS ); + D_PAD* GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask = ALL_LAYERS ); /** * GetPadCount diff --git a/pcbnew/class_module_transform_functions.cpp b/pcbnew/class_module_transform_functions.cpp index afad7503a0..be9bb14dc8 100644 --- a/pcbnew/class_module_transform_functions.cpp +++ b/pcbnew/class_module_transform_functions.cpp @@ -79,9 +79,9 @@ int BOARD::ReturnFlippedLayerNumber( int oldlayer ) /* Calculate the mask layer when flipping a footprint * BACK and FRONT copper layers , mask, paste, solder layers are swapped */ -int ChangeSideMaskLayer( int aMask ) +LAYER_MSK ChangeSideMaskLayer( LAYER_MSK aMask ) { - int newMask; + LAYER_MSK newMask; newMask = aMask & ~(LAYER_BACK | LAYER_FRONT | SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT | diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 7d3101e523..d80ff222ae 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -690,7 +690,7 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) // see class_pad.h bool D_PAD::IsOnLayer( int aLayer ) const { - return (1 << aLayer) & m_layerMask; + return ::GetLayerMask( aLayer ) & m_layerMask; } diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 2a58543ec6..a7003f9cfb 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -186,8 +186,8 @@ public: void SetDrillShape( PAD_SHAPE_T aDrillShape ) { m_DrillShape = aDrillShape; } PAD_SHAPE_T GetDrillShape() const { return m_DrillShape; } - void SetLayerMask( int aLayerMask ) { m_layerMask = aLayerMask; } - int GetLayerMask() const { return m_layerMask; } + void SetLayerMask( LAYER_MSK aLayerMask ) { m_layerMask = aLayerMask; } + LAYER_MSK GetLayerMask() const { return m_layerMask; } void SetAttribute( PAD_ATTR_T aAttribute ); PAD_ATTR_T GetAttribute() const { return m_Attribute; } @@ -454,7 +454,7 @@ private: */ wxPoint m_Offset; - int m_layerMask; ///< Bitwise layer :1= copper layer, 15= cmp, + LAYER_MSK m_layerMask; ///< Bitwise layer :1= copper layer, 15= cmp, ///< 2..14 = internal layers ///< 16 .. 31 = technical layers diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index e9cc99131e..09d1862a71 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -246,8 +246,8 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, // if routing between copper and component layers, // or the current layer is one of said 2 external copper layers, // then highlight only the current layer. - if( ( ( 1 << routeTop ) | ( 1 << routeBot ) ) == ( LAYER_BACK | LAYER_FRONT ) - || ( ( 1 << screen->m_Active_Layer ) & ( LAYER_BACK | LAYER_FRONT ) ) ) + if( ( ::GetLayerMask( routeTop ) | ::GetLayerMask( routeBot ) ) == ( LAYER_BACK | LAYER_FRONT ) + || ( ::GetLayerMask( screen->m_Active_Layer ) & ( LAYER_BACK | LAYER_FRONT ) ) ) { if( !IsOnLayer( screen->m_Active_Layer ) ) ColorTurnToDarkDarkGray( &color ); diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 819a589f20..6de78f808d 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -263,7 +263,7 @@ void PCB_LAYER_WIDGET::ReFill() // show all coppers first, with front on top, back on bottom, then technical layers layer = LAYER_N_FRONT; - if( enabledLayers & (1 << layer) ) + if( enabledLayers & GetLayerMask( layer ) ) { AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ), _("Front copper layer"), true ) ); @@ -271,7 +271,7 @@ void PCB_LAYER_WIDGET::ReFill() for( layer = LAYER_N_FRONT-1; layer >= 1; --layer ) { - if( enabledLayers & (1 << layer) ) + if( enabledLayers & GetLayerMask( layer ) ) { AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ), _("An innner copper layer"), true ) ); @@ -279,7 +279,7 @@ void PCB_LAYER_WIDGET::ReFill() } layer = LAYER_N_BACK; - if( enabledLayers & (1 << layer) ) + if( enabledLayers & GetLayerMask( layer ) ) { AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ), _("Back copper layer"), true ) ); @@ -309,7 +309,7 @@ void PCB_LAYER_WIDGET::ReFill() { layer = techLayerSeq[i].layerId; - if( !(enabledLayers & (1 << layer)) ) + if( !(enabledLayers & GetLayerMask( layer )) ) continue; AppendLayerRow( LAYER_WIDGET::ROW( @@ -349,12 +349,12 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal { BOARD* brd = myframe->GetBoard(); - int visibleLayers = brd->GetVisibleLayers(); + LAYER_MSK visibleLayers = brd->GetVisibleLayers(); if( isVisible ) - visibleLayers |= (1 << aLayer); + visibleLayers |= GetLayerMask( aLayer ); else - visibleLayers &= ~(1 << aLayer); + visibleLayers &= ~GetLayerMask( aLayer ); brd->SetVisibleLayers( visibleLayers ); diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index b8c2413614..514c091529 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -87,7 +87,7 @@ inline bool IsNear( wxPoint& p1, wxPoint& p2, int max_dist ) } -TRACK* GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask ) +TRACK* GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, const wxPoint& aPosition, LAYER_MSK aLayerMask ) { TRACK* PtSegm; @@ -100,13 +100,13 @@ TRACK* GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, const wxPoint& aPosition, { if( aPosition == PtSegm->GetStart() ) { - if( aLayerMask & PtSegm->ReturnMaskLayer() ) + if( aLayerMask & PtSegm->GetLayerMask() ) return PtSegm; } if( aPosition == PtSegm->GetEnd() ) { - if( aLayerMask & PtSegm->ReturnMaskLayer() ) + if( aLayerMask & PtSegm->GetLayerMask() ) return PtSegm; } } @@ -429,7 +429,7 @@ bool SEGVIA::IsOnLayer( int layer_number ) const } -int TRACK::ReturnMaskLayer() const +LAYER_MSK TRACK::GetLayerMask() const { if( Type() == PCB_VIA_T ) { @@ -445,18 +445,19 @@ int TRACK::ReturnMaskLayer() const // ReturnLayerPair() knows how layers are stored ( (SEGVIA*) this )->ReturnLayerPair( &top_layer, &bottom_layer ); - int layermask = 0; + LAYER_MSK layermask = NO_LAYERS; while( bottom_layer <= top_layer ) { - layermask |= GetLayerMask( bottom_layer++ ); + layermask |= ::GetLayerMask( bottom_layer ); + ++bottom_layer; } return layermask; } else { - return GetLayerMask( m_Layer ); + return ::GetLayerMask( m_Layer ); } } @@ -1190,7 +1191,7 @@ bool TRACK::HitTest( const EDA_RECT& aRect ) const } -TRACK* TRACK::GetVia( const wxPoint& aPosition, int aLayerMask ) +TRACK* TRACK::GetVia( const wxPoint& aPosition, int aLayer ) { TRACK* track; @@ -1205,10 +1206,10 @@ TRACK* TRACK::GetVia( const wxPoint& aPosition, int aLayerMask ) if( track->GetState( BUSY | IS_DELETED ) ) continue; - if( aLayerMask < 0 ) + if( aLayer < 0 ) break; - if( track->IsOnLayer( aLayerMask ) ) + if( track->IsOnLayer( aLayer ) ) break; } @@ -1216,7 +1217,7 @@ TRACK* TRACK::GetVia( const wxPoint& aPosition, int aLayerMask ) } -TRACK* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask ) +TRACK* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, LAYER_MSK aLayerMask ) { TRACK* trace; @@ -1228,7 +1229,7 @@ TRACK* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask { if( trace->GetState( BUSY | IS_DELETED ) == 0 ) { - if( aLayerMask & trace->ReturnMaskLayer() ) + if( aLayerMask & trace->GetLayerMask() ) return trace; } } @@ -1258,7 +1259,7 @@ TRACK* TRACK::GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, int aEndPoint ) else position = m_End; - Reflayer = ReturnMaskLayer(); + Reflayer = GetLayerMask(); previousSegment = nextSegment = this; @@ -1282,13 +1283,13 @@ TRACK* TRACK::GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, int aEndPoint ) if( IsNear( position, nextSegment->m_Start, max_dist ) ) { - if( Reflayer & nextSegment->ReturnMaskLayer() ) + if( Reflayer & nextSegment->GetLayerMask() ) return nextSegment; } if( IsNear( position, nextSegment->m_End, max_dist ) ) { - if( Reflayer & nextSegment->ReturnMaskLayer() ) + if( Reflayer & nextSegment->GetLayerMask() ) return nextSegment; } suite: @@ -1310,13 +1311,13 @@ suite: if( IsNear( position, previousSegment->m_Start, max_dist ) ) { - if( Reflayer & previousSegment->ReturnMaskLayer() ) + if( Reflayer & previousSegment->GetLayerMask() ) return previousSegment; } if( IsNear( position, previousSegment->m_End, max_dist ) ) { - if( Reflayer & previousSegment->ReturnMaskLayer() ) + if( Reflayer & previousSegment->GetLayerMask() ) return previousSegment; } suite1: @@ -1352,13 +1353,13 @@ suite1: if( IsNear( position, nextSegment->m_Start, max_dist ) ) { - if( Reflayer & nextSegment->ReturnMaskLayer() ) + if( Reflayer & nextSegment->GetLayerMask() ) return nextSegment; } if( IsNear( position, nextSegment->m_End, max_dist ) ) { - if( Reflayer & nextSegment->ReturnMaskLayer() ) + if( Reflayer & nextSegment->GetLayerMask() ) return nextSegment; } @@ -1373,7 +1374,8 @@ suite1: int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace ) { TRACK* Track, * via, * segm, * TrackListEnd; - int NbEnds, layerMask, ii, ok = 0; + int NbEnds, ii, ok = 0; + LAYER_MSK layerMask; if( aCount <= 1 ) { @@ -1402,12 +1404,12 @@ int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace ) if( Track->Type() == PCB_VIA_T ) continue; - layerMask = Track->ReturnMaskLayer(); + layerMask = Track->GetLayerMask(); via = GetVia( TrackListEnd, Track->m_Start, layerMask ); if( via ) { - layerMask |= via->ReturnMaskLayer(); + layerMask |= via->GetLayerMask(); via->SetState( BUSY, true ); } @@ -1449,12 +1451,12 @@ int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace ) } } - layerMask = Track->ReturnMaskLayer(); + layerMask = Track->GetLayerMask(); via = GetVia( TrackListEnd, Track->m_End, layerMask ); if( via ) { - layerMask |= via->ReturnMaskLayer(); + layerMask |= via->GetLayerMask(); via->SetState( BUSY, true ); } diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 8ac2836061..14d6eac95e 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -68,7 +68,7 @@ class MSG_PANEL_ITEM; * @return A TRACK object pointer if found otherwise NULL. */ extern TRACK* GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, const wxPoint& aPosition, - int aLayerMask ); + LAYER_MSK aLayerMask ); class TRACK : public BOARD_CONNECTED_ITEM @@ -215,12 +215,12 @@ public: bool IsDrillDefault() { return m_Drill <= 0; } /** - * Function ReturnMaskLayer + * Function GetLayerMask * returns a "layer mask", which is a bitmap of all layers on which the * TRACK segment or SEGVIA physically resides. * @return int - a layer mask, see pcbstruct.h's LAYER_BACK, etc. */ - int ReturnMaskLayer() const; + LAYER_MSK GetLayerMask() const; /** * Function IsPointOnEnds @@ -265,10 +265,10 @@ public: * finds the first SEGVIA object at \a aPosition on \a aLayer starting at the trace. * * @param aPosition The wxPoint to HitTest() against. - * @param aLayerMask The layer to match, pass -1 for a don't care. + * @param aLayer The layer to match, pass -1 for a don't care. * @return A pointer to a SEGVIA object if found, else NULL. */ - TRACK* GetVia( const wxPoint& aPosition, int aLayerMask = -1 ); + TRACK* GetVia( const wxPoint& aPosition, int aLayer = -1 ); /** * Function GetVia @@ -280,7 +280,7 @@ public: * @param aLayerMask The layers to match, pass -1 for a don't care. * @return A pointer to a SEGVIA object if found, else NULL. */ - TRACK* GetVia( TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask ); + TRACK* GetVia( TRACK* aEndTrace, const wxPoint& aPosition, LAYER_MSK aLayerMask ); /** * Function GetTrace diff --git a/pcbnew/collectors.h b/pcbnew/collectors.h index cd1f25dcfa..b958b82e98 100644 --- a/pcbnew/collectors.h +++ b/pcbnew/collectors.h @@ -379,10 +379,10 @@ private: int m_PreferredLayer; bool m_IgnorePreferredLayer; - int m_LayerLocked; ///< bit-mapped layer locked bits + LAYER_MSK m_LayerLocked; ///< bit-mapped layer locked bits bool m_IgnoreLockedLayers; - int m_LayerVisible; ///< bit-mapped layer visible bits + LAYER_MSK m_LayerVisible; ///< bit-mapped layer visible bits bool m_IgnoreNonVisibleLayers; bool m_IgnoreLockedItems; @@ -407,11 +407,11 @@ public: * @param aVisibleLayerMask = current visible layers (bit mask) * @param aPreferredLayer = the layer to search first */ - GENERAL_COLLECTORS_GUIDE( int aVisibleLayerMask, int aPreferredLayer ) + GENERAL_COLLECTORS_GUIDE( LAYER_MSK aVisibleLayerMask, int aPreferredLayer ) { m_PreferredLayer = LAYER_N_FRONT; m_IgnorePreferredLayer = false; - m_LayerLocked = 0; + m_LayerLocked = NO_LAYERS; m_LayerVisible = aVisibleLayerMask; m_IgnoreLockedLayers = true; m_IgnoreNonVisibleLayers = true; @@ -443,13 +443,16 @@ public: * Function IsLayerLocked * @return bool - true if the given layer is locked, else false. */ - bool IsLayerLocked( int aLayer ) const { return (1<GetLayerMask() & cp_item->GetTrack()->ReturnMaskLayer()) == 0 ) + if( (pad->GetLayerMask() & cp_item->GetTrack()->GetLayerMask()) == 0 ) continue; if( pad->HitTest( cp_item->GetPoint() ) ) @@ -296,7 +296,7 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack ) int count = 0; m_connected.clear(); - int layerMask = aTrack->ReturnMaskLayer(); + LAYER_MSK layerMask = aTrack->GetLayerMask(); // Search for connections to starting point: #define USE_EXTENDED_SEARCH @@ -318,7 +318,7 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack ) continue; if( m_candidates[ii].GetPoint() != position ) break; - if( (m_candidates[ii].GetTrack()->ReturnMaskLayer() & layerMask ) != 0 ) + if( m_candidates[ii].GetTrack()->GetLayerMask() & layerMask ) m_connected.push_back( m_candidates[ii].GetTrack() ); } // search before: @@ -328,7 +328,7 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack ) continue; if( m_candidates[ii].GetPoint() != position ) break; - if( (m_candidates[ii].GetTrack()->ReturnMaskLayer() & layerMask ) != 0 ) + if( m_candidates[ii].GetTrack()->GetLayerMask() & layerMask ) m_connected.push_back( m_candidates[ii].GetTrack() ); } } @@ -339,7 +339,7 @@ int CONNECTIONS::SearchConnectedTracks( const TRACK * aTrack ) { TRACK * ctrack = tracks_candidates[ii]->GetTrack(); - if( ( ctrack->ReturnMaskLayer() & layerMask ) == 0 ) + if( ( ctrack->GetLayerMask() & layerMask ) == 0 ) continue; if( ctrack == aTrack ) diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index 472f8f5ef3..9b9e7052bb 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -127,7 +127,7 @@ void DIALOG_SVG_PRINT::initDialog() if( m_boxSelectLayer[layer] == NULL ) continue; - long mask = 1 << layer; + LAYER_MSK mask = GetLayerMask( layer ); if( mask & s_SelectedLayers ) m_boxSelectLayer[layer]->SetValue( true ); @@ -235,7 +235,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) SetPenWidth(); // Build layers mask - int printMaskLayer = 0; + LAYER_MSK printMaskLayer = NO_LAYERS; for( int layer = 0; layerGetSelection() != 0 ) // Use current layer only - layers_filter = 1 << m_currentLayer; + layers_filter = GetLayerMask( m_currentLayer ); if( m_DelDrawings->GetValue() ) @@ -111,7 +111,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) for( item = pcb->m_Drawings; item != NULL; item = nextitem ) { nextitem = item->Next(); - bool removeme = (GetLayerMask( item->GetLayer() ) & masque_layer) != 0; + bool removeme = GetLayerMask( item->GetLayer() ) & masque_layer; if( ( item->Type() == PCB_TEXT_T ) && m_DelTexts->GetValue() ) removeme = true; @@ -162,7 +162,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) if( (track->Type() == PCB_VIA_T) && !m_TrackFilterVias->GetValue() ) continue; - if( (track->ReturnMaskLayer() & layers_filter) == 0 ) + if( (track->GetLayerMask() & layers_filter) == 0 ) continue; itemPicker.SetItem( track ); diff --git a/pcbnew/dialogs/dialog_layers_setup.cpp b/pcbnew/dialogs/dialog_layers_setup.cpp index e91369152d..7d7d836410 100644 --- a/pcbnew/dialogs/dialog_layers_setup.cpp +++ b/pcbnew/dialogs/dialog_layers_setup.cpp @@ -76,7 +76,7 @@ private: PCB_EDIT_FRAME* m_Parent; int m_CopperLayerCount; - int m_EnabledLayers; + LAYER_MSK m_EnabledLayers; BOARD* m_Pcb; @@ -90,12 +90,12 @@ private: void showCopperChoice( int copperCount ); void showBoardLayerNames(); - void showSelectedLayerCheckBoxes( int enableLayerMask ); + void showSelectedLayerCheckBoxes( LAYER_MSK enableLayerMask ); void showLayerTypes(); - void showPresets( int enabledLayerMask ); + void showPresets( LAYER_MSK enabledLayerMask ); /** return the selected layer mask within the UI checkboxes */ - int getUILayerMask(); + LAYER_MSK getUILayerMask(); wxString getLayerName( int layer ); int getLayerTypeIndex( int layer ); @@ -171,12 +171,12 @@ public: // Layer bit masks for each defined "Preset Layer Grouping" -static const int presets[] = +static const LAYER_MSK presets[] = { #define FRONT_AUX (SILKSCREEN_LAYER_FRONT | SOLDERMASK_LAYER_FRONT | ADHESIVE_LAYER_FRONT | SOLDERPASTE_LAYER_FRONT) #define BACK_AUX (SILKSCREEN_LAYER_BACK | SOLDERMASK_LAYER_BACK | ADHESIVE_LAYER_BACK | SOLDERPASTE_LAYER_BACK) - 0, // shift the array index up by one, matches with "Custom". + NO_LAYERS, // shift the array index up by one, matches with "Custom". // "Two layers, parts on Front only" EDGE_LAYER | LAYER_FRONT | LAYER_BACK | FRONT_AUX, @@ -348,16 +348,16 @@ void DIALOG_LAYERS_SETUP::showBoardLayerNames() } -void DIALOG_LAYERS_SETUP::showSelectedLayerCheckBoxes( int enabledLayers ) +void DIALOG_LAYERS_SETUP::showSelectedLayerCheckBoxes( LAYER_MSK enabledLayers ) { for( int layer=0; layerGetValue() ) { - layerMaskResult |= (1 << layer); + layerMaskResult |= GetLayerMask( layer ); } } diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 20d8390fe3..b489b89a5b 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -65,7 +65,7 @@ static PAD_ATTR_T CodeType[] = { // Default mask layers setup for pads according to the pad type -static long Std_Pad_Layers[] = { +static const LAYER_MSK Std_Pad_Layers[] = { // PAD_STANDARD: PAD_STANDARD_DEFAULT_LAYERS, @@ -114,7 +114,7 @@ private: * updates the CheckBox states in pad layers list, * @param layer_mask = pad layer mask (ORed layers bit mask) */ - void setPadLayersList( long layer_mask ); + void setPadLayersList( LAYER_MSK layer_mask ); /// Copy values from dialog field to aPad's members bool transferDataToPad( D_PAD* aPad ); @@ -592,13 +592,12 @@ void DIALOG_PAD_PROPERTIES::PadOrientEvent( wxCommandEvent& event ) void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event ) { - long layer_mask; unsigned ii = m_PadType->GetSelection(); if( ii >= NBTYPES ) // catches < 0 also ii = 0; - layer_mask = Std_Pad_Layers[ii]; + LAYER_MSK layer_mask = Std_Pad_Layers[ii]; setPadLayersList( layer_mask ); // Enable/disable drill dialog items: @@ -619,7 +618,7 @@ void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event ) } -void DIALOG_PAD_PROPERTIES::setPadLayersList( long layer_mask ) +void DIALOG_PAD_PROPERTIES::setPadLayersList( LAYER_MSK layer_mask ) { if( ( layer_mask & ALL_CU_LAYERS ) == LAYER_FRONT ) m_rbCopperLayersSel->SetSelection(0); @@ -672,7 +671,7 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK() error_msgs.Add( _( "Incorrect value for pad drill: pad drill bigger than pad size" ) ); } - int padlayers_mask = m_dummyPad->GetLayerMask(); + LAYER_MSK padlayers_mask = m_dummyPad->GetLayerMask(); if( ( padlayers_mask == 0 ) && ( m_dummyPad->GetAttribute() != PAD_HOLE_NOT_PLATED ) ) error_msgs.Add( _( "Error: pad has no layer and is not a mechanical pad" ) ); @@ -851,7 +850,6 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad ) { - long padLayerMask; wxString msg; int x, y; @@ -1038,7 +1036,7 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad ) break; } - padLayerMask = 0; + LAYER_MSK padLayerMask = NO_LAYERS; switch( m_rbCopperLayersSel->GetSelection() ) { diff --git a/pcbnew/dialogs/dialog_pcb_text_properties.cpp b/pcbnew/dialogs/dialog_pcb_text_properties.cpp index a3740b1548..dfcc221af1 100644 --- a/pcbnew/dialogs/dialog_pcb_text_properties.cpp +++ b/pcbnew/dialogs/dialog_pcb_text_properties.cpp @@ -126,11 +126,11 @@ void DIALOG_PCB_TEXT_PROPERTIES::MyInit() PutValueInLocalUnits( *m_PositionXCtrl, m_SelectedPCBText->GetTextPosition().x ); PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->GetTextPosition().y ); - int enabledLayers = m_Parent->GetBoard()->GetEnabledLayers(); + LAYER_MSK enabledLayers = m_Parent->GetBoard()->GetEnabledLayers(); - for( int layer = 0; layer < NB_LAYERS; ++layer ) + for( int layer = 0; layer < NB_LAYERS; ++layer ) { - if( enabledLayers & (1 << layer) ) + if( enabledLayers & GetLayerMask( layer ) ) { layerList.push_back( layer ); int itemIndex = diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp index 111d107391..7d711ae9f1 100644 --- a/pcbnew/dialogs/dialog_print_using_printer.cpp +++ b/pcbnew/dialogs/dialog_print_using_printer.cpp @@ -282,7 +282,7 @@ int DIALOG_PRINT_USING_PRINTER::SetLayerMaskFromListSelection() int page_count; int layers_count = NB_LAYERS; - s_Parameters.m_PrintMaskLayer = 0; + s_Parameters.m_PrintMaskLayer = NO_LAYERS; int ii; for( ii = 0, page_count = 0; ii < layers_count; ii++ ) { @@ -291,7 +291,7 @@ int DIALOG_PRINT_USING_PRINTER::SetLayerMaskFromListSelection() if( m_BoxSelectLayer[ii]->IsChecked() ) { page_count++; - s_Parameters.m_PrintMaskLayer |= 1 << ii; + s_Parameters.m_PrintMaskLayer |= GetLayerMask( ii ); } } diff --git a/pcbnew/drag.h b/pcbnew/drag.h index bc4e216c4f..beb87b62c5 100644 --- a/pcbnew/drag.h +++ b/pcbnew/drag.h @@ -183,7 +183,7 @@ void EraseDragList(); * @param aNetCode = the net code to consider * @param aMaxDist = max distance from aRefPos to a track end candidate to collect the track */ -void Collect_TrackSegmentsToDrag( BOARD* aPcb, const wxPoint& aRefPos, int aLayerMask, +void Collect_TrackSegmentsToDrag( BOARD* aPcb, const wxPoint& aRefPos, LAYER_MSK aLayerMask, int aNetCode, int aMaxDist ); /* Add aTrack to the drag list diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp index c23c8fe5da..abe8a8344b 100644 --- a/pcbnew/dragsegm.cpp +++ b/pcbnew/dragsegm.cpp @@ -334,7 +334,7 @@ void AddSegmentToDragList( int flag, TRACK* aTrack ) } -void Collect_TrackSegmentsToDrag( BOARD* aPcb, const wxPoint& aRefPos, int aLayerMask, +void Collect_TrackSegmentsToDrag( BOARD* aPcb, const wxPoint& aRefPos, LAYER_MSK aLayerMask, int aNetCode, int aMaxDist ) { TRACK* track = aPcb->m_Track->GetStartNetCode( aNetCode ); @@ -344,7 +344,7 @@ void Collect_TrackSegmentsToDrag( BOARD* aPcb, const wxPoint& aRefPos, int aLaye if( track->GetNet() != aNetCode ) // not the same netcodenet code: all candidates tested break; - if( ( aLayerMask & track->ReturnMaskLayer() ) == 0 ) + if( ( aLayerMask & track->GetLayerMask() ) == 0 ) continue; // Cannot be connected, not on the same layer if( track->IsDragging() ) @@ -393,7 +393,7 @@ void Collect_TrackSegmentsToDrag( BOARD* aPcb, const wxPoint& aRefPos, int aLaye // If a connected via is found at location aRefPos, // collect also tracks connected by this via. if( track->Type() == PCB_VIA_T ) - Collect_TrackSegmentsToDrag( aPcb, aRefPos, track->ReturnMaskLayer(), + Collect_TrackSegmentsToDrag( aPcb, aRefPos, track->GetLayerMask(), aNetCode, track->GetWidth() / 2 ); } } diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index 67d1194022..bd08a55e20 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -663,7 +663,7 @@ bool DRC::doTrackKeepoutDrc( TRACK* aRefSeg ) bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_limit ) { - int layerMask = aRefPad->GetLayerMask() & ALL_CU_LAYERS; + LAYER_MSK layerMask = aRefPad->GetLayerMask() & ALL_CU_LAYERS; /* used to test DRC pad to holes: this dummy pad has the size and shape of the hole * to test pad to pad hole DRC, using the pad to pad DRC test function. diff --git a/pcbnew/drc_clearance_test_functions.cpp b/pcbnew/drc_clearance_test_functions.cpp index 804e33dca5..5df8dcfe95 100644 --- a/pcbnew/drc_clearance_test_functions.cpp +++ b/pcbnew/drc_clearance_test_functions.cpp @@ -150,7 +150,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) { TRACK* track; wxPoint delta; // lenght on X and Y axis of segments - int layerMask; + LAYER_MSK layerMask; int net_code_ref; wxPoint shape_pos; @@ -164,7 +164,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) m_segmEnd = delta = aRefSeg->GetEnd() - origin; m_segmAngle = 0; - layerMask = aRefSeg->ReturnMaskLayer(); + layerMask = aRefSeg->GetLayerMask(); net_code_ref = aRefSeg->GetNet(); // Phase 0 : Test vias @@ -343,7 +343,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) continue; // No problem if segment are on different layers : - if( ( layerMask & track->ReturnMaskLayer() ) == 0 ) + if( ( layerMask & track->GetLayerMask() ) == 0 ) continue; // the minimum distance = clearance plus half the reference track diff --git a/pcbnew/eagle_plugin.h b/pcbnew/eagle_plugin.h index 373cca6671..a84b2af6bd 100644 --- a/pcbnew/eagle_plugin.h +++ b/pcbnew/eagle_plugin.h @@ -27,6 +27,7 @@ */ #include +#include // forward declaration on ptree template so we can confine use of big boost diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 97888d433f..7064aceac4 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -99,7 +99,7 @@ static void Abort_Create_Track( EDA_DRAW_PANEL* Panel, wxDC* DC ) TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) { TRACK* TrackOnStartPoint = NULL; - int layerMask = GetLayerMask( GetScreen()->m_Active_Layer ); + LAYER_MSK layerMask = GetLayerMask( GetScreen()->m_Active_Layer ); BOARD_CONNECTED_ITEM* LockPoint; wxPoint pos = GetScreen()->GetCrossHairPosition(); @@ -411,7 +411,7 @@ bool PCB_EDIT_FRAME::Add45DegreeSegment( wxDC* aDC ) bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC ) { - int layerMask = GetLayerMask( GetScreen()->m_Active_Layer ); + LAYER_MSK layerMask = GetLayerMask( GetScreen()->m_Active_Layer ); if( aTrack == NULL ) return false; diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index 780c3857ec..06001dcdd7 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -231,8 +231,8 @@ static int ViaSort( const void* aRefptr, const void* aObjptr ) if( padref->GetDrillValue() != padcmp->GetDrillValue() ) return padref->GetDrillValue() - padcmp->GetDrillValue(); - if( padref->ReturnMaskLayer() != padcmp->ReturnMaskLayer() ) - return padref->ReturnMaskLayer() - padcmp->ReturnMaskLayer(); + if( padref->GetLayerMask() != padcmp->GetLayerMask() ) + return padref->GetLayerMask() - padcmp->GetLayerMask(); return 0; } @@ -258,7 +258,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb ) padstacks.resize( 1 ); // We count pads from 1 // The master layermask (i.e. the enabled layers) for padstack generation - unsigned master_layermask = aPcb->GetDesignSettings().GetEnabledLayers(); + LAYER_MSK master_layermask = aPcb->GetDesignSettings().GetEnabledLayers(); fputs( "$PADS\n", aFile ); @@ -293,7 +293,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb ) viastacks.push_back( via ); fprintf( aFile, "PAD V%d.%d.%X ROUND %g\nCIRCLE 0 0 %g\n", via->GetWidth(), via->GetDrillValue(), - via->ReturnMaskLayer(), + via->GetLayerMask(), via->GetDrillValue() / SCALE_FACTOR, via->GetWidth() / (SCALE_FACTOR * 2) ); } @@ -434,14 +434,14 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb ) for( unsigned i = 0; i < viastacks.size(); i++ ) { TRACK* via = viastacks[i]; - unsigned mask = via->ReturnMaskLayer() & master_layermask; + LAYER_MSK mask = via->GetLayerMask() & master_layermask; fprintf( aFile, "PADSTACK VIA%d.%d.%X %g\n", via->GetWidth(), via->GetDrillValue(), mask, via->GetDrillValue() / SCALE_FACTOR ); for( int layer = 0; layer < 32; layer++ ) { - if( mask & (1 << layer) ) + if( mask & GetLayerMask( layer ) ) { fprintf( aFile, "PAD V%d.%d.%X %s 0 0\n", via->GetWidth(), via->GetDrillValue(), @@ -465,7 +465,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb ) pad->GetDrillSize().x / SCALE_FACTOR ); for( int layer = 0; layer < 32; layer++ ) { - if( pad->GetLayerMask() & (1 << layer) & master_layermask ) + if( pad->GetLayerMask() & GetLayerMask( layer ) & master_layermask ) { fprintf( aFile, "PAD P%d %s 0 0\n", i, TO_UTF8( GenCADLayerName[layer] ) ); @@ -477,7 +477,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb ) pad->GetDrillSize().x / SCALE_FACTOR ); for( int layer = 0; layer < 32; layer++ ) { - if( pad->GetLayerMask() & (1 << layer) & master_layermask ) + if( pad->GetLayerMask() & GetLayerMask( layer ) & master_layermask ) { fprintf( aFile, "PAD P%d %s 0 0\n", i, TO_UTF8( GenCADLayerNameFlipped[layer] ) ); @@ -760,7 +760,7 @@ static void CreateRoutesSection( FILE* aFile, BOARD* aPcb ) int vianum = 1; int old_netcode, old_width, old_layer; int nbitems, ii; - unsigned master_layermask = aPcb->GetDesignSettings().GetEnabledLayers(); + LAYER_MSK master_layermask = aPcb->GetDesignSettings().GetEnabledLayers(); // Count items nbitems = 0; @@ -836,7 +836,7 @@ static void CreateRoutesSection( FILE* aFile, BOARD* aPcb ) { fprintf( aFile, "VIA VIA%d.%d.%X %g %g ALL %g via%d\n", track->GetWidth(), track->GetDrillValue(), - track->ReturnMaskLayer() & master_layermask, + track->GetLayerMask() & master_layermask, MapXTo( track->GetStart().x ), MapYTo( track->GetStart().y ), track->GetDrillValue() / SCALE_FACTOR, vianum++ ); } diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp index b9ec9ff37b..b1706d069a 100644 --- a/pcbnew/export_vrml.cpp +++ b/pcbnew/export_vrml.cpp @@ -918,7 +918,7 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* aPad ) //{{{ } // The pad proper, on the selected layers - int layer_mask = aPad->GetLayerMask(); + LAYER_MSK layer_mask = aPad->GetLayerMask(); int copper_layers = pcb->GetCopperLayerCount( ); // The (maybe offseted) pad position @@ -939,7 +939,7 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* aPad ) //{{{ if( (layer > FIRST_COPPER_LAYER) && (layer == copper_layers - 1) ) layer = LAST_COPPER_LAYER; - if( layer_mask & (1 << layer) ) + if( layer_mask & GetLayerMask( layer ) ) { // OK, the pad is on this layer, export it switch( aPad->GetShape() ) diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 2411ba9c54..a047e644fa 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -425,7 +425,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const m_out->Print( aNestLevel, "(layers\n" ); unsigned mask = LAYER_FRONT; - unsigned layer = LAYER_N_FRONT; + int layer = LAYER_N_FRONT; // Save only the used copper layers from front to back. while( mask != 0 ) @@ -980,12 +980,12 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const } -void PCB_IO::formatLayers( int aLayerMask, int aNestLevel ) const +void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const throw( IO_ERROR ) { m_out->Print( aNestLevel, "(layers" ); - int cuMask = ALL_CU_LAYERS; + LAYER_MSK cuMask = ALL_CU_LAYERS; if( m_board ) cuMask &= m_board->GetEnabledLayers(); diff --git a/pcbnew/kicad_plugin.h b/pcbnew/kicad_plugin.h index 0a1076f003..aa2b297ad4 100644 --- a/pcbnew/kicad_plugin.h +++ b/pcbnew/kicad_plugin.h @@ -26,6 +26,7 @@ #include #include +#include class BOARD; class BOARD_ITEM; @@ -189,7 +190,7 @@ private: void formatLayer( const BOARD_ITEM* aItem ) const; - void formatLayers( int aLayerMask, int aNestLevel = 0 ) const + void formatLayers( LAYER_MSK aLayerMask, int aNestLevel = 0 ) const throw( IO_ERROR ); /// we only cache one footprint library for now, this determines which one. diff --git a/pcbnew/layer_widget.h b/pcbnew/layer_widget.h index 39d55d17ad..a39fe8644b 100644 --- a/pcbnew/layer_widget.h +++ b/pcbnew/layer_widget.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #define LYR_COLUMN_COUNT 4 ///< Layer tab column count diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 8798236902..fa681a52c0 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -409,7 +409,7 @@ void LEGACY_PLUGIN::loadGENERAL() else if( TESTLINE( "EnabledLayers" ) ) { - int enabledLayers = hexParse( line + SZ( "EnabledLayers" ) ); + LAYER_MSK enabledLayers = hexParse( line + SZ( "EnabledLayers" ) ); // layer usage m_board->SetEnabledLayers( enabledLayers ); @@ -420,7 +420,7 @@ void LEGACY_PLUGIN::loadGENERAL() else if( TESTLINE( "VisibleLayers" ) ) { - int visibleLayers = hexParse( line + SZ( "VisibleLayers" ) ); + LAYER_MSK visibleLayers = hexParse( line + SZ( "VisibleLayers" ) ); m_board->SetVisibleLayers( visibleLayers ); } @@ -1239,7 +1239,6 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) // sscanf( PtLine, "%s %s %X", BufLine, BufCar, &m_layerMask ); PAD_ATTR_T attribute; - int layer_mask; data = strtok( line + SZ( "At" ), delims ); @@ -1255,7 +1254,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) data = strtok( NULL, delims ); // skip BufCar data = strtok( NULL, delims ); - layer_mask = hexParse( data ); + LAYER_MSK layer_mask = hexParse( data ); pad->SetLayerMask( layer_mask ); pad->SetAttribute( attribute ); diff --git a/pcbnew/magnetic_tracks_functions.cpp b/pcbnew/magnetic_tracks_functions.cpp index f365647597..4edb3d416c 100644 --- a/pcbnew/magnetic_tracks_functions.cpp +++ b/pcbnew/magnetic_tracks_functions.cpp @@ -157,7 +157,7 @@ bool Magnetize( PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize aGridSize, if( doPad ) { - int layer_mask = GetLayerMask( screen->m_Active_Layer ); + LAYER_MSK layer_mask = GetLayerMask( screen->m_Active_Layer ); D_PAD* pad = m_Pcb->GetPad( pos, layer_mask ); if( pad ) @@ -192,7 +192,7 @@ bool Magnetize( PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize aGridSize, if( !currTrack ) { - int layer_mask = GetLayerMask( layer ); + LAYER_MSK layer_mask = GetLayerMask( layer ); TRACK* track = m_Pcb->GetTrace( m_Pcb->m_Track, pos, layer_mask ); diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index da3166e3ed..870d988e4c 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -154,7 +154,7 @@ public: * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) * @param aData = a pointer on an auxiliary data (NULL if not used) */ - virtual void PrintPage( wxDC* aDC, int aPrintMaskLayer, bool aPrintMirrorMode, + virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMaskLayer, bool aPrintMirrorMode, void * aData = NULL); // BOARD handling diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 394ed2bc0f..3e89a847b4 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -629,7 +629,7 @@ void PCB_EDIT_FRAME::StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aC if( aCommand != ID_POPUP_PCB_MOVE_TRACK_SEGMENT ) { Collect_TrackSegmentsToDrag( GetBoard(), aTrack->GetStart(), - aTrack->ReturnMaskLayer(), + aTrack->GetLayerMask(), aTrack->GetNet(), aTrack->GetWidth() / 2 ); } @@ -649,17 +649,17 @@ void PCB_EDIT_FRAME::StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aC case ID_POPUP_PCB_DRAG_TRACK_SEGMENT: // drag a segment pos = aTrack->GetStart(); - Collect_TrackSegmentsToDrag( GetBoard(), pos, aTrack->ReturnMaskLayer(), + Collect_TrackSegmentsToDrag( GetBoard(), pos, aTrack->GetLayerMask(), aTrack->GetNet(), aTrack->GetWidth() / 2 ); pos = aTrack->GetEnd(); aTrack->SetFlags( IS_DRAGGED | ENDPOINT | STARTPOINT ); - Collect_TrackSegmentsToDrag( GetBoard(), pos, aTrack->ReturnMaskLayer(), + Collect_TrackSegmentsToDrag( GetBoard(), pos, aTrack->GetLayerMask(), aTrack->GetNet(), aTrack->GetWidth() / 2 ); break; case ID_POPUP_PCB_MOVE_TRACK_NODE: // Drag via or move node pos = (diag & STARTPOINT) ? aTrack->GetStart() : aTrack->GetEnd(); - Collect_TrackSegmentsToDrag( GetBoard(), pos, aTrack->ReturnMaskLayer(), + Collect_TrackSegmentsToDrag( GetBoard(), pos, aTrack->GetLayerMask(), aTrack->GetNet(), aTrack->GetWidth() / 2 ); PosInit = pos; break; @@ -865,7 +865,7 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) /* Test the connections modified by the move * (only pad connection must be tested, track connection will be * tested by TestNetConnection() ) */ - int layerMask = GetLayerMask( Track->GetLayer() ); + LAYER_MSK layerMask = GetLayerMask( Track->GetLayer() ); Track->start = GetBoard()->GetPadFast( Track->GetStart(), layerMask ); if( Track->start ) diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h b/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h index 2cbc11c53f..9d49ea3a3c 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h @@ -31,6 +31,7 @@ #define PCB_CALLBACKS_H_ #include +#include "include/layers_id_colors_and_visibility.h" enum LAYER_TYPE_T { diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index d11833c600..8f45cec82a 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -66,7 +66,7 @@ void PCB_PARSER::init() std::string untranslated = TO_UTF8( BOARD::GetStandardLayerName( layerNdx ) ); m_layerIndices[ untranslated ] = layerNdx; - m_layerMasks[ untranslated ] = 1 << layerNdx; + m_layerMasks[ untranslated ] = GetLayerMask( layerNdx ); } m_layerMasks[ "*.Cu" ] = ALL_CU_LAYERS; @@ -667,8 +667,8 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR ) std::string type; int layerIndex; bool isVisible = true; - int visibleLayers = 0; - int enabledLayers = 0; + LAYER_MSK visibleLayers = NO_LAYERS; + LAYER_MSK enabledLayers = NO_LAYERS; int copperLayerCount = 0; for( token = NextTok(); token != T_RIGHT; token = NextTok() ) @@ -700,13 +700,13 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR ) Expecting( "hide or )" ); } - enabledLayers |= 1 << layerIndex; + enabledLayers |= GetLayerMask( layerIndex ); if( isVisible ) - visibleLayers |= 1 << layerIndex; + visibleLayers |= GetLayerMask( layerIndex ); m_layerIndices[ name ] = layerIndex; - m_layerMasks[ name ] = 1 << layerIndex; + m_layerMasks[ name ] = GetLayerMask(layerIndex); wxString wname = FROM_UTF8( name.c_str() ); enum LAYER_T layerType = LAYER::ParseType( type.c_str() ); @@ -736,10 +736,11 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR ) } -int PCB_PARSER::lookUpLayer( const LAYER_MAP& aMap ) throw( PARSE_ERROR, IO_ERROR ) +template +T PCB_PARSER::lookUpLayer( const M& aMap ) throw( PARSE_ERROR, IO_ERROR ) { // avoid constructing another std::string, use lexer's directly - LAYER_MAP::const_iterator it = aMap.find( curText ); + typename M::const_iterator it = aMap.find( curText ); if( it == aMap.end() ) { @@ -747,7 +748,7 @@ int PCB_PARSER::lookUpLayer( const LAYER_MAP& aMap ) throw( PARSE_ERROR, IO_ERRO // dump the whole darn table, there's something wrong with it. for( it = aMap.begin(); it != aMap.end(); ++it ) { - printf( &aMap == &m_layerIndices ? "lm[%s] = %d\n" : "lm[%s] = %08X\n", + printf( &aMap == (void*)&m_layerIndices ? "lm[%s] = %d\n" : "lm[%s] = %08X\n", it->first.c_str(), it->second ); } #endif @@ -771,7 +772,7 @@ int PCB_PARSER::parseBoardItemLayer() throw( PARSE_ERROR, IO_ERROR ) NextTok(); - int layerIndex = lookUpLayer( m_layerIndices ); + int layerIndex = lookUpLayer( m_layerIndices ); // Handle closing ) in object parser. @@ -779,17 +780,17 @@ int PCB_PARSER::parseBoardItemLayer() throw( PARSE_ERROR, IO_ERROR ) } -int PCB_PARSER::parseBoardItemLayersAsMask() throw( PARSE_ERROR, IO_ERROR ) +LAYER_MSK PCB_PARSER::parseBoardItemLayersAsMask() throw( PARSE_ERROR, IO_ERROR ) { - wxCHECK_MSG( CurTok() == T_layers, 0, + wxCHECK_MSG( CurTok() == T_layers, NO_LAYERS, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as item layer mask." ) ); - int layerMask = 0; + LAYER_MSK layerMask = NO_LAYERS; for( T token = NextTok(); token != T_RIGHT; token = NextTok() ) { - int mask = lookUpLayer( m_layerMasks ); + LAYER_MSK mask = lookUpLayer( m_layerMasks ); layerMask |= mask; } @@ -2152,7 +2153,7 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR ) case T_layers: { - int layerMask = parseBoardItemLayersAsMask(); + LAYER_MSK layerMask = parseBoardItemLayersAsMask(); pad->SetLayerMask( layerMask ); } break; @@ -2324,9 +2325,9 @@ SEGVIA* PCB_PARSER::parseSEGVIA() throw( IO_ERROR, PARSE_ERROR ) { int layer1, layer2; NextTok(); - layer1 = lookUpLayer( m_layerIndices ); + layer1 = lookUpLayer( m_layerIndices ); NextTok(); - layer2 = lookUpLayer( m_layerIndices ); + layer2 = lookUpLayer( m_layerIndices ); via->SetLayerPair( layer1, layer2 ); NeedRIGHT(); } diff --git a/pcbnew/pcb_parser.h b/pcbnew/pcb_parser.h index 78071fdfac..e1f89e839e 100644 --- a/pcbnew/pcb_parser.h +++ b/pcbnew/pcb_parser.h @@ -58,11 +58,12 @@ class FPL_CACHE; */ class PCB_PARSER : public PCB_LEXER { - typedef KEYWORD_MAP LAYER_MAP; + typedef boost::unordered_map< std::string, int > LAYER_NUM_MAP; + typedef boost::unordered_map< std::string, LAYER_MSK > LAYER_MSK_MAP; BOARD* m_board; - LAYER_MAP m_layerIndices; ///< map layer name to it's index - LAYER_MAP m_layerMasks; ///< map layer names to their masks + LAYER_NUM_MAP m_layerIndices; ///< map layer name to it's index + LAYER_MSK_MAP m_layerMasks; ///< map layer names to their masks /** @@ -99,13 +100,14 @@ class PCB_PARSER : public PCB_LEXER * Function lookUpLayer * parses the current token for the layer definition of a #BOARD_ITEM object. * - * @param aMap is the LAYER_MAP to use for the lookup. + * @param aMap is the LAYER_{NUM|MSK}_MAP to use for the lookup. * * @throw IO_ERROR if the layer is not valid. * @throw PARSE_ERROR if the layer syntax is incorrect. * @return int - The result of the parsed #BOARD_ITEM layer or set designator. */ - int lookUpLayer( const LAYER_MAP& aMap ) throw( PARSE_ERROR, IO_ERROR ); + template + T lookUpLayer( const M& aMap ) throw( PARSE_ERROR, IO_ERROR ); /** * Function parseBoardItemLayer @@ -125,7 +127,7 @@ class PCB_PARSER : public PCB_LEXER * @throw PARSE_ERROR if the layers syntax is incorrect. * @return The mask of layers the parsed #BOARD_ITEM is on. */ - int parseBoardItemLayersAsMask() throw( PARSE_ERROR, IO_ERROR ); + LAYER_MSK parseBoardItemLayersAsMask() throw( PARSE_ERROR, IO_ERROR ); /** * Function parseXY diff --git a/pcbnew/pcb_plot_params.h b/pcbnew/pcb_plot_params.h index 77d5890788..737032bbbb 100644 --- a/pcbnew/pcb_plot_params.h +++ b/pcbnew/pcb_plot_params.h @@ -27,6 +27,7 @@ #include #include // EDA_DRAW_MODE_T #include +#include class PCB_PLOT_PARAMS; class LINE_READER; @@ -115,7 +116,7 @@ private: bool m_excludeEdgeLayer; /// Set of layers to plot - long m_layerSelection; + LAYER_MSK m_layerSelection; /** When plotting gerbers use a conventional set of extensions instead of * appending a suffix to the board name */ diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index 0cbe3b0694..aeeb6a9a61 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -9,6 +9,7 @@ #include // wxWidgets include. #include // IS_DRAGGED and IN_EDIT definitions. #include // to define DMils2iu() conversion function +#include // Arcs are approximated by segments: define the number of segments per 360 deg (KiCad uses 0.1 // deg approximation). Be aware 3600 / ARC_APPROX_SEGMENTS_COUNT_LOW_DEF is an integer. diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index 5e374cf8e4..503e44f31e 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -255,11 +255,9 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) // Save the current plot options in the board m_parent->SetPlotSettings( m_plotOpts ); - long layerMask = 1; - - for( layer = 0; layer < NB_LAYERS; layer++, layerMask <<= 1 ) + for( layer = 0; layer < NB_LAYERS; ++layer ) { - if( m_plotOpts.GetLayerSelection() & layerMask ) + if( m_plotOpts.GetLayerSelection() & GetLayerMask( layer ) ) { // Pick the basename from the board file wxFileName fn( boardFilename ); diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h index 0c89c03bf0..a4e71ee323 100644 --- a/pcbnew/pcbplot.h +++ b/pcbnew/pcbplot.h @@ -32,6 +32,7 @@ #include #include #include +#include class PLOTTER; class TEXTE_PCB; @@ -199,7 +200,7 @@ void PlotOneBoardLayer( BOARD* aBoard, PLOTTER* aPlotter, int aLayer, * SetDrillMarksType( DrillMarksType aVal ) controle the actual hole: * no hole, small hole, actual hole */ -void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, long aLayerMask, +void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LAYER_MSK aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt ); /** @@ -211,7 +212,7 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, long aLayerMask, * @param aLayerMask = the mask to define the layers to plot (silkscreen Front and/or Back) * @param aPlotOpt = the plot options (files, sketch). Has meaning for some formats only */ -void PlotSilkScreen( BOARD* aBoard, PLOTTER* aPlotter, long aLayerMask, +void PlotSilkScreen( BOARD* aBoard, PLOTTER* aPlotter, LAYER_MSK aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt ); diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index ae54ca70c0..8e9ec9ad72 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -67,7 +67,7 @@ static void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, * Silkscreen layers have specific requirement for pads (not filled) and texts * (with option to remove them from some copper areas (pads...) */ -void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask, +void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, LAYER_MSK aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt ) { BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt ); @@ -93,7 +93,7 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask, for( D_PAD * pad = Module->Pads(); pad != NULL; pad = pad->Next() ) { // See if the pad is on this layer - int masklayer = pad->GetLayerMask(); + LAYER_MSK masklayer = pad->GetLayerMask(); if( (masklayer & layersmask_plotpads) == 0 ) continue; @@ -124,7 +124,7 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask, { ZONE_CONTAINER* edge_zone = aBoard->GetArea( ii ); - if( ( ( 1 << edge_zone->GetLayer() ) & aLayerMask ) == 0 ) + if( ( GetLayerMask( edge_zone->GetLayer() ) & aLayerMask ) == 0 ) continue; itemplotter.PlotFilledAreas( edge_zone ); @@ -134,7 +134,7 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask, // compatibility): for( SEGZONE* seg = aBoard->m_Zone; seg != NULL; seg = seg->Next() ) { - if( ( ( 1 << seg->GetLayer() ) & aLayerMask ) == 0 ) + if( ( GetLayerMask( seg->GetLayer() ) & aLayerMask ) == 0 ) continue; aPlotter->ThickSegment( seg->GetStart(), seg->GetEnd(), seg->GetWidth(), @@ -154,7 +154,7 @@ void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, int aLayer, // Specify that the contents of the "Edges Pcb" layer are to be plotted // in addition to the contents of the currently specified layer. - int layer_mask = GetLayerMask( aLayer ); + LAYER_MSK layer_mask = GetLayerMask( aLayer ); if( !aPlotOpt.GetExcludeEdgeLayer() ) layer_mask |= EDGE_LAYER; @@ -240,7 +240,7 @@ void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, int aLayer, * Silk screen layers are not plotted here. */ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, - long aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt ) + LAYER_MSK aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt ) { BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt ); @@ -367,7 +367,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, // vias are not plotted if not on selected layer, but if layer // is SOLDERMASK_LAYER_BACK or SOLDERMASK_LAYER_FRONT,vias are drawn, // only if they are on the corresponding external copper layer - int via_mask_layer = Via->ReturnMaskLayer(); + int via_mask_layer = Via->GetLayerMask(); if( aPlotOpt.GetPlotViaOnMaskLayer() ) { @@ -435,7 +435,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, { ZONE_CONTAINER* zone = aBoard->GetArea( ii ); - if( ( ( 1 << zone->GetLayer() ) & aLayerMask ) == 0 ) + if( ( GetLayerMask(zone->GetLayer() ) & aLayerMask ) == 0 ) continue; itemplotter.PlotFilledAreas( zone ); @@ -580,7 +580,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, // vias are plotted only if they are on the corresponding // external copper layer - int via_mask_layer = via->ReturnMaskLayer(); + LAYER_MSK via_mask_layer = via->GetLayerMask(); if( via_mask_layer & LAYER_BACK ) via_mask_layer |= SOLDERMASK_LAYER_BACK; diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index d2d9091a9d..a549acde42 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -112,7 +112,7 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule ) if( textLayer >= LAYER_COUNT ) return false; - if( ( ( 1 << textLayer ) & m_layerMask ) == 0 ) + if( ( GetLayerMask( textLayer ) & m_layerMask ) == 0 ) trace_ref = false; if( !textModule->IsVisible() && !GetPlotInvisibleText() ) @@ -124,7 +124,7 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule ) if( textLayer > LAYER_COUNT ) return false; - if( ( (1 << textLayer) & m_layerMask ) == 0 ) + if( ( GetLayerMask( textLayer ) & m_layerMask ) == 0 ) trace_val = false; if( !textModule->IsVisible() && !GetPlotInvisibleText() ) @@ -164,7 +164,7 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule ) if( textLayer >= LAYER_COUNT ) return false; - if( !( ( 1 << textLayer ) & m_layerMask ) ) + if( !( GetLayerMask( textLayer ) & m_layerMask ) ) continue; PlotTextModule( textModule, getColor( textLayer ) ); diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index 8c27dbba4b..09c4a3f9d0 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -45,11 +45,11 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, - GR_DRAWMODE aDraw_mode, int aMasklayer, + GR_DRAWMODE aDraw_mode, LAYER_MSK aMasklayer, PRINT_PARAMETERS::DrillShapeOptT aDrillShapeOpt ); void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC, - int aPrintMaskLayer, + LAYER_MSK aPrintMaskLayer, bool aPrintMirrorMode, void * aData) { @@ -131,7 +131,7 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC, * @param aData = a pointer to an optional data (NULL if not used) */ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, - int aPrintMaskLayer, + LAYER_MSK aPrintMaskLayer, bool aPrintMirrorMode, void* aData) { @@ -176,7 +176,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, for(int kk = 0; kk < 32; kk ++ ) { - if( ((1 << kk) & aPrintMaskLayer) != 0 ) + if( GetLayerMask( kk ) & aPrintMaskLayer ) { GetScreen()->m_Active_Layer = kk; break; @@ -232,10 +232,8 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, case PCB_DIMENSION_T: case PCB_TEXT_T: case PCB_TARGET_T: - if( ( ( 1 << item->GetLayer() ) & aPrintMaskLayer ) == 0 ) - break; - - item->Draw( m_canvas, aDC, drawmode ); + if( GetLayerMask( item->GetLayer() ) & aPrintMaskLayer ) + item->Draw( m_canvas, aDC, drawmode ); break; case PCB_MARKER_T: @@ -247,7 +245,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, // Print tracks for( TRACK * track = Pcb->m_Track; track; track = track->Next() ) { - if( ( aPrintMaskLayer & track->ReturnMaskLayer() ) == 0 ) + if( !( aPrintMaskLayer & track->GetLayerMask() ) ) continue; if( track->Type() == PCB_VIA_T ) // VIA encountered. @@ -270,7 +268,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, // Outdated: only for compatibility to old boards for( TRACK * track = Pcb->m_Zone; track != NULL; track = track->Next() ) { - if( ( aPrintMaskLayer & track->ReturnMaskLayer() ) == 0 ) + if( !( aPrintMaskLayer & track->GetLayerMask() ) ) continue; track->Draw( m_canvas, aDC, drawmode ); @@ -281,9 +279,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, { ZONE_CONTAINER* zone = Pcb->GetArea( ii ); - if( ( aPrintMaskLayer & ( 1 << zone->GetLayer() ) ) == 0 ) - continue; - + if( aPrintMaskLayer & GetLayerMask( zone->GetLayer() ) ) zone->DrawFilledArea( m_canvas, aDC, drawmode ); } @@ -312,7 +308,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, for( ; track != NULL; track = track->Next() ) { - if( ( aPrintMaskLayer & track->ReturnMaskLayer() ) == 0 ) + if( !( aPrintMaskLayer & track->GetLayerMask() ) ) continue; if( track->Type() == PCB_VIA_T ) // VIA encountered. @@ -350,13 +346,13 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, - GR_DRAWMODE aDraw_mode, int aMasklayer, + GR_DRAWMODE aDraw_mode, LAYER_MSK aMasklayer, PRINT_PARAMETERS::DrillShapeOptT aDrillShapeOpt ) { // Print pads for( D_PAD* pad = aModule->Pads(); pad; pad = pad->Next() ) { - if( (pad->GetLayerMask() & aMasklayer ) == 0 ) + if( !(pad->GetLayerMask() & aMasklayer ) ) continue; // Manage hole according to the print drill option @@ -387,7 +383,7 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, } // Print footprint graphic shapes - int mlayer = GetLayerMask( aModule->GetLayer() ); + LAYER_MSK mlayer = GetLayerMask( aModule->GetLayer() ); if( aModule->GetLayer() == LAYER_N_BACK ) mlayer = SILKSCREEN_LAYER_BACK; diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index f3c040be05..74fd538310 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -95,7 +95,7 @@ bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage ) int layers_count = LAYER_COUNT; #endif - int mask_layer = m_PrintParams.m_PrintMaskLayer; + LAYER_MSK mask_layer = m_PrintParams.m_PrintMaskLayer; // compute layer mask from page number if we want one page per layer if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer diff --git a/pcbnew/printout_controler.h b/pcbnew/printout_controler.h index e7a2f1a1dd..a31ccad559 100644 --- a/pcbnew/printout_controler.h +++ b/pcbnew/printout_controler.h @@ -33,7 +33,7 @@ #include - +#include #define DEFAULT_ORIENTATION_PAPER wxLANDSCAPE // other option is wxPORTRAIT @@ -51,7 +51,7 @@ public: double m_XScaleAdjust; // fine scale adjust for X axis double m_YScaleAdjust; // fine scale adjust for Y axis bool m_Print_Sheet_Ref; // Option: print page references - long m_PrintMaskLayer; // Layers to print + LAYER_MSK m_PrintMaskLayer; // Layers to print bool m_PrintMirror; // Option: Print mirrored bool m_Print_Black_and_White; // Option: Print in B&W or Color int m_OptionPrintPage; // Option: 0 = a layer per page, 1 = all layers at once diff --git a/pcbnew/protos.h b/pcbnew/protos.h index 7a76739260..0ae8f2e77b 100644 --- a/pcbnew/protos.h +++ b/pcbnew/protos.h @@ -56,7 +56,7 @@ void DrawTraces( EDA_DRAW_PANEL* panel, * calculates the mask layer when flipping a footprint. * BACK and FRONT copper layers , mask, paste, solder layers are swapped. */ -int ChangeSideMaskLayer( int aMask ); +LAYER_MSK ChangeSideMaskLayer( LAYER_MSK aMask ); void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module ); diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index 990e56424f..d1e739ebe9 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -107,8 +107,8 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( PCB_BASE_FRAME* parent, /* Build the layer list */ LayerCount = 0; - int Masque_Layer = g_TabAllCopperLayerMask[board->GetCopperLayerCount() - 1]; - Masque_Layer += ALL_NO_CU_LAYERS; + LAYER_MSK Masque_Layer = g_TabAllCopperLayerMask[board->GetCopperLayerCount() - 1]; + Masque_Layer |= ALL_NO_CU_LAYERS; for( ii = 0; ii < NB_LAYERS; ii++ ) { @@ -262,8 +262,8 @@ SELECT_LAYERS_PAIR_DIALOG::SELECT_LAYERS_PAIR_DIALOG( PCB_BASE_FRAME* parent ) : m_Parent = parent; PCB_SCREEN* screen = (PCB_SCREEN*) m_Parent->GetScreen(); - int Masque_Layer = g_TabAllCopperLayerMask[board->GetCopperLayerCount() - 1]; - Masque_Layer += ALL_NO_CU_LAYERS; + LAYER_MSK Masque_Layer = g_TabAllCopperLayerMask[board->GetCopperLayerCount() - 1]; + Masque_Layer |= ALL_NO_CU_LAYERS; for( ii = 0, LayerCount = 0; ii < NB_COPPER_LAYERS; ii++ ) { diff --git a/pcbnew/tr_modif.cpp b/pcbnew/tr_modif.cpp index 3a042ae2da..11fa841a96 100644 --- a/pcbnew/tr_modif.cpp +++ b/pcbnew/tr_modif.cpp @@ -70,7 +70,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, int ii, jj, nb_segm, nbconnect; wxPoint start; wxPoint end; - int startmasklayer, endmasklayer; + LAYER_MSK startmasklayer, endmasklayer; int netcode = aNewTrack->GetNet(); @@ -135,14 +135,14 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, return 0; // Determine layers interconnected these points. - startmasklayer = StartTrack->ReturnMaskLayer(); - endmasklayer = EndTrack->ReturnMaskLayer(); + startmasklayer = StartTrack->GetLayerMask(); + endmasklayer = EndTrack->GetLayerMask(); // There may be a via or a pad on the end points. pt_segm = m_Pcb->m_Track->GetVia( NULL, start, startmasklayer ); if( pt_segm ) - startmasklayer |= pt_segm->ReturnMaskLayer(); + startmasklayer |= pt_segm->GetLayerMask(); if( StartTrack->start && ( StartTrack->start->Type() == PCB_PAD_T ) ) { @@ -154,7 +154,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, pt_segm = m_Pcb->m_Track->GetVia( NULL, end, endmasklayer ); if( pt_segm ) - endmasklayer |= pt_segm->ReturnMaskLayer(); + endmasklayer |= pt_segm->GetLayerMask(); if( EndTrack->end && ( EndTrack->end->Type() == PCB_PAD_T ) ) { diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index fb62fec1c1..3df519dfea 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -55,7 +55,7 @@ * The pads must appear on the layers selected in LayerMask */ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module, - int ox, int oy, int LayerMask, GR_DRAWMODE draw_mode ); + int ox, int oy, LAYER_MSK LayerMask, GR_DRAWMODE draw_mode ); void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) @@ -199,7 +199,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const for( MODULE* module = m_Modules; module; module = module->Next() ) { bool display = true; - int layerMask = ALL_CU_LAYERS; + LAYER_MSK layerMask = ALL_CU_LAYERS; if( module->IsMoving() ) continue; @@ -286,7 +286,7 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode ) * The pads must appear on the layers selected in LayerMask */ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* aModule, - int ox, int oy, int aLayerMask, GR_DRAWMODE draw_mode ) + int ox, int oy, LAYER_MSK aLayerMask, GR_DRAWMODE draw_mode ) { PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent(); diff --git a/polygon/PolyLine.h b/polygon/PolyLine.h index 98273d3769..39368bf003 100644 --- a/polygon/PolyLine.h +++ b/polygon/PolyLine.h @@ -19,7 +19,7 @@ #include #include // for wxPoint definition - +#include #include class CRect