From 699863f8d8028fad3054ff2828dc7d4aa3dc5837 Mon Sep 17 00:00:00 2001 From: charras Date: Mon, 29 Mar 2010 16:42:03 +0000 Subject: [PATCH] Pcbnew: enhancements in printing (or plot in SVG format) --- CHANGELOG.txt | 11 ++++ README.txt | 3 +- pcbnew/class_pad_draw_functions.cpp | 49 +++++++++++++-- pcbnew/print_board_functions.cpp | 97 +++++++++++++++++------------ pcbnew/printout_controler.cpp | 2 +- pcbnew/printout_controler.h | 4 +- 6 files changed, 117 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 48a6e34e30..a05cf6be04 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,17 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. + +2010-mar-29, UPDATE Jean-Pierre Charras +================================================================================ +++Pcbnew + enhancements in printing or plot in SVG format: + When printing techncal layers, pads on solder mask or solder paste layers + where printed in sketch mode. + Now they are printed as solid shapes, with dimensions according to + solder past or solder mask clearances. + + 2010-mar-18 UPDATE Jean-Pierre Charras ================================================================================ ++Eeschema diff --git a/README.txt b/README.txt index 5501d39c35..bb5295f066 100644 --- a/README.txt +++ b/README.txt @@ -22,7 +22,7 @@ Subdirectories bitmaps - Menu and program icons CMakeModules - Modules for the CMAKE build tool common - Sourcecode of the common library (common functions shared across whole suite) -cvpcb - Sourcecode of CvPCB, (eeschema) convert to pcb sourcecode +cvpcb - Sourcecode of CvPCB, tool to link components with footprints sourcecode demos - Some demo examples Documentation - Misc documentation. Translating the GUI, old changelogs etcetera. eeschema - Sourcecode of the schematic editor @@ -36,6 +36,5 @@ pcbnew - Sourcecode of the printed circuit board editor polygon - Sourcecode of the polygon library resources - Resources for installation, freedesktop mime-types for linux scripts - Helper scripts. For building, sourcecode packaging, font setting, pcb adjusting. -share - ? template - Project template(s) diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 015fa6b2b7..e4be22a43a 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -14,6 +14,13 @@ #include "class_board_design_settings.h" #include "colors_selection.h" +/* uncomment this line to show this pad with its specfic size and color + * when it is not on copper layers, and only one solder mask layer or solder paste layer + * is displayed for this pad + * After testing this feature,I am not sure this is a good idea + * but the code is left here. + */ +//#define SHOW_PADMASK_REAL_SIZE_AND_COLOR /** Draw a pad: * @param DC = device context @@ -35,6 +42,10 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, int fillpad = 0; wxPoint shape_pos; wxSize mask_margin; // margin (clearance) used for some non copper layers + int showActualMaskSize = 0; /* == layer number if the actual pad size on mask layer can be displayed + * i.e. if only one layer is shown for this pad + * and this layer is a mask (solder mask or sloder paste + */ if( m_Flags & DO_NOT_DRAW ) return; @@ -103,8 +114,15 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, { // If the pad in on only one tech layer, use the layer color // else use DARKGRAY - switch( m_Masque_Layer & ~ALL_CU_LAYERS ) + int mask_non_copper_layers = m_Masque_Layer & ~ALL_CU_LAYERS; +#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR + mask_non_copper_layers &= brd->GetVisibleLayers(); +#endif + switch( mask_non_copper_layers ) { + case 0: + break; + case ADHESIVE_LAYER_BACK: color = brd->GetLayerColor(ADHESIVE_N_BACK); break; @@ -115,10 +133,12 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, case SOLDERPASTE_LAYER_BACK: color = brd->GetLayerColor(SOLDERPASTE_N_BACK); + showActualMaskSize = SOLDERPASTE_N_BACK; break; case SOLDERPASTE_LAYER_FRONT: color = brd->GetLayerColor(SOLDERPASTE_N_FRONT); + showActualMaskSize = SOLDERPASTE_N_FRONT; break; case SILKSCREEN_LAYER_BACK: @@ -131,10 +151,12 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, case SOLDERMASK_LAYER_BACK: color = brd->GetLayerColor(SOLDERMASK_N_BACK); + showActualMaskSize = SOLDERMASK_N_BACK; break; case SOLDERMASK_LAYER_FRONT: color = brd->GetLayerColor(SOLDERMASK_N_FRONT); + showActualMaskSize = SOLDERMASK_N_FRONT; break; case DRAW_LAYER: @@ -163,7 +185,6 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, } } - // if PAD_SMD pad and high contrast mode if( ( m_Attribut == PAD_SMD || m_Attribut == PAD_CONN ) && DisplayOpt.ContrastModeDisplay ) @@ -211,11 +232,31 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, } } +#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR + if( showActualMaskSize ) + { + switch( showActualMaskSize ) + { + case SOLDERMASK_N_BACK: + case SOLDERMASK_N_FRONT: + mask_margin.x = mask_margin.y = GetSolderMaskMargin(); + break; + + case SOLDERPASTE_N_BACK: + case SOLDERPASTE_N_FRONT: + mask_margin = GetSolderPasteMargin(); + break; + + default: + break; + } + } +#endif + // if Contrast mode is ON and a technical layer active, show pads on this // layer so we can see pads on paste or solder layer and the size of the // mask - if( DisplayOpt.ContrastModeDisplay - && screen->m_Active_Layer > LAST_COPPER_LAYER ) + if( DisplayOpt.ContrastModeDisplay && screen->m_Active_Layer > LAST_COPPER_LAYER ) { if( IsOnLayer( screen->m_Active_Layer ) ) { diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index 0fd0d40bc8..82b5f19537 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -41,7 +41,11 @@ void WinEDA_PcbFrame::PrintPage( wxDC* aDC, TRACK* pt_piste; BOARD* Pcb = GetBoard(); int defaultPenSize = 50; + bool onePagePerLayer = false; + PRINT_PARAMETERS * printParameters = (PRINT_PARAMETERS*) aData; // can be null + if( printParameters && printParameters->m_OptionPrintPage == 0 ) + onePagePerLayer = true; PRINT_PARAMETERS::DrillShapeOptT drillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE; if( printParameters ) @@ -51,16 +55,44 @@ void WinEDA_PcbFrame::PrintPage( wxDC* aDC, } save_opt = DisplayOpt; - if( aPrintMaskLayer & ALL_CU_LAYERS ) + int activeLayer = GetScreen()->m_Active_Layer; + + DisplayOpt.ContrastModeDisplay = false; + DisplayOpt.DisplayPadFill = true; + DisplayOpt.DisplayViaFill = true; + + if( (aPrintMaskLayer & ALL_CU_LAYERS) == 0 ) { - DisplayOpt.DisplayPadFill = true; - DisplayOpt.DisplayViaFill = true; - } - else - { - DisplayOpt.DisplayPadFill = false; - DisplayOpt.DisplayViaFill = false; + if( onePagePerLayer ) + { // We can print mask layers (solder mask and solder paste) with the actual pad sizes + // To do that, we must set ContrastModeDisplay to true and set the GetScreen()->m_Active_Layer + // to the current printed layer + DisplayOpt.ContrastModeDisplay = true; + DisplayOpt.DisplayPadFill = true; + + // Calculate the active layer number to print from its mask layer: + GetScreen()->m_Active_Layer = 0; + for(int kk = 0; kk < 32; kk ++ ) + { + if( ((1 << kk) & aPrintMaskLayer) != 0 ) + { + GetScreen()->m_Active_Layer = kk; + break; + } + } + + // pads on Silkscreen layer are usually plot in sketch mode: + if( (GetScreen()->m_Active_Layer == SILKSCREEN_N_BACK) || + (GetScreen()->m_Active_Layer == SILKSCREEN_N_FRONT) ) + DisplayOpt.DisplayPadFill = false; + + } + else + { + DisplayOpt.DisplayPadFill = false; + } } + m_DisplayPadFill = DisplayOpt.DisplayPadFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill; @@ -79,7 +111,7 @@ void WinEDA_PcbFrame::PrintPage( wxDC* aDC, DrawPanel->m_PrintIsMirrored = aPrintMirrorMode; // The OR mode is used in color mode, but be aware the backgroud *must be - // BLACK. In the print page dialog, we first plrint in BLACK, and after + // BLACK. In the print page dialog, we first print in BLACK, and after // reprint in color, on the black "local" backgroud, in OR mode the black // print is not made before, only a white page is printed if( GetGRForceBlackPenState() == false ) @@ -193,6 +225,7 @@ void WinEDA_PcbFrame::PrintPage( wxDC* aDC, DrawPanel->m_PrintIsMirrored = false; DisplayOpt = save_opt; + GetScreen()->m_Active_Layer = activeLayer; m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; m_DisplayPadFill = DisplayOpt.DisplayPadFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill; @@ -217,39 +250,23 @@ static void Print_Module( WinEDA_DrawPanel* aPanel, wxDC* aDC, MODULE* aModule, { if( (pt_pad->m_Masque_Layer & aMasklayer ) == 0 ) continue; - - // Usually we draw pads in sketch mode on non copper layers: - if( (aMasklayer & ALL_CU_LAYERS) == 0 ) + // Manage hole according to the print drill option + wxSize drill_tmp = pt_pad->m_Drill; + switch ( aDrillShapeOpt ) { - int tmp_fill = - ( (WinEDA_BasePcbFrame*) aPanel->GetParent() )->m_DisplayPadFill; - - // Switch in sketch mode - ( (WinEDA_BasePcbFrame*) aPanel->GetParent() )->m_DisplayPadFill = 0; - pt_pad->Draw( aPanel, aDC, aDraw_mode ); - ( (WinEDA_BasePcbFrame*) aPanel->GetParent() )->m_DisplayPadFill = - tmp_fill; - } - else // on copper layer, draw pads according to current options - { - // Manage hole according to the print drill option - wxSize drill_tmp = pt_pad->m_Drill; - switch ( aDrillShapeOpt ) - { - case PRINT_PARAMETERS::NO_DRILL_SHAPE: - pt_pad->m_Drill = wxSize(0,0); - break; - case PRINT_PARAMETERS::SMALL_DRILL_SHAPE: - pt_pad->m_Drill.x = MIN(SMALL_DRILL,pt_pad->m_Drill.x); - pt_pad->m_Drill.y = MIN(SMALL_DRILL,pt_pad->m_Drill.y); - break; - case PRINT_PARAMETERS::FULL_DRILL_SHAPE: - // Do nothing - break; - } - pt_pad->Draw( aPanel, aDC, aDraw_mode ); - pt_pad->m_Drill = drill_tmp; + case PRINT_PARAMETERS::NO_DRILL_SHAPE: + pt_pad->m_Drill = wxSize(0,0); + break; + case PRINT_PARAMETERS::SMALL_DRILL_SHAPE: + pt_pad->m_Drill.x = MIN(SMALL_DRILL,pt_pad->m_Drill.x); + pt_pad->m_Drill.y = MIN(SMALL_DRILL,pt_pad->m_Drill.y); + break; + case PRINT_PARAMETERS::FULL_DRILL_SHAPE: + // Do nothing + break; } + pt_pad->Draw( aPanel, aDC, aDraw_mode ); + pt_pad->m_Drill = drill_tmp; } /* Print footprint graphic shapes */ diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index 1d156e3138..71741a3f6b 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -58,7 +58,7 @@ bool BOARD_PRINTOUT_CONTROLER::OnPrintPage( int page ) int mask_layer = m_PrintParams.m_PrintMaskLayer; // compute layer mask from page number if we want one page per layer - if( m_PrintParams.m_OptionPrintPage == 0 ) + if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer { int ii, jj, mask = 1; for( ii = 0, jj = 0; ii < layers_count; ii++ ) diff --git a/pcbnew/printout_controler.h b/pcbnew/printout_controler.h index e45ba6b357..090962174e 100644 --- a/pcbnew/printout_controler.h +++ b/pcbnew/printout_controler.h @@ -27,8 +27,8 @@ public: long m_PrintMaskLayer; // Layers to print bool m_PrintMirror; // Option: Print mirroed bool m_Print_Black_and_White; // Option: Print in B&W ou Color - int m_OptionPrintPage; // Option: 0 = a layer per page, all layers at once - int m_PageCount; // Nmuber of page to print + int m_OptionPrintPage; // Option: 0 = a layer per page, 1 = all layers at once + int m_PageCount; // Number of page to print bool m_ForceCentered; // Forge plot origin to page centre (used in modedit) int m_Flags; // auxiliary variable: can be used to pass some other info