diff --git a/include/class_board_design_settings.h b/include/class_board_design_settings.h index 55d0343886..f2d94bd445 100644 --- a/include/class_board_design_settings.h +++ b/include/class_board_design_settings.h @@ -11,33 +11,39 @@ class BOARD_DESIGN_SETTINGS { protected: - int m_CopperLayerCount; ///< Number of copper layers for this design - 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 + int m_CopperLayerCount; ///< Number of copper layers for this design + 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: - bool m_MicroViasAllowed; ///< true to allow micro vias - int m_CurrentViaType; ///< via type (VIA_BLIND_BURIED, VIA_TROUGHT VIA_MICROVIA) + bool m_MicroViasAllowed; ///< true to allow micro vias + int m_CurrentViaType; ///< via type (VIA_BLIND_BURIED, VIA_TROUGHT VIA_MICROVIA) /// if true, when creating a new track starting on an existing track, use this track width - bool m_UseConnectedTrackWidth; - 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 + bool m_UseConnectedTrackWidth; + 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 // Global mask margins: - int m_SolderMaskMargin; ///< Solder mask margin - int m_SolderPasteMargin; ///< Solder paste margin absolute value - double m_SolderPasteMarginRatio; ///< Solder pask margin ratio value of pad size - ///< The final margin is the sum of these 2 values - int m_BoardThickness; ///< Board Thickness for 3D viewer + int m_SolderMaskMargin; ///< Solder mask margin + int m_SolderPasteMargin; ///< Solder paste margin absolute value + double m_SolderPasteMarginRatio; ///< Solder pask margin ratio value of pad size + ///< The final margin is the sum of these 2 values + int m_BoardThickness; ///< Board Thickness for 3D viewer + + // Variables used in footprint handling + wxSize m_ModuleTextSize; ///< Default footprint texts size + int m_ModuleTextWidth; + int m_ModuleSegmentWidth; public: BOARD_DESIGN_SETTINGS(); diff --git a/pcbnew/class_board_design_settings.cpp b/pcbnew/class_board_design_settings.cpp index 8ec99f8df2..9e98c3c10a 100644 --- a/pcbnew/class_board_design_settings.cpp +++ b/pcbnew/class_board_design_settings.cpp @@ -45,6 +45,11 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() // The final margin is the sum of these 2 values // Usually < 0 because the mask is smaller than pad + m_ModuleTextSize = wxSize( 500, 500 ); + m_ModuleTextWidth = 100; + m_ModuleSegmentWidth = 100; + + // Layer thickness for 3D viewer m_BoardThickness = (int)(1.6 * PCB_INTERNAL_UNIT / 25.4); } diff --git a/pcbnew/dialogs/dialog_graphic_items_options.cpp b/pcbnew/dialogs/dialog_graphic_items_options.cpp index a75cdf185b..8b704cb1ec 100644 --- a/pcbnew/dialogs/dialog_graphic_items_options.cpp +++ b/pcbnew/dialogs/dialog_graphic_items_options.cpp @@ -86,20 +86,20 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::initValues() /* Modules: Edges width */ AddUnitSymbol( *m_EdgeModWidthTitle ); PutValueInLocalUnits( *m_OptModuleEdgesWidth, - g_ModuleSegmentWidth, PCB_INTERNAL_UNIT ); + m_BrdSettings.m_ModuleSegmentWidth, PCB_INTERNAL_UNIT ); /* Modules: Texts: Size & width */ AddUnitSymbol( *m_TextModWidthTitle ); PutValueInLocalUnits( *m_OptModuleTextWidth, - g_ModuleTextWidth, PCB_INTERNAL_UNIT ); + m_BrdSettings.m_ModuleTextWidth, PCB_INTERNAL_UNIT ); AddUnitSymbol( *m_TextModSizeVTitle ); PutValueInLocalUnits( *m_OptModuleTextVSize, - g_ModuleTextSize.y, PCB_INTERNAL_UNIT ); + m_BrdSettings.m_ModuleTextSize.y, PCB_INTERNAL_UNIT ); AddUnitSymbol( *m_TextModSizeHTitle ); PutValueInLocalUnits( *m_OptModuleTextHSize, - g_ModuleTextSize.x, PCB_INTERNAL_UNIT ); + m_BrdSettings.m_ModuleTextSize.x, PCB_INTERNAL_UNIT ); AddUnitSymbol( *m_DefaultPenSizeTitle ); PutValueInLocalUnits( *m_DefaultPenSizeCtrl, @@ -122,13 +122,13 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::OnOkClick( wxCommandEvent& event ) m_Parent->GetBoard()->SetDesignSettings( m_BrdSettings ); - g_ModuleSegmentWidth = + m_BrdSettings.m_ModuleSegmentWidth = ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth, PCB_INTERNAL_UNIT ); - g_ModuleTextWidth = + m_BrdSettings.m_ModuleTextWidth = ReturnValueFromTextCtrl( *m_OptModuleTextWidth, PCB_INTERNAL_UNIT ); - g_ModuleTextSize.y = + m_BrdSettings.m_ModuleTextSize.y = ReturnValueFromTextCtrl( *m_OptModuleTextVSize, PCB_INTERNAL_UNIT ); - g_ModuleTextSize.x = + m_BrdSettings.m_ModuleTextSize.x = ReturnValueFromTextCtrl( *m_OptModuleTextHSize, PCB_INTERNAL_UNIT ); g_DrawDefaultLineThickness = diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index c0e67f1832..5267f7be4b 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -159,40 +159,40 @@ static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge ) { - MODULE* Module = GetBoard()->m_Modules; + MODULE* module = GetBoard()->m_Modules; - SaveCopyInUndoList( Module, UR_MODEDIT ); + SaveCopyInUndoList( module, UR_MODEDIT ); if( aEdge == NULL ) { - aEdge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings; + aEdge = (EDGE_MODULE*) (BOARD_ITEM*) module->m_Drawings; for( ; aEdge != NULL; aEdge = aEdge->Next() ) { if( aEdge->Type() != PCB_MODULE_EDGE_T ) continue; - aEdge->SetWidth( g_ModuleSegmentWidth ); + aEdge->SetWidth( GetBoard()->GetDesignSettings().m_ModuleSegmentWidth ); } } else { - aEdge->SetWidth( g_ModuleSegmentWidth ); + aEdge->SetWidth( GetBoard()->GetDesignSettings().m_ModuleSegmentWidth ); } OnModify(); - Module->CalculateBoundingBox(); - Module->m_LastEdit_Time = time( NULL ); + module->CalculateBoundingBox(); + module->m_LastEdit_Time = time( NULL ); } -void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* Edge ) +void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* aEdge ) { - MODULE* Module = GetBoard()->m_Modules; + MODULE* module = GetBoard()->m_Modules; int new_layer = SILKSCREEN_N_FRONT; - if( Edge != NULL ) - new_layer = Edge->GetLayer(); + if( aEdge ) + new_layer = aEdge->GetLayer(); /* Ask for the new layer */ new_layer = SelectLayer( new_layer, FIRST_COPPER_LAYER, LAST_NO_COPPER_LAYER ); @@ -209,28 +209,28 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* Edge ) return; } - SaveCopyInUndoList( Module, UR_MODEDIT ); + SaveCopyInUndoList( module, UR_MODEDIT ); - if( Edge == NULL ) + if( aEdge == NULL ) { - Edge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings; + aEdge = (EDGE_MODULE*) (BOARD_ITEM*) module->m_Drawings; - for( ; Edge != NULL; Edge = Edge->Next() ) + for( ; aEdge != NULL; aEdge = aEdge->Next() ) { - if( Edge->Type() != PCB_MODULE_EDGE_T ) + if( aEdge->Type() != PCB_MODULE_EDGE_T ) continue; - Edge->SetLayer( new_layer ); + aEdge->SetLayer( new_layer ); } } else { - Edge->SetLayer( new_layer ); + aEdge->SetLayer( new_layer ); } OnModify(); - Module->CalculateBoundingBox(); - Module->m_LastEdit_Time = time( NULL ); + module->CalculateBoundingBox(); + module->m_LastEdit_Time = time( NULL ); } @@ -238,7 +238,7 @@ void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge ) { wxString buffer; - buffer = ReturnStringFromValue( g_UserUnit, g_ModuleSegmentWidth, + buffer = ReturnStringFromValue( g_UserUnit, GetBoard()->GetDesignSettings().m_ModuleSegmentWidth, GetScreen()->GetInternalUnits() ); wxTextEntryDialog dlg( this, _( "New Width:" ), _( "Edge Width" ), buffer ); @@ -246,13 +246,13 @@ void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge ) return; // canceled by user buffer = dlg.GetValue( ); - g_ModuleSegmentWidth = ReturnValueFromString( g_UserUnit, buffer, - GetScreen()->GetInternalUnits() ); + GetBoard()->GetDesignSettings().m_ModuleSegmentWidth = + ReturnValueFromString( g_UserUnit, buffer, GetScreen()->GetInternalUnits() ); if( aEdge ) { MODULE* module = GetBoard()->m_Modules; - aEdge->SetWidth( g_ModuleSegmentWidth ); + aEdge->SetWidth( GetBoard()->GetDesignSettings().m_ModuleSegmentWidth ); module->CalculateBoundingBox(); OnModify(); } @@ -337,7 +337,7 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge, if( Edge->GetShape() == S_ARC ) Edge->SetAngle( ArcValue ); - Edge->SetWidth( g_ModuleSegmentWidth ); + Edge->SetWidth( GetBoard()->GetDesignSettings().m_ModuleSegmentWidth ); Edge->SetLayer( module->GetLayer() ); if( module->GetLayer() == LAYER_N_FRONT ) @@ -383,7 +383,7 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge, Edge = newedge; // point now new item Edge->SetFlags( IS_NEW ); - Edge->SetWidth( g_ModuleSegmentWidth ); + Edge->SetWidth( GetBoard()->GetDesignSettings().m_ModuleSegmentWidth ); Edge->SetStart( GetScreen()->GetCrossHairPosition() ); Edge->SetEnd( Edge->GetStart() ); diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index c04e89ed25..a35fe147b0 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -76,10 +76,10 @@ TEXTE_MODULE* PCB_BASE_FRAME::CreateTextModule( MODULE* Module, wxDC* DC ) Text->m_Text = wxT( "text" ); - g_ModuleTextWidth = Clamp_Text_PenSize( g_ModuleTextWidth, - MIN( g_ModuleTextSize.x, g_ModuleTextSize.y ), true ); - Text->m_Size = g_ModuleTextSize; - Text->m_Thickness = g_ModuleTextWidth; + GetBoard()->GetDesignSettings().m_ModuleTextWidth = Clamp_Text_PenSize( GetBoard()->GetDesignSettings().m_ModuleTextWidth, + MIN( GetBoard()->GetDesignSettings().m_ModuleTextSize.x, GetBoard()->GetDesignSettings().m_ModuleTextSize.y ), true ); + Text->m_Size = GetBoard()->GetDesignSettings().m_ModuleTextSize; + Text->m_Thickness = GetBoard()->GetDesignSettings().m_ModuleTextWidth; Text->m_Pos = GetScreen()->GetCrossHairPosition(); Text->SetLocalCoord(); @@ -316,8 +316,8 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC ) break; case PCB_MODULE_TEXT_T: - newSize = g_ModuleTextSize; - newThickness = g_ModuleTextWidth; + newSize = GetBoard()->GetDesignSettings().m_ModuleTextSize; + newThickness = GetBoard()->GetDesignSettings().m_ModuleTextWidth; moduleText = (TEXTE_MODULE*) aItem; text = (EDA_TEXT*) moduleText; break; @@ -380,7 +380,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) case TEXT_is_REFERENCE: item = module->m_Reference; - if( item->GetSize() != g_ModuleTextSize || item->GetThickness() != g_ModuleTextWidth ) + if( item->GetSize() != GetBoard()->GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetBoard()->GetDesignSettings().m_ModuleTextWidth ) undoItemList.PushItem( itemWrapper ); break; @@ -388,7 +388,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) case TEXT_is_VALUE: item = module->m_Value; - if( item->GetSize() != g_ModuleTextSize || item->GetThickness() != g_ModuleTextWidth ) + if( item->GetSize() != GetBoard()->GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetBoard()->GetDesignSettings().m_ModuleTextWidth ) undoItemList.PushItem( itemWrapper ); break; @@ -401,8 +401,8 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) { item = (TEXTE_MODULE*) boardItem; - if( item->GetSize() != g_ModuleTextSize - || item->GetThickness() != g_ModuleTextWidth ) + if( item->GetSize() != GetBoard()->GetDesignSettings().m_ModuleTextSize + || item->GetThickness() != GetBoard()->GetDesignSettings().m_ModuleTextWidth ) { undoItemList.PushItem( itemWrapper ); break; @@ -432,13 +432,13 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) switch( aType ) { case TEXT_is_REFERENCE: - module->m_Reference->SetThickness( g_ModuleTextWidth ); - module->m_Reference->SetSize( g_ModuleTextSize ); + module->m_Reference->SetThickness( GetBoard()->GetDesignSettings().m_ModuleTextWidth ); + module->m_Reference->SetSize( GetBoard()->GetDesignSettings().m_ModuleTextSize ); break; case TEXT_is_VALUE: - module->m_Value->SetThickness( g_ModuleTextWidth ); - module->m_Value->SetSize( g_ModuleTextSize ); + module->m_Value->SetThickness( GetBoard()->GetDesignSettings().m_ModuleTextWidth ); + module->m_Value->SetSize( GetBoard()->GetDesignSettings().m_ModuleTextSize ); break; case TEXT_is_DIVERS: @@ -447,8 +447,8 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) if( boardItem->Type() == PCB_MODULE_TEXT_T ) { item = (TEXTE_MODULE*) boardItem; - item->SetThickness( g_ModuleTextWidth ); - item->SetSize( g_ModuleTextSize ); + item->SetThickness( GetBoard()->GetDesignSettings().m_ModuleTextWidth ); + item->SetSize( GetBoard()->GetDesignSettings().m_ModuleTextSize ); } } diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index ac9d5f9196..d3312bbe28 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -563,21 +563,21 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) if( stricmp( line, "EdgeModWidth" ) == 0 ) { - g_ModuleSegmentWidth = atoi( data ); + GetBoard()->GetDesignSettings().m_ModuleSegmentWidth = atoi( data ); continue; } if( stricmp( line, "TextModWidth" ) == 0 ) { - g_ModuleTextWidth = atoi( data ); + GetBoard()->GetDesignSettings().m_ModuleTextWidth = atoi( data ); continue; } if( stricmp( line, "TextModSize" ) == 0 ) { - g_ModuleTextSize.x = atoi( data ); + GetBoard()->GetDesignSettings().m_ModuleTextSize.x = atoi( data ); data = strtok( NULL, delims ); - g_ModuleTextSize.y = atoi( data ); + GetBoard()->GetDesignSettings().m_ModuleTextSize.y = atoi( data ); continue; } @@ -735,9 +735,9 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) aBoard->GetDesignSettings().m_PcbTextSize.x, aBoard->GetDesignSettings().m_PcbTextSize.y ); - fprintf( aFile, "EdgeModWidth %d\n", g_ModuleSegmentWidth ); - fprintf( aFile, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y ); - fprintf( aFile, "TextModWidth %d\n", g_ModuleTextWidth ); + fprintf( aFile, "EdgeModWidth %d\n", aBoard->GetDesignSettings().m_ModuleSegmentWidth ); + fprintf( aFile, "TextModSize %d %d\n", aBoard->GetDesignSettings().m_ModuleTextSize.x, aBoard->GetDesignSettings().m_ModuleTextSize.y ); + fprintf( aFile, "TextModWidth %d\n", aBoard->GetDesignSettings().m_ModuleTextWidth ); fprintf( aFile, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y ); fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x ); fprintf( aFile, diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 77dbd82863..4996862dbd 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -71,10 +71,6 @@ #include #include -#ifdef CVPCB -//#include -#endif - #include #include #include @@ -107,10 +103,11 @@ /// C string compare test for a specific length of characters. -/// The -1 is to omit the trailing \0 which is included in sizeof() on a -/// string constant. #define TESTLINE( x ) ( !strnicmp( line, x, SZ( x ) ) && isspace( line[SZ( x )] ) ) +/// C sub-string compare test for a specific length of characters. +#define TESTSUBSTR( x ) ( !strnicmp( line, x, SZ( x ) ) ) + #if 1 #define READLINE() m_reader->ReadLine() @@ -560,6 +557,7 @@ void KICAD_PLUGIN::loadSHEET() void KICAD_PLUGIN::loadSETUP() { NETCLASS* netclass_default = m_board->m_NetClasses.GetDefault(); + BOARD_DESIGN_SETTINGS bds = m_board->GetDesignSettings(); while( READLINE() ) { @@ -586,7 +584,7 @@ void KICAD_PLUGIN::loadSETUP() m_board->SetCopperLayerCount( tmp ); } - else if( TESTLINE( "Layer[" ) ) + else if( TESTSUBSTR( "Layer[" ) ) { // eg: "Layer[n] " @@ -634,7 +632,7 @@ void KICAD_PLUGIN::loadSETUP() else if( TESTLINE( "TrackMinWidth" ) ) { BIU tmp = biuParse( line + SZ( "TrackMinWidth" ) ); - m_board->GetDesignSettings().m_TrackMinWidth = tmp; + bds.m_TrackMinWidth = tmp; } else if( TESTLINE( "ZoneClearence" ) ) @@ -646,25 +644,25 @@ void KICAD_PLUGIN::loadSETUP() else if( TESTLINE( "DrawSegmWidth" ) ) { BIU tmp = biuParse( line + SZ( "DrawSegmWidth" ) ); - m_board->GetDesignSettings().m_DrawSegmentWidth = tmp; + bds.m_DrawSegmentWidth = tmp; } else if( TESTLINE( "EdgeSegmWidth" ) ) { BIU tmp = biuParse( line + SZ( "EdgeSegmWidth" ) ); - m_board->GetDesignSettings().m_EdgeSegmentWidth = tmp; + bds.m_EdgeSegmentWidth = tmp; } else if( TESTLINE( "ViaMinSize" ) ) { BIU tmp = biuParse( line + SZ( "ViaMinSize" ) ); - m_board->GetDesignSettings().m_ViasMinSize = tmp; + bds.m_ViasMinSize = tmp; } else if( TESTLINE( "MicroViaMinSize" ) ) { BIU tmp = biuParse( line + SZ( "MicroViaMinSize" ) ); - m_board->GetDesignSettings().m_MicroViasMinSize = tmp; + bds.m_MicroViasMinSize = tmp; } else if( TESTLINE( "ViaSizeList" ) ) @@ -690,7 +688,7 @@ void KICAD_PLUGIN::loadSETUP() else if( TESTLINE( "ViaMinDrill" ) ) { BIU tmp = biuParse( line + SZ( "ViaMinDrill" ) ); - m_board->GetDesignSettings().m_ViasMinDrill = tmp; + bds.m_ViasMinDrill = tmp; } else if( TESTLINE( "MicroViaDrill" ) ) @@ -702,19 +700,19 @@ void KICAD_PLUGIN::loadSETUP() else if( TESTLINE( "MicroViaMinDrill" ) ) { BIU tmp = biuParse( line + SZ( "MicroViaMinDrill" ) ); - m_board->GetDesignSettings().m_MicroViasMinDrill = tmp; + bds.m_MicroViasMinDrill = tmp; } else if( TESTLINE( "MicroViasAllowed" ) ) { int tmp = intParse( line + SZ( "MicroViasAllowed" ) ); - m_board->GetDesignSettings().m_MicroViasAllowed = tmp; + bds.m_MicroViasAllowed = tmp; } else if( TESTLINE( "TextPcbWidth" ) ) { BIU tmp = biuParse( line + SZ( "TextPcbWidth" ) ); - m_board->GetDesignSettings().m_PcbTextWidth = tmp; + bds.m_PcbTextWidth = tmp; } else if( TESTLINE( "TextPcbSize" ) ) @@ -722,32 +720,27 @@ void KICAD_PLUGIN::loadSETUP() BIU x = biuParse( line + SZ( "TextPcbSize" ), &data ); BIU y = biuParse( data ); - m_board->GetDesignSettings().m_PcbTextSize = wxSize( x, y ); + bds.m_PcbTextSize = wxSize( x, y ); } else if( TESTLINE( "EdgeModWidth" ) ) { BIU tmp = biuParse( line + SZ( "EdgeModWidth" ) ); - /* @todo - g_ModuleSegmentWidth = tmp; - */ + bds.m_ModuleSegmentWidth = tmp; } else if( TESTLINE( "TextModWidth" ) ) { BIU tmp = biuParse( line + SZ( "TextModWidth" ) ); - /* @todo - g_ModuleTextWidth = tmp; - */ + bds.m_ModuleTextWidth = tmp; } else if( TESTLINE( "TextModSize" ) ) { BIU x = biuParse( line + SZ( "TextModSize" ), &data ); BIU y = biuParse( data ); - /* @todo - g_ModuleTextSize = wxSize( x, y ); - */ + + bds.m_ModuleTextSize = wxSize( x, y ); } else if( TESTLINE( "PadSize" ) ) @@ -771,19 +764,19 @@ void KICAD_PLUGIN::loadSETUP() else if( TESTLINE( "Pad2MaskClearance" ) ) { BIU tmp = biuParse( line + SZ( "Pad2MaskClearance" ) ); - m_board->GetDesignSettings().m_SolderMaskMargin = tmp; + bds.m_SolderMaskMargin = tmp; } else if( TESTLINE( "Pad2PasteClearance" ) ) { BIU tmp = biuParse( line + SZ( "Pad2PasteClearance" ) ); - m_board->GetDesignSettings().m_SolderPasteMargin = tmp; + bds.m_SolderPasteMargin = tmp; } else if( TESTLINE( "Pad2PasteClearanceRatio" ) ) { double ratio = atof( line + SZ( "Pad2PasteClearanceRatio" ) ); - m_board->GetDesignSettings().m_SolderPasteMarginRatio = ratio; + bds.m_SolderPasteMarginRatio = ratio; } else if( TESTLINE( "GridOrigin" ) ) @@ -799,6 +792,8 @@ void KICAD_PLUGIN::loadSETUP() else if( TESTLINE( "$EndSETUP" ) ) { + m_board->SetDesignSettings( bds ); + // Until such time as the *.brd file does not have the // global parameters: // "TrackWidth", "TrackMinWidth", "ViaSize", "ViaDrill", @@ -861,7 +856,7 @@ void KICAD_PLUGIN::loadMODULE() // most frequently encountered ones at the top - if( TESTLINE( "D" ) ) // read a drawing item, e.g. "DS" + if( TESTSUBSTR( "D" ) ) // read a drawing item, e.g. "DS" { loadMODULE_EDGE( module.get() ); } @@ -872,7 +867,7 @@ void KICAD_PLUGIN::loadMODULE() } // Read a footprint text description (ref, value, or drawing) - else if( TESTLINE( "T" ) ) + else if( TESTSUBSTR( "T" ) ) { // e.g. "T1 6940 -16220 350 300 900 60 M I 20 N "CFCARD"\r\n" @@ -2776,7 +2771,8 @@ void KICAD_PLUGIN::saveSHEET() const void KICAD_PLUGIN::saveSETUP() const { - NETCLASS* netclass_default = m_board->m_NetClasses.GetDefault(); + NETCLASS* netclass_default = m_board->m_NetClasses.GetDefault(); + const BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings(); fprintf( m_fp, "$SETUP\n" ); @@ -2812,16 +2808,16 @@ void KICAD_PLUGIN::saveSETUP() const fprintf( m_fp, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance ); */ - fprintf( m_fp, "TrackMinWidth %s\n", fmtBIU( m_board->GetDesignSettings().m_TrackMinWidth ).c_str() ); + fprintf( m_fp, "TrackMinWidth %s\n", fmtBIU( bds.m_TrackMinWidth ).c_str() ); - fprintf( m_fp, "DrawSegmWidth %s\n", fmtBIU( m_board->GetDesignSettings().m_DrawSegmentWidth ).c_str() ); - fprintf( m_fp, "EdgeSegmWidth %s\n", fmtBIU( m_board->GetDesignSettings().m_EdgeSegmentWidth ).c_str() ); + fprintf( m_fp, "DrawSegmWidth %s\n", fmtBIU( bds.m_DrawSegmentWidth ).c_str() ); + fprintf( m_fp, "EdgeSegmWidth %s\n", fmtBIU( bds.m_EdgeSegmentWidth ).c_str() ); // Save current default via size, for compatibility with older Pcbnew version; fprintf( m_fp, "ViaSize %s\n", fmtBIU( netclass_default->GetViaDiameter() ).c_str() ); fprintf( m_fp, "ViaDrill %s\n", fmtBIU( netclass_default->GetViaDrill() ).c_str() ); - fprintf( m_fp, "ViaMinSize %s\n", fmtBIU( m_board->GetDesignSettings().m_ViasMinSize ).c_str() ); - fprintf( m_fp, "ViaMinDrill %s\n", fmtBIU( m_board->GetDesignSettings().m_ViasMinDrill ).c_str() ); + fprintf( m_fp, "ViaMinSize %s\n", fmtBIU( bds.m_ViasMinSize ).c_str() ); + fprintf( m_fp, "ViaMinDrill %s\n", fmtBIU( bds.m_ViasMinDrill ).c_str() ); // Save custom vias diameters list (the first is not saved here: this is // the netclass value @@ -2833,28 +2829,29 @@ void KICAD_PLUGIN::saveSETUP() const // for old versions compatibility: fprintf( m_fp, "MicroViaSize %s\n", fmtBIU( netclass_default->GetuViaDiameter() ).c_str() ); fprintf( m_fp, "MicroViaDrill %s\n", fmtBIU( netclass_default->GetuViaDrill() ).c_str() ); - fprintf( m_fp, "MicroViasAllowed %s\n", fmtBIU( m_board->GetDesignSettings().m_MicroViasAllowed ).c_str() ); - fprintf( m_fp, "MicroViaMinSize %s\n", fmtBIU( m_board->GetDesignSettings().m_MicroViasMinSize ).c_str() ); - fprintf( m_fp, "MicroViaMinDrill %s\n", fmtBIU( m_board->GetDesignSettings().m_MicroViasMinDrill ).c_str() ); + fprintf( m_fp, "MicroViasAllowed %s\n", fmtBIU( bds.m_MicroViasAllowed ).c_str() ); + fprintf( m_fp, "MicroViaMinSize %s\n", fmtBIU( bds.m_MicroViasMinSize ).c_str() ); + fprintf( m_fp, "MicroViaMinDrill %s\n", fmtBIU( bds.m_MicroViasMinDrill ).c_str() ); - fprintf( m_fp, "TextPcbWidth %s\n", fmtBIU( m_board->GetDesignSettings().m_PcbTextWidth ).c_str() ); - fprintf( m_fp, "TextPcbSize %s\n", fmtBIUSize( m_board->GetDesignSettings().m_PcbTextSize ).c_str() ); + fprintf( m_fp, "TextPcbWidth %s\n", fmtBIU( bds.m_PcbTextWidth ).c_str() ); + fprintf( m_fp, "TextPcbSize %s\n", fmtBIUSize( bds.m_PcbTextSize ).c_str() ); - /* @todo no globals - fprintf( m_fp, "EdgeModWidth %d\n", g_ModuleSegmentWidth ); - fprintf( m_fp, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y ); - fprintf( m_fp, "TextModWidth %d\n", g_ModuleTextWidth ); + fprintf( m_fp, "EdgeModWidth %s\n", fmtBIU( bds.m_ModuleSegmentWidth ).c_str() ); + fprintf( m_fp, "TextModSize %s\n", fmtBIUSize( bds.m_ModuleTextSize ).c_str() ); + fprintf( m_fp, "TextModWidth %s\n", fmtBIU( bds.m_ModuleTextWidth ).c_str() ); + + /* @todo fprintf( m_fp, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y ); fprintf( m_fp, "PadDrill %d\n", g_Pad_Master.m_Drill.x ); */ - fprintf( m_fp, "Pad2MaskClearance %s\n", fmtBIU( m_board->GetDesignSettings().m_SolderMaskMargin ).c_str() ); + fprintf( m_fp, "Pad2MaskClearance %s\n", fmtBIU( bds.m_SolderMaskMargin ).c_str() ); - if( m_board->GetDesignSettings().m_SolderPasteMargin != 0 ) - fprintf( m_fp, "Pad2PasteClearance %s\n", fmtBIU( m_board->GetDesignSettings().m_SolderPasteMargin ).c_str() ); + if( bds.m_SolderPasteMargin != 0 ) + fprintf( m_fp, "Pad2PasteClearance %s\n", fmtBIU( bds.m_SolderPasteMargin ).c_str() ); - if( m_board->GetDesignSettings().m_SolderPasteMarginRatio != 0 ) - fprintf( m_fp, "Pad2PasteClearanceRatio %g\n", m_board->GetDesignSettings().m_SolderPasteMarginRatio ); + if( bds.m_SolderPasteMarginRatio != 0 ) + fprintf( m_fp, "Pad2PasteClearanceRatio %g\n", bds.m_SolderPasteMarginRatio ); /* @todo no aFrame if ( aFrame->GetScreen()->m_GridOrigin != wxPoint( 0, 0 ) ) diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index b2bbf9ec48..445ef2b7bc 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -87,7 +87,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module() // Switch the locale to standard C (needed to print floating point numbers like 1.3) SetLocaleTo_C_standard(); - /* Read header and test file type */ + // Read header and test file type reader.ReadLine(); Line = reader.Line(); @@ -104,7 +104,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module() } } - /* Read file: Search the description starting line (skip lib header)*/ + // Read file: Search the description starting line (skip lib header) if( !Footprint_Is_GPCB_Format ) { while( reader.ReadLine() ) @@ -127,10 +127,10 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module() SetLocaleTo_Default(); // revert to the current locale - /* Insert footprint in list*/ + // Insert footprint in list GetBoard()->Add( module ); - /* Display info : */ + // Display info : module->DisplayInfo( this ); PlaceModule( module, NULL ); GetBoard()->m_Status_Pcb = 0; @@ -216,7 +216,7 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) if( CmpName == wxEmptyString ) return; - /* Confirmation */ + // Confirmation msg.Printf( _( "Ok to delete module %s in library %s" ), GetChars( CmpName ), GetChars( aLibname ) ); @@ -236,7 +236,7 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) FOOTPRINT_LIBRARY input_lib( lib_module ); - /* Read header. */ + // Read header. if( ! input_lib.IsLibrary() ) { fclose( lib_module ); @@ -247,7 +247,7 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) return; } - /* Read module names. */ + // Read module names. input_lib.RebuildIndex(); bool found = input_lib.FindInList( CmpName ); @@ -259,7 +259,7 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) return; } - /* Create new library. */ + // Create new library. newFileName = oldFileName; newFileName.SetExt( FILETMP_EXT ); @@ -281,7 +281,7 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) output_lib.SortList(); output_lib.WriteSectionIndex(); - /* Copy modules. */ + // Copy modules. rewind( lib_module ); LineNum = input_lib.m_LineNum; @@ -298,7 +298,7 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) if( msg.CmpNoCase( CmpName ) == 0 ) { - /* Delete old module (i.e. do not copy description to out_file). */ + // Delete old module (i.e. do not copy description to out_file). while( GetLine( lib_module, Line, &LineNum ) ) { if( strnicmp( Line, "$EndMODULE", 9 ) == 0 ) @@ -318,7 +318,7 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) wxEndBusyCursor(); - /* The old library file is renamed .bak */ + // The old library file is renamed .bak wxFileName backupFileName = oldFileName; backupFileName.SetExt( BACKUP_EXT ); @@ -333,7 +333,7 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) return; } - /* The temporary file is renamed as the previous library. */ + // The temporary file is renamed as the previous library. if( !wxRenameFile( newFileName.GetFullPath(), oldFileName.GetFullPath() ) ) { msg.Printf( _("Could not create temporary library file <%s>."), @@ -435,7 +435,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewM if( !success ) break; - /* Check for request to stop backup (ESCAPE key actuated) */ + // Check for request to stop backup (ESCAPE key actuated) if( m_canvas->GetAbortRequest() ) break; } @@ -472,7 +472,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, if( !IsWritable( newFileName ) ) return false; - /* Ask for the footprint name in lib */ + // Ask for the footprint name in lib Name_Cmp = aModule->m_LibRef; if( aDisplayDialog ) @@ -506,7 +506,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, return false; } - /* Read library file */ + // Read library file FOOTPRINT_LIBRARY input_lib( lib_module ); if( ! input_lib.IsLibrary() ) @@ -517,7 +517,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, return false; } - /* Read footprints in lib: - search for an existing footprint */ + // Read footprints in lib: - search for an existing footprint input_lib.RebuildIndex(); bool module_exists = input_lib.FindInList( Name_Cmp ); @@ -538,7 +538,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, } } - /* Creates the new library */ + // Creates the new library newFileName.SetExt( FILETMP_EXT ); @@ -563,7 +563,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, output_lib.SortList(); - /* Create the library header with a new date */ + // Create the library header with a new date output_lib.WriteHeader(); output_lib.WriteSectionIndex(); @@ -595,7 +595,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, if( msg.CmpNoCase( Name_Cmp ) == 0 ) { - /* skip old footprint descr (delete from the lib) */ + // skip old footprint descr (delete from the lib) while( GetLine( lib_module, Line, &LineNum ) ) { if( strnicmp( Line, "$EndMODULE", 9 ) == 0 ) @@ -609,7 +609,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, fprintf( dest, "%s\n", Line ); } - /* Write the new footprint ( append it to the list of footprint ) */ + // Write the new footprint ( append it to the list of footprint ) tmp = aModule->GetTimeStamp(); aModule->SetTimeStamp( 0 ); aModule->Save( dest ); @@ -623,7 +623,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, wxEndBusyCursor(); - /* The old library file is renamed .bak */ + // The old library file is renamed .bak oldFileName = aLibName; oldFileName.SetExt( BACKUP_EXT ); @@ -637,7 +637,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, DisplayError( this, msg ); } - /* The new library file is renamed */ + // The new library file is renamed if( !wxRenameFile( newFileName.GetFullPath(), aLibName ) ) { msg.Printf( _( "Could not create temporary library file <%s>." ), @@ -667,7 +667,7 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName ) moduleName = aModuleName; - /* Ask for the new module reference */ + // Ask for the new module reference if( moduleName.IsEmpty() ) { wxTextEntryDialog dlg( this, _( "Module Reference:" ), @@ -693,23 +693,23 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName ) GetBoard()->Add( Module ); - /* Update parameters: position, timestamp ... */ + // Update parameters: position, timestamp ... newpos = GetScreen()->GetCrossHairPosition(); Module->SetPosition( newpos ); Module->m_LastEdit_Time = time( NULL ); - /* Update its name in lib */ + // Update its name in lib Module->m_LibRef = moduleName; - /* Update reference: */ + // Update reference: Module->m_Reference->m_Text = moduleName; - Module->m_Reference->SetThickness( g_ModuleTextWidth ); - Module->m_Reference->SetSize( g_ModuleTextSize ); + Module->m_Reference->SetThickness( GetBoard()->GetDesignSettings().m_ModuleTextWidth ); + Module->m_Reference->SetSize( GetBoard()->GetDesignSettings().m_ModuleTextSize ); - /* Set the value field to a default value */ + // Set the value field to a default value Module->m_Value->m_Text = wxT( "VAL**" ); - Module->m_Value->SetThickness( g_ModuleTextWidth ); - Module->m_Value->SetSize( g_ModuleTextSize ); + Module->m_Value->SetThickness( GetBoard()->GetDesignSettings().m_ModuleTextWidth ); + Module->m_Value->SetSize( GetBoard()->GetDesignSettings().m_ModuleTextSize ); Module->SetPosition( wxPoint( 0, 0 ) ); diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 12798758da..667076ca75 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -64,9 +64,6 @@ bool g_Track_45_Only_Allowed = true; // True to allow horiz, vert. an bool Segments_45_Only; // True to allow horiz, vert. and 45deg only graphic segments bool g_TwoSegmentTrackBuild = true; -wxSize g_ModuleTextSize; /* Default footprint texts size */ -int g_ModuleSegmentWidth; -int g_ModuleTextWidth; int Route_Layer_TOP; int Route_Layer_BOTTOM; int g_MaxLinksShowed; diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index 7dc7d1f3d8..ca9db9d4cd 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -57,11 +57,6 @@ extern bool Segments_45_Only; extern wxString g_Shapes3DExtBuffer; extern wxString g_DocModulesFileName; -/* Variables used in footprint handling */ -extern wxSize g_ModuleTextSize; /* Default footprint texts size */ -extern int g_ModuleTextWidth; -extern int g_ModuleSegmentWidth; - /* Layer pair for auto routing and switch layers by hotkey */ extern int Route_Layer_TOP; extern int Route_Layer_BOTTOM; diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 4ee6c31ec3..68d1142215 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -236,11 +236,11 @@ PARAM_CFG_ARRAY PCB_EDIT_FRAME::GetProjectFileParameters() &bds.m_PcbTextSize.x, 600, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) ); - pca.push_back( new PARAM_CFG_INT( wxT( "TxtModV" ), &g_ModuleTextSize.y, + pca.push_back( new PARAM_CFG_INT( wxT( "TxtModV" ), &bds.m_ModuleTextSize.y, 500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) ); - pca.push_back( new PARAM_CFG_INT( wxT( "TxtModH" ), &g_ModuleTextSize.x, + pca.push_back( new PARAM_CFG_INT( wxT( "TxtModH" ), &bds.m_ModuleTextSize.x, 500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) ); - pca.push_back( new PARAM_CFG_INT( wxT( "TxtModW" ), &g_ModuleTextWidth, + pca.push_back( new PARAM_CFG_INT( wxT( "TxtModW" ), &bds.m_ModuleTextWidth, 100, 1, TEXTS_MAX_WIDTH ) ); pca.push_back( new PARAM_CFG_INT( wxT( "VEgarde" ), @@ -257,7 +257,7 @@ PARAM_CFG_ARRAY PCB_EDIT_FRAME::GetProjectFileParameters() pca.push_back( new PARAM_CFG_INT( wxT( "TxtLar" ), &bds.m_PcbTextWidth, 120, 0, 0xFFFF ) ); - pca.push_back( new PARAM_CFG_INT( wxT( "MSegLar" ), &g_ModuleSegmentWidth, + pca.push_back( new PARAM_CFG_INT( wxT( "MSegLar" ), &bds.m_ModuleSegmentWidth, 120, 0, 0xFFFF ) ); pca.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ), &m_lastNetListRead ) );