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
Expand all
Show 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
;
...
...
@@ -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
,
...
...
@@ -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
This diff is collapsed.
Click to expand it.
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
,
const
wxString
&
aBoardFilename
,
wxTextCtrl
*
aMessageBox
);
REPORTER
*
aReporter
=
NULL
);
/**
* Function BuildPlotFileName (helper function)
...
...
@@ -236,7 +237,7 @@ 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
...
...
@@ -246,6 +247,14 @@ void BuildPlotFileName( wxFileName* aFilename,
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,6 +34,8 @@
class
PLOTTER
;
class
BOARD
;
class
REPORTER
;
/**
* Batch plotter state object. Keeps the plot options and handles multiple
...
...
@@ -18,14 +44,24 @@ class BOARD;
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
);
...
...
@@ -36,8 +72,8 @@ private:
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