Grand printing dialogs refactor
Patch introduces a generic printing settings window that is customized by pcbnew and gerbview.
This commit is contained in:
parent
e81c3a59a2
commit
dea778842b
|
@ -187,6 +187,8 @@ set( COMMON_DLG_SRCS
|
|||
dialogs/dialog_list_selector_base.cpp
|
||||
dialogs/dialog_page_settings_base.cpp
|
||||
dialogs/dialog_text_entry_base.cpp
|
||||
dialogs/dialog_print_generic.cpp
|
||||
dialogs/dialog_print_generic_base.cpp
|
||||
dialogs/dialog_text_entry.cpp
|
||||
dialogs/panel_common_settings.cpp
|
||||
dialogs/panel_common_settings_base.cpp
|
||||
|
@ -322,6 +324,7 @@ set( COMMON_SRCS
|
|||
netlist_keywords.cpp
|
||||
observable.cpp
|
||||
prependpath.cpp
|
||||
printout.cpp
|
||||
project.cpp
|
||||
properties.cpp
|
||||
ptree.cpp
|
||||
|
|
|
@ -29,35 +29,48 @@
|
|||
#include <view/view.h>
|
||||
#include <gal/gal_print.h>
|
||||
#include <painter.h>
|
||||
#include <pcbplot.h>
|
||||
|
||||
PRINT_PARAMETERS::PRINT_PARAMETERS()
|
||||
|
||||
BOARD_PRINTOUT_SETTINGS::BOARD_PRINTOUT_SETTINGS( const PAGE_INFO& aPageInfo )
|
||||
: PRINTOUT_SETTINGS( aPageInfo )
|
||||
{
|
||||
// TODO Millimeter2iu is depends on PCBNEW/GERBVIEW #ifdefs, so it cannot be compiled to libcommon
|
||||
//m_PenDefaultSize = Millimeter2iu( 0.2 ); // A reasonable default value to draw items
|
||||
// which do not have a specified line width
|
||||
m_PenDefaultSize = 0.0;
|
||||
m_PrintScale = 1.0;
|
||||
m_XScaleAdjust = 1.0;
|
||||
m_YScaleAdjust = 1.0;
|
||||
m_Print_Sheet_Ref = false;
|
||||
m_PrintMaskLayer.set();
|
||||
m_PrintMirror = false;
|
||||
m_Print_Black_and_White = true;
|
||||
m_OptionPrintPage = 1;
|
||||
m_PageCount = 1;
|
||||
m_ForceCentered = false;
|
||||
m_Flags = 0;
|
||||
m_DrillShapeOpt = PRINT_PARAMETERS::SMALL_DRILL_SHAPE;
|
||||
m_PageSetupData = NULL;
|
||||
m_layerSet.set();
|
||||
m_mirror = false;
|
||||
}
|
||||
|
||||
|
||||
BOARD_PRINTOUT::BOARD_PRINTOUT( const PRINT_PARAMETERS& aParams, const KIGFX::VIEW* aView,
|
||||
void BOARD_PRINTOUT_SETTINGS::Load( wxConfigBase* aConfig )
|
||||
{
|
||||
PRINTOUT_SETTINGS::Load( aConfig );
|
||||
|
||||
for( unsigned layer = 0; layer < m_layerSet.count(); ++layer )
|
||||
{
|
||||
int tmp;
|
||||
wxString key = wxString::Format( OPTKEY_LAYERBASE, layer );
|
||||
aConfig->Read( key, &tmp, 1 );
|
||||
m_layerSet.set( layer, tmp );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BOARD_PRINTOUT_SETTINGS::Save( wxConfigBase* aConfig )
|
||||
{
|
||||
PRINTOUT_SETTINGS::Save( aConfig );
|
||||
|
||||
for( unsigned layer = 0; layer < m_layerSet.count(); ++layer )
|
||||
{
|
||||
wxString key = wxString::Format( OPTKEY_LAYERBASE, layer );
|
||||
aConfig->Write( key, m_layerSet.test( layer ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOARD_PRINTOUT::BOARD_PRINTOUT( const BOARD_PRINTOUT_SETTINGS& aParams, const KIGFX::VIEW* aView,
|
||||
const wxSize& aSheetSize, const wxString& aTitle ) :
|
||||
wxPrintout( aTitle )
|
||||
wxPrintout( aTitle ), m_settings( aParams )
|
||||
{
|
||||
m_view = aView;
|
||||
m_PrintParams = aParams;
|
||||
m_sheetSize = aSheetSize;
|
||||
}
|
||||
|
||||
|
@ -67,13 +80,8 @@ void BOARD_PRINTOUT::GetPageInfo( int* minPage, int* maxPage, int* selPageFrom,
|
|||
*minPage = 1;
|
||||
*selPageFrom = 1;
|
||||
|
||||
int icnt = 1;
|
||||
|
||||
if( m_PrintParams.m_OptionPrintPage == 0 )
|
||||
icnt = m_PrintParams.m_PageCount;
|
||||
|
||||
*maxPage = icnt;
|
||||
*selPageTo = icnt;
|
||||
*maxPage = m_settings.m_pageCount;
|
||||
*selPageTo = m_settings.m_pageCount;
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,7 +110,7 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa
|
|||
auto srcSettings = m_view->GetPainter()->GetSettings();
|
||||
auto dstSettings = view->GetPainter()->GetSettings();
|
||||
|
||||
if( m_PrintParams.m_Print_Black_and_White )
|
||||
if( m_settings.m_blackWhite )
|
||||
{
|
||||
for( int i = 0; i < LAYER_ID_COUNT; ++i )
|
||||
dstSettings->SetLayerColor( i, COLOR4D::BLACK );
|
||||
|
@ -114,12 +122,12 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa
|
|||
}
|
||||
|
||||
|
||||
setupViewLayers( view, m_PrintParams.m_PrintMaskLayer );
|
||||
setupViewLayers( view, m_settings.m_layerSet );
|
||||
setupPainter( painter );
|
||||
|
||||
BOX2I bBox; // determine printout bounding box
|
||||
|
||||
if( m_PrintParams.PrintBorderAndTitleBlock() )
|
||||
if( m_settings.PrintBorderAndTitleBlock() )
|
||||
{
|
||||
bBox = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( m_sheetSize ) );
|
||||
view->SetLayerVisible( LAYER_WORKSHEET, true );
|
||||
|
@ -133,26 +141,25 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa
|
|||
|
||||
|
||||
// Fit to page
|
||||
if( m_PrintParams.m_PrintScale <= 0.0 )
|
||||
if( m_settings.m_scale <= 0.0 )
|
||||
{
|
||||
if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
|
||||
{
|
||||
// Nothing to print
|
||||
m_PrintParams.m_PrintScale = 1.0;
|
||||
m_settings.m_scale = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
double scaleX = (double) m_sheetSize.GetWidth() / bBox.GetWidth();
|
||||
double scaleY = (double) m_sheetSize.GetHeight() / bBox.GetHeight();
|
||||
m_PrintParams.m_PrintScale = std::min( scaleX, scaleY );
|
||||
m_settings.m_scale = std::min( scaleX, scaleY );
|
||||
}
|
||||
}
|
||||
|
||||
setupGal( gal );
|
||||
galPrint->SetNativePaperSize( pageSizeIn, printCtx->HasNativeLandscapeRotation() );
|
||||
gal->SetFlip( m_PrintParams.m_PrintMirror, false );
|
||||
gal->SetLookAtPoint( bBox.Centre() );
|
||||
gal->SetZoomFactor( m_PrintParams.m_PrintScale );
|
||||
gal->SetZoomFactor( m_settings.m_scale );
|
||||
|
||||
{
|
||||
KIGFX::GAL_DRAWING_CONTEXT ctx( gal );
|
||||
|
@ -176,6 +183,12 @@ void BOARD_PRINTOUT::setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView,
|
|||
|
||||
void BOARD_PRINTOUT::setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPainter )
|
||||
{
|
||||
aPainter->GetSettings()->SetOutlineWidth( m_PrintParams.m_PenDefaultSize );
|
||||
aPainter->GetSettings()->SetOutlineWidth( m_settings.m_lineWidth );
|
||||
aPainter->GetSettings()->SetBackgroundColor( COLOR4D::WHITE );
|
||||
}
|
||||
|
||||
|
||||
void BOARD_PRINTOUT::setupGal( KIGFX::GAL* aGal )
|
||||
{
|
||||
aGal->SetFlip( m_settings.m_mirror, false );
|
||||
}
|
||||
|
|
|
@ -0,0 +1,297 @@
|
|||
/*
|
||||
* Copyright (C) 2018 CERN
|
||||
* Author: Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "dialog_print_generic.h"
|
||||
|
||||
#include <confirm.h>
|
||||
#include <draw_frame.h>
|
||||
#include <printout.h>
|
||||
#include <enabler.h>
|
||||
|
||||
// Define min and max reasonable values for print scale
|
||||
static constexpr double MIN_SCALE = 0.01;
|
||||
static constexpr double MAX_SCALE = 100.0;
|
||||
|
||||
DIALOG_PRINT_GENERIC::DIALOG_PRINT_GENERIC( EDA_DRAW_FRAME* aParent, PRINTOUT_SETTINGS* aSettings )
|
||||
: DIALOG_PRINT_GENERIC_BASE( aParent ), m_config( nullptr ), m_settings( aSettings ),
|
||||
m_lineWidth( aParent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true )
|
||||
{
|
||||
m_scaleValidator.SetRange( MIN_SCALE, MAX_SCALE );
|
||||
m_scaleCustomText->SetValidator( m_scaleValidator );
|
||||
|
||||
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
|
||||
// that requires us to correct the button labels here.
|
||||
m_sdbSizer1OK->SetLabel( _( "Print" ) );
|
||||
m_sdbSizer1Apply->SetLabel( _( "Print Preview" ) );
|
||||
m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
|
||||
m_sdbSizer1->Layout();
|
||||
|
||||
m_sdbSizer1OK->SetDefault();
|
||||
|
||||
#if defined(__WXMAC__) or defined(__WXGTK__)
|
||||
// Preview does not work well on GTK or Mac,
|
||||
// but these platforms provide native print preview
|
||||
m_sdbSizer1Apply->Hide();
|
||||
#endif
|
||||
|
||||
FinishDialogSettings();
|
||||
Layout();
|
||||
initPrintData();
|
||||
}
|
||||
|
||||
|
||||
DIALOG_PRINT_GENERIC::~DIALOG_PRINT_GENERIC()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GENERIC::ForcePrintBorder( bool aValue )
|
||||
{
|
||||
m_titleBlock->SetValue( aValue );
|
||||
m_titleBlock->Hide();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GENERIC::saveSettings()
|
||||
{
|
||||
m_settings->m_lineWidth = m_lineWidth.GetValue();
|
||||
m_settings->m_scale = getScaleValue();
|
||||
m_settings->m_titleBlock = m_titleBlock->GetValue();
|
||||
m_settings->m_blackWhite = m_outputMode->GetSelection();
|
||||
|
||||
if( m_config )
|
||||
m_settings->Save( m_config );
|
||||
}
|
||||
|
||||
|
||||
double DIALOG_PRINT_GENERIC::getScaleValue() const
|
||||
{
|
||||
if( m_scale1->GetValue() )
|
||||
return 1.0;
|
||||
|
||||
if( m_scaleFit->GetValue() )
|
||||
return 0.0;
|
||||
|
||||
if( m_scaleCustom->GetValue() )
|
||||
{
|
||||
double scale;
|
||||
|
||||
wxCHECK( m_scaleCustomText->GetValue().ToDouble( &scale ), 1.0 );
|
||||
return scale;
|
||||
}
|
||||
|
||||
wxCHECK( false, 1.0 );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GENERIC::setScaleValue( double aValue )
|
||||
{
|
||||
wxASSERT( aValue >= 0.0 );
|
||||
|
||||
if( aValue == 0.0 ) // fit to page
|
||||
{
|
||||
m_scaleFit->SetValue( true );
|
||||
}
|
||||
else if( aValue == 1.0 )
|
||||
{
|
||||
m_scale1->SetValue( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( aValue > MAX_SCALE )
|
||||
{
|
||||
DisplayInfoMessage( nullptr, _( "Warning: Scale option set to a very large value" ) );
|
||||
}
|
||||
else if( aValue < MIN_SCALE )
|
||||
{
|
||||
DisplayInfoMessage( nullptr, _( "Warning: Scale option set to a very small value" ) );
|
||||
}
|
||||
|
||||
m_scaleCustom->SetValue( true );
|
||||
m_scaleCustomText->SetValue( wxString::Format( wxT( "%f" ), aValue ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_PRINT_GENERIC::TransferDataToWindow()
|
||||
{
|
||||
if( !wxDialog::TransferDataToWindow() )
|
||||
return false;
|
||||
|
||||
if( m_config )
|
||||
m_settings->Load( m_config );
|
||||
|
||||
m_lineWidth.SetValue( m_settings->m_lineWidth );
|
||||
setScaleValue( m_settings->m_scale );
|
||||
m_titleBlock->SetValue( m_settings->m_titleBlock );
|
||||
m_outputMode->SetSelection( m_settings->m_blackWhite ? 1 : 0 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GENERIC::onPageSetup( wxCommandEvent& event )
|
||||
{
|
||||
wxPageSetupDialog pageSetupDialog( this, s_pageSetupData );
|
||||
pageSetupDialog.ShowModal();
|
||||
|
||||
(*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
|
||||
(*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GENERIC::onPrintPreview( wxCommandEvent& event )
|
||||
{
|
||||
m_settings->m_pageCount = 0; // it needs to be set by a derived dialog
|
||||
saveSettings();
|
||||
|
||||
if( m_settings->m_pageCount == 0 )
|
||||
{
|
||||
DisplayError( this, _( "Nothing to print" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// Pass two printout objects: for preview, and possible printing.
|
||||
wxString title = _( "Print Preview" );
|
||||
wxPrintPreview* preview =
|
||||
new wxPrintPreview( createPrintout( title ), createPrintout( title ), s_PrintData );
|
||||
|
||||
preview->SetZoom( 100 );
|
||||
|
||||
wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, m_parent->GetPosition(),
|
||||
m_parent->GetSize() );
|
||||
frame->SetMinSize( wxSize( 550, 350 ) );
|
||||
frame->Center();
|
||||
|
||||
// On wxGTK, set the flag wxTOPLEVEL_EX_DIALOG is mandatory, if we want
|
||||
// close the frame using the X box in caption, when the preview frame is run
|
||||
// from a dialog
|
||||
frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
|
||||
|
||||
// We use here wxPreviewFrame_WindowModal option to make the wxPrintPreview frame
|
||||
// modal for its caller only.
|
||||
// An other reason is the fact when closing the frame without this option,
|
||||
// all top level frames are reenabled.
|
||||
// With this option, only the parent is reenabled.
|
||||
// Reenabling all top level frames should be made by the parent dialog.
|
||||
frame->InitializeWithModality( wxPreviewFrame_WindowModal );
|
||||
|
||||
frame->Raise(); // Needed on Ubuntu/Unity to display the frame
|
||||
frame->Show( true );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GENERIC::onPrintButtonClick( wxCommandEvent& event )
|
||||
{
|
||||
m_settings->m_pageCount = 0; // it needs to be set by a derived dialog
|
||||
saveSettings();
|
||||
|
||||
if( m_settings->m_pageCount == 0 )
|
||||
{
|
||||
DisplayError( this, _( "Nothing to print" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
wxPrintDialogData printDialogData( *s_PrintData );
|
||||
printDialogData.SetMaxPage( m_settings->m_pageCount );
|
||||
|
||||
wxPrinter printer( &printDialogData );
|
||||
auto printout = std::unique_ptr<wxPrintout>( createPrintout( _( "Print" ) ) );
|
||||
|
||||
// Disable 'Print' button to prevent issuing another print
|
||||
// command before the previous one is finished (causes problems on Windows)
|
||||
ENABLER printBtnDisable( *m_sdbSizer1OK, false );
|
||||
|
||||
if( !printer.Print( this, printout.get(), true ) )
|
||||
{
|
||||
if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
|
||||
DisplayError( this, _( "There was a problem printing." ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
*s_PrintData = printer.GetPrintDialogData().GetPrintData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GENERIC::onCloseButton( wxCommandEvent& event )
|
||||
{
|
||||
saveSettings();
|
||||
|
||||
if( IsQuasiModal() )
|
||||
EndQuasiModal( wxID_CANCEL );
|
||||
|
||||
if( IsModal() )
|
||||
EndModal( wxID_CANCEL );
|
||||
|
||||
Close( wxID_CANCEL );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GENERIC::onClose( wxCloseEvent& event )
|
||||
{
|
||||
saveSettings();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GENERIC::onSetCustomScale( wxCommandEvent& event )
|
||||
{
|
||||
// Select 'custom scale' radio button when user types in a value in the
|
||||
// custom scale text box
|
||||
m_scaleCustom->SetValue( true );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GENERIC::initPrintData()
|
||||
{
|
||||
if( !s_PrintData ) // First print
|
||||
{
|
||||
s_PrintData = new wxPrintData();
|
||||
|
||||
if( !s_PrintData->Ok() )
|
||||
DisplayError( this, _( "An error occurred initializing the printer information." ) );
|
||||
|
||||
s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH;
|
||||
}
|
||||
|
||||
if( !s_pageSetupData )
|
||||
{
|
||||
const PAGE_INFO& pageInfo = m_settings->m_pageInfo;
|
||||
|
||||
s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
|
||||
s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
|
||||
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
|
||||
|
||||
if( pageInfo.IsCustom() )
|
||||
{
|
||||
if( pageInfo.IsPortrait() )
|
||||
s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ),
|
||||
Mils2mm( pageInfo.GetHeightMils() ) ) );
|
||||
else
|
||||
s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ),
|
||||
Mils2mm( pageInfo.GetWidthMils() ) ) );
|
||||
}
|
||||
|
||||
*s_PrintData = s_pageSetupData->GetPrintData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wxPrintData* DIALOG_PRINT_GENERIC::s_PrintData = nullptr;
|
||||
wxPageSetupDialogData* DIALOG_PRINT_GENERIC::s_pageSetupData = nullptr;
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Copyright (C) 2018 CERN
|
||||
* Author: Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DIALOG_PRINT_GENERIC_H
|
||||
#define DIALOG_PRINT_GENERIC_H
|
||||
|
||||
#include "dialog_print_generic_base.h"
|
||||
#include <wx/valnum.h>
|
||||
#include <widgets/unit_binder.h>
|
||||
|
||||
class wxConfigBase;
|
||||
class EDA_DRAW_FRAME;
|
||||
struct PRINTOUT_SETTINGS;
|
||||
|
||||
class DIALOG_PRINT_GENERIC : public DIALOG_PRINT_GENERIC_BASE
|
||||
{
|
||||
public:
|
||||
DIALOG_PRINT_GENERIC( EDA_DRAW_FRAME* aParent, PRINTOUT_SETTINGS* aSettings );
|
||||
virtual ~DIALOG_PRINT_GENERIC();
|
||||
|
||||
/**
|
||||
* Set 'print border and title block' to a requested value and hides the
|
||||
* corresponding checkbox.
|
||||
*/
|
||||
void ForcePrintBorder( bool aValue );
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Create a printout with a requested title.
|
||||
*/
|
||||
virtual wxPrintout* createPrintout( const wxString& aTitle ) = 0;
|
||||
|
||||
virtual void saveSettings();
|
||||
|
||||
wxSizer* getMainSizer()
|
||||
{
|
||||
return bUpperSizer;
|
||||
}
|
||||
|
||||
wxGridBagSizer* getOptionsSizer()
|
||||
{
|
||||
return gbOptionsSizer;
|
||||
}
|
||||
|
||||
wxStaticBox* getOptionsBox()
|
||||
{
|
||||
return sbOptionsSizer->GetStaticBox();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return scale value selected in the dialog.
|
||||
*/
|
||||
double getScaleValue() const;
|
||||
|
||||
/**
|
||||
* Select a corresponding scale radio button and update custom scale value if needed.
|
||||
* @param aValue is the scale value to be selected (0 stands for fit-to-page).
|
||||
*/
|
||||
void setScaleValue( double aValue );
|
||||
|
||||
// There is no TransferDataFromWindow() so options are saved
|
||||
// even if the dialog is closed without printing
|
||||
bool TransferDataToWindow() override;
|
||||
|
||||
wxConfigBase* m_config;
|
||||
|
||||
PRINTOUT_SETTINGS* m_settings;
|
||||
|
||||
UNIT_BINDER m_lineWidth;
|
||||
|
||||
private:
|
||||
void onPageSetup( wxCommandEvent& event ) override;
|
||||
void onPrintPreview( wxCommandEvent& event ) override;
|
||||
void onPrintButtonClick( wxCommandEvent& event ) override;
|
||||
|
||||
// Needed to execute onClose handler
|
||||
void onCloseButton( wxCommandEvent& event ) override;
|
||||
void onClose( wxCloseEvent& event ) override;
|
||||
void onSetCustomScale( wxCommandEvent& event ) override;
|
||||
|
||||
void initPrintData();
|
||||
|
||||
wxFloatingPointValidator<double> m_scaleValidator;
|
||||
|
||||
static wxPrintData* s_PrintData;
|
||||
static wxPageSetupDialogData* s_pageSetupData;
|
||||
};
|
||||
|
||||
#endif // DIALOG_PRINT_GENERIC_H
|
|
@ -0,0 +1,149 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 17 2016)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dialog_print_generic_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DIALOG_PRINT_GENERIC_BASE::DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
|
||||
|
||||
wxBoxSizer* bMainSizer;
|
||||
bMainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
bUpperSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxBoxSizer* bOptionsSizer;
|
||||
bOptionsSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL );
|
||||
|
||||
gbOptionsSizer = new wxGridBagSizer( 2, 0 );
|
||||
gbOptionsSizer->SetFlexibleDirection( wxBOTH );
|
||||
gbOptionsSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
m_penWidthLabel = new wxStaticText( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Default line width:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_penWidthLabel->Wrap( -1 );
|
||||
m_penWidthLabel->SetToolTip( _("Pen size used to draw items that have no pen size specified.\nUsed mainly to draw items in sketch mode.") );
|
||||
|
||||
gbOptionsSizer->Add( m_penWidthLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
|
||||
|
||||
m_penWidthCtrl = new wxTextCtrl( sbOptionsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
gbOptionsSizer->Add( m_penWidthCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
m_penWidthUnits = new wxStaticText( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_penWidthUnits->Wrap( -1 );
|
||||
gbOptionsSizer->Add( m_penWidthUnits, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
|
||||
|
||||
m_outputModeLabel = new wxStaticText( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Output mode:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_outputModeLabel->Wrap( -1 );
|
||||
gbOptionsSizer->Add( m_outputModeLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 );
|
||||
|
||||
wxString m_outputModeChoices[] = { _("Color"), _("Black and white") };
|
||||
int m_outputModeNChoices = sizeof( m_outputModeChoices ) / sizeof( wxString );
|
||||
m_outputMode = new wxChoice( sbOptionsSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_outputModeNChoices, m_outputModeChoices, 0 );
|
||||
m_outputMode->SetSelection( 0 );
|
||||
gbOptionsSizer->Add( m_outputMode, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
m_titleBlock = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_FRAME_SEL, _("Print border and title block"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_titleBlock->SetValue(true);
|
||||
m_titleBlock->SetToolTip( _("Print Frame references.") );
|
||||
|
||||
gbOptionsSizer->Add( m_titleBlock, wxGBPosition( 3, 0 ), wxGBSpan( 1, 3 ), wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
gbOptionsSizer->AddGrowableCol( 1 );
|
||||
|
||||
sbOptionsSizer->Add( gbOptionsSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bOptionsSizer->Add( sbOptionsSizer, 1, wxEXPAND|wxALL, 5 );
|
||||
|
||||
wxStaticBoxSizer* bScaleSizer;
|
||||
bScaleSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Scale") ), wxVERTICAL );
|
||||
|
||||
m_scale1 = new wxRadioButton( bScaleSizer->GetStaticBox(), wxID_ANY, _("1:1"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bScaleSizer->Add( m_scale1, 0, 0, 5 );
|
||||
|
||||
m_scaleFit = new wxRadioButton( bScaleSizer->GetStaticBox(), wxID_ANY, _("Fit to page"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bScaleSizer->Add( m_scaleFit, 0, wxTOP, 5 );
|
||||
|
||||
wxBoxSizer* bSizer10;
|
||||
bSizer10 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_scaleCustom = new wxRadioButton( bScaleSizer->GetStaticBox(), wxID_ANY, _("Custom:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer10->Add( m_scaleCustom, 0, wxTOP, 5 );
|
||||
|
||||
m_scaleCustomText = new wxTextCtrl( bScaleSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_scaleCustomText->SetToolTip( _("Set X scale adjust for exact scale plotting") );
|
||||
|
||||
bSizer10->Add( m_scaleCustomText, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bScaleSizer->Add( bSizer10, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bOptionsSizer->Add( bScaleSizer, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bUpperSizer->Add( bOptionsSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bMainSizer->Add( bUpperSizer, 1, wxEXPAND|wxALL, 5 );
|
||||
|
||||
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
bMainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
wxBoxSizer* bButtonsSizer;
|
||||
bButtonsSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_buttonOption = new wxButton( this, wxID_PRINT_OPTIONS, _("Page Setup..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_buttonOption->SetMinSize( wxSize( 120,-1 ) );
|
||||
|
||||
bButtonsSizer->Add( m_buttonOption, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_sdbSizer1 = new wxStdDialogButtonSizer();
|
||||
m_sdbSizer1OK = new wxButton( this, wxID_OK );
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1OK );
|
||||
m_sdbSizer1Apply = new wxButton( this, wxID_APPLY );
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1Apply );
|
||||
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
|
||||
m_sdbSizer1->Realize();
|
||||
|
||||
bButtonsSizer->Add( m_sdbSizer1, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bMainSizer->Add( bButtonsSizer, 0, wxEXPAND|wxLEFT, 10 );
|
||||
|
||||
|
||||
this->SetSizer( bMainSizer );
|
||||
this->Layout();
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_GENERIC_BASE::onClose ) );
|
||||
m_scaleCustomText->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onSetCustomScale ), NULL, this );
|
||||
m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPageSetup ), NULL, this );
|
||||
m_sdbSizer1Apply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintPreview ), NULL, this );
|
||||
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onCloseButton ), NULL, this );
|
||||
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintButtonClick ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_PRINT_GENERIC_BASE::~DIALOG_PRINT_GENERIC_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_GENERIC_BASE::onClose ) );
|
||||
m_scaleCustomText->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onSetCustomScale ), NULL, this );
|
||||
m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPageSetup ), NULL, this );
|
||||
m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintPreview ), NULL, this );
|
||||
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onCloseButton ), NULL, this );
|
||||
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintButtonClick ), NULL, this );
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -5,8 +5,8 @@
|
|||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __DIALOG_PRINT_PCBNEW_BASE_H__
|
||||
#define __DIALOG_PRINT_PCBNEW_BASE_H__
|
||||
#ifndef __DIALOG_PRINT_GENERIC_BASE_H__
|
||||
#define __DIALOG_PRINT_GENERIC_BASE_H__
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
|
@ -20,25 +20,23 @@ class DIALOG_SHIM;
|
|||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/checklst.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/radiobox.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/radiobut.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class DIALOG_PRINT_PCBNEW_BASE
|
||||
/// Class DIALOG_PRINT_GENERIC_BASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class DIALOG_PRINT_PCBNEW_BASE : public DIALOG_SHIM
|
||||
class DIALOG_PRINT_GENERIC_BASE : public DIALOG_SHIM
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -46,27 +44,18 @@ class DIALOG_PRINT_PCBNEW_BASE : public DIALOG_SHIM
|
|||
enum
|
||||
{
|
||||
wxID_FRAME_SEL = 1000,
|
||||
wxID_PAGE_MODE,
|
||||
wxID_PRINT_OPTIONS
|
||||
};
|
||||
|
||||
wxStaticText* m_staticText4;
|
||||
wxCheckListBox* m_CopperLayersList;
|
||||
wxStaticText* m_staticText5;
|
||||
wxCheckListBox* m_TechnicalLayersList;
|
||||
wxButton* m_buttonSelectAll;
|
||||
wxButton* m_buttonDeselectAll;
|
||||
wxCheckBox* m_Exclude_Edges_Pcb;
|
||||
wxBoxSizer* bUpperSizer;
|
||||
wxStaticBoxSizer* sbOptionsSizer;
|
||||
wxGridBagSizer* gbOptionsSizer;
|
||||
wxStaticText* m_penWidthLabel;
|
||||
wxTextCtrl* m_penWidthCtrl;
|
||||
wxStaticText* m_penWidthUnits;
|
||||
wxStaticText* m_drillMarksLabel;
|
||||
wxChoice* m_drillMarksChoice;
|
||||
wxStaticText* m_outputModeLabel;
|
||||
wxChoice* m_outputMode;
|
||||
wxCheckBox* m_Print_Sheet_Ref;
|
||||
wxCheckBox* m_Print_Mirror;
|
||||
wxRadioBox* m_PagesOption;
|
||||
wxCheckBox* m_titleBlock;
|
||||
wxRadioButton* m_scale1;
|
||||
wxRadioButton* m_scaleFit;
|
||||
wxRadioButton* m_scaleCustom;
|
||||
|
@ -79,19 +68,19 @@ class DIALOG_PRINT_PCBNEW_BASE : public DIALOG_SHIM
|
|||
wxButton* m_sdbSizer1Cancel;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnSelectAllClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnDeselectAllClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnSetCustomScale( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnPageSetup( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnPrintPreview( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnPrintButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onClose( wxCloseEvent& event ) { event.Skip(); }
|
||||
virtual void onSetCustomScale( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onPageSetup( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onPrintPreview( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onCloseButton( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onPrintButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DIALOG_PRINT_PCBNEW_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 700,550 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_PRINT_PCBNEW_BASE();
|
||||
DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 410,476 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_PRINT_GENERIC_BASE();
|
||||
|
||||
};
|
||||
|
||||
#endif //__DIALOG_PRINT_PCBNEW_BASE_H__
|
||||
#endif //__DIALOG_PRINT_GENERIC_BASE_H__
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 2018 CERN
|
||||
* Author: Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <printout.h>
|
||||
#include <pcbplot.h>
|
||||
#include <wx/config.h>
|
||||
|
||||
void PRINTOUT_SETTINGS::Save( wxConfigBase* aConfig )
|
||||
{
|
||||
aConfig->Write( OPTKEY_PRINT_SCALE, m_scale );
|
||||
aConfig->Write( OPTKEY_PRINT_PAGE_FRAME, m_titleBlock );
|
||||
aConfig->Write( OPTKEY_PRINT_MONOCHROME_MODE, m_blackWhite );
|
||||
}
|
||||
|
||||
|
||||
void PRINTOUT_SETTINGS::Load( wxConfigBase* aConfig )
|
||||
{
|
||||
aConfig->Read( OPTKEY_PRINT_SCALE, &m_scale, 1.0 );
|
||||
aConfig->Read( OPTKEY_PRINT_PAGE_FRAME, &m_titleBlock, false );
|
||||
aConfig->Read( OPTKEY_PRINT_MONOCHROME_MODE, &m_blackWhite, 1 );
|
||||
}
|
|
@ -10,6 +10,7 @@ include_directories(
|
|||
../include/legacy_wx
|
||||
../pcbnew
|
||||
dialogs
|
||||
../common
|
||||
../3d-viewer
|
||||
../polygon
|
||||
${INC_AFTER}
|
||||
|
@ -22,8 +23,7 @@ set( DIALOGS_SRCS
|
|||
dialogs/panel_gerbview_settings.cpp
|
||||
dialogs/panel_gerbview_settings_base.cpp
|
||||
dialogs/dialog_layers_select_to_pcb_base.cpp
|
||||
dialogs/dialog_print_using_printer.cpp
|
||||
dialogs/dialog_print_using_printer_base.cpp
|
||||
dialogs/dialog_print_gerbview.cpp
|
||||
dialogs/dialog_select_one_pcb_layer.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,328 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2010-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2018 CERN
|
||||
* Author: Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
|
||||
#include <kiface_i.h>
|
||||
#include <common.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <confirm.h>
|
||||
|
||||
#include <dialogs/dialog_print_generic.h>
|
||||
#include <gerbview_printout.h>
|
||||
|
||||
#include <gerbview.h>
|
||||
#include <gerbview_frame.h>
|
||||
#include <gerber_file_image.h>
|
||||
#include <gerber_file_image_list.h>
|
||||
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/gerbview_actions.h>
|
||||
|
||||
///@{
|
||||
/// \ingroup config
|
||||
|
||||
#define OPTKEY_LAYERBASE wxT( "PlotLayer_%d" )
|
||||
#define OPTKEY_PRINT_X_FINESCALE_ADJ wxT( "PrintXFineScaleAdj" )
|
||||
#define OPTKEY_PRINT_Y_FINESCALE_ADJ wxT( "PrintYFineScaleAdj" )
|
||||
#define OPTKEY_PRINT_SCALE wxT( "PrintScale" )
|
||||
#define OPTKEY_PRINT_PAGE_FRAME wxT( "PrintPageFrame" )
|
||||
#define OPTKEY_PRINT_MONOCHROME_MODE wxT( "PrintMonochrome" )
|
||||
|
||||
///@}
|
||||
|
||||
|
||||
class DIALOG_PRINT_GERBVIEW : public DIALOG_PRINT_GENERIC
|
||||
{
|
||||
public:
|
||||
DIALOG_PRINT_GERBVIEW( GERBVIEW_FRAME* aParent, BOARD_PRINTOUT_SETTINGS* aSettings );
|
||||
~DIALOG_PRINT_GERBVIEW() {};
|
||||
|
||||
private:
|
||||
BOARD_PRINTOUT_SETTINGS* settings() const
|
||||
{
|
||||
wxASSERT( dynamic_cast<BOARD_PRINTOUT_SETTINGS*>( m_settings ) );
|
||||
return static_cast<BOARD_PRINTOUT_SETTINGS*>( m_settings );
|
||||
}
|
||||
|
||||
bool TransferDataToWindow() override;
|
||||
|
||||
void createExtraOptions();
|
||||
void createLeftPanel();
|
||||
|
||||
void onSelectAllClick( wxCommandEvent& event );
|
||||
void onDeselectAllClick( wxCommandEvent& event );
|
||||
|
||||
///> (Un)check all items in a checklist box
|
||||
void setListBoxValue( wxCheckListBox* aList, bool aValue );
|
||||
|
||||
///> Check whether a layer is enabled in a listbox
|
||||
bool isLayerEnabled( unsigned int aLayer ) const;
|
||||
|
||||
///> Enable/disable layer in a listbox
|
||||
void enableLayer( unsigned int aLayer, bool aValue );
|
||||
|
||||
///> Update layerset basing on the selected layers
|
||||
int setLayerSetFromList();
|
||||
|
||||
void saveSettings() override;
|
||||
|
||||
wxPrintout* createPrintout( const wxString& aTitle ) override
|
||||
{
|
||||
return new GERBVIEW_PRINTOUT( m_parent->GetGerberLayout(), *settings(),
|
||||
m_parent->GetGalCanvas()->GetView(), m_parent->GetPageSettings().GetSizeIU(), aTitle );
|
||||
}
|
||||
|
||||
GERBVIEW_FRAME* m_parent;
|
||||
|
||||
// Number of layers in each list
|
||||
static constexpr unsigned int LAYER_PER_LIST = 16;
|
||||
|
||||
// Number of layer list widgets
|
||||
static constexpr unsigned int LAYER_LIST_COUNT = 2;
|
||||
|
||||
// Extra widgets
|
||||
wxCheckListBox* m_layerLists[LAYER_LIST_COUNT];
|
||||
wxButton* m_buttonSelectAll;
|
||||
wxButton* m_buttonDeselectAll;
|
||||
wxCheckBox* m_checkboxMirror;
|
||||
|
||||
// Map layer numbers to items on the list
|
||||
std::unordered_map<int, int> m_layerToItemMap;
|
||||
};
|
||||
|
||||
|
||||
DIALOG_PRINT_GERBVIEW::DIALOG_PRINT_GERBVIEW( GERBVIEW_FRAME* aParent, BOARD_PRINTOUT_SETTINGS* aSettings ) :
|
||||
DIALOG_PRINT_GENERIC( aParent, aSettings )
|
||||
{
|
||||
m_parent = aParent;
|
||||
m_config = Kiface().KifaceSettings();
|
||||
|
||||
// Line width settings range
|
||||
m_lineWidth.SetMax( KiROUND( 5 * IU_PER_MM ) );
|
||||
m_lineWidth.SetMin( KiROUND( 0.005 * IU_PER_MM ) );
|
||||
|
||||
createExtraOptions();
|
||||
createLeftPanel();
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_PRINT_GERBVIEW::TransferDataToWindow()
|
||||
{
|
||||
if( !DIALOG_PRINT_GENERIC::TransferDataToWindow() )
|
||||
return false;
|
||||
|
||||
if( m_config )
|
||||
settings()->Load( m_config );
|
||||
|
||||
GERBER_FILE_IMAGE_LIST* images = m_parent->GetGerberLayout()->GetImagesList();
|
||||
int itemIdx = 0;
|
||||
|
||||
// Create layer list
|
||||
for( unsigned ii = 0; ii < images->ImagesMaxCount(); ++ii )
|
||||
{
|
||||
wxString layerName;
|
||||
unsigned int listIdx = itemIdx / LAYER_PER_LIST;
|
||||
|
||||
if( listIdx >= LAYER_LIST_COUNT )
|
||||
{
|
||||
wxFAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
GERBER_FILE_IMAGE* gbrImage = images->GetGbrImage( ii );
|
||||
|
||||
if( !gbrImage )
|
||||
continue;
|
||||
|
||||
wxFileName filename( gbrImage->m_FileName );
|
||||
m_layerLists[listIdx]->Append( filename.GetFullName() );
|
||||
wxASSERT( m_layerToItemMap.count( ii ) == 0 );
|
||||
m_layerToItemMap[ii] = itemIdx;
|
||||
++itemIdx;
|
||||
}
|
||||
|
||||
m_checkboxMirror->SetValue( settings()->m_mirror );
|
||||
|
||||
// Update the dialog layout when layers are added
|
||||
GetSizer()->Fit( this );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GERBVIEW::createExtraOptions()
|
||||
{
|
||||
wxGridBagSizer* optionsSizer = getOptionsSizer();
|
||||
wxStaticBox* box = getOptionsBox();
|
||||
int rows = optionsSizer->GetEffectiveRowsCount();
|
||||
int cols = optionsSizer->GetEffectiveColsCount();
|
||||
|
||||
// Print mirrored
|
||||
m_checkboxMirror = new wxCheckBox( box, wxID_ANY, _( "Print mirrored" ) );
|
||||
optionsSizer->Add( m_checkboxMirror, wxGBPosition( rows, 0 ), wxGBSpan( 1, cols ),
|
||||
wxBOTTOM | wxRIGHT | wxLEFT, 5 );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GERBVIEW::createLeftPanel()
|
||||
{
|
||||
wxStaticBoxSizer* sbLayersSizer = new wxStaticBoxSizer( new wxStaticBox( this,
|
||||
wxID_ANY, _( "Included Layers" ) ), wxVERTICAL );
|
||||
|
||||
// Layer lists
|
||||
wxBoxSizer* bLayerListsSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
for( unsigned int i = 0; i < LAYER_LIST_COUNT; ++i )
|
||||
{
|
||||
m_layerLists[i] = new wxCheckListBox( sbLayersSizer->GetStaticBox(), wxID_ANY );
|
||||
bLayerListsSizer->Add( m_layerLists[i], 1, wxEXPAND, 5 );
|
||||
}
|
||||
|
||||
|
||||
// Select/Unselect all buttons
|
||||
m_buttonSelectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Select all" ) );
|
||||
m_buttonDeselectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Deselect all" ) );
|
||||
|
||||
m_buttonSelectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
wxCommandEventHandler( DIALOG_PRINT_GERBVIEW::onSelectAllClick ), NULL, this );
|
||||
m_buttonDeselectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
wxCommandEventHandler( DIALOG_PRINT_GERBVIEW::onDeselectAllClick ), NULL, this );
|
||||
|
||||
wxBoxSizer* buttonSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
buttonSizer->Add( m_buttonSelectAll, 1, wxALL, 5 );
|
||||
buttonSizer->Add( m_buttonDeselectAll, 1, wxALL, 5 );
|
||||
|
||||
// Static box sizer layout
|
||||
sbLayersSizer->Add( bLayerListsSizer, 1, wxALL | wxEXPAND, 5 );
|
||||
sbLayersSizer->Add( buttonSizer, 0, wxALL | wxEXPAND, 5 );
|
||||
|
||||
getMainSizer()->Insert( 0, sbLayersSizer, 1, wxEXPAND );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GERBVIEW::onSelectAllClick( wxCommandEvent& event )
|
||||
{
|
||||
for( unsigned int i = 0; i < LAYER_LIST_COUNT; ++i )
|
||||
setListBoxValue( m_layerLists[i], true );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GERBVIEW::onDeselectAllClick( wxCommandEvent& event )
|
||||
{
|
||||
for( unsigned int i = 0; i < LAYER_LIST_COUNT; ++i )
|
||||
setListBoxValue( m_layerLists[i], false );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GERBVIEW::setListBoxValue( wxCheckListBox* aList, bool aValue )
|
||||
{
|
||||
for( unsigned int i = 0; i < aList->GetCount(); ++i )
|
||||
aList->Check( i, aValue );
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_PRINT_GERBVIEW::isLayerEnabled( unsigned int aLayer ) const
|
||||
{
|
||||
auto layerMapIt = m_layerToItemMap.find( aLayer );
|
||||
|
||||
if( layerMapIt == m_layerToItemMap.end() )
|
||||
return false;
|
||||
|
||||
unsigned int itemNr = layerMapIt->second;
|
||||
unsigned int listIdx = itemNr / LAYER_PER_LIST;
|
||||
unsigned int itemIdx = itemNr % LAYER_PER_LIST;
|
||||
wxCHECK( listIdx < LAYER_LIST_COUNT, false );
|
||||
wxCheckListBox* listBox = m_layerLists[listIdx];
|
||||
|
||||
return itemIdx < listBox->GetCount() && listBox->IsChecked( itemIdx );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GERBVIEW::enableLayer( unsigned int aLayer, bool aValue )
|
||||
{
|
||||
auto layerMapIt = m_layerToItemMap.find( aLayer );
|
||||
|
||||
if( layerMapIt == m_layerToItemMap.end() )
|
||||
return;
|
||||
|
||||
unsigned int itemNr = layerMapIt->second;
|
||||
unsigned int listIdx = itemNr / LAYER_PER_LIST;
|
||||
unsigned int itemIdx = itemNr % LAYER_PER_LIST;
|
||||
wxCHECK( listIdx < LAYER_LIST_COUNT, /* void */ );
|
||||
wxCheckListBox* listBox = m_layerLists[listIdx];
|
||||
|
||||
if( itemIdx < listBox->GetCount() )
|
||||
listBox->Check( itemIdx, aValue );
|
||||
}
|
||||
|
||||
|
||||
int DIALOG_PRINT_GERBVIEW::setLayerSetFromList()
|
||||
{
|
||||
settings()->m_layerSet = LSET();
|
||||
int& pageCount = settings()->m_pageCount;
|
||||
pageCount = 0;
|
||||
|
||||
unsigned int layer = 0;
|
||||
|
||||
for( unsigned int j = 0; j < LAYER_LIST_COUNT; ++j )
|
||||
{
|
||||
for( unsigned int i = 0; i < LAYER_PER_LIST; ++i )
|
||||
{
|
||||
if( isLayerEnabled( layer ) )
|
||||
{
|
||||
settings()->m_layerSet.set( layer );
|
||||
++pageCount;
|
||||
}
|
||||
|
||||
++layer;
|
||||
}
|
||||
}
|
||||
|
||||
return pageCount;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_GERBVIEW::saveSettings()
|
||||
{
|
||||
setLayerSetFromList();
|
||||
|
||||
settings()->m_mirror = m_checkboxMirror->GetValue();
|
||||
|
||||
DIALOG_PRINT_GENERIC::saveSettings();
|
||||
}
|
||||
|
||||
|
||||
void GERBVIEW_FRAME::ToPrinter( wxCommandEvent& event )
|
||||
{
|
||||
// Selection affects the original item visibility
|
||||
GetToolManager()->RunAction( GERBVIEW_ACTIONS::selectionClear, true );
|
||||
|
||||
BOARD_PRINTOUT_SETTINGS settings( GetPageSettings() );
|
||||
DIALOG_PRINT_GERBVIEW dlg( this, &settings );
|
||||
dlg.ForcePrintBorder( false );
|
||||
dlg.ShowModal();
|
||||
}
|
|
@ -1,432 +0,0 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2010-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
|
||||
#include <kiface_i.h>
|
||||
#include <common.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <confirm.h>
|
||||
|
||||
#include <dialog_print_using_printer_base.h>
|
||||
#include <gerbview_printout.h>
|
||||
|
||||
#include <gerbview.h>
|
||||
#include <gerbview_frame.h>
|
||||
#include <gerber_file_image.h>
|
||||
#include <gerber_file_image_list.h>
|
||||
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/gerbview_actions.h>
|
||||
|
||||
#include <enabler.h>
|
||||
|
||||
///@{
|
||||
/// \ingroup config
|
||||
|
||||
#define OPTKEY_LAYERBASE wxT( "PlotLayer_%d" )
|
||||
#define OPTKEY_PRINT_X_FINESCALE_ADJ wxT( "PrintXFineScaleAdj" )
|
||||
#define OPTKEY_PRINT_Y_FINESCALE_ADJ wxT( "PrintYFineScaleAdj" )
|
||||
#define OPTKEY_PRINT_SCALE wxT( "PrintScale" )
|
||||
#define OPTKEY_PRINT_PAGE_FRAME wxT( "PrintPageFrame" )
|
||||
#define OPTKEY_PRINT_MONOCHROME_MODE wxT( "PrintMonochrome" )
|
||||
|
||||
///@}
|
||||
|
||||
static double s_ScaleList[] =
|
||||
{ 0, 0.5, 0.7, 0.999, 1.0, 1.4, 2.0, 3.0, 4.0 };
|
||||
|
||||
// Define min et max reasonnable values for print scale
|
||||
#define MIN_SCALE 0.01
|
||||
#define MAX_SCALE 100.0
|
||||
|
||||
// static print data and page setup data, to remember settings during the session
|
||||
static wxPrintData* s_printData;
|
||||
static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL;
|
||||
|
||||
// Variables locales
|
||||
static PRINT_PARAMETERS s_Parameters;
|
||||
|
||||
|
||||
/* Dialog to print schematic. Class derived from DIALOG_PRINT_USING_PRINTER_BASE
|
||||
* created by wxFormBuilder
|
||||
*/
|
||||
class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE
|
||||
{
|
||||
private:
|
||||
GERBVIEW_FRAME* m_Parent;
|
||||
wxConfigBase* m_Config;
|
||||
wxCheckBox* m_BoxSelectLayer[32];
|
||||
|
||||
public:
|
||||
DIALOG_PRINT_USING_PRINTER( GERBVIEW_FRAME* parent );
|
||||
~DIALOG_PRINT_USING_PRINTER() {};
|
||||
|
||||
private:
|
||||
void OnCloseWindow( wxCloseEvent& event ) override;
|
||||
void OnInitDialog( wxInitDialogEvent& event );
|
||||
void OnPageSetup( wxCommandEvent& event ) override;
|
||||
void OnPrintPreview( wxCommandEvent& event ) override;
|
||||
void OnPrintButtonClick( wxCommandEvent& event ) override;
|
||||
void OnScaleSelectionClick( wxCommandEvent& event ) override;
|
||||
|
||||
void OnButtonCloseClick( wxCommandEvent& event ) override { Close(); }
|
||||
void SetPrintParameters();
|
||||
void InitValues();
|
||||
|
||||
GERBVIEW_PRINTOUT* createPrintout( const wxString& aTitle )
|
||||
{
|
||||
return new GERBVIEW_PRINTOUT( m_Parent->GetGerberLayout(), s_Parameters,
|
||||
m_Parent->GetGalCanvas()->GetView(), m_Parent->GetPageSettings().GetSizeIU(), aTitle );
|
||||
}
|
||||
|
||||
public:
|
||||
bool IsMirrored() { return m_Print_Mirror->IsChecked(); }
|
||||
bool PrintUsingSinglePage() { return true; }
|
||||
int SetLayerSetFromListSelection();
|
||||
};
|
||||
|
||||
|
||||
void GERBVIEW_FRAME::ToPrinter( wxCommandEvent& event )
|
||||
{
|
||||
// Selection affects the original item visibility
|
||||
GetToolManager()->RunAction( GERBVIEW_ACTIONS::selectionClear, true );
|
||||
|
||||
if( s_printData == NULL ) // First print
|
||||
s_printData = new wxPrintData();
|
||||
|
||||
if( !s_printData->Ok() )
|
||||
{
|
||||
DisplayError( this, _( "Error Init Printer info" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
s_printData->SetQuality( wxPRINT_QUALITY_HIGH );
|
||||
s_printData->SetOrientation( GetPageSettings().IsPortrait() ?
|
||||
wxPORTRAIT : wxLANDSCAPE );
|
||||
|
||||
DIALOG_PRINT_USING_PRINTER* frame = new DIALOG_PRINT_USING_PRINTER( this );
|
||||
|
||||
frame->ShowModal();
|
||||
frame->Destroy();
|
||||
}
|
||||
|
||||
|
||||
DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( GERBVIEW_FRAME* parent ) :
|
||||
DIALOG_PRINT_USING_PRINTER_BASE( parent )
|
||||
{
|
||||
m_Parent = parent;
|
||||
m_Config = Kiface().KifaceSettings();
|
||||
|
||||
InitValues( );
|
||||
GetSizer()->SetSizeHints( this );
|
||||
|
||||
#ifdef __WXMAC__
|
||||
/* Problems with modal on wx-2.9 - Anyway preview is standard for OSX */
|
||||
m_buttonPreview->Hide();
|
||||
#endif
|
||||
|
||||
GetSizer()->Fit( this );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_USING_PRINTER::InitValues( )
|
||||
{
|
||||
SetFocus();
|
||||
wxString msg;
|
||||
|
||||
if( s_pageSetupData == NULL )
|
||||
{
|
||||
s_pageSetupData = new wxPageSetupDialogData;
|
||||
// Set initial page margins.
|
||||
// Margins are already set in Gerbview, so we can use 0
|
||||
s_pageSetupData->SetMarginTopLeft( wxPoint( 0, 0 ) );
|
||||
s_pageSetupData->SetMarginBottomRight( wxPoint( 0, 0 ) );
|
||||
}
|
||||
|
||||
s_Parameters.m_PageSetupData = s_pageSetupData;
|
||||
GERBER_FILE_IMAGE_LIST* images = m_Parent->GetGerberLayout()->GetImagesList();
|
||||
|
||||
// Create layer list
|
||||
for( unsigned ii = 0; ii < images->ImagesMaxCount(); ++ii )
|
||||
{
|
||||
msg = _( "Layer" );
|
||||
msg << wxT( " " ) << ii + 1;
|
||||
|
||||
wxStaticBoxSizer* boxSizer = ( ii < 16 ) ? m_leftLayersBoxSizer
|
||||
: m_rightLayersBoxSizer;
|
||||
|
||||
m_BoxSelectLayer[ii] = new wxCheckBox( boxSizer->GetStaticBox(),
|
||||
wxID_ANY, msg );
|
||||
boxSizer->Add( m_BoxSelectLayer[ii], wxGROW | wxLEFT | wxRIGHT | wxTOP );
|
||||
|
||||
if( images->GetGbrImage( ii ) == NULL ) // Nothing loaded on this draw layer
|
||||
m_BoxSelectLayer[ii]->Enable( false );
|
||||
}
|
||||
|
||||
// Read the scale adjust option
|
||||
int scale_idx = 4; // default selected scale = ScaleList[4] = 1.000
|
||||
|
||||
if( m_Config )
|
||||
{
|
||||
m_Config->Read( OPTKEY_PRINT_X_FINESCALE_ADJ, &s_Parameters.m_XScaleAdjust );
|
||||
m_Config->Read( OPTKEY_PRINT_Y_FINESCALE_ADJ, &s_Parameters.m_YScaleAdjust );
|
||||
m_Config->Read( OPTKEY_PRINT_SCALE, &scale_idx );
|
||||
m_Config->Read( OPTKEY_PRINT_PAGE_FRAME, &s_Parameters.m_Print_Sheet_Ref, 1 );
|
||||
m_Config->Read( OPTKEY_PRINT_MONOCHROME_MODE, &s_Parameters.m_Print_Black_and_White, 1 );
|
||||
|
||||
// Test for a reasonnable scale value. Set to 1 if problem
|
||||
if( s_Parameters.m_XScaleAdjust < MIN_SCALE ||
|
||||
s_Parameters.m_YScaleAdjust < MIN_SCALE ||
|
||||
s_Parameters.m_XScaleAdjust > MAX_SCALE ||
|
||||
s_Parameters.m_YScaleAdjust > MAX_SCALE )
|
||||
s_Parameters.m_XScaleAdjust = s_Parameters.m_YScaleAdjust = 1.0;
|
||||
|
||||
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
||||
{
|
||||
wxString layerKey;
|
||||
bool option;
|
||||
|
||||
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
||||
m_Config->Read( layerKey, &option, false );
|
||||
m_BoxSelectLayer[layer]->SetValue( option );
|
||||
}
|
||||
}
|
||||
|
||||
m_ScaleOption->SetSelection( scale_idx );
|
||||
scale_idx = m_ScaleOption->GetSelection();
|
||||
s_Parameters.m_PrintScale = s_ScaleList[scale_idx];
|
||||
m_Print_Mirror->SetValue( s_Parameters.m_PrintMirror );
|
||||
|
||||
|
||||
if( s_Parameters.m_Print_Black_and_White )
|
||||
m_ModeColorOption->SetSelection( 1 );
|
||||
else
|
||||
m_ModeColorOption->SetSelection( 0 );
|
||||
|
||||
s_Parameters.m_PenDefaultSize = 0;
|
||||
s_Parameters.m_Print_Sheet_Ref = false;
|
||||
|
||||
// Create scale adjust option
|
||||
msg.Printf( wxT( "%f" ), s_Parameters.m_XScaleAdjust );
|
||||
m_FineAdjustXscaleOpt->SetValue( msg );
|
||||
msg.Printf( wxT( "%f" ), s_Parameters.m_YScaleAdjust );
|
||||
m_FineAdjustYscaleOpt->SetValue( msg );
|
||||
|
||||
bool enable = (s_Parameters.m_PrintScale == 1.0);
|
||||
|
||||
m_FineAdjustXscaleOpt->Enable(enable);
|
||||
m_FineAdjustYscaleOpt->Enable(enable);
|
||||
}
|
||||
|
||||
|
||||
int DIALOG_PRINT_USING_PRINTER::SetLayerSetFromListSelection()
|
||||
{
|
||||
s_Parameters.m_PrintMaskLayer = LSET();
|
||||
s_Parameters.m_PageCount = 0;
|
||||
s_Parameters.m_Flags = 0;
|
||||
|
||||
for( unsigned layer = 0; layer < DIM( m_BoxSelectLayer ); ++layer )
|
||||
{
|
||||
if( m_BoxSelectLayer[layer]->IsChecked() && m_BoxSelectLayer[layer]->IsEnabled() )
|
||||
{
|
||||
++s_Parameters.m_PageCount;
|
||||
s_Parameters.m_PrintMaskLayer.set( layer );
|
||||
}
|
||||
}
|
||||
|
||||
return s_Parameters.m_PageCount;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
|
||||
{
|
||||
SetPrintParameters();
|
||||
|
||||
if( m_Config )
|
||||
{
|
||||
m_Config->Write( OPTKEY_PRINT_X_FINESCALE_ADJ, s_Parameters.m_XScaleAdjust );
|
||||
m_Config->Write( OPTKEY_PRINT_Y_FINESCALE_ADJ, s_Parameters.m_YScaleAdjust );
|
||||
m_Config->Write( OPTKEY_PRINT_SCALE, m_ScaleOption->GetSelection() );
|
||||
m_Config->Write( OPTKEY_PRINT_PAGE_FRAME, s_Parameters.m_Print_Sheet_Ref);
|
||||
m_Config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White);
|
||||
wxString layerKey;
|
||||
|
||||
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
||||
{
|
||||
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
||||
m_Config->Write( layerKey, m_BoxSelectLayer[layer]->IsChecked() );
|
||||
}
|
||||
}
|
||||
|
||||
EndModal( 0 );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_USING_PRINTER::SetPrintParameters()
|
||||
{
|
||||
s_Parameters.m_PrintMirror = m_Print_Mirror->GetValue();
|
||||
s_Parameters.m_Print_Black_and_White = m_ModeColorOption->GetSelection() != 0;
|
||||
|
||||
// Due to negative objects in gerber objects, always use one page per image,
|
||||
// because these objects create artefact when they are printed on an existing image.
|
||||
s_Parameters.m_OptionPrintPage = false;
|
||||
|
||||
SetLayerSetFromListSelection();
|
||||
|
||||
int idx = m_ScaleOption->GetSelection();
|
||||
s_Parameters.m_PrintScale = s_ScaleList[idx];
|
||||
|
||||
// Test for a reasonnable scale value
|
||||
bool ok = true;
|
||||
double scaleX;
|
||||
m_FineAdjustXscaleOpt->GetValue().ToDouble( &scaleX );
|
||||
|
||||
double scaleY;
|
||||
m_FineAdjustYscaleOpt->GetValue().ToDouble( &scaleY );
|
||||
|
||||
if( scaleX > MAX_SCALE || scaleY > MAX_SCALE )
|
||||
{
|
||||
DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very large value" ) );
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if( scaleX < MIN_SCALE || scaleY < MIN_SCALE )
|
||||
{
|
||||
DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very small value" ) );
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if( ok )
|
||||
{
|
||||
s_Parameters.m_XScaleAdjust = scaleX;
|
||||
s_Parameters.m_YScaleAdjust = scaleY;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update actual fine scale value
|
||||
m_FineAdjustXscaleOpt->SetValue( wxString::Format( "%f", s_Parameters.m_XScaleAdjust ) );
|
||||
m_FineAdjustYscaleOpt->SetValue( wxString::Format( "%f", s_Parameters.m_YScaleAdjust ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event )
|
||||
{
|
||||
double scale = s_ScaleList[m_ScaleOption->GetSelection()];
|
||||
bool enable = ( scale == 1.0 );
|
||||
|
||||
if( m_FineAdjustXscaleOpt )
|
||||
m_FineAdjustXscaleOpt->Enable( enable );
|
||||
|
||||
if( m_FineAdjustYscaleOpt )
|
||||
m_FineAdjustYscaleOpt->Enable( enable );
|
||||
}
|
||||
|
||||
|
||||
// Open a dialog box for printer setup (printer options, page size ...)
|
||||
void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event )
|
||||
{
|
||||
*s_pageSetupData = *s_printData;
|
||||
|
||||
wxPageSetupDialog pageSetupDialog(this, s_pageSetupData);
|
||||
pageSetupDialog.ShowModal();
|
||||
|
||||
(*s_printData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
|
||||
(*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Open and display a previewer frame for printing
|
||||
void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
|
||||
{
|
||||
SetPrintParameters();
|
||||
|
||||
// If no layer selected, we have no plot. prompt user if it happens
|
||||
// because he could think there is a bug in Pcbnew:
|
||||
if( s_Parameters.m_PrintMaskLayer == 0 )
|
||||
{
|
||||
DisplayError( this, _( "No layer selected" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// Pass two printout objects: for preview, and possible printing.
|
||||
wxString title = _( "Print Preview" );
|
||||
wxPrintPreview* preview =
|
||||
new wxPrintPreview( createPrintout( title ), createPrintout( title ), s_printData );
|
||||
|
||||
if( preview == NULL )
|
||||
{
|
||||
DisplayError( this, wxT( "OnPrintPreview() problem" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Uses the parent position and size.
|
||||
// @todo uses last position and size ans store them when exit in m_Config
|
||||
wxPoint WPos = m_Parent->GetPosition();
|
||||
wxSize WSize = m_Parent->GetSize();
|
||||
|
||||
wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, WPos, WSize );
|
||||
frame->SetMinSize( wxSize( 550, 350 ) );
|
||||
|
||||
frame->Initialize();
|
||||
|
||||
frame->Raise(); // Needed on Ubuntu/Unity to display the frame
|
||||
frame->Show( true );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
|
||||
{
|
||||
SetPrintParameters();
|
||||
|
||||
// If no layer selected, we have no plot. prompt user if it happens
|
||||
// because he could think there is a bug in Pcbnew:
|
||||
if( s_Parameters.m_PrintMaskLayer == 0 )
|
||||
{
|
||||
DisplayError( this, _( "No layer selected" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
wxPrintDialogData printDialogData( *s_printData );
|
||||
wxPrinter printer( &printDialogData );
|
||||
wxString title = _( "Print" );
|
||||
auto printout = std::unique_ptr<GERBVIEW_PRINTOUT>( createPrintout( _( "Print" ) ) );
|
||||
|
||||
// Disable 'Print' button to prevent issuing another print
|
||||
// command before the previous one is finished (causes problems on Windows)
|
||||
ENABLER printBtnDisable( *m_buttonPrint, false );
|
||||
|
||||
if( !printer.Print( this, printout.get(), true ) )
|
||||
{
|
||||
if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
|
||||
DisplayError( this, _( "There was a problem printing" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
*s_printData = printer.GetPrintDialogData().GetPrintData();
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Apr 19 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dialog_print_using_printer_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DIALOG_PRINT_USING_PRINTER_BASE::DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
|
||||
|
||||
wxBoxSizer* bMainSizer;
|
||||
bMainSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticBoxSizer* sbLayersSizer;
|
||||
sbLayersSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Layers:") ), wxVERTICAL );
|
||||
|
||||
wxBoxSizer* bleftSizer;
|
||||
bleftSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_leftLayersBoxSizer = new wxStaticBoxSizer( new wxStaticBox( sbLayersSizer->GetStaticBox(), wxID_ANY, _("Graphic layers:") ), wxVERTICAL );
|
||||
|
||||
|
||||
bleftSizer->Add( m_leftLayersBoxSizer, 1, wxALL, 5 );
|
||||
|
||||
m_rightLayersBoxSizer = new wxStaticBoxSizer( new wxStaticBox( sbLayersSizer->GetStaticBox(), wxID_ANY, _("Graphic layers:") ), wxVERTICAL );
|
||||
|
||||
|
||||
bleftSizer->Add( m_rightLayersBoxSizer, 1, wxALL, 5 );
|
||||
|
||||
|
||||
sbLayersSizer->Add( bleftSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bMainSizer->Add( sbLayersSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bmiddleLeftSizer;
|
||||
bmiddleLeftSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxString m_ScaleOptionChoices[] = { _("Fit to page"), _("Scale 0.5"), _("Scale 0.7"), _("Approximate scale 1"), _("Accurate scale 1"), _("Scale 1.4"), _("Scale 2"), _("Scale 3"), _("Scale 4") };
|
||||
int m_ScaleOptionNChoices = sizeof( m_ScaleOptionChoices ) / sizeof( wxString );
|
||||
m_ScaleOption = new wxRadioBox( this, wxID_ANY, _("Approximate Scale:"), wxDefaultPosition, wxDefaultSize, m_ScaleOptionNChoices, m_ScaleOptionChoices, 1, wxRA_SPECIFY_COLS );
|
||||
m_ScaleOption->SetSelection( 0 );
|
||||
bmiddleLeftSizer->Add( m_ScaleOption, 0, wxALL, 5 );
|
||||
|
||||
m_FineAdjustXscaleTitle = new wxStaticText( this, wxID_ANY, _("X scale:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_FineAdjustXscaleTitle->Wrap( -1 );
|
||||
bmiddleLeftSizer->Add( m_FineAdjustXscaleTitle, 0, wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_FineAdjustXscaleOpt = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_FineAdjustXscaleOpt->SetToolTip( _("Set X scale adjust for exact scale plotting") );
|
||||
|
||||
bmiddleLeftSizer->Add( m_FineAdjustXscaleOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
m_FineAdjustYscaleTitle = new wxStaticText( this, wxID_ANY, _("Y scale:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_FineAdjustYscaleTitle->Wrap( -1 );
|
||||
bmiddleLeftSizer->Add( m_FineAdjustYscaleTitle, 0, wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_FineAdjustYscaleOpt = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_FineAdjustYscaleOpt->SetToolTip( _("Set Y scale adjust for exact scale plotting") );
|
||||
|
||||
bmiddleLeftSizer->Add( m_FineAdjustYscaleOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bMainSizer->Add( bmiddleLeftSizer, 0, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bmiddleRightSizer;
|
||||
bmiddleRightSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxStaticBoxSizer* sbOptionsSizer;
|
||||
sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options:") ), wxVERTICAL );
|
||||
|
||||
m_Print_Mirror = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Mirror"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sbOptionsSizer->Add( m_Print_Mirror, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bmiddleRightSizer->Add( sbOptionsSizer, 0, wxEXPAND|wxALL, 5 );
|
||||
|
||||
wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and white") };
|
||||
int m_ModeColorOptionNChoices = sizeof( m_ModeColorOptionChoices ) / sizeof( wxString );
|
||||
m_ModeColorOption = new wxRadioBox( this, wxID_PRINT_MODE, _("Print Mode:"), wxDefaultPosition, wxDefaultSize, m_ModeColorOptionNChoices, m_ModeColorOptionChoices, 1, wxRA_SPECIFY_COLS );
|
||||
m_ModeColorOption->SetSelection( 0 );
|
||||
m_ModeColorOption->SetToolTip( _("Choose if you want to print sheets in color, or force the black and white mode.") );
|
||||
|
||||
bmiddleRightSizer->Add( m_ModeColorOption, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bMainSizer->Add( bmiddleRightSizer, 0, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* b_buttonsSizer;
|
||||
b_buttonsSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_buttonOption = new wxButton( this, wxID_PRINT_OPTIONS, _("Page Options"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
b_buttonsSizer->Add( m_buttonOption, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_buttonPreview = new wxButton( this, wxID_PREVIEW, _("Preview"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
b_buttonsSizer->Add( m_buttonPreview, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_buttonPrint = new wxButton( this, wxID_PRINT_ALL, _("Print"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_buttonPrint->SetDefault();
|
||||
b_buttonsSizer->Add( m_buttonPrint, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
b_buttonsSizer->Add( m_buttonQuit, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bMainSizer->Add( b_buttonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
|
||||
this->SetSizer( bMainSizer );
|
||||
this->Layout();
|
||||
bMainSizer->Fit( this );
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) );
|
||||
m_ScaleOption->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnScaleSelectionClick ), NULL, this );
|
||||
m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this );
|
||||
m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this );
|
||||
m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintButtonClick ), NULL, this );
|
||||
m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnButtonCloseClick ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_PRINT_USING_PRINTER_BASE::~DIALOG_PRINT_USING_PRINTER_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) );
|
||||
m_ScaleOption->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnScaleSelectionClick ), NULL, this );
|
||||
m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this );
|
||||
m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this );
|
||||
m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintButtonClick ), NULL, this );
|
||||
m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnButtonCloseClick ), NULL, this );
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,76 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Apr 19 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __DIALOG_PRINT_USING_PRINTER_BASE_H__
|
||||
#define __DIALOG_PRINT_USING_PRINTER_BASE_H__
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
#include "dialog_shim.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/radiobox.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class DIALOG_PRINT_USING_PRINTER_BASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class DIALOG_PRINT_USING_PRINTER_BASE : public DIALOG_SHIM
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
wxID_PRINT_MODE = 1000,
|
||||
wxID_PRINT_OPTIONS,
|
||||
wxID_PRINT_ALL
|
||||
};
|
||||
|
||||
wxStaticBoxSizer* m_leftLayersBoxSizer;
|
||||
wxStaticBoxSizer* m_rightLayersBoxSizer;
|
||||
wxRadioBox* m_ScaleOption;
|
||||
wxStaticText* m_FineAdjustXscaleTitle;
|
||||
wxTextCtrl* m_FineAdjustXscaleOpt;
|
||||
wxStaticText* m_FineAdjustYscaleTitle;
|
||||
wxTextCtrl* m_FineAdjustYscaleOpt;
|
||||
wxCheckBox* m_Print_Mirror;
|
||||
wxRadioBox* m_ModeColorOption;
|
||||
wxButton* m_buttonOption;
|
||||
wxButton* m_buttonPreview;
|
||||
wxButton* m_buttonPrint;
|
||||
wxButton* m_buttonQuit;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
|
||||
virtual void OnScaleSelectionClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnPageSetup( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnPrintPreview( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnPrintButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnButtonCloseClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_PRINT_USING_PRINTER_BASE();
|
||||
|
||||
};
|
||||
|
||||
#endif //__DIALOG_PRINT_USING_PRINTER_BASE_H__
|
|
@ -46,7 +46,7 @@
|
|||
#include <gerbview_painter.h>
|
||||
|
||||
|
||||
GERBVIEW_PRINTOUT::GERBVIEW_PRINTOUT( GBR_LAYOUT* aLayout, const PRINT_PARAMETERS& aParams,
|
||||
GERBVIEW_PRINTOUT::GERBVIEW_PRINTOUT( GBR_LAYOUT* aLayout, const BOARD_PRINTOUT_SETTINGS& aParams,
|
||||
const KIGFX::VIEW* aView, const wxSize& aSheetSize, const wxString& aTitle ) :
|
||||
BOARD_PRINTOUT( aParams, aView, aSheetSize, aTitle )
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ GERBVIEW_PRINTOUT::GERBVIEW_PRINTOUT( GBR_LAYOUT* aLayout, const PRINT_PARAMETER
|
|||
bool GERBVIEW_PRINTOUT::OnPrintPage( int aPage )
|
||||
{
|
||||
// Store the layerset, as it is going to be modified below and the original settings are needed
|
||||
LSET lset = m_PrintParams.m_PrintMaskLayer;
|
||||
LSET lset = m_settings.m_layerSet;
|
||||
|
||||
// The gerber filename of the page to print will be printed to the worksheet.
|
||||
// Find this filename:
|
||||
|
@ -70,7 +70,7 @@ bool GERBVIEW_PRINTOUT::OnPrintPage( int aPage )
|
|||
// because handling negative objects when using only one page is tricky
|
||||
|
||||
// Enable only one layer to create a printout
|
||||
m_PrintParams.m_PrintMaskLayer = LSET( layerId );
|
||||
m_settings.m_layerSet = LSET( layerId );
|
||||
|
||||
GERBER_FILE_IMAGE_LIST& gbrImgList = GERBER_FILE_IMAGE_LIST::GetImagesList();
|
||||
GERBER_FILE_IMAGE* gbrImage = gbrImgList.GetGbrImage( layerId );
|
||||
|
@ -79,10 +79,10 @@ bool GERBVIEW_PRINTOUT::OnPrintPage( int aPage )
|
|||
if( gbrImage )
|
||||
gbr_filename = gbrImage->m_FileName;
|
||||
|
||||
DrawPage( gbr_filename, aPage, m_PrintParams.m_PageCount );
|
||||
DrawPage( gbr_filename, aPage, m_settings.m_pageCount );
|
||||
|
||||
// Restore the original layer set, so the next page can be printed
|
||||
m_PrintParams.m_PrintMaskLayer = lset;
|
||||
m_settings.m_layerSet = lset;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -93,13 +93,14 @@ void GERBVIEW_PRINTOUT::setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aVi
|
|||
{
|
||||
BOARD_PRINTOUT::setupViewLayers( aView, aLayerSet );
|
||||
|
||||
for( LSEQ layerSeq = m_PrintParams.m_PrintMaskLayer.Seq(); layerSeq; ++layerSeq )
|
||||
for( LSEQ layerSeq = m_settings.m_layerSet.Seq(); layerSeq; ++layerSeq )
|
||||
aView->SetLayerVisible( GERBVIEW_LAYER_ID_START + *layerSeq, true );
|
||||
}
|
||||
|
||||
|
||||
void GERBVIEW_PRINTOUT::setupGal( KIGFX::GAL* aGal )
|
||||
{
|
||||
BOARD_PRINTOUT::setupGal( aGal );
|
||||
aGal->SetWorldUnitLength( 10e-9 /* 10 nm */ / 0.0254 /* 1 inch in meters */ );
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class GBR_LAYOUT;
|
|||
class GERBVIEW_PRINTOUT : public BOARD_PRINTOUT
|
||||
{
|
||||
public:
|
||||
GERBVIEW_PRINTOUT( GBR_LAYOUT* aLayout, const PRINT_PARAMETERS& aParams,
|
||||
GERBVIEW_PRINTOUT( GBR_LAYOUT* aLayout, const BOARD_PRINTOUT_SETTINGS& aParams,
|
||||
const KIGFX::VIEW* aView, const wxSize& aSheetSize, const wxString& aTitle );
|
||||
|
||||
bool OnPrintPage( int aPage ) override;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <wx/print.h>
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
#include <eda_rect.h>
|
||||
#include <printout.h>
|
||||
|
||||
namespace KIGFX {
|
||||
class GAL;
|
||||
|
@ -43,59 +44,18 @@ class VIEW;
|
|||
class PAINTER;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class PRINT_PARAMETERS
|
||||
* handles the parameters used to print a board drawing.
|
||||
*/
|
||||
|
||||
class PRINT_PARAMETERS
|
||||
struct BOARD_PRINTOUT_SETTINGS : public PRINTOUT_SETTINGS
|
||||
{
|
||||
public:
|
||||
PRINT_PARAMETERS();
|
||||
BOARD_PRINTOUT_SETTINGS( const PAGE_INFO& aPageInfo );
|
||||
|
||||
int m_PenDefaultSize; // The default value pen size to plot/print items
|
||||
// that have no defined pen size
|
||||
double m_PrintScale; // general scale when printing
|
||||
double m_XScaleAdjust; // fine scale adjust for X axis
|
||||
double m_YScaleAdjust; // fine scale adjust for Y axis
|
||||
bool m_Print_Sheet_Ref; // Option: print page references
|
||||
LSET m_PrintMaskLayer; // Layers to print
|
||||
bool m_PrintMirror; // Option: Print mirrored
|
||||
bool m_Print_Black_and_White; // Option: Print in B&W or Color
|
||||
int m_OptionPrintPage; // Option: 0 = a layer per page, 1 = all layers at once
|
||||
int m_PageCount; // Number of pages to print
|
||||
bool m_ForceCentered; // Force plot origin to page centre (used in modedit)
|
||||
int m_Flags; // Can be used to pass some other info
|
||||
wxPageSetupDialogData* m_PageSetupData; // A wxPageSetupDialogData for page options (margins)
|
||||
LSET m_layerSet; ///< Layers to print
|
||||
bool m_mirror; ///< Print mirrored
|
||||
|
||||
enum DrillShapeOptT {
|
||||
NO_DRILL_SHAPE = 0,
|
||||
SMALL_DRILL_SHAPE = 1,
|
||||
FULL_DRILL_SHAPE = 2
|
||||
void Load( wxConfigBase* aConfig ) override;
|
||||
void Save( wxConfigBase* aConfig ) override;
|
||||
};
|
||||
|
||||
DrillShapeOptT m_DrillShapeOpt; // Options to print pads and via holes
|
||||
|
||||
/**
|
||||
* Returns true if the drawing border and title block should be printed.
|
||||
*
|
||||
* For scale factors greater than one, the border is not printed because it will end up
|
||||
* scaling off of the page.
|
||||
*/
|
||||
bool PrintBorderAndTitleBlock() const { return m_PrintScale <= 1.0 && m_Print_Sheet_Ref; }
|
||||
|
||||
/**
|
||||
* Returns true if the print should be centered by the board outline instead of the
|
||||
* paper size.
|
||||
*/
|
||||
bool CenterOnBoardOutline() const
|
||||
{
|
||||
return !PrintBorderAndTitleBlock()
|
||||
&& ( m_ForceCentered || ( m_PrintScale > 1.0 ) || ( m_PrintScale == 0 ) );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class BOARD_PRINTOUT
|
||||
* is a class derived from wxPrintout to handle the necessary information to control a printer
|
||||
|
@ -104,7 +64,7 @@ public:
|
|||
class BOARD_PRINTOUT : public wxPrintout
|
||||
{
|
||||
public:
|
||||
BOARD_PRINTOUT( const PRINT_PARAMETERS& aParams, const KIGFX::VIEW* aView,
|
||||
BOARD_PRINTOUT( const BOARD_PRINTOUT_SETTINGS& aParams, const KIGFX::VIEW* aView,
|
||||
const wxSize& aSheetSize, const wxString& aTitle );
|
||||
|
||||
virtual ~BOARD_PRINTOUT() {}
|
||||
|
@ -113,7 +73,7 @@ public:
|
|||
|
||||
bool HasPage( int aPage ) override
|
||||
{
|
||||
return aPage <= m_PrintParams.m_PageCount;
|
||||
return aPage <= m_settings.m_pageCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,7 +95,7 @@ protected:
|
|||
virtual void setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPainter );
|
||||
|
||||
///> Configures GAL object for a printout
|
||||
virtual void setupGal( KIGFX::GAL* aGal ) {}
|
||||
virtual void setupGal( KIGFX::GAL* aGal );
|
||||
|
||||
///> Returns bounding box of the printed objects (excluding worksheet frame)
|
||||
virtual EDA_RECT getBoundingBox() = 0;
|
||||
|
@ -147,7 +107,7 @@ protected:
|
|||
const KIGFX::VIEW* m_view;
|
||||
|
||||
///> Printout parameters
|
||||
PRINT_PARAMETERS m_PrintParams;
|
||||
BOARD_PRINTOUT_SETTINGS m_settings;
|
||||
|
||||
///> Sheet size expressed in internal units
|
||||
wxSize m_sheetSize;
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (C) 2018 CERN
|
||||
* Author: Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PRINTOUT_H
|
||||
#define PRINTOUT_H
|
||||
|
||||
#include <page_info.h>
|
||||
|
||||
class wxConfigBase;
|
||||
|
||||
/**
|
||||
* Class PRINT_PARAMETERS
|
||||
* handles the parameters used to print a board drawing.
|
||||
*/
|
||||
struct PRINTOUT_SETTINGS
|
||||
{
|
||||
PRINTOUT_SETTINGS( const PAGE_INFO& aPageInfo )
|
||||
: m_pageInfo( aPageInfo )
|
||||
{
|
||||
// TODO Millimeter2iu is depends on PCBNEW/GERBVIEW #ifdefs, so it cannot be compiled to libcommon
|
||||
//m_lineWidth = Millimeter2iu( 0.2 ); // A reasonable default value to draw items
|
||||
// which do not have a specified line width
|
||||
m_lineWidth = 0.0;
|
||||
m_scale = 1.0;
|
||||
m_titleBlock = false;
|
||||
m_blackWhite = true;
|
||||
m_pageCount = 0;
|
||||
}
|
||||
|
||||
virtual void Save( wxConfigBase* aConfig );
|
||||
virtual void Load( wxConfigBase* aConfig );
|
||||
|
||||
int m_lineWidth; ///< The default value pen size to plot/print items
|
||||
///< that have no defined pen size
|
||||
double m_scale; ///< Printing scale
|
||||
bool m_titleBlock; ///< Print frame and title block
|
||||
bool m_blackWhite; ///< Print in B&W or Color
|
||||
int m_pageCount; ///< Number of pages to print
|
||||
const PAGE_INFO& m_pageInfo;
|
||||
|
||||
/**
|
||||
* Returns true if the drawing border and title block should be printed.
|
||||
*
|
||||
* For scale factors greater than one, the border is not printed because it will end up
|
||||
* scaling off of the page.
|
||||
*/
|
||||
bool PrintBorderAndTitleBlock() const
|
||||
{
|
||||
return m_scale <= 1.0 && m_titleBlock;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* PRINTOUT_H */
|
|
@ -66,6 +66,24 @@ public:
|
|||
*/
|
||||
virtual void SetUnits( EDA_UNITS_T aUnits, bool aUseMils = false );
|
||||
|
||||
/**
|
||||
* Set the minimal accepted value (in Internal Units).
|
||||
*/
|
||||
void SetMin( int aMin )
|
||||
{
|
||||
wxASSERT( aMin < m_max );
|
||||
m_min = aMin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximal accepted value (in Internal Units).
|
||||
*/
|
||||
void SetMax( int aMax )
|
||||
{
|
||||
wxASSERT( aMax > m_min );
|
||||
m_max = aMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetValue
|
||||
* Sets new value (in Internal Units) for the text field, taking care of units conversion.
|
||||
|
|
|
@ -130,7 +130,6 @@ set( PCBNEW_DIALOGS
|
|||
dialogs/dialog_position_relative.cpp
|
||||
dialogs/dialog_position_relative_base.cpp
|
||||
dialogs/dialog_print_pcbnew.cpp
|
||||
dialogs/dialog_print_pcbnew_base.cpp
|
||||
dialogs/dialog_select_net_from_list.cpp
|
||||
dialogs/dialog_select_net_from_list_base.cpp
|
||||
dialogs/dialog_set_grid.cpp
|
||||
|
|
|
@ -57,7 +57,7 @@ private:
|
|||
wxString m_outputDirectory;
|
||||
bool m_printMirror;
|
||||
bool m_oneFileOnly;
|
||||
UNIT_BINDER m_defaultPenWidth;
|
||||
UNIT_BINDER m_lineWidth;
|
||||
|
||||
void initDialog();
|
||||
|
||||
|
@ -91,7 +91,7 @@ private:
|
|||
*/
|
||||
DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG( PCB_BASE_FRAME* aParent, BOARD* aBoard ) :
|
||||
DIALOG_EXPORT_SVG_BASE( aParent ),
|
||||
m_defaultPenWidth( aParent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true,
|
||||
m_lineWidth( aParent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true,
|
||||
WIDTH_MIN_VALUE, WIDTH_MAX_VALUE)
|
||||
{
|
||||
m_board = aBoard;
|
||||
|
@ -115,7 +115,7 @@ DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG( PCB_BASE_FRAME* aParent, BOARD* aBoard ) :
|
|||
|
||||
DIALOG_EXPORT_SVG::~DIALOG_EXPORT_SVG()
|
||||
{
|
||||
g_DrawDefaultLineThickness = m_defaultPenWidth.GetValue();
|
||||
g_DrawDefaultLineThickness = m_lineWidth.GetValue();
|
||||
m_printBW = m_ModeColorOption->GetSelection();
|
||||
m_oneFileOnly = m_rbFileOpt->GetSelection() == 1;
|
||||
m_outputDirectory = m_outputDirectoryName->GetValue();
|
||||
|
@ -165,7 +165,7 @@ void DIALOG_EXPORT_SVG::initDialog()
|
|||
m_printMirrorOpt->SetValue( m_printMirror );
|
||||
m_rbFileOpt->SetSelection( m_oneFileOnly ? 1 : 0 );
|
||||
|
||||
m_defaultPenWidth.SetValue( g_DrawDefaultLineThickness );
|
||||
m_lineWidth.SetValue( g_DrawDefaultLineThickness );
|
||||
|
||||
for( LSEQ seq = m_board->GetEnabledLayers().UIOrder(); seq; ++seq )
|
||||
{
|
||||
|
@ -267,7 +267,7 @@ void DIALOG_EXPORT_SVG::ExportSVGFile( bool aOnlyOneFile )
|
|||
|
||||
m_printMirror = m_printMirrorOpt->GetValue();
|
||||
m_printBW = m_ModeColorOption->GetSelection();
|
||||
g_DrawDefaultLineThickness = m_defaultPenWidth.GetValue();
|
||||
g_DrawDefaultLineThickness = m_lineWidth.GetValue();
|
||||
|
||||
LSET all_selected = getCheckBoxSelectedLayers();
|
||||
|
||||
|
|
|
@ -31,217 +31,102 @@
|
|||
#include <pcb_edit_frame.h>
|
||||
#include <footprint_edit_frame.h>
|
||||
#include <base_units.h>
|
||||
#include <pcbnew_printout.h>
|
||||
#include <pcbnew.h>
|
||||
#include <pcbplot.h>
|
||||
#include <class_board.h>
|
||||
#include <enabler.h>
|
||||
#include <wx/valnum.h>
|
||||
#include <widgets/unit_binder.h>
|
||||
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
|
||||
#include <dialog_print_pcbnew_base.h>
|
||||
|
||||
#define PEN_WIDTH_MAX_VALUE ( KiROUND( 5 * IU_PER_MM ) )
|
||||
#define PEN_WIDTH_MIN_VALUE ( KiROUND( 0.005 * IU_PER_MM ) )
|
||||
|
||||
#include <dialog_print_generic.h>
|
||||
#include <pcbnew_printout.h>
|
||||
|
||||
extern int g_DrawDefaultLineThickness;
|
||||
|
||||
// Define min and max reasonable values for print scale
|
||||
#define MIN_SCALE 0.01
|
||||
#define MAX_SCALE 100.0
|
||||
|
||||
// static print data and page setup data, to remember settings during the session
|
||||
static wxPrintData* s_PrintData;
|
||||
static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL;
|
||||
|
||||
static PRINT_PARAMETERS s_Parameters;
|
||||
|
||||
|
||||
/**
|
||||
* Dialog to print schematic. Class derived from DIALOG_PRINT_PCBNEW_BASE
|
||||
* created by wxFormBuilder
|
||||
*/
|
||||
class DIALOG_PRINT_PCBNEW : public DIALOG_PRINT_PCBNEW_BASE
|
||||
class DIALOG_PRINT_PCBNEW : public DIALOG_PRINT_GENERIC
|
||||
{
|
||||
public:
|
||||
DIALOG_PRINT_PCBNEW( PCB_BASE_EDIT_FRAME* parent );
|
||||
~DIALOG_PRINT_PCBNEW() override;
|
||||
|
||||
/**
|
||||
* Set 'print border and title block' to a requested value and hides the
|
||||
* corresponding checkbox.
|
||||
*/
|
||||
void ForcePrintBorder( bool aValue )
|
||||
{
|
||||
m_Print_Sheet_Ref->SetValue( aValue );
|
||||
m_Print_Sheet_Ref->Hide();
|
||||
}
|
||||
DIALOG_PRINT_PCBNEW( PCB_BASE_EDIT_FRAME* aParent, PCBNEW_PRINTOUT_SETTINGS* aSettings );
|
||||
~DIALOG_PRINT_PCBNEW() {}
|
||||
|
||||
private:
|
||||
PCB_BASE_EDIT_FRAME* m_parent;
|
||||
wxConfigBase* m_config;
|
||||
// the list of existing board layers in wxCheckListBox, with the board layers id:
|
||||
std::pair<wxCheckListBox*, int> m_layers[PCB_LAYER_ID_COUNT];
|
||||
static bool m_ExcludeEdgeLayer;
|
||||
wxFloatingPointValidator<double> m_scaleValidator;
|
||||
|
||||
UNIT_BINDER m_defaultPenWidth;
|
||||
PCBNEW_PRINTOUT_SETTINGS* settings() const
|
||||
{
|
||||
wxASSERT( dynamic_cast<PCBNEW_PRINTOUT_SETTINGS*>( m_settings ) );
|
||||
return static_cast<PCBNEW_PRINTOUT_SETTINGS*>( m_settings );
|
||||
}
|
||||
|
||||
bool TransferDataToWindow() override;
|
||||
|
||||
void OnSelectAllClick( wxCommandEvent& event ) override;
|
||||
void OnDeselectAllClick( wxCommandEvent& event ) override;
|
||||
void OnSetCustomScale( wxCommandEvent& event ) override;
|
||||
void OnPageSetup( wxCommandEvent& event ) override;
|
||||
void OnPrintPreview( wxCommandEvent& event ) override;
|
||||
void OnPrintButtonClick( wxCommandEvent& event ) override;
|
||||
void createExtraOptions();
|
||||
void createLeftPanel();
|
||||
|
||||
void onSelectAllClick( wxCommandEvent& event );
|
||||
void onDeselectAllClick( wxCommandEvent& event );
|
||||
|
||||
///> (Un)checks all items in a checklist box
|
||||
void setListBoxValue( wxCheckListBox* aList, bool aValue )
|
||||
{
|
||||
for( int i = 0; i < aList->GetCount(); ++i )
|
||||
aList->Check( i, aValue );
|
||||
}
|
||||
void setListBoxValue( wxCheckListBox* aList, bool aValue );
|
||||
|
||||
void SetPrintParameters();
|
||||
int SetLayerSetFromListSelection();
|
||||
///> Check whether a layer is enabled in a listbox
|
||||
bool isLayerEnabled( unsigned int aLayer ) const;
|
||||
|
||||
PCBNEW_PRINTOUT* createPrintout( const wxString& aTitle )
|
||||
///> Enable/disable layer in a listbox
|
||||
void enableLayer( unsigned int aLayer, bool aValue );
|
||||
|
||||
///> Update layerset basing on the selected layers
|
||||
int setLayerSetFromList();
|
||||
|
||||
void saveSettings() override;
|
||||
|
||||
wxPrintout* createPrintout( const wxString& aTitle ) override
|
||||
{
|
||||
return new PCBNEW_PRINTOUT( m_parent->GetBoard(), s_Parameters,
|
||||
return new PCBNEW_PRINTOUT( m_parent->GetBoard(), *settings(),
|
||||
m_parent->GetGalCanvas()->GetView(), m_parent->GetPageSettings().GetSizeIU(), aTitle );
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a corresponing scale radio button and update custom scale value if needed.
|
||||
* @param aValue is the scale value to be selected (0 stands for fit-to-page).
|
||||
*/
|
||||
void setScaleValue( double aValue ) const
|
||||
{
|
||||
wxASSERT( aValue >= 0.0 );
|
||||
PCB_BASE_EDIT_FRAME* m_parent;
|
||||
|
||||
if( aValue == 0.0 )
|
||||
{
|
||||
m_scaleFit->SetValue( true );
|
||||
}
|
||||
else if( aValue == 1.0 )
|
||||
{
|
||||
m_scale1->SetValue( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( aValue > MAX_SCALE )
|
||||
{
|
||||
DisplayInfoMessage( NULL,
|
||||
_( "Warning: Scale option set to a very large value" ) );
|
||||
}
|
||||
// List of existing board layers in wxCheckListBox, with the board layers id:
|
||||
std::pair<wxCheckListBox*, int> m_layers[PCB_LAYER_ID_COUNT];
|
||||
|
||||
if( aValue < MIN_SCALE )
|
||||
{
|
||||
DisplayInfoMessage( NULL,
|
||||
_( "Warning: Scale option set to a very small value" ) );
|
||||
}
|
||||
|
||||
m_scaleCustom->SetValue( true );
|
||||
m_scaleCustomText->SetValue( wxString::Format( wxT( "%f" ), aValue ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return scale value selected in the dialog.
|
||||
*/
|
||||
double getScaleValue() const
|
||||
{
|
||||
if( m_scale1->GetValue() )
|
||||
return 1.0;
|
||||
|
||||
if( m_scaleFit->GetValue() )
|
||||
return 0.0;
|
||||
|
||||
if( m_scaleCustom->GetValue() )
|
||||
{
|
||||
double scale;
|
||||
|
||||
wxCHECK( m_scaleCustomText->GetValue().ToDouble( &scale ), 1.0 );
|
||||
return scale;
|
||||
}
|
||||
|
||||
wxCHECK( false, 1.0 );
|
||||
}
|
||||
// Extra widgets
|
||||
wxCheckListBox* m_listTechLayers;
|
||||
wxCheckListBox* m_listCopperLayers;
|
||||
wxButton* m_buttonSelectAll;
|
||||
wxButton* m_buttonDeselectAll;
|
||||
wxCheckBox* m_checkboxNoEdge;
|
||||
wxCheckBox* m_checkboxMirror;
|
||||
wxChoice* m_drillMarksChoice;
|
||||
wxRadioBox* m_boxPagination;
|
||||
};
|
||||
|
||||
|
||||
bool DIALOG_PRINT_PCBNEW::m_ExcludeEdgeLayer;
|
||||
|
||||
|
||||
DIALOG_PRINT_PCBNEW::DIALOG_PRINT_PCBNEW( PCB_BASE_EDIT_FRAME* parent ) :
|
||||
DIALOG_PRINT_PCBNEW_BASE( parent ),
|
||||
m_parent( parent ),
|
||||
m_defaultPenWidth( parent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true,
|
||||
PEN_WIDTH_MIN_VALUE, PEN_WIDTH_MAX_VALUE )
|
||||
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();
|
||||
memset( m_layers, 0, sizeof( m_layers ) );
|
||||
|
||||
m_scaleValidator.SetRange( 1e-3, 1e3 );
|
||||
m_scaleCustomText->SetValidator( m_scaleValidator );
|
||||
// Line width settings range
|
||||
m_lineWidth.SetMax( KiROUND( 5 * IU_PER_MM ) );
|
||||
m_lineWidth.SetMin( KiROUND( 0.005 * IU_PER_MM ) );
|
||||
|
||||
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
|
||||
// that requires us to correct the button labels here.
|
||||
m_sdbSizer1OK->SetLabel( _( "Print" ) );
|
||||
m_sdbSizer1Apply->SetLabel( _( "Print Preview" ) );
|
||||
m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
|
||||
m_sdbSizer1->Layout();
|
||||
|
||||
m_sdbSizer1OK->SetDefault();
|
||||
|
||||
#if defined(__WXMAC__) or defined(__WXGTK__)
|
||||
// Preview does not work well on GTK or Mac,
|
||||
// but these platforms provide native print preview
|
||||
m_sdbSizer1Apply->Hide();
|
||||
#endif
|
||||
|
||||
FinishDialogSettings();
|
||||
}
|
||||
|
||||
|
||||
DIALOG_PRINT_PCBNEW::~DIALOG_PRINT_PCBNEW()
|
||||
{
|
||||
SetPrintParameters();
|
||||
|
||||
if( m_config )
|
||||
{
|
||||
m_config->Write( OPTKEY_PRINT_SCALE, getScaleValue() );
|
||||
m_config->Write( OPTKEY_PRINT_PAGE_FRAME, s_Parameters.m_Print_Sheet_Ref);
|
||||
m_config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White);
|
||||
m_config->Write( OPTKEY_PRINT_PAGE_PER_LAYER, s_Parameters.m_OptionPrintPage );
|
||||
m_config->Write( OPTKEY_PRINT_PADS_DRILL, (long) s_Parameters.m_DrillShapeOpt );
|
||||
|
||||
for( unsigned layer = 0; layer < DIM(m_layers); ++layer )
|
||||
{
|
||||
if( m_layers[layer].first )
|
||||
{
|
||||
wxString key = wxString::Format( OPTKEY_LAYERBASE, layer );
|
||||
bool value = m_layers[layer].first->IsChecked( m_layers[layer].second );
|
||||
m_config->Write( key, value );
|
||||
}
|
||||
}
|
||||
}
|
||||
createExtraOptions();
|
||||
createLeftPanel();
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_PRINT_PCBNEW::TransferDataToWindow()
|
||||
{
|
||||
wxString msg;
|
||||
if( !DIALOG_PRINT_GENERIC::TransferDataToWindow() )
|
||||
return false;
|
||||
|
||||
if( m_config )
|
||||
settings()->Load( m_config );
|
||||
|
||||
BOARD* board = m_parent->GetBoard();
|
||||
|
||||
s_Parameters.m_PageSetupData = s_pageSetupData;
|
||||
|
||||
// Create layer list.
|
||||
// Create layer list
|
||||
for( LSEQ seq = board->GetEnabledLayers().UIOrder(); seq; ++seq )
|
||||
{
|
||||
PCB_LAYER_ID layer = *seq;
|
||||
|
@ -249,275 +134,232 @@ bool DIALOG_PRINT_PCBNEW::TransferDataToWindow()
|
|||
|
||||
if( IsCopperLayer( layer ) )
|
||||
{
|
||||
checkIndex = m_CopperLayersList->Append( board->GetLayerName( layer ) );
|
||||
m_layers[layer] = std::make_pair( m_CopperLayersList, checkIndex );
|
||||
checkIndex = m_listCopperLayers->Append( board->GetLayerName( layer ) );
|
||||
m_layers[layer] = std::make_pair( m_listCopperLayers, checkIndex );
|
||||
}
|
||||
else
|
||||
{
|
||||
checkIndex = m_TechnicalLayersList->Append( board->GetLayerName( layer ) );
|
||||
m_layers[layer] = std::make_pair( m_TechnicalLayersList, checkIndex );
|
||||
checkIndex = m_listTechLayers->Append( board->GetLayerName( layer ) );
|
||||
m_layers[layer] = std::make_pair( m_listTechLayers, checkIndex );
|
||||
}
|
||||
|
||||
if( m_config )
|
||||
{
|
||||
wxString layerKey;
|
||||
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
||||
bool option;
|
||||
|
||||
if( m_config->Read( layerKey, &option ) )
|
||||
m_layers[layer].first->Check( checkIndex, option );
|
||||
}
|
||||
m_layers[layer].first->Check( checkIndex, settings()->m_layerSet.test( layer ) );
|
||||
}
|
||||
|
||||
// Option for excluding contents of "Edges Pcb" layer
|
||||
m_Exclude_Edges_Pcb->Show( true );
|
||||
|
||||
// Read the scale adjust option
|
||||
double scale = 1.0;
|
||||
|
||||
if( m_config )
|
||||
{
|
||||
m_config->Read( OPTKEY_PRINT_SCALE, &scale );
|
||||
m_config->Read( OPTKEY_PRINT_PAGE_FRAME, &s_Parameters.m_Print_Sheet_Ref, 1);
|
||||
m_config->Read( OPTKEY_PRINT_MONOCHROME_MODE, &s_Parameters.m_Print_Black_and_White, 1);
|
||||
m_config->Read( OPTKEY_PRINT_PAGE_PER_LAYER, &s_Parameters.m_OptionPrintPage, 0);
|
||||
int tmp;
|
||||
m_config->Read( OPTKEY_PRINT_PADS_DRILL, &tmp, PRINT_PARAMETERS::SMALL_DRILL_SHAPE );
|
||||
s_Parameters.m_DrillShapeOpt = (PRINT_PARAMETERS::DrillShapeOptT) tmp;
|
||||
}
|
||||
|
||||
setScaleValue( scale );
|
||||
s_Parameters.m_PrintScale = getScaleValue();
|
||||
m_Print_Mirror->SetValue(s_Parameters.m_PrintMirror);
|
||||
m_Exclude_Edges_Pcb->SetValue(m_ExcludeEdgeLayer);
|
||||
m_Print_Sheet_Ref->SetValue( s_Parameters.m_Print_Sheet_Ref );
|
||||
m_checkboxMirror->SetValue( settings()->m_mirror );
|
||||
m_checkboxNoEdge->SetValue( settings()->m_noEdgeLayer );
|
||||
m_titleBlock->SetValue( settings()->m_titleBlock );
|
||||
|
||||
// Options to plot pads and vias holes
|
||||
m_drillMarksChoice->SetSelection( s_Parameters.m_DrillShapeOpt );
|
||||
m_drillMarksChoice->SetSelection( settings()->m_drillMarks );
|
||||
|
||||
m_outputMode->SetSelection( s_Parameters.m_Print_Black_and_White ? 1 : 0 );
|
||||
// Print all layers one one page or separately
|
||||
m_boxPagination->SetSelection( settings()->m_pagination );
|
||||
|
||||
m_PagesOption->SetSelection( s_Parameters.m_OptionPrintPage );
|
||||
s_Parameters.m_PenDefaultSize = g_DrawDefaultLineThickness;
|
||||
m_defaultPenWidth.SetValue( s_Parameters.m_PenDefaultSize );
|
||||
// Default line width
|
||||
settings()->m_lineWidth = g_DrawDefaultLineThickness;
|
||||
m_lineWidth.SetValue( settings()->m_lineWidth );
|
||||
|
||||
// Update the layout when layers are added
|
||||
// Update the dialog layout when layers are added
|
||||
GetSizer()->Fit( this );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int DIALOG_PRINT_PCBNEW::SetLayerSetFromListSelection()
|
||||
void DIALOG_PRINT_PCBNEW::createExtraOptions()
|
||||
{
|
||||
int page_count = 0;
|
||||
wxGridBagSizer* optionsSizer = getOptionsSizer();
|
||||
wxStaticBox* box = getOptionsBox();
|
||||
int rows = optionsSizer->GetEffectiveRowsCount();
|
||||
int cols = optionsSizer->GetEffectiveColsCount();
|
||||
|
||||
s_Parameters.m_PrintMaskLayer = LSET();
|
||||
// Drill marks option
|
||||
auto drillMarksLabel = new wxStaticText( box, wxID_ANY, _( "Drill marks:" ) );
|
||||
std::vector<wxString> drillMarkChoices =
|
||||
{ _( "No drill mark" ), _( "Small mark" ), _( "Real drill" ) };
|
||||
m_drillMarksChoice = new wxChoice( box, wxID_ANY, wxDefaultPosition,
|
||||
wxDefaultSize, drillMarkChoices.size(), drillMarkChoices.data(), 0 );
|
||||
m_drillMarksChoice->SetSelection( 0 );
|
||||
|
||||
for( unsigned layer = 0; layer < DIM(m_layers); ++layer )
|
||||
// Print mirrored
|
||||
m_checkboxMirror = new wxCheckBox( box, wxID_ANY, _( "Print mirrored" ) );
|
||||
|
||||
// Pagination
|
||||
std::vector<wxString> pagesOption = { _( "One page per layer" ), _( "All layers on single page" ) };
|
||||
m_boxPagination = new wxRadioBox( box, wxID_ANY, _( "Pagination" ), wxDefaultPosition,
|
||||
wxDefaultSize, pagesOption.size(), pagesOption.data(), 1, wxRA_SPECIFY_COLS );
|
||||
m_boxPagination->SetSelection( 0 );
|
||||
|
||||
// Sizer layout
|
||||
optionsSizer->Add( drillMarksLabel, wxGBPosition( rows, 0 ), wxGBSpan( 1, 1 ),
|
||||
wxBOTTOM | wxRIGHT | wxLEFT | wxALIGN_CENTER_VERTICAL, 5 );
|
||||
optionsSizer->Add( m_drillMarksChoice, wxGBPosition( rows, 1 ), wxGBSpan( 1, cols - 1 ),
|
||||
wxBOTTOM | wxRIGHT | wxLEFT, 5 );
|
||||
optionsSizer->Add( m_checkboxMirror, wxGBPosition( rows + 1, 0 ), wxGBSpan( 1, cols ),
|
||||
wxBOTTOM | wxRIGHT | wxLEFT, 5 );
|
||||
optionsSizer->Add( m_boxPagination, wxGBPosition( rows + 2, 0 ), wxGBSpan( 1, cols ), wxALL | wxEXPAND, 5 );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::createLeftPanel()
|
||||
{
|
||||
if( m_layers[layer].first && m_layers[layer].first->IsChecked( m_layers[layer].second ) )
|
||||
wxStaticBoxSizer* sbLayersSizer = new wxStaticBoxSizer( new wxStaticBox( this,
|
||||
wxID_ANY, _( "Included Layers" ) ), wxVERTICAL );
|
||||
|
||||
// Copper layer list
|
||||
auto copperLabel = new wxStaticText( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Copper layers:" ) );
|
||||
m_listCopperLayers = new wxCheckListBox( sbLayersSizer->GetStaticBox(), wxID_ANY );
|
||||
|
||||
wxBoxSizer* sizerLeft = new wxBoxSizer( wxVERTICAL );
|
||||
sizerLeft->Add( copperLabel, 0, wxRIGHT | wxLEFT, 5 );
|
||||
sizerLeft->Add( m_listCopperLayers, 1, wxEXPAND | wxBOTTOM | wxRIGHT | wxLEFT, 5 );
|
||||
|
||||
|
||||
// Technical layer list
|
||||
auto technicalLabel = new wxStaticText( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Technical layers:" ) );
|
||||
m_listTechLayers = new wxCheckListBox( sbLayersSizer->GetStaticBox(), wxID_ANY );
|
||||
|
||||
wxBoxSizer* sizerRight = new wxBoxSizer( wxVERTICAL );
|
||||
sizerRight->Add( technicalLabel, 0, wxRIGHT | wxLEFT, 5 );
|
||||
sizerRight->Add( m_listTechLayers, 1, wxEXPAND | wxBOTTOM | wxRIGHT | wxLEFT, 5 );
|
||||
|
||||
|
||||
// Layer list layout
|
||||
wxBoxSizer* bLayerListsSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
bLayerListsSizer->Add( sizerLeft, 1, wxEXPAND, 5 );
|
||||
bLayerListsSizer->Add( sizerRight, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
// Select/Unselect all buttons
|
||||
m_buttonSelectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Select all" ) );
|
||||
m_buttonDeselectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Deselect all" ) );
|
||||
|
||||
m_buttonSelectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onSelectAllClick ), NULL, this );
|
||||
m_buttonDeselectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onDeselectAllClick ), NULL, this );
|
||||
|
||||
wxBoxSizer* buttonSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
buttonSizer->Add( m_buttonSelectAll, 1, wxALL, 5 );
|
||||
buttonSizer->Add( m_buttonDeselectAll, 1, wxALL, 5 );
|
||||
|
||||
|
||||
// Exclude Edge.Pcb layer checkbox
|
||||
m_checkboxNoEdge = new wxCheckBox( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Exclude PCB edge layer" ) );
|
||||
m_checkboxNoEdge->SetToolTip( _("Exclude contents of Edges_Pcb layer from all other layers") );
|
||||
|
||||
// Static box sizer layout
|
||||
sbLayersSizer->Add( bLayerListsSizer, 1, wxALL | wxEXPAND, 5 );
|
||||
sbLayersSizer->Add( buttonSizer, 0, wxALL | wxEXPAND, 5 );
|
||||
sbLayersSizer->Add( m_checkboxNoEdge, 0, wxALL | wxEXPAND, 5 );
|
||||
|
||||
getMainSizer()->Insert( 0, sbLayersSizer, 1, wxEXPAND );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::onSelectAllClick( wxCommandEvent& event )
|
||||
{
|
||||
page_count++;
|
||||
s_Parameters.m_PrintMaskLayer.set( layer );
|
||||
setListBoxValue( m_listCopperLayers, true );
|
||||
setListBoxValue( m_listTechLayers, true );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::onDeselectAllClick( wxCommandEvent& event )
|
||||
{
|
||||
setListBoxValue( m_listCopperLayers, false );
|
||||
setListBoxValue( m_listTechLayers, false );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::setListBoxValue( wxCheckListBox* aList, bool aValue )
|
||||
{
|
||||
for( unsigned int i = 0; i < aList->GetCount(); ++i )
|
||||
aList->Check( i, aValue );
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_PRINT_PCBNEW::isLayerEnabled( unsigned int aLayer ) const
|
||||
{
|
||||
wxCHECK( aLayer < DIM( m_layers ), false );
|
||||
const auto& layerInfo = m_layers[aLayer];
|
||||
|
||||
if( layerInfo.first )
|
||||
return layerInfo.first->IsChecked( layerInfo.second );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::enableLayer( unsigned int aLayer, bool aValue )
|
||||
{
|
||||
wxCHECK( aLayer < DIM( m_layers ), /* void */ );
|
||||
const auto& layerInfo = m_layers[aLayer];
|
||||
layerInfo.first->Check( layerInfo.second, aValue );
|
||||
}
|
||||
|
||||
|
||||
int DIALOG_PRINT_PCBNEW::setLayerSetFromList()
|
||||
{
|
||||
settings()->m_layerSet = LSET();
|
||||
int& pageCount = settings()->m_pageCount;
|
||||
pageCount = 0;
|
||||
|
||||
for( unsigned int layer = 0; layer < DIM( m_layers ); ++layer )
|
||||
{
|
||||
if( isLayerEnabled( layer ) )
|
||||
{
|
||||
++pageCount;
|
||||
settings()->m_layerSet.set( layer );
|
||||
}
|
||||
}
|
||||
|
||||
// In Pcbnew force the EDGE layer to be printed or not with the other layers
|
||||
m_ExcludeEdgeLayer = m_Exclude_Edges_Pcb->IsChecked();
|
||||
s_Parameters.m_Flags = m_ExcludeEdgeLayer ? 0 : 1;
|
||||
settings()->m_noEdgeLayer = m_checkboxNoEdge->IsChecked();
|
||||
|
||||
if( m_PagesOption->GetSelection() != 0 )
|
||||
page_count = 1;
|
||||
// All layers on one page (only if there is at least one layer selected)
|
||||
if( m_boxPagination->GetSelection() != 0 && pageCount > 0 )
|
||||
pageCount = 1;
|
||||
|
||||
s_Parameters.m_PageCount = page_count;
|
||||
|
||||
return page_count;
|
||||
return pageCount;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::SetPrintParameters()
|
||||
void DIALOG_PRINT_PCBNEW::saveSettings()
|
||||
{
|
||||
PCB_PLOT_PARAMS plot_opts = m_parent->GetPlotSettings();
|
||||
setLayerSetFromList();
|
||||
|
||||
s_Parameters.m_PrintMirror = m_Print_Mirror->GetValue();
|
||||
s_Parameters.m_Print_Sheet_Ref = m_Print_Sheet_Ref->GetValue();
|
||||
s_Parameters.m_Print_Black_and_White = m_outputMode->GetSelection() != 0;
|
||||
settings()->m_drillMarks =
|
||||
(PCBNEW_PRINTOUT_SETTINGS::DRILL_MARK_SHAPE_T) m_drillMarksChoice->GetSelection();
|
||||
|
||||
s_Parameters.m_DrillShapeOpt =
|
||||
(PRINT_PARAMETERS::DrillShapeOptT) m_drillMarksChoice->GetSelection();
|
||||
settings()->m_pagination = m_boxPagination->GetSelection() == 0
|
||||
? PCBNEW_PRINTOUT_SETTINGS::LAYER_PER_PAGE : PCBNEW_PRINTOUT_SETTINGS::ALL_LAYERS;
|
||||
|
||||
s_Parameters.m_OptionPrintPage = m_PagesOption->GetSelection() != 0;
|
||||
settings()->m_mirror = m_checkboxMirror->GetValue();
|
||||
|
||||
SetLayerSetFromListSelection();
|
||||
|
||||
s_Parameters.m_PrintScale = getScaleValue();
|
||||
plot_opts.SetScale( s_Parameters.m_PrintScale );
|
||||
|
||||
m_parent->SetPlotSettings( plot_opts );
|
||||
|
||||
s_Parameters.m_PenDefaultSize = m_defaultPenWidth.GetValue();
|
||||
g_DrawDefaultLineThickness = s_Parameters.m_PenDefaultSize;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::OnSelectAllClick( wxCommandEvent& event )
|
||||
{
|
||||
setListBoxValue( m_CopperLayersList, true );
|
||||
setListBoxValue( m_TechnicalLayersList, true );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::OnDeselectAllClick( wxCommandEvent& event )
|
||||
{
|
||||
setListBoxValue( m_CopperLayersList, false );
|
||||
setListBoxValue( m_TechnicalLayersList, false );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::OnSetCustomScale( wxCommandEvent& event )
|
||||
{
|
||||
// Select 'custom scale' radio button when user types in a value in the
|
||||
// custom scale text box
|
||||
m_scaleCustom->SetValue( true );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::OnPageSetup( wxCommandEvent& event )
|
||||
{
|
||||
wxPageSetupDialog pageSetupDialog( this, s_pageSetupData );
|
||||
pageSetupDialog.ShowModal();
|
||||
|
||||
(*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
|
||||
(*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::OnPrintPreview( wxCommandEvent& event )
|
||||
{
|
||||
SetPrintParameters();
|
||||
|
||||
// If no layer selected, we have no plot. prompt user if it happens
|
||||
// because he could think there is a bug in Pcbnew:
|
||||
if( s_Parameters.m_PrintMaskLayer == 0 )
|
||||
{
|
||||
DisplayError( this, _( "No layer selected" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// Pass two printout objects: for preview, and possible printing.
|
||||
wxString title = _( "Print Preview" );
|
||||
wxPrintPreview* preview =
|
||||
new wxPrintPreview( createPrintout( title ), createPrintout( title ), s_PrintData );
|
||||
|
||||
preview->SetZoom( 100 );
|
||||
|
||||
wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, m_parent->GetPosition(),
|
||||
m_parent->GetSize() );
|
||||
frame->SetMinSize( wxSize( 550, 350 ) );
|
||||
frame->Center();
|
||||
|
||||
// On wxGTK, set the flag wxTOPLEVEL_EX_DIALOG is mandatory, if we want
|
||||
// close the frame using the X box in caption, when the preview frame is run
|
||||
// from a dialog
|
||||
frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
|
||||
|
||||
// We use here wxPreviewFrame_WindowModal option to make the wxPrintPreview frame
|
||||
// modal for its caller only.
|
||||
// An other reason is the fact when closing the frame without this option,
|
||||
// all top level frames are reenabled.
|
||||
// With this option, only the parent is reenabled.
|
||||
// Reenabling all top level frames should be made by the parent dialog.
|
||||
frame->InitializeWithModality( wxPreviewFrame_WindowModal );
|
||||
|
||||
frame->Raise(); // Needed on Ubuntu/Unity to display the frame
|
||||
frame->Show( true );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PRINT_PCBNEW::OnPrintButtonClick( wxCommandEvent& event )
|
||||
{
|
||||
SetPrintParameters();
|
||||
|
||||
// If no layer selected, we have no plot. prompt user if it happens
|
||||
// because he could think there is a bug in Pcbnew:
|
||||
if( s_Parameters.m_PrintMaskLayer == 0 )
|
||||
{
|
||||
DisplayError( this, _( "No layer selected" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
wxPrintDialogData printDialogData( *s_PrintData );
|
||||
printDialogData.SetMaxPage( s_Parameters.m_PageCount );
|
||||
|
||||
wxPrinter printer( &printDialogData );
|
||||
auto printout = std::unique_ptr<PCBNEW_PRINTOUT>( createPrintout( _( "Print" ) ) );
|
||||
|
||||
// Disable 'Print' button to prevent issuing another print
|
||||
// command before the previous one is finished (causes problems on Windows)
|
||||
ENABLER printBtnDisable( *m_sdbSizer1OK, false );
|
||||
|
||||
if( !printer.Print( this, printout.get(), true ) )
|
||||
{
|
||||
if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
|
||||
DisplayError( this, _( "There was a problem printing." ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
*s_PrintData = printer.GetPrintDialogData().GetPrintData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PCB_BASE_EDIT_FRAME::preparePrintout()
|
||||
{
|
||||
// Selection affects the original item visibility
|
||||
GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
const PAGE_INFO& pageInfo = GetPageSettings();
|
||||
|
||||
if( s_PrintData == NULL ) // First print
|
||||
{
|
||||
s_PrintData = new wxPrintData();
|
||||
|
||||
if( !s_PrintData->Ok() )
|
||||
DisplayError( this, _( "An error occurred initializing the printer information." ) );
|
||||
|
||||
s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH;
|
||||
}
|
||||
|
||||
if( s_pageSetupData == NULL )
|
||||
s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
|
||||
|
||||
s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
|
||||
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
|
||||
|
||||
if( pageInfo.IsCustom() )
|
||||
{
|
||||
if( pageInfo.IsPortrait() )
|
||||
s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ),
|
||||
Mils2mm( pageInfo.GetHeightMils() ) ) );
|
||||
else
|
||||
s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ),
|
||||
Mils2mm( pageInfo.GetWidthMils() ) ) );
|
||||
}
|
||||
|
||||
*s_PrintData = s_pageSetupData->GetPrintData();
|
||||
DIALOG_PRINT_GENERIC::saveSettings();
|
||||
g_DrawDefaultLineThickness = settings()->m_lineWidth;
|
||||
}
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
|
||||
{
|
||||
preparePrintout();
|
||||
DIALOG_PRINT_PCBNEW dlg( this );
|
||||
// Selection affects the original item visibility
|
||||
GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
PCBNEW_PRINTOUT_SETTINGS settings( GetPageSettings() );
|
||||
DIALOG_PRINT_PCBNEW dlg( this, &settings );
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
|
||||
{
|
||||
preparePrintout();
|
||||
DIALOG_PRINT_PCBNEW dlg( this );
|
||||
// Selection affects the original item visibility
|
||||
GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
PCBNEW_PRINTOUT_SETTINGS settings( GetPageSettings() );
|
||||
DIALOG_PRINT_PCBNEW dlg( this, &settings );
|
||||
dlg.ForcePrintBorder( false );
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
|
|
@ -1,228 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 17 2016)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dialog_print_pcbnew_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DIALOG_PRINT_PCBNEW_BASE::DIALOG_PRINT_PCBNEW_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
|
||||
|
||||
wxBoxSizer* bMainSizer;
|
||||
bMainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* bUpperSizer;
|
||||
bUpperSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticBoxSizer* sbLayersSizer;
|
||||
sbLayersSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Included Layers") ), wxVERTICAL );
|
||||
|
||||
wxBoxSizer* bLayerListsSizer;
|
||||
bLayerListsSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxBoxSizer* bSizer6;
|
||||
bSizer6 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText4 = new wxStaticText( sbLayersSizer->GetStaticBox(), wxID_ANY, _("Copper layers:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText4->Wrap( -1 );
|
||||
bSizer6->Add( m_staticText4, 0, wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
wxArrayString m_CopperLayersListChoices;
|
||||
m_CopperLayersList = new wxCheckListBox( sbLayersSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_CopperLayersListChoices, 0 );
|
||||
bSizer6->Add( m_CopperLayersList, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
bLayerListsSizer->Add( bSizer6, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer7;
|
||||
bSizer7 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText5 = new wxStaticText( sbLayersSizer->GetStaticBox(), wxID_ANY, _("Technical layers:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText5->Wrap( -1 );
|
||||
bSizer7->Add( m_staticText5, 0, wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
wxArrayString m_TechnicalLayersListChoices;
|
||||
m_TechnicalLayersList = new wxCheckListBox( sbLayersSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_TechnicalLayersListChoices, 0 );
|
||||
bSizer7->Add( m_TechnicalLayersList, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
bLayerListsSizer->Add( bSizer7, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
sbLayersSizer->Add( bLayerListsSizer, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer9;
|
||||
bSizer9 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_buttonSelectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _("Select all"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer9->Add( m_buttonSelectAll, 1, wxALL, 5 );
|
||||
|
||||
m_buttonDeselectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _("Deselect all"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer9->Add( m_buttonDeselectAll, 1, wxALL, 5 );
|
||||
|
||||
|
||||
sbLayersSizer->Add( bSizer9, 0, wxEXPAND, 5 );
|
||||
|
||||
m_Exclude_Edges_Pcb = new wxCheckBox( sbLayersSizer->GetStaticBox(), wxID_ANY, _("Exclude PCB edge layer"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_Exclude_Edges_Pcb->SetToolTip( _("Exclude contents of Edges_Pcb layer from all other layers") );
|
||||
|
||||
sbLayersSizer->Add( m_Exclude_Edges_Pcb, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bUpperSizer->Add( sbLayersSizer, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bOptionsSizer;
|
||||
bOptionsSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxStaticBoxSizer* sbOptionsSizer;
|
||||
sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL );
|
||||
|
||||
wxGridBagSizer* gbSizer1;
|
||||
gbSizer1 = new wxGridBagSizer( 2, 0 );
|
||||
gbSizer1->SetFlexibleDirection( wxBOTH );
|
||||
gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
m_penWidthLabel = new wxStaticText( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Default line width:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_penWidthLabel->Wrap( -1 );
|
||||
m_penWidthLabel->SetToolTip( _("Pen size used to draw items that have no pen size specified.\nUsed mainly to draw items in sketch mode.") );
|
||||
|
||||
gbSizer1->Add( m_penWidthLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
|
||||
|
||||
m_penWidthCtrl = new wxTextCtrl( sbOptionsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
gbSizer1->Add( m_penWidthCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
m_penWidthUnits = new wxStaticText( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_penWidthUnits->Wrap( -1 );
|
||||
gbSizer1->Add( m_penWidthUnits, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
|
||||
|
||||
m_drillMarksLabel = new wxStaticText( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Drill marks:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_drillMarksLabel->Wrap( -1 );
|
||||
gbSizer1->Add( m_drillMarksLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
wxString m_drillMarksChoiceChoices[] = { _("No drill mark"), _("Small mark"), _("Real drill") };
|
||||
int m_drillMarksChoiceNChoices = sizeof( m_drillMarksChoiceChoices ) / sizeof( wxString );
|
||||
m_drillMarksChoice = new wxChoice( sbOptionsSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_drillMarksChoiceNChoices, m_drillMarksChoiceChoices, 0 );
|
||||
m_drillMarksChoice->SetSelection( 0 );
|
||||
gbSizer1->Add( m_drillMarksChoice, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
m_outputModeLabel = new wxStaticText( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Output mode:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_outputModeLabel->Wrap( -1 );
|
||||
gbSizer1->Add( m_outputModeLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 );
|
||||
|
||||
wxString m_outputModeChoices[] = { _("Color"), _("Black and white") };
|
||||
int m_outputModeNChoices = sizeof( m_outputModeChoices ) / sizeof( wxString );
|
||||
m_outputMode = new wxChoice( sbOptionsSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_outputModeNChoices, m_outputModeChoices, 0 );
|
||||
m_outputMode->SetSelection( 0 );
|
||||
gbSizer1->Add( m_outputMode, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
m_Print_Sheet_Ref = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_FRAME_SEL, _("Print border and title block"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_Print_Sheet_Ref->SetValue(true);
|
||||
m_Print_Sheet_Ref->SetToolTip( _("Print Frame references.") );
|
||||
|
||||
gbSizer1->Add( m_Print_Sheet_Ref, wxGBPosition( 3, 0 ), wxGBSpan( 1, 3 ), wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_Print_Mirror = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Print mirrored"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
gbSizer1->Add( m_Print_Mirror, wxGBPosition( 4, 0 ), wxGBSpan( 1, 3 ), wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
gbSizer1->AddGrowableCol( 1 );
|
||||
|
||||
sbOptionsSizer->Add( gbSizer1, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bOptionsSizer->Add( sbOptionsSizer, 1, wxEXPAND|wxALL, 5 );
|
||||
|
||||
wxString m_PagesOptionChoices[] = { _("One page per layer"), _("All layers on single page") };
|
||||
int m_PagesOptionNChoices = sizeof( m_PagesOptionChoices ) / sizeof( wxString );
|
||||
m_PagesOption = new wxRadioBox( this, wxID_PAGE_MODE, _("Pagination"), wxDefaultPosition, wxDefaultSize, m_PagesOptionNChoices, m_PagesOptionChoices, 1, wxRA_SPECIFY_COLS );
|
||||
m_PagesOption->SetSelection( 0 );
|
||||
bOptionsSizer->Add( m_PagesOption, 0, wxALL|wxEXPAND|wxLEFT|wxRIGHT, 5 );
|
||||
|
||||
wxStaticBoxSizer* bScaleSizer;
|
||||
bScaleSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Scale") ), wxVERTICAL );
|
||||
|
||||
m_scale1 = new wxRadioButton( bScaleSizer->GetStaticBox(), wxID_ANY, _("1:1"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bScaleSizer->Add( m_scale1, 0, 0, 5 );
|
||||
|
||||
m_scaleFit = new wxRadioButton( bScaleSizer->GetStaticBox(), wxID_ANY, _("Fit to page"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bScaleSizer->Add( m_scaleFit, 0, wxTOP, 5 );
|
||||
|
||||
wxBoxSizer* bSizer10;
|
||||
bSizer10 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_scaleCustom = new wxRadioButton( bScaleSizer->GetStaticBox(), wxID_ANY, _("Custom:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer10->Add( m_scaleCustom, 0, wxTOP, 5 );
|
||||
|
||||
m_scaleCustomText = new wxTextCtrl( bScaleSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_scaleCustomText->SetToolTip( _("Set X scale adjust for exact scale plotting") );
|
||||
|
||||
bSizer10->Add( m_scaleCustomText, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bScaleSizer->Add( bSizer10, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bOptionsSizer->Add( bScaleSizer, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bUpperSizer->Add( bOptionsSizer, 0, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bMainSizer->Add( bUpperSizer, 1, wxEXPAND|wxALL, 5 );
|
||||
|
||||
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
bMainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
wxBoxSizer* bButtonsSizer;
|
||||
bButtonsSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_buttonOption = new wxButton( this, wxID_PRINT_OPTIONS, _("Page Setup..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_buttonOption->SetMinSize( wxSize( 120,-1 ) );
|
||||
|
||||
bButtonsSizer->Add( m_buttonOption, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_sdbSizer1 = new wxStdDialogButtonSizer();
|
||||
m_sdbSizer1OK = new wxButton( this, wxID_OK );
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1OK );
|
||||
m_sdbSizer1Apply = new wxButton( this, wxID_APPLY );
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1Apply );
|
||||
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
|
||||
m_sdbSizer1->Realize();
|
||||
|
||||
bButtonsSizer->Add( m_sdbSizer1, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bMainSizer->Add( bButtonsSizer, 0, wxEXPAND|wxLEFT, 10 );
|
||||
|
||||
|
||||
this->SetSizer( bMainSizer );
|
||||
this->Layout();
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
|
||||
// Connect Events
|
||||
m_buttonSelectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnSelectAllClick ), NULL, this );
|
||||
m_buttonDeselectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnDeselectAllClick ), NULL, this );
|
||||
m_scaleCustomText->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnSetCustomScale ), NULL, this );
|
||||
m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnPageSetup ), NULL, this );
|
||||
m_sdbSizer1Apply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnPrintPreview ), NULL, this );
|
||||
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnPrintButtonClick ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_PRINT_PCBNEW_BASE::~DIALOG_PRINT_PCBNEW_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_buttonSelectAll->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnSelectAllClick ), NULL, this );
|
||||
m_buttonDeselectAll->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnDeselectAllClick ), NULL, this );
|
||||
m_scaleCustomText->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnSetCustomScale ), NULL, this );
|
||||
m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnPageSetup ), NULL, this );
|
||||
m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnPrintPreview ), NULL, this );
|
||||
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW_BASE::OnPrintButtonClick ), NULL, this );
|
||||
|
||||
}
|
|
@ -211,11 +211,6 @@ protected:
|
|||
virtual void duplicateItems( bool aIncrement ) = 0;
|
||||
|
||||
void unitsChangeRefresh() override;
|
||||
|
||||
/**
|
||||
* Set up printing system.
|
||||
*/
|
||||
virtual void preparePrintout();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,10 +30,36 @@
|
|||
|
||||
#include <pcb_painter.h>
|
||||
#include <view/view.h>
|
||||
#include <pcbplot.h>
|
||||
|
||||
PCBNEW_PRINTOUT::PCBNEW_PRINTOUT( BOARD* aBoard, const PRINT_PARAMETERS& aParams,
|
||||
PCBNEW_PRINTOUT_SETTINGS::PCBNEW_PRINTOUT_SETTINGS( const PAGE_INFO& aPageInfo )
|
||||
: BOARD_PRINTOUT_SETTINGS( aPageInfo )
|
||||
{
|
||||
m_drillMarks = SMALL_DRILL_SHAPE;
|
||||
m_pagination = ALL_LAYERS;
|
||||
m_noEdgeLayer = false;
|
||||
}
|
||||
|
||||
|
||||
void PCBNEW_PRINTOUT_SETTINGS::Load( wxConfigBase* aConfig )
|
||||
{
|
||||
BOARD_PRINTOUT_SETTINGS::Load( aConfig );
|
||||
aConfig->Read( OPTKEY_PRINT_PADS_DRILL, (int*) &m_drillMarks, FULL_DRILL_SHAPE );
|
||||
aConfig->Read( OPTKEY_PRINT_PAGE_PER_LAYER, (int*) &m_pagination, ALL_LAYERS );
|
||||
}
|
||||
|
||||
|
||||
void PCBNEW_PRINTOUT_SETTINGS::Save( wxConfigBase* aConfig )
|
||||
{
|
||||
BOARD_PRINTOUT_SETTINGS::Save( aConfig );
|
||||
aConfig->Write( OPTKEY_PRINT_PADS_DRILL, (int) m_drillMarks );
|
||||
aConfig->Write( OPTKEY_PRINT_PAGE_PER_LAYER, (int) m_pagination );
|
||||
}
|
||||
|
||||
|
||||
PCBNEW_PRINTOUT::PCBNEW_PRINTOUT( BOARD* aBoard, const PCBNEW_PRINTOUT_SETTINGS& aParams,
|
||||
const KIGFX::VIEW* aView, const wxSize& aSheetSize, const wxString& aTitle ) :
|
||||
BOARD_PRINTOUT( aParams, aView, aSheetSize, aTitle )
|
||||
BOARD_PRINTOUT( aParams, aView, aSheetSize, aTitle ), m_pcbnewSettings( aParams )
|
||||
{
|
||||
m_board = aBoard;
|
||||
}
|
||||
|
@ -42,13 +68,13 @@ PCBNEW_PRINTOUT::PCBNEW_PRINTOUT( BOARD* aBoard, const PRINT_PARAMETERS& aParams
|
|||
bool PCBNEW_PRINTOUT::OnPrintPage( int aPage )
|
||||
{
|
||||
// Store the layerset, as it is going to be modified below and the original settings are needed
|
||||
LSET lset = m_PrintParams.m_PrintMaskLayer;
|
||||
LSET lset = m_settings.m_layerSet;
|
||||
int pageCount = lset.count();
|
||||
wxString layer;
|
||||
PCB_LAYER_ID extractLayer;
|
||||
|
||||
// compute layer mask from page number if we want one page per layer
|
||||
if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer
|
||||
if( m_pcbnewSettings.m_pagination == 0 ) // One page per layer
|
||||
{
|
||||
// This sequence is TBD, call a different
|
||||
// sequencer if needed, such as Seq(). Could not find documentation on
|
||||
|
@ -57,13 +83,13 @@ bool PCBNEW_PRINTOUT::OnPrintPage( int aPage )
|
|||
|
||||
// aPage starts at 1, not 0
|
||||
if( unsigned( aPage - 1 ) < seq.size() )
|
||||
m_PrintParams.m_PrintMaskLayer = LSET( seq[aPage - 1] );
|
||||
m_settings.m_layerSet = LSET( seq[aPage - 1] );
|
||||
}
|
||||
|
||||
if( !m_PrintParams.m_PrintMaskLayer.any() )
|
||||
if( !m_settings.m_layerSet.any() )
|
||||
return false;
|
||||
|
||||
extractLayer = m_PrintParams.m_PrintMaskLayer.ExtractLayer();
|
||||
extractLayer = m_settings.m_layerSet.ExtractLayer();
|
||||
|
||||
if( extractLayer == UNDEFINED_LAYER )
|
||||
layer = _( "Multiple Layers" );
|
||||
|
@ -71,13 +97,13 @@ bool PCBNEW_PRINTOUT::OnPrintPage( int aPage )
|
|||
layer = LSET::Name( extractLayer );
|
||||
|
||||
// In Pcbnew we can want the layer EDGE always printed
|
||||
if( m_PrintParams.m_Flags == 1 )
|
||||
m_PrintParams.m_PrintMaskLayer.set( Edge_Cuts );
|
||||
if( !m_pcbnewSettings.m_noEdgeLayer )
|
||||
m_settings.m_layerSet.set( Edge_Cuts );
|
||||
|
||||
DrawPage( layer, aPage, pageCount );
|
||||
|
||||
// Restore the original layer set, so the next page can be printed
|
||||
m_PrintParams.m_PrintMaskLayer = lset;
|
||||
m_settings.m_layerSet = lset;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -88,7 +114,7 @@ void PCBNEW_PRINTOUT::setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView
|
|||
{
|
||||
BOARD_PRINTOUT::setupViewLayers( aView, aLayerSet );
|
||||
|
||||
for( LSEQ layerSeq = m_PrintParams.m_PrintMaskLayer.Seq(); layerSeq; ++layerSeq )
|
||||
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
|
||||
|
@ -107,7 +133,7 @@ void PCBNEW_PRINTOUT::setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView
|
|||
aView->SetLayerVisible( item, true );
|
||||
}
|
||||
|
||||
if( m_PrintParams.m_DrillShapeOpt != PRINT_PARAMETERS::NO_DRILL_SHAPE )
|
||||
if( m_pcbnewSettings.m_drillMarks != PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE )
|
||||
{
|
||||
// Enable hole layers to draw drill marks
|
||||
for( auto holeLayer : { LAYER_PADS_PLATEDHOLES,
|
||||
|
@ -138,17 +164,17 @@ void PCBNEW_PRINTOUT::setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPain
|
|||
|
||||
auto painter = static_cast<KIGFX::PCB_PRINT_PAINTER*>( aPainter.get() );
|
||||
|
||||
switch( m_PrintParams.m_DrillShapeOpt )
|
||||
switch( m_pcbnewSettings.m_drillMarks )
|
||||
{
|
||||
case PRINT_PARAMETERS::NO_DRILL_SHAPE:
|
||||
case PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE:
|
||||
painter->SetDrillMarks( false, 0 );
|
||||
break;
|
||||
|
||||
case PRINT_PARAMETERS::SMALL_DRILL_SHAPE:
|
||||
case PCBNEW_PRINTOUT_SETTINGS::SMALL_DRILL_SHAPE:
|
||||
painter->SetDrillMarks( false, Millimeter2iu( 0.3 ) );
|
||||
break;
|
||||
|
||||
case PRINT_PARAMETERS::FULL_DRILL_SHAPE:
|
||||
case PCBNEW_PRINTOUT_SETTINGS::FULL_DRILL_SHAPE:
|
||||
painter->SetDrillMarks( true );
|
||||
break;
|
||||
}
|
||||
|
@ -161,6 +187,7 @@ void PCBNEW_PRINTOUT::setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPain
|
|||
|
||||
void PCBNEW_PRINTOUT::setupGal( KIGFX::GAL* aGal )
|
||||
{
|
||||
BOARD_PRINTOUT::setupGal( aGal );
|
||||
aGal->SetWorldUnitLength( 1e-9 /* 1 nm */ / 0.0254 /* 1 inch in meters */ );
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,32 @@
|
|||
|
||||
class BOARD;
|
||||
|
||||
struct PCBNEW_PRINTOUT_SETTINGS : BOARD_PRINTOUT_SETTINGS
|
||||
{
|
||||
PCBNEW_PRINTOUT_SETTINGS( const PAGE_INFO& aPageInfo );
|
||||
|
||||
enum DRILL_MARK_SHAPE_T {
|
||||
NO_DRILL_SHAPE,
|
||||
SMALL_DRILL_SHAPE,
|
||||
FULL_DRILL_SHAPE
|
||||
} m_drillMarks; ///< Drill marks shape
|
||||
|
||||
enum PAGINATION_T {
|
||||
LAYER_PER_PAGE,
|
||||
ALL_LAYERS
|
||||
} m_pagination; ///< Pagination
|
||||
|
||||
bool m_noEdgeLayer; ///< Disable board outline on each page
|
||||
|
||||
void Load( wxConfigBase* aConfig ) override;
|
||||
void Save( wxConfigBase* aConfig ) override;
|
||||
};
|
||||
|
||||
|
||||
class PCBNEW_PRINTOUT : public BOARD_PRINTOUT
|
||||
{
|
||||
public:
|
||||
PCBNEW_PRINTOUT( BOARD* aBoard, const PRINT_PARAMETERS& aParams,
|
||||
PCBNEW_PRINTOUT( BOARD* aBoard, const PCBNEW_PRINTOUT_SETTINGS& aParams,
|
||||
const KIGFX::VIEW* aView, const wxSize& aSheetSize, const wxString& aTitle );
|
||||
|
||||
bool OnPrintPage( int aPage ) override;
|
||||
|
@ -46,6 +68,8 @@ protected:
|
|||
|
||||
private:
|
||||
BOARD* m_board;
|
||||
|
||||
PCBNEW_PRINTOUT_SETTINGS m_pcbnewSettings;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
class PLOTTER;
|
||||
class TEXTE_PCB;
|
||||
class D_PAD;
|
||||
class DRAWSEGMENT;
|
||||
class DIMENSION;
|
||||
class MODULE;
|
||||
|
@ -50,10 +51,7 @@ class REPORTER;
|
|||
/// \ingroup config
|
||||
|
||||
#define OPTKEY_LAYERBASE wxT( "PlotLayer_%d" )
|
||||
#define OPTKEY_PRINT_X_FINESCALE_ADJ wxT( "PrintXFineScaleAdj" )
|
||||
#define OPTKEY_PRINT_Y_FINESCALE_ADJ wxT( "PrintYFineScaleAdj" )
|
||||
#define OPTKEY_PRINT_SCALE wxT( "PrintScale" )
|
||||
#define OPTKEY_PRINT_MODULE_SCALE wxT( "PrintModuleScale" )
|
||||
#define OPTKEY_PRINT_PAGE_FRAME wxT( "PrintPageFrame" )
|
||||
#define OPTKEY_PRINT_MONOCHROME_MODE wxT( "PrintMonochrome" )
|
||||
#define OPTKEY_PRINT_PAGE_PER_LAYER wxT( "PrintSinglePage" )
|
||||
|
|
Loading…
Reference in New Issue