Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
ac00eede
Commit
ac00eede
authored
Apr 21, 2010
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Plain Diff
Pcbnew+Gerbview: Fixed some issues in print dialog
parents
85604886
e066b91c
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
62 deletions
+70
-62
dialog_print_using_printer.cpp
gerbview/dialog_print_using_printer.cpp
+19
-13
dialog_print_using_printer_base.cpp
gerbview/dialog_print_using_printer_base.cpp
+2
-2
dialog_print_using_printer_base.fbp
gerbview/dialog_print_using_printer_base.fbp
+1
-1
dialog_print_using_printer_base.h
gerbview/dialog_print_using_printer_base.h
+1
-1
dialog_print_using_printer.cpp
pcbnew/dialog_print_using_printer.cpp
+16
-10
printout_controler.cpp
pcbnew/printout_controler.cpp
+30
-35
printout_controler.h
pcbnew/printout_controler.h
+1
-0
No files found.
gerbview/dialog_print_using_printer.cpp
View file @
ac00eede
...
...
@@ -34,6 +34,7 @@ static double s_ScaleList[] =
// static print data and page setup data, to remember settings during the session
static
wxPrintData
*
g_PrintData
;
static
wxPageSetupDialogData
*
g_pageSetupData
=
(
wxPageSetupDialogData
*
)
NULL
;
// Variables locales
static
PRINT_PARAMETERS
s_Parameters
;
...
...
@@ -58,7 +59,7 @@ public:
private
:
void
OnCloseWindow
(
wxCloseEvent
&
event
);
void
OnInitDialog
(
wxInitDialogEvent
&
event
);
void
OnP
rint
Setup
(
wxCommandEvent
&
event
);
void
OnP
age
Setup
(
wxCommandEvent
&
event
);
void
OnPrintPreview
(
wxCommandEvent
&
event
);
void
OnPrintButtonClick
(
wxCommandEvent
&
event
);
...
...
@@ -130,8 +131,18 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
int
layer_max
=
NB_LAYERS
;
wxString
msg
;
layer_max
=
32
;
if
(
g_pageSetupData
==
NULL
)
{
g_pageSetupData
=
new
wxPageSetupDialogData
;
// Set initial page margins.
// Margins are already set in Pcbnew, so we cans use 0
g_pageSetupData
->
SetMarginTopLeft
(
wxPoint
(
0
,
0
));
g_pageSetupData
->
SetMarginBottomRight
(
wxPoint
(
0
,
0
));
}
s_Parameters
.
m_PageSetupData
=
g_pageSetupData
;
layer_max
=
32
;
/* Create layer list */
int
mask
=
1
,
ii
;
for
(
ii
=
0
;
ii
<
layer_max
;
ii
++
,
mask
<<=
1
)
...
...
@@ -326,24 +337,19 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
}
/**********************************************************/
void
DIALOG_PRINT_USING_PRINTER
::
OnP
rint
Setup
(
wxCommandEvent
&
event
)
void
DIALOG_PRINT_USING_PRINTER
::
OnP
age
Setup
(
wxCommandEvent
&
event
)
/**********************************************************/
/* Open a dialog box for printer setup (printer options, page size ...)
*/
{
wxPrintDialogData
printDialogData
(
*
g_PrintData
);
if
(
printDialogData
.
Ok
()
)
{
wxPrintDialog
printerDialog
(
this
,
&
printDialogData
);
*
g_pageSetupData
=
*
g_PrintData
;
printerDialog
.
ShowModal
();
wxPageSetupDialog
pageSetupDialog
(
this
,
g_pageSetupData
);
pageSetupDialog
.
ShowModal
();
*
g_PrintData
=
printerDialog
.
GetPrintDialogData
().
GetPrintData
();
}
else
DisplayError
(
this
,
_
(
"Printer Problem!"
)
);
(
*
g_PrintData
)
=
pageSetupDialog
.
GetPageSetupDialogData
().
GetPrintData
();
(
*
g_pageSetupData
)
=
pageSetupDialog
.
GetPageSetupDialogData
();
}
...
...
gerbview/dialog_print_using_printer_base.cpp
View file @
ac00eede
...
...
@@ -113,7 +113,7 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare
// Connect Events
this
->
Connect
(
wxEVT_CLOSE_WINDOW
,
wxCloseEventHandler
(
DIALOG_PRINT_USING_PRINTER_base
::
OnCloseWindow
)
);
m_buttonOption
->
Connect
(
wxEVT_COMMAND_BUTTON_CLICKED
,
wxCommandEventHandler
(
DIALOG_PRINT_USING_PRINTER_base
::
OnP
rint
Setup
),
NULL
,
this
);
m_buttonOption
->
Connect
(
wxEVT_COMMAND_BUTTON_CLICKED
,
wxCommandEventHandler
(
DIALOG_PRINT_USING_PRINTER_base
::
OnP
age
Setup
),
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
::
OnButtonCancelClick
),
NULL
,
this
);
...
...
@@ -123,7 +123,7 @@ 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_buttonOption
->
Disconnect
(
wxEVT_COMMAND_BUTTON_CLICKED
,
wxCommandEventHandler
(
DIALOG_PRINT_USING_PRINTER_base
::
OnP
rint
Setup
),
NULL
,
this
);
m_buttonOption
->
Disconnect
(
wxEVT_COMMAND_BUTTON_CLICKED
,
wxCommandEventHandler
(
DIALOG_PRINT_USING_PRINTER_base
::
OnP
age
Setup
),
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
::
OnButtonCancelClick
),
NULL
,
this
);
...
...
gerbview/dialog_print_using_printer_base.fbp
View file @
ac00eede
...
...
@@ -625,7 +625,7 @@
<property
name=
"window_extra_style"
></property>
<property
name=
"window_name"
></property>
<property
name=
"window_style"
></property>
<event
name=
"OnButtonClick"
>
OnP
rint
Setup
</event>
<event
name=
"OnButtonClick"
>
OnP
age
Setup
</event>
<event
name=
"OnChar"
></event>
<event
name=
"OnEnterWindow"
></event>
<event
name=
"OnEraseBackground"
></event>
...
...
gerbview/dialog_print_using_printer_base.h
View file @
ac00eede
...
...
@@ -59,7 +59,7 @@ class DIALOG_PRINT_USING_PRINTER_base : public wxDialog
// Virtual event handlers, overide them in your derived class
virtual
void
OnCloseWindow
(
wxCloseEvent
&
event
){
event
.
Skip
();
}
virtual
void
OnP
rint
Setup
(
wxCommandEvent
&
event
){
event
.
Skip
();
}
virtual
void
OnP
age
Setup
(
wxCommandEvent
&
event
){
event
.
Skip
();
}
virtual
void
OnPrintPreview
(
wxCommandEvent
&
event
){
event
.
Skip
();
}
virtual
void
OnPrintButtonClick
(
wxCommandEvent
&
event
){
event
.
Skip
();
}
virtual
void
OnButtonCancelClick
(
wxCommandEvent
&
event
){
event
.
Skip
();
}
...
...
pcbnew/dialog_print_using_printer.cpp
View file @
ac00eede
...
...
@@ -36,6 +36,7 @@ static double s_ScaleList[] =
// static print data and page setup data, to remember settings during the session
static
wxPrintData
*
g_PrintData
;
static
wxPageSetupDialogData
*
g_pageSetupData
=
(
wxPageSetupDialogData
*
)
NULL
;
static
PRINT_PARAMETERS
s_Parameters
;
...
...
@@ -138,6 +139,16 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
int
layer_max
=
NB_LAYERS
;
wxString
msg
;
BOARD
*
board
=
m_Parent
->
GetBoard
();
if
(
g_pageSetupData
==
NULL
)
{
g_pageSetupData
=
new
wxPageSetupDialogData
;
// Set initial page margins.
// Margins are already set in Pcbnew, so we cans use 0
g_pageSetupData
->
SetMarginTopLeft
(
wxPoint
(
0
,
0
));
g_pageSetupData
->
SetMarginBottomRight
(
wxPoint
(
0
,
0
));
}
s_Parameters
.
m_PageSetupData
=
g_pageSetupData
;
// Create layer list.
int
layer
;
...
...
@@ -420,18 +431,13 @@ void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event )
/* Open a dialog box for printer setup (printer options, page size ...)
*/
{
wxPrintDialogData
printDialogData
(
*
g_PrintData
)
;
*
g_pageSetupData
=
*
g_PrintData
;
if
(
printDialogData
.
Ok
()
)
{
wxPrintDialog
printerDialog
(
this
,
&
printDialogData
);
printerDialog
.
ShowModal
();
wxPageSetupDialog
pageSetupDialog
(
this
,
g_pageSetupData
);
pageSetupDialog
.
ShowModal
();
*
g_PrintData
=
printerDialog
.
GetPrintDialogData
().
GetPrintData
();
}
else
DisplayError
(
this
,
_
(
"Printer Problem!"
)
);
(
*
g_PrintData
)
=
pageSetupDialog
.
GetPageSetupDialogData
().
GetPrintData
();
(
*
g_pageSetupData
)
=
pageSetupDialog
.
GetPageSetupDialogData
();
}
...
...
pcbnew/printout_controler.cpp
View file @
ac00eede
...
...
@@ -32,6 +32,7 @@ PRINT_PARAMETERS::PRINT_PARAMETERS()
m_ForceCentered
=
false
;
m_Flags
=
0
;
m_DrillShapeOpt
=
PRINT_PARAMETERS
::
SMALL_DRILL_SHAPE
;
m_PageSetupData
=
NULL
;
}
...
...
@@ -116,10 +117,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
{
int
tmpzoom
;
wxPoint
tmp_startvisu
;
wxSize
PageSize_in_mm
;
wxSize
SheetSize
;
// Page size in internal units
wxSize
PlotAreaSize
;
// plot area size in pixels
double
scaleX
,
scaleY
,
scale
;
wxPoint
old_org
;
wxPoint
DrawOffset
;
// Offset de trace
double
userscale
;
...
...
@@ -130,8 +128,6 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
wxBusyCursor
dummy
;
GetPageSizeMM
(
&
PageSize_in_mm
.
x
,
&
PageSize_in_mm
.
y
);
/* Save old draw scale and draw offset */
tmp_startvisu
=
ActiveScreen
->
m_StartVisu
;
tmpzoom
=
ActiveScreen
->
GetZoom
();
...
...
@@ -151,21 +147,19 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
SheetSize
.
x
*=
m_Parent
->
m_InternalUnits
/
1000
;
SheetSize
.
y
*=
m_Parent
->
m_InternalUnits
/
1000
;
// size in pixels
// Get the size of the DC in pixels
dc
->
GetSize
(
&
PlotAreaSize
.
x
,
&
PlotAreaSize
.
y
);
WinEDA_BasePcbFrame
*
pcbframe
=
(
WinEDA_BasePcbFrame
*
)
m_Parent
;
pcbframe
->
GetBoard
()
->
ComputeBoundaryBox
();
/* Compute the PCB size in internal units*/
userscale
=
m_PrintParams
.
m_PrintScale
;
if
(
userscale
==
0
)
// fit in page
{
int
extra_margin
=
0
;
// Margin = 8000/2 units pcb = 0,
4 inch
int
extra_margin
=
4000
*
2
;
// Margin = 4000 units pcb = 0.
4 inch
SheetSize
.
x
=
pcbframe
->
GetBoard
()
->
m_BoundaryBox
.
GetWidth
()
+
extra_margin
;
SheetSize
.
y
=
pcbframe
->
GetBoard
()
->
m_BoundaryBox
.
GetHeight
()
+
extra_margin
;
userscale
=
0.99
;
}
if
(
(
m_PrintParams
.
m_PrintScale
>
1.0
)
// scale > 1 -> Recadrage
||
(
m_PrintParams
.
m_PrintScale
==
0
)
)
// fit in page
{
...
...
@@ -173,26 +167,28 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
DrawOffset
.
y
+=
pcbframe
->
GetBoard
()
->
m_BoundaryBox
.
Centre
().
y
;
}
// Calculate a suitable scaling factor
scaleX
=
(
double
)
SheetSize
.
x
/
(
double
)
PlotAreaSize
.
x
;
scaleY
=
(
double
)
SheetSize
.
y
/
(
double
)
PlotAreaSize
.
y
;
scale
=
wxMax
(
scaleX
,
scaleY
)
/
userscale
;
// Use x or y scaling factor, whichever fits on the DC
// ajust the real draw scale
double
accurate_Xscale
,
accurate_Yscale
;
dc
->
SetUserScale
(
DrawZoom
/
scale
*
m_PrintParams
.
m_XScaleAdjust
,
DrawZoom
/
scale
*
m_PrintParams
.
m_YScaleAdjust
);
if
(
m_PrintParams
.
m_PageSetupData
)
{
wxSize
pagesize
;
pagesize
.
x
=
(
int
)
(
SheetSize
.
x
/
userscale
);
pagesize
.
y
=
(
int
)
(
SheetSize
.
y
/
userscale
);
FitThisSizeToPageMargins
(
pagesize
,
*
m_PrintParams
.
m_PageSetupData
);
}
// Compute Accurate scale 1
if
(
userscale
==
1.0
)
{
// We want a 1:1 scale and margins for printing
MapScreenSizeToPaper
(
);
int
w
,
h
;
GetPPIPrinter
(
&
w
,
&
h
);
accurate_Xscale
=
(
(
double
)
(
DrawZoom
*
w
)
)
/
(
double
)
PCB_INTERNAL_UNIT
;
accurate_Yscale
=
(
(
double
)
(
DrawZoom
*
h
)
)
/
(
double
)
PCB_INTERNAL_UNIT
;
double
accurate_Xscale
=
(
(
double
)
(
DrawZoom
*
w
)
)
/
(
double
)
PCB_INTERNAL_UNIT
;
double
accurate_Yscale
=
(
(
double
)
(
DrawZoom
*
h
)
)
/
(
double
)
PCB_INTERNAL_UNIT
;
if
(
IsPreview
()
)
// Scale must take in account the DC size in Preview
{
// Get the size of the DC in pixels
wxSize
PlotAreaSize
;
dc
->
GetSize
(
&
PlotAreaSize
.
x
,
&
PlotAreaSize
.
y
);
GetPageSizePixels
(
&
w
,
&
h
);
accurate_Xscale
*=
PlotAreaSize
.
x
;
...
...
@@ -202,8 +198,19 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
}
accurate_Xscale
*=
m_PrintParams
.
m_XScaleAdjust
;
accurate_Yscale
*=
m_PrintParams
.
m_YScaleAdjust
;
// Fine scale adjust
dc
->
SetUserScale
(
accurate_Xscale
,
accurate_Yscale
);
}
// Get the final size of the DC in pixels
wxSize
PlotAreaSizeInPixels
;
dc
->
GetSize
(
&
PlotAreaSizeInPixels
.
x
,
&
PlotAreaSizeInPixels
.
y
);
double
scalex
,
scaley
;
dc
->
GetUserScale
(
&
scalex
,
&
scaley
);
wxSize
PlotAreaSizeInUserUnits
;
PlotAreaSizeInUserUnits
.
x
=
(
int
)
(
PlotAreaSizeInPixels
.
x
/
scalex
);
PlotAreaSizeInUserUnits
.
y
=
(
int
)
(
PlotAreaSizeInPixels
.
y
/
scaley
);
/* In some cases the plot origin is the centre of the page
* when:
* - Asked
...
...
@@ -214,13 +221,9 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
||
(
m_PrintParams
.
m_PrintScale
>
1.0
)
// scale > 1
||
(
m_PrintParams
.
m_PrintScale
==
0
)
)
// fit in page
{
DrawOffset
.
x
-=
wxRound
(
(
(
double
)
PlotAreaSize
.
x
/
2.0
)
*
scale
)
;
DrawOffset
.
y
-=
wxRound
(
(
(
double
)
PlotAreaSize
.
y
/
2.0
)
*
scale
)
;
DrawOffset
.
x
-=
PlotAreaSizeInUserUnits
.
x
/
2
;
DrawOffset
.
y
-=
PlotAreaSizeInUserUnits
.
y
/
2
;
}
DrawOffset
.
x
+=
wxRound
(
(
(
double
)
SheetSize
.
x
/
2.0
)
*
(
m_PrintParams
.
m_XScaleAdjust
-
1.0
)
);
DrawOffset
.
y
+=
wxRound
(
(
(
double
)
SheetSize
.
y
/
2.0
)
*
(
m_PrintParams
.
m_YScaleAdjust
-
1.0
)
);
ActiveScreen
->
m_DrawOrg
=
DrawOffset
;
...
...
@@ -238,14 +241,6 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
m_Parent
->
GetBaseScreen
()
->
m_IsPrinting
=
true
;
int
bg_color
=
g_DrawBgColor
;
if
(
userscale
==
1.0
)
{
// We want a 1:1 scale and margins for printing
MapScreenSizeToPaper
(
);
// Fine scale adjust
dc
->
SetUserScale
(
accurate_Xscale
,
accurate_Yscale
);
}
if
(
m_PrintParams
.
m_Print_Sheet_Ref
)
m_Parent
->
TraceWorkSheet
(
dc
,
ActiveScreen
,
m_PrintParams
.
m_PenDefaultSize
);
...
...
@@ -263,7 +258,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
* the old draw area in the new draw area, because the draw origin has not moved
* (this is the upper left corner) but the Y axis is reversed, therefore the plotting area
* is the y coordinate values from - PlotAreaSize.y to 0 */
int
ysize
=
(
int
)
(
PlotAreaSize
.
y
/
sy
);
int
ysize
=
(
int
)
(
PlotAreaSize
InPixels
.
y
/
sy
);
DrawOffset
.
y
+=
ysize
;
/* in order to keep the board position in the sheet
...
...
pcbnew/printout_controler.h
View file @
ac00eede
...
...
@@ -31,6 +31,7 @@ public:
int
m_PageCount
;
// Number of page to print
bool
m_ForceCentered
;
// Forge plot origin to page centre (used in modedit)
int
m_Flags
;
// auxiliary variable: can be used to pass some other info
wxPageSetupDialogData
*
m_PageSetupData
;
// A wxPageSetupDialogData to know page options (margins)
enum
DrillShapeOptT
{
NO_DRILL_SHAPE
=
0
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment