KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_export_step.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2016 Cirilo Bernardo
5 * Copyright (C) 2016-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <wx/log.h>
26#include <wx/stdpaths.h>
27#include <wx/process.h>
28#include <wx/string.h>
29#include <wx/filedlg.h>
30
31#include <pgm_base.h>
32#include <board.h>
33#include <confirm.h>
34#include <kidialog.h>
36#include "dialog_export_step.h"
38#include <footprint.h>
39#include <kiface_base.h>
40#include <locale_io.h>
41#include <math/vector3.h>
42#include <pcb_edit_frame.h>
43#include <pcbnew_settings.h>
44#include <project/project_file.h> // LAST_PATH_TYPE
45#include <reporter.h>
46#include <trace_helpers.h>
49#include <filename_resolver.h>
50#include <core/map_helpers.h>
53
54
55// Maps m_choiceFormat selection to extension (and kicad-cli command)
56static const std::vector<wxString> c_formatCommand = { FILEEXT::StepFileExtension,
62
63// Maps file extensions to m_choiceFormat selection
64static const std::map<wxString, int> c_formatExtToChoice = { { FILEEXT::StepFileExtension, 0 },
71
72
73
74int DIALOG_EXPORT_STEP::m_toleranceLastChoice = -1; // Use default
75int DIALOG_EXPORT_STEP::m_formatLastChoice = -1; // Use default
88
89
90DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aEditFrame, const wxString& aBoardPath ) :
91 DIALOG_EXPORT_STEP( aEditFrame, aEditFrame, aBoardPath )
92{
93}
94
95
97 const wxString& aBoardPath,
98 JOB_EXPORT_PCB_3D* aJob ) :
99 DIALOG_EXPORT_STEP_BASE( aEditFrame ),
100 m_editFrame( aEditFrame ),
101 m_job( aJob ),
102 m_boardPath( aBoardPath )
103{
104 if( m_job == nullptr )
105 {
106 m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
107 SetupStandardButtons( { { wxID_OK, _( "Export" ) },
108 { wxID_CANCEL, _( "Close" ) } } );
109 }
110 else
111 {
112 m_browseButton->Hide();
113 SetupStandardButtons( { { wxID_OK, _( "Save" ) },
114 { wxID_CANCEL, _( "Close" ) } } );
115 }
116
117 // Build default output file name
118 // (last saved filename in project or built from board filename)
120
121 if( path.IsEmpty() )
122 {
123 wxFileName brdFile( m_editFrame->GetBoard()->GetFileName() );
124 brdFile.SetExt( wxT( "step" ) );
125 path = brdFile.GetFullPath();
126 }
127
128 m_outputFileName->SetValue( path );
129
130 Layout();
131 bSizerSTEPFile->Fit( this );
132
133 SetFocus();
134
135 if( !m_job )
136 {
138
140
141 switch( m_origin )
142 {
143 default:
144 case STEP_ORIGIN_PLOT_AXIS: m_rbDrillAndPlotOrigin->SetValue( true ); break;
145 case STEP_ORIGIN_GRID_AXIS: m_rbGridOrigin->SetValue( true ); break;
146 case STEP_ORIGIN_USER: m_rbUserDefinedOrigin->SetValue( true ); break;
147 case STEP_ORIGIN_BOARD_CENTER: m_rbBoardCenterOrigin->SetValue( true ); break;
148 }
149
155
156 m_txtNetFilter->SetValue( m_netFilter );
157 m_cbOptimizeStep->SetValue( m_optimizeStep );
160 m_cbExportTracks->SetValue( m_exportTracks );
161 m_cbExportPads->SetValue( m_exportPads );
162 m_cbExportZones->SetValue( m_exportZones );
166 m_cbFuseShapes->SetValue( m_fuseShapes );
168 m_cbRemoveDNP->SetValue( m_noDNP );
171
173
174 switch( m_componentMode )
175 {
176 case COMPONENT_MODE::EXPORT_ALL: m_rbAllComponents->SetValue( true ); break;
177 case COMPONENT_MODE::EXPORT_SELECTED: m_rbOnlySelected->SetValue( true ); break;
178 case COMPONENT_MODE::CUSTOM_FILTER: m_rbFilteredComponents->SetValue( true ); break;
179 }
180
181 // Sync the enabled states
182 wxCommandEvent dummy;
184
185 m_STEP_OrgUnitChoice->SetSelection( m_originUnits );
186 wxString tmpStr;
187 tmpStr << m_userOriginX;
188 m_STEP_Xorg->SetValue( tmpStr );
189 tmpStr = wxEmptyString;
190 tmpStr << m_userOriginY;
191 m_STEP_Yorg->SetValue( tmpStr );
192 }
193 else
194 {
196 m_rbDrillAndPlotOrigin->SetValue( true );
198 m_rbGridOrigin->SetValue( true );
199 else if( m_job->m_3dparams.m_Origin.x == 0.0 && m_job->m_3dparams.m_Origin.y == 0.0 )
200 m_rbBoardCenterOrigin->SetValue( true );
201 else
202 m_rbUserDefinedOrigin->SetValue( true );
203
206
209
225
227
228 wxCommandEvent dummy;
230
231 m_STEP_OrgUnitChoice->SetSelection( m_originUnits );
232
233 wxString tmpStr;
234 tmpStr << m_userOriginX;
235 m_STEP_Xorg->SetValue( tmpStr );
236 tmpStr = wxEmptyString;
237 tmpStr << m_userOriginY;
238 m_STEP_Yorg->SetValue( tmpStr );
239 }
240
241 wxString bad_scales;
242 size_t bad_count = 0;
243
244 for( FOOTPRINT* fp : m_editFrame->GetBoard()->Footprints() )
245 {
246 for( const FP_3DMODEL& model : fp->Models() )
247 {
248 if( model.m_Scale.x != 1.0 || model.m_Scale.y != 1.0 || model.m_Scale.z != 1.0 )
249 {
250 bad_scales.Append( wxS("\n") );
251 bad_scales.Append( model.m_Filename );
252 bad_count++;
253 }
254 }
255
256 if( bad_count >= 5 )
257 break;
258 }
259
260 if( !bad_scales.empty()
261 && !Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning )
262 {
263 wxString extendedMsg = _( "Non-unity scaled models:" ) + wxT( "\n" ) + bad_scales;
264
265 KIDIALOG msgDlg( m_editFrame, _( "Scaled models detected. "
266 "Model scaling is not reliable for mechanical export." ),
267 _( "Model Scale Warning" ), wxOK | wxICON_WARNING );
268 msgDlg.SetExtendedMessage( extendedMsg );
269 msgDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
270
271 msgDlg.ShowModal();
272
273 if( msgDlg.DoNotShowAgain() )
275 }
276
277 if( m_toleranceLastChoice >= 0 )
279
280 if( m_formatLastChoice >= 0 )
281 m_choiceFormat->SetSelection( m_formatLastChoice );
282 else
283 // ensure the selected fmt and the output file ext are synchronized the first time
284 // the dialog is opened
286
287 // Now all widgets have the size fixed, call FinishDialogSettings
289}
290
291
293{
294 GetOriginOption(); // Update m_origin member.
295
296 PCBNEW_SETTINGS* cfg = nullptr;
297
298 try
299 {
301 }
302 catch( const std::runtime_error& e )
303 {
304 wxFAIL_MSG( e.what() );
305 }
306
307 if( cfg )
308 {
309 cfg->m_ExportStep.origin_mode = static_cast<int>( m_origin );
310 cfg->m_ExportStep.origin_units = m_STEP_OrgUnitChoice->GetSelection();
313
314 double val = 0.0;
315
316 m_STEP_Xorg->GetValue().ToDouble( &val );
317 cfg->m_ExportStep.origin_x = val;
318
319 m_STEP_Yorg->GetValue().ToDouble( &val );
320 cfg->m_ExportStep.origin_y = val;
321
323 cfg->m_ExportStep.no_dnp = m_cbRemoveDNP->GetValue();
324 }
325
326 m_netFilter = m_txtNetFilter->GetValue();
328 m_formatLastChoice = m_choiceFormat->GetSelection();
329 m_optimizeStep = m_cbOptimizeStep->GetValue();
330 m_exportBoardBody = m_cbExportBody->GetValue();
332 m_exportTracks = m_cbExportTracks->GetValue();
333 m_exportPads = m_cbExportPads->GetValue();
334 m_exportZones = m_cbExportZones->GetValue();
338 m_fuseShapes = m_cbFuseShapes->GetValue();
340
341 if( m_rbAllComponents->GetValue() )
343 else if( m_rbOnlySelected->GetValue() )
345 else
347}
348
349
351{
353
354 if( m_rbDrillAndPlotOrigin->GetValue() )
356 else if( m_rbGridOrigin->GetValue() )
358 else if( m_rbUserDefinedOrigin->GetValue() )
360 else if( m_rbBoardCenterOrigin->GetValue() )
362
363 return m_origin;
364}
365
366
367void PCB_EDIT_FRAME::OnExportSTEP( wxCommandEvent& event )
368{
369 wxFileName brdFile = GetBoard()->GetFileName();
370
371 // The project filename (.kicad_pro) of the auto saved board filename, if it is created
372 wxFileName autosaveProjFile;
373
374 if( GetScreen()->IsContentModified() || brdFile.GetFullPath().empty() )
375 {
376 if( !doAutoSave() )
377 {
378 DisplayErrorMessage( this, _( "STEP export failed! "
379 "Please save the PCB and try again" ) );
380 return;
381 }
382
383 wxString autosaveFileName = FILEEXT::AutoSaveFilePrefix + brdFile.GetName();
384
385 // Create a dummy .kicad_pro file for this auto saved board file.
386 // this is useful to use some settings (like project path and name)
387 // Because doAutoSave() works, the target directory exists and is writable
388 autosaveProjFile = brdFile;
389 autosaveProjFile.SetName( autosaveFileName );
390 autosaveProjFile.SetExt( "kicad_pro" );
391
392 // Use auto-saved board for export
393 GetSettingsManager()->SaveProjectCopy( autosaveProjFile.GetFullPath(), GetBoard()->GetProject() );
394 brdFile.SetName( autosaveFileName );
395 }
396
397 DIALOG_EXPORT_STEP dlg( this, brdFile.GetFullPath() );
398 dlg.ShowModal();
399
400 // If a dummy .kicad_pro file is created, delete it now it is useless.
401 if( !autosaveProjFile.GetFullPath().IsEmpty() )
402 wxRemoveFile( autosaveProjFile.GetFullPath() );
403}
404
405
406void DIALOG_EXPORT_STEP::onUpdateUnits( wxUpdateUIEvent& aEvent )
407{
408 aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
409}
410
411
412void DIALOG_EXPORT_STEP::onUpdateXPos( wxUpdateUIEvent& aEvent )
413{
414 aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
415}
416
417
418void DIALOG_EXPORT_STEP::onUpdateYPos( wxUpdateUIEvent& aEvent )
419{
420 aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
421}
422
423
424void DIALOG_EXPORT_STEP::onBrowseClicked( wxCommandEvent& aEvent )
425{
426 // clang-format off
427 wxString filter = _( "STEP files" )
429 + _( "Binary glTF files" )
431 + _( "XAO files" )
433 + _( "BREP (OCCT) files" )
435 + _( "PLY files" )
437 + _( "STL files" )
439 // clang-format on
440
441 // Build the absolute path of current output directory to preselect it in the file browser.
442 wxString path = ExpandEnvVarSubstitutions( m_outputFileName->GetValue(), &Prj() );
443 wxFileName fn( Prj().AbsolutePath( path ) );
444
445 wxFileDialog dlg( this, _( "3D Model Output File" ), fn.GetPath(), fn.GetFullName(), filter,
446 wxFD_SAVE );
447
448 if( dlg.ShowModal() == wxID_CANCEL )
449 return;
450
451 path = dlg.GetPath();
452 m_outputFileName->SetValue( path );
453
454 fn = wxFileName( path );
455
456 if( auto formatChoice = get_opt( c_formatExtToChoice, fn.GetExt().Lower() ) )
457 m_choiceFormat->SetSelection( *formatChoice );
458}
459
460
461void DIALOG_EXPORT_STEP::onFormatChoice( wxCommandEvent& event )
462{
464}
465
466
468{
469 wxString newExt = c_formatCommand[m_choiceFormat->GetSelection()];
470 wxString path = m_outputFileName->GetValue();
471
472 int sepIdx = std::max( path.Find( '/', true ), path.Find( '\\', true ) );
473 int dotIdx = path.Find( '.', true );
474
475 if( dotIdx == -1 || dotIdx < sepIdx )
476 path << '.' << newExt;
477 else
478 path = path.Mid( 0, dotIdx ) << '.' << newExt;
479
480 m_outputFileName->SetValue( path );
482}
483
484
485void DIALOG_EXPORT_STEP::onCbExportComponents( wxCommandEvent& event )
486{
487 bool enable = m_cbExportComponents->GetValue();
488
489 m_rbAllComponents->Enable( enable );
490 m_rbOnlySelected->Enable( enable );
491 m_rbFilteredComponents->Enable( enable );
492 m_txtComponentFilter->Enable( enable && m_rbFilteredComponents->GetValue() );
493}
494
495
496void DIALOG_EXPORT_STEP::OnComponentModeChange( wxCommandEvent& event )
497{
498 m_txtComponentFilter->Enable( m_rbFilteredComponents->GetValue() );
499}
500
501
502void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
503{
504 if( !m_job )
505 {
506 wxString path = m_outputFileName->GetValue();
508
509 // Build the absolute path of current output directory to preselect it in the file browser.
510 std::function<bool( wxString* )> textResolver =
511 [&]( wxString* token ) -> bool
512 {
513 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
514 };
515
516 path = ExpandTextVars( path, &textResolver );
518 path = Prj().AbsolutePath( path );
519
520 if( path.IsEmpty() )
521 {
522 DisplayErrorMessage( this, _( "No filename for output file" ) );
523 return;
524 }
525
526 m_netFilter = m_txtNetFilter->GetValue();
528
529 if( m_rbAllComponents->GetValue() )
531 else if( m_rbOnlySelected->GetValue() )
533 else
535
536 double tolerance; // default value in mm
538 m_formatLastChoice = m_choiceFormat->GetSelection();
539 m_optimizeStep = m_cbOptimizeStep->GetValue();
540 m_exportBoardBody = m_cbExportBody->GetValue();
542 m_exportTracks = m_cbExportTracks->GetValue();
543 m_exportPads = m_cbExportPads->GetValue();
544 m_exportZones = m_cbExportZones->GetValue();
548 m_fuseShapes = m_cbFuseShapes->GetValue();
549
550 switch( m_choiceTolerance->GetSelection() )
551 {
552 case 0: tolerance = 0.001; break;
553 default:
554 case 1: tolerance = 0.01; break;
555 case 2: tolerance = 0.1; break;
556 }
557
558 SHAPE_POLY_SET outline;
559 wxString msg;
560
561 // Check if the board outline is continuous
562 // max dist from one endPt to next startPt to build a closed shape:
563 int chainingEpsilon = pcbIUScale.mmToIU( tolerance );
564
565 // Arc to segment approx error (not critical here: we do not use the outline shape):
566 int maxError = pcbIUScale.mmToIU( 0.005 );
567 bool success = BuildBoardPolygonOutlines( m_editFrame->GetBoard(), outline, maxError,
568 chainingEpsilon, nullptr );
569 if( !success )
570 {
571 DisplayErrorMessage( this, wxString::Format(
572 _( "Board outline is missing or not closed using %.3f mm tolerance.\n"
573 "Run DRC for a full analysis." ), tolerance ) );
574 return;
575 }
576
577 wxFileName fn( Prj().AbsolutePath( path ) );
578
579 if( fn.FileExists() && !GetOverwriteFile() )
580 {
581 msg.Printf( _( "File '%s' already exists. Do you want overwrite this file?" ),
582 fn.GetFullPath() );
583
584 if( wxMessageBox( msg, _( "STEP/GLTF Export" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
585 return;
586 }
587
588 wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() );
589 #ifdef __WXMAC__
590 // On macOS, we have standalone applications inside the main bundle, so we handle that here:
591 if( appK2S.GetPath().Find( "/Contents/Applications/pcbnew.app/Contents/MacOS" ) != wxNOT_FOUND )
592 {
593 appK2S.AppendDir( wxT( ".." ) );
594 appK2S.AppendDir( wxT( ".." ) );
595 appK2S.AppendDir( wxT( ".." ) );
596 appK2S.AppendDir( wxT( ".." ) );
597 appK2S.AppendDir( wxT( "MacOS" ) );
598 }
599 #else
600 if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
601 {
602 appK2S.RemoveLastDir();
603 appK2S.AppendDir( "kicad" );
604 }
605 #endif
606
607 appK2S.SetName( wxT( "kicad-cli" ) );
608 appK2S.Normalize( FN_NORMALIZE_FLAGS );
609
610 wxString cmdK2S = wxT( "\"" );
611 cmdK2S.Append( appK2S.GetFullPath() );
612 cmdK2S.Append( wxT( "\"" ) );
613
614 cmdK2S.Append( wxT( " pcb" ) );
615 cmdK2S.Append( wxT( " export" ) );
616
617 cmdK2S.Append( wxT( " " ) );
618 cmdK2S.Append( c_formatCommand[m_choiceFormat->GetSelection()] );
619
621 cmdK2S.Append( wxT( " --no-unspecified" ) );
622
623 if( GetNoDNPOption() )
624 cmdK2S.Append( wxT( " --no-dnp" ) );
625
626 if( GetSubstOption() )
627 cmdK2S.Append( wxT( " --subst-models" ) );
628
629 if( !m_optimizeStep )
630 cmdK2S.Append( wxT( " --no-optimize-step" ) );
631
632 if( !m_exportBoardBody )
633 cmdK2S.Append( wxT( " --no-board-body" ) );
634
635 if( !m_exportComponents )
636 cmdK2S.Append( wxT( " --no-components" ) );
637
638 if( m_exportTracks )
639 cmdK2S.Append( wxT( " --include-tracks" ) );
640
641 if( m_exportPads )
642 cmdK2S.Append( wxT( " --include-pads" ) );
643
644 if( m_exportZones )
645 cmdK2S.Append( wxT( " --include-zones" ) );
646
648 cmdK2S.Append( wxT( " --include-inner-copper" ) );
649
651 cmdK2S.Append( wxT( " --include-silkscreen" ) );
652
654 cmdK2S.Append( wxT( " --include-soldermask" ) );
655
656 if( m_fuseShapes )
657 cmdK2S.Append( wxT( " --fuse-shapes" ) );
658
659 // Note: for some reason, using \" to insert a quote in a format string, under MacOS
660 // wxString::Format does not work. So use a %c format in string
661 int quote = '\'';
662 int dblquote = '"';
663
664 if( !m_netFilter.empty() )
665 {
666 cmdK2S.Append( wxString::Format( wxT( " --net-filter %c%s%c" ), dblquote, m_netFilter,
667 dblquote ) );
668 }
669
670 switch( m_componentMode )
671 {
673 {
674 wxArrayString components;
676
677 std::for_each( selection.begin(), selection.end(),
678 [&components]( EDA_ITEM* item )
679 {
680 if( item->Type() == PCB_FOOTPRINT_T )
681 components.push_back( static_cast<FOOTPRINT*>( item )->GetReference() );
682 } );
683
684 cmdK2S.Append( wxString::Format( wxT( " --component-filter %c%s%c" ), dblquote,
685 wxJoin( components, ',' ), dblquote ) );
686 break;
687 }
688
690 cmdK2S.Append( wxString::Format( wxT( " --component-filter %c%s%c" ), dblquote,
691 m_componentFilter, dblquote ) );
692 break;
693
694 default:
695 break;
696 }
697
698 switch( GetOriginOption() )
699 {
700 case STEP_ORIGIN_0:
701 wxFAIL_MSG( wxT( "Unsupported origin option: how did we get here?" ) );
702 break;
703
705 cmdK2S.Append( wxT( " --drill-origin" ) );
706 break;
707
709 cmdK2S.Append( wxT( " --grid-origin" ) );
710 break;
711
712 case STEP_ORIGIN_USER:
713 {
714 double xOrg = GetXOrg();
715 double yOrg = GetYOrg();
716
717 if( GetOrgUnitsChoice() == 1 )
718 {
719 // selected reference unit is in inches, and STEP units are mm
720 xOrg *= 25.4;
721 yOrg *= 25.4;
722 }
723
725 cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6fx%.6fmm%c" ),
726 quote, xOrg, yOrg, quote ) );
727 break;
728 }
729
731 {
732 BOX2I bbox = m_editFrame->GetBoard()->ComputeBoundingBox( true );
733 double xOrg = pcbIUScale.IUTomm( bbox.GetCenter().x );
734 double yOrg = pcbIUScale.IUTomm( bbox.GetCenter().y );
736
737 cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6fx%.6fmm%c" ),
738 quote, xOrg, yOrg, quote ) );
739 break;
740 }
741 }
742
743 {
745 cmdK2S.Append( wxString::Format( wxT( " --min-distance=%c%.3fmm%c" ),
746 quote, tolerance, quote ) );
747 }
748
749 // Output file path.
750 cmdK2S.Append( wxString::Format( wxT( " -f -o %c%s%c" ),
751 dblquote, fn.GetFullPath(), dblquote ) );
752
753
754 // Input file path.
755 cmdK2S.Append( wxString::Format( wxT( " %c%s%c" ), dblquote, m_boardPath, dblquote ) );
756
757 wxLogTrace( traceKiCad2Step, wxT( "export step command: %s" ), cmdK2S );
758
759 DIALOG_EXPORT_STEP_LOG* log = new DIALOG_EXPORT_STEP_LOG( this, cmdK2S );
760 log->ShowModal();
761 }
762 else
763 {
764 m_job->SetOutputPath( m_outputFileName->GetValue() );
777 m_job->m_3dparams.m_Format = static_cast<EXPORTER_STEP_PARAMS::FORMAT>( m_choiceFormat->GetSelection() );
782
783 switch( GetOriginOption() )
784 {
785 case STEP_ORIGIN_0:
786 break;
789 break;
792 break;
793 case STEP_ORIGIN_USER:
794 {
795 double xOrg = GetXOrg();
796 double yOrg = GetYOrg();
797
798 if( GetOrgUnitsChoice() == 1 )
799 {
800 // selected reference unit is in inches, and STEP units are mm
801 xOrg *= 25.4;
802 yOrg *= 25.4;
803 }
804
805 m_job->m_3dparams.m_Origin = VECTOR2D( xOrg, yOrg );
806 break;
807 }
808
810 {
811 BOX2I bbox = m_editFrame->GetBoard()->ComputeBoundingBox( true );
812 double xOrg = pcbIUScale.IUTomm( bbox.GetCenter().x );
813 double yOrg = pcbIUScale.IUTomm( bbox.GetCenter().y );
815
816 m_job->m_3dparams.m_Origin = VECTOR2D( xOrg, yOrg );
817 break;
818 }
819 }
820
821 Close();
822 }
823}
824
825
827{
829}
830
831
833{
835}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:433
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1670
const FOOTPRINTS & Footprints() const
Definition: board.h:331
const wxString & GetFileName() const
Definition: board.h:327
constexpr const Vec GetCenter() const
Definition: box2.h:230
DO_NOT_SHOW_AGAIN m_DoNotShowAgain
Class DIALOG_EXPORT_STEP_BASE.
wxRadioButton * m_rbFilteredComponents
wxRadioButton * m_rbDrillAndPlotOrigin
STD_BITMAP_BUTTON * m_browseButton
void onFormatChoice(wxCommandEvent &event) override
STEP_ORIGIN_OPTION GetOriginOption()
static bool m_exportSoldermask
int GetOrgUnitsChoice() const
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)
static COMPONENT_MODE m_componentMode
void onUpdateXPos(wxUpdateUIEvent &aEvent) override
static bool m_exportComponents
STEP_ORIGIN_OPTION m_origin
JOB_EXPORT_PCB_3D * m_job
void onExportButton(wxCommandEvent &aEvent) override
static bool m_exportBoardBody
static bool m_exportSilkscreen
static wxString m_componentFilter
static int m_toleranceLastChoice
void onUpdateUnits(wxUpdateUIEvent &aEvent) override
static bool m_exportInnerCopper
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...
int ShowModal() override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
EXPORTER_STEP_PARAMS m_3dparams
Despite the name; also used for other formats.
void SetOutputPath(const wxString &aPath)
Definition: job.cpp:129
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: kidialog.h:43
bool DoNotShowAgain() const
Definition: kidialog.cpp:59
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: kidialog.cpp:51
int ShowModal() override
Definition: kidialog.cpp:95
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.
Definition: locale_io.h:49
DIALOG_EXPORT_STEP m_ExportStep
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
BOARD * GetBoard() const
The main frame for Pcbnew.
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
bool doAutoSave() override
Perform auto save when the board has been modified and not saved within the auto save interval.
void OnExportSTEP(wxCommandEvent &event)
Export the current BOARD to a STEP assembly.
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
bool IsContentModified() const override
Get if the current board has been modified but not saved.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:679
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.
Definition: project.cpp:359
ITER end()
Definition: selection.h:75
ITER begin()
Definition: selection.h:74
void SaveProjectCopy(const wxString &aFullPath, PROJECT *aProject=nullptr)
Saves a copy of the current project under the given path.
Represent a set of closed polygons.
void SetBitmap(const wxBitmapBundle &aBmp)
void SetValue(const wxString &aValue) override
Set a new value in evaluator buffer, and display it in the wxTextCtrl.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition: common.cpp:348
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:59
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:195
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
#define _(s)
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
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)
Definition: map_helpers.h:34
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function DoubleValueFromString converts aTextValue to a double.
Definition: eda_units.cpp:576
SETTINGS_MANAGER * GetSettingsManager()
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
@ LAST_PATH_STEP
Definition: project_file.h:51
std::vector< FAB_LAYER_COLOR > dummy
constexpr double IUTomm(int iu) const
Definition: base_units.h:86
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
wxLogTrace helper definitions.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:690
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().
Definition: wx_filename.h:39