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