diff --git a/3d-viewer/3d_canvas/board_adapter.cpp b/3d-viewer/3d_canvas/board_adapter.cpp index 87911cfebb..4a09ba00bd 100644 --- a/3d-viewer/3d_canvas/board_adapter.cpp +++ b/3d-viewer/3d_canvas/board_adapter.cpp @@ -267,7 +267,7 @@ bool BOARD_ADAPTER::Is3dLayerEnabled( PCB_LAYER_ID aLayer, case Eco2_User: return aVisibilityFlags.test( LAYER_3D_USER_ECO2 ); default: { - int layer3D = MapPCBUserLayerTo3DLayer( aLayer ); + int layer3D = MapPCBLayerTo3DLayer( aLayer ); if( layer3D != UNDEFINED_LAYER ) return aVisibilityFlags.test( layer3D ); @@ -922,7 +922,7 @@ std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetVisibleLayers() const ret.set( LAYER_3D_USER_ECO2, layers.test( Eco2_User ) ); for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer ) - ret.set( layer, layers.test( Map3DUserLayerToPCBLayer( layer ) ) ); + ret.set( layer, layers.test( Map3DLayerToPCBLayer( layer ) ) ); ret.set( LAYER_FP_REFERENCES, plotParams.GetPlotReference() ); ret.set( LAYER_FP_VALUES, plotParams.GetPlotValue() ); @@ -1047,7 +1047,7 @@ float BOARD_ADAPTER::GetFootprintZPos( bool aIsFlipped ) const SFVEC4F BOARD_ADAPTER::GetLayerColor( int aLayerId ) const { if( aLayerId >= LAYER_3D_USER_1 && aLayerId <= LAYER_3D_USER_45 ) - aLayerId = Map3DUserLayerToPCBLayer( aLayerId ); + aLayerId = Map3DLayerToPCBLayer( aLayerId ); wxASSERT( aLayerId < PCB_LAYER_ID_COUNT ); diff --git a/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp b/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp index 3e88208158..105e68b142 100644 --- a/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp +++ b/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp @@ -361,11 +361,11 @@ void RENDER_3D_OPENGL::setLayerMaterial( PCB_LAYER_ID aLayerID ) default: { - int layer3D = MapPCBUserLayerTo3DLayer( aLayerID ); + int layer3D = MapPCBLayerTo3DLayer( aLayerID ); - if( layer3D != UNDEFINED_LAYER ) + // Note: MUST do this in LAYER_3D space; User_1..User_45 are NOT contiguous + if( layer3D >= LAYER_3D_USER_1 && layer3D <= LAYER_3D_USER_45 ) { - // Note: MUST do this in LAYER_3D space; User_1..User_45 are NOT contiguous int user_idx = layer3D - LAYER_3D_USER_1; m_materials.m_Plastic.m_Diffuse = m_boardAdapter.m_UserDefinedLayerColor[ user_idx ]; diff --git a/3d-viewer/3d_rendering/raytracing/create_scene.cpp b/3d-viewer/3d_rendering/raytracing/create_scene.cpp index 66e305cab7..a5c60ceb28 100644 --- a/3d-viewer/3d_rendering/raytracing/create_scene.cpp +++ b/3d-viewer/3d_rendering/raytracing/create_scene.cpp @@ -633,11 +633,11 @@ void RENDER_3D_RAYTRACE_BASE::Reload( REPORTER* aStatusReporter, REPORTER* aWarn default: { - int layer3D = MapPCBUserLayerTo3DLayer( layer_id ); + int layer3D = MapPCBLayerTo3DLayer( layer_id ); - if( layer3D != UNDEFINED_LAYER ) + // Note: MUST do this in LAYER_3D space; User_1..User_45 are NOT contiguous + if( layer3D >= LAYER_3D_USER_1 && layer3D <= LAYER_3D_USER_45 ) { - // Note: MUST do this in LAYER_3D space; User_1..User_45 are NOT contiguous layerColor = m_boardAdapter.m_UserDefinedLayerColor[ layer3D - LAYER_3D_USER_1 ]; } else if( m_boardAdapter.m_Cfg->m_Render.differentiate_plated_copper ) diff --git a/3d-viewer/dialogs/appearance_controls_3D.cpp b/3d-viewer/dialogs/appearance_controls_3D.cpp index 10c95a9f8e..855318e751 100644 --- a/3d-viewer/dialogs/appearance_controls_3D.cpp +++ b/3d-viewer/dialogs/appearance_controls_3D.cpp @@ -579,8 +579,13 @@ void APPEARANCE_CONTROLS_3D::rebuildLayers() sizer->AddSpacer( 5 ); - wxStaticText* label = new wxStaticText( m_windowLayers, layer, - aSetting->GetLabel() ); + wxString layerName = aSetting->GetLabel(); + PCB_LAYER_ID boardLayer = Map3DLayerToPCBLayer( layer ); + + if( boardLayer != UNDEFINED_LAYER ) + layerName = m_frame->GetBoard()->GetLayerName( boardLayer ); + + wxStaticText* label = new wxStaticText( m_windowLayers, layer, layerName ); label->Wrap( -1 ); label->SetToolTip( aSetting->GetTooltip() ); @@ -630,7 +635,7 @@ void APPEARANCE_CONTROLS_3D::rebuildLayers() } else if( setting->m_Id >= LAYER_3D_USER_1 && setting->m_Id <= LAYER_3D_USER_45 ) { - if( enabled.test( Map3DUserLayerToPCBLayer( setting->m_Id ) ) ) + if( enabled.test( Map3DLayerToPCBLayer( setting->m_Id ) ) ) appendLayer( setting ); } else diff --git a/common/layer_id.cpp b/common/layer_id.cpp index dddd64da61..c32748064c 100644 --- a/common/layer_id.cpp +++ b/common/layer_id.cpp @@ -262,113 +262,133 @@ PCB_LAYER_ID BoardLayerFromLegacyId( int aLegacyId ) } -PCB_LAYER_ID Map3DUserLayerToPCBLayer( int aLayer ) +PCB_LAYER_ID Map3DLayerToPCBLayer( int aLayer ) { // NOTE: User_1..User45 are NOT consecutive numbers! switch( aLayer ) { - case LAYER_3D_USER_1: return User_1; - case LAYER_3D_USER_2: return User_2; - case LAYER_3D_USER_3: return User_3; - case LAYER_3D_USER_4: return User_4; - case LAYER_3D_USER_5: return User_5; - case LAYER_3D_USER_6: return User_6; - case LAYER_3D_USER_7: return User_7; - case LAYER_3D_USER_8: return User_8; - case LAYER_3D_USER_9: return User_9; - case LAYER_3D_USER_10: return User_10; - case LAYER_3D_USER_11: return User_11; - case LAYER_3D_USER_12: return User_12; - case LAYER_3D_USER_13: return User_13; - case LAYER_3D_USER_14: return User_14; - case LAYER_3D_USER_15: return User_15; - case LAYER_3D_USER_16: return User_16; - case LAYER_3D_USER_17: return User_17; - case LAYER_3D_USER_18: return User_18; - case LAYER_3D_USER_19: return User_19; - case LAYER_3D_USER_20: return User_20; - case LAYER_3D_USER_21: return User_21; - case LAYER_3D_USER_22: return User_22; - case LAYER_3D_USER_23: return User_23; - case LAYER_3D_USER_24: return User_24; - case LAYER_3D_USER_25: return User_25; - case LAYER_3D_USER_26: return User_26; - case LAYER_3D_USER_27: return User_27; - case LAYER_3D_USER_28: return User_28; - case LAYER_3D_USER_29: return User_29; - case LAYER_3D_USER_30: return User_30; - case LAYER_3D_USER_31: return User_31; - case LAYER_3D_USER_32: return User_32; - case LAYER_3D_USER_33: return User_33; - case LAYER_3D_USER_34: return User_34; - case LAYER_3D_USER_35: return User_35; - case LAYER_3D_USER_36: return User_36; - case LAYER_3D_USER_37: return User_37; - case LAYER_3D_USER_38: return User_38; - case LAYER_3D_USER_39: return User_39; - case LAYER_3D_USER_40: return User_40; - case LAYER_3D_USER_41: return User_41; - case LAYER_3D_USER_42: return User_42; - case LAYER_3D_USER_43: return User_43; - case LAYER_3D_USER_44: return User_44; - case LAYER_3D_USER_45: return User_45; + case LAYER_3D_COPPER_TOP: return F_Cu; + case LAYER_3D_COPPER_BOTTOM: return B_Cu; + case LAYER_3D_SILKSCREEN_BOTTOM: return B_SilkS; + case LAYER_3D_SILKSCREEN_TOP: return F_SilkS; + case LAYER_3D_SOLDERMASK_BOTTOM: return B_Mask; + case LAYER_3D_SOLDERMASK_TOP: return F_Mask; + case LAYER_3D_USER_COMMENTS: return Cmts_User; + case LAYER_3D_USER_DRAWINGS: return Dwgs_User; + case LAYER_3D_USER_ECO1: return Eco1_User; + case LAYER_3D_USER_ECO2: return Eco2_User; + case LAYER_3D_USER_1: return User_1; + case LAYER_3D_USER_2: return User_2; + case LAYER_3D_USER_3: return User_3; + case LAYER_3D_USER_4: return User_4; + case LAYER_3D_USER_5: return User_5; + case LAYER_3D_USER_6: return User_6; + case LAYER_3D_USER_7: return User_7; + case LAYER_3D_USER_8: return User_8; + case LAYER_3D_USER_9: return User_9; + case LAYER_3D_USER_10: return User_10; + case LAYER_3D_USER_11: return User_11; + case LAYER_3D_USER_12: return User_12; + case LAYER_3D_USER_13: return User_13; + case LAYER_3D_USER_14: return User_14; + case LAYER_3D_USER_15: return User_15; + case LAYER_3D_USER_16: return User_16; + case LAYER_3D_USER_17: return User_17; + case LAYER_3D_USER_18: return User_18; + case LAYER_3D_USER_19: return User_19; + case LAYER_3D_USER_20: return User_20; + case LAYER_3D_USER_21: return User_21; + case LAYER_3D_USER_22: return User_22; + case LAYER_3D_USER_23: return User_23; + case LAYER_3D_USER_24: return User_24; + case LAYER_3D_USER_25: return User_25; + case LAYER_3D_USER_26: return User_26; + case LAYER_3D_USER_27: return User_27; + case LAYER_3D_USER_28: return User_28; + case LAYER_3D_USER_29: return User_29; + case LAYER_3D_USER_30: return User_30; + case LAYER_3D_USER_31: return User_31; + case LAYER_3D_USER_32: return User_32; + case LAYER_3D_USER_33: return User_33; + case LAYER_3D_USER_34: return User_34; + case LAYER_3D_USER_35: return User_35; + case LAYER_3D_USER_36: return User_36; + case LAYER_3D_USER_37: return User_37; + case LAYER_3D_USER_38: return User_38; + case LAYER_3D_USER_39: return User_39; + case LAYER_3D_USER_40: return User_40; + case LAYER_3D_USER_41: return User_41; + case LAYER_3D_USER_42: return User_42; + case LAYER_3D_USER_43: return User_43; + case LAYER_3D_USER_44: return User_44; + case LAYER_3D_USER_45: return User_45; default: return UNDEFINED_LAYER; } } -int MapPCBUserLayerTo3DLayer( PCB_LAYER_ID aLayer ) +int MapPCBLayerTo3DLayer( PCB_LAYER_ID aLayer ) { // NOTE: User_1..User45 are NOT consecutive numbers! switch( aLayer ) { - case User_1: return LAYER_3D_USER_1; - case User_2: return LAYER_3D_USER_2; - case User_3: return LAYER_3D_USER_3; - case User_4: return LAYER_3D_USER_4; - case User_5: return LAYER_3D_USER_5; - case User_6: return LAYER_3D_USER_6; - case User_7: return LAYER_3D_USER_7; - case User_8: return LAYER_3D_USER_8; - case User_9: return LAYER_3D_USER_9; - case User_10: return LAYER_3D_USER_10; - case User_11: return LAYER_3D_USER_11; - case User_12: return LAYER_3D_USER_12; - case User_13: return LAYER_3D_USER_13; - case User_14: return LAYER_3D_USER_14; - case User_15: return LAYER_3D_USER_15; - case User_16: return LAYER_3D_USER_16; - case User_17: return LAYER_3D_USER_17; - case User_18: return LAYER_3D_USER_18; - case User_19: return LAYER_3D_USER_19; - case User_20: return LAYER_3D_USER_20; - case User_21: return LAYER_3D_USER_21; - case User_22: return LAYER_3D_USER_22; - case User_23: return LAYER_3D_USER_23; - case User_24: return LAYER_3D_USER_24; - case User_25: return LAYER_3D_USER_25; - case User_26: return LAYER_3D_USER_26; - case User_27: return LAYER_3D_USER_27; - case User_28: return LAYER_3D_USER_28; - case User_29: return LAYER_3D_USER_29; - case User_30: return LAYER_3D_USER_30; - case User_31: return LAYER_3D_USER_31; - case User_32: return LAYER_3D_USER_32; - case User_33: return LAYER_3D_USER_33; - case User_34: return LAYER_3D_USER_34; - case User_35: return LAYER_3D_USER_35; - case User_36: return LAYER_3D_USER_36; - case User_37: return LAYER_3D_USER_37; - case User_38: return LAYER_3D_USER_38; - case User_39: return LAYER_3D_USER_39; - case User_40: return LAYER_3D_USER_40; - case User_41: return LAYER_3D_USER_41; - case User_42: return LAYER_3D_USER_42; - case User_43: return LAYER_3D_USER_43; - case User_44: return LAYER_3D_USER_44; - case User_45: return LAYER_3D_USER_45; - default: return UNDEFINED_LAYER; + case F_Cu: return LAYER_3D_COPPER_TOP; + case B_Cu: return LAYER_3D_COPPER_BOTTOM; + case B_SilkS: return LAYER_3D_SILKSCREEN_BOTTOM; + case F_SilkS: return LAYER_3D_SILKSCREEN_TOP; + case B_Mask: return LAYER_3D_SOLDERMASK_BOTTOM; + case F_Mask: return LAYER_3D_SOLDERMASK_TOP; + case Cmts_User: return LAYER_3D_USER_COMMENTS; + case Dwgs_User: return LAYER_3D_USER_DRAWINGS; + case Eco1_User: return LAYER_3D_USER_ECO1; + case Eco2_User: return LAYER_3D_USER_ECO2; + case User_1: return LAYER_3D_USER_1; + case User_2: return LAYER_3D_USER_2; + case User_3: return LAYER_3D_USER_3; + case User_4: return LAYER_3D_USER_4; + case User_5: return LAYER_3D_USER_5; + case User_6: return LAYER_3D_USER_6; + case User_7: return LAYER_3D_USER_7; + case User_8: return LAYER_3D_USER_8; + case User_9: return LAYER_3D_USER_9; + case User_10: return LAYER_3D_USER_10; + case User_11: return LAYER_3D_USER_11; + case User_12: return LAYER_3D_USER_12; + case User_13: return LAYER_3D_USER_13; + case User_14: return LAYER_3D_USER_14; + case User_15: return LAYER_3D_USER_15; + case User_16: return LAYER_3D_USER_16; + case User_17: return LAYER_3D_USER_17; + case User_18: return LAYER_3D_USER_18; + case User_19: return LAYER_3D_USER_19; + case User_20: return LAYER_3D_USER_20; + case User_21: return LAYER_3D_USER_21; + case User_22: return LAYER_3D_USER_22; + case User_23: return LAYER_3D_USER_23; + case User_24: return LAYER_3D_USER_24; + case User_25: return LAYER_3D_USER_25; + case User_26: return LAYER_3D_USER_26; + case User_27: return LAYER_3D_USER_27; + case User_28: return LAYER_3D_USER_28; + case User_29: return LAYER_3D_USER_29; + case User_30: return LAYER_3D_USER_30; + case User_31: return LAYER_3D_USER_31; + case User_32: return LAYER_3D_USER_32; + case User_33: return LAYER_3D_USER_33; + case User_34: return LAYER_3D_USER_34; + case User_35: return LAYER_3D_USER_35; + case User_36: return LAYER_3D_USER_36; + case User_37: return LAYER_3D_USER_37; + case User_38: return LAYER_3D_USER_38; + case User_39: return LAYER_3D_USER_39; + case User_40: return LAYER_3D_USER_40; + case User_41: return LAYER_3D_USER_41; + case User_42: return LAYER_3D_USER_42; + case User_43: return LAYER_3D_USER_43; + case User_44: return LAYER_3D_USER_44; + case User_45: return LAYER_3D_USER_45; + default: return UNDEFINED_LAYER; } } diff --git a/common/settings/color_settings.cpp b/common/settings/color_settings.cpp index d58c530f4e..b0bc8bfb72 100644 --- a/common/settings/color_settings.cpp +++ b/common/settings/color_settings.cpp @@ -253,7 +253,7 @@ COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath ) for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer ) { int idx = layer - LAYER_3D_USER_1; - PCB_LAYER_ID pcb_layer = Map3DUserLayerToPCBLayer( layer ); + PCB_LAYER_ID pcb_layer = Map3DLayerToPCBLayer( layer ); m_params.emplace_back( new COLOR_MAP_PARAM( "3d_viewer.user_" + std::to_string( idx + 1 ), layer, s_defaultTheme.at( pcb_layer ), diff --git a/include/layer_ids.h b/include/layer_ids.h index 5b48675d13..61e900108b 100644 --- a/include/layer_ids.h +++ b/include/layer_ids.h @@ -908,8 +908,8 @@ inline size_t CopperLayerToOrdinal( PCB_LAYER_ID aLayer ) KICOMMON_API PCB_LAYER_ID BoardLayerFromLegacyId( int aLegacyId ); -KICOMMON_API PCB_LAYER_ID Map3DUserLayerToPCBLayer( int aLayer ); -KICOMMON_API int MapPCBUserLayerTo3DLayer( PCB_LAYER_ID aLayer ); +KICOMMON_API PCB_LAYER_ID Map3DLayerToPCBLayer( int aLayer ); +KICOMMON_API int MapPCBLayerTo3DLayer( PCB_LAYER_ID aLayer ); KICOMMON_API PCB_LAYER_ID ToLAYER_ID( int aLayer );