diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index 8167926f6d..b2c162a456 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -316,12 +316,14 @@ void Pcb3D_GLCanvas::Draw3D_Track( TRACK* track ) { double zpos; int layer = track->GetLayer(); - int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; double ox, oy, fx, fy; double w; - if( color & ITEM_NOT_SHOW ) + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) return; + + int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; + if( layer == LAST_COPPER_LAYER ) layer = g_Parm_3D_Visu.m_Layers - 1; zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; @@ -363,11 +365,17 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) { zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; if( layer < g_Parm_3D_Visu.m_Layers - 1 ) + { + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) + continue; color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; + } else + { + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( CMP_N ) == false ) + continue; color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[CMP_N]; - if( color & ITEM_NOT_SHOW ) - continue; + } SetGLColor( color ); @@ -394,14 +402,16 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment ) /*************************************************************/ { - int layer; double x, y, xf, yf; double zpos, w; - int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[segment->GetLayer()]; - if( color & ITEM_NOT_SHOW ) + int layer = segment->GetLayer(); + + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) return; + int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; + SetGLColor( color ); w = segment->m_Width * g_Parm_3D_Visu.m_BoardScale; x = segment->m_Start.x * g_Parm_3D_Visu.m_BoardScale; @@ -409,7 +419,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment ) xf = segment->m_End.x * g_Parm_3D_Visu.m_BoardScale; yf = segment->m_End.y * g_Parm_3D_Visu.m_BoardScale; - if( segment->GetLayer() == EDGE_N ) + if( layer == EDGE_N ) { for( layer = 0; layer < g_Parm_3D_Visu.m_Layers; layer++ ) { @@ -434,7 +444,6 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment ) } else { - layer = segment->GetLayer(); glNormal3f( 0.0, 0.0, Get3DLayerSide( layer ) ); zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; if( Get3DLayerEnable( layer ) ) @@ -623,10 +632,12 @@ void EDGE_MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) wxString s; int dx, dy; double scale, x, y, fx, fy, w, zpos; + + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( m_Layer ) == false ) + return; + int color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[m_Layer]; - if( color & ITEM_NOT_SHOW ) - return; SetGLColor( color ); glNormal3f( 0.0, 0.0, (m_Layer == COPPER_LAYER_N) ? -1.0 : 1.0 ); @@ -737,7 +748,7 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) && !Both ) continue; color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; - if( color & ITEM_NOT_SHOW ) + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) continue; SetGLColor( color ); @@ -787,7 +798,7 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) continue; color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 ); - if( color & ITEM_NOT_SHOW ) + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) continue; SetGLColor( color ); @@ -862,7 +873,7 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) continue; color = g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[layer]; glNormal3f( 0.0, 0.0, (layer == COPPER_LAYER_N) ? -1.0 : 1.0 ); - if( color & ITEM_NOT_SHOW ) + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) continue; SetGLColor( color ); diff --git a/gerbview/gerbview_config.h b/gerbview/gerbview_config.h index a2d781bafa..ecfe02efe2 100644 --- a/gerbview/gerbview_config.h +++ b/gerbview/gerbview_config.h @@ -338,7 +338,8 @@ static PARAM_CFG_SETCOLOR ColorpcbGrilleCfg ( INSETUP, wxT("CoPcbGr"), /* identification */ - &g_DesignSettings.m_PcbGridColor, /* Adresse du parametre */ +//@@IMB: Wrong object &g_DesignSettings.m_PcbGridColor, /* Adresse du parametre */ + &g_GridColor, //@@IMB: This is the real variable. DARKGRAY /* Valeur par defaut */ ); diff --git a/gerbview/set_color.cpp b/gerbview/set_color.cpp index db52298b51..5a00b17463 100644 --- a/gerbview/set_color.cpp +++ b/gerbview/set_color.cpp @@ -213,10 +213,10 @@ void WinEDA_SetColorsFrame::CreateControls() if( laytool_list[lyr]->m_NoDisplayIsColor ) { - if( *laytool_list[lyr]->m_Color & ITEM_NOT_SHOW ) - CheckBox->SetValue( FALSE ); - else + if( g_DesignSettings.IsLayerVisible( lyr )) CheckBox->SetValue( TRUE ); + else + CheckBox->SetValue( FALSE ); } else CheckBox->SetValue( *laytool_list[lyr]->m_NoDisplay ); @@ -427,25 +427,24 @@ void WinEDA_SetColorsFrame::SetColor(wxCommandEvent& event) void WinEDA_SetColorsFrame::UpdateLayerSettings() /******************************************************************/ { - for( int lyr = 0; lyr < NB_BUTT; lyr++ ) + for( int lyr = 0; lyr < NB_BUTT - 2; lyr++ ) { - if( laytool_list[lyr]->m_NoDisplayIsColor ) - { - if( laytool_list[lyr]->m_CheckBox->GetValue() ) - *laytool_list[lyr]->m_Color = CurrentColor[lyr] & ~ITEM_NOT_SHOW; - else - *laytool_list[lyr]->m_Color = CurrentColor[lyr] | ITEM_NOT_SHOW; - } - else - { - // (As a bitmap button and a checkbox have been provided for *every* - // layer, it is not necessary to check whether each of those items - // actually has been provided for each of those layers.) - *laytool_list[lyr]->m_Color = CurrentColor[lyr]; - *laytool_list[lyr]->m_NoDisplay = laytool_list[lyr]->m_CheckBox->GetValue(); - } + g_DesignSettings.SetLayerVisibility( lyr, laytool_list[lyr]->m_CheckBox->GetValue() ); + *laytool_list[lyr]->m_Color = CurrentColor[lyr]; } - // Additional command required for updating visibility of grid. + + // (As a bitmap button and a checkbox have been provided for *every* + // layer, it is not necessary to check whether each of those items + // actually has been provided for each of those layers.) + + + g_GridColor = CurrentColor[32]; + s_showGrid = laytool_list[32]->m_CheckBox->GetValue(); + + g_DCodesColor = CurrentColor[33]; + DisplayOpt.DisplayPadNum = laytool_list[33]->m_CheckBox->GetValue(); + + // Additional command required for updating visibility of grid. m_Parent->m_Draw_Grid = s_showGrid; } diff --git a/gerbview/set_color.h b/gerbview/set_color.h index 4c0a7d6afb..10220bb93e 100644 --- a/gerbview/set_color.h +++ b/gerbview/set_color.h @@ -85,112 +85,112 @@ static ColorButton Layer_1_Butt= { _("Layer 1"), // Title ADR(0), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_2_Butt= { _("Layer 2"), // Title ADR(1), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_3_Butt= { _("Layer 3"), // Title ADR(2), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_4_Butt= { _("Layer 4"), // Title ADR(3), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_5_Butt= { _("Layer 5"), // Title ADR(4), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_6_Butt= { _("Layer 6"), // Title ADR(5), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_7_Butt= { _("Layer 7"), // Title ADR(6), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_8_Butt= { _("Layer 8"), // Title ADR(7), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_9_Butt= { _("Layer 9"), // Title ADR(8), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_10_Butt= { _("Layer 10"), // Title ADR(9), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_11_Butt= { _("Layer 11"), // Title ADR(10), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_12_Butt= { _("Layer 12"), // Title ADR(11), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_13_Butt= { _("Layer 13"), // Title ADR(12), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_14_Butt= { _("Layer 14"), // Title ADR(13), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_15_Butt= { _("Layer 15"), // Title ADR(14), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_16_Butt= { _("Layer 16"), // Title ADR(15), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; @@ -204,112 +204,112 @@ static ColorButton Layer_17_Butt= { _("Layer 17"), // Title ADR(16), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_18_Butt= { _("Layer 18"), // Title ADR(17), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_19_Butt= { _("Layer 19"), // Title ADR(18), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_20_Butt= { _("Layer 20"), // Title ADR(19), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_21_Butt= { _("Layer 21"), // Title ADR(20), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_22_Butt= { _("Layer 22"), // Title ADR(21), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_23_Butt= { _("Layer 23"), // Title ADR(22), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_24_Butt= { _("Layer 24"), // Title ADR(23), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_25_Butt= { _("Layer 25"), // Title ADR(24), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_26_Butt= { _("Layer 26"), // Title ADR(25), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_27_Butt= { _("Layer 27"), // Title ADR(26), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_28_Butt= { _("Layer 28"), // Title ADR(27), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_29_Butt= { _("Layer 29"), // Title ADR(28), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_30_Butt= { _("Layer 30"), // Title ADR(29), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_31_Butt= { _("Layer 31"), // Title ADR(30), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; static ColorButton Layer_32_Butt= { _("Layer 32"), // Title ADR(31), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + TRUE // Toggle ITEM*NOT*SHOW bit of the color variable }; diff --git a/gerbview/trpiste.cpp b/gerbview/trpiste.cpp index 7d295145f5..5f12712c31 100644 --- a/gerbview/trpiste.cpp +++ b/gerbview/trpiste.cpp @@ -78,10 +78,11 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo } else { - color = g_DesignSettings.m_LayerColor[track->GetLayer()]; - if( color & ITEM_NOT_SHOW ) + if( g_DesignSettings.IsLayerVisible( track->GetLayer() ) == false ) return; + color = g_DesignSettings.m_LayerColor[track->GetLayer()]; + if( draw_mode & GR_SURBRILL ) { if( draw_mode & GR_AND ) diff --git a/include/colors.h b/include/colors.h index ba0be9a77a..1241fb1b9c 100644 --- a/include/colors.h +++ b/include/colors.h @@ -11,7 +11,7 @@ #define MASKCOLOR 31 ///< mask for color index into ColorRefs[] /// bit indicateur d'affichage (vu / non vu) des items : (defini dans les valeurs des couleurs -#define ITEM_NOT_SHOW (1<<18) // 0x40000 +//IMB: Not used anymore #define ITEM_NOT_SHOW (1<<18) // 0x40000 /// Definition du bit de surbrillance #define HIGHT_LIGHT_FLAG (1<<19) // 0x80000 diff --git a/include/pcbstruct.h b/include/pcbstruct.h index dbf3d8587e..6a9f160f6d 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -134,6 +134,23 @@ class RATSNEST_ITEM; /* Class to handle a board */ #include "class_board.h" +enum ELEMENTS_NUMBERS +{ + VIAS_VISIBLE = 0, + VIA_NOT_DEFINED_VISIBLE = VIAS_VISIBLE, + VIA_MICROVIA_VISIBLE, + VIA_BLIND_BURIED_VISIBLE, + VIA_THROUGH_VISIBLE, + MODULE_TEXT_CMP_VISIBLE, + MODULE_TEXT_CU_VISIBLE, + MODULE_TEXT_NOV_VISIBLE, + ANCHOR_VISIBLE, + PAD_CU_VISIBLE, + PAD_CMP_VISIBLE +}; + + + // Class for handle current printed board design settings class EDA_BoardDesignSettings { @@ -160,21 +177,28 @@ public: int m_LayerThickness; // Layer Thickness for 3D viewer // Color options for screen display of the Printed Board: - int m_PcbGridColor; // Grid color +//@@IMB: Not used int m_PcbGridColor; // Grid color - int m_LayerColor[32]; // Layer colors (tracks and graphic items) + int m_EnabledLayers; // IMB: Paving the road + int m_VisibleLayers; // IMB: Bit-mask for layer visibility + int m_VisibleElements; // IMB: Bit-mask for elements visibility - int m_ViaColor[4]; // Via color (depending on is type) - int m_ModuleTextCMPColor; // Text module color for modules on the COMPONENT layer - int m_ModuleTextCUColor; // Text module color for modules on the COPPER layer - int m_ModuleTextNOVColor; // Text module color for "invisible" texts (must be BLACK if really not displayed) - int m_AnchorColor; // Anchor color for modules and texts + int m_LayerColor[32]; // Layer colors (tracks and graphic items) + + int m_ViaColor[4]; // Via color (depending on is type) + +//@@IMB: Not used int m_ModuleTextCMPColor; // Text module color for modules on the COMPONENT layer +//@@IMB: Not used int m_ModuleTextCUColor; // Text module color for modules on the COPPER layer +//@@IMB: Not used int m_ModuleTextNOVColor; // Text module color for "invisible" texts (must be BLACK if really not displayed) +//@@IMB: Not used int m_AnchorColor; // Anchor color for modules and texts + +//@@IMB: Not used int m_PadCUColor; // Pad color for the COPPER side of the pad +//@@IMB: Not used int m_PadCMPColor; // Pad color for the COMPONENT side of the pad - int m_PadCUColor; // Pad color for the COPPER side of the pad - int m_PadCMPColor; // Pad color for the COMPONENT side of the pad // Pad color for the pads of both sides is m_PadCUColor OR m_PadCMPColor (in terms of colors) - int m_RatsnestColor; // Ratsnest color + int m_RatsnestColor; // Ratsnest color + public: EDA_BoardDesignSettings(); @@ -185,6 +209,36 @@ public: * @return int - the visible layers in bit-mapped form. */ int GetVisibleLayers() const; + + void SetVisibleLayers( int Mask ); + + /** + * Function IsLayerVisible + * @param LayerNumber The number of the layer to be tested. + * @return bool - true if the layer is visible. + */ + inline bool IsLayerVisible( int LayerNumber ) const + { + if( LayerNumber < 0 || LayerNumber >= 32 ) //@@IMB: Altough Pcbnew uses only 29, Gerbview uses all 32 layers + return false; + return (bool)( m_VisibleLayers & 1 << LayerNumber ); + } + + void SetLayerVisibility( int LayerNumber, bool State ); + + /** + * Function IsElementVisible + * @param ElementNumber The number of the element to be tested. + * @return bool - true if the elememt is visible. + */ + inline bool IsElementVisible( int ElementNumber ) const + { + if( ElementNumber < 0 || ElementNumber > PAD_CMP_VISIBLE ) + return false; + return (bool)( m_VisibleElements & 1 << ElementNumber ); + } + + void SetElementVisibility( int ElementNumber, bool State ); }; diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 5d6af2c810..ec967f7fdd 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -290,9 +290,9 @@ GENERAL_COLLECTORS_GUIDE WinEDA_BasePcbFrame::GetCollectorsGuide() ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); // account for the globals - guide.SetIgnoreMTextsMarkedNoShow( g_ModuleTextNOVColor & ITEM_NOT_SHOW ); - guide.SetIgnoreMTextsOnCopper( g_ModuleTextCUColor & ITEM_NOT_SHOW ); - guide.SetIgnoreMTextsOnCmp( g_ModuleTextCMPColor & ITEM_NOT_SHOW ); + guide.SetIgnoreMTextsMarkedNoShow( ! g_DesignSettings.IsElementVisible( MODULE_TEXT_NOV_VISIBLE )); + guide.SetIgnoreMTextsOnCopper( ! g_DesignSettings.IsElementVisible( MODULE_TEXT_CU_VISIBLE )); + guide.SetIgnoreMTextsOnCmp( ! g_DesignSettings.IsElementVisible( MODULE_TEXT_CMP_VISIBLE )); guide.SetIgnoreModulesOnCu( !DisplayOpt.Show_Modules_Cu ); guide.SetIgnoreModulesOnCmp( !DisplayOpt.Show_Modules_Cmp ); diff --git a/pcbnew/class_cotation.cpp b/pcbnew/class_cotation.cpp index eacf8317aa..d12e4f29d9 100644 --- a/pcbnew/class_cotation.cpp +++ b/pcbnew/class_cotation.cpp @@ -406,10 +406,11 @@ void COTATION::Draw( WinEDA_DrawPanel* panel, wxDC* DC, m_Text->Draw( panel, DC, mode_color, offset ); - gcolor = g_DesignSettings.m_LayerColor[m_Layer]; - if( (gcolor & ITEM_NOT_SHOW) != 0 ) + if( g_DesignSettings.IsLayerVisible( m_Layer ) == false ) return; + gcolor = g_DesignSettings.m_LayerColor[m_Layer]; + GRSetDrawMode( DC, mode_color ); typeaff = DisplayOpt.DisplayDrawItems; width = m_Width; diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index b18643f635..ccc6d610e0 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -234,10 +234,11 @@ void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int color, mode; int rayon; - color = g_DesignSettings.m_LayerColor[GetLayer()]; - if( color & ITEM_NOT_SHOW ) + if( g_DesignSettings.IsLayerVisible( GetLayer() ) == false ) return; + color = g_DesignSettings.m_LayerColor[GetLayer()]; + GRSetDrawMode( DC, draw_mode ); l_piste = m_Width >> 1; /* l_piste = demi largeur piste */ diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index feff9920b6..ed9fc84461 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -102,10 +102,11 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, if( m_Parent && (m_Parent->Type() == TYPE_MODULE) ) Module = (MODULE*) m_Parent; - color = g_DesignSettings.m_LayerColor[m_Layer]; - if( (color & ITEM_NOT_SHOW) != 0 ) + if( g_DesignSettings.IsLayerVisible( m_Layer ) == false ) return; + color = g_DesignSettings.m_LayerColor[m_Layer]; + frame = (WinEDA_BasePcbFrame*) panel->m_Parent; screen = frame->GetScreen(); diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index e0c86e8d4b..dd315c608b 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -114,10 +114,11 @@ void MIREPCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ox = m_Pos.x + offset.x; oy = m_Pos.y + offset.y; - gcolor = g_DesignSettings.m_LayerColor[m_Layer]; - if( (gcolor & ITEM_NOT_SHOW) != 0 ) + if( g_DesignSettings.IsLayerVisible( m_Layer ) == false ) return; + gcolor = g_DesignSettings.m_LayerColor[m_Layer]; + GRSetDrawMode( DC, mode_color ); typeaff = DisplayOpt.DisplayDrawItems; width = m_Width; diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index c357ebc4d8..f57dd23b87 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -67,7 +67,7 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset GRSetDrawMode( DC, draw_mode ); - if( (g_AnchorColor & ITEM_NOT_SHOW) == 0 ) + if( g_DesignSettings.IsElementVisible( ANCHOR_VISIBLE )) { GRLine( &panel->m_ClipBox, DC, m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y, diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 8eac011ad6..6dcaf16a67 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -196,11 +196,11 @@ void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC, * and the actual size is very important, especially for copper texts */ { - int color = g_DesignSettings.m_LayerColor[m_Layer]; - - if( color & ITEM_NOT_SHOW ) + if( g_DesignSettings.IsLayerVisible( m_Layer ) == false ) return; + int color = g_DesignSettings.m_LayerColor[m_Layer]; + GRTraceMode fillmode = FILLED; if ( DisplayOpt.DisplayDrawItems == SKETCH) fillmode = SKETCH; @@ -210,7 +210,8 @@ void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC, offset, (EDA_Colors) color, DrawMode, fillmode, - (g_AnchorColor & ITEM_NOT_SHOW) ? UNSPECIFIED_COLOR : (EDA_Colors) g_AnchorColor ); + g_DesignSettings.IsElementVisible( ANCHOR_VISIBLE ) ? + (EDA_Colors) g_AnchorColor : UNSPECIFIED_COLOR ); } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 1eb7dbc90e..53a0a6ec9d 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -381,7 +381,7 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const GRSetDrawMode( DC, draw_mode ); /* trace du centre du texte */ - if( (g_AnchorColor & ITEM_NOT_SHOW) == 0 ) + if( g_DesignSettings.IsElementVisible( ANCHOR_VISIBLE )) { int anchor_size = screen->Unscale( 2 ); GRLine( &panel->m_ClipBox, DC, @@ -392,22 +392,30 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const pos.x, pos.y + anchor_size, 0, g_AnchorColor ); } + //@@@@IMB: BIG BIG BUG Here???? May Module be NULL? color = g_DesignSettings.m_LayerColor[Module->GetLayer()]; + + //@@IMB: Why the next ifs are testing for Module? if( Module && Module->GetLayer() == COPPER_LAYER_N ) + { + if( g_DesignSettings.IsElementVisible( MODULE_TEXT_CU_VISIBLE ) == false ) + return; color = g_ModuleTextCUColor; - + } else if( Module && Module->GetLayer() == CMP_N ) + { + if( g_DesignSettings.IsElementVisible( MODULE_TEXT_CMP_VISIBLE ) == false ) + return; color = g_ModuleTextCMPColor; - - if( (color & ITEM_NOT_SHOW) != 0 ) - return; + } if( m_NoShow ) + { + if( g_DesignSettings.IsElementVisible( MODULE_TEXT_NOV_VISIBLE ) == false ) + return; color = g_ModuleTextNOVColor; - - if( (color & ITEM_NOT_SHOW) != 0 ) - return; + } /* If the text is mirrored : negate size.x (mirror / Y axis) */ if( m_Mirror ) diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index d2a758ffb4..5d98dd6db1 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -579,7 +579,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin { color = g_DesignSettings.m_LayerColor[m_Layer]; - if( ( color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG) ) == ITEM_NOT_SHOW ) + if( g_DesignSettings.IsLayerVisible( m_Layer ) == false && ( color & HIGHT_LIGHT_FLAG ) != HIGHT_LIGHT_FLAG ) return; if( DisplayOpt.ContrastModeDisplay ) @@ -743,7 +743,7 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi color = g_DesignSettings.m_ViaColor[m_Shape]; - if( ( color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG) ) == ITEM_NOT_SHOW ) + if( g_DesignSettings.IsElementVisible( VIAS_VISIBLE + m_Shape ) == false && ( color & HIGHT_LIGHT_FLAG ) != HIGHT_LIGHT_FLAG ) return; if( DisplayOpt.ContrastModeDisplay ) diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 77c8f5e422..a40d7d3096 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -450,7 +450,7 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, con int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; int color = g_DesignSettings.m_LayerColor[m_Layer]; - if( ( color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG) ) == ITEM_NOT_SHOW ) + if( g_DesignSettings.IsLayerVisible( m_Layer ) == false && ( color & HIGHT_LIGHT_FLAG ) != HIGHT_LIGHT_FLAG ) return; GRSetDrawMode( DC, draw_mode ); @@ -538,7 +538,7 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; int color = g_DesignSettings.m_LayerColor[m_Layer]; - if( ( color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG) ) == ITEM_NOT_SHOW ) + if( g_DesignSettings.IsLayerVisible( m_Layer ) == false && ( color & HIGHT_LIGHT_FLAG ) != HIGHT_LIGHT_FLAG ) return; GRSetDrawMode( DC, aDrawMode ); diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index 5672c36ed3..a1bf1b068f 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -137,32 +137,32 @@ bool PCB_SCREEN::IsMicroViaAcceptable( void ) DISPLAY_OPTIONS::DISPLAY_OPTIONS() { - DisplayPadFill = FILLED; - DisplayViaFill = FILLED; - DisplayPadNum = true; - DisplayPadNoConn = true; - DisplayPadIsol = true; + DisplayPadFill = FILLED; + DisplayViaFill = FILLED; + DisplayPadNum = true; + DisplayPadNoConn = true; + DisplayPadIsol = true; - DisplayModEdge = true; - DisplayModText = true; - DisplayPcbTrackFill = true; /* false = sketch , true = filled */ - ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS; - m_DisplayViaMode = VIA_HOLE_NOT_SHOW; + DisplayModEdge = true; + DisplayModText = true; + DisplayPcbTrackFill = true; /* false = sketch , true = filled */ + ShowTrackClearanceMode = SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS; + m_DisplayViaMode = VIA_HOLE_NOT_SHOW; - DisplayPolarCood = false; /* false = display absolute coordinates, - * true = display polar cordinates */ - DisplayZonesMode = 0; /* 0 = Show filled areas outlines in zones, - * 1 = do not show filled areas outlines - * 2 = show outlines of filled areas */ - DisplayNetNamesMode = 3; /* 0 do not show netnames, - * 1 show netnames on pads - * 2 show netnames on tracks - * 3 show netnames on tracks and pads */ - Show_Modules_Cmp = true; - Show_Modules_Cu = true; + DisplayPolarCood = false; /* false = display absolute coordinates, + * true = display polar cordinates */ + DisplayZonesMode = 0; /* 0 = Show filled areas outlines in zones, + * 1 = do not show filled areas outlines + * 2 = show outlines of filled areas */ + DisplayNetNamesMode = 3; /* 0 do not show netnames, + * 1 show netnames on pads + * 2 show netnames on tracks + * 3 show netnames on tracks and pads */ + Show_Modules_Cmp = true; + Show_Modules_Cu = true; - DisplayDrawItems = true; - ContrastModeDisplay = false; + DisplayDrawItems = true; + ContrastModeDisplay = false; } @@ -213,23 +213,30 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings() m_MicroViasMinSize = 200; // micro vias (not vias) min diameter m_MaskMargin = 150; // Solder mask margin /* Color options for screen display of the Printed Board: */ - m_PcbGridColor = DARKGRAY; // Grid color + + +//@@IMB: Not used m_PcbGridColor = DARKGRAY; // Grid color + + m_EnabledLayers = 0x1fffffff; // IMB: All layers enabled at first. TODO: Use a macro for the initial value. + m_VisibleLayers = 0xffffffff; // IMB: All layers visible at first. TODO: Use a macro for the initial value. + m_VisibleElements = 0x00000fff; // IMB: All elements visible at first. TODO: Use a macro for the initial value. for( ii = 0; ii < 32; ii++ ) m_LayerColor[ii] = default_layer_color[ii]; // Layer colors (tracks and graphic items) - m_ViaColor[VIA_NOT_DEFINED] = DARKGRAY; - m_ViaColor[VIA_MICROVIA] = CYAN; - m_ViaColor[VIA_BLIND_BURIED] = BROWN; - m_ViaColor[VIA_THROUGH] = WHITE; + m_ViaColor[VIA_NOT_DEFINED] = DARKGRAY; + m_ViaColor[VIA_MICROVIA] = CYAN; + m_ViaColor[VIA_BLIND_BURIED] = BROWN; + m_ViaColor[VIA_THROUGH] = WHITE; + +//@@IMB: Not used m_ModuleTextCMPColor = LIGHTGRAY; // Text module color for modules on the COMPONENT layer +//@@IMB: Not used m_ModuleTextCUColor = MAGENTA; // Text module color for modules on the COPPER layer +//@@IMB: Not used m_ModuleTextNOVColor = DARKGRAY; // Text module color for "invisible" texts (must be BLACK if really not displayed) +//@@IMB: Not used m_AnchorColor = BLUE; // Anchor color for modules and texts +//@@IMB: Not used m_PadCUColor = GREEN; // Pad color for the COMPONENT side of the pad +//@@IMB: Not used m_PadCMPColor = RED; // Pad color for the COPPER side of the pad - m_ModuleTextCMPColor = LIGHTGRAY; // Text module color for modules on the COMPONENT layer - m_ModuleTextCUColor = MAGENTA; // Text module color for modules on the COPPER layer - m_ModuleTextNOVColor = DARKGRAY; // Text module color for "invisible" texts (must be BLACK if really not displayed) - m_AnchorColor = BLUE; // Anchor color for modules and texts - m_PadCUColor = GREEN; // Pad color for the COMPONENT side of the pad - m_PadCMPColor = RED; // Pad color for the COPPER side of the pad m_RatsnestColor = WHITE; // Ratsnest color } @@ -237,13 +244,48 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings() // see pcbstruct.h int EDA_BoardDesignSettings::GetVisibleLayers() const { - int layerMask = 0; - - for( int i = 0, mask = 1; i< 32; ++i, mask <<= 1 ) - { - if( !( m_LayerColor[i] & ITEM_NOT_SHOW ) ) - layerMask |= mask; - } - - return layerMask; + return m_VisibleLayers; +} + +void EDA_BoardDesignSettings::SetVisibleLayers( int Mask ) +{ + m_VisibleLayers = Mask & 0x1fffffff; +} + +/* //@@IMB: Made inline +bool EDA_BoardDesignSettings::IsLayerVisible( int LayerNumber ) const +{ + if( LayerNumber < 0 || LayerNumber >= 32 ) //@@IMB: Altough Pcbnew uses only 29, Gerbview uses all 32 layers + return false; + return (bool)( m_VisibleLayers & 1 << LayerNumber ); +} +*/ + +void EDA_BoardDesignSettings::SetLayerVisibility( int LayerNumber, bool State ) +{ + if( LayerNumber < 0 || LayerNumber >= 32 ) //@@IMB: Altough Pcbnew uses only 29, Gerbview uses all 32 layers + return; + if( State ) + m_VisibleLayers |= 1 << LayerNumber; + else + m_VisibleLayers &= ~( 1 << LayerNumber ); +} + +/* //@@IMB: Made inline +bool EDA_BoardDesignSettings::IsElementVisible( int ElementNumber ) const +{ + if( ElementNumber < 0 || ElementNumber > PAD_CMP_VISIBLE ) + return false; + return (bool)( m_VisibleElements & 1 << ElementNumber ); +} +*/ + +void EDA_BoardDesignSettings::SetElementVisibility( int ElementNumber, bool State ) +{ + if( ElementNumber < 0 || ElementNumber > PAD_CMP_VISIBLE ) + return; + if( State ) + m_VisibleElements |= 1 << ElementNumber; + else + m_VisibleElements &= ~( 1 << ElementNumber ); } diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index ac88639f91..bf20586a58 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -420,7 +420,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, if( doCheckNet && currTrack && currTrack->GetNet() != track->GetNet() ) continue; - if( g_DesignSettings.m_LayerColor[track->GetLayer()] & ITEM_NOT_SHOW ) + if( g_DesignSettings.IsLayerVisible( track->GetLayer() ) == false ) continue; // omit the layer check if moving a via diff --git a/pcbnew/dialog_general_options.cpp b/pcbnew/dialog_general_options.cpp index d82f5d535c..9569f17b9b 100644 --- a/pcbnew/dialog_general_options.cpp +++ b/pcbnew/dialog_general_options.cpp @@ -294,10 +294,8 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) DrawPanel->Refresh( ); break; case ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE: - if(!m_OptionsToolBar->GetToolState( id )) - g_ModuleTextNOVColor &= (~ITEM_NOT_SHOW); - else - g_ModuleTextNOVColor |= ( ITEM_NOT_SHOW); + g_DesignSettings.SetElementVisibility( MODULE_TEXT_NOV_VISIBLE, + m_OptionsToolBar->GetToolState( id )); DrawPanel->Refresh( ); break; diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index bd143cd5f0..d8f57c4357 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -189,6 +189,42 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum ) if( strnicmp( data, "$EndGENERAL", 10 ) == 0 ) break; + if( stricmp( data, "EnabledLayers" ) == 0 ) + { + int EnabledLayers = 0; + data = strtok( NULL, " =\n\r" ); + sscanf( data, "%X", &EnabledLayers ); + + // Setup layer visibility + GetBoard()->m_BoardSettings->m_EnabledLayers = EnabledLayers; + + continue; + } + + if( stricmp( data, "VisibleLayers" ) == 0 ) + { + int VisibleLayers = 0; + data = strtok( NULL, " =\n\r" ); + sscanf( data, "%X", &VisibleLayers ); + + // Setup layer visibility + GetBoard()->m_BoardSettings->m_VisibleLayers = VisibleLayers; + + continue; + } + + if( stricmp( data, "VisibleElements" ) == 0 ) + { + int VisibleElements = 0; + data = strtok( NULL, " =\n\r" ); + sscanf( data, "%X", &VisibleElements ); + + // Setup elements visibility + GetBoard()->m_BoardSettings->m_VisibleElements = VisibleElements; + + continue; + } + if( strncmp( data, "Ly", 2 ) == 0 ) // Old format for Layer count { int Masque_Layer = 1, ii; @@ -629,6 +665,9 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File ) // Write old format for Layer count (for compatibility with old versions of pcbnew fprintf( File, "Ly %8X\n", g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS ); // For compatibility with old version of pcbnew + fprintf( File, "EnabledLayers %08X\n", GetBoard()->m_BoardSettings->m_EnabledLayers ); + fprintf( File, "VisibleLayers %08X\n", GetBoard()->m_BoardSettings->m_VisibleLayers ); + fprintf( File, "VisibleElements %08X\n", GetBoard()->m_BoardSettings->m_VisibleElements ); fprintf( File, "Links %d\n", GetBoard()->GetRatsnestsCount() ); fprintf( File, "NoConn %d\n", GetBoard()->m_NbNoconnect ); diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp index 16cadd9c1b..a9506255e8 100644 --- a/pcbnew/locate.cpp +++ b/pcbnew/locate.cpp @@ -506,7 +506,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLa continue; } - if( g_DesignSettings.m_LayerColor[layer] & ITEM_NOT_SHOW ) + if( g_DesignSettings.IsLayerVisible( layer ) == false ) continue; if( track->Type() == TYPE_VIA ) /* VIA rencontree */ diff --git a/pcbnew/pcbcfg.cpp b/pcbnew/pcbcfg.cpp index 7d3d197f50..c55eedb89a 100644 --- a/pcbnew/pcbcfg.cpp +++ b/pcbnew/pcbcfg.cpp @@ -186,25 +186,29 @@ bool Read_Config( const wxString& projectFileName ) /* User library path takes precedent over default library search paths. */ wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 ); - /* Reset the ITEM_NOT_SHOW flag when loading a new config - * Because it could creates SERIOUS mistakes for the user, + /* Reset the ITEM*NOT*SHOW flag when loading a new config + * Because it could creates SERIOUS mistakes for the user, * if some items are not visible after loading a board... - */ + */ for( ii = 0; ii < LAYER_COUNT; ii++ ) - g_DesignSettings.m_LayerColor[ii] &= ~ ITEM_NOT_SHOW; + g_DesignSettings.SetLayerVisibility( ii, true ); + DisplayOpt.Show_Modules_Cmp = true; DisplayOpt.Show_Modules_Cu = true; - g_ModuleTextNOVColor &= ~ ITEM_NOT_SHOW; - g_ModuleTextCMPColor &= ~ ITEM_NOT_SHOW; - g_ModuleTextCUColor &= ~ ITEM_NOT_SHOW; - g_PadCMPColor &= ~ ITEM_NOT_SHOW; - g_PadCUColor &= ~ ITEM_NOT_SHOW; - g_DesignSettings.m_ViaColor[VIA_THROUGH] &= ~ ITEM_NOT_SHOW; - g_DesignSettings.m_ViaColor[VIA_BLIND_BURIED] &= ~ ITEM_NOT_SHOW; - g_DesignSettings.m_ViaColor[VIA_MICROVIA] &= ~ ITEM_NOT_SHOW; + // These parameters could be left in their previous state, or resetted // Comment or uncomment to keep or reset this option after loading a board - g_AnchorColor &= ~ ITEM_NOT_SHOW; + + g_DesignSettings.SetElementVisibility( MODULE_TEXT_NOV_VISIBLE, true ); + g_DesignSettings.SetElementVisibility( MODULE_TEXT_CMP_VISIBLE, true ); + g_DesignSettings.SetElementVisibility( MODULE_TEXT_CU_VISIBLE, true ); + g_DesignSettings.SetElementVisibility( PAD_CMP_VISIBLE, true ); + g_DesignSettings.SetElementVisibility( PAD_CU_VISIBLE, true ); + g_DesignSettings.SetElementVisibility( VIA_THROUGH_VISIBLE, true ); + g_DesignSettings.SetElementVisibility( VIA_BLIND_BURIED_VISIBLE, true ); + g_DesignSettings.SetElementVisibility( VIA_MICROVIA_VISIBLE, true ); + g_DesignSettings.SetElementVisibility( ANCHOR_VISIBLE, true ); + DisplayOpt.DisplayPadNoConn = true; return TRUE; } diff --git a/pcbnew/set_color.cpp b/pcbnew/set_color.cpp index c91731bbd5..0ecf018ba6 100644 --- a/pcbnew/set_color.cpp +++ b/pcbnew/set_color.cpp @@ -210,32 +210,47 @@ void WinEDA_SetColorsFrame::CreateControls() RowBoxSizer->Add(BUTT_SIZE_X, BUTT_SIZE_Y, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5); } + //--------------------------------------------------------------- // Note: When setting texts, we must call wxGetTranslation( ) for all statically created texts // if we want them translated - if( laytool_list[lyr]->m_LayerNumber >= 0 ) + switch( laytool_list[lyr]->m_Type ) { - if( laytool_list[lyr]->m_Title == wxT( "*" ) ) - msg = wxGetTranslation( g_ViaType_Name[laytool_list[lyr]->m_LayerNumber]); - else + case type_layer: msg = m_Parent->GetBoard()->GetLayerName( laytool_list[lyr]->m_LayerNumber ); - } - else - msg = wxGetTranslation( laytool_list[lyr]->m_Title ); + break; + case type_via: + msg = wxGetTranslation( g_ViaType_Name[laytool_list[lyr]->m_LayerNumber] ); + break; + + default: + msg = wxGetTranslation( laytool_list[lyr]->m_Title ); + break; + } + + //--------------------------------------------------------------- CheckBox = new wxCheckBox( this, ID_COLOR_CHECKBOX_ONOFF, msg, wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); laytool_list[lyr]->m_CheckBox = CheckBox; - if( laytool_list[lyr]->m_NoDisplayIsColor ) + //--------------------------------------------------------------- + + switch( laytool_list[lyr]->m_Type ) { - if( *laytool_list[lyr]->m_Color & ITEM_NOT_SHOW ) - CheckBox->SetValue( FALSE ); - else - CheckBox->SetValue( TRUE ); + case type_layer: + CheckBox->SetValue( g_DesignSettings.IsLayerVisible( laytool_list[lyr]->m_LayerNumber )); + break; + + case type_via: + case type_element: + CheckBox->SetValue( g_DesignSettings.IsElementVisible( laytool_list[lyr]->m_LayerNumber )); + break; + + case type_visual: + CheckBox->SetValue( *laytool_list[lyr]->m_NoDisplay ); + break; } - else if( laytool_list[lyr]->m_NoDisplay ) - CheckBox->SetValue( *laytool_list[lyr]->m_NoDisplay ); RowBoxSizer->Add(CheckBox, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5); @@ -457,26 +472,31 @@ void WinEDA_SetColorsFrame::UpdateLayerSettings() { for( int lyr = 0; lyr < NB_BUTT; lyr++ ) { - if( laytool_list[lyr]->m_NoDisplayIsColor ) + if( laytool_list[lyr]->m_Color ) + *laytool_list[lyr]->m_Color = CurrentColor[lyr]; + switch( laytool_list[lyr]->m_Type ) { - if( laytool_list[lyr]->m_CheckBox->GetValue() ) - *laytool_list[lyr]->m_Color = CurrentColor[lyr] & ~ITEM_NOT_SHOW; - else - *laytool_list[lyr]->m_Color = CurrentColor[lyr] | ITEM_NOT_SHOW; - } - else - { - if( laytool_list[lyr]->m_Color ) - *laytool_list[lyr]->m_Color = CurrentColor[lyr]; + case type_layer: + g_DesignSettings.SetLayerVisibility( laytool_list[lyr]->m_LayerNumber, + laytool_list[lyr]->m_CheckBox->GetValue() ); + break; - *laytool_list[lyr]->m_NoDisplay = laytool_list[lyr]->m_CheckBox->GetValue(); + case type_via: + case type_element: + g_DesignSettings.SetElementVisibility( laytool_list[lyr]->m_LayerNumber, + laytool_list[lyr]->m_CheckBox->GetValue() ); + break; + + case type_visual: + *laytool_list[lyr]->m_NoDisplay = laytool_list[lyr]->m_CheckBox->GetValue(); + break; } } + // Additional command required for updating visibility of grid. m_Parent->m_Draw_Grid = s_showGrid; } - /**********************************************************************/ void WinEDA_SetColorsFrame::ResetDisplayLayersCu( wxCommandEvent& event ) /**********************************************************************/ @@ -487,11 +507,6 @@ void WinEDA_SetColorsFrame::ResetDisplayLayersCu( wxCommandEvent& event ) for( int lyr = 0; lyr < 16; lyr++ ) { -// if( laytool_list[lyr]->m_CheckBox ) -// laytool_list[lyr]->m_CheckBox->SetValue( NewState ); - - // (As checkboxes are actually provided for *all* of these layers, - // the following (simpler) command can be used instead.) laytool_list[lyr]->m_CheckBox->SetValue( NewState ); } } diff --git a/pcbnew/set_color.h b/pcbnew/set_color.h index af87c9aa13..2fa545c404 100644 --- a/pcbnew/set_color.h +++ b/pcbnew/set_color.h @@ -53,12 +53,22 @@ const int BUTT_SIZE_Y = 20; /**********************************/ /* Liste des menus de Menu_Layers */ /**********************************/ + +enum button_types +{ + type_layer, + type_via, + type_element, + type_visual +}; + + struct ColorButton { + int m_Type; /// const wxString m_Title; int m_LayerNumber; int* m_Color; ///< pointer to color variable to manipulate - bool m_NoDisplayIsColor; ///< TRUE if bit ITEM_NOT_SHOW of the color variable should be manipulated bool* m_NoDisplay; ///< pointer to the on/off display control variable, if it is not the color variable int m_Id; @@ -82,130 +92,130 @@ static ButtonIndex Msg_Layers_Cu = static ColorButton Layer_1_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, COPPER_LAYER_N, // Layer - ADR( COPPER_LAYER_N ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( COPPER_LAYER_N ) // Address of optional parameter }; static ColorButton Layer_2_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 1, // Layer - ADR( 1 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 1 ) // Address of optional parameter }; static ColorButton Layer_3_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 2, // Layer - ADR( 2 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 2 ) // Address of optional parameter }; static ColorButton Layer_4_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 3, // Layer - ADR( 3 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 3 ) // Address of optional parameter }; static ColorButton Layer_5_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 4, // Layer - ADR( 4 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 4 ) // Address of optional parameter }; static ColorButton Layer_6_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 5, // Layer - ADR( 5 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 5 ) // Address of optional parameter }; static ColorButton Layer_7_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 6, // Layer - ADR( 6 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 6 ) // Address of optional parameter }; static ColorButton Layer_8_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 7, // Layer - ADR( 7 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 7 ) // Address of optional parameter }; static ColorButton Layer_9_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 8, // Layer - ADR( 8 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 8 ) // Address of optional parameter }; static ColorButton Layer_10_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 9, // Layer - ADR( 9 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 9 ) // Address of optional parameter }; static ColorButton Layer_11_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 10, // Layer - ADR( 10 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 10 ) // Address of optional parameter }; static ColorButton Layer_12_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 11, // Layer - ADR( 11 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 11 ) // Address of optional parameter }; static ColorButton Layer_13_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 12, // Layer - ADR( 12 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 12 ) // Address of optional parameter }; static ColorButton Layer_14_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 13, // Layer - ADR( 13 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 13 ) // Address of optional parameter }; static ColorButton Layer_15_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, 14, // Layer - ADR( 14 ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( 14 ) // Address of optional parameter }; static ColorButton Layer_16_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, CMP_N, // Layer - ADR( CMP_N ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( CMP_N ) // Address of optional parameter }; @@ -217,106 +227,106 @@ static ButtonIndex Msg_Layers_Tech = static ColorButton Layer_17_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, ADHESIVE_N_CU, // Layer - ADR( ADHESIVE_N_CU ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( ADHESIVE_N_CU ) // Address of optional parameter }; static ColorButton Layer_18_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, ADHESIVE_N_CMP, // Layer - ADR( ADHESIVE_N_CMP ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( ADHESIVE_N_CMP ) // Address of optional parameter }; static ColorButton Layer_19_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, SOLDERPASTE_N_CU, // Layer - ADR( SOLDERPASTE_N_CU ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( SOLDERPASTE_N_CU ) // Address of optional parameter }; static ColorButton Layer_20_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, SOLDERPASTE_N_CMP, // Layer ADR( SOLDERPASTE_N_CMP ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable }; static ColorButton Layer_21_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, SILKSCREEN_N_CU, // Layer - ADR( SILKSCREEN_N_CU ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( SILKSCREEN_N_CU ) // Address of optional parameter }; static ColorButton Layer_22_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, SILKSCREEN_N_CMP, // Layer - ADR( SILKSCREEN_N_CMP ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( SILKSCREEN_N_CMP ) // Address of optional parameter }; static ColorButton Layer_23_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, SOLDERMASK_N_CU, // Layer - ADR( SOLDERMASK_N_CU ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( SOLDERMASK_N_CU ) // Address of optional parameter }; static ColorButton Layer_24_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, SOLDERMASK_N_CMP, // Layer - ADR( SOLDERMASK_N_CMP ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( SOLDERMASK_N_CMP ) // Address of optional parameter }; static ColorButton Layer_25_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, DRAW_N, // Layer - ADR( DRAW_N ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( DRAW_N ) // Address of optional parameter }; static ColorButton Layer_26_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, COMMENT_N, // Layer - ADR( COMMENT_N ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( COMMENT_N ) // Address of optional parameter }; static ColorButton Layer_27_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, ECO1_N, // Layer - ADR( ECO1_N ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( ECO1_N ) // Address of optional parameter }; static ColorButton Layer_28_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, ECO2_N, // Layer - ADR( ECO2_N ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( ECO2_N ) // Address of optional parameter }; static ColorButton Layer_29_Butt = { + type_layer, // Toggle ITEM_NOT_SHOW bit of the color variable wxEmptyString, EDGE_N, // Layer - ADR( EDGE_N ), // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ADR( EDGE_N ) // Address of optional parameter }; @@ -328,118 +338,118 @@ static ButtonIndex Msg_Others_Items = static ColorButton VIA_THROUGH_Butt = { - wxT( "*" ), + type_via, // Toggle ITEM_NOT_SHOW bit of the color variable + wxEmptyString, VIA_THROUGH, // Layer - &g_DesignSettings.m_ViaColor[VIA_THROUGH], // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + &g_DesignSettings.m_ViaColor[VIA_THROUGH] // Address of optional parameter }; static ColorButton VIA_BLIND_BURIED_Butt = { - wxT( "*" ), + type_via, // Toggle ITEM_NOT_SHOW bit of the color variable + wxEmptyString, VIA_BLIND_BURIED, // Layer - &g_DesignSettings.m_ViaColor[VIA_BLIND_BURIED], // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + &g_DesignSettings.m_ViaColor[VIA_BLIND_BURIED] // Address of optional parameter }; static ColorButton MICRO_VIA_Butt = { - wxT( "*" ), + type_via, // Toggle ITEM_NOT_SHOW bit of the color variable + wxEmptyString, VIA_MICROVIA, // Layer - &g_DesignSettings.m_ViaColor[VIA_MICROVIA], // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + &g_DesignSettings.m_ViaColor[VIA_MICROVIA] // Address of optional parameter }; static ColorButton Ratsnest_Butt = { + type_visual, _( "Ratsnest" ), // Title -1, &g_DesignSettings.m_RatsnestColor, // Address of optional parameter - FALSE, &g_Show_Ratsnest // Address of boolean display control parameter to toggle }; static ColorButton Pad_Cu_Butt = { + type_element, // Toggle ITEM_NOT_SHOW bit of the color variable _( "Pad Cu" ), // Title - -1, - &g_PadCUColor, // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + PAD_CU_VISIBLE, + &g_PadCUColor // Address of optional parameter }; static ColorButton Pad_Cmp_Butt = { + type_element, // Toggle ITEM_NOT_SHOW bit of the color variable _( "Pad Cmp" ), // Title - -1, - &g_PadCMPColor, // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + PAD_CMP_VISIBLE, + &g_PadCMPColor // Address of optional parameter }; static ColorButton Text_Mod_Cu_Butt = { + type_element, // Toggle ITEM_NOT_SHOW bit of the color variable _( "Text Module Cu" ), // Title - -1, - &g_ModuleTextCUColor, // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + MODULE_TEXT_CU_VISIBLE, + &g_ModuleTextCUColor // Address of optional parameter }; static ColorButton Text_Mod_Cmp_Butt = { + type_element, // Toggle ITEM_NOT_SHOW bit of the color variable _( "Text Module Cmp" ), // Title - -1, - &g_ModuleTextCMPColor, // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + MODULE_TEXT_CMP_VISIBLE, + &g_ModuleTextCMPColor // Address of optional parameter }; static ColorButton Text_Mod_NoVisible_Butt = { + type_element, // Toggle ITEM_NOT_SHOW bit of the color variable _( "Text Module invisible" ), // Title - -1, - &g_ModuleTextNOVColor, // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + MODULE_TEXT_NOV_VISIBLE, + &g_ModuleTextNOVColor // Address of optional parameter }; static ColorButton Anchors_Butt = { + type_element, // Toggle ITEM_NOT_SHOW bit of the color variable _( "Anchors" ), // Title - -1, - &g_AnchorColor, // Address of optional parameter - TRUE // Toggle ITEM_NOT_SHOW bit of the color variable + ANCHOR_VISIBLE, + &g_AnchorColor // Address of optional parameter }; static ColorButton Grid_Butt = { + type_visual, _( "Grid" ), // Title -1, &g_GridColor, // Address of optional parameter - FALSE, &s_showGrid // Address of boolean display control parameter to toggle }; static ColorButton Show_Pads_Noconnect_Butt = { + type_visual, _( "Show Noconnect" ), // Title -1, NULL, // Address of optional parameter - FALSE, &DisplayOpt.DisplayPadNoConn // Address of boolean display control parameter to toggle }; static ColorButton Show_Modules_Cmp_Butt = { + type_visual, _( "Show Modules Cmp" ), // Title -1, NULL, // Address of optional parameter - FALSE, &DisplayOpt.Show_Modules_Cmp // Address of boolean display control parameter to toggle }; static ColorButton Show_Modules_Cu_Butt = { + type_visual, _( "Show Modules Cu" ), // Title -1, NULL, // Address of optional parameter - FALSE, &DisplayOpt.Show_Modules_Cu // Address of boolean display control parameter to toggle }; diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index b23d806f21..58736620af 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -388,7 +388,7 @@ void WinEDA_PcbFrame::ReCreateOptToolbar() _( "Show Invisible Text" ), wxITEM_CHECK ); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE, - g_ModuleTextNOVColor & ITEM_NOT_SHOW ); + g_DesignSettings.IsElementVisible( MODULE_TEXT_NOV_VISIBLE )); #ifdef MUWAVE_ENBL diff --git a/pcbnew/toolbars_update_user_interface.cpp b/pcbnew/toolbars_update_user_interface.cpp index cdf9152d7e..98c4a29845 100644 --- a/pcbnew/toolbars_update_user_interface.cpp +++ b/pcbnew/toolbars_update_user_interface.cpp @@ -271,12 +271,14 @@ void WinEDA_PcbFrame::SetToolbars() DisplayOpt.ContrastModeDisplay ? _( "Normal contrast mode display" ) : _( "High contrast mode display" ) ); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE, - g_ModuleTextNOVColor & ITEM_NOT_SHOW ); + g_DesignSettings.IsElementVisible( MODULE_TEXT_NOV_VISIBLE ) ); m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE, - g_ModuleTextNOVColor & (ITEM_NOT_SHOW) ? - _( "Show invisible text" ) : - _( "Hide invisible text" ) ); + g_DesignSettings.IsElementVisible( MODULE_TEXT_NOV_VISIBLE ) ? + _( "Hide invisible text" ) : + _( "Show invisible text" ) ); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1, m_AuxVToolBar ? true : false ); }