From e027e659711e12ed81937a5e931d81c1c331b41e Mon Sep 17 00:00:00 2001 From: charras Date: Wed, 28 Oct 2009 11:48:47 +0000 Subject: [PATCH] code and files cleanup --- 3d-viewer/3d_draw.cpp | 5 +- common/CMakeLists.txt | 1 + common/pcbcommon.cpp | 2 +- gerbview/CMakeLists.txt | 3 +- gerbview/export_to_pcbnew.cpp | 7 +- gerbview/gerbview_config.cpp | 1 + gerbview/select_layers_to_pcb.cpp | 28 +- gerbview/set_color.cpp | 3 +- gerbview/tracepcb.cpp | 288 +++++++++++++++- gerbview/trpiste.cpp | 287 ---------------- include/class_board_design_settings.h | 182 ++++++++++ include/pcbstruct.h | 177 +--------- pcbnew/autoplac.cpp | 1 + pcbnew/autorout.cpp | 3 +- pcbnew/basepcbframe.cpp | 7 +- pcbnew/class_board.cpp | 3 +- pcbnew/class_board_design_settings.cpp | 122 +++++++ pcbnew/class_cotation.cpp | 1 + pcbnew/class_drawsegment.cpp | 1 + pcbnew/class_edge_mod.cpp | 6 +- pcbnew/class_mire.cpp | 1 + pcbnew/class_module.cpp | 1 + pcbnew/class_netclass.cpp | 1 + pcbnew/class_netinfo_item.cpp | 1 + pcbnew/class_pad_draw_functions.cpp | 1 + pcbnew/class_pcb_text.cpp | 1 + pcbnew/class_text_mod.cpp | 7 +- pcbnew/class_track.cpp | 9 +- pcbnew/class_zone.cpp | 1 + pcbnew/classpcb.cpp | 112 +------ pcbnew/cotation.cpp | 1 + pcbnew/dialog_copper_layers_setup.cpp | 216 ------------ pcbnew/dialog_copper_layers_setup.h | 36 -- pcbnew/dialog_copper_layers_setup_base.cpp | 116 ------- pcbnew/dialog_copper_layers_setup_base.fbp | 349 -------------------- pcbnew/dialog_copper_layers_setup_base.h | 60 ---- pcbnew/dialog_design_rules.cpp | 1 + pcbnew/dialog_drc.cpp | 1 + pcbnew/dialog_general_options.cpp | 5 +- pcbnew/dialog_graphic_item_properties.cpp | 1 + pcbnew/dialog_layers_setup.cpp | 7 +- pcbnew/dialog_track_options.cpp | 1 + pcbnew/drc.cpp | 3 +- pcbnew/edit.cpp | 5 +- pcbnew/edit_pcb_text.cpp | 1 + pcbnew/edit_track_width.cpp | 1 + pcbnew/editedge.cpp | 1 + pcbnew/editrack-part2.cpp | 6 +- pcbnew/editrack.cpp | 1 + pcbnew/event_handlers_tracks_vias_sizes.cpp | 1 + pcbnew/gen_drill_report_files.cpp | 5 +- pcbnew/gendrill.cpp | 3 +- pcbnew/hotkeys.cpp | 9 +- pcbnew/initpcb.cpp | 6 +- pcbnew/ioascii.cpp | 10 +- pcbnew/locate.cpp | 1 + pcbnew/magnetic_tracks_functions.cpp | 1 + pcbnew/mirepcb.cpp | 8 +- pcbnew/muonde.cpp | 1 + pcbnew/onrightclick.cpp | 6 +- pcbnew/pcbnew_config.cpp | 2 +- pcbnew/plot_rtn.cpp | 1 + pcbnew/print_board_functions.cpp | 1 + pcbnew/ratsnest.cpp | 1 + pcbnew/sel_layer.cpp | 11 +- pcbnew/set_color.cpp | 1 + pcbnew/solve.cpp | 3 +- pcbnew/specctra_export.cpp | 1 + pcbnew/tool_pcb.cpp | 1 + pcbnew/toolbars_update_user_interface.cpp | 1 + pcbnew/via_edit.cpp | 1 + 71 files changed, 710 insertions(+), 1440 deletions(-) delete mode 100644 gerbview/trpiste.cpp create mode 100644 include/class_board_design_settings.h create mode 100644 pcbnew/class_board_design_settings.cpp delete mode 100644 pcbnew/dialog_copper_layers_setup.cpp delete mode 100644 pcbnew/dialog_copper_layers_setup.h delete mode 100644 pcbnew/dialog_copper_layers_setup_base.cpp delete mode 100644 pcbnew/dialog_copper_layers_setup_base.fbp delete mode 100644 pcbnew/dialog_copper_layers_setup_base.h diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index b2c162a456..b57e9f607f 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -9,6 +9,7 @@ #include "macros.h" #include "drawtxt.h" #include "confirm.h" +#include "class_board_design_settings.h" #include "3d_viewer.h" #include "trackball.h" @@ -113,7 +114,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() g_Parm_3D_Visu.m_BoardSize = pcb->m_BoundaryBox.GetSize(); g_Parm_3D_Visu.m_BoardPos = pcb->m_BoundaryBox.Centre(); g_Parm_3D_Visu.m_BoardPos.y = -g_Parm_3D_Visu.m_BoardPos.y; - g_Parm_3D_Visu.m_Layers = pcb->m_BoardSettings->m_CopperLayerCount; + g_Parm_3D_Visu.m_Layers = pcb->m_BoardSettings->GetCopperLayerCount(); // Ensure the board has 2 sides for 3D views, because it is hard to find a *really* single side board in the true life... if ( g_Parm_3D_Visu.m_Layers < 2 ) @@ -406,7 +407,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment ) double zpos, w; int layer = segment->GetLayer(); - + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) return; diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 633cbdae30..3af35c2bf2 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -57,6 +57,7 @@ set(PCB_COMMON_SRCS ../pcbnew/basepcbframe.cpp ../pcbnew/class_board.cpp ../pcbnew/class_board_connected_item.cpp + ../pcbnew/class_board_design_settings.cpp ../pcbnew/class_board_item.cpp ../pcbnew/class_cotation.cpp ../pcbnew/class_drawsegment.cpp diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index a96d9c182d..bd984b1215 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -34,7 +34,7 @@ #include "pcbcommon.h" #include "plot_common.h" #include "class_zone_setting.h" - +#include "class_board_design_settings.h" /* Look up Table for conversion one layer number -> one bit layer mask: */ int g_TabOneLayerMask[LAYER_COUNT] = { diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index bb161fc4c7..cb3438fd02 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -33,8 +33,7 @@ set(GERBVIEW_SRCS select_layers_to_pcb.cpp set_color.cpp tool_gerber.cpp - tracepcb.cpp - trpiste.cpp ) + tracepcb.cpp ) set(GERBVIEW_EXTRA_SRCS ../share/setpage.cpp diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index ea53d339c3..46aa651dfb 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -12,6 +12,7 @@ #include "gestfich.h" #include "gerbview.h" +#include "class_board_design_settings.h" #include "protos.h" /* Routines Locales : */ @@ -96,8 +97,8 @@ static int WriteSetup( FILE* File, BOARD* Pcb ) sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT ); fprintf( File, "%s", text ); - Pcb->m_BoardSettings->m_CopperLayerCount = g_DesignSettings.m_CopperLayerCount; - fprintf( File, "Layers %d\n", g_DesignSettings.m_CopperLayerCount ); + Pcb->m_BoardSettings->SetCopperLayerCount( g_DesignSettings.GetCopperLayerCount( ) ); + fprintf( File, "Layers %d\n", g_DesignSettings.GetCopperLayerCount( ) ); fprintf( File, "$EndSETUP\n\n" ); return 1; @@ -111,7 +112,7 @@ static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File ) int NbLayers; /* Print the copper layer count */ - NbLayers = Pcb->m_BoardSettings->m_CopperLayerCount; + NbLayers = Pcb->m_BoardSettings->GetCopperLayerCount( ); fprintf( File, "$GENERAL\n" ); fprintf( File, "LayerCount %d\n", NbLayers ); diff --git a/gerbview/gerbview_config.cpp b/gerbview/gerbview_config.cpp index 872c882ada..25c7939f82 100644 --- a/gerbview/gerbview_config.cpp +++ b/gerbview/gerbview_config.cpp @@ -14,6 +14,7 @@ #include "gerbview.h" #include "pcbplot.h" #include "hotkeys.h" +#include "class_board_design_settings.h" #include "gerbview_config.h" #include "protos.h" diff --git a/gerbview/select_layers_to_pcb.cpp b/gerbview/select_layers_to_pcb.cpp index f0bc515209..12e29b4d9f 100644 --- a/gerbview/select_layers_to_pcb.cpp +++ b/gerbview/select_layers_to_pcb.cpp @@ -7,6 +7,7 @@ #include "fctsys.h" #include "common.h" #include "gerbview.h" +#include "class_board_design_settings.h" #include "protos.h" @@ -127,25 +128,26 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_GerberFrame* parent ) : // buttons should be some other size in that version. // Compute a reasonable number of copper layers - g_DesignSettings.m_CopperLayerCount = 0; + int pcb_layer_number = 0; for( ii = 0; ii < 32; ii++ ) { if( g_GERBER_List[ii] != NULL ) - g_DesignSettings.m_CopperLayerCount++; + pcb_layer_number++; // Specify the default value for each member of these arrays. ButtonTable[ii] = -1; LayerLookUpTable[ii] = LAYER_UNSELECTED; } + g_DesignSettings.SetCopperLayerCount(pcb_layer_number); - int pcb_layer_number = 0; + pcb_layer_number = 0; for( nb_items = 0, ii = 0; ii < 32; ii++ ) { if( g_GERBER_List[ii] == NULL ) continue; - if( (pcb_layer_number == g_DesignSettings.m_CopperLayerCount - 1) - && (g_DesignSettings.m_CopperLayerCount > 1) ) + if( (pcb_layer_number == g_DesignSettings.GetCopperLayerCount() - 1) + && (g_DesignSettings.GetCopperLayerCount() > 1) ) pcb_layer_number = CMP_N; ButtonTable[nb_items] = ii; @@ -375,8 +377,8 @@ void WinEDA_SwapLayerFrame::OnSelectLayer( wxCommandEvent& event ) /*********************************************************/ void WinEDA_SwapLayerFrame::OnCancelClick( wxCommandEvent& event ) -{ /*********************************************************/ +{ EndModal( -1 ); } @@ -391,7 +393,7 @@ void WinEDA_SwapLayerFrame::OnOkClick( wxCommandEvent& event ) /* Compute the number of copper layers * this is the max layer number + 1 (if some internal layers exist) */ - g_DesignSettings.m_CopperLayerCount = 1; + int layers_count = 1; for( ii = 0; ii < 32; ii++ ) { if( LayerLookUpTable[ii] == CMP_N ) @@ -400,15 +402,17 @@ void WinEDA_SwapLayerFrame::OnOkClick( wxCommandEvent& event ) { if( LayerLookUpTable[ii] >= LAST_COPPER_LAYER ) continue; // not a copper layer - if( LayerLookUpTable[ii] >= g_DesignSettings.m_CopperLayerCount ) - g_DesignSettings.m_CopperLayerCount++; + if( LayerLookUpTable[ii] >= layers_count ) + layers_count++; } } if( AsCmpLayer ) - g_DesignSettings.m_CopperLayerCount++; - if( g_DesignSettings.m_CopperLayerCount > NB_COPPER_LAYERS ) // should not occur. - g_DesignSettings.m_CopperLayerCount = NB_COPPER_LAYERS; + layers_count++; + if( layers_count > NB_COPPER_LAYERS ) // should not occur. + layers_count = NB_COPPER_LAYERS; + + g_DesignSettings.SetCopperLayerCount( layers_count ); EndModal( 1 ); } diff --git a/gerbview/set_color.cpp b/gerbview/set_color.cpp index 5a00b17463..ba777afd88 100644 --- a/gerbview/set_color.cpp +++ b/gerbview/set_color.cpp @@ -16,6 +16,7 @@ #include "gerbview.h" #include "pcbnew.h" +#include "class_board_design_settings.h" #include "protos.h" @@ -443,7 +444,7 @@ void WinEDA_SetColorsFrame::UpdateLayerSettings() 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/tracepcb.cpp b/gerbview/tracepcb.cpp index 73a813c965..689beea647 100644 --- a/gerbview/tracepcb.cpp +++ b/gerbview/tracepcb.cpp @@ -1,26 +1,21 @@ -/*****************************************/ -/* Routines generales d'affichage du PCB */ -/*****************************************/ - -/* fichier TRACEPCB.CPP */ +/****************/ +/* tracepcb.cpp */ +/****************/ /* - * Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ... + * Redraw the screen. */ #include "fctsys.h" #include "gr_basic.h" #include "common.h" #include "class_drawpanel.h" +#include "drawtxt.h" #include "gerbview.h" #include "pcbplot.h" #include "protos.h" - - -/* Externes */ - -/* Variables Locales */ +#include "class_board_design_settings.h" /************************************************************************************************************/ @@ -106,6 +101,7 @@ void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC, { } + /***********************************************************************************/ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklayer ) /***********************************************************************************/ @@ -193,9 +189,277 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay GetScreen()->ClrRefreshReq(); } +/***************************************************************************************************/ +void Draw_Track_Buffer( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int draw_mode, + int printmasklayer ) +/***************************************************************************************************/ + +/* Function to draw the tracks (i.e Spots or lines) in gerbview + * Polygons are not handled here (there are in Pcb->m_Zone) + * @param DC = device context to draw + * @param Pcb = Board to draw (only Pcb->m_Track is used) + * @param draw_mode = draw mode for the device context (GR_COPY, GR_OR, GR_XOR ..) + * @param printmasklayer = mask for allowed layer (=-1 to draw all layers) + */ +{ + int layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; + GERBER* gerber = g_GERBER_List[layer]; + int dcode_hightlight = 0; + + if( gerber ) + dcode_hightlight = gerber->m_Selected_Tool; + + for( TRACK* track = Pcb->m_Track; track; track = track->Next() ) + { + if( !(track->ReturnMaskLayer() & printmasklayer) ) + continue; + + D(printf("D:%p\n", track );) + + if( dcode_hightlight == track->GetNet() && track->GetLayer()==layer ) + Trace_Segment( panel, DC, track, draw_mode | GR_SURBRILL ); + else + Trace_Segment( panel, DC, track, draw_mode ); + } +} + + +#if 1 + +/***********************************************************************************/ +void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mode ) +/***********************************************************************************/ + +/* routine de trace de 1 segment de piste. + * Parametres : + * track = adresse de la description de la piste en buflib + * draw_mode = mode ( GR_XOR, GR_OR..) + */ +{ + int l_piste; + int color; + int fillopt; + int radius; + int halfPenWidth; + static bool show_err; + + if( track->m_Flags & DRAW_ERASED ) // draw in background color, used by classs TRACK in gerbview + { + color = g_DrawBgColor; + } + else + { + 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 ) + color &= ~HIGHT_LIGHT_FLAG; + else + color |= HIGHT_LIGHT_FLAG; + } + if( color & HIGHT_LIGHT_FLAG ) + color = ColorRefs[color & MASKCOLOR].m_LightColor; + } + + GRSetDrawMode( DC, draw_mode ); + + + fillopt = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH; + + switch( track->m_Shape ) + { + case S_CIRCLE: + radius = (int) hypot( (double) (track->m_End.x - track->m_Start.x), + (double) (track->m_End.y - track->m_Start.y) ); + + halfPenWidth = track->m_Width >> 1; + if( panel->GetScreen()->Scale( halfPenWidth ) < L_MIN_DESSIN ) + { + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, + track->m_Start.y, radius, 0, color ); + } + + if( fillopt == SKETCH ) + { + // draw the border of the pen's path using two circles, each as narrow as possible + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + radius - halfPenWidth, 0, color ); + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + radius + halfPenWidth, 0, color ); + } + else + { + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + radius, track->m_Width, color ); + } + break; + + case S_ARC: + if( fillopt == SKETCH ) + { + GRArc1( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, + track->m_Param, track->GetSubNet(), 0, color ); + } + else + { + GRArc1( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, + track->m_Param, track->GetSubNet(), + track->m_Width, color ); + } + break; + + case S_SPOT_CIRCLE: + radius = track->m_Width >> 1; + + fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; + if( panel->GetScreen()->Scale( radius ) < L_MIN_DESSIN ) + { + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, + track->m_Start.y, radius, 0, color ); + } + else if( fillopt == SKETCH ) + { + GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, + track->m_Start.y, radius, 0, color ); + } + else + { + GRFilledCircle( &panel->m_ClipBox, DC, track->m_Start.x, + track->m_Start.y, radius, 0, color, color ); + } + break; + + case S_SPOT_RECT: + case S_RECT: + + l_piste = track->m_Width >> 1; + + fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; + if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN ) + { + GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, 0, color ); + } + else if( fillopt == SKETCH ) + { + GRRect( &panel->m_ClipBox, DC, + track->m_Start.x - l_piste, + track->m_Start.y - l_piste, + track->m_End.x + l_piste, + track->m_End.y + l_piste, + 0, color ); + } + else + { + GRFilledRect( &panel->m_ClipBox, DC, + track->m_Start.x - l_piste, + track->m_Start.y - l_piste, + track->m_End.x + l_piste, + track->m_End.y + l_piste, + 0, color, color ); + } + break; + + case S_SPOT_OVALE: + fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; + + case S_SEGMENT: + l_piste = track->m_Width >> 1; + + if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN ) + { + GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, 0, color ); + break; + } + + if( fillopt == SKETCH ) + { + GRCSegm( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, + track->m_End.x, track->m_End.y, track->m_Width, color ); + } + else + { + GRFillCSegm( &panel->m_ClipBox, DC, track->m_Start.x, + track->m_Start.y, track->m_End.x, track->m_End.y, + track->m_Width, color ); + } + break; + + default: + if( !show_err ) + { + wxMessageBox( wxT( "Trace_Segment() type error" ) ); + show_err = TRUE; + } + break; + } +} + +#endif + + +/*****************************************************************************************/ +void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int drawmode ) +/*****************************************************************************************/ +{ + TRACK* track; + wxPoint pos; + int width, orient; + wxString Line; + + GRSetDrawMode( DC, drawmode ); + track = Pcb->m_Track; + for( ; track != NULL; track = track->Next() ) + { + if( (track->m_Shape == S_ARC) + || (track->m_Shape == S_CIRCLE) + || (track->m_Shape == S_ARC_RECT) ) + { + pos.x = track->m_Start.x; + pos.y = track->m_Start.y; + } + else + { + pos.x = (track->m_Start.x + track->m_End.x) / 2; + pos.y = (track->m_Start.y + track->m_End.y) / 2; + } + + Line.Printf( wxT( "D%d" ), track->GetNet() ); + + width = track->m_Width; + orient = TEXT_ORIENT_HORIZ; + if( track->m_Shape >= S_SPOT_CIRCLE ) // forme flash + { + width /= 3; + } + else // lines + { + int dx, dy; + dx = track->m_Start.x - track->m_End.x; + dy = track->m_Start.y - track->m_End.y; + if( abs( dx ) < abs( dy ) ) + orient = TEXT_ORIENT_VERT; + width /= 2; + } + + DrawGraphicText( panel, DC, + pos, (EDA_Colors) g_DCodesColor, Line, + orient, wxSize( width, width ), + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + 0, false, false, false); + } +} + /* Virtual fonction needed by the PCB_SCREEN class derived from BASE_SCREEN -* this is a virtaul pure function in BASE_SCREEN +* this is a virtual pure function in BASE_SCREEN * do nothing in gerbview * could be removed later */ diff --git a/gerbview/trpiste.cpp b/gerbview/trpiste.cpp deleted file mode 100644 index 5f12712c31..0000000000 --- a/gerbview/trpiste.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/*****************************************************************/ -/* Routines de tracage des pistes ( Toutes, 1 piste, 1 segment ) */ -/*****************************************************************/ - -#include "fctsys.h" -#include "gr_basic.h" -#include "common.h" -#include "class_drawpanel.h" -#include "drawtxt.h" -#include "confirm.h" - -#include "gerbview.h" -#include "pcbplot.h" -#include "protos.h" - -/* Definition des cas ou l'on force l'affichage en SKETCH (membre .flags) */ -#define FORCE_SKETCH (DRAG | EDIT ) - -/* variables locales : */ - -/***************************************************************************************************/ -void Draw_Track_Buffer( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int draw_mode, - int printmasklayer ) -/***************************************************************************************************/ - -/* Function to draw the tracks (i.e Spots or lines) in gerbview - * Polygons are not handled here (there are in Pcb->m_Zone) - * @param DC = device context to draw - * @param Pcb = Board to draw (only Pcb->m_Track is used) - * @param draw_mode = draw mode for the device context (GR_COPY, GR_OR, GR_XOR ..) - * @param printmasklayer = mask for allowed layer (=-1 to draw all layers) - */ -{ - int layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - GERBER* gerber = g_GERBER_List[layer]; - int dcode_hightlight = 0; - - if( gerber ) - dcode_hightlight = gerber->m_Selected_Tool; - - for( TRACK* track = Pcb->m_Track; track; track = track->Next() ) - { - if( !(track->ReturnMaskLayer() & printmasklayer) ) - continue; - - D(printf("D:%p\n", track );) - - if( dcode_hightlight == track->GetNet() && track->GetLayer()==layer ) - Trace_Segment( panel, DC, track, draw_mode | GR_SURBRILL ); - else - Trace_Segment( panel, DC, track, draw_mode ); - } -} - - -#if 1 - -/***********************************************************************************/ -void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mode ) -/***********************************************************************************/ - -/* routine de trace de 1 segment de piste. - * Parametres : - * track = adresse de la description de la piste en buflib - * draw_mode = mode ( GR_XOR, GR_OR..) - */ -{ - int l_piste; - int color; - int fillopt; - int radius; - int halfPenWidth; - static bool show_err; - - if( track->m_Flags & DRAW_ERASED ) // draw in background color, used by classs TRACK in gerbview - { - color = g_DrawBgColor; - } - else - { - 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 ) - color &= ~HIGHT_LIGHT_FLAG; - else - color |= HIGHT_LIGHT_FLAG; - } - if( color & HIGHT_LIGHT_FLAG ) - color = ColorRefs[color & MASKCOLOR].m_LightColor; - } - - GRSetDrawMode( DC, draw_mode ); - - - fillopt = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH; - - switch( track->m_Shape ) - { - case S_CIRCLE: - radius = (int) hypot( (double) (track->m_End.x - track->m_Start.x), - (double) (track->m_End.y - track->m_Start.y) ); - - halfPenWidth = track->m_Width >> 1; - if( panel->GetScreen()->Scale( halfPenWidth ) < L_MIN_DESSIN ) - { - GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, - track->m_Start.y, radius, 0, color ); - } - - if( fillopt == SKETCH ) - { - // draw the border of the pen's path using two circles, each as narrow as possible - GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - radius - halfPenWidth, 0, color ); - GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - radius + halfPenWidth, 0, color ); - } - else - { - GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - radius, track->m_Width, color ); - } - break; - - case S_ARC: - if( fillopt == SKETCH ) - { - GRArc1( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - track->m_End.x, track->m_End.y, - track->m_Param, track->GetSubNet(), 0, color ); - } - else - { - GRArc1( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - track->m_End.x, track->m_End.y, - track->m_Param, track->GetSubNet(), - track->m_Width, color ); - } - break; - - case S_SPOT_CIRCLE: - radius = track->m_Width >> 1; - - fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; - if( panel->GetScreen()->Scale( radius ) < L_MIN_DESSIN ) - { - GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, - track->m_Start.y, radius, 0, color ); - } - else if( fillopt == SKETCH ) - { - GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, - track->m_Start.y, radius, 0, color ); - } - else - { - GRFilledCircle( &panel->m_ClipBox, DC, track->m_Start.x, - track->m_Start.y, radius, 0, color, color ); - } - break; - - case S_SPOT_RECT: - case S_RECT: - - l_piste = track->m_Width >> 1; - - fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; - if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN ) - { - GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - track->m_End.x, track->m_End.y, 0, color ); - } - else if( fillopt == SKETCH ) - { - GRRect( &panel->m_ClipBox, DC, - track->m_Start.x - l_piste, - track->m_Start.y - l_piste, - track->m_End.x + l_piste, - track->m_End.y + l_piste, - 0, color ); - } - else - { - GRFilledRect( &panel->m_ClipBox, DC, - track->m_Start.x - l_piste, - track->m_Start.y - l_piste, - track->m_End.x + l_piste, - track->m_End.y + l_piste, - 0, color, color ); - } - break; - - case S_SPOT_OVALE: - fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; - - case S_SEGMENT: - l_piste = track->m_Width >> 1; - - if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN ) - { - GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - track->m_End.x, track->m_End.y, 0, color ); - break; - } - - if( fillopt == SKETCH ) - { - GRCSegm( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, - track->m_End.x, track->m_End.y, track->m_Width, color ); - } - else - { - GRFillCSegm( &panel->m_ClipBox, DC, track->m_Start.x, - track->m_Start.y, track->m_End.x, track->m_End.y, - track->m_Width, color ); - } - break; - - default: - if( !show_err ) - { - DisplayError( panel, wxT( "Trace_Segment() type error" ) ); - show_err = TRUE; - } - break; - } -} - -#endif - - -/*****************************************************************************************/ -void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int drawmode ) -/*****************************************************************************************/ -{ - TRACK* track; - wxPoint pos; - int width, orient; - wxString Line; - - GRSetDrawMode( DC, drawmode ); - track = Pcb->m_Track; - for( ; track != NULL; track = track->Next() ) - { - if( (track->m_Shape == S_ARC) - || (track->m_Shape == S_CIRCLE) - || (track->m_Shape == S_ARC_RECT) ) - { - pos.x = track->m_Start.x; - pos.y = track->m_Start.y; - } - else - { - pos.x = (track->m_Start.x + track->m_End.x) / 2; - pos.y = (track->m_Start.y + track->m_End.y) / 2; - } - - Line.Printf( wxT( "D%d" ), track->GetNet() ); - - width = track->m_Width; - orient = TEXT_ORIENT_HORIZ; - if( track->m_Shape >= S_SPOT_CIRCLE ) // forme flash - { - width /= 3; - } - else // lines - { - int dx, dy; - dx = track->m_Start.x - track->m_End.x; - dy = track->m_Start.y - track->m_End.y; - if( abs( dx ) < abs( dy ) ) - orient = TEXT_ORIENT_VERT; - width /= 2; - } - - DrawGraphicText( panel, DC, - pos, (EDA_Colors) g_DCodesColor, Line, - orient, wxSize( width, width ), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, - 0, false, false, false); - } -} diff --git a/include/class_board_design_settings.h b/include/class_board_design_settings.h new file mode 100644 index 0000000000..233177efc3 --- /dev/null +++ b/include/class_board_design_settings.h @@ -0,0 +1,182 @@ +/**********************************************************/ +/* class_board_design_settings.h : handle board options */ +/**********************************************************/ + +#ifndef _BOARD_DESIGN_SETTING_H +#define _BOARD_DESIGN_SETTING_H + +// Class for handle current printed board design settings +class EDA_BoardDesignSettings +{ +protected: + int m_CopperLayerCount; // Number of copper layers for this design +public: + int m_ViaDrillCustomValue; // via drill for vias that have a specific drill value + int m_CurrentViaSize; // Current via size + int m_CurrentMicroViaSize; // Current micro via size + bool m_MicroViasAllowed; // true to allow micro vias + int m_CurrentViaType; // via type (VIA_BLIND_BURIED, VIA_TROUGHT VIA_MICROVIA) + int m_CurrentTrackWidth; // current track width + bool m_UseConnectedTrackWidth; // if true, when creating a new track starting on an existing track, use this track width + int m_DrawSegmentWidth; // current graphic line width (not EDGE layer) + int m_EdgeSegmentWidth; // current graphic line width (EDGE layer only) + int m_PcbTextWidth; // current Pcb (not module) Text width + wxSize m_PcbTextSize; // current Pcb (not module) Text size + int m_TrackMinWidth; // track min value for width ((min copper size value + int m_ViasMinSize; // vias (not micro vias) min diameter + int m_ViasMinDrill; // vias (not micro vias) min drill diameter + int m_MicroViasMinSize; // micro vias (not vias) min diameter + int m_MicroViasMinDrill; // micro vias (not vias) min drill diameter + int m_MaskMargin; // Solder mask margin + int m_LayerThickness; // Layer Thickness for 3D viewer + +protected: + int m_EnabledLayers; // Bit-mask for layer enabling + int m_VisibleLayers; // Bit-mask for layer visibility + int m_VisibleElements; // Bit-mask for element category visibility + +public: + // Color options for screen display of the Printed Board: + int m_LayerColor[32]; // Layer colors (tracks and graphic items) + + int m_ViaColor[4]; // Via color (depending on is type) + + // Pad color for the pads of both sides is m_PadCUColor OR m_PadCMPColor (in terms of colors) + + int m_RatsnestColor; // Ratsnest color + + +public: + EDA_BoardDesignSettings(); + + /** + * Function GetVisibleLayers + * returns a bit-mask of all the layers that are visible + * @return int - the visible layers in bit-mapped form. + */ + int GetVisibleLayers() const; + + /** + * Function SetVisibleLayers + * changes the bit-mask of visible layers + * @param aMask = The new bit-mask of visible layers + */ + void SetVisibleLayers( int aMask ); + + /** + * Function IsLayerVisible + * tests whether a given layer is visible + * @param aLayerIndex = The index of the layer to be tested + * @return bool - true if the layer is visible. + */ + inline bool IsLayerVisible( int aLayerIndex ) const + { + if( aLayerIndex < 0 || aLayerIndex >= 32 ) //@@IMB: Altough Pcbnew uses only 29, Gerbview uses all 32 layers + return false; + // If a layer is disabled, it is automatically invisible + return (bool)( m_VisibleLayers & m_EnabledLayers & 1 << aLayerIndex ); + } + + /** + * Function SetLayerVisibility + * changes the visibility of a given layer + * @param aLayerIndex = The index of the layer to be changed + * @param aNewState = The new visibility state of the layer + */ + void SetLayerVisibility( int aLayerIndex, bool aNewState ); + + /** + * Function GetVisibleElements + * returns a bit-mask of all the element categories that are visible + * @return int - the visible element categories in bit-mapped form. + */ + inline int GetVisibleElements() const + { + return m_VisibleElements; + } + + /** + * Function SetVisibleElements + * changes the bit-mask of visible element categories + * @param aMask = The new bit-mask of visible element categories + */ + inline void SetVisibleElements( int aMask ) + { + m_VisibleElements = aMask; + } + + /** + * Function IsElementVisible + * tests whether a given element category is visible + * @param aCategoryIndex = The index of the element category to be tested. + * @return bool - true if the element is visible. + */ + inline bool IsElementVisible( int aCategoryIndex ) const + { + if( aCategoryIndex < 0 || aCategoryIndex > PAD_CMP_VISIBLE ) + return false; + return (bool)( m_VisibleElements & 1 << aCategoryIndex ); + } + + /** + * Function SetElementVisibility + * changes the visibility of an element category + * @param aCategoryIndex = The index of the element category to be changed + * @param aNewState = The new visibility state of the element category + */ + void SetElementVisibility( int aCategoryIndex, bool aNewState ); + + /** + * Function GetEnabledLayers + * returns a bit-mask of all the layers that are enabled + * @return int - the enabled layers in bit-mapped form. + */ + inline int GetEnabledLayers() const + { + return m_EnabledLayers; + } + + /** + * Function SetEnabledLayers + * changes the bit-mask of enabled layers + * @param aMask = The new bit-mask of enabled layers + */ + void SetEnabledLayers( int aMask ) + { + // TODO; ensure consistency with m_CopperLayerCount + m_EnabledLayers = aMask; + // A disabled layer cannot be visible + m_VisibleLayers &= aMask; + } + + /** + * Function IsLayerEnabled + * tests whether a given layer is enabled + * @param aLayerIndex = The index of the layer to be tested + * @return bool - true if the layer is enabled + */ + inline bool IsLayerEnabled( int aLayerIndex ) + { + return (bool)( m_EnabledLayers & 1 << aLayerIndex ); + } + + /** + * Function GetCopperLayerCount + * @return int - the number of neabled copper layers + */ + inline int GetCopperLayerCount() const + { + return m_CopperLayerCount; + } + + /** + * Function SetCopperLayerCount + * do what its name says... + * @param aNewLayerCount = The new number of enabled copper layers + */ + void SetCopperLayerCount( int aNewLayerCount ); +}; + + +#endif + // _BOARD_DESIGN_SETTING_H diff --git a/include/pcbstruct.h b/include/pcbstruct.h index db4f552bfd..f27d6f0c98 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -1,5 +1,5 @@ /**************************************************************/ -/* pcbstruct.h : definition des structures de donnees type PCB */ +/* pcbstruct.h : some classes and definitions used in pcbnew */ /**************************************************************/ #ifndef PCBSTRUCT_H @@ -182,181 +182,6 @@ inline bool IsValidNonCopperLayerIndex( int aLayerIndex ) return aLayerIndex >= FIRST_NO_COPPER_LAYER && aLayerIndex <= LAST_NO_COPPER_LAYER; } -// Class for handle current printed board design settings -class EDA_BoardDesignSettings -{ -public: - int m_CopperLayerCount; // Number of copper layers for this design - int m_ViaDrillCustomValue; // via drill for vias that have a specific drill value - int m_CurrentViaSize; // Current via size - int m_CurrentMicroViaSize; // Current micro via size - bool m_MicroViasAllowed; // true to allow micro vias - int m_CurrentViaType; // via type (VIA_BLIND_BURIED, VIA_TROUGHT VIA_MICROVIA) - int m_CurrentTrackWidth; // current track width - bool m_UseConnectedTrackWidth; // if true, when creating a new track starting on an existing track, use this track width - int m_DrawSegmentWidth; // current graphic line width (not EDGE layer) - int m_EdgeSegmentWidth; // current graphic line width (EDGE layer only) - int m_PcbTextWidth; // current Pcb (not module) Text width - wxSize m_PcbTextSize; // current Pcb (not module) Text size - int m_TrackMinWidth; // track min value for width ((min copper size value - int m_ViasMinSize; // vias (not micro vias) min diameter - int m_ViasMinDrill; // vias (not micro vias) min drill diameter - int m_MicroViasMinSize; // micro vias (not vias) min diameter - int m_MicroViasMinDrill; // micro vias (not vias) min drill diameter - int m_MaskMargin; // Solder mask margin - int m_LayerThickness; // Layer Thickness for 3D viewer - -protected: - int m_EnabledLayers; // Bit-mask for layer enabling - int m_VisibleLayers; // Bit-mask for layer visibility - int m_VisibleElements; // Bit-mask for element category visibility - -public: - // Color options for screen display of the Printed Board: - int m_LayerColor[32]; // Layer colors (tracks and graphic items) - - int m_ViaColor[4]; // Via color (depending on is type) - - // Pad color for the pads of both sides is m_PadCUColor OR m_PadCMPColor (in terms of colors) - - int m_RatsnestColor; // Ratsnest color - - -public: - EDA_BoardDesignSettings(); - - /** - * Function GetVisibleLayers - * returns a bit-mask of all the layers that are visible - * @return int - the visible layers in bit-mapped form. - */ - int GetVisibleLayers() const; - - /** - * Function SetVisibleLayers - * changes the bit-mask of visible layers - * @param aMask = The new bit-mask of visible layers - */ - void SetVisibleLayers( int aMask ); - - /** - * Function IsLayerVisible - * tests whether a given layer is visible - * @param aLayerIndex = The index of the layer to be tested - * @return bool - true if the layer is visible. - */ - inline bool IsLayerVisible( int aLayerIndex ) const - { - if( aLayerIndex < 0 || aLayerIndex >= 32 ) //@@IMB: Altough Pcbnew uses only 29, Gerbview uses all 32 layers - return false; - // If a layer is disabled, it is automatically invisible - return (bool)( m_VisibleLayers & m_EnabledLayers & 1 << aLayerIndex ); - } - - /** - * Function SetLayerVisibility - * changes the visibility of a given layer - * @param aLayerIndex = The index of the layer to be changed - * @param aNewState = The new visibility state of the layer - */ - void SetLayerVisibility( int aLayerIndex, bool aNewState ); - - /** - * Function GetVisibleElements - * returns a bit-mask of all the element categories that are visible - * @return int - the visible element categories in bit-mapped form. - */ - inline int GetVisibleElements() const - { - return m_VisibleElements; - } - - /** - * Function SetVisibleElements - * changes the bit-mask of visible element categories - * @param aMask = The new bit-mask of visible element categories - */ - inline void SetVisibleElements( int aMask ) - { - m_VisibleElements = aMask; - } - - /** - * Function IsElementVisible - * tests whether a given element category is visible - * @param aCategoryIndex = The index of the element category to be tested. - * @return bool - true if the element is visible. - */ - inline bool IsElementVisible( int aCategoryIndex ) const - { - if( aCategoryIndex < 0 || aCategoryIndex > PAD_CMP_VISIBLE ) - return false; - return (bool)( m_VisibleElements & 1 << aCategoryIndex ); - } - - /** - * Function SetElementVisibility - * changes the visibility of an element category - * @param aCategoryIndex = The index of the element category to be changed - * @param aNewState = The new visibility state of the element category - */ - void SetElementVisibility( int aCategoryIndex, bool aNewState ); - - /** - * Function GetEnabledLayers - * returns a bit-mask of all the layers that are enabled - * @return int - the enabled layers in bit-mapped form. - */ - inline int GetEnabledLayers() const - { - return m_EnabledLayers; - } - - /** - * Function SetEnabledLayers - * changes the bit-mask of enabled layers - * @param aMask = The new bit-mask of enabled layers - */ - void SetEnabledLayers( int aMask ) - { - // TODO; ensure consistency with m_CopperLayerCount - m_EnabledLayers = aMask; - // A disabled layer cannot be visible - m_VisibleLayers &= aMask; - } - - /** - * Function IsLayerEnabled - * tests whether a given layer is enabled - * @param aLayerIndex = The index of the layer to be tested - * @return bool - true if the layer is enabled - */ - inline bool IsLayerEnabled( int aLayerIndex ) - { - return (bool)( m_EnabledLayers & 1 << aLayerIndex ); - } - - /** - * Function GetCopperLayerCount - * @return int - the number of neabled copper layers - */ - inline int GetCopperLayerCount() const - { - return m_CopperLayerCount; - } - - /** - * Function SetCopperLayerCount - * do what its name says... - * @param aNewLayerCount = The new number of enabled copper layers - */ - inline void SetCopperLayerCount( int aNewLayerCount ) - { - // TODO; ensure consistency with the m_EnabledLayers member - m_CopperLayerCount = aNewLayerCount; - } -}; - // Values for m_DisplayViaMode member: enum DisplayViaMode { diff --git a/pcbnew/autoplac.cpp b/pcbnew/autoplac.cpp index 7ecd9df062..c30cc1aca1 100644 --- a/pcbnew/autoplac.cpp +++ b/pcbnew/autoplac.cpp @@ -14,6 +14,7 @@ #include "autorout.h" #include "zones.h" #include "cell.h" +#include "class_board_design_settings.h" #include "protos.h" diff --git a/pcbnew/autorout.cpp b/pcbnew/autorout.cpp index ce4ae24267..dbea4b5b21 100644 --- a/pcbnew/autorout.cpp +++ b/pcbnew/autorout.cpp @@ -12,6 +12,7 @@ #include "autorout.h" #include "cell.h" #include "zones.h" +#include "class_board_design_settings.h" #include "protos.h" @@ -40,7 +41,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) int autoroute_net_code = -1; wxString msg; - if( g_DesignSettings.m_CopperLayerCount > 1 ) + if( g_DesignSettings.GetCopperLayerCount() > 1 ) { Route_Layer_TOP = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP; Route_Layer_BOTTOM = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM; diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 2574034fd7..262cac5abc 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -16,6 +16,7 @@ #include "bitmaps.h" #include "protos.h" #include "pcbnew_id.h" +#include "class_board_design_settings.h" #include "collectors.h" #include "class_drawpanel.h" @@ -185,7 +186,7 @@ void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer ) // If only one copper layer is enabled, the only such layer // that can be selected to is the "Copper" layer (so the // selection of any other copper layer is disregarded). - if( m_Pcb->m_BoardSettings->m_CopperLayerCount < 2 ) + if( m_Pcb->m_BoardSettings->GetCopperLayerCount() < 2 ) { if( layer != COPPER_LAYER_N ) { @@ -200,7 +201,7 @@ void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer ) else { if( (layer != COPPER_LAYER_N) && (layer != LAYER_CMP_N) - && (layer >= m_Pcb->m_BoardSettings->m_CopperLayerCount - 1) ) + && (layer >= m_Pcb->m_BoardSettings->GetCopperLayerCount() - 1) ) { return; } @@ -212,7 +213,7 @@ void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer ) // and a non-copper layer, or vice-versa? // ... - ((PCB_SCREEN*)GetScreen())->m_Active_Layer = layer; + GetScreen()->m_Active_Layer = layer; if( DisplayOpt.ContrastModeDisplay ) GetScreen()->SetRefreshReq(); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 6b8de3f829..b878d42a1b 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -5,6 +5,7 @@ #include "common.h" #include "pcbnew.h" +#include "class_board_design_settings.h" /* This is an odd place for this, but cvpcb won't link if it is @@ -264,7 +265,7 @@ LAYER_T LAYER::ParseType( const char* aType ) int BOARD::GetCopperLayerCount() const { - return m_BoardSettings->m_CopperLayerCount; + return m_BoardSettings->GetCopperLayerCount(); } int BOARD::GetEnabledLayers() const diff --git a/pcbnew/class_board_design_settings.cpp b/pcbnew/class_board_design_settings.cpp new file mode 100644 index 0000000000..ffe858dfea --- /dev/null +++ b/pcbnew/class_board_design_settings.cpp @@ -0,0 +1,122 @@ +/***************************************************************************/ +/* class_board_design_settings.cpp - EDA_BoardDesignSettings class functions */ +/***************************************************************************/ +#include "fctsys.h" +#include "common.h" + +#include "pcbnew.h" +#include "class_board_design_settings.h" + + +/*****************************************************/ +EDA_BoardDesignSettings::EDA_BoardDesignSettings() +/*****************************************************/ + +// Default values for designing boards +{ + int ii; + + static const int default_layer_color[32] = + { + GREEN, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, RED, + LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, LIGHTGRAY, + MAGENTA, CYAN, + LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, + LIGHTGRAY, + LIGHTGRAY, LIGHTGRAY, + LIGHTGRAY, + LIGHTGRAY, + LIGHTGRAY, + LIGHTGRAY + }; + + m_EnabledLayers = ALL_LAYERS; // All layers enabled at first. + // SetCopperLayerCount() will adjust thist. + 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. + + SetCopperLayerCount( 2 ); // Default design is a double sided board + m_ViaDrillCustomValue = 250; // via drill for vias which must have a defined drill value + m_CurrentViaSize = 450; // Current via size + m_CurrentViaType = VIA_THROUGH; // via type (VIA_BLIND_BURIED, VIA_THROUGH VIA_MICROVIA) + m_CurrentTrackWidth = 170; // current track width + m_UseConnectedTrackWidth = false; // if true, when creating a new track starting on an existing track, use this track width + m_CurrentMicroViaSize = 150; // Current micro via size + m_MicroViasAllowed = false; // true to allow micro vias + m_DrawSegmentWidth = 100; // current graphic line width (not EDGE layer) + m_EdgeSegmentWidth = 100; // current graphic line width (EDGE layer only) + m_PcbTextWidth = 100; // current Pcb (not module) Text width + m_PcbTextSize = wxSize( 500, 500 ); // current Pcb (not module) Text size + m_TrackMinWidth = 80; // track min value for width ((min copper size value + m_ViasMinSize = 350; // vias (not micro vias) min diameter + m_ViasMinDrill = 200; // vias (not micro vias) min drill diameter + m_MicroViasMinSize = 200; // micro vias (not vias) min diameter + m_MicroViasMinDrill = 50; // micro vias (not vias) min drill diameter + m_MaskMargin = 150; // Solder mask margin + + /* Color options for screen display of the Printed Board: */ + 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_RatsnestColor = WHITE; // Ratsnest color +} + + +// see pcbstruct.h +int EDA_BoardDesignSettings::GetVisibleLayers() const +{ + return m_VisibleLayers; +} + +void EDA_BoardDesignSettings::SetVisibleLayers( int aMask ) +{ + m_VisibleLayers = aMask & m_EnabledLayers & ALL_LAYERS; +} + +void EDA_BoardDesignSettings::SetLayerVisibility( int aLayerIndex, bool aNewState ) +{ + // Altough Pcbnew uses only 29, Gerbview uses all 32 layers + if( aLayerIndex < 0 || aLayerIndex >= 32 ) + return; + if( aNewState && IsLayerEnabled( aLayerIndex )) + m_VisibleLayers |= 1 << aLayerIndex; + else + m_VisibleLayers &= ~( 1 << aLayerIndex ); +} + +void EDA_BoardDesignSettings::SetElementVisibility( int aElementCategory, bool aNewState ) +{ + if( aElementCategory < 0 || aElementCategory > PAD_CMP_VISIBLE ) + return; + if( aNewState ) + m_VisibleElements |= 1 << aElementCategory; + else + m_VisibleElements &= ~( 1 << aElementCategory ); +} +/** + * Function SetCopperLayerCount + * do what its name says... + * @param aNewLayerCount = The new number of enabled copper layers + */ +void EDA_BoardDesignSettings::SetCopperLayerCount( int aNewLayerCount ) +{ + m_CopperLayerCount = aNewLayerCount; + // ensure consistency with the m_EnabledLayers member + m_EnabledLayers &= ~ALL_CU_LAYERS; + m_EnabledLayers |= CUIVRE_LAYER; + if ( m_CopperLayerCount > 1 ) + m_EnabledLayers |= CMP_LAYER; + for( int ii = 1; ii < aNewLayerCount-1; ii++ ) + m_EnabledLayers |= 1 << ii; +} diff --git a/pcbnew/class_cotation.cpp b/pcbnew/class_cotation.cpp index d12e4f29d9..35dd3bf1d0 100644 --- a/pcbnew/class_cotation.cpp +++ b/pcbnew/class_cotation.cpp @@ -8,6 +8,7 @@ #include "pcbnew.h" #include "trigo.h" #include "wxstruct.h" +#include "class_board_design_settings.h" #include "class_drawpanel.h" #include "kicad_string.h" #include "protos.h" diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index d3c5069296..428ee819af 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -11,6 +11,7 @@ #include "kicad_string.h" #include "pcbnew.h" +#include "class_board_design_settings.h" #include "trigo.h" #include "protos.h" diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 2f9cbbe1c5..c2fe6e2da6 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -10,13 +10,9 @@ #include "class_drawpanel.h" #include "confirm.h" #include "kicad_string.h" -#include "macros.h" #include "pcbnew.h" -#include "autorout.h" -#include "drag.h" - -#include "protos.h" +#include "class_board_design_settings.h" #define MAX_WIDTH 10000 // Epaisseur (en 1/10000 ") max raisonnable des traits, textes... diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index dd315c608b..c5ab12e7eb 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -9,6 +9,7 @@ #include "kicad_string.h" #include "pcbnew.h" +#include "class_board_design_settings.h" #include "trigo.h" #include "protos.h" diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index a2a9bc2d22..c48fb30b43 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -14,6 +14,7 @@ #include "pcbcommon.h" #include "pcbnew.h" +#include "class_board_design_settings.h" #include "autorout.h" #include "drag.h" diff --git a/pcbnew/class_netclass.cpp b/pcbnew/class_netclass.cpp index 509193ab43..1ce3ccf995 100644 --- a/pcbnew/class_netclass.cpp +++ b/pcbnew/class_netclass.cpp @@ -29,6 +29,7 @@ #include "common.h" #include "kicad_string.h" #include "pcbnew.h" +#include "class_board_design_settings.h" // This will get mapped to "kicad_default" in the specctra_export. diff --git a/pcbnew/class_netinfo_item.cpp b/pcbnew/class_netinfo_item.cpp index 36c883a0cf..1f77ae68af 100644 --- a/pcbnew/class_netinfo_item.cpp +++ b/pcbnew/class_netinfo_item.cpp @@ -7,6 +7,7 @@ #include "common.h" #include "kicad_string.h" #include "pcbnew.h" +#include "class_board_design_settings.h" /*********************************************************/ diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index fb19da5b5e..74344665a0 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -11,6 +11,7 @@ #include "drawtxt.h" #include "pcbnew.h" +#include "class_board_design_settings.h" /*******************************************************************************************/ diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index d37cdbf172..4c83fd4d71 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -11,6 +11,7 @@ #include "kicad_string.h" #include "pcbnew.h" +#include "class_board_design_settings.h" #include "trigo.h" #include "protos.h" diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 062f41833b..9f910868eb 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -12,10 +12,11 @@ #include "drawtxt.h" #include "kicad_string.h" #include "pcbcommon.h" +#include "class_board_design_settings.h" -#include "autorout.h" -#include "drag.h" -#include "protos.h" +//#include "autorout.h" +//#include "drag.h" +//#include "protos.h" /************************************************************************/ diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index ffb35b0f30..10d30cdc80 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -11,6 +11,7 @@ #include "drawtxt.h" #include "pcbnew.h" +#include "class_board_design_settings.h" #include "protos.h" @@ -862,15 +863,15 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi ( (SEGVIA*) this )->ReturnLayerPair( &layer_top, &layer_bottom ); /* lines for the top layer */ - RotatePoint( &ax, &ay, layer_top * 3600 / g_DesignSettings.m_CopperLayerCount ); - RotatePoint( &bx, &by, layer_top * 3600 / g_DesignSettings.m_CopperLayerCount ); + RotatePoint( &ax, &ay, layer_top * 3600 / g_DesignSettings.GetCopperLayerCount( ) ); + RotatePoint( &bx, &by, layer_top * 3600 / g_DesignSettings.GetCopperLayerCount( ) ); GRLine( &panel->m_ClipBox, DC, m_Start.x - ax, m_Start.y - ay, m_Start.x - bx, m_Start.y - by, 0, color ); /* lines for the bottom layer */ ax = 0; ay = rayon; bx = 0; by = drill_rayon; - RotatePoint( &ax, &ay, layer_bottom * 3600 / g_DesignSettings.m_CopperLayerCount ); - RotatePoint( &bx, &by, layer_bottom * 3600 / g_DesignSettings.m_CopperLayerCount ); + RotatePoint( &ax, &ay, layer_bottom * 3600 / g_DesignSettings.GetCopperLayerCount( ) ); + RotatePoint( &bx, &by, layer_bottom * 3600 / g_DesignSettings.GetCopperLayerCount( ) ); GRLine( &panel->m_ClipBox, DC, m_Start.x - ax, m_Start.y - ay, m_Start.x - bx, m_Start.y - by, 0, color ); } diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index b9bf8927e7..4099f627fb 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -13,6 +13,7 @@ #include "PolyLine.h" #include "pcbnew.h" #include "zones.h" +#include "class_board_design_settings.h" #include "protos.h" diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index c40fd4de93..3dc5c7c14a 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -7,6 +7,7 @@ #include "common.h" #include "pcbnew.h" +#include "class_board_design_settings.h" #include "trigo.h" #include "pcbnew_id.h" @@ -116,7 +117,7 @@ int PCB_SCREEN::GetInternalUnits( void ) */ bool PCB_SCREEN::IsMicroViaAcceptable( void ) { - int copperlayercnt = g_DesignSettings.m_CopperLayerCount; + int copperlayercnt = g_DesignSettings.GetCopperLayerCount( ); if( !g_DesignSettings.m_MicroViasAllowed ) return false; // Obvious.. @@ -124,7 +125,7 @@ bool PCB_SCREEN::IsMicroViaAcceptable( void ) return false; // Only on multilayer boards.. if( ( m_Active_Layer == COPPER_LAYER_N ) || ( m_Active_Layer == LAYER_CMP_N ) - || ( m_Active_Layer == g_DesignSettings.m_CopperLayerCount - 2 ) + || ( m_Active_Layer == g_DesignSettings.GetCopperLayerCount( ) - 2 ) || ( m_Active_Layer == LAYER_N_2 ) ) return true; @@ -169,110 +170,3 @@ DISPLAY_OPTIONS::DISPLAY_OPTIONS() DisplayDrawItems = true; ContrastModeDisplay = false; } - - -/*****************************************************/ -EDA_BoardDesignSettings::EDA_BoardDesignSettings() -/*****************************************************/ - -// Default values for designing boards -{ - int ii; - - static const int default_layer_color[32] = - { - GREEN, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, - LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, - LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, - LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, RED, - LIGHTGRAY, LIGHTGRAY, - LIGHTGRAY, LIGHTGRAY, - MAGENTA, CYAN, - LIGHTGRAY, LIGHTGRAY, - LIGHTGRAY, - LIGHTGRAY, - LIGHTGRAY, LIGHTGRAY, - LIGHTGRAY, - LIGHTGRAY, - LIGHTGRAY, - LIGHTGRAY - }; - - m_CopperLayerCount = 2; // Default design is a double sided board - m_ViaDrillCustomValue = 250; // via drill for vias which must have a defined drill value - m_CurrentViaSize = 450; // Current via size - m_CurrentViaType = VIA_THROUGH; // via type (VIA_BLIND_BURIED, VIA_THROUGH VIA_MICROVIA) - m_CurrentTrackWidth = 170; // current track width - m_UseConnectedTrackWidth = false; // if true, when creating a new track starting on an existing track, use this track width - m_CurrentMicroViaSize = 150; // Current micro via size - m_MicroViasAllowed = false; // true to allow micro vias - m_DrawSegmentWidth = 100; // current graphic line width (not EDGE layer) - m_EdgeSegmentWidth = 100; // current graphic line width (EDGE layer only) - m_PcbTextWidth = 100; // current Pcb (not module) Text width - m_PcbTextSize = wxSize( 500, 500 ); // current Pcb (not module) Text size - m_TrackMinWidth = 80; // track min value for width ((min copper size value - m_ViasMinSize = 350; // vias (not micro vias) min diameter - m_ViasMinDrill = 200; // vias (not micro vias) min drill diameter - m_MicroViasMinSize = 200; // micro vias (not vias) min diameter - m_MicroViasMinDrill = 50; // micro vias (not vias) min drill diameter - m_MaskMargin = 150; // Solder mask margin - /* Color options for screen display of the Printed Board: */ - - -//@@IMB: Not used m_PcbGridColor = DARKGRAY; // Grid color - - m_EnabledLayers = ALL_LAYERS; // All layers enabled at first. - 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; - -//@@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_RatsnestColor = WHITE; // Ratsnest color -} - - -// see pcbstruct.h -int EDA_BoardDesignSettings::GetVisibleLayers() const -{ - return m_VisibleLayers; -} - -void EDA_BoardDesignSettings::SetVisibleLayers( int aMask ) -{ - m_VisibleLayers = aMask & m_EnabledLayers & ALL_LAYERS; -} - -void EDA_BoardDesignSettings::SetLayerVisibility( int aLayerIndex, bool aNewState ) -{ - // Altough Pcbnew uses only 29, Gerbview uses all 32 layers - if( aLayerIndex < 0 || aLayerIndex >= 32 ) - return; - if( aNewState && IsLayerEnabled( aLayerIndex )) - m_VisibleLayers |= 1 << aLayerIndex; - else - m_VisibleLayers &= ~( 1 << aLayerIndex ); -} - -void EDA_BoardDesignSettings::SetElementVisibility( int aElementCategory, bool aNewState ) -{ - if( aElementCategory < 0 || aElementCategory > PAD_CMP_VISIBLE ) - return; - if( aNewState ) - m_VisibleElements |= 1 << aElementCategory; - else - m_VisibleElements &= ~( 1 << aElementCategory ); -} diff --git a/pcbnew/cotation.cpp b/pcbnew/cotation.cpp index 055386f264..1af425b0f6 100644 --- a/pcbnew/cotation.cpp +++ b/pcbnew/cotation.cpp @@ -7,6 +7,7 @@ #include "class_drawpanel.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" /* Routines Locales */ static void Exit_EditCotation( WinEDA_DrawPanel* Panel, wxDC* DC ); diff --git a/pcbnew/dialog_copper_layers_setup.cpp b/pcbnew/dialog_copper_layers_setup.cpp deleted file mode 100644 index d18f866ebe..0000000000 --- a/pcbnew/dialog_copper_layers_setup.cpp +++ /dev/null @@ -1,216 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// - -// Name: dialog_design_rules.cpp -// Author: jean-pierre Charras -///////////////////////////////////////////////////////////////////////////// - -/* functions relatives to the design rules editor - */ -#include "fctsys.h" -#include "common.h" -#include "class_drawpanel.h" - -#include "confirm.h" -#include "pcbnew.h" -#include "wxPcbStruct.h" - -#include "pcbnew_id.h" -#include "dialog_copper_layers_setup.h" -#include "wx/generic/gridctrl.h" - - -// Fields Positions on layer grid -#define LAYERS_GRID_ROUTABLE_POSITION 0 -#define LAYERS_GRID_STATUS_POSITION 1 -#define LAYERS_GRID_NAME_POSITION 2 - - -/***********************************************************************************/ -DIALOG_COPPER_LAYERS_SETUP::DIALOG_COPPER_LAYERS_SETUP( WinEDA_PcbFrame* parent ) : - DIALOG_COPPER_LAYERS_SETUP_BASE( parent ) -/***********************************************************************************/ -{ - m_Parent = parent; - - Init(); - SetAutoLayout( true ); - GetSizer()->Fit( this ); - GetSizer()->SetSizeHints( this ); -} - - -/********************************************************************/ -void DIALOG_COPPER_LAYERS_SETUP::Init() -/********************************************************************/ -{ - SetFocus(); - SetReturnCode( 0 ); - - // Initialize the layers grid: - m_ActivesLayersCount = g_DesignSettings.m_CopperLayerCount; - m_Pcb = m_Parent->GetBoard(); - - m_LayersCountSelection->SetSelection( m_ActivesLayersCount / 2 ); - - // Initialize the Routable column - SetRoutableLayerStatus(); - - // Initialize the Status column (layers attribute) - LAYER_T typelist[4] = { LT_SIGNAL, LT_POWER, LT_MIXED, LT_JUMPER }; - for( int ii = 0; ii < 4; ii++ ) - { - m_LayersType[ii] = typelist[ii]; - m_LayersTypeName[ii] = CONV_FROM_UTF8( LAYER::ShowType( typelist[ii] ) ); - } - - for( int ii = 0; ii < m_gridLayersProperties->GetNumberRows(); ii++ ) - { - m_gridLayersProperties->SetCellEditor( ii, LAYERS_GRID_STATUS_POSITION, - new wxGridCellChoiceEditor( WXSIZEOF( - m_LayersTypeName ), - m_LayersTypeName ) ); - int select = LT_SIGNAL; - for( int jj = 0; jj < 4; jj++ ) - { - int layer = LAYER_CMP_N - ii; - if( m_Pcb->GetLayerType( layer ) == m_LayersType[jj] ) - { - select = m_LayersType[jj]; - break; - } - } - - m_gridLayersProperties->SetCellValue( ii, LAYERS_GRID_STATUS_POSITION, - m_LayersTypeName[select] ); - m_gridLayersProperties->SetCellOverflow( ii, LAYERS_GRID_STATUS_POSITION, false ); - } - - // Initialize the Name column - for( int ii = 0; ii < m_gridLayersProperties->GetNumberRows(); ii++ ) - { - wxString layer_name = m_Pcb->GetLayerName( LAYER_CMP_N - ii ); - m_gridLayersProperties->SetCellValue( ii, LAYERS_GRID_NAME_POSITION, layer_name ); - } -} - - -/* Initialize the Routable column, and the R/W property of some cells - */ -void DIALOG_COPPER_LAYERS_SETUP::SetRoutableLayerStatus() -{ - m_gridLayersProperties->SetColFormatBool( LAYERS_GRID_ROUTABLE_POSITION ); - for( int ii = 0; ii < m_gridLayersProperties->GetNumberRows(); ii++ ) - { - int layer = LAYER_CMP_N - ii; - wxString value = layer < (m_ActivesLayersCount - 1) ? wxT( "1" ) : wxT( "0" ); - if( m_ActivesLayersCount > 1 && layer == LAYER_CMP_N ) - value = wxT( "1" ); - if( layer == COPPER_LAYER_N ) - value = wxT( "1" ); - m_gridLayersProperties->SetCellValue( ii, LAYERS_GRID_ROUTABLE_POSITION, value ); - m_gridLayersProperties->SetReadOnly( ii, LAYERS_GRID_ROUTABLE_POSITION ); - - // Set to Read Only cell for non existing copper layers: - m_gridLayersProperties->SetReadOnly( ii, LAYERS_GRID_STATUS_POSITION, value != wxT( "1" ) ); - m_gridLayersProperties->SetReadOnly( ii, LAYERS_GRID_NAME_POSITION, value != wxT( "1" ) ); - } -} - - - -/*****************************************************************/ -void DIALOG_COPPER_LAYERS_SETUP::OnCancelButtonClick( wxCommandEvent& event ) -/*****************************************************************/ -{ - EndModal( 0 ); -} - - -/**************************************************************************/ -void DIALOG_COPPER_LAYERS_SETUP::OnOkButtonClick( wxCommandEvent& event ) -/**************************************************************************/ -{ - if( !TestDataValidity() ) - { - DisplayError( this, _( "Errors detected, Abort" ) ); - return; - } - - g_DesignSettings.m_CopperLayerCount = m_ActivesLayersCount; - - // Initialize the new layer name - for( int ii = 0; ii < m_gridLayersProperties->GetNumberRows(); ii++ ) - { - wxString layer_name = m_gridLayersProperties->GetCellValue( ii, LAYERS_GRID_NAME_POSITION ); - if( layer_name != m_Pcb->GetLayerName( LAYER_CMP_N - ii ) ) - { - m_Pcb->SetLayerName( LAYER_CMP_N - ii, layer_name ); - } - } - - // Initialize the layer type - for( int ii = 0; ii < m_gridLayersProperties->GetNumberRows(); ii++ ) - { - wxString txt = m_gridLayersProperties->GetCellValue( ii, LAYERS_GRID_STATUS_POSITION ); - int layer = LAYER_CMP_N - ii; - for( int jj = 0; jj < 3; jj++ ) - { - if( m_LayersTypeName[jj] == txt ) - { - m_Pcb->SetLayerType( layer, m_LayersType[jj] ); - break; - } - } - } - m_Parent->ReCreateLayerBox( NULL ); - - EndModal( wxID_OK ); -} - - -/**************************************************************************/ -void DIALOG_COPPER_LAYERS_SETUP::OnLayerCountClick( wxCommandEvent& event ) -/**************************************************************************/ -{ - m_ActivesLayersCount = m_LayersCountSelection->GetSelection() * 2; - if( m_ActivesLayersCount <= 0 ) - m_ActivesLayersCount = 1; - - // Reinit the routable layers status - SetRoutableLayerStatus(); -} - - -/* TestDataValidity - * Performs a control of data validity - * set the background of a bad cell in RED and display an info message - * @return true if Ok, false if error - */ -bool DIALOG_COPPER_LAYERS_SETUP::TestDataValidity() -{ - bool success = true; - m_MessagesList->SetPage(wxEmptyString); // Clear message list - - // Test duplicate layers names - for( int ii = 0; ii < m_gridLayersProperties->GetNumberRows() - 1; ii++ ) - { - wxString value = m_gridLayersProperties->GetCellValue( ii, LAYERS_GRID_NAME_POSITION ); - for( int jj = ii+1; jj < m_gridLayersProperties->GetNumberRows(); jj++ ) - { - wxString othervalue = m_gridLayersProperties->GetCellValue( ii, - LAYERS_GRID_NAME_POSITION ); - othervalue = m_gridLayersProperties->GetCellValue( jj, LAYERS_GRID_NAME_POSITION ); - if( value.CmpNoCase( othervalue ) == 0 ) // Already exists! - { - wxString text; - text.Printf( _( - "This layer name %s is already existing
" ), - GetChars( value ) ); - m_MessagesList->AppendToPage( text ); - success = false; - } - } - } - - return success; -} diff --git a/pcbnew/dialog_copper_layers_setup.h b/pcbnew/dialog_copper_layers_setup.h deleted file mode 100644 index bf430de12e..0000000000 --- a/pcbnew/dialog_copper_layers_setup.h +++ /dev/null @@ -1,36 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_COPPER_LAYERS_SETUP -/////////////////////////////////////////////////////////////////////////////// - -#ifndef __dialog_design_rules_h_ -#define __dialog_design_rules_h_ - -#include "dialog_copper_layers_setup_base.h" - - -class DIALOG_COPPER_LAYERS_SETUP : public DIALOG_COPPER_LAYERS_SETUP_BASE -{ - private: - WinEDA_PcbFrame * m_Parent; - int m_ActivesLayersCount; - BOARD * m_Pcb; - LAYER_T m_LayersType[4]; - wxString m_LayersTypeName[4]; - - private: - void OnCancelButtonClick( wxCommandEvent& event ); - void OnOkButtonClick( wxCommandEvent& event ); - void OnLayerCountClick( wxCommandEvent& event ); - void OnLayerGridLeftClick( wxGridEvent& event ){ event.Skip(); } - void OnLayerGridRighttClick( wxGridEvent& event ){ event.Skip(); } - void Init(); - void SetRoutableLayerStatus( ); - bool TestDataValidity(); - - public: - DIALOG_COPPER_LAYERS_SETUP( WinEDA_PcbFrame* parent ); - ~DIALOG_COPPER_LAYERS_SETUP( ) { }; - -}; - -#endif //__dialog_design_rules_h_ diff --git a/pcbnew/dialog_copper_layers_setup_base.cpp b/pcbnew/dialog_copper_layers_setup_base.cpp deleted file mode 100644 index 715ed79292..0000000000 --- a/pcbnew/dialog_copper_layers_setup_base.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_copper_layers_setup_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_COPPER_LAYERS_SETUP_BASE::DIALOG_COPPER_LAYERS_SETUP_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); - - wxBoxSizer* bMainSizer; - bMainSizer = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bMainSizerLayers; - bMainSizerLayers = new wxBoxSizer( wxHORIZONTAL ); - - wxString m_LayersCountSelectionChoices[] = { _("1"), _("2"), _("4"), _("6"), _("8"), _("10"), _("12"), _("14"), _("16") }; - int m_LayersCountSelectionNChoices = sizeof( m_LayersCountSelectionChoices ) / sizeof( wxString ); - m_LayersCountSelection = new wxRadioBox( this, ID_LAYERS_COUNT_SELECTION, _("Layers Count"), wxDefaultPosition, wxDefaultSize, m_LayersCountSelectionNChoices, m_LayersCountSelectionChoices, 1, wxRA_SPECIFY_COLS ); - m_LayersCountSelection->SetSelection( 1 ); - bMainSizerLayers->Add( m_LayersCountSelection, 0, wxALL, 5 ); - - m_gridLayersProperties = new wxGrid( this, ID_LAYERS_PROPERTIES, wxDefaultPosition, wxDefaultSize, 0 ); - - // Grid - m_gridLayersProperties->CreateGrid( 16, 3 ); - m_gridLayersProperties->EnableEditing( true ); - m_gridLayersProperties->EnableGridLines( true ); - m_gridLayersProperties->EnableDragGridSize( false ); - m_gridLayersProperties->SetMargins( 0, 0 ); - - // Columns - m_gridLayersProperties->SetColSize( 0, 100 ); - m_gridLayersProperties->SetColSize( 1, 100 ); - m_gridLayersProperties->SetColSize( 2, 150 ); - m_gridLayersProperties->EnableDragColMove( false ); - m_gridLayersProperties->EnableDragColSize( true ); - m_gridLayersProperties->SetColLabelSize( 30 ); - m_gridLayersProperties->SetColLabelValue( 0, _("Active") ); - m_gridLayersProperties->SetColLabelValue( 1, _("Status") ); - m_gridLayersProperties->SetColLabelValue( 2, _("Name") ); - m_gridLayersProperties->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - - // Rows - m_gridLayersProperties->AutoSizeRows(); - m_gridLayersProperties->EnableDragRowSize( true ); - m_gridLayersProperties->SetRowLabelSize( 80 ); - m_gridLayersProperties->SetRowLabelValue( 0, _("Top Layer") ); - m_gridLayersProperties->SetRowLabelValue( 1, _("Inner 14") ); - m_gridLayersProperties->SetRowLabelValue( 2, _("Inner 13") ); - m_gridLayersProperties->SetRowLabelValue( 3, _("Inner 12") ); - m_gridLayersProperties->SetRowLabelValue( 4, _("Inner 11") ); - m_gridLayersProperties->SetRowLabelValue( 5, _("Inner 10") ); - m_gridLayersProperties->SetRowLabelValue( 6, _("Inner 9") ); - m_gridLayersProperties->SetRowLabelValue( 7, _("Inner 8") ); - m_gridLayersProperties->SetRowLabelValue( 8, _("Inner 7") ); - m_gridLayersProperties->SetRowLabelValue( 9, _("Inner 6") ); - m_gridLayersProperties->SetRowLabelValue( 10, _("Inner 5") ); - m_gridLayersProperties->SetRowLabelValue( 11, _("Inner 4") ); - m_gridLayersProperties->SetRowLabelValue( 12, _("Inner 3") ); - m_gridLayersProperties->SetRowLabelValue( 13, _("Inner 2") ); - m_gridLayersProperties->SetRowLabelValue( 14, _("Inner 1") ); - m_gridLayersProperties->SetRowLabelValue( 15, _("Bottom Layer") ); - m_gridLayersProperties->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - - // Label Appearance - - // Cell Defaults - m_gridLayersProperties->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - bMainSizerLayers->Add( m_gridLayersProperties, 1, wxALL|wxEXPAND, 5 ); - - bMainSizer->Add( bMainSizerLayers, 1, wxEXPAND, 5 ); - - wxStaticBoxSizer* sbSizer1; - sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Messages:") ), wxVERTICAL ); - - m_MessagesList = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO ); - m_MessagesList->SetMinSize( wxSize( -1,150 ) ); - - sbSizer1->Add( m_MessagesList, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - - bMainSizer->Add( sbSizer1, 0, wxEXPAND, 5 ); - - m_sdbSizer1 = new wxStdDialogButtonSizer(); - m_sdbSizer1OK = new wxButton( this, wxID_OK ); - m_sdbSizer1->AddButton( m_sdbSizer1OK ); - m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); - m_sdbSizer1->Realize(); - bMainSizer->Add( m_sdbSizer1, 0, wxALIGN_RIGHT, 5 ); - - this->SetSizer( bMainSizer ); - this->Layout(); - - // Connect Events - m_LayersCountSelection->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_COPPER_LAYERS_SETUP_BASE::OnLayerCountClick ), NULL, this ); - m_gridLayersProperties->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYERS_SETUP_BASE::OnLayerGridLeftClick ), NULL, this ); - m_gridLayersProperties->Connect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYERS_SETUP_BASE::OnLayerGridRighttClick ), NULL, this ); - m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYERS_SETUP_BASE::OnCancelButtonClick ), NULL, this ); - m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYERS_SETUP_BASE::OnOkButtonClick ), NULL, this ); -} - -DIALOG_COPPER_LAYERS_SETUP_BASE::~DIALOG_COPPER_LAYERS_SETUP_BASE() -{ - // Disconnect Events - m_LayersCountSelection->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_COPPER_LAYERS_SETUP_BASE::OnLayerCountClick ), NULL, this ); - m_gridLayersProperties->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYERS_SETUP_BASE::OnLayerGridLeftClick ), NULL, this ); - m_gridLayersProperties->Disconnect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYERS_SETUP_BASE::OnLayerGridRighttClick ), NULL, this ); - m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYERS_SETUP_BASE::OnCancelButtonClick ), NULL, this ); - m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYERS_SETUP_BASE::OnOkButtonClick ), NULL, this ); -} diff --git a/pcbnew/dialog_copper_layers_setup_base.fbp b/pcbnew/dialog_copper_layers_setup_base.fbp deleted file mode 100644 index 07930166f4..0000000000 --- a/pcbnew/dialog_copper_layers_setup_base.fbp +++ /dev/null @@ -1,349 +0,0 @@ - - - - - - C++ - 1 - UTF-8 - connect - dialog_copper_layers_setup_base - 1000 - none - 1 - dialog_copper_layers_setup_base - - . - - 1 - 0 - 0 - - - - - 1 - - - - 0 - wxID_ANY - - -1,-1 - DIALOG_COPPER_LAYERS_SETUP_BASE - - 558,598 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - - Copper layers setup - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bMainSizer - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - - bMainSizerLayers - wxHORIZONTAL - none - - 5 - wxALL - 0 - - - "1" "2" "4" "6" "8" "10" "12" "14" "16" - - 1 - - - 0 - ID_LAYERS_COUNT_SELECTION - Layers Count - 1 - - - m_LayersCountSelection - protected - - 1 - - wxRA_SPECIFY_COLS - - - - - - - - - - - - - - - - - - - - - - - OnLayerCountClick - - - - - - - - - - 5 - wxALL|wxEXPAND - 1 - - 0 - 1 - - - - wxALIGN_CENTRE - - wxALIGN_CENTRE - wxALIGN_CENTRE - 30 - "Active" "Status" "Name" - wxALIGN_CENTRE - 3 - 100,100,150 - - 0 - 1 - 0 - 1 - 1 - 1 - - - - 1 - 0 - ID_LAYERS_PROPERTIES - - - - 0 - 0 - - -1,-1 - m_gridLayersProperties - protected - - wxALIGN_CENTRE - 80 - "Top Layer" "Inner 14" "Inner 13" "Inner 12" "Inner 11" "Inner 10" "Inner 9" "Inner 8" "Inner 7" "Inner 6" "Inner 5" "Inner 4" "Inner 3" "Inner 2" "Inner 1" "Bottom Layer" - wxALIGN_CENTRE - - 16 - - - - - - - - - - - OnLayerGridLeftClick - - OnLayerGridRighttClick - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - wxID_ANY - Messages: - - sbSizer1 - wxVERTICAL - none - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 0 - - - - 1 - - - 0 - wxID_ANY - - -1,150 - m_MessagesList - protected - - - wxHW_SCROLLBAR_AUTO - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_RIGHT - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer1 - protected - - OnCancelButtonClick - - - - OnOkButtonClick - - - - - - - - diff --git a/pcbnew/dialog_copper_layers_setup_base.h b/pcbnew/dialog_copper_layers_setup_base.h deleted file mode 100644 index 23304b38c4..0000000000 --- a/pcbnew/dialog_copper_layers_setup_base.h +++ /dev/null @@ -1,60 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __dialog_copper_layers_setup_base__ -#define __dialog_copper_layers_setup_base__ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - -#define ID_LAYERS_COUNT_SELECTION 1000 -#define ID_LAYERS_PROPERTIES 1001 - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_COPPER_LAYERS_SETUP_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_COPPER_LAYERS_SETUP_BASE : public wxDialog -{ - private: - - protected: - wxRadioBox* m_LayersCountSelection; - wxGrid* m_gridLayersProperties; - wxHtmlWindow* m_MessagesList; - wxStdDialogButtonSizer* m_sdbSizer1; - wxButton* m_sdbSizer1OK; - wxButton* m_sdbSizer1Cancel; - - // Virtual event handlers, overide them in your derived class - virtual void OnLayerCountClick( wxCommandEvent& event ){ event.Skip(); } - virtual void OnLayerGridLeftClick( wxGridEvent& event ){ event.Skip(); } - virtual void OnLayerGridRighttClick( wxGridEvent& event ){ event.Skip(); } - virtual void OnCancelButtonClick( wxCommandEvent& event ){ event.Skip(); } - virtual void OnOkButtonClick( wxCommandEvent& event ){ event.Skip(); } - - - public: - DIALOG_COPPER_LAYERS_SETUP_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Copper layers setup"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 558,598 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_COPPER_LAYERS_SETUP_BASE(); - -}; - -#endif //__dialog_copper_layers_setup_base__ diff --git a/pcbnew/dialog_design_rules.cpp b/pcbnew/dialog_design_rules.cpp index 3780275285..3443f1b567 100644 --- a/pcbnew/dialog_design_rules.cpp +++ b/pcbnew/dialog_design_rules.cpp @@ -37,6 +37,7 @@ #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "pcbnew_id.h" #include "dialog_design_rules.h" diff --git a/pcbnew/dialog_drc.cpp b/pcbnew/dialog_drc.cpp index 8eb595cfb8..6af51854a5 100644 --- a/pcbnew/dialog_drc.cpp +++ b/pcbnew/dialog_drc.cpp @@ -11,6 +11,7 @@ #include "dialog_drc.h" #include "common.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" /* class DIALOG_DRC_CONTROL: a dialog to set DRC parameters (clearance, min cooper size) * and run DRC tests diff --git a/pcbnew/dialog_general_options.cpp b/pcbnew/dialog_general_options.cpp index e5b2c63bec..0cbbef2331 100644 --- a/pcbnew/dialog_general_options.cpp +++ b/pcbnew/dialog_general_options.cpp @@ -3,8 +3,8 @@ // Author: jean-pierre Charras ///////////////////////////////////////////////////////////////////////////// /* functions relatives to the dialogs opened from the main menu : - Prefernces/general - Prefernces/display + Preferences/general + Preferences/display */ #include "fctsys.h" #include "common.h" @@ -12,6 +12,7 @@ #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "pcbnew_id.h" diff --git a/pcbnew/dialog_graphic_item_properties.cpp b/pcbnew/dialog_graphic_item_properties.cpp index 7850ddef84..c567a2b091 100644 --- a/pcbnew/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialog_graphic_item_properties.cpp @@ -17,6 +17,7 @@ #include "class_drawpanel.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "dialog_graphic_item_properties_base.h" diff --git a/pcbnew/dialog_layers_setup.cpp b/pcbnew/dialog_layers_setup.cpp index bcaeb3b752..3e53e57731 100644 --- a/pcbnew/dialog_layers_setup.cpp +++ b/pcbnew/dialog_layers_setup.cpp @@ -10,6 +10,7 @@ #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "pcbnew_id.h" @@ -259,7 +260,7 @@ void DialogLayerSetup::SetLayerType( int Layer, LAYER_T Type ) //============================================================================== // The layer mask for non-copper layers is obtained from the new -// EDA_BoardDesignSettings::m*EnabledLayers, but for compatibility, the mask +// EDA_BoardDesignSettings::m_EnabledLayers, but for compatibility, the mask // for the copper-layers is obtained from g_DesignSettings::m_CopperLayerCount // Hopefully in the future we may unify them, perhaps saving only the mask and @@ -279,7 +280,7 @@ int DialogLayerSetup::GetLayersMask() else Aux /= 2; - return CopperMasks[Aux] | m_Pcb->GetEnabledLayers() & ALL_NO_CU_LAYERS; + return CopperMasks[Aux] | ( m_Pcb->GetEnabledLayers() & ALL_NO_CU_LAYERS ); } //============================================================================== @@ -997,7 +998,7 @@ void DialogLayerSetup::OnOKClick( wxCommandEvent& event ) NumberOfCopperLayers++; } - m_Pcb->m_BoardSettings->m_CopperLayerCount = NumberOfCopperLayers; + m_Pcb->m_BoardSettings->SetCopperLayerCount( NumberOfCopperLayers ); m_Pcb->SetEnabledLayers( m_LayersMask ); diff --git a/pcbnew/dialog_track_options.cpp b/pcbnew/dialog_track_options.cpp index 33766dcbdb..687a1a99f7 100644 --- a/pcbnew/dialog_track_options.cpp +++ b/pcbnew/dialog_track_options.cpp @@ -12,6 +12,7 @@ #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "dialog_track_options.h" #include diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index 58d2d3e11f..9d35384120 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -37,6 +37,7 @@ #include "autorout.h" #include "trigo.h" #include "gestfich.h" +#include "class_board_design_settings.h" #include "protos.h" @@ -771,7 +772,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) // test: if( layer1 == COPPER_LAYER_N && layer2 == LAYER_N_2 ) err = false; - if( layer1 == (g_DesignSettings.m_CopperLayerCount - 2 ) && layer2 == LAYER_CMP_N ) + if( layer1 == (g_DesignSettings.GetCopperLayerCount() - 2 ) && layer2 == LAYER_CMP_N ) err = false; if( err ) { diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index ebbb3a435a..b73dc8c425 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -12,6 +12,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "autorout.h" #include "protos.h" @@ -1105,7 +1106,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) // If only one copper layer is enabled, the only such layer // that can be selected to is the "Copper" layer (so the // selection of any other copper layer is disregarded). - if( GetBoard()->m_BoardSettings->m_CopperLayerCount < 2 ) + if( GetBoard()->m_BoardSettings->GetCopperLayerCount() < 2 ) { if( layer != COPPER_LAYER_N ) { @@ -1124,7 +1125,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) else { if( (layer != COPPER_LAYER_N) && (layer != LAYER_CMP_N) - && (layer >= GetBoard()->m_BoardSettings->m_CopperLayerCount - 1) ) + && (layer >= GetBoard()->m_BoardSettings->GetCopperLayerCount() - 1) ) { // Uncomment following command (and line 17) to beep // the speaker. (Doing that would provide feedback to diff --git a/pcbnew/edit_pcb_text.cpp b/pcbnew/edit_pcb_text.cpp index 17cdff2ff0..1a5fb0f6c5 100644 --- a/pcbnew/edit_pcb_text.cpp +++ b/pcbnew/edit_pcb_text.cpp @@ -9,6 +9,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "protos.h" diff --git a/pcbnew/edit_track_width.cpp b/pcbnew/edit_track_width.cpp index e898e245ce..d787e2c78f 100644 --- a/pcbnew/edit_track_width.cpp +++ b/pcbnew/edit_track_width.cpp @@ -10,6 +10,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "protos.h" diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index 8c4f1f6f80..adc86290d5 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -11,6 +11,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "protos.h" diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index db7adc1529..c93c85ce07 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -10,6 +10,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "protos.h" @@ -204,10 +205,11 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) if ( old_layer == COPPER_LAYER_N ) ((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_N_2; else if ( old_layer == LAYER_CMP_N ) - ((PCB_SCREEN*)GetScreen())->m_Active_Layer = GetBoard()->m_BoardSettings->m_CopperLayerCount - 2; + ((PCB_SCREEN*)GetScreen())->m_Active_Layer = + GetBoard()->m_BoardSettings->GetCopperLayerCount() - 2; else if ( old_layer == LAYER_N_2 ) ((PCB_SCREEN*)GetScreen())->m_Active_Layer = COPPER_LAYER_N; - else if ( old_layer == GetBoard()->m_BoardSettings->m_CopperLayerCount - 2 ) + else if ( old_layer == GetBoard()->m_BoardSettings->GetCopperLayerCount() - 2 ) ((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_CMP_N; // else error via->SetLayerPair( old_layer, ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 167ae33dd2..e336679ab5 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -9,6 +9,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "drc_stuff.h" #include "trigo.h" diff --git a/pcbnew/event_handlers_tracks_vias_sizes.cpp b/pcbnew/event_handlers_tracks_vias_sizes.cpp index 3dc1b79010..f35e3ef4a1 100644 --- a/pcbnew/event_handlers_tracks_vias_sizes.cpp +++ b/pcbnew/event_handlers_tracks_vias_sizes.cpp @@ -14,6 +14,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" /** Function Tracks_and_Vias_Size_Event * Event handler for tracks and vias size selection (and some options) diff --git a/pcbnew/gen_drill_report_files.cpp b/pcbnew/gen_drill_report_files.cpp index 3455b34769..8ee1bbe019 100644 --- a/pcbnew/gen_drill_report_files.cpp +++ b/pcbnew/gen_drill_report_files.cpp @@ -18,6 +18,7 @@ using namespace std; #include "pcbnew.h" #include "pcbplot.h" #include "macros.h" +#include "class_board_design_settings.h" #include "gendrill.h" /**********************************************************************************/ @@ -394,7 +395,7 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, const wxString& aBoardFilenam sprintf( line, "\ntotal holes count %d\n\n\n", TotalHoleCount ); fputs( line, aFile ); - if( g_DesignSettings.m_CopperLayerCount <= 2 ) + if( g_DesignSettings.GetCopperLayerCount() <= 2 ) break; if( gen_through_holes ) @@ -404,7 +405,7 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, const wxString& aBoardFilenam if( layer2 >= LAYER_CMP_N ) // no more layer pair to consider break; layer1++; layer2++; // use next layer pair - if( layer2 == g_DesignSettings.m_CopperLayerCount - 1 ) // The last layer is reached + if( layer2 == g_DesignSettings.GetCopperLayerCount() - 1 ) // The last layer is reached layer2 = LAYER_CMP_N; // the last layer is always the component layer } gen_through_holes = false; diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp index b0893ec58b..21afb50027 100644 --- a/pcbnew/gendrill.cpp +++ b/pcbnew/gendrill.cpp @@ -18,6 +18,7 @@ #include "pcbplot.h" #include "macros.h" #include "appl_wxstruct.h" +#include "class_board_design_settings.h" #include "gendrill.h" @@ -364,7 +365,7 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event ) layer1++; layer2++; // use next layer pair - if( layer2 == g_DesignSettings.m_CopperLayerCount - 1 ) + if( layer2 == g_DesignSettings.GetCopperLayerCount() - 1 ) layer2 = LAYER_CMP_N; // the last layer is always the component layer } diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 906bed8faf..45ecf935e8 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -9,6 +9,7 @@ #include "pcbnew_id.h" #include "class_drawpanel.h" #include "confirm.h" +#include "class_board_design_settings.h" #include "hotkeys.h" #include "protos.h" @@ -189,11 +190,11 @@ void WinEDA_PcbFrame::OnHotKey(wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct) ll = GetScreen()->m_Active_Layer; if ((ll <= COPPER_LAYER_N) || (ll > CMP_N)) break; - if (GetBoard()->m_BoardSettings->m_CopperLayerCount < 2) // Single layer + if (GetBoard()->m_BoardSettings->GetCopperLayerCount() < 2) // Single layer ll = COPPER_LAYER_N; else if (ll == CMP_N) ll = MAX(COPPER_LAYER_N, - GetBoard()->m_BoardSettings->m_CopperLayerCount - 2); + GetBoard()->m_BoardSettings->GetCopperLayerCount() - 2); else ll--; SwitchLayer(DC, ll); @@ -203,9 +204,9 @@ void WinEDA_PcbFrame::OnHotKey(wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct) ll = GetScreen()->m_Active_Layer; if ((ll < COPPER_LAYER_N) || (ll >= CMP_N)) break; - if (GetBoard()->m_BoardSettings->m_CopperLayerCount < 2) // Single layer + if (GetBoard()->m_BoardSettings->GetCopperLayerCount() < 2) // Single layer ll = COPPER_LAYER_N; - else if (ll >= GetBoard()->m_BoardSettings->m_CopperLayerCount - 2) + else if (ll >= GetBoard()->m_BoardSettings->GetCopperLayerCount() - 2) ll = CMP_N; else ll++; diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index c288266f55..474ad9a751 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -9,6 +9,7 @@ #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "protos.h" @@ -175,10 +176,13 @@ bool WinEDA_PcbFrame::Clear_Pcb( bool aQuery ) GetScreen()->SetGrid( gridsize ); g_HightLigt_Status = 0; + // Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled) + g_DesignSettings.SetEnabledLayers(ALL_LAYERS); // Default copper layers count set to 2: double layer board - g_DesignSettings.m_CopperLayerCount = 2; + g_DesignSettings.SetCopperLayerCount(2); // Update display: + g_DesignSettings.SetVisibleLayers( ALL_LAYERS ); SetToolbars(); Zoom_Automatique( true ); diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 92fb760e09..1f1760bd63 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -13,6 +13,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #ifdef PCBNEW #include "autorout.h" @@ -232,13 +233,14 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum ) sscanf( data, "%X", &Masque_Layer ); // Setup layer count - GetBoard()->m_BoardSettings->m_CopperLayerCount = 0; + int layer_count = 0; for( ii = 0; ii < NB_COPPER_LAYERS; ii++ ) { if( Masque_Layer & 1 ) - GetBoard()->m_BoardSettings->m_CopperLayerCount++; + layer_count++; Masque_Layer >>= 1; } + GetBoard()->m_BoardSettings->SetCopperLayerCount( layer_count ); continue; } @@ -363,7 +365,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) { int tmp; sscanf( data, "%d", &tmp ); - GetBoard()->m_BoardSettings->m_CopperLayerCount = tmp; + GetBoard()->m_BoardSettings->SetCopperLayerCount( tmp ); continue; } @@ -673,7 +675,7 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File ) int NbModules, NbDrawItem, NbLayers; /* Write copper layer count */ - NbLayers = GetBoard()->m_BoardSettings->m_CopperLayerCount; + NbLayers = GetBoard()->m_BoardSettings->GetCopperLayerCount(); fprintf( File, "$GENERAL\n" ); fprintf( File, "LayerCount %d\n", NbLayers ); diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp index a9506255e8..b88d8cf186 100644 --- a/pcbnew/locate.cpp +++ b/pcbnew/locate.cpp @@ -7,6 +7,7 @@ #include "common.h" #include "pcbnew.h" +#include "class_board_design_settings.h" #include "protos.h" diff --git a/pcbnew/magnetic_tracks_functions.cpp b/pcbnew/magnetic_tracks_functions.cpp index 88c1889025..4530eb1805 100644 --- a/pcbnew/magnetic_tracks_functions.cpp +++ b/pcbnew/magnetic_tracks_functions.cpp @@ -12,6 +12,7 @@ #include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "protos.h" #include "pcbnew_id.h" diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index 1fe0001f70..a54ca8ec9e 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -8,6 +8,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "protos.h" @@ -22,11 +23,6 @@ static MIREPCB s_TargetCopy( NULL ); /* Used to store "old" values of the c * parameters before edition (used in undo/redo or cancel operations) */ -enum id_mire_properties { - ID_SIZE_MIRE = 1900, // (Not currently used anywhere else) - ID_LISTBOX_SHAPE_MIRE -}; - /************************************/ /* class WinEDA_MirePropertiesFrame */ /************************************/ @@ -116,7 +112,7 @@ WinEDA_MirePropertiesFrame::WinEDA_MirePropertiesFrame( WinEDA_PcbFrame* parent, // Shape wxString shape_list[2] = { _( "shape +" ), _( "shape X" ) }; - m_MireShape = new wxRadioBox( this, ID_LISTBOX_SHAPE_MIRE, + m_MireShape = new wxRadioBox( this, wxID_ANY, _( "Target Shape:" ), wxDefaultPosition, wxSize( -1, -1 ), 2, shape_list, 1 ); diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 0564d41e10..005e1588a7 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -13,6 +13,7 @@ #include "gestfich.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "protos.h" /* Fonctions locales */ diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 2605a62073..b879091e00 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -11,17 +11,15 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" -//#include "autorout.h" #include "pcbnew_id.h" #include "hotkeys.h" #include "collectors.h" -//#include "protos.h" - - /* Bitmaps */ #include "bitmaps.h" + static wxMenu* Append_Track_Width_List( BOARD * aBoard ); diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 8ef76dc938..5185405351 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -12,13 +12,13 @@ #include "gestfich.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "pcbplot.h" #include "pcbnew_config.h" #include "worksheet.h" #include "pcbnew_id.h" #include "hotkeys.h" #include "protos.h" -//#include "dialog_copper_layers_setup.h" /* Routines Locales */ diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index d32e7e8c5f..da4c4c3abe 100644 --- a/pcbnew/plot_rtn.cpp +++ b/pcbnew/plot_rtn.cpp @@ -13,6 +13,7 @@ #include "pcbnew.h" #include "pcbplot.h" #include "trigo.h" +#include "class_board_design_settings.h" /* Fonctions locales */ diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index c19c9df3e0..733bab0440 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -8,6 +8,7 @@ #include "class_drawpanel.h" #include "pcbnew.h" +#include "class_board_design_settings.h" #include "pcbplot.h" #include "protos.h" diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index 4430a67009..9ccb9ee125 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -10,6 +10,7 @@ #include "confirm.h" #include "pcbnew.h" #include "autorout.h" +#include "class_board_design_settings.h" #include "protos.h" diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index a109d37207..98cc9252cf 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -7,13 +7,10 @@ #include "confirm.h" #include "pcbnew.h" +#include "class_board_design_settings.h" #include "protos.h" -/* Variables locales */ - -/* Fonctions locales: */ - enum layer_sel_id { ID_LAYER_SELECT_TOP = 1800, ID_LAYER_SELECT_BOTTOM, @@ -111,7 +108,7 @@ WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent, /* Build the layer list */ LayerCount = 0; - int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount - 1]; + int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.GetCopperLayerCount( ) - 1]; Masque_Layer += ALL_NO_CU_LAYERS; for( ii = 0; ii < NB_LAYERS; ii++ ) { @@ -231,7 +228,7 @@ void WinEDA_BasePcbFrame::SelectLayerPair() // Check whether more than one copper layer has been enabled for the // current PCB file, as Layer Pairs can only meaningfully be defined // within PCB files which contain at least two copper layers. - if( GetBoard()->m_BoardSettings->m_CopperLayerCount < 2 ) + if( GetBoard()->m_BoardSettings->GetCopperLayerCount( ) < 2 ) { wxString InfoMsg; InfoMsg = _( "Less than two copper layers are being used." ); @@ -273,7 +270,7 @@ WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent PCB_SCREEN* screen = (PCB_SCREEN*) m_Parent->GetScreen(); /* Construction de la liste des couches autoris�s */ - int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount - 1]; + int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.GetCopperLayerCount( ) - 1]; Masque_Layer += ALL_NO_CU_LAYERS; for( ii = 0, LayerCount = 0; ii < NB_COPPER_LAYERS; ii++ ) { diff --git a/pcbnew/set_color.cpp b/pcbnew/set_color.cpp index 0ecf018ba6..981a7f8643 100644 --- a/pcbnew/set_color.cpp +++ b/pcbnew/set_color.cpp @@ -12,6 +12,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" //#include "protos.h" diff --git a/pcbnew/solve.cpp b/pcbnew/solve.cpp index b0dbda6691..7b54049a9a 100644 --- a/pcbnew/solve.cpp +++ b/pcbnew/solve.cpp @@ -12,6 +12,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "autorout.h" #include "zones.h" #include "protos.h" @@ -418,7 +419,7 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, /* Test du cas trivial: connection directe par superposition des pads */ if( (row_source == row_target) && (col_source == col_target) && ( pad_masque_layer_e & pad_masque_layer_s & - g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount - 1]) ) + g_TabAllCopperLayerMask[g_DesignSettings.GetCopperLayerCount() - 1]) ) { result = TRIVIAL_SUCCESS; goto end_of_route; diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index f9ee4db318..a642cecb17 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -39,6 +39,7 @@ #include "confirm.h" // DisplayError() #include "gestfich.h" // EDA_FileSelector() #include "autorout.h" // NET_CODES_OK +#include "class_board_design_settings.h" #include "trigo.h" // RotatePoint() #include // std::set diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index 716d3067e4..71939267a2 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -7,6 +7,7 @@ #include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "bitmaps.h" diff --git a/pcbnew/toolbars_update_user_interface.cpp b/pcbnew/toolbars_update_user_interface.cpp index f52fe156aa..5c5316ae9d 100644 --- a/pcbnew/toolbars_update_user_interface.cpp +++ b/pcbnew/toolbars_update_user_interface.cpp @@ -16,6 +16,7 @@ #include "pcbnew_id.h" #include "drc_stuff.h" #include "3d_viewer.h" +#include "class_board_design_settings.h" /* helper to convert an integer value to a string, using mils or mm * according to g_UnitMetric value diff --git a/pcbnew/via_edit.cpp b/pcbnew/via_edit.cpp index 0a2b723054..3757ebabef 100644 --- a/pcbnew/via_edit.cpp +++ b/pcbnew/via_edit.cpp @@ -8,6 +8,7 @@ #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" +#include "class_board_design_settings.h" #include "pcbnew_id.h"