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 The 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 "dialog_export_step.h"
27
28#include <wx/log.h>
29#include <wx/stdpaths.h>
30#include <wx/process.h>
31#include <wx/string.h>
32#include <wx/filedlg.h>
33
34#include <pgm_base.h>
35#include <board.h>
36#include <confirm.h>
37#include <kidialog.h>
39#include <footprint.h>
40#include <kiface_base.h>
41#include <locale_io.h>
42#include <math/vector3.h>
43#include <pcb_edit_frame.h>
45#include <project/project_file.h> // LAST_PATH_TYPE
46#include <reporter.h>
47#include <string_utils.h>
48#include <trace_helpers.h>
51#include <filename_resolver.h>
52#include <core/map_helpers.h>
55
56
57// Maps m_choiceFormat selection to extension (and kicad-cli command)
68
69// Maps file extensions to m_choiceFormat selection
80
81
82DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aEditFrame, const wxString& aBoardPath ) :
83 DIALOG_EXPORT_STEP( aEditFrame, aEditFrame, aBoardPath )
84{
85}
86
87
89 const wxString& aBoardPath, JOB_EXPORT_PCB_3D* aJob ) :
90 DIALOG_EXPORT_STEP_BASE( aEditFrame ),
91 m_editFrame( aEditFrame ),
92 m_job( aJob ),
95 m_boardPath( aBoardPath )
96{
97 if( !m_job )
98 {
100 SetupStandardButtons( { { wxID_OK, _( "Export" ) },
101 { wxID_CANCEL, _( "Close" ) } } );
102 }
103 else
104 {
105 SetTitle( m_job->GetSettingsDialogTitle() );
106
107 m_browseButton->Hide();
109 }
110
111 // DIALOG_SHIM needs a unique hash_key because classname will be the same for both job and
112 // non-job versions.
113 m_hash_key = TO_UTF8( GetTitle() );
114
115 Layout();
116 bSizerSTEPFile->Fit( this );
117
118 SetFocus();
119
120 wxString bad_scales;
121 size_t bad_count = 0;
122
123 for( FOOTPRINT* fp : m_editFrame->GetBoard()->Footprints() )
124 {
125 for( const FP_3DMODEL& model : fp->Models() )
126 {
127 if( model.m_Scale.x != 1.0 || model.m_Scale.y != 1.0 || model.m_Scale.z != 1.0 )
128 {
129 bad_scales.Append( wxS("\n") );
130 bad_scales.Append( model.m_Filename );
131 bad_count++;
132 }
133 }
134
135 if( bad_count >= 5 )
136 break;
137 }
138
139 if( !bad_scales.empty() && !Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning )
140 {
141 wxString extendedMsg = _( "Non-unity scaled models:" ) + wxT( "\n" ) + bad_scales;
142
143 KIDIALOG msgDlg( m_editFrame, _( "Scaled models detected. Model scaling is not reliable for "
144 "mechanical export." ),
145 _( "Model Scale Warning" ), wxOK | wxICON_WARNING );
146 msgDlg.SetExtendedMessage( extendedMsg );
147 msgDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
148
149 msgDlg.ShowModal();
150
151 if( msgDlg.DoNotShowAgain() )
153 }
154
156
157 // Now all widgets have the size fixed, call FinishDialogSettings
159}
160
161
163{
164 if( !m_job )
165 {
166 if( m_outputFileName->GetValue().IsEmpty() )
167 {
168 wxFileName brdFile( m_editFrame->GetBoard()->GetFileName() );
169 brdFile.SetExt( wxT( "step" ) );
170 m_outputFileName->SetValue( brdFile.GetFullPath() );
171 }
172 }
173 else
174 {
175 m_rbBoardCenterOrigin->SetValue( true ); // Default
176
177 if( m_job->m_3dparams.m_UseDrillOrigin )
178 m_rbDrillAndPlotOrigin->SetValue( true );
179 else if( m_job->m_3dparams.m_UseGridOrigin )
180 m_rbGridOrigin->SetValue( true );
181 else if( m_job->m_3dparams.m_UseDefinedOrigin )
182 m_rbUserDefinedOrigin->SetValue( true );
183 else if( m_job->m_3dparams.m_UsePcbCenterOrigin )
184 m_rbBoardCenterOrigin->SetValue( true );
185
186 m_originX.SetValue( pcbIUScale.mmToIU( m_job->m_3dparams.m_Origin.x ) );
187 m_originY.SetValue( pcbIUScale.mmToIU( m_job->m_3dparams.m_Origin.y ) );
188
189 m_txtNetFilter->SetValue( m_job->m_3dparams.m_NetFilter );
190 m_cbOptimizeStep->SetValue( m_job->m_3dparams.m_OptimizeStep );
191 m_cbExportBody->SetValue( m_job->m_3dparams.m_ExportBoardBody );
192 m_cbExportComponents->SetValue( m_job->m_3dparams.m_ExportComponents );
193 m_cbExportTracks->SetValue( m_job->m_3dparams.m_ExportTracksVias );
194 m_cbExportPads->SetValue( m_job->m_3dparams.m_ExportPads );
195 m_cbExportZones->SetValue( m_job->m_3dparams.m_ExportZones );
196 m_cbExportInnerCopper->SetValue( m_job->m_3dparams.m_ExportInnerCopper );
197 m_cbExportSilkscreen->SetValue( m_job->m_3dparams.m_ExportSilkscreen );
198 m_cbExportSoldermask->SetValue( m_job->m_3dparams.m_ExportSoldermask );
199 m_cbFuseShapes->SetValue( m_job->m_3dparams.m_FuseShapes );
200 m_cbCutViasInBody->SetValue( m_job->m_3dparams.m_CutViasInBody );
201 m_cbFillAllVias->SetValue( m_job->m_3dparams.m_FillAllVias );
202 m_cbRemoveUnspecified->SetValue( !m_job->m_3dparams.m_IncludeUnspecified );
203 m_cbRemoveDNP->SetValue( !m_job->m_3dparams.m_IncludeDNP );
204 m_cbSubstModels->SetValue( m_job->m_3dparams.m_SubstModels );
205 m_cbOverwriteFile->SetValue( m_job->m_3dparams.m_Overwrite );
206
207 if( m_job->m_3dparams.m_BoardOutlinesChainingEpsilon > 0.05 )
208 m_choiceTolerance->SetSelection( 2 );
209 else if( m_job->m_3dparams.m_BoardOutlinesChainingEpsilon < 0.005 )
210 m_choiceTolerance->SetSelection( 0 );
211 else
212 m_choiceTolerance->SetSelection( 1 );
213
214 m_txtComponentFilter->SetValue( m_job->m_3dparams.m_ComponentFilter );
215 m_outputFileName->SetValue( m_job->GetConfiguredOutputPath() );
216 }
217
218 // Sync the enabled states
219 wxCommandEvent dummy;
221
222 return true;
223}
224
225
227{
228 BOARD* board = m_frame->GetBoard();
229 wxFileName brdFile = board->GetFileName();
230
231 // The project filename (.kicad_pro) of the auto saved board filename, if it is created
232 wxFileName autosaveProjFile;
233
234 if( m_frame->GetScreen()->IsContentModified() || brdFile.GetFullPath().empty() )
235 {
236 if( !m_frame->DoAutoSave() )
237 {
238 DisplayErrorMessage( m_frame, _( "STEP export failed! Please save the PCB and try again" ) );
239 return 0;
240 }
241
242 wxString autosaveFileName = FILEEXT::AutoSaveFilePrefix + brdFile.GetName();
243
244 // Create a dummy .kicad_pro file for this auto saved board file.
245 // this is useful to use some settings (like project path and name)
246 // Because DoAutoSave() works, the target directory exists and is writable
247 autosaveProjFile = brdFile;
248 autosaveProjFile.SetName( autosaveFileName );
249 autosaveProjFile.SetExt( "kicad_pro" );
250
251 // Use auto-saved board for export
252 m_frame->GetSettingsManager()->SaveProjectCopy( autosaveProjFile.GetFullPath(), board->GetProject() );
253 brdFile.SetName( autosaveFileName );
254 }
255
256 DIALOG_EXPORT_STEP dlg( m_frame, brdFile.GetFullPath() );
257 dlg.ShowModal();
258
259 // If a dummy .kicad_pro file is created, delete it now it is useless.
260 if( !autosaveProjFile.GetFullPath().IsEmpty() )
261 wxRemoveFile( autosaveProjFile.GetFullPath() );
262
263 return 0;
264}
265
266
267void DIALOG_EXPORT_STEP::onUpdateXPos( wxUpdateUIEvent& aEvent )
268{
269 aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
270}
271
272
273void DIALOG_EXPORT_STEP::onUpdateYPos( wxUpdateUIEvent& aEvent )
274{
275 aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
276}
277
278
279void DIALOG_EXPORT_STEP::onBrowseClicked( wxCommandEvent& aEvent )
280{
281 // clang-format off
282 wxString filter = _( "STEP files" )
284 + _( "Binary glTF files" )
286 + _( "XAO files" )
288 + _( "BREP (OCCT) files" )
290 + _( "PLY files" )
292 + _( "STL files" )
294 + _( "Universal 3D files" )
296 + _( "PDF files" )
298 // clang-format on
299
300 // Build the absolute path of current output directory to preselect it in the file browser.
301 wxString path = ExpandEnvVarSubstitutions( m_outputFileName->GetValue(), &Prj() );
302 wxFileName fn( Prj().AbsolutePath( path ) );
303
304 wxFileDialog dlg( this, _( "3D Model Output File" ), fn.GetPath(), fn.GetFullName(), filter, wxFD_SAVE );
305
306 if( dlg.ShowModal() == wxID_CANCEL )
307 return;
308
309 path = dlg.GetPath();
310 m_outputFileName->SetValue( path );
311
312 fn = wxFileName( path );
313
314 if( auto formatChoice = get_opt( c_formatExtToChoice, fn.GetExt().Lower() ) )
315 m_choiceFormat->SetSelection( *formatChoice );
316}
317
318
319void DIALOG_EXPORT_STEP::onFormatChoice( wxCommandEvent& event )
320{
322}
323
324
326{
327 wxString newExt;
328 int idx = m_choiceFormat->GetSelection();
329
330 for( auto& choices : c_formatExtToChoice )
331 {
332 if( choices.second == idx )
333 {
334 newExt = choices.first;
335 break;
336 }
337 }
338
339 wxString path = m_outputFileName->GetValue();
340
341 int sepIdx = std::max( path.Find( '/', true ), path.Find( '\\', true ) );
342 int dotIdx = path.Find( '.', true );
343
344 if( dotIdx == -1 || dotIdx < sepIdx )
345 path << '.' << newExt;
346 else
347 path = path.Mid( 0, dotIdx ) << '.' << newExt;
348
349 m_outputFileName->SetValue( path );
350}
351
352
353void DIALOG_EXPORT_STEP::onCbExportComponents( wxCommandEvent& event )
354{
355 bool enable = m_cbExportComponents->GetValue();
356
357 m_rbAllComponents->Enable( enable );
358 m_rbOnlySelected->Enable( enable );
359 m_rbFilteredComponents->Enable( enable );
360 m_txtComponentFilter->Enable( enable && m_rbFilteredComponents->GetValue() );
361}
362
363
364void DIALOG_EXPORT_STEP::OnComponentModeChange( wxCommandEvent& event )
365{
366 m_txtComponentFilter->Enable( m_rbFilteredComponents->GetValue() );
367}
368
369
370void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
371{
372 wxString path = m_outputFileName->GetValue();
373 double tolerance; // default value in mm
374
375 switch( m_choiceTolerance->GetSelection() )
376 {
377 case 0: tolerance = 0.001; break;
378 default:
379 case 1: tolerance = 0.01; break;
380 case 2: tolerance = 0.1; break;
381 }
382
383 if( !m_job )
384 {
385 // Build the absolute path of current output directory to preselect it in the file browser.
386 std::function<bool( wxString* )> textResolver =
387 [&]( wxString* token ) -> bool
388 {
389 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
390 };
391
392 path = ExpandTextVars( path, &textResolver );
394 path = Prj().AbsolutePath( path );
395
396 if( path.IsEmpty() )
397 {
398 DisplayErrorMessage( this, _( "No filename for output file" ) );
399 return;
400 }
401
402 SHAPE_POLY_SET outline;
403 wxString msg;
404
405 // Check if the board outline is continuous
406 // max dist from one endPt to next startPt to build a closed shape:
407 int chainingEpsilon = pcbIUScale.mmToIU( tolerance );
408
409 // Arc to segment approximation error (not critical here: we do not use the outline shape):
410 int maxError = pcbIUScale.mmToIU( 0.05 );
411
412 if( !BuildBoardPolygonOutlines( m_editFrame->GetBoard(), outline, maxError, chainingEpsilon ) )
413 {
414 DisplayErrorMessage( this, wxString::Format( _( "Board outline is missing or not closed using "
415 "%.3f mm tolerance.\n"
416 "Run DRC for a full analysis." ),
417 tolerance ) );
418 return;
419 }
420
421 wxFileName fn( Prj().AbsolutePath( path ) );
422
423 if( fn.FileExists() && !m_cbOverwriteFile->GetValue() )
424 {
425 msg.Printf( _( "File '%s' already exists. Do you want overwrite this file?" ), fn.GetFullPath() );
426
427 if( wxMessageBox( msg, _( "STEP/GLTF Export" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
428 return;
429 }
430
431 wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() );
432 #ifdef __WXMAC__
433 // On macOS, we have standalone applications inside the main bundle, so we handle that here:
434 if( appK2S.GetPath().Find( "/Contents/Applications/pcbnew.app/Contents/MacOS" ) != wxNOT_FOUND )
435 {
436 appK2S.AppendDir( wxT( ".." ) );
437 appK2S.AppendDir( wxT( ".." ) );
438 appK2S.AppendDir( wxT( ".." ) );
439 appK2S.AppendDir( wxT( ".." ) );
440 appK2S.AppendDir( wxT( "MacOS" ) );
441 }
442 #else
443 if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
444 {
445 appK2S.RemoveLastDir();
446 appK2S.AppendDir( "kicad" );
447 }
448 #endif
449
450 appK2S.SetName( wxT( "kicad-cli" ) );
451 appK2S.Normalize( FN_NORMALIZE_FLAGS );
452
453 wxString cmdK2S = wxT( "\"" );
454 cmdK2S.Append( appK2S.GetFullPath() );
455 cmdK2S.Append( wxT( "\"" ) );
456
457 cmdK2S.Append( wxT( " pcb" ) );
458 cmdK2S.Append( wxT( " export" ) );
459
460 cmdK2S.Append( wxT( " " ) );
461 cmdK2S.Append( c_formatCommand[m_choiceFormat->GetSelection()] );
462
463 if( m_cbRemoveUnspecified->GetValue() )
464 cmdK2S.Append( wxT( " --no-unspecified" ) );
465
466 if( m_cbRemoveDNP->GetValue() )
467 cmdK2S.Append( wxT( " --no-dnp" ) );
468
469 if( m_cbSubstModels->GetValue() )
470 cmdK2S.Append( wxT( " --subst-models" ) );
471
472 if( !m_cbOptimizeStep->GetValue() )
473 cmdK2S.Append( wxT( " --no-optimize-step" ) );
474
475 if( !m_cbExportBody->GetValue() )
476 cmdK2S.Append( wxT( " --no-board-body" ) );
477
478 if( !m_cbExportComponents->GetValue() )
479 cmdK2S.Append( wxT( " --no-components" ) );
480
481 if( m_cbExportTracks->GetValue() )
482 cmdK2S.Append( wxT( " --include-tracks" ) );
483
484 if( m_cbExportPads->GetValue() )
485 cmdK2S.Append( wxT( " --include-pads" ) );
486
487 if( m_cbExportZones->GetValue() )
488 cmdK2S.Append( wxT( " --include-zones" ) );
489
490 if( m_cbExportInnerCopper->GetValue() )
491 cmdK2S.Append( wxT( " --include-inner-copper" ) );
492
493 if( m_cbExportSilkscreen->GetValue() )
494 cmdK2S.Append( wxT( " --include-silkscreen" ) );
495
496 if( m_cbExportSoldermask->GetValue() )
497 cmdK2S.Append( wxT( " --include-soldermask" ) );
498
499 if( m_cbFuseShapes->GetValue() )
500 cmdK2S.Append( wxT( " --fuse-shapes" ) );
501
502 if( m_cbCutViasInBody->GetValue() )
503 cmdK2S.Append( wxT( " --cut-vias-in-body" ) );
504
505 if( m_cbFillAllVias->GetValue() )
506 cmdK2S.Append( wxT( " --fill-all-vias" ) );
507
508 // Note: for some reason, using \" to insert a quote in a format string, under MacOS
509 // wxString::Format does not work. So use a %c format in string
510 int quote = '\'';
511 int dblquote = '"';
512
513 if( !m_txtNetFilter->GetValue().empty() )
514 {
515 cmdK2S.Append( wxString::Format( wxT( " --net-filter %c%s%c" ),
516 dblquote, m_txtNetFilter->GetValue(), dblquote ) );
517 }
518
519 if( m_rbOnlySelected->GetValue() )
520 {
521 wxArrayString components;
522 SELECTION& selection = m_editFrame->GetCurrentSelection();
523
524 std::for_each( selection.begin(), selection.end(),
525 [&components]( EDA_ITEM* item )
526 {
527 if( item->Type() == PCB_FOOTPRINT_T )
528 components.push_back( static_cast<FOOTPRINT*>( item )->GetReference() );
529 } );
530
531 cmdK2S.Append( wxString::Format( wxT( " --component-filter %c%s%c" ),
532 dblquote, wxJoin( components, ',' ), dblquote ) );
533 }
534 else if( m_rbFilteredComponents->GetValue() )
535 {
536 cmdK2S.Append( wxString::Format( wxT( " --component-filter %c%s%c" ),
537 dblquote, m_txtComponentFilter->GetValue(), dblquote ) );
538 }
539
540 if( m_rbDrillAndPlotOrigin->GetValue() )
541 {
542 cmdK2S.Append( wxT( " --drill-origin" ) );
543 }
544 else if( m_rbGridOrigin->GetValue() )
545 {
546 cmdK2S.Append( wxT( " --grid-origin" ) );
547 }
548 else if( m_rbUserDefinedOrigin->GetValue() )
549 {
550 double xOrg = pcbIUScale.IUTomm( m_originX.GetIntValue() );
551 double yOrg = pcbIUScale.IUTomm( m_originY.GetIntValue() );
552
554 cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6fx%.6fmm%c" ),
555 quote, xOrg, yOrg, quote ) );
556 }
557 else if( m_rbBoardCenterOrigin->GetValue() )
558 {
559 BOX2I bbox = m_editFrame->GetBoard()->ComputeBoundingBox( true );
560 double xOrg = pcbIUScale.IUTomm( bbox.GetCenter().x );
561 double yOrg = pcbIUScale.IUTomm( bbox.GetCenter().y );
563
564 cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6fx%.6fmm%c" ),
565 quote, xOrg, yOrg, quote ) );
566 }
567 else
568 {
569 wxFAIL_MSG( wxT( "Unsupported origin option: how did we get here?" ) );
570 }
571
572 {
574 cmdK2S.Append( wxString::Format( wxT( " --min-distance=%c%.3fmm%c" ),
575 quote, tolerance, quote ) );
576 }
577
578 // Output file path.
579 cmdK2S.Append( wxString::Format( wxT( " -f -o %c%s%c" ),
580 dblquote, fn.GetFullPath(), dblquote ) );
581
582
583 // Input file path.
584 cmdK2S.Append( wxString::Format( wxT( " %c%s%c" ), dblquote, m_boardPath, dblquote ) );
585
586 wxLogTrace( traceKiCad2Step, wxT( "export step command: %s" ), cmdK2S );
587
588 DIALOG_EXPORT_STEP_LOG* log = new DIALOG_EXPORT_STEP_LOG( this, cmdK2S );
589 log->ShowModal();
590 }
591 else
592 {
593 m_job->SetConfiguredOutputPath( path );
594 m_job->m_3dparams.m_NetFilter = m_txtNetFilter->GetValue();
595 m_job->m_3dparams.m_ComponentFilter = m_txtComponentFilter->GetValue();
596 m_job->m_3dparams.m_ExportBoardBody = m_cbExportBody->GetValue();
597 m_job->m_3dparams.m_ExportComponents = m_cbExportComponents->GetValue();
598 m_job->m_3dparams.m_ExportTracksVias = m_cbExportTracks->GetValue();
599 m_job->m_3dparams.m_ExportPads = m_cbExportPads->GetValue();
600 m_job->m_3dparams.m_ExportZones = m_cbExportZones->GetValue();
601 m_job->m_3dparams.m_ExportInnerCopper = m_cbExportInnerCopper->GetValue();
602 m_job->m_3dparams.m_ExportSilkscreen = m_cbExportSilkscreen->GetValue();
603 m_job->m_3dparams.m_ExportSoldermask = m_cbExportSoldermask->GetValue();
604 m_job->m_3dparams.m_FuseShapes = m_cbFuseShapes->GetValue();
605 m_job->m_3dparams.m_CutViasInBody = m_cbCutViasInBody->GetValue();
606 m_job->m_3dparams.m_FillAllVias = m_cbFillAllVias->GetValue();
607 m_job->m_3dparams.m_OptimizeStep = m_cbOptimizeStep->GetValue();
608 m_job->m_3dparams.m_Overwrite = m_cbOverwriteFile->GetValue();
609 m_job->m_3dparams.m_IncludeUnspecified = !m_cbRemoveUnspecified->GetValue();
610 m_job->m_3dparams.m_IncludeDNP = !m_cbRemoveDNP->GetValue();
611 m_job->m_3dparams.m_SubstModels = m_cbSubstModels->GetValue();
612 m_job->m_3dparams.m_BoardOutlinesChainingEpsilon = tolerance;
613
614 m_job->SetStepFormat( static_cast<EXPORTER_STEP_PARAMS::FORMAT>( m_choiceFormat->GetSelection() ) );
615
616 // ensure the main format on the job is populated
617 switch( m_job->m_3dparams.m_Format )
618 {
628 }
629
630 m_job->m_3dparams.m_UseDrillOrigin = false;
631 m_job->m_3dparams.m_UseGridOrigin = false;
632 m_job->m_3dparams.m_UseDefinedOrigin = false;
633 m_job->m_3dparams.m_UsePcbCenterOrigin = false;
634
635 if( m_rbDrillAndPlotOrigin->GetValue() )
636 {
637 m_job->m_3dparams.m_UseDrillOrigin = true;
638 }
639 else if( m_rbGridOrigin->GetValue() )
640 {
641 m_job->m_3dparams.m_UseGridOrigin = true;
642 }
643 else if( m_rbUserDefinedOrigin->GetValue() )
644 {
645 double xOrg = pcbIUScale.IUTomm( m_originX.GetIntValue() );
646 double yOrg = pcbIUScale.IUTomm( m_originY.GetIntValue() );
647
648 m_job->m_3dparams.m_UseDefinedOrigin = true;
649 m_job->m_3dparams.m_Origin = VECTOR2D( xOrg, yOrg );
650 }
651 else if( m_rbBoardCenterOrigin->GetValue() )
652 {
653 BOX2I bbox = m_editFrame->GetBoard()->ComputeBoundingBox( true );
654 double xOrg = pcbIUScale.IUTomm( bbox.GetCenter().x );
655 double yOrg = pcbIUScale.IUTomm( bbox.GetCenter().y );
657
658 m_job->m_3dparams.m_UsePcbCenterOrigin = true;
659 m_job->m_3dparams.m_Origin = VECTOR2D( xOrg, yOrg );
660 }
661
662 EndModal( wxID_OK );
663 }
664}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
int ExportSTEP(const TOOL_EVENT &aEvent)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:317
constexpr const Vec GetCenter() const
Definition box2.h:230
DO_NOT_SHOW_AGAIN m_DoNotShowAgain
DIALOG_EXPORT_STEP_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Export 3D Model"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
STD_BITMAP_BUTTON * m_browseButton
void onFormatChoice(wxCommandEvent &event) override
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={})
std::string m_hash_key
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:98
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition kidialog.h:42
bool DoNotShowAgain() const
Checks the 'do not show again' setting for the dialog.
Definition kidialog.cpp:63
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox.
Definition kidialog.cpp:55
int ShowModal() override
Definition kidialog.cpp:93
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:41
The main frame for Pcbnew.
BOARD * board() const
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:576
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:386
ITER end()
Definition selection.h:80
ITER begin()
Definition selection.h:79
Represent a set of closed polygons.
Generic, UI-independent tool event.
Definition tool_event.h:171
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition common.cpp:355
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
Definition common.cpp:59
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:194
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 U3DFileExtension
static const std::string PdfFileExtension
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.
std::optional< V > get_opt(const std::map< wxString, V > &aMap, const wxString &aKey)
Definition map_helpers.h:34
PGM_BASE & Pgm()
The global program "get" accessor.
Definition pgm_base.cpp:913
see class PGM_BASE
std::vector< FAB_LAYER_COLOR > dummy
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
wxLogTrace helper definitions.
VECTOR2< double > VECTOR2D
Definition vector2d.h:694
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