Commit 93a8e7b3 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: print dialog: code cleanup and bug fixes (added some fixes from Sergey A. Borshch)

parent 2a2a530c
......@@ -18,9 +18,6 @@
#include <pcbplot.h>
#include <class_board_design_settings.h>
#define WIDTH_MAX_VALUE 1000
#define WIDTH_MIN_VALUE 1
static long s_SelectedLayers;
static double s_ScaleList[] =
{ 0, 0.5, 0.7, 0.999, 1.0, 1.4, 2.0, 3.0, 4.0 };
......
......@@ -17,9 +17,6 @@
#include <dialog_print_for_modedit_base.h>
#include <printout_controler.h>
#define WIDTH_MAX_VALUE 1000
#define WIDTH_MIN_VALUE 1
static double s_ScaleList[] =
{ 0, 0.5, 0.7, 1.0, 1.4, 2.0, 3.0, 4.0, 8.0, 16.0 };
......
......@@ -21,8 +21,8 @@
#include <dialog_print_using_printer_base.h>
#define WIDTH_MAX_VALUE 1000
#define WIDTH_MIN_VALUE 1
#define PEN_WIDTH_MAX_VALUE ( (int)(5 * IU_PER_MM) )
#define PEN_WIDTH_MIN_VALUE ( (int)(0.005 * IU_PER_MM) )
extern int g_DrawDefaultLineThickness;
......@@ -211,6 +211,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
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);
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;
......@@ -258,6 +259,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
else
m_ModeColorOption->SetSelection( 0 );
m_PagesOption->SetSelection(s_Parameters.m_OptionPrintPage);
s_Parameters.m_PenDefaultSize = g_DrawDefaultLineThickness;
AddUnitSymbol( *m_TextPenWidth, g_UserUnit );
m_DialogPenWidth->SetValue(
......@@ -320,6 +322,7 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
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);
m_config->Write( OPTKEY_PRINT_PAGE_PER_LAYER, s_Parameters.m_OptionPrintPage );
m_config->Write( OPTKEY_PRINT_PADS_DRILL, (long) s_Parameters.m_DrillShapeOpt );
wxString layerKey;
for( int layer = 0; layer < NB_LAYERS; ++layer )
......@@ -387,14 +390,14 @@ void DIALOG_PRINT_USING_PRINTER::SetPenWidth()
s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth );
if( s_Parameters.m_PenDefaultSize > WIDTH_MAX_VALUE )
if( s_Parameters.m_PenDefaultSize > PEN_WIDTH_MAX_VALUE )
{
s_Parameters.m_PenDefaultSize = WIDTH_MAX_VALUE;
s_Parameters.m_PenDefaultSize = PEN_WIDTH_MAX_VALUE;
}
if( s_Parameters.m_PenDefaultSize < WIDTH_MIN_VALUE )
if( s_Parameters.m_PenDefaultSize < PEN_WIDTH_MIN_VALUE )
{
s_Parameters.m_PenDefaultSize = WIDTH_MIN_VALUE;
s_Parameters.m_PenDefaultSize = PEN_WIDTH_MIN_VALUE;
}
g_DrawDefaultLineThickness = s_Parameters.m_PenDefaultSize;
......@@ -429,6 +432,14 @@ 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 =
......@@ -442,16 +453,6 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
return;
}
SetLayerMaskFromListSelection();
// 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;
}
// 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();
......
......@@ -121,6 +121,13 @@ bool EDA_APP::OnInit()
{
fn = argv[1];
// Be sure the filename is absolute, to avoid issues
// when the filename is relative,
// for instance when stored in history list without path,
// and when building the config filename ( which should have a path )
if( fn.IsRelative() )
fn.MakeAbsolute();
if( fn.GetExt() != PcbFileExtension && fn.GetExt() != LegacyPcbFileExtension )
{
msg.Printf( _( "Pcbnew file <%s> has a wrong extension.\n\
......
......@@ -28,6 +28,7 @@ class BOARD;
#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" )
#define OPTKEY_PRINT_PADS_DRILL wxT( "PrintPadsDrillOpt" )
#define OPTKEY_PLOT_X_FINESCALE_ADJ wxT( "PlotXFineScaleAdj" )
#define OPTKEY_PLOT_Y_FINESCALE_ADJ wxT( "PlotYFineScaleAdj" )
......@@ -37,13 +38,6 @@ class BOARD;
#define PLOT_MIN_SCALE 0.01
#define PLOT_MAX_SCALE 100.0
// Conversion unit constants.
// Convert pcb dimension of 0.1 mil to PS units of inches.
#define SCALE_PS .0001
// Convert dimension 0.1 mil -> HPGL units (1 HPGL unit = 25 micrometers):
#define SCALE_HPGL 0.102041
// Small drill marks (small pad holes) diameter value
#define SMALL_DRILL (int)( 0.35 * IU_PER_MM )
......
......@@ -32,7 +32,7 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC,
void * aData)
{
GR_DRAWMODE drawmode = GR_COPY;
int defaultPenSize = 50;
int defaultPenSize = Millimeter2iu( 0.2 );
DISPLAY_OPTIONS save_opt;
......@@ -53,6 +53,8 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC,
m_DisplayPadNum = DisplayOpt.DisplayPadNum = false;
bool nctmp = GetBoard()->IsElementVisible(NO_CONNECTS_VISIBLE);
GetBoard()->SetElementVisibility(NO_CONNECTS_VISIBLE, false);
bool anchorsTmp = GetBoard()->IsElementVisible( ANCHOR_VISIBLE );
GetBoard()->SetElementVisibility( ANCHOR_VISIBLE, false );
DisplayOpt.DisplayPadIsol = false;
DisplayOpt.DisplayModEdge = FILLED;
DisplayOpt.DisplayModText = FILLED;
......@@ -96,6 +98,7 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC,
m_DisplayViaFill = DisplayOpt.DisplayViaFill;
m_DisplayPadNum = DisplayOpt.DisplayPadNum;
GetBoard()->SetElementVisibility( NO_CONNECTS_VISIBLE, nctmp );
GetBoard()->SetElementVisibility(ANCHOR_VISIBLE, anchorsTmp);
}
......@@ -116,9 +119,8 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
MODULE* Module;
GR_DRAWMODE drawmode = GR_COPY;
DISPLAY_OPTIONS save_opt;
TRACK* pt_trace;
BOARD* Pcb = GetBoard();
int defaultPenSize = 50;
int defaultPenSize = Millimeter2iu( 0.2 );
bool onePagePerLayer = false;
PRINT_PARAMETERS * printParameters = (PRINT_PARAMETERS*) aData; // can be null
......@@ -222,7 +224,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
}
// Print tracks
pt_trace = Pcb->m_Track;
TRACK * pt_trace = Pcb->m_Track;
for( ; pt_trace != NULL; pt_trace = pt_trace->Next() )
{
......@@ -246,8 +248,8 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
}
}
// Outdated: only for compatibility to old boards
pt_trace = Pcb->m_Zone;
for( ; pt_trace != NULL; pt_trace = pt_trace->Next() )
{
if( ( aPrintMaskLayer & pt_trace->ReturnMaskLayer() ) == 0 )
......
......@@ -163,10 +163,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
wxBusyCursor dummy;
#ifdef PCBNEW
if( m_PrintParams.PrintBorderAndTitleBlock() )
boardBoundingBox =((PCB_BASE_FRAME*) m_Parent)->GetBoard()->ComputeBoundingBox();
else
boardBoundingBox =((PCB_BASE_FRAME*) m_Parent)->GetBoard()->ComputeBoundingBox( true );
boardBoundingBox =((PCB_BASE_FRAME*) m_Parent)->GetBoard()->ComputeBoundingBox();
#else
boardBoundingBox = ((GERBVIEW_FRAME*) m_Parent)->GetLayoutBoundingBox();
#endif
......@@ -185,15 +182,16 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
boardBoundingBox.GetHeight()/2 ) );
}
wxLogTrace( tracePrinting, wxT( "Drawing bounding box: x=%d, y=%d, w=%d, h=%d" ),
wxLogTrace( tracePrinting, wxT( "Drawing bounding box: x=%d, y=%d, w=%d, h=%d" ),
boardBoundingBox.GetX(), boardBoundingBox.GetY(),
boardBoundingBox.GetWidth(), boardBoundingBox.GetHeight() );
// Compute the PCB size in internal units
userscale = m_PrintParams.m_PrintScale;
if( m_PrintParams.m_PrintScale == 0 ) // fit in page
if( m_PrintParams.m_PrintScale == 0 ) // fit in page option
{
// TODO: a better way to calculate the userscale
userscale = 1.0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment