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#include <kiplatform/ui.h>
34
35#include <pgm_base.h>
37#include <board.h>
38#include <confirm.h>
39#include <kidialog.h>
41#include <footprint.h>
42#include <kiface_base.h>
43#include <locale_io.h>
44#include <math/vector3.h>
45#include <pcb_edit_frame.h>
47#include <project/project_file.h> // LAST_PATH_TYPE
48#include <reporter.h>
49#include <string_utils.h>
50#include <trace_helpers.h>
53#include <filename_resolver.h>
54#include <core/map_helpers.h>
57
58
59// Maps m_choiceFormat selection to extension (and kicad-cli command)
70
71// Maps m_choiceFormat selection to the step exporter format
83
84// Maps file extensions to m_choiceFormat selection
95
96
97DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aEditFrame, const wxString& aBoardPath ) :
98 DIALOG_EXPORT_STEP( aEditFrame, aEditFrame, aBoardPath )
99{
100}
101
102
104 const wxString& aBoardPath, JOB_EXPORT_PCB_3D* aJob ) :
105 DIALOG_EXPORT_STEP_BASE( aEditFrame ),
106 m_editFrame( aEditFrame ),
107 m_job( aJob ),
110 m_boardPath( aBoardPath )
111{
112 if( !m_job )
113 {
115 SetupStandardButtons( { { wxID_OK, _( "Export" ) },
116 { wxID_CANCEL, _( "Close" ) } } );
117 }
118 else
119 {
120 SetTitle( m_job->GetSettingsDialogTitle() );
121
122 m_browseButton->Hide();
124 }
125
126 // DIALOG_SHIM needs a unique hash_key because classname will be the same for both job and
127 // non-job versions.
128 m_hash_key = TO_UTF8( GetTitle() );
129
130 m_choiceVariant->Append( m_editFrame->GetBoard()->GetVariantNamesForUI() );
131 m_choiceVariant->SetSelection( 0 );
132
133 Layout();
134 bSizerSTEPFile->Fit( this );
135
136 SetFocus();
137
138 wxString bad_scales;
139 size_t bad_count = 0;
140
141 for( FOOTPRINT* fp : m_editFrame->GetBoard()->Footprints() )
142 {
143 for( const FP_3DMODEL& model : fp->Models() )
144 {
145 if( model.m_Scale.x != 1.0 || model.m_Scale.y != 1.0 || model.m_Scale.z != 1.0 )
146 {
147 bad_scales.Append( wxS("\n") );
148 bad_scales.Append( model.m_Filename );
149 bad_count++;
150 }
151 }
152
153 if( bad_count >= 5 )
154 break;
155 }
156
157 if( !bad_scales.empty() && !Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning )
158 {
159 wxString extendedMsg = _( "Non-unity scaled models:" ) + wxT( "\n" ) + bad_scales;
160
161 KIDIALOG msgDlg( m_editFrame, _( "Scaled models detected. Model scaling is not reliable for "
162 "mechanical export." ),
163 _( "Model Scale Warning" ), wxOK | wxICON_WARNING );
164 msgDlg.SetExtendedMessage( extendedMsg );
165 msgDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
166
167 msgDlg.ShowModal();
168
169 if( msgDlg.DoNotShowAgain() )
171 }
172
174
175 // Now all widgets have the size fixed, call FinishDialogSettings
177}
178
179
181{
182 if( !m_job )
183 {
184 if( m_outputFileName->GetValue().IsEmpty() )
185 {
186 wxFileName brdFile( m_editFrame->GetBoard()->GetFileName() );
187 brdFile.SetExt( wxT( "step" ) );
188 m_outputFileName->SetValue( brdFile.GetFullPath() );
189 }
190
191 wxString currentVariant = m_editFrame->GetBoard()->GetCurrentVariant();
192
193 if( !currentVariant.IsEmpty() )
194 {
195 int idx = m_choiceVariant->FindString( currentVariant );
196
197 if( idx != wxNOT_FOUND )
198 m_choiceVariant->SetSelection( idx );
199 }
200
201 wxFileName fn = m_outputFileName->GetValue();
202
203 if( auto formatChoice = get_opt( c_formatExtToChoice, fn.GetExt().Lower() ) )
204 m_choiceFormat->SetSelection( *formatChoice );
205 }
206 else
207 {
208 m_rbBoardCenterOrigin->SetValue( true ); // Default
209
210 if( m_job->m_3dparams.m_UseDrillOrigin )
211 m_rbDrillAndPlotOrigin->SetValue( true );
212 else if( m_job->m_3dparams.m_UseGridOrigin )
213 m_rbGridOrigin->SetValue( true );
214 else if( m_job->m_3dparams.m_UseDefinedOrigin )
215 m_rbUserDefinedOrigin->SetValue( true );
216 else if( m_job->m_3dparams.m_UsePcbCenterOrigin )
217 m_rbBoardCenterOrigin->SetValue( true );
218
219 m_originX.SetValue( pcbIUScale.mmToIU( m_job->m_3dparams.m_Origin.x ) );
220 m_originY.SetValue( pcbIUScale.mmToIU( m_job->m_3dparams.m_Origin.y ) );
221
222 m_txtNetFilter->SetValue( m_job->m_3dparams.m_NetFilter );
223 m_cbOptimizeStep->SetValue( m_job->m_3dparams.m_OptimizeStep );
224 m_cbExportBody->SetValue( m_job->m_3dparams.m_ExportBoardBody );
225 m_cbExportComponents->SetValue( m_job->m_3dparams.m_ExportComponents );
226 m_cbExportTracks->SetValue( m_job->m_3dparams.m_ExportTracksVias );
227 m_cbExportPads->SetValue( m_job->m_3dparams.m_ExportPads );
228 m_cbExportZones->SetValue( m_job->m_3dparams.m_ExportZones );
229 m_cbExportInnerCopper->SetValue( m_job->m_3dparams.m_ExportInnerCopper );
230 m_cbExportSilkscreen->SetValue( m_job->m_3dparams.m_ExportSilkscreen );
231 m_cbExportSoldermask->SetValue( m_job->m_3dparams.m_ExportSoldermask );
232 m_cbFuseShapes->SetValue( m_job->m_3dparams.m_FuseShapes );
233 m_cbCutViasInBody->SetValue( m_job->m_3dparams.m_CutViasInBody );
234 m_cbFillAllVias->SetValue( m_job->m_3dparams.m_FillAllVias );
235 m_cbRemoveUnspecified->SetValue( !m_job->m_3dparams.m_IncludeUnspecified );
236 m_cbRemoveDNP->SetValue( !m_job->m_3dparams.m_IncludeDNP );
237 m_cbSubstModels->SetValue( m_job->m_3dparams.m_SubstModels );
238 m_cbOverwriteFile->SetValue( m_job->m_3dparams.m_Overwrite );
239
240 if( m_job->m_3dparams.m_BoardOutlinesChainingEpsilon > 0.05 )
241 m_choiceTolerance->SetSelection( 2 );
242 else if( m_job->m_3dparams.m_BoardOutlinesChainingEpsilon < 0.005 )
243 m_choiceTolerance->SetSelection( 0 );
244 else
245 m_choiceTolerance->SetSelection( 1 );
246
247 m_txtComponentFilter->SetValue( m_job->m_3dparams.m_ComponentFilter );
248 m_outputFileName->SetValue( m_job->GetConfiguredOutputPath() );
249
250 if( !m_job->m_variant.IsEmpty() )
251 {
252 int idx = m_choiceVariant->FindString( m_job->m_variant );
253
254 if( idx != wxNOT_FOUND )
255 m_choiceVariant->SetSelection( idx );
256 }
257
258 // Use the recorded format instead of the file extension for jobs
259 for( auto& formats : c_formatJobCommand )
260 {
261 if( formats.second == m_job->m_3dparams.m_Format )
262 {
263 m_choiceFormat->SetSelection( formats.first );
264 break;
265 }
266 }
267 }
268
269 // Sync the enabled states
270 wxCommandEvent dummy;
272
273 return true;
274}
275
276
278{
279 wxString variant;
280 int selection = m_choiceVariant->GetSelection();
281
282 if( ( selection != 0 ) && ( selection != wxNOT_FOUND ) )
283 variant = m_choiceVariant->GetString( selection );
284
285 return variant;
286}
287
288
290{
291 BOARD* board = m_frame->GetBoard();
292 wxFileName brdFile = board->GetFileName();
293
294 DIALOG_EXPORT_STEP dlg( m_frame, brdFile.GetFullPath() );
295 dlg.ShowModal();
296
297 return 0;
298}
299
300
301void DIALOG_EXPORT_STEP::onUpdateXPos( wxUpdateUIEvent& aEvent )
302{
303 aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
304}
305
306
307void DIALOG_EXPORT_STEP::onUpdateYPos( wxUpdateUIEvent& aEvent )
308{
309 aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
310}
311
312
313void DIALOG_EXPORT_STEP::onBrowseClicked( wxCommandEvent& aEvent )
314{
315 // clang-format off
316 wxString filter = _( "STEP files" )
318 + _( "Binary glTF files" )
320 + _( "XAO files" )
322 + _( "BREP (OCCT) files" )
324 + _( "PLY files" )
326 + _( "STL files" )
328 + _( "Universal 3D files" )
330 + _( "PDF files" )
332 // clang-format on
333
334 // Build the absolute path of current output directory to preselect it in the file browser.
335 wxString path = ExpandEnvVarSubstitutions( m_outputFileName->GetValue(), &Prj() );
336 wxFileName fn( Prj().AbsolutePath( path ) );
337
338 wxFileDialog dlg( this, _( "3D Model Output File" ), fn.GetPath(), fn.GetFullName(), filter, wxFD_SAVE );
339
341
342 if( dlg.ShowModal() == wxID_CANCEL )
343 return;
344
345 path = dlg.GetPath();
346 m_outputFileName->SetValue( path );
347
348 fn = wxFileName( path );
349
350 if( auto formatChoice = get_opt( c_formatExtToChoice, fn.GetExt().Lower() ) )
351 m_choiceFormat->SetSelection( *formatChoice );
352}
353
354
355void DIALOG_EXPORT_STEP::onFormatChoice( wxCommandEvent& event )
356{
358}
359
360
362{
363 wxString newExt;
364 int idx = m_choiceFormat->GetSelection();
365
366 for( auto& choices : c_formatExtToChoice )
367 {
368 if( choices.second == idx )
369 {
370 newExt = choices.first;
371 break;
372 }
373 }
374
375 wxString path = m_outputFileName->GetValue();
376
377 int sepIdx = std::max( path.Find( '/', true ), path.Find( '\\', true ) );
378 int dotIdx = path.Find( '.', true );
379
380 if( dotIdx == -1 || dotIdx < sepIdx )
381 path << '.' << newExt;
382 else
383 path = path.Mid( 0, dotIdx ) << '.' << newExt;
384
385 m_outputFileName->SetValue( path );
386}
387
388
389void DIALOG_EXPORT_STEP::onCbExportComponents( wxCommandEvent& event )
390{
391 bool enable = m_cbExportComponents->GetValue();
392
393 m_rbAllComponents->Enable( enable );
394 m_rbOnlySelected->Enable( enable );
395 m_rbFilteredComponents->Enable( enable );
396 m_txtComponentFilter->Enable( enable && m_rbFilteredComponents->GetValue() );
397}
398
399
400void DIALOG_EXPORT_STEP::OnComponentModeChange( wxCommandEvent& event )
401{
402 m_txtComponentFilter->Enable( m_rbFilteredComponents->GetValue() );
403}
404
405
406void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
407{
408 wxString path = m_outputFileName->GetValue();
409 double tolerance; // default value in mm
410
411 switch( m_choiceTolerance->GetSelection() )
412 {
413 case 0: tolerance = 0.001; break;
414 default:
415 case 1: tolerance = 0.01; break;
416 case 2: tolerance = 0.1; break;
417 }
418
419 if( !m_job )
420 {
421 // Build the absolute path of current output directory to preselect it in the file browser.
422 std::function<bool( wxString* )> textResolver =
423 [&]( wxString* token ) -> bool
424 {
425 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
426 };
427
428 path = ExpandTextVars( path, &textResolver );
430 path = Prj().AbsolutePath( path );
431
432 if( path.IsEmpty() )
433 {
434 DisplayErrorMessage( this, _( "No filename for output file" ) );
435 return;
436 }
437
438 SHAPE_POLY_SET outline;
439 wxString msg;
440
441 // Check if the board outline is continuous
442 // max dist from one endPt to next startPt to build a closed shape:
443 int chainingEpsilon = pcbIUScale.mmToIU( tolerance );
444
445 // Arc to segment approximation error (not critical here: we do not use the outline shape):
446 int maxError = pcbIUScale.mmToIU( 0.05 );
447
448 if( !BuildBoardPolygonOutlines( m_editFrame->GetBoard(), outline, maxError, chainingEpsilon, false ) )
449 {
450 DisplayErrorMessage( this, wxString::Format( _( "Board outline is missing or not closed using "
451 "%.3f mm tolerance.\n"
452 "Run DRC for a full analysis." ),
453 tolerance ) );
454 return;
455 }
456
457 wxFileName fn( Prj().AbsolutePath( path ) );
458
459 if( fn.FileExists() && !m_cbOverwriteFile->GetValue() )
460 {
461 msg.Printf( _( "File '%s' already exists. Do you want overwrite this file?" ), fn.GetFullPath() );
462
463 if( wxMessageBox( msg, _( "STEP/GLTF Export" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
464 return;
465 }
466
467 wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() );
468 #ifdef __WXMAC__
469 // On macOS, we have standalone applications inside the main bundle, so we handle that here:
470 if( appK2S.GetPath().Find( "/Contents/Applications/pcbnew.app/Contents/MacOS" ) != wxNOT_FOUND )
471 {
472 appK2S.AppendDir( wxT( ".." ) );
473 appK2S.AppendDir( wxT( ".." ) );
474 appK2S.AppendDir( wxT( ".." ) );
475 appK2S.AppendDir( wxT( ".." ) );
476 appK2S.AppendDir( wxT( "MacOS" ) );
477 }
478 #else
479 if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
480 {
481 appK2S.RemoveLastDir();
482 appK2S.AppendDir( "kicad" );
483 }
484 #endif
485
486 appK2S.SetName( wxT( "kicad-cli" ) );
487 appK2S.Normalize( FN_NORMALIZE_FLAGS );
488
489 wxString cmdK2S = wxT( "\"" );
490 cmdK2S.Append( appK2S.GetFullPath() );
491 cmdK2S.Append( wxT( "\"" ) );
492
493 cmdK2S.Append( wxT( " pcb" ) );
494 cmdK2S.Append( wxT( " export" ) );
495
496 cmdK2S.Append( wxT( " " ) );
497 cmdK2S.Append( c_formatCommand[m_choiceFormat->GetSelection()] );
498
499 if( m_cbRemoveUnspecified->GetValue() )
500 cmdK2S.Append( wxT( " --no-unspecified" ) );
501
502 if( m_cbRemoveDNP->GetValue() )
503 cmdK2S.Append( wxT( " --no-dnp" ) );
504
505 if( m_cbSubstModels->GetValue() )
506 cmdK2S.Append( wxT( " --subst-models" ) );
507
508 if( !m_cbOptimizeStep->GetValue() )
509 cmdK2S.Append( wxT( " --no-optimize-step" ) );
510
511 if( !m_cbExportBody->GetValue() )
512 cmdK2S.Append( wxT( " --no-board-body" ) );
513
514 if( !m_cbExportComponents->GetValue() )
515 cmdK2S.Append( wxT( " --no-components" ) );
516
517 if( m_cbExportTracks->GetValue() )
518 cmdK2S.Append( wxT( " --include-tracks" ) );
519
520 if( m_cbExportPads->GetValue() )
521 cmdK2S.Append( wxT( " --include-pads" ) );
522
523 if( m_cbExportZones->GetValue() )
524 cmdK2S.Append( wxT( " --include-zones" ) );
525
526 if( m_cbExportInnerCopper->GetValue() )
527 cmdK2S.Append( wxT( " --include-inner-copper" ) );
528
529 if( m_cbExportSilkscreen->GetValue() )
530 cmdK2S.Append( wxT( " --include-silkscreen" ) );
531
532 if( m_cbExportSoldermask->GetValue() )
533 cmdK2S.Append( wxT( " --include-soldermask" ) );
534
535 if( m_cbFuseShapes->GetValue() )
536 cmdK2S.Append( wxT( " --fuse-shapes" ) );
537
538 if( m_cbCutViasInBody->GetValue() )
539 cmdK2S.Append( wxT( " --cut-vias-in-body" ) );
540
541 if( m_cbFillAllVias->GetValue() )
542 cmdK2S.Append( wxT( " --fill-all-vias" ) );
543
544 // Note: for some reason, using \" to insert a quote in a format string, under MacOS
545 // wxString::Format does not work. So use a %c format in string
546 int quote = '\'';
547 int dblquote = '"';
548
549 wxString selectedVariant = getSelectedVariant();
550
551 if( !selectedVariant.IsEmpty() )
552 {
553 cmdK2S.Append( wxString::Format( wxT( " --variant %c%s%c" ),
554 dblquote, selectedVariant, dblquote ) );
555 }
556
557 if( !m_txtNetFilter->GetValue().empty() )
558 {
559 cmdK2S.Append( wxString::Format( wxT( " --net-filter %c%s%c" ),
560 dblquote, m_txtNetFilter->GetValue(), dblquote ) );
561 }
562
563 if( m_rbOnlySelected->GetValue() )
564 {
565 wxArrayString components;
566 SELECTION& selection = m_editFrame->GetCurrentSelection();
567
568 std::for_each( selection.begin(), selection.end(),
569 [&components]( EDA_ITEM* item )
570 {
571 if( item->Type() == PCB_FOOTPRINT_T )
572 components.push_back( static_cast<FOOTPRINT*>( item )->GetReference() );
573 } );
574
575 cmdK2S.Append( wxString::Format( wxT( " --component-filter %c%s%c" ),
576 dblquote, wxJoin( components, ',' ), dblquote ) );
577 }
578 else if( m_rbFilteredComponents->GetValue() )
579 {
580 cmdK2S.Append( wxString::Format( wxT( " --component-filter %c%s%c" ),
581 dblquote, m_txtComponentFilter->GetValue(), dblquote ) );
582 }
583
584 if( m_rbDrillAndPlotOrigin->GetValue() )
585 {
586 cmdK2S.Append( wxT( " --drill-origin" ) );
587 }
588 else if( m_rbGridOrigin->GetValue() )
589 {
590 cmdK2S.Append( wxT( " --grid-origin" ) );
591 }
592 else if( m_rbUserDefinedOrigin->GetValue() )
593 {
594 double xOrg = pcbIUScale.IUTomm( m_originX.GetIntValue() );
595 double yOrg = pcbIUScale.IUTomm( m_originY.GetIntValue() );
596
598 cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6fx%.6fmm%c" ),
599 quote, xOrg, yOrg, quote ) );
600 }
601 else if( m_rbBoardCenterOrigin->GetValue() )
602 {
603 BOX2I bbox = m_editFrame->GetBoard()->ComputeBoundingBox( true, true );
604 double xOrg = pcbIUScale.IUTomm( bbox.GetCenter().x );
605 double yOrg = pcbIUScale.IUTomm( bbox.GetCenter().y );
607
608 cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6fx%.6fmm%c" ),
609 quote, xOrg, yOrg, quote ) );
610 }
611 else
612 {
613 wxFAIL_MSG( wxT( "Unsupported origin option: how did we get here?" ) );
614 }
615
616 {
618 cmdK2S.Append( wxString::Format( wxT( " --min-distance=%c%.3fmm%c" ),
619 quote, tolerance, quote ) );
620 }
621
622 // Output file path.
623 cmdK2S.Append( wxString::Format( wxT( " -f -o %c%s%c" ),
624 dblquote, fn.GetFullPath(), dblquote ) );
625
626
627 // Input file path.
628 cmdK2S.Append( wxString::Format( wxT( " %c%s%c" ), dblquote, m_boardPath, dblquote ) );
629
630 wxLogTrace( traceKiCad2Step, wxT( "export step command: %s" ), cmdK2S );
631
632 DIALOG_EXPORT_STEP_LOG* log = new DIALOG_EXPORT_STEP_LOG( this, cmdK2S );
633 log->ShowModal();
634 }
635 else
636 {
637 m_job->SetConfiguredOutputPath( path );
638 m_job->m_variant = getSelectedVariant();
639 m_job->m_3dparams.m_NetFilter = m_txtNetFilter->GetValue();
640 m_job->m_3dparams.m_ComponentFilter = m_txtComponentFilter->GetValue();
641 m_job->m_3dparams.m_ExportBoardBody = m_cbExportBody->GetValue();
642 m_job->m_3dparams.m_ExportComponents = m_cbExportComponents->GetValue();
643 m_job->m_3dparams.m_ExportTracksVias = m_cbExportTracks->GetValue();
644 m_job->m_3dparams.m_ExportPads = m_cbExportPads->GetValue();
645 m_job->m_3dparams.m_ExportZones = m_cbExportZones->GetValue();
646 m_job->m_3dparams.m_ExportInnerCopper = m_cbExportInnerCopper->GetValue();
647 m_job->m_3dparams.m_ExportSilkscreen = m_cbExportSilkscreen->GetValue();
648 m_job->m_3dparams.m_ExportSoldermask = m_cbExportSoldermask->GetValue();
649 m_job->m_3dparams.m_FuseShapes = m_cbFuseShapes->GetValue();
650 m_job->m_3dparams.m_CutViasInBody = m_cbCutViasInBody->GetValue();
651 m_job->m_3dparams.m_FillAllVias = m_cbFillAllVias->GetValue();
652 m_job->m_3dparams.m_OptimizeStep = m_cbOptimizeStep->GetValue();
653 m_job->m_3dparams.m_Overwrite = m_cbOverwriteFile->GetValue();
654 m_job->m_3dparams.m_IncludeUnspecified = !m_cbRemoveUnspecified->GetValue();
655 m_job->m_3dparams.m_IncludeDNP = !m_cbRemoveDNP->GetValue();
656 m_job->m_3dparams.m_SubstModels = m_cbSubstModels->GetValue();
657 m_job->m_3dparams.m_BoardOutlinesChainingEpsilon = tolerance;
658
659 if( auto formatChoice = get_opt( c_formatJobCommand, m_choiceFormat->GetSelection() ) )
660 {
661 m_job->SetStepFormat( *formatChoice );
662 }
663 else
664 {
665 wxASSERT_MSG(false, wxString::Format( "Unknown format value %d", m_choiceFormat->GetSelection() ) );
666 }
667
668
669 // ensure the main format on the job is populated
670 switch( m_job->m_3dparams.m_Format )
671 {
681 }
682
683 m_job->m_3dparams.m_UseDrillOrigin = false;
684 m_job->m_3dparams.m_UseGridOrigin = false;
685 m_job->m_3dparams.m_UseDefinedOrigin = false;
686 m_job->m_3dparams.m_UsePcbCenterOrigin = false;
687
688 if( m_rbDrillAndPlotOrigin->GetValue() )
689 {
690 m_job->m_3dparams.m_UseDrillOrigin = true;
691 }
692 else if( m_rbGridOrigin->GetValue() )
693 {
694 m_job->m_3dparams.m_UseGridOrigin = true;
695 }
696 else if( m_rbUserDefinedOrigin->GetValue() )
697 {
698 double xOrg = pcbIUScale.IUTomm( m_originX.GetIntValue() );
699 double yOrg = pcbIUScale.IUTomm( m_originY.GetIntValue() );
700
701 m_job->m_3dparams.m_UseDefinedOrigin = true;
702 m_job->m_3dparams.m_Origin = VECTOR2D( xOrg, yOrg );
703 }
704 else if( m_rbBoardCenterOrigin->GetValue() )
705 {
706 BOX2I bbox = m_editFrame->GetBoard()->ComputeBoundingBox( true, true );
707 double xOrg = pcbIUScale.IUTomm( bbox.GetCenter().x );
708 double yOrg = pcbIUScale.IUTomm( bbox.GetCenter().y );
710
711 m_job->m_3dparams.m_UsePcbCenterOrigin = true;
712 m_job->m_3dparams.m_Origin = VECTOR2D( xOrg, yOrg );
713 }
714
715 EndModal( wxID_OK );
716 }
717}
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:323
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)
wxString getSelectedVariant() const
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:100
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:541
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:401
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:558
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
Definition common.cpp:62
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:202
This file is part of the common library.
bool BuildBoardPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aErrorMax, int aChainingEpsilon, bool aInferOutlineIfNecessary, 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::map< int, EXPORTER_STEP_PARAMS::FORMAT > c_formatJobCommand
#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 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
void AllowNetworkFileSystems(wxDialog *aDialog)
Configure a file dialog to show network and virtual file systems.
Definition wxgtk/ui.cpp:435
PGM_BASE & Pgm()
The global program "get" accessor.
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.
std::string path
KIBIS_MODEL * model
wxLogTrace helper definitions.
VECTOR2< double > VECTOR2D
Definition vector2d.h:686
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