From 00f0e278518a164e9936ca7bccab4abd70f3fd86 Mon Sep 17 00:00:00 2001 From: Lorenzo Marcantonio Date: Fri, 5 Apr 2013 21:04:58 +0200 Subject: [PATCH] Factored layer utility functions: classification, layer flip and mask flip --- common/CMakeLists.txt | 1 - common/pcbcommon.cpp | 112 +++++++++++++++ include/layers_id_colors_and_visibility.h | 25 ++++ pcbnew/class_board.h | 8 -- pcbnew/class_dimension.cpp | 2 +- pcbnew/class_drawsegment.cpp | 2 +- pcbnew/class_mire.cpp | 2 +- pcbnew/class_module.cpp | 22 ++- pcbnew/class_module_transform_functions.cpp | 130 ------------------ pcbnew/class_pad.cpp | 69 ++-------- pcbnew/class_pad_draw_functions.cpp | 94 ++----------- pcbnew/class_pcb_text.cpp | 2 +- pcbnew/class_track.cpp | 2 +- pcbnew/class_zone.cpp | 2 +- pcbnew/dialogs/dialog_pad_properties.cpp | 4 +- pcbnew/dialogs/dialog_plot.cpp | 2 +- pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp | 2 +- pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp | 37 +---- pcbnew/pcad2kicadpcb_plugin/pcb_component.h | 2 - pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp | 2 +- pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp | 2 +- pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp | 2 +- pcbnew/protos.h | 7 - polygon/PolyLine.cpp | 2 +- 24 files changed, 186 insertions(+), 349 deletions(-) delete mode 100644 pcbnew/class_module_transform_functions.cpp diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 8961793ec1..6c17b8496d 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -106,7 +106,6 @@ set(PCB_COMMON_SRCS ../pcbnew/class_marker_pcb.cpp ../pcbnew/class_mire.cpp ../pcbnew/class_module.cpp - ../pcbnew/class_module_transform_functions.cpp ../pcbnew/class_pad.cpp ../pcbnew/class_pad_draw_functions.cpp ../pcbnew/class_pcb_text.cpp diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index 70b8473508..8dfbd03e08 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -72,3 +72,115 @@ int g_PadCMPColor = RED; */ DLIST g_CurrentTrackList; +LAYER_NUM FlipLayer( LAYER_NUM oldlayer ) +{ + switch( oldlayer ) + { + case LAYER_N_BACK: + return LAYER_N_FRONT; + + case LAYER_N_FRONT: + return LAYER_N_BACK; + + case SILKSCREEN_N_BACK: + return SILKSCREEN_N_FRONT; + + case SILKSCREEN_N_FRONT: + return SILKSCREEN_N_BACK; + + case ADHESIVE_N_BACK: + return ADHESIVE_N_FRONT; + + case ADHESIVE_N_FRONT: + return ADHESIVE_N_BACK; + + case SOLDERMASK_N_BACK: + return SOLDERMASK_N_FRONT; + + case SOLDERMASK_N_FRONT: + return SOLDERMASK_N_BACK; + + case SOLDERPASTE_N_BACK: + return SOLDERPASTE_N_FRONT; + + case SOLDERPASTE_N_FRONT: + return SOLDERPASTE_N_BACK; + + // No change for the other layers + default: + return oldlayer; + } +} + + +LAYER_MSK FlipLayerMask( LAYER_MSK aMask ) +{ + LAYER_MSK newMask; + + newMask = aMask & ~(LAYER_BACK | LAYER_FRONT | + SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT | + ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT | + SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT | + SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT | + ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT); + + if( aMask & LAYER_BACK ) + newMask |= LAYER_FRONT; + + if( aMask & LAYER_FRONT ) + newMask |= LAYER_BACK; + + if( aMask & SILKSCREEN_LAYER_BACK ) + newMask |= SILKSCREEN_LAYER_FRONT; + + if( aMask & SILKSCREEN_LAYER_FRONT ) + newMask |= SILKSCREEN_LAYER_BACK; + + if( aMask & ADHESIVE_LAYER_BACK ) + newMask |= ADHESIVE_LAYER_FRONT; + + if( aMask & ADHESIVE_LAYER_FRONT ) + newMask |= ADHESIVE_LAYER_BACK; + + if( aMask & SOLDERMASK_LAYER_BACK ) + newMask |= SOLDERMASK_LAYER_FRONT; + + if( aMask & SOLDERMASK_LAYER_FRONT ) + newMask |= SOLDERMASK_LAYER_BACK; + + if( aMask & SOLDERPASTE_LAYER_BACK ) + newMask |= SOLDERPASTE_LAYER_FRONT; + + if( aMask & SOLDERPASTE_LAYER_FRONT ) + newMask |= SOLDERPASTE_LAYER_BACK; + + if( aMask & ADHESIVE_LAYER_BACK ) + newMask |= ADHESIVE_LAYER_FRONT; + + if( aMask & ADHESIVE_LAYER_FRONT ) + newMask |= ADHESIVE_LAYER_BACK; + + return newMask; +} + +LAYER_NUM ExtractLayer( LAYER_MSK aMask ) +{ + if( aMask == NO_LAYERS ) + return UNSELECTED_LAYER; + + LAYER_NUM candidate = UNDEFINED_LAYER; + + // Scan all the layers and take note of the first set; if other are + // then found return UNDEFINED_LAYER + for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i ) + { + if( aMask & GetLayerMask( i ) ) + { + if( candidate == UNDEFINED_LAYER ) + candidate = i; + else + return UNDEFINED_LAYER; + } + } + return candidate; +} diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index 28dacafee3..a9dd03f915 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -124,6 +124,12 @@ typedef unsigned LAYER_MSK; #define ALL_CU_LAYERS 0x0000FFFF #define INTERNAL_LAYERS 0x00007FFE #define EXTERNAL_LAYERS 0x00008001 +#define BACK_LAYERS (LAYER_BACK | ADHESIVE_LAYER_BACK | \ + SOLDERPASTE_LAYER_BACK | SILKSCREEN_LAYER_BACK | \ + SOLDERMASK_LAYER_BACK) +#define FRONT_LAYERS (LAYER_FRONT | ADHESIVE_LAYER_FRONT | \ + SOLDERPASTE_LAYER_FRONT | SILKSCREEN_LAYER_FRONT | \ + SOLDERMASK_LAYER_FRONT) #define NO_LAYERS 0x00000000 /** return a one bit layer mask from a layer number @@ -271,5 +277,24 @@ inline bool IsBackLayer( LAYER_NUM aLayer ) aLayer == SOLDERPASTE_N_BACK ); } +/** + * Function ReturnFlippedLayerNumber + * @return the layer number after flipping an item + * some (not all) layers: external copper, Mask, Paste, and solder + * are swapped between front and back sides + */ +LAYER_NUM FlipLayer( LAYER_NUM oldlayer ); + +/** + * Calculate the mask layer when flipping a footprint + * BACK and FRONT copper layers, mask, paste, solder layers are swapped + */ +LAYER_MSK FlipLayerMask( LAYER_MSK aMask ); + +/** + * Extract the set layer from a mask. Returns UNDEFINED_LAYER if more + * than one is set or UNSELECTED_LAYER if none is + */ +LAYER_NUM ExtractLayer( LAYER_MSK aMask ); #endif // _LAYERS_ID_AND_VISIBILITY_H_ diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index bd2885df42..fe92536160 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -656,14 +656,6 @@ public: */ EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const; - /** - * Function ReturnFlippedLayerNumber - * @return the layer number after flipping an item - * some (not all) layers: external copper, Mask, Paste, and solder - * are swapped between front and back sides - */ - static LAYER_NUM ReturnFlippedLayerNumber( LAYER_NUM oldlayer ); - /** Functions to get some items count */ int GetNumSegmTrack() const; diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 1b77f73417..c1f54724c4 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -176,7 +176,7 @@ void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) void DIMENSION::Flip( const wxPoint& aCentre ) { Mirror( aCentre ); - SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) ); + SetLayer( FlipLayer( GetLayer() ) ); } diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 9e23534245..8926769111 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -111,7 +111,7 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre ) NEGATE( m_Angle ); } - SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) ); + SetLayer( FlipLayer( GetLayer() ) ); } const wxPoint DRAWSEGMENT::GetArcEnd() const diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index c05a03dfee..e1a2df6a78 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -194,7 +194,7 @@ void PCB_TARGET::Rotate(const wxPoint& aRotCentre, double aAngle) void PCB_TARGET::Flip(const wxPoint& aCentre ) { m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y ); - SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) ); + SetLayer( FlipLayer( GetLayer() ) ); } diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index c6eaac88f0..2c06379a03 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -758,7 +758,7 @@ void MODULE::Flip( const wxPoint& aCentre ) SetPosition( finalPos ); // Flip layer - SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) ); + SetLayer( FlipLayer( GetLayer() ) ); // Reverse mirror orientation. NEGATE( m_Orient ); @@ -777,7 +777,7 @@ void MODULE::Flip( const wxPoint& aCentre ) text->m_Mirror = false; NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient ); text->SetLayer( GetLayer() ); - text->SetLayer( BOARD::ReturnFlippedLayerNumber( text->GetLayer() ) ); + text->SetLayer( FlipLayer( text->GetLayer() ) ); if( GetLayer() == LAYER_N_BACK ) text->SetLayer( SILKSCREEN_N_BACK ); @@ -785,8 +785,7 @@ void MODULE::Flip( const wxPoint& aCentre ) if( GetLayer() == LAYER_N_FRONT ) text->SetLayer( SILKSCREEN_N_FRONT ); - if( (GetLayer() == SILKSCREEN_N_BACK) - || (GetLayer() == ADHESIVE_N_BACK) || (GetLayer() == LAYER_N_BACK) ) + if( IsBackLayer( GetLayer() ) ) text->m_Mirror = true; // Mirror value. @@ -798,7 +797,7 @@ void MODULE::Flip( const wxPoint& aCentre ) text->m_Mirror = false; NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient ); text->SetLayer( GetLayer() ); - text->SetLayer( BOARD::ReturnFlippedLayerNumber( text->GetLayer() ) ); + text->SetLayer( FlipLayer( text->GetLayer() ) ); if( GetLayer() == LAYER_N_BACK ) text->SetLayer( SILKSCREEN_N_BACK ); @@ -806,8 +805,7 @@ void MODULE::Flip( const wxPoint& aCentre ) if( GetLayer() == LAYER_N_FRONT ) text->SetLayer( SILKSCREEN_N_FRONT ); - if( (GetLayer() == SILKSCREEN_N_BACK) - || (GetLayer() == ADHESIVE_N_BACK) || (GetLayer() == LAYER_N_BACK) ) + if( IsBackLayer( GetLayer() ) ) text->m_Mirror = true; // Reverse mirror module graphics and texts. @@ -839,7 +837,7 @@ void MODULE::Flip( const wxPoint& aCentre ) em->SetAngle( -em->GetAngle() ); } - em->SetLayer( BOARD::ReturnFlippedLayerNumber( em->GetLayer() ) ); + em->SetLayer( FlipLayer( em->GetLayer() ) ); } break; @@ -854,7 +852,7 @@ void MODULE::Flip( const wxPoint& aCentre ) NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient ); text->SetLayer( GetLayer() ); - text->SetLayer( BOARD::ReturnFlippedLayerNumber( text->GetLayer() ) ); + text->SetLayer( FlipLayer( text->GetLayer() ) ); if( GetLayer() == LAYER_N_BACK ) text->SetLayer( SILKSCREEN_N_BACK ); @@ -862,12 +860,8 @@ void MODULE::Flip( const wxPoint& aCentre ) if( GetLayer() == LAYER_N_FRONT ) text->SetLayer( SILKSCREEN_N_FRONT ); - if( GetLayer() == SILKSCREEN_N_BACK - || GetLayer() == ADHESIVE_N_BACK - || GetLayer() == LAYER_N_BACK ) - { + if( IsBackLayer( GetLayer() ) ) text->m_Mirror = true; - } break; diff --git a/pcbnew/class_module_transform_functions.cpp b/pcbnew/class_module_transform_functions.cpp deleted file mode 100644 index 159b83697d..0000000000 --- a/pcbnew/class_module_transform_functions.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/** - * @file class_module_transform_functions.cpp - * @brief Functions of class MODULE to handle some geometric changes such as move, rotate ... - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - - -/* Returns the layer number after flipping an item - * some layers: external copper, Mask, Paste, and solder - * are swapped between front and back sides - */ -LAYER_NUM BOARD::ReturnFlippedLayerNumber( LAYER_NUM oldlayer ) -{ - LAYER_NUM newlayer; - - switch( oldlayer ) - { - case LAYER_N_BACK: - newlayer = LAYER_N_FRONT; - break; - - case LAYER_N_FRONT: - newlayer = LAYER_N_BACK; - break; - - case SILKSCREEN_N_BACK: - newlayer = SILKSCREEN_N_FRONT; - break; - - case SILKSCREEN_N_FRONT: - newlayer = SILKSCREEN_N_BACK; - break; - - case ADHESIVE_N_BACK: - newlayer = ADHESIVE_N_FRONT; - break; - - case ADHESIVE_N_FRONT: - newlayer = ADHESIVE_N_BACK; - break; - - case SOLDERMASK_N_BACK: - newlayer = SOLDERMASK_N_FRONT; - break; - - case SOLDERMASK_N_FRONT: - newlayer = SOLDERMASK_N_BACK; - break; - - case SOLDERPASTE_N_BACK: - newlayer = SOLDERPASTE_N_FRONT; - break; - - case SOLDERPASTE_N_FRONT: - newlayer = SOLDERPASTE_N_BACK; - break; - - default: - newlayer = oldlayer; - } - - return newlayer; -} - - -/* Calculate the mask layer when flipping a footprint - * BACK and FRONT copper layers , mask, paste, solder layers are swapped - */ -LAYER_MSK ChangeSideMaskLayer( LAYER_MSK aMask ) -{ - LAYER_MSK newMask; - - newMask = aMask & ~(LAYER_BACK | LAYER_FRONT | - SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT | - ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT | - SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT | - SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT | - ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT); - - if( aMask & LAYER_BACK ) - newMask |= LAYER_FRONT; - - if( aMask & LAYER_FRONT ) - newMask |= LAYER_BACK; - - if( aMask & SILKSCREEN_LAYER_BACK ) - newMask |= SILKSCREEN_LAYER_FRONT; - - if( aMask & SILKSCREEN_LAYER_FRONT ) - newMask |= SILKSCREEN_LAYER_BACK; - - if( aMask & ADHESIVE_LAYER_BACK ) - newMask |= ADHESIVE_LAYER_FRONT; - - if( aMask & ADHESIVE_LAYER_FRONT ) - newMask |= ADHESIVE_LAYER_BACK; - - if( aMask & SOLDERMASK_LAYER_BACK ) - newMask |= SOLDERMASK_LAYER_FRONT; - - if( aMask & SOLDERMASK_LAYER_FRONT ) - newMask |= SOLDERMASK_LAYER_BACK; - - if( aMask & SOLDERPASTE_LAYER_BACK ) - newMask |= SOLDERPASTE_LAYER_FRONT; - - if( aMask & SOLDERPASTE_LAYER_FRONT ) - newMask |= SOLDERPASTE_LAYER_BACK; - - if( aMask & ADHESIVE_LAYER_BACK ) - newMask |= ADHESIVE_LAYER_FRONT; - - if( aMask & ADHESIVE_LAYER_FRONT ) - newMask |= ADHESIVE_LAYER_BACK; - - return newMask; -} diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index ee52e4ad20..9a82cf7d9b 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -168,7 +168,7 @@ void D_PAD::Flip( int aTranslationY ) SetOrientation( -GetOrientation() ); // flip pads layers - SetLayerMask( ChangeSideMaskLayer( m_layerMask ) ); + SetLayerMask( FlipLayerMask( m_layerMask ) ); // m_boundingRadius = -1; the shape has not been changed } @@ -542,76 +542,31 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) if( (m_layerMask & ALL_CU_LAYERS) == 0 ) // pad is not on any copper layers { - switch( m_layerMask & ~ALL_CU_LAYERS ) + LAYER_NUM pad_layer = ExtractLayer( m_layerMask & ~ALL_CU_LAYERS ); + switch( pad_layer ) { - case ADHESIVE_LAYER_BACK: - layerInfo = board->GetLayerName( ADHESIVE_N_BACK ); + case UNSELECTED_LAYER: + layerInfo = _( "No layers" ); break; - case ADHESIVE_LAYER_FRONT: - layerInfo = board->GetLayerName( ADHESIVE_N_FRONT ); - break; - - case SOLDERPASTE_LAYER_BACK: - layerInfo = board->GetLayerName( SOLDERPASTE_N_BACK ); - break; - - case SOLDERPASTE_LAYER_FRONT: - layerInfo = board->GetLayerName( SOLDERPASTE_N_FRONT ); - break; - - case SILKSCREEN_LAYER_BACK: - layerInfo = board->GetLayerName( SILKSCREEN_N_BACK ); - break; - - case SILKSCREEN_LAYER_FRONT: - layerInfo = board->GetLayerName( SILKSCREEN_N_FRONT ); - break; - - case SOLDERMASK_LAYER_BACK: - layerInfo = board->GetLayerName( SOLDERMASK_N_BACK ); - break; - - case SOLDERMASK_LAYER_FRONT: - layerInfo = board->GetLayerName( SOLDERMASK_N_FRONT ); - break; - - case DRAW_LAYER: - layerInfo = board->GetLayerName( DRAW_N ); - break; - - case COMMENT_LAYER: - layerInfo = board->GetLayerName( COMMENT_N ); - break; - - case ECO1_LAYER: - layerInfo = board->GetLayerName( ECO1_N ); - break; - - case ECO2_LAYER: - layerInfo = board->GetLayerName( ECO2_N ); - break; - - case EDGE_LAYER: - layerInfo = board->GetLayerName( EDGE_N ); + case UNDEFINED_LAYER: + layerInfo = _( "Non-copper" ); break; default: - layerInfo = _( "Non-copper" ); + layerInfo = board->GetLayerName( pad_layer ); break; } } else { -#define INTERIOR_COPPER (ALL_CU_LAYERS & ~(LAYER_BACK | LAYER_FRONT)) - static const wxChar* andInternal = _( " & int" ); if( (m_layerMask & (LAYER_BACK | LAYER_FRONT)) == LAYER_BACK ) { layerInfo = board->GetLayerName( LAYER_N_BACK ); - if( m_layerMask & INTERIOR_COPPER ) + if( m_layerMask & INTERNAL_LAYERS ) layerInfo += andInternal; } @@ -620,7 +575,7 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) layerInfo = board->GetLayerName( LAYER_N_BACK ) + wxT(", ") + board->GetLayerName( LAYER_N_FRONT ); - if( m_layerMask & INTERIOR_COPPER ) + if( m_layerMask & INTERNAL_LAYERS ) layerInfo += andInternal; } @@ -628,10 +583,10 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) { layerInfo = board->GetLayerName( LAYER_N_FRONT ); - if( m_layerMask & INTERIOR_COPPER ) + if( m_layerMask & INTERNAL_LAYERS ) layerInfo += andInternal; } - else // necessarily true: if( m_layerMask & INTERIOR_COPPER ) + else // necessarily true: if( m_layerMask & INTERNAL_LAYERS ) { layerInfo = _( "internal" ); } diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 23c1706f9b..c8fa9f75c7 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -100,16 +100,6 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, * ECO, edge and Draw layers and not considered */ - // Mask layers for Back side of board - #define BACK_SIDE_LAYERS \ - (LAYER_BACK | ADHESIVE_LAYER_BACK | SOLDERPASTE_LAYER_BACK \ - | SILKSCREEN_LAYER_BACK | SOLDERMASK_LAYER_BACK) - - // Mask layers for Front side of board - #define FRONT_SIDE_LAYERS \ - (LAYER_FRONT | ADHESIVE_LAYER_FRONT | SOLDERPASTE_LAYER_FRONT \ - | SILKSCREEN_LAYER_FRONT | SOLDERMASK_LAYER_FRONT) - BOARD* brd = GetBoard(); bool frontVisible = brd->IsElementVisible( PCB_VISIBLE( PAD_FR_VISIBLE ) ); bool backVisible = brd->IsElementVisible( PCB_VISIBLE( PAD_BK_VISIBLE ) ); @@ -120,13 +110,13 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, /* If pad are only on front side (no layer on back side) * and if hide front side pads is enabled, do not draw */ - if( !frontVisible && ( (m_layerMask & BACK_SIDE_LAYERS) == 0 ) ) + if( !frontVisible && ( (m_layerMask & BACK_LAYERS) == 0 ) ) return; /* If pad are only on back side (no layer on front side) * and if hide back side pads is enabled, do not draw */ - if( !backVisible && ( (m_layerMask & FRONT_SIDE_LAYERS) == 0 ) ) + if( !backVisible && ( (m_layerMask & FRONT_LAYERS) == 0 ) ) return; @@ -152,86 +142,29 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, if( color == BLACK ) // Not on a visible copper layer (i.e. still nothing to show) { // If the pad is on only one tech layer, use the layer color else use DARKGRAY - int mask_non_copper_layers = m_layerMask & ~ALL_CU_LAYERS; + LAYER_MSK mask_non_copper_layers = m_layerMask & ~ALL_CU_LAYERS; #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR mask_non_copper_layers &= brd->GetVisibleLayers(); #endif - switch( mask_non_copper_layers ) + LAYER_NUM pad_layer = ExtractLayer( mask_non_copper_layers ); + switch( pad_layer ) { - case 0: + case UNDEFINED_LAYER: // More than one layer + color = DARKGRAY; break; - case ADHESIVE_LAYER_BACK: - color = brd->GetLayerColor( ADHESIVE_N_BACK ); - break; - - case ADHESIVE_LAYER_FRONT: - color = brd->GetLayerColor( ADHESIVE_N_FRONT ); - break; - - case SOLDERPASTE_LAYER_BACK: - color = brd->GetLayerColor( SOLDERPASTE_N_BACK ); -#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR - showActualMaskSize = SOLDERPASTE_N_BACK; -#endif - break; - - case SOLDERPASTE_LAYER_FRONT: - color = brd->GetLayerColor( SOLDERPASTE_N_FRONT ); -#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR - showActualMaskSize = SOLDERPASTE_N_FRONT; -#endif - break; - - case SILKSCREEN_LAYER_BACK: - color = brd->GetLayerColor( SILKSCREEN_N_BACK ); - break; - - case SILKSCREEN_LAYER_FRONT: - color = brd->GetLayerColor( SILKSCREEN_N_FRONT ); - break; - - case SOLDERMASK_LAYER_BACK: - color = brd->GetLayerColor( SOLDERMASK_N_BACK ); -#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR - showActualMaskSize = SOLDERMASK_N_BACK; -#endif - break; - - case SOLDERMASK_LAYER_FRONT: - color = brd->GetLayerColor( SOLDERMASK_N_FRONT ); -#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR - showActualMaskSize = SOLDERMASK_N_FRONT; -#endif - break; - - case DRAW_LAYER: - color = brd->GetLayerColor( DRAW_N ); - break; - - case COMMENT_LAYER: - color = brd->GetLayerColor( COMMENT_N ); - break; - - case ECO1_LAYER: - color = brd->GetLayerColor( ECO1_N ); - break; - - case ECO2_LAYER: - color = brd->GetLayerColor( ECO2_N ); - break; - - case EDGE_LAYER: - color = brd->GetLayerColor( EDGE_N ); + case UNSELECTED_LAYER: // Shouldn't really happen... break; default: - color = DARKGRAY; - break; + color = brd->GetLayerColor( pad_layer ); +#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR + showActualMaskSize = pad_layer; +#endif } } - // if PAD_SMD pad and high contrast mode + // if SMD or connector pad and high contrast mode if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && ( GetAttribute() == PAD_SMD || GetAttribute() == PAD_CONN ) && DisplayOpt.ContrastModeDisplay ) @@ -286,6 +219,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, break; default: + // Another layer which has no margin to handle break; } } diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index d535f4a414..5b53db3350 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -169,7 +169,7 @@ void TEXTE_PCB::Flip(const wxPoint& aCentre ) { m_Mirror = not m_Mirror; /* inverse mirror */ } - SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) ); + SetLayer( FlipLayer( GetLayer() ) ); } diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index d8f0cabb72..326b78e06a 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -390,7 +390,7 @@ void TRACK::Flip( const wxPoint& aCentre ) } else { - SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) ); + SetLayer( FlipLayer( GetLayer() ) ); } } diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 7a0fc5816a..48aa55462e 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -826,7 +826,7 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle ) void ZONE_CONTAINER::Flip( const wxPoint& aCentre ) { Mirror( aCentre ); - SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) ); + SetLayer( FlipLayer( GetLayer() ) ); } diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index b489b89a5b..27ca9bc5ae 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -294,7 +294,7 @@ void DIALOG_PAD_PROPERTIES::initValues() m_dummyPad->SetDelta( sz ); // flip pad's layers - m_dummyPad->SetLayerMask( ChangeSideMaskLayer( m_dummyPad->GetLayerMask() ) ); + m_dummyPad->SetLayerMask( FlipLayerMask( m_dummyPad->GetLayerMask() ) ); } m_staticTextWarningPadFlipped->Show(m_isFlipped); @@ -799,7 +799,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) } if( m_isFlipped ) - m_currentPad->SetLayerMask( ChangeSideMaskLayer( m_currentPad->GetLayerMask() ) ); + m_currentPad->SetLayerMask( FlipLayerMask( m_currentPad->GetLayerMask() ) ); m_currentPad->SetPadName( m_padMaster.GetPadName() ); diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 805bbe34af..4bafc1ef3c 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -238,7 +238,7 @@ void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event ) switch( event.GetId() ) { - case ID_LAYER_FAB: // Select layers usually neede d to build a board + case ID_LAYER_FAB: // Select layers usually needed to build a board for( i = 0; i < m_layerList.size(); i++ ) { LAYER_MSK layermask = GetLayerMask( m_layerList[ i ] ); diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp index 8ebb0b684d..7adda1fda4 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp @@ -144,7 +144,7 @@ void PCB_ARC::Flip() m_startX = -m_startX; m_angle = -m_angle; - m_KiCadLayer = FlipLayers( m_KiCadLayer ); + m_KiCadLayer = FlipLayer( m_KiCadLayer ); } diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp index 0bcb43984b..f551919ad8 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp @@ -43,7 +43,7 @@ PCB_COMPONENT::PCB_COMPONENT( PCB_CALLBACKS* aCallbacks, m_tag = 0; m_objType = wxT( '?' ); m_PCadLayer = 0; - m_KiCadLayer = NO_LAYER; + m_KiCadLayer = LAYER_N_FRONT; // It *has* to be somewhere... m_timestamp = 0; m_positionX = 0; m_positionY = 0; @@ -77,39 +77,4 @@ void PCB_COMPONENT::Flip() m_positionX = -m_positionX; } -LAYER_NUM PCB_COMPONENT::FlipLayers( LAYER_NUM aLayer ) -{ - LAYER_NUM result = aLayer; // dafault is no swap - - // routed layers - if( aLayer == LAYER_N_BACK ) - result = LAYER_N_FRONT; - - if( aLayer == LAYER_N_FRONT ) - result = LAYER_N_BACK; - - // Silk - if( aLayer == SILKSCREEN_N_FRONT ) - result = SILKSCREEN_N_BACK; - - if( aLayer == SILKSCREEN_N_BACK ) - result = SILKSCREEN_N_FRONT; - - // Paste - if( aLayer == SOLDERPASTE_N_FRONT ) - result = SOLDERPASTE_N_BACK; - - if( aLayer == SOLDERPASTE_N_BACK ) - result = SOLDERPASTE_N_FRONT; - - // Mask - if( aLayer == SOLDERMASK_N_FRONT ) - result = SOLDERMASK_N_BACK; - - if( aLayer == SOLDERMASK_N_BACK ) - result = SOLDERMASK_N_FRONT; - - return result; -} - } // namespace PCAD2KICAD diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_component.h b/pcbnew/pcad2kicadpcb_plugin/pcb_component.h index 48700318d0..97c769f63e 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_component.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_component.h @@ -77,8 +77,6 @@ public: protected: PCB_CALLBACKS* m_callbacks; BOARD* m_board; - - LAYER_NUM FlipLayers( LAYER_NUM aLayer ); }; WX_DEFINE_ARRAY( PCB_COMPONENT*, PCB_COMPONENTS_ARRAY ); diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp index 6a3170e415..280551795b 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp @@ -110,7 +110,7 @@ void PCB_LINE::Flip() PCB_COMPONENT::Flip(); m_toX = -m_toX; - m_KiCadLayer = FlipLayers( m_KiCadLayer ); + m_KiCadLayer = FlipLayer( m_KiCadLayer ); } diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp index de0c5c41fb..daa698bdd2 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp @@ -606,7 +606,7 @@ void PCB_MODULE::Flip() if( m_mirror == 1 ) { // Flipped - m_KiCadLayer = FlipLayers( m_KiCadLayer ); + m_KiCadLayer = FlipLayer( m_KiCadLayer ); m_rotation = -m_rotation; m_name.textPositionX = -m_name.textPositionX; m_name.mirror = m_mirror; diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp index ea5a41f72b..53a27fce03 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_pad.cpp @@ -180,7 +180,7 @@ void PCB_PAD::Flip() m_rotation = -m_rotation; for( i = 0; i < (int)m_shapes.GetCount(); i++ ) - m_shapes[i]->m_KiCadLayer = FlipLayers( m_shapes[i]->m_KiCadLayer ); + m_shapes[i]->m_KiCadLayer = FlipLayer( m_shapes[i]->m_KiCadLayer ); } diff --git a/pcbnew/protos.h b/pcbnew/protos.h index a906b947df..7218e7508d 100644 --- a/pcbnew/protos.h +++ b/pcbnew/protos.h @@ -51,13 +51,6 @@ void DrawTraces( EDA_DRAW_PANEL* panel, /* MODULES.C */ /*************/ -/** - * Function ChangeSideMaskLayer - * calculates the mask layer when flipping a footprint. - * BACK and FRONT copper layers , mask, paste, solder layers are swapped. - */ -LAYER_MSK ChangeSideMaskLayer( LAYER_MSK aMask ); - void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module ); diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index 5ed3951842..52241b5543 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -21,7 +21,7 @@ CPolyLine::CPolyLine() { m_hatchStyle = NO_HATCH; m_hatchPitch = 0; - m_layer = NO_LAYER; + m_layer = LAYER_N_FRONT; m_utility = 0; }