diff --git a/pcbnew/dialogs/dialog_print_pcbnew.cpp b/pcbnew/dialogs/dialog_print_pcbnew.cpp index 1d3c049a5b..d3974c8fee 100644 --- a/pcbnew/dialogs/dialog_print_pcbnew.cpp +++ b/pcbnew/dialogs/dialog_print_pcbnew.cpp @@ -96,6 +96,7 @@ private: wxCheckBox* m_checkboxMirror; wxChoice* m_drillMarksChoice; wxRadioBox* m_boxPagination; + wxCheckBox* m_checkAsItems; wxCheckBox* m_checkBackground; wxCheckBox* m_checkUseTheme; wxStaticText* m_lblTheme; @@ -103,16 +104,17 @@ private: }; -DIALOG_PRINT_PCBNEW::DIALOG_PRINT_PCBNEW( PCB_BASE_EDIT_FRAME* aParent, PCBNEW_PRINTOUT_SETTINGS* aSettings ) : - DIALOG_PRINT_GENERIC( aParent, aSettings ), m_parent( aParent ) +DIALOG_PRINT_PCBNEW::DIALOG_PRINT_PCBNEW( PCB_BASE_EDIT_FRAME* aParent, + PCBNEW_PRINTOUT_SETTINGS* aSettings ) : + DIALOG_PRINT_GENERIC( aParent, aSettings ), + m_parent( aParent ) { m_config = Kiface().KifaceSettings(); createExtraOptions(); createLeftPanel(); - m_outputMode->Bind( - wxEVT_COMMAND_CHOICE_SELECTED, &DIALOG_PRINT_PCBNEW::onColorModeChanged, this ); + m_outputMode->Bind( wxEVT_COMMAND_CHOICE_SELECTED, &DIALOG_PRINT_PCBNEW::onColorModeChanged, this ); } @@ -196,12 +198,19 @@ void DIALOG_PRINT_PCBNEW::createExtraOptions() int rows = optionsSizer->GetEffectiveRowsCount(); int cols = optionsSizer->GetEffectiveColsCount(); + m_checkAsItems = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, + _( "Print according to Items tab of Layers Manager" ), + wxDefaultPosition, wxDefaultSize, 0 ); + optionsSizer->Add( m_checkAsItems, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 3 ), wxALL, 5 ); + m_checkBackground = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, - _( "Print background color" ), wxDefaultPosition, wxDefaultSize, 0 ); + _( "Print background color" ), wxDefaultPosition, + wxDefaultSize, 0 ); optionsSizer->Add( m_checkBackground, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 3 ), wxALL, 5 ); m_checkUseTheme = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, - _( "Use a different color theme for printing" ), wxDefaultPosition, wxDefaultSize, 0 ); + _( "Use a different color theme for printing" ), + wxDefaultPosition, wxDefaultSize, 0 ); optionsSizer->Add( m_checkUseTheme, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 3 ), wxLEFT | wxRIGHT | wxTOP, 5 ); @@ -404,6 +413,8 @@ void DIALOG_PRINT_PCBNEW::saveSettings() { setLayerSetFromList(); + settings()->m_asItemCheckboxes = m_checkAsItems->GetValue(); + settings()->m_drillMarks = (PCBNEW_PRINTOUT_SETTINGS::DRILL_MARK_SHAPE_T) m_drillMarksChoice->GetSelection(); @@ -418,8 +429,8 @@ void DIALOG_PRINT_PCBNEW::saveSettings() settings()->m_background = cfg->m_Printing.background; cfg->m_Printing.use_theme = m_checkUseTheme->GetValue(); - COLOR_SETTINGS* theme = static_cast( - m_colorTheme->GetClientData( m_colorTheme->GetSelection() ) ); + int sel = m_colorTheme->GetSelection(); + COLOR_SETTINGS* theme = static_cast( m_colorTheme->GetClientData( sel ) ); if( theme && m_checkUseTheme->IsChecked() ) { @@ -429,7 +440,7 @@ void DIALOG_PRINT_PCBNEW::saveSettings() else { // This should always work, but in case it doesn't we fall back on default colors - if( auto pcbframe = dynamic_cast( m_parent ) ) + if( PCB_BASE_EDIT_FRAME* pcbframe = dynamic_cast( m_parent ) ) settings()->m_colorSettings = pcbframe->GetColorSettings(); else settings()->m_colorSettings = m_parent->GetColorSettings(); diff --git a/pcbnew/pcbnew_printout.cpp b/pcbnew/pcbnew_printout.cpp index 3c10fe891e..4e57b773cf 100644 --- a/pcbnew/pcbnew_printout.cpp +++ b/pcbnew/pcbnew_printout.cpp @@ -131,43 +131,78 @@ void PCBNEW_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet for( LSEQ layerSeq = m_settings.m_layerSet.Seq(); layerSeq; ++layerSeq ) aView.SetLayerVisible( PCBNEW_LAYER_ID_START + *layerSeq, true ); - // Enable pad layers corresponding to the selected copper layers - if( aLayerSet.test( F_Cu ) ) - aView.SetLayerVisible( LAYER_PAD_FR, true ); - - if( aLayerSet.test( B_Cu ) ) - aView.SetLayerVisible( LAYER_PAD_BK, true ); - - if( ( aLayerSet & LSET::AllCuMask() ).any() ) // Items visible on any copper layer + if( m_pcbnewSettings.m_asItemCheckboxes ) { - // Enable items on copper layers, but do not draw holes - for( GAL_LAYER_ID item : { LAYER_PADS_TH, LAYER_VIAS } ) - { - aView.SetLayerVisible( item, true ); - } + auto setVisibility = [&]( GAL_LAYER_ID aLayer ) + { + if( m_board->IsElementVisible( aLayer ) ) + aView.SetLayerVisible( aLayer ); + }; - if( m_pcbnewSettings.m_drillMarks != PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE ) + setVisibility( LAYER_MOD_FR ); + setVisibility( LAYER_MOD_BK ); + setVisibility( LAYER_MOD_VALUES ); + setVisibility( LAYER_MOD_REFERENCES ); + setVisibility( LAYER_MOD_TEXT_FR ); + setVisibility( LAYER_MOD_TEXT_BK ); + setVisibility( LAYER_MOD_TEXT_INVISIBLE ); + setVisibility( LAYER_PAD_FR ); + setVisibility( LAYER_PAD_BK ); + setVisibility( LAYER_PADS_TH ); + + setVisibility( LAYER_TRACKS ); + setVisibility( LAYER_VIA_THROUGH ); + setVisibility( LAYER_VIA_BBLIND ); + setVisibility( LAYER_VIA_MICROVIA ); + setVisibility( LAYER_NON_PLATEDHOLES ); + + setVisibility( LAYER_NO_CONNECTS ); + setVisibility( LAYER_DRC_WARNING ); + setVisibility( LAYER_DRC_ERROR ); + setVisibility( LAYER_DRC_EXCLUSION ); + setVisibility( LAYER_ANCHOR ); + setVisibility( LAYER_WORKSHEET ); + setVisibility( LAYER_GRID ); + } + else + { + // Enable pad layers corresponding to the selected copper layers + if( aLayerSet.test( F_Cu ) ) + aView.SetLayerVisible( LAYER_PAD_FR, true ); + + if( aLayerSet.test( B_Cu ) ) + aView.SetLayerVisible( LAYER_PAD_BK, true ); + + if( ( aLayerSet & LSET::AllCuMask() ).any() ) // Items visible on any copper layer { - // Enable hole layers to draw drill marks - for( GAL_LAYER_ID holeLayer : { LAYER_PADS_PLATEDHOLES, LAYER_NON_PLATEDHOLES, - LAYER_VIAS_HOLES } ) + // Enable items on copper layers, but do not draw holes + for( GAL_LAYER_ID item : { LAYER_PADS_TH, LAYER_VIAS } ) { - aView.SetLayerVisible( holeLayer, true ); - aView.SetTopLayer( holeLayer, true ); + aView.SetLayerVisible( item, true ); + } + + if( m_pcbnewSettings.m_drillMarks != PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE ) + { + // Enable hole layers to draw drill marks + for( GAL_LAYER_ID holeLayer : { LAYER_PADS_PLATEDHOLES, LAYER_NON_PLATEDHOLES, + LAYER_VIAS_HOLES } ) + { + aView.SetLayerVisible( holeLayer, true ); + aView.SetTopLayer( holeLayer, true ); + } } } + + // Keep certain items always enabled/disabled and just rely on the layer visibility + const int alwaysEnabled[] = { + LAYER_MOD_TEXT_FR, LAYER_MOD_TEXT_BK, LAYER_MOD_FR, LAYER_MOD_BK, + LAYER_MOD_VALUES, LAYER_MOD_REFERENCES, LAYER_TRACKS, + LAYER_VIA_MICROVIA, LAYER_VIA_BBLIND, LAYER_VIA_THROUGH + }; + + for( int item : alwaysEnabled ) + aView.SetLayerVisible( item, true ); } - - - // Keep certain items always enabled/disabled and just rely on the layer visibility - const int alwaysEnabled[] = { - LAYER_MOD_TEXT_FR, LAYER_MOD_TEXT_BK, LAYER_MOD_FR, LAYER_MOD_BK, - LAYER_MOD_VALUES, LAYER_MOD_REFERENCES, LAYER_TRACKS, - LAYER_VIA_MICROVIA, LAYER_VIA_BBLIND, LAYER_VIA_THROUGH - }; - - for( int item : alwaysEnabled ) - aView.SetLayerVisible( item, true ); } diff --git a/pcbnew/pcbnew_printout.h b/pcbnew/pcbnew_printout.h index 4b9c9e4bb8..ba91257fd6 100644 --- a/pcbnew/pcbnew_printout.h +++ b/pcbnew/pcbnew_printout.h @@ -33,14 +33,15 @@ struct PCBNEW_PRINTOUT_SETTINGS : BOARD_PRINTOUT_SETTINGS NO_DRILL_SHAPE, SMALL_DRILL_SHAPE, FULL_DRILL_SHAPE - } m_drillMarks; ///< Drill marks shape + } m_drillMarks; enum PAGINATION_T { LAYER_PER_PAGE, ALL_LAYERS - } m_pagination; ///< Pagination + } m_pagination; bool m_noEdgeLayer; ///< Disable board outline on each page + bool m_asItemCheckboxes; ///< Honor checkboxes in the Items tab of the Layers Manager void Load( APP_SETTINGS_BASE* aConfig ) override; void Save( APP_SETTINGS_BASE* aConfig ) override;