26#include <wx/stdpaths.h>
27#include <wx/process.h>
29#include <wx/filedlg.h>
84 m_editFrame( aEditFrame ),
86 m_originX( aEditFrame, m_originXLabel, m_originXCtrl, m_originXUnits ),
87 m_originY( aEditFrame, m_originYLabel, m_originYCtrl, m_originYUnits ),
88 m_boardPath( aBoardPath )
94 { wxID_CANCEL,
_(
"Close" ) } } );
114 size_t bad_count = 0;
120 if( model.m_Scale.x != 1.0 || model.m_Scale.y != 1.0 || model.m_Scale.z != 1.0 )
122 bad_scales.Append( wxS(
"\n") );
123 bad_scales.Append( model.m_Filename );
132 if( !bad_scales.empty() && !
Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning )
134 wxString extendedMsg =
_(
"Non-unity scaled models:" ) + wxT(
"\n" ) + bad_scales;
137 "mechanical export." ),
138 _(
"Model Scale Warning" ), wxOK | wxICON_WARNING );
139 msgDlg.SetExtendedMessage( extendedMsg );
162 brdFile.SetExt( wxT(
"step" ) );
212 wxCommandEvent
dummy;
225 wxFileName autosaveProjFile;
240 autosaveProjFile = brdFile;
241 autosaveProjFile.SetName( autosaveFileName );
242 autosaveProjFile.SetExt(
"kicad_pro" );
246 brdFile.SetName( autosaveFileName );
253 if( !autosaveProjFile.GetFullPath().IsEmpty() )
254 wxRemoveFile( autosaveProjFile.GetFullPath() );
275 wxString
filter =
_(
"STEP files" )
277 +
_(
"Binary glTF files" )
281 +
_(
"BREP (OCCT) files" )
291 wxFileName fn(
Prj().AbsolutePath(
path ) );
293 wxFileDialog dlg(
this,
_(
"3D Model Output File" ), fn.GetPath(), fn.GetFullName(),
filter, wxFD_SAVE );
295 if( dlg.ShowModal() == wxID_CANCEL )
298 path = dlg.GetPath();
301 fn = wxFileName(
path );
319 int sepIdx = std::max(
path.Find(
'/',
true ),
path.Find(
'\\',
true ) );
320 int dotIdx =
path.Find(
'.',
true );
322 if( dotIdx == -1 || dotIdx < sepIdx )
323 path <<
'.' << newExt;
325 path =
path.Mid( 0, dotIdx ) <<
'.' << newExt;
355 case 0: tolerance = 0.001;
break;
357 case 1: tolerance = 0.01;
break;
358 case 2: tolerance = 0.1;
break;
364 std::function<bool( wxString* )> textResolver =
365 [&]( wxString* token ) ->
bool
393 "%.3f mm tolerance.\n"
394 "Run DRC for a full analysis." ),
399 wxFileName fn(
Prj().AbsolutePath(
path ) );
403 msg.Printf(
_(
"File '%s' already exists. Do you want overwrite this file?" ), fn.GetFullPath() );
405 if( wxMessageBox( msg,
_(
"STEP/GLTF Export" ), wxYES_NO | wxICON_QUESTION,
this ) == wxNO )
409 wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() );
412 if( appK2S.GetPath().Find(
"/Contents/Applications/pcbnew.app/Contents/MacOS" ) != wxNOT_FOUND )
414 appK2S.AppendDir( wxT(
".." ) );
415 appK2S.AppendDir( wxT(
".." ) );
416 appK2S.AppendDir( wxT(
".." ) );
417 appK2S.AppendDir( wxT(
".." ) );
418 appK2S.AppendDir( wxT(
"MacOS" ) );
421 if( wxGetEnv( wxT(
"KICAD_RUN_FROM_BUILD_DIR" ),
nullptr ) )
423 appK2S.RemoveLastDir();
424 appK2S.AppendDir(
"kicad" );
428 appK2S.SetName( wxT(
"kicad-cli" ) );
431 wxString cmdK2S = wxT(
"\"" );
432 cmdK2S.Append( appK2S.GetFullPath() );
433 cmdK2S.Append( wxT(
"\"" ) );
435 cmdK2S.Append( wxT(
" pcb" ) );
436 cmdK2S.Append( wxT(
" export" ) );
438 cmdK2S.Append( wxT(
" " ) );
442 cmdK2S.Append( wxT(
" --no-unspecified" ) );
445 cmdK2S.Append( wxT(
" --no-dnp" ) );
448 cmdK2S.Append( wxT(
" --subst-models" ) );
451 cmdK2S.Append( wxT(
" --no-optimize-step" ) );
454 cmdK2S.Append( wxT(
" --no-board-body" ) );
457 cmdK2S.Append( wxT(
" --no-components" ) );
460 cmdK2S.Append( wxT(
" --include-tracks" ) );
463 cmdK2S.Append( wxT(
" --include-pads" ) );
466 cmdK2S.Append( wxT(
" --include-zones" ) );
469 cmdK2S.Append( wxT(
" --include-inner-copper" ) );
472 cmdK2S.Append( wxT(
" --include-silkscreen" ) );
475 cmdK2S.Append( wxT(
" --include-soldermask" ) );
478 cmdK2S.Append( wxT(
" --fuse-shapes" ) );
481 cmdK2S.Append( wxT(
" --cut-vias-in-body" ) );
484 cmdK2S.Append( wxT(
" --fill-all-vias" ) );
493 cmdK2S.Append( wxString::Format( wxT(
" --net-filter %c%s%c" ),
499 wxArrayString components;
502 std::for_each( selection.
begin(), selection.
end(),
505 if( item->Type() == PCB_FOOTPRINT_T )
506 components.push_back( static_cast<FOOTPRINT*>( item )->GetReference() );
509 cmdK2S.Append( wxString::Format( wxT(
" --component-filter %c%s%c" ),
510 dblquote, wxJoin( components,
',' ), dblquote ) );
514 cmdK2S.Append( wxString::Format( wxT(
" --component-filter %c%s%c" ),
520 cmdK2S.Append( wxT(
" --drill-origin" ) );
524 cmdK2S.Append( wxT(
" --grid-origin" ) );
532 cmdK2S.Append( wxString::Format( wxT(
" --user-origin=%c%.6fx%.6fmm%c" ),
533 quote, xOrg, yOrg, quote ) );
542 cmdK2S.Append( wxString::Format( wxT(
" --user-origin=%c%.6fx%.6fmm%c" ),
543 quote, xOrg, yOrg, quote ) );
547 wxFAIL_MSG( wxT(
"Unsupported origin option: how did we get here?" ) );
552 cmdK2S.Append( wxString::Format( wxT(
" --min-distance=%c%.3fmm%c" ),
553 quote, tolerance, quote ) );
557 cmdK2S.Append( wxString::Format( wxT(
" -f -o %c%s%c" ),
558 dblquote, fn.GetFullPath(), dblquote ) );
562 cmdK2S.Append( wxString::Format( wxT(
" %c%s%c" ), dblquote,
m_boardPath, dblquote ) );
564 wxLogTrace(
traceKiCad2Step, wxT(
"export step command: %s" ), cmdK2S );
constexpr EDA_IU_SCALE pcbIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
bool IsContentModified() const
int ExportSTEP(const TOOL_EVENT &aEvent)
Information pertinent to a Pcbnew printed circuit board.
bool ResolveTextVar(wxString *token, int aDepth) const
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
const FOOTPRINTS & Footprints() const
const wxString & GetFileName() const
PROJECT * GetProject() const
constexpr const Vec GetCenter() const
DO_NOT_SHOW_AGAIN m_DoNotShowAgain
Class DIALOG_EXPORT_STEP_BASE.
wxCheckBox * m_cbExportTracks
wxCheckBox * m_cbSubstModels
wxRadioButton * m_rbOnlySelected
wxRadioButton * m_rbGridOrigin
wxCheckBox * m_cbExportBody
wxCheckBox * m_cbRemoveUnspecified
wxCheckBox * m_cbOverwriteFile
wxCheckBox * m_cbRemoveDNP
wxBoxSizer * bSizerSTEPFile
wxCheckBox * m_cbExportComponents
wxCheckBox * m_cbOptimizeStep
wxCheckBox * m_cbFuseShapes
wxRadioButton * m_rbBoardCenterOrigin
wxTextCtrl * m_outputFileName
wxCheckBox * m_cbExportInnerCopper
wxChoice * m_choiceTolerance
wxTextCtrl * m_txtNetFilter
wxCheckBox * m_cbExportSoldermask
wxCheckBox * m_cbExportPads
wxChoice * m_choiceFormat
wxCheckBox * m_cbExportZones
wxRadioButton * m_rbAllComponents
wxRadioButton * m_rbUserDefinedOrigin
wxCheckBox * m_cbExportSilkscreen
wxRadioButton * m_rbFilteredComponents
wxCheckBox * m_cbCutViasInBody
wxRadioButton * m_rbDrillAndPlotOrigin
wxTextCtrl * m_txtComponentFilter
STD_BITMAP_BUTTON * m_browseButton
wxCheckBox * m_cbFillAllVias
void onFormatChoice(wxCommandEvent &event) override
void OnFmtChoiceOptionChanged()
void onCbExportComponents(wxCommandEvent &event) override
PCB_EDIT_FRAME * m_editFrame
void OnComponentModeChange(wxCommandEvent &event) override
DIALOG_EXPORT_STEP(PCB_EDIT_FRAME *aEditFrame, const wxString &aBoardPath)
void onUpdateXPos(wxUpdateUIEvent &aEvent) override
JOB_EXPORT_PCB_3D * m_job
bool TransferDataToWindow() override
void onExportButton(wxCommandEvent &aEvent) override
void onUpdateYPos(wxUpdateUIEvent &aEvent) override
void onBrowseClicked(wxCommandEvent &aEvent) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
SETTINGS_MANAGER * GetSettingsManager() const
A base class for most all the KiCad significant classes used in schematics and boards.
double m_BoardOutlinesChainingEpsilon
bool m_IncludeUnspecified
wxString m_ComponentFilter
bool m_UsePcbCenterOrigin
JOB_EXPORT_PCB_3D::FORMAT m_format
wxString GetSettingsDialogTitle() const override
void SetStepFormat(EXPORTER_STEP_PARAMS::FORMAT aFormat)
EXPORTER_STEP_PARAMS m_3dparams
Despite the name; also used for other formats.
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
wxString GetConfiguredOutputPath() const
Returns the configured output path for the job.
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
bool DoNotShowAgain() const
Checks the 'do not show again' setting for the dialog.
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
The main frame for Pcbnew.
bool DoAutoSave()
Perform auto save when the board has been modified and not saved within the auto save interval.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
void SaveProjectCopy(const wxString &aFullPath, PROJECT *aProject=nullptr)
Save a copy of the current project under the given path.
Represent a set of closed polygons.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
bool BuildBoardPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aErrorMax, int aChainingEpsilon, OUTLINE_ERROR_HANDLER *aErrorHandler, bool aAllowUseArcsInPolygons)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
static const std::map< wxString, int > c_formatExtToChoice
static const std::vector< wxString > c_formatCommand
static const std::string BrepFileExtension
static const std::string StepFileAbrvExtension
static const std::string XaoFileExtension
static const std::string GltfBinaryFileExtension
static const std::string StlFileExtension
static const std::string AutoSaveFilePrefix
static const std::string PlyFileExtension
static const std::string StepFileExtension
static const std::string StepZFileAbrvExtension
const wxChar *const traceKiCad2Step
Flag to enable KiCad2Step debug tracing.
This file is part of the common library.
std::optional< V > get_opt(const std::map< wxString, V > &aMap, const wxString &aKey)
PGM_BASE & Pgm()
The global program "get" accessor.
std::vector< FAB_LAYER_COLOR > dummy
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool scaled_3d_models_warning
constexpr double IUTomm(int iu) const
constexpr int mmToIU(double mm) const
wxLogTrace helper definitions.
VECTOR2< double > VECTOR2D
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().