From e8e6f1a77f5fc21a5902f507b9b4090097a691fa Mon Sep 17 00:00:00 2001 From: charras Date: Thu, 4 Jun 2009 19:39:50 +0000 Subject: [PATCH] code cleaning and very minor bugs fixed --- common/base_struct.cpp | 16 ++++++++-------- common/pcbcommon.cpp | 1 - gerbview/options.cpp | 2 +- gerbview/set_color.cpp | 8 ++++++-- gerbview/set_color.h | 2 +- include/base_struct.h | 8 ++++---- include/pcbcommon.h | 1 - pcbnew/dialog_general_options.cpp | 2 +- pcbnew/pcbcfg.cpp | 22 +++++++++++++++++++++- pcbnew/pcbcfg.h | 16 ++++++++-------- pcbnew/set_color.cpp | 7 ++++++- pcbnew/set_color.h | 4 +++- 12 files changed, 59 insertions(+), 30 deletions(-) diff --git a/common/base_struct.cpp b/common/base_struct.cpp index d16aa121f8..e768bdcaae 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -328,7 +328,7 @@ bool EDA_TextStruct::HitTest( EDA_Rect& refArea ) void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_Colors aColor, int aDrawMode, - GRFillMode aDisplayMode, EDA_Colors aAnchor_color ) + GRFillMode aFillMode, EDA_Colors aAnchor_color ) /***************************************************************/ /** Function Draw @@ -338,7 +338,7 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, * @param aOffset = draw offset (usually (0,0)) * @param EDA_Colors aColor = text color * @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode. - * @param aDisplayMode = FILAIRE, FILLED or SKETCH + * @param aFillMode = FILAIRE, FILLED or SKETCH * @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ). */ @@ -360,7 +360,7 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, aOffset, aColor, aDrawMode, - aDisplayMode, + aFillMode, aAnchor_color, txt, pos ); @@ -375,7 +375,7 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, aOffset, aColor, aDrawMode, - aDisplayMode, + aFillMode, aAnchor_color, m_Text, m_Pos ); @@ -390,7 +390,7 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, * @param aOffset = draw offset (usually (0,0)) * @param EDA_Colors aColor = text color * @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode. - * @param aDisplayMode = FILAIRE, FILLED or SKETCH + * @param aFillMode = FILAIRE, FILLED or SKETCH * @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ). * @param EDA_Colors aText = the single line of text to draw. * @param EDA_Colors aPos = the position of this line ). @@ -398,12 +398,12 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_Colors aColor, int aDrawMode, - GRFillMode aDisplayMode, EDA_Colors aAnchor_color, + GRFillMode aFillMode, EDA_Colors aAnchor_color, wxString& aText, wxPoint aPos ) { int width = m_Width; - if( aDisplayMode == FILAIRE ) + if( aFillMode == FILAIRE ) width = 0; if( aDrawMode != -1 ) @@ -425,7 +425,7 @@ void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC, cX, cY + anchor_size, 0, aAnchor_color ); } - if( aDisplayMode == SKETCH ) + if( aFillMode == SKETCH ) width = -width; wxSize size = m_Size; diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index cc5a24036b..5de35b6f07 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -69,7 +69,6 @@ wxArrayString g_LibName_List; // library list to load BOARD_ITEM* g_UnDeleteStack[UNDELETE_STACK_SIZE]; // Linked list of deleted items int g_UnDeleteStackPtr; -bool g_ShowGrid = true; DISPLAY_OPTIONS DisplayOpt; /* Display options for board items */ diff --git a/gerbview/options.cpp b/gerbview/options.cpp index 48be122e97..550a8d1d7c 100644 --- a/gerbview/options.cpp +++ b/gerbview/options.cpp @@ -36,7 +36,7 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event ) switch( id ) { case ID_TB_OPTIONS_SHOW_GRID: - m_Draw_Grid = g_ShowGrid = m_OptionsToolBar->GetToolState( id ); + m_Draw_Grid = m_OptionsToolBar->GetToolState( id ); DrawPanel->Refresh( TRUE ); break; diff --git a/gerbview/set_color.cpp b/gerbview/set_color.cpp index e49c17d821..db52298b51 100644 --- a/gerbview/set_color.cpp +++ b/gerbview/set_color.cpp @@ -19,6 +19,9 @@ #include "protos.h" +// variable used to handle grid visibility: +bool s_showGrid; + #include "set_color.h" // Header file associated with this file // Local variables: @@ -132,6 +135,7 @@ void WinEDA_SetColorsFrame::CreateControls() // Add various items to the dialog box, as determined by the // details of each element contained within laytool_list[] + s_showGrid = m_Parent->m_Draw_Grid; for( lyr = 0, cln = 0; lyr < NB_BUTT; lyr++ ) { // Look for the first set of controls within each column. @@ -441,8 +445,8 @@ void WinEDA_SetColorsFrame::UpdateLayerSettings() *laytool_list[lyr]->m_NoDisplay = laytool_list[lyr]->m_CheckBox->GetValue(); } } - // Additional command required for updating visibility of grid. - m_Parent->m_Draw_Grid = g_ShowGrid; + // 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 300732c2d5..4c0a7d6afb 100644 --- a/gerbview/set_color.h +++ b/gerbview/set_color.h @@ -324,7 +324,7 @@ static ColorButton Grid_Butt= _("Grid"), // Title &g_GridColor, // Address of optional parameter FALSE, - &g_ShowGrid // Address of boolean display control parameter to toggle + &s_showGrid // Address of boolean display control parameter to toggle }; static ColorButton Show_DCodes_Butt= diff --git a/include/base_struct.h b/include/base_struct.h index e813709fab..4ca494b078 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -513,13 +513,13 @@ public: * @param aDC = the current Device Context * @param aOffset = draw offset (usually (0,0)) * @param EDA_Colors aColor = text color - * @param aDraw_mode = GR_OR, GR_XOR.., -1 to use the current mode. + * @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode. * @param GRFillMode aDisplay_mode = FILAIRE, FILLED or SKETCH * @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ). */ void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_Colors aColor, - int aDisplayMode, GRFillMode aDisplay_mode = FILAIRE, + int aDrawMode, GRFillMode aDisplay_mode = FILAIRE, EDA_Colors aAnchor_color = UNSPECIFIED_COLOR ); private: @@ -531,14 +531,14 @@ private: * @param aOffset = draw offset (usually (0,0)) * @param EDA_Colors aColor = text color * @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode. - * @param aDisplayMode = FILAIRE, FILLED or SKETCH + * @param aFillMode = FILAIRE, FILLED or SKETCH * @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ). * @param EDA_Colors aText = the single line of text to draw. * @param EDA_Colors aPos = the position of this line ). */ void DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_Colors aColor, - int aDisplayMode, GRFillMode aDisplay_mode, + int aDrawMode, GRFillMode aFillMode, EDA_Colors aAnchor_color, wxString& aText, wxPoint aPos ); public: diff --git a/include/pcbcommon.h b/include/pcbcommon.h index f5d930f097..7cd1a63e90 100644 --- a/include/pcbcommon.h +++ b/include/pcbcommon.h @@ -23,7 +23,6 @@ extern int g_TabAllCopperLayerMask[NB_COPPER_LAYERS]; extern wxArrayString g_LibName_List; // library list to load -extern bool g_ShowGrid; extern BOARD_ITEM* g_UnDeleteStack[UNDELETE_STACK_SIZE]; extern int g_UnDeleteStackPtr; extern DISPLAY_OPTIONS DisplayOpt; diff --git a/pcbnew/dialog_general_options.cpp b/pcbnew/dialog_general_options.cpp index d41d6a19d8..2076523fe0 100644 --- a/pcbnew/dialog_general_options.cpp +++ b/pcbnew/dialog_general_options.cpp @@ -320,7 +320,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) break; case ID_TB_OPTIONS_SHOW_GRID: - m_Draw_Grid = g_ShowGrid = m_OptionsToolBar->GetToolState( id ); + m_Draw_Grid = m_OptionsToolBar->GetToolState( id ); DrawPanel->Refresh( ); break; diff --git a/pcbnew/pcbcfg.cpp b/pcbnew/pcbcfg.cpp index 9e44b9ac3b..9812015170 100644 --- a/pcbnew/pcbcfg.cpp +++ b/pcbnew/pcbcfg.cpp @@ -182,7 +182,7 @@ file extension to a Kicad project file extension (.pro)." ), /* User library path takes precedent over default library search paths. */ wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 ); - /* Traitement des variables particulieres: */ + /* Some parameters must be reinitialize after loading a new board or config: */ g_DesignSettings.m_TrackWidthHistory[0] = g_DesignSettings.m_CurrentTrackWidth; g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize; @@ -192,6 +192,26 @@ file extension to a Kicad project file extension (.pro)." ), g_DesignSettings.m_ViaSizeHistory[ii] = 0; } + /* 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; + 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; + DisplayOpt.DisplayPadNoConn = true; return TRUE; } diff --git a/pcbnew/pcbcfg.h b/pcbnew/pcbcfg.h index 5154c20aa6..ea0ded673d 100644 --- a/pcbnew/pcbcfg.h +++ b/pcbnew/pcbcfg.h @@ -210,11 +210,11 @@ static PARAM_CFG_BOOL TrackAfficheGardeCfg FALSE /* Default value */ ); -static PARAM_CFG_INT PadFillCfg +static PARAM_CFG_BOOL PadFillCfg ( INSETUP, wxT( "PadFill" ), /* Keyword */ - (int*)&DisplayOpt.DisplayPadFill, /* Parameter address */ + &DisplayOpt.DisplayPadFill, /* Parameter address */ TRUE /* Default value */ ); @@ -252,7 +252,7 @@ static PARAM_CFG_INT AfficheTexteModuleCfg // Module Texts: fill/line/sketch 0, 2 /* Min and max values*/ ); -static PARAM_CFG_INT AfficheTextePcbCfg // PCB Texts: fill/line/sketch +static PARAM_CFG_INT AffichePcbTextCfg // PCB Texts: fill/line/sketch ( INSETUP, wxT( "PcbAffT" ), /* Keyword */ @@ -268,7 +268,7 @@ static PARAM_CFG_BOOL SegmPcb45Cfg // Force 45 degrees for segments TRUE /* Default value */ ); -static PARAM_CFG_INT TextePcbDimVCfg +static PARAM_CFG_INT PcbTextDimVCfg ( wxT( "TxtPcbV" ), /* Keyword */ &g_DesignSettings.m_PcbTextSize.y, /* Parameter address */ @@ -276,7 +276,7 @@ static PARAM_CFG_INT TextePcbDimVCfg TEXTS_MIN_SIZE, TEXTS_MAX_SIZE /* Min and max values*/ ); -static PARAM_CFG_INT TextePcbDimHCfg +static PARAM_CFG_INT PcbTextDimHCfg ( wxT( "TxtPcbH" ), /* Keyword */ &g_DesignSettings.m_PcbTextSize.x, /* Parameter address */ @@ -823,10 +823,10 @@ PARAM_CFG_BASE* ParamCfgList[] = &PadShowNumCfg, &AfficheContourModuleCfg, &AfficheTexteModuleCfg, - &AfficheTextePcbCfg, + &AffichePcbTextCfg, &SegmPcb45Cfg, - &TextePcbDimVCfg, - &TextePcbDimHCfg, + &PcbTextDimVCfg, + &PcbTextDimHCfg, &ColorLayer0Cfg, &ColorLayer1Cfg, &ColorLayer2Cfg, diff --git a/pcbnew/set_color.cpp b/pcbnew/set_color.cpp index 96131638f3..b15f6465b1 100644 --- a/pcbnew/set_color.cpp +++ b/pcbnew/set_color.cpp @@ -17,6 +17,9 @@ #include "pcbnew.h" #include "protos.h" +// temporary variable used to handle grid visibility: +bool s_showGrid; + #include "set_color.h" // Header file associated with this file // Local variables: @@ -129,6 +132,8 @@ void WinEDA_SetColorsFrame::CreateControls() MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); OuterBoxSizer->Add(MainBoxSizer, 1, wxGROW|wxLEFT|wxRIGHT, 5); + s_showGrid = m_Parent->m_Draw_Grid; + // Add various items to the dialog box, as determined by the // details of each element contained within laytool_list[] for( lyr = 0, cln = 0; lyr < NB_BUTT; lyr++ ) @@ -470,7 +475,7 @@ void WinEDA_SetColorsFrame::UpdateLayerSettings() } } // Additional command required for updating visibility of grid. - m_Parent->m_Draw_Grid = g_ShowGrid; + m_Parent->m_Draw_Grid = s_showGrid; } diff --git a/pcbnew/set_color.h b/pcbnew/set_color.h index 4aa71e7691..2e4a60045e 100644 --- a/pcbnew/set_color.h +++ b/pcbnew/set_color.h @@ -16,6 +16,8 @@ class wxFlexGridSizer; class wxStaticLine; class wxStdDialogButtonSizer; +// variable used to handle grid visibility: +extern bool s_showGrid; // Specify how many elements are contained within laytool_list[] const int NB_BUTT = 43; @@ -415,7 +417,7 @@ static ColorButton Grid_Butt = -1, &g_GridColor, // Address of optional parameter FALSE, - &g_ShowGrid // Address of boolean display control parameter to toggle + &s_showGrid // Address of boolean display control parameter to toggle }; static ColorButton Show_Pads_Noconnect_Butt =