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
f78497bf
Commit
f78497bf
authored
May 10, 2013
by
Wayne Stambaugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decouple PLOT_CONTROLLER from UI dependencies.
parent
b5bb5642
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
275 additions
and
204 deletions
+275
-204
footprint_info.cpp
common/footprint_info.cpp
+3
-0
dialog_SVG_print.cpp
pcbnew/dialogs/dialog_SVG_print.cpp
+20
-8
dialog_plot.cpp
pcbnew/dialogs/dialog_plot.cpp
+134
-8
pcbframe.cpp
pcbnew/pcbframe.cpp
+7
-0
pcbplot.cpp
pcbnew/pcbplot.cpp
+50
-172
pcbplot.h
pcbnew/pcbplot.h
+19
-10
plotcontroller.h
pcbnew/plotcontroller.h
+42
-6
No files found.
common/footprint_info.cpp
View file @
f78497bf
...
...
@@ -72,6 +72,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
}
}
wxLogDebug
(
wxT
(
"Path <%s> -> <%s>."
),
GetChars
(
aFootprintsLibNames
[
ii
]
),
GetChars
(
filename
.
GetFullPath
()
)
);
if
(
!
filename
.
FileExists
()
)
{
m_filesNotFound
<<
filename
.
GetFullName
()
<<
wxT
(
"
\n
"
);
...
...
pcbnew/dialogs/dialog_SVG_print.cpp
View file @
f78497bf
...
...
@@ -37,6 +37,8 @@
#include <convert_from_iu.h>
#include <wildcards_and_files_ext.h>
#include <macros.h>
#include <reporter.h>
#include <confirm.h>
#include <pcbnew.h>
#include <pcbplot.h>
...
...
@@ -49,7 +51,7 @@
#define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" )
#define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" )
// reason
n
able values for default pen width
// reasonable values for default pen width
#define WIDTH_MAX_VALUE (2 * IU_PER_MM)
#define WIDTH_MIN_VALUE (0.05 * IU_PER_MM)
...
...
@@ -164,6 +166,7 @@ void DIALOG_SVG_PRINT::initDialog()
}
}
void
DIALOG_SVG_PRINT
::
OnOutputDirectoryBrowseClicked
(
wxCommandEvent
&
event
)
{
// Build the absolute path of current output plot directory
...
...
@@ -192,8 +195,7 @@ void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
wxString
boardFilePath
=
(
(
wxFileName
)
m_board
->
GetFileName
()
).
GetPath
();
if
(
!
dirName
.
MakeRelativeTo
(
boardFilePath
)
)
wxMessageBox
(
_
(
"Cannot make path relative (target volume different from board file volume)!"
),
wxMessageBox
(
_
(
"Cannot make path relative (target volume different from board file volume)!"
),
_
(
"Plot Output Directory"
),
wxOK
|
wxICON_ERROR
);
}
...
...
@@ -201,6 +203,7 @@ void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
m_outputDirectory
=
m_outputDirectoryName
->
GetValue
();
}
void
DIALOG_SVG_PRINT
::
SetPenWidth
()
{
int
pensize
=
ReturnValueFromTextCtrl
(
*
m_DialogDefaultPenSize
);
...
...
@@ -219,6 +222,7 @@ void DIALOG_SVG_PRINT::SetPenWidth()
m_DialogDefaultPenSize
->
SetValue
(
ReturnStringFromValue
(
g_UserUnit
,
pensize
)
);
}
void
DIALOG_SVG_PRINT
::
ExportSVGFile
(
bool
aOnlyOneFile
)
{
m_outputDirectory
=
m_outputDirectoryName
->
GetValue
();
...
...
@@ -227,9 +231,16 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
// absolute form). Bail if it fails
wxFileName
outputDir
=
wxFileName
::
DirName
(
m_outputDirectory
);
wxString
boardFilename
=
m_board
->
GetFileName
();
WX_TEXT_CTRL_REPORTER
reporter
(
m_messagesBox
);
if
(
!
EnsureOutputDirectory
(
&
outputDir
,
boardFilename
,
m_messagesBox
)
)
if
(
!
EnsureOutputDirectory
(
&
outputDir
,
boardFilename
,
&
reporter
)
)
{
wxString
msg
;
msg
.
Printf
(
_
(
"Could not write plot files to folder
\"
%s
\"
."
),
GetChars
(
outputDir
.
GetPath
()
)
);
DisplayError
(
this
,
msg
);
return
;
}
m_printMirror
=
m_printMirrorOpt
->
GetValue
();
m_printBW
=
m_ModeColorOption
->
GetSelection
();
...
...
@@ -245,9 +256,11 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
}
wxString
msg
;
for
(
LAYER_NUM
layer
=
FIRST_LAYER
;
layer
<
NB_PCB_LAYERS
;
++
layer
)
{
LAYER_MSK
currlayer_mask
=
GetLayerMask
(
layer
);
if
(
(
printMaskLayer
&
currlayer_mask
)
==
0
)
continue
;
...
...
@@ -257,7 +270,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
{
m_printMaskLayer
=
printMaskLayer
;
suffix
=
wxT
(
"-brd"
);
}
}
else
{
m_printMaskLayer
=
currlayer_mask
;
...
...
@@ -320,8 +333,8 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName )
LOCALE_IO
toggle
;
SVG_PLOTTER
*
plotter
=
(
SVG_PLOTTER
*
)
StartPlotBoard
(
m_board
,
&
m_plotOpts
,
aFullFileName
,
wxEmptyString
);
&
m_plotOpts
,
aFullFileName
,
wxEmptyString
);
if
(
plotter
)
{
...
...
@@ -387,6 +400,5 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
m_parent
->
OnModify
();
}
EndModal
(
0
);
}
pcbnew/dialogs/dialog_plot.cpp
View file @
f78497bf
...
...
@@ -31,14 +31,13 @@
#include <wxPcbStruct.h>
#include <pcbplot.h>
#include <base_units.h>
#include <macros.h>
#include <reporter.h>
#include <class_board.h>
#include <plotcontroller.h>
#include <wx/ffile.h>
#include <dialog_plot.h>
/**
* Class DIALOG_PLOT
*/
DIALOG_PLOT
::
DIALOG_PLOT
(
PCB_EDIT_FRAME
*
aParent
)
:
DIALOG_PLOT_BASE
(
aParent
),
m_parent
(
aParent
),
...
...
@@ -102,7 +101,6 @@ void DIALOG_PLOT::Init_Dialog()
msg
=
ReturnStringFromValue
(
g_UserUnit
,
m_brdSettings
.
m_SolderMaskMinWidth
,
true
);
m_SolderMaskMinWidthCurrValue
->
SetLabel
(
msg
);
// Set units and value for HPGL pen size (this param in in mils).
AddUnitSymbol
(
*
m_textPenSize
,
g_UserUnit
);
msg
=
ReturnStringFromValue
(
g_UserUnit
,
...
...
@@ -163,7 +161,7 @@ void DIALOG_PLOT::Init_Dialog()
m_layerList
.
push_back
(
layer
);
checkIndex
=
m_layerCheckListBox
->
Append
(
m_board
->
GetLayerName
(
layer
)
);
if
(
m_plotOpts
.
GetLayerSelection
()
&
GetLayerMask
(
layer
)
)
if
(
m_plotOpts
.
GetLayerSelection
()
&
GetLayerMask
(
layer
)
)
m_layerCheckListBox
->
Check
(
checkIndex
);
}
...
...
@@ -224,12 +222,14 @@ void DIALOG_PLOT::OnClose( wxCloseEvent& event )
EndModal
(
0
);
}
// A helper function to show a popup menu, when the dialog is right clicked.
void
DIALOG_PLOT
::
OnRightClick
(
wxMouseEvent
&
event
)
{
PopupMenu
(
m_popMenu
);
}
// Select or deselect groups of layers in the layers list:
#include <layers_id_colors_and_visibility.h>
void
DIALOG_PLOT
::
OnPopUpLayers
(
wxCommandEvent
&
event
)
...
...
@@ -283,6 +283,7 @@ void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event )
}
}
void
DIALOG_PLOT
::
CreateDrillFile
(
wxCommandEvent
&
event
)
{
m_parent
->
InstallDrillFrame
(
event
);
...
...
@@ -329,8 +330,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
wxString
boardFilePath
=
(
(
wxFileName
)
m_parent
->
GetBoard
()
->
GetFileName
()
).
GetPath
();
if
(
!
dirName
.
MakeRelativeTo
(
boardFilePath
)
)
wxMessageBox
(
_
(
"Cannot make path relative (target volume different from board file volume)!"
),
wxMessageBox
(
_
(
"Cannot make path relative (target volume different from board file volume)!"
),
_
(
"Plot Output Directory"
),
wxOK
|
wxICON_ERROR
);
}
...
...
@@ -354,6 +354,7 @@ PlotFormat DIALOG_PLOT::GetPlotFormat()
return
plotFmt
[
m_plotFormatOpt
->
GetSelection
()
];
}
// Enable or disable widgets according to the plot format selected
// and clear also some optional values
void
DIALOG_PLOT
::
SetPlotFormat
(
wxCommandEvent
&
event
)
...
...
@@ -533,6 +534,8 @@ static bool setDouble( double* aResult, double aValue, double aMin, double aMax
*
aResult
=
aValue
;
return
true
;
}
static
bool
setInt
(
int
*
aResult
,
int
aValue
,
int
aMin
,
int
aMax
)
{
if
(
aValue
<
aMin
)
...
...
@@ -691,3 +694,126 @@ void DIALOG_PLOT::applyPlotSettings()
m_parent
->
OnModify
();
}
}
void
DIALOG_PLOT
::
Plot
(
wxCommandEvent
&
event
)
{
applyPlotSettings
();
// Create output directory if it does not exist (also transform it in
// absolute form). Bail if it fails
wxFileName
outputDir
=
wxFileName
::
DirName
(
m_plotOpts
.
GetOutputDirectory
()
);
wxString
boardFilename
=
m_parent
->
GetBoard
()
->
GetFileName
();
WX_TEXT_CTRL_REPORTER
reporter
(
m_messagesBox
);
if
(
!
EnsureOutputDirectory
(
&
outputDir
,
boardFilename
,
&
reporter
)
)
{
wxString
msg
;
msg
.
Printf
(
_
(
"Could not write plot files to folder
\"
%s
\"
."
),
GetChars
(
outputDir
.
GetPath
()
)
);
DisplayError
(
this
,
msg
);
return
;
}
m_plotOpts
.
SetAutoScale
(
false
);
m_plotOpts
.
SetScale
(
1
);
switch
(
m_plotOpts
.
GetScaleSelection
()
)
{
default
:
break
;
case
0
:
// Autoscale option
m_plotOpts
.
SetAutoScale
(
true
);
break
;
case
2
:
// 3:2 option
m_plotOpts
.
SetScale
(
1.5
);
break
;
case
3
:
// 2:1 option
m_plotOpts
.
SetScale
(
2
);
break
;
case
4
:
// 3:1 option
m_plotOpts
.
SetScale
(
3
);
break
;
}
/* If the scale factor edit controls are disabled or the scale value
* is 0, don't adjust the base scale factor. This fixes a bug when
* the default scale adjust is initialized to 0 and saved in program
* settings resulting in a divide by zero fault.
*/
if
(
m_fineAdjustXscaleOpt
->
IsEnabled
()
&&
m_XScaleAdjust
!=
0.0
)
m_plotOpts
.
SetFineScaleAdjustX
(
m_XScaleAdjust
);
if
(
m_fineAdjustYscaleOpt
->
IsEnabled
()
&&
m_YScaleAdjust
!=
0.0
)
m_plotOpts
.
SetFineScaleAdjustY
(
m_YScaleAdjust
);
if
(
m_PSFineAdjustWidthOpt
->
IsEnabled
()
)
m_plotOpts
.
SetWidthAdjust
(
m_PSWidthAdjust
);
wxString
file_ext
(
GetDefaultPlotExtension
(
m_plotOpts
.
GetFormat
()
)
);
// Test for a reasonable scale value
// XXX could this actually happen? isn't it constrained in the apply
// function?
if
(
m_plotOpts
.
GetScale
()
<
PLOT_MIN_SCALE
)
DisplayInfoMessage
(
this
,
_
(
"Warning: Scale option set to a very small value"
)
);
if
(
m_plotOpts
.
GetScale
()
>
PLOT_MAX_SCALE
)
DisplayInfoMessage
(
this
,
_
(
"Warning: Scale option set to a very large value"
)
);
// Save the current plot options in the board
m_parent
->
SetPlotSettings
(
m_plotOpts
);
for
(
LAYER_NUM
layer
=
FIRST_LAYER
;
layer
<
NB_PCB_LAYERS
;
++
layer
)
{
if
(
m_plotOpts
.
GetLayerSelection
()
&
GetLayerMask
(
layer
)
)
{
// Pick the basename from the board file
wxFileName
fn
(
boardFilename
);
// Use Gerber Extensions based on layer number
// (See http://en.wikipedia.org/wiki/Gerber_File)
if
(
(
m_plotOpts
.
GetFormat
()
==
PLOT_FORMAT_GERBER
)
&&
m_useGerberExtensions
->
GetValue
()
)
file_ext
=
GetGerberExtension
(
layer
);
// Create file name (from the English layer name for non copper layers).
BuildPlotFileName
(
&
fn
,
outputDir
.
GetPath
(),
m_board
->
GetStandardLayerName
(
layer
),
file_ext
);
LOCALE_IO
toggle
;
BOARD
*
board
=
m_parent
->
GetBoard
();
PLOTTER
*
plotter
=
StartPlotBoard
(
board
,
&
m_plotOpts
,
fn
.
GetFullPath
(),
wxEmptyString
);
// Print diags in messages box:
wxString
msg
;
if
(
plotter
)
{
PlotOneBoardLayer
(
board
,
plotter
,
layer
,
m_plotOpts
);
plotter
->
EndPlot
();
delete
plotter
;
msg
.
Printf
(
_
(
"Plot file <%s> created"
),
GetChars
(
fn
.
GetFullPath
()
)
);
}
else
msg
.
Printf
(
_
(
"Unable to create <%s>"
),
GetChars
(
fn
.
GetFullPath
()
)
);
msg
<<
wxT
(
"
\n
"
);
m_messagesBox
->
AppendText
(
msg
);
}
}
// If no layer selected, we have nothing plotted.
// Prompt user if it happens because he could think there is a bug in Pcbnew.
if
(
!
m_plotOpts
.
GetLayerSelection
()
)
DisplayError
(
this
,
_
(
"No layer selected"
)
);
}
pcbnew/pcbframe.cpp
View file @
f78497bf
...
...
@@ -53,6 +53,7 @@
#include <module_editor_frame.h>
#include <dialog_SVG_print.h>
#include <dialog_helpers.h>
#include <dialog_plot.h>
#include <convert_from_iu.h>
#if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
...
...
@@ -853,3 +854,9 @@ void PCB_EDIT_FRAME::OnSelectAutoPlaceMode( wxCommandEvent& aEvent )
}
}
void
PCB_EDIT_FRAME
::
ToPlotter
(
wxCommandEvent
&
event
)
{
DIALOG_PLOT
dlg
(
this
);
dlg
.
ShowModal
();
}
pcbnew/pcbplot.cpp
View file @
f78497bf
/**
* @file pcbnew/pcbplot.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
...
...
@@ -27,6 +23,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pcbnew/pcbplot.cpp
*/
#include <fctsys.h>
#include <plot_common.h>
#include <confirm.h>
...
...
@@ -34,6 +34,7 @@
#include <pcbplot.h>
#include <pcbstruct.h>
#include <base_units.h>
#include <reporter.h>
#include <class_board.h>
#include <pcbnew.h>
#include <plotcontroller.h>
...
...
@@ -43,9 +44,7 @@
#include <macros.h>
/** Get the 'traditional' gerber extension depending on the layer
*/
static
wxString
GetGerberExtension
(
LAYER_NUM
layer
)
/*{{{*/
wxString
GetGerberExtension
(
LAYER_NUM
layer
)
{
switch
(
layer
)
{
...
...
@@ -107,17 +106,13 @@ static wxString GetGerberExtension( LAYER_NUM layer )/*{{{*/
default:
return
wxString
(
wxT
(
"gbr"
)
);
}
}
/*}}}*/
}
/* Complete a plot filename: forces the output directory,
* add a suffix to the name and sets the specified extension
* the suffix is usually the layer name
* replaces not allowed chars in suffix by '_'
*/
void
BuildPlotFileName
(
wxFileName
*
aFilename
,
const
wxString
&
aOutputDir
,
const
wxString
&
aSuffix
,
const
wxString
&
aExtension
)
void
BuildPlotFileName
(
wxFileName
*
aFilename
,
const
wxString
&
aOutputDir
,
const
wxString
&
aSuffix
,
const
wxString
&
aExtension
)
{
aFilename
->
SetPath
(
aOutputDir
);
...
...
@@ -141,190 +136,73 @@ void BuildPlotFileName( wxFileName *aFilename,
aFilename
->
SetName
(
aFilename
->
GetName
()
+
wxT
(
"-"
)
+
suffix
);
}
/*
* Fix the output directory pathname to absolute and ensure it exists
* (Creates it if not exists)
*/
bool
EnsureOutputDirectory
(
wxFileName
*
aOutputDir
,
bool
EnsureOutputDirectory
(
wxFileName
*
aOutputDir
,
const
wxString
&
aBoardFilename
,
wxTextCtrl
*
aMessageBox
)
REPORTER
*
aReporter
)
{
wxString
msg
;
wxString
boardFilePath
=
wxFileName
(
aBoardFilename
).
GetPath
();
if
(
!
aOutputDir
->
MakeAbsolute
(
boardFilePath
)
)
{
wxString
msg
;
msg
.
Printf
(
_
(
"Cannot make <%s> absolute with respect to <%s>!"
),
GetChars
(
aOutputDir
->
GetPath
()
),
GetChars
(
boardFilePath
)
);
wxMessageBox
(
msg
,
_
(
"Plot"
),
wxOK
|
wxICON_ERROR
);
if
(
aReporter
)
{
msg
.
Printf
(
_
(
"*** Error: cannot make path <%s> absolute with respect to <%s>! ***"
),
GetChars
(
aOutputDir
->
GetPath
()
),
GetChars
(
boardFilePath
)
);
aReporter
->
Report
(
msg
);
}
return
false
;
}
wxString
outputPath
(
aOutputDir
->
GetPath
()
);
if
(
!
wxFileName
::
DirExists
(
outputPath
)
)
{
if
(
wxMkdir
(
outputPath
)
)
{
if
(
a
MessageBox
)
if
(
a
Reporter
)
{
wxString
msg
;
msg
.
Printf
(
_
(
"Directory <%s> created.
\n
"
),
GetChars
(
outputPath
)
);
aMessageBox
->
AppendText
(
msg
);
msg
.
Printf
(
_
(
"Output directory <%s> created.
\n
"
),
GetChars
(
outputPath
)
);
aReporter
->
Report
(
msg
);
return
true
;
}
}
else
{
if
(
aMessageBox
)
wxMessageBox
(
_
(
"Cannot create output directory!"
),
_
(
"Plot"
),
wxOK
|
wxICON_ERROR
);
return
false
;
}
}
return
true
;
}
/*
* DIALOG_PLOT:Plot
* Actually creates the files
*/
void
DIALOG_PLOT
::
Plot
(
wxCommandEvent
&
event
)
{
applyPlotSettings
();
// Create output directory if it does not exist (also transform it in
// absolute form). Bail if it fails
wxFileName
outputDir
=
wxFileName
::
DirName
(
m_plotOpts
.
GetOutputDirectory
()
);
wxString
boardFilename
=
m_parent
->
GetBoard
()
->
GetFileName
();
if
(
!
EnsureOutputDirectory
(
&
outputDir
,
boardFilename
,
m_messagesBox
)
)
return
;
m_plotOpts
.
SetAutoScale
(
false
);
m_plotOpts
.
SetScale
(
1
);
switch
(
m_plotOpts
.
GetScaleSelection
()
)
{
default
:
break
;
case
0
:
// Autoscale option
m_plotOpts
.
SetAutoScale
(
true
);
break
;
case
2
:
// 3:2 option
m_plotOpts
.
SetScale
(
1.5
);
break
;
case
3
:
// 2:1 option
m_plotOpts
.
SetScale
(
2
);
break
;
case
4
:
// 3:1 option
m_plotOpts
.
SetScale
(
3
);
break
;
}
/* If the scale factor edit controls are disabled or the scale value
* is 0, don't adjust the base scale factor. This fixes a bug when
* the default scale adjust is initialized to 0 and saved in program
* settings resulting in a divide by zero fault.
*/
if
(
m_fineAdjustXscaleOpt
->
IsEnabled
()
&&
m_XScaleAdjust
!=
0.0
)
m_plotOpts
.
SetFineScaleAdjustX
(
m_XScaleAdjust
);
if
(
m_fineAdjustYscaleOpt
->
IsEnabled
()
&&
m_YScaleAdjust
!=
0.0
)
m_plotOpts
.
SetFineScaleAdjustY
(
m_YScaleAdjust
);
if
(
m_PSFineAdjustWidthOpt
->
IsEnabled
()
)
m_plotOpts
.
SetWidthAdjust
(
m_PSWidthAdjust
);
wxString
file_ext
(
GetDefaultPlotExtension
(
m_plotOpts
.
GetFormat
()
)
);
// Test for a reasonable scale value
// XXX could this actually happen? isn't it constrained in the apply
// function?
if
(
m_plotOpts
.
GetScale
()
<
PLOT_MIN_SCALE
)
DisplayInfoMessage
(
this
,
_
(
"Warning: Scale option set to a very small value"
)
);
if
(
m_plotOpts
.
GetScale
()
>
PLOT_MAX_SCALE
)
DisplayInfoMessage
(
this
,
_
(
"Warning: Scale option set to a very large value"
)
);
// Save the current plot options in the board
m_parent
->
SetPlotSettings
(
m_plotOpts
);
for
(
LAYER_NUM
layer
=
FIRST_LAYER
;
layer
<
NB_PCB_LAYERS
;
++
layer
)
{
if
(
m_plotOpts
.
GetLayerSelection
()
&
GetLayerMask
(
layer
)
)
{
// Pick the basename from the board file
wxFileName
fn
(
boardFilename
);
// Use Gerber Extensions based on layer number
// (See http://en.wikipedia.org/wiki/Gerber_File)
if
(
(
m_plotOpts
.
GetFormat
()
==
PLOT_FORMAT_GERBER
)
&&
m_useGerberExtensions
->
GetValue
()
)
file_ext
=
GetGerberExtension
(
layer
);
// Create file name (from the English layer name for non copper layers).
BuildPlotFileName
(
&
fn
,
outputDir
.
GetPath
(),
m_board
->
GetStandardLayerName
(
layer
),
file_ext
);
LOCALE_IO
toggle
;
BOARD
*
board
=
m_parent
->
GetBoard
();
PLOTTER
*
plotter
=
StartPlotBoard
(
board
,
&
m_plotOpts
,
fn
.
GetFullPath
(),
wxEmptyString
);
// Print diags in messages box:
wxString
msg
;
if
(
plotter
)
if
(
aReporter
)
{
PlotOneBoardLayer
(
board
,
plotter
,
layer
,
m_plotOpts
);
plotter
->
EndPlot
();
delete
plotter
;
msg
.
Printf
(
_
(
"Plot file <%s> created"
),
GetChars
(
fn
.
GetFullPath
()
)
);
msg
.
Printf
(
_
(
"*** Error: cannot create output directory <%s>! ***
\n
"
),
GetChars
(
outputPath
)
);
aReporter
->
Report
(
msg
);
}
else
msg
.
Printf
(
_
(
"Unable to create <%s>"
),
GetChars
(
fn
.
GetFullPath
()
)
);
msg
<<
wxT
(
"
\n
"
);
m_messagesBox
->
AppendText
(
msg
);
return
false
;
}
}
// If no layer selected, we have nothing plotted.
// Prompt user if it happens because he could think there is a bug in Pcbnew.
if
(
!
m_plotOpts
.
GetLayerSelection
()
)
DisplayError
(
this
,
_
(
"No layer selected"
)
);
return
true
;
}
void
PCB_EDIT_FRAME
::
ToPlotter
(
wxCommandEvent
&
event
)
{
DIALOG_PLOT
dlg
(
this
);
dlg
.
ShowModal
();
}
/** Batch plotter constructor, nothing interesting here */
PLOT_CONTROLLER
::
PLOT_CONTROLLER
(
BOARD
*
aBoard
)
:
m_plotter
(
NULL
),
m_board
(
aBoard
)
{
}
/** Batch plotter destructor, ensures that the last plot is closed */
PLOT_CONTROLLER
::~
PLOT_CONTROLLER
()
{
ClosePlot
();
}
/* IMPORTANT THING TO KNOW: the locale during plots *MUST* be kept as
* C/POSIX using a LOCALE_IO object on the stack. This even when
* opening/closing the plotfile, since some drivers do I/O even then */
/** Close the current plot, nothing happens if it isn't open */
void
PLOT_CONTROLLER
::
ClosePlot
()
{
LOCALE_IO
toggle
;
...
...
@@ -337,10 +215,9 @@ void PLOT_CONTROLLER::ClosePlot()
}
}
/** Open a new plotfile; works as a factory for plotter objects
*/
bool
PLOT_CONTROLLER
::
OpenPlotfile
(
const
wxString
&
aSuffix
,
/*{{{*/
PlotFormat
aFormat
,
bool
PLOT_CONTROLLER
::
OpenPlotfile
(
const
wxString
&
aSuffix
,
PlotFormat
aFormat
,
const
wxString
&
aSheetDesc
)
{
LOCALE_IO
toggle
;
...
...
@@ -358,20 +235,20 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix, /*{{{*/
wxString
outputDirName
=
m_plotOpts
.
GetOutputDirectory
()
;
wxFileName
outputDir
=
wxFileName
::
DirName
(
outputDirName
);
wxString
boardFilename
=
m_board
->
GetFileName
();
if
(
EnsureOutputDirectory
(
&
outputDir
,
boardFilename
,
NULL
)
)
if
(
EnsureOutputDirectory
(
&
outputDir
,
boardFilename
)
)
{
wxFileName
fn
(
boardFilename
);
BuildPlotFileName
(
&
fn
,
outputDirName
,
aSuffix
,
GetDefaultPlotExtension
(
aFormat
)
);
BuildPlotFileName
(
&
fn
,
outputDirName
,
aSuffix
,
GetDefaultPlotExtension
(
aFormat
)
);
m_plotter
=
StartPlotBoard
(
m_board
,
&
m_plotOpts
,
fn
.
GetFullPath
(),
aSheetDesc
);
m_plotter
=
StartPlotBoard
(
m_board
,
&
m_plotOpts
,
fn
.
GetFullPath
(),
aSheetDesc
);
}
return
(
m_plotter
!=
NULL
);
}
/*}}}*/
}
/** Plot a single layer on the current plotfile */
bool
PLOT_CONTROLLER
::
PlotLayer
(
LAYER_NUM
aLayer
)
/*{{{*/
bool
PLOT_CONTROLLER
::
PlotLayer
(
LAYER_NUM
aLayer
)
{
LOCALE_IO
toggle
;
...
...
@@ -383,7 +260,8 @@ bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer )/*{{{*/
PlotOneBoardLayer
(
m_board
,
m_plotter
,
aLayer
,
m_plotOpts
);
return
true
;
}
/*}}}*/
}
void
PLOT_CONTROLLER
::
SetColorMode
(
bool
aColorMode
)
{
...
...
@@ -393,6 +271,7 @@ void PLOT_CONTROLLER::SetColorMode( bool aColorMode )
m_plotter
->
SetColorMode
(
aColorMode
);
}
bool
PLOT_CONTROLLER
::
GetColorMode
()
{
if
(
!
m_plotter
)
...
...
@@ -400,4 +279,3 @@ bool PLOT_CONTROLLER::GetColorMode()
return
m_plotter
->
GetColorMode
();
}
pcbnew/pcbplot.h
View file @
f78497bf
...
...
@@ -44,6 +44,7 @@ class PCB_TARGET;
class
TEXTE_MODULE
;
class
ZONE_CONTAINER
;
class
BOARD
;
class
REPORTER
;
// Shared Config keys for plot and print
#define OPTKEY_LAYERBASE wxT( "PlotLayer_%d" )
...
...
@@ -218,16 +219,16 @@ void PlotSilkScreen( BOARD* aBoard, PLOTTER* aPlotter, LAYER_MSK aLayerMask,
/**
* Function EnsureOutputDirectory (helper function)
*
Fix the output directory pathname to absolute and ensure it exists
*
(Creates it if not exists)
*
@param aOutputDir = the wxFileName to modify
*
(contains the absolute or relative to the board path
* @param a
BoardFilename = the board full filename
* @
param aMessageBox = a wxMessageBox to show message (can be NULL)
*
make \a OutputDir absolute and creates the path if it doesn't exist.
*
@param aOutputDir the wxFileName containing the full path and file name to modify. The path
*
may be absolute or relative to \a aBoardFilename .
*
@param aBoardFilename the board full path and filename.
* @param a
Reporter a point to a REPORTER object use to show messages (can be NULL)
* @
return true if \a aOutputDir already exists or was successfully created.
*/
bool
EnsureOutputDirectory
(
wxFileName
*
aOutputDir
,
bool
EnsureOutputDirectory
(
wxFileName
*
aOutputDir
,
const
wxString
&
aBoardFilename
,
wxTextCtrl
*
aMessageBox
);
REPORTER
*
aReporter
=
NULL
);
/**
* Function BuildPlotFileName (helper function)
...
...
@@ -236,16 +237,24 @@ bool EnsureOutputDirectory( wxFileName* aOutputDir,
* the suffix is usually the layer name
* replaces not allowed chars in suffix by '_'
* @param aFilename = the wxFileName to initialize
* Cont
ia
ns the base filename
* Cont
ai
ns the base filename
* @param aOutputDir = the path
* @param aSuffix = the suffix to add to the base filename
* @param aExtension = the file extension
*/
void
BuildPlotFileName
(
wxFileName
*
aFilename
,
void
BuildPlotFileName
(
wxFileName
*
aFilename
,
const
wxString
&
aOutputDir
,
const
wxString
&
aSuffix
,
const
wxString
&
aExtension
);
/**
* Function GetGerberExtension
* @return the appropriate Gerber file extension for \a aLayer
*/
extern
wxString
GetGerberExtension
(
LAYER_NUM
aLayer
);
// PLOTGERB.CPP
void
SelectD_CODE_For_LineDraw
(
PLOTTER
*
plotter
,
int
aSize
);
...
...
pcbnew/plotcontroller.h
View file @
f78497bf
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Lorenzo Marcantonio, <l.marcantonio@logossrl.com>
* Copyright (C) 1992-2012 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
*/
/**
* @file pcbnew/pcbplot.h
*/
...
...
@@ -10,34 +34,46 @@
class
PLOTTER
;
class
BOARD
;
class
REPORTER
;
/**
/**
* Batch plotter state object. Keeps the plot options and handles multiple
* plot requests
*/
class
PLOT_CONTROLLER
{
public
:
/** Batch plotter constructor, nothing interesting here */
PLOT_CONTROLLER
(
BOARD
*
aBoard
);
/** Batch plotter destructor, ensures that the last plot is closed */
~
PLOT_CONTROLLER
();
PCB_PLOT_PARAMS
*
AccessPlotOpts
()
{
return
&
m_plotOpts
;
}
bool
IsPlotOpen
()
const
{
return
m_plotter
!=
NULL
;
}
/** Close the current plot, nothing happens if it isn't open */
void
ClosePlot
();
/** Open a new plotfile; works as a factory for plotter objects
*/
bool
OpenPlotfile
(
const
wxString
&
aSuffix
,
PlotFormat
aFormat
,
const
wxString
&
aSheetDesc
);
/** Plot a single layer on the current plotfile */
bool
PlotLayer
(
LAYER_NUM
layer
);
void
SetColorMode
(
bool
aColorMode
);
bool
GetColorMode
();
private
:
/// Option bank
PCB_PLOT_PARAMS
m_plotOpts
;
/// This is the plotter object; it starts NULL and become instantiated
// when a plotfile is requested
PLOTTER
*
m_plotter
;
//
/
when a plotfile is requested
PLOTTER
*
m_plotter
;
/// The board we're plotting
BOARD
*
m_board
;
...
...
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