KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_preview_3d_model.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 Mario Luzeiro <[email protected]>
5 * Copyright (C) 2015 Cirilo Bernardo <[email protected]>
6 * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#include <3d_rendering/opengl/render_3d_opengl.h> // Must be included before any GL header
28
33#include <tool/tool_manager.h>
37#include <base_units.h>
38#include <bitmaps.h>
39#include <board.h>
41#include <dpi_scaling_common.h>
42#include <footprint.h>
43#include <lset.h>
44#include <pgm_base.h>
45#include <project_pcb.h>
48#include <widgets/wx_infobar.h>
52
53#if defined(__linux__) || defined(__FreeBSD__)
55#else
57#endif
58
59static wxString evaluateTextCtrl( const wxString& aValue )
60{
61 // NUMERIC_EVALUATOR doesn't handle UTF-8 multi-byte characters properly,
62 // so skip evaluation if the string contains non-ASCII characters (e.g., degree symbols)
63 for( wxUniChar c : aValue )
64 {
65 if( !c.IsAscii() )
66 return aValue;
67 }
68
69 // Attempt to evaluate formula; if successful return result, otherwise return original
71
72 if( eval.Process( aValue ) )
73 return eval.Result();
74
75 return aValue;
76}
77
78
84static double rotationFromString( const wxString& aValue )
85{
87
88 if( rotation > MAX_ROTATION )
89 {
90 int n = KiROUND( rotation / MAX_ROTATION );
91 rotation -= MAX_ROTATION * n;
92 }
93 else if( rotation < -MAX_ROTATION )
94 {
95 int n = KiROUND( -rotation / MAX_ROTATION );
96 rotation += MAX_ROTATION * n;
97 }
98
99 return rotation;
100}
101
102
104 std::vector<FP_3DMODEL>* aParentModelList ) :
106 m_parentFrame( aFrame ),
107 m_previewPane( nullptr ),
108 m_infobar( nullptr ),
112{
113 m_userUnits = m_parentFrame->GetUserUnits();
114
115 m_dummyBoard = new BOARD();
116
117 m_dummyBoard->SetProject( &aFrame->Prj(), true );
118 m_dummyBoard->SetEmbeddedFilesDelegate( aFrame->GetBoard() );
119
120 // This board will only be used to hold a footprint for viewing
121 m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER );
122
123 BOARD_DESIGN_SETTINGS parent_bds = aFrame->GetDesignSettings();
124 BOARD_DESIGN_SETTINGS& dummy_bds = m_dummyBoard->GetDesignSettings();
125 dummy_bds.SetBoardThickness( parent_bds.GetBoardThickness() );
127 BOARD_STACKUP& dummy_board_stackup = m_dummyBoard->GetDesignSettings().GetStackupDescriptor();
128 dummy_board_stackup.RemoveAll();
129 dummy_board_stackup.BuildDefaultStackupList( &dummy_bds, 2 );
130
131 m_selected = -1;
132
133 m_previewLabel->SetFont( KIUI::GetStatusFont( this ) );
134
135 // Set the bitmap of 3D view buttons:
142 m_bpvISO->SetBitmap( KiBitmapBundle( BITMAPS::ortho ) );
146
147 // Set the min and max values of spin buttons (mandatory on Linux)
148 // They are not used, so they are set to min and max 32 bits int values
149 // (the min and max values supported by a wxSpinButton)
150 // It avoids blocking the up or down arrows when reaching this limit after
151 // a few clicks.
152 wxSpinButton* spinButtonList[] =
153 {
157 };
158
159 for( wxSpinButton* button : spinButtonList )
160 button->SetRange(INT_MIN, INT_MAX );
161
162 for( TEXT_CTRL_EVAL* rotCtrl : { xrot, yrot, zrot } )
163 {
164 rotCtrl->SetCustomEval(
165 [&]( TEXT_CTRL_EVAL* aCtrl )
166 {
167 double value = rotationFromString( evaluateTextCtrl( aCtrl->GetValue() ) );
168 aCtrl->SetValue( formatRotationValue( value ) );
169 } );
170 }
171
172 for( TEXT_CTRL_EVAL* scaleCtrl : { xscale, yscale, zscale } )
173 {
174 scaleCtrl->SetCustomEval(
175 [&]( TEXT_CTRL_EVAL* aCtrl )
176 {
178 evaluateTextCtrl( aCtrl->GetValue() ) );
179 aCtrl->SetValue( formatScaleValue( value ) );
180 } );
181 }
182
183 m_parentModelList = aParentModelList;
184
185 m_dummyFootprint = new FOOTPRINT( *aFootprint );
186 m_dummyFootprint->SetParentGroup( nullptr );
187
188 // Ensure the footprint is shown like in Fp editor: rot 0, not flipped
189 // to avoid mistakes when setting the3D shape position/rotation
190 if( m_dummyFootprint->IsFlipped() )
192
193 m_dummyFootprint->SetOrientation( ANGLE_0 );
194
196
197 // Create the 3D canvas
200 PROJECT_PCB::Get3DCacheManager( &aFrame->Prj() ) );
201
202 try
203 {
204#if defined(__linux__) || defined(__FreeBSD__)
205 m_spaceMouse = std::make_unique<SPNAV_VIEWER_PLUGIN>( m_previewPane );
206#else
207 m_spaceMouse = std::make_unique<NL_FOOTPRINT_PROPERTIES_PLUGIN>( m_previewPane );
208#endif
209 m_spaceMouse->SetFocus( true );
210 }
211 catch( const std::system_error& e )
212 {
213 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
214 }
215
216 m_boardAdapter.SetBoard( m_dummyBoard );
217 m_boardAdapter.m_IsBoardView = false;
218
219 // Force display 3D models, regardless the 3D viewer options.
220 m_boardAdapter.m_IsPreviewer = true;
221
222 loadSettings();
223
224 // Don't show placeholder models in the footprint properties 3D preview
225 if( m_boardAdapter.m_Cfg )
226 m_boardAdapter.m_Cfg->m_Render.show_missing_models = false;
227
228 // Create the manager
230 m_toolManager->SetEnvironment( m_dummyBoard, nullptr, nullptr, nullptr, this );
231
234 m_previewPane->SetEventDispatcher( m_toolDispatcher );
235
236 // Register tools
237 m_toolManager->RegisterTool( new EDA_3D_CONTROLLER );
238 m_toolManager->InitTools();
239
240 // Run the viewer control tool, it is supposed to be always active
241 m_toolManager->InvokeTool( "3DViewer.Control" );
242
243 m_infobar = new WX_INFOBAR( this );
244 m_previewPane->SetInfoBar( m_infobar );
245
246 m_SizerPanelView->Add( m_infobar, 0, wxEXPAND, 0 );
247 m_SizerPanelView->Add( m_previewPane, 1, wxEXPAND, 5 );
248
249 for( wxEventType eventType : { wxEVT_MENU_OPEN, wxEVT_MENU_CLOSE, wxEVT_MENU_HIGHLIGHT } )
250 Connect( eventType, wxMenuEventHandler( PANEL_PREVIEW_3D_MODEL::OnMenuEvent ), nullptr, this );
251
252 aFrame->Connect( EDA_EVT_UNITS_CHANGED, wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL::onUnitsChanged ),
253 nullptr, this );
254
255 Bind( wxCUSTOM_PANEL_SHOWN_EVENT, &PANEL_PREVIEW_3D_MODEL::onPanelShownEvent, this );
256}
257
258
260{
261 // Shutdown all running tools
262 if( m_toolManager )
263 m_toolManager->ShutdownAllTools();
264
265 // Restore the 3D viewer Render settings, that can be modified by the panel tools
266 if( m_boardAdapter.m_Cfg )
267 m_boardAdapter.m_Cfg->m_Render = m_initialRender;
268
269 delete m_dummyBoard;
270 delete m_previewPane;
271}
272
273
274void PANEL_PREVIEW_3D_MODEL::OnMenuEvent( wxMenuEvent& aEvent )
275{
276 if( !m_toolDispatcher )
277 aEvent.Skip();
278 else
279 m_toolDispatcher->DispatchWxEvent( aEvent );
280}
281
282
284{
285 wxCHECK_RET( m_previewPane, wxT( "Cannot load settings to null canvas" ) );
286
287 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
288
289 // TODO(JE) use all control options
290 m_boardAdapter.m_MousewheelPanning = settings->m_Input.scroll_modifier_zoom != 0;
291
293 {
294 // Save the 3D viewer render settings, to restore it after closing the preview
295 m_initialRender = cfg->m_Render;
296
297 m_boardAdapter.m_Cfg = cfg;
298
299 m_previewPane->SetAnimationEnabled( cfg->m_Camera.animation_enabled );
300 m_previewPane->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier );
301 m_previewPane->SetProjectionMode( cfg->m_Camera.projection_mode );
302 }
303}
304
305
307{
308 return wxString::Format( wxT( "%.4f" ),
309 aValue );
310}
311
312
314{
315 // Sigh. Did we really need differentiated +/- 0.0?
316 if( aValue == -0.0 )
317 aValue = 0.0;
318
319 return wxString::Format( wxT( "%.2f%s" ),
320 aValue,
322}
323
324
326{
327 // Convert from internal units (mm) to user units
329 aValue /= 25.4;
330 else if( m_userUnits == EDA_UNITS::MILS )
331 aValue /= 25.4 / 1e3;
332
333 return wxString::Format( wxT( "%.6f%s" ),
334 aValue,
336}
337
338
340{
341 if( m_parentModelList && idx >= 0 && idx < (int) m_parentModelList->size() )
342 {
343 m_selected = idx;
344 const FP_3DMODEL& modelInfo = m_parentModelList->at( (unsigned) m_selected );
345
346 // Use ChangeValue() instead of SetValue(). It's not the user making the change, so we
347 // don't want to generate wxEVT_GRID_CELL_CHANGED events.
348 xscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.x ) );
349 yscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.y ) );
350 zscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.z ) );
351
352 // Rotation is stored in the file as positive-is-CW, but we use positive-is-CCW in the GUI
353 // to match the rest of KiCad
354 xrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.x ) );
355 yrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.y ) );
356 zrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.z ) );
357
358 xoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.x ) );
359 yoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.y ) );
360 zoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.z ) );
361
362 m_opacity->SetValue( modelInfo.m_Opacity * 100.0 );
363 }
364 else
365 {
366 m_selected = -1;
367
368 xscale->ChangeValue( wxEmptyString );
369 yscale->ChangeValue( wxEmptyString );
370 zscale->ChangeValue( wxEmptyString );
371
372 xrot->ChangeValue( wxEmptyString );
373 yrot->ChangeValue( wxEmptyString );
374 zrot->ChangeValue( wxEmptyString );
375
376 xoff->ChangeValue( wxEmptyString );
377 yoff->ChangeValue( wxEmptyString );
378 zoff->ChangeValue( wxEmptyString );
379
380 m_opacity->SetValue( 100 );
381 }
382}
383
384
385void PANEL_PREVIEW_3D_MODEL::updateOrientation( wxCommandEvent &event )
386{
387 if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
388 {
389 // Write settings back to the parent
390 FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
391
393 evaluateTextCtrl( xscale->GetValue() ) );
395 evaluateTextCtrl( yscale->GetValue() ) );
397 evaluateTextCtrl( zscale->GetValue() ) );
398
399 // Rotation is stored in the file as positive-is-CW, but we use positive-is-CCW in the GUI
400 // to match the rest of KiCad
401 modelInfo->m_Rotation.x = -rotationFromString( evaluateTextCtrl( xrot->GetValue() ) );
402 modelInfo->m_Rotation.y = -rotationFromString( evaluateTextCtrl( yrot->GetValue() ) );
403 modelInfo->m_Rotation.z = -rotationFromString( evaluateTextCtrl( zrot->GetValue() ) );
404
406 evaluateTextCtrl( xoff->GetValue() ) )
407 / pcbIUScale.IU_PER_MM;
409 evaluateTextCtrl( yoff->GetValue() ) )
410 / pcbIUScale.IU_PER_MM;
412 evaluateTextCtrl( zoff->GetValue() ) )
413 / pcbIUScale.IU_PER_MM;
414
415 // Update the dummy footprint for the preview
416 UpdateDummyFootprint( false );
417 onModify();
418 }
419}
420
421
422void PANEL_PREVIEW_3D_MODEL::onOpacitySlider( wxCommandEvent& event )
423{
424 if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
425 {
426 // Write settings back to the parent
427 FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
428
429 modelInfo->m_Opacity = m_opacity->GetValue() / 100.0;
430
431 // Update the dummy footprint for the preview
432 UpdateDummyFootprint( false );
433 onModify();
434 }
435}
436
437
438void PANEL_PREVIEW_3D_MODEL::setBodyStyleView( wxCommandEvent& event )
439{
440 // turn ON or OFF options to show the board body if OFF, solder paste, soldermask
441 // and board body are hidden, to allows a good view of the 3D model and its pads.
443
444 if( !cfg )
445 return;
446
448
449 m_previewPane->ReloadRequest();
450 m_previewPane->Refresh();
451}
452
453
454void PANEL_PREVIEW_3D_MODEL::View3DSettings( wxCommandEvent& event )
455{
456 BOARD_DESIGN_SETTINGS bds = m_dummyBoard->GetDesignSettings();
457 int thickness = bds.GetBoardThickness();
458
459 WX_UNIT_ENTRY_DIALOG dlg( m_parentFrame, _( "3D Preview Options" ), _( "Board thickness:" ), thickness );
460
461 if( dlg.ShowModal() != wxID_OK )
462 return;
463
464 bds.SetBoardThickness( dlg.GetValue() );
465
466 BOARD_STACKUP& boardStackup = m_dummyBoard->GetDesignSettings().GetStackupDescriptor();
467 boardStackup.RemoveAll();
468 boardStackup.BuildDefaultStackupList( &bds, 2 );
469
470 UpdateDummyFootprint( true );
471
472 m_previewPane->ReloadRequest();
473 m_previewPane->Refresh();
474}
475
476
477void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double aSign )
478{
479 wxSpinButton* spinCtrl = dynamic_cast<wxSpinButton*>( event.GetEventObject() );
480
481 wxCHECK( spinCtrl, /* void */ );
482
483 wxTextCtrl * textCtrl = xscale;
484
485 if( spinCtrl == m_spinYscale )
486 textCtrl = yscale;
487 else if( spinCtrl == m_spinZscale )
488 textCtrl = zscale;
489
490 double step = SCALE_INCREMENT;
491
492 if( wxGetMouseState().ShiftDown( ) )
494
495 double value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::UNSCALED, textCtrl->GetValue() );
496
497 value += ( step * aSign );
498 value = std::max( 1/MAX_SCALE, value );
499 value = std::min( value, MAX_SCALE );
500
501 textCtrl->SetValue( formatScaleValue( value ) );
502}
503
504
505void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aSign )
506{
507 wxSpinButton* spinCtrl = dynamic_cast<wxSpinButton*>( aEvent.GetEventObject() );
508
509 wxCHECK( spinCtrl, /* void */ );
510
511 wxTextCtrl* textCtrl = xrot;
512
513 if( spinCtrl == m_spinYrot )
514 textCtrl = yrot;
515 else if( spinCtrl == m_spinZrot )
516 textCtrl = zrot;
517
518 double step = ROTATION_INCREMENT;
519
520 if( wxGetMouseState().ShiftDown( ) )
522
523 double value = rotationFromString( textCtrl->GetValue() );
524
525 value += ( step * aSign );
526
527 textCtrl->SetValue( formatRotationValue( value ) );
528}
529
530
531void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double aSign )
532{
533 wxSpinButton* spinCtrl = dynamic_cast<wxSpinButton*>( event.GetEventObject() );
534
535 wxCHECK( spinCtrl, /* void */ );
536
537 wxTextCtrl * textCtrl = xoff;
538
539 if( spinCtrl == m_spinYoffset )
540 textCtrl = yoff;
541 else if( spinCtrl == m_spinZoffset )
542 textCtrl = zoff;
543
544 double step_mm = OFFSET_INCREMENT_MM;
545
546 if( wxGetMouseState().ShiftDown( ) )
547 step_mm = OFFSET_INCREMENT_MM_FINE;
548
550 {
551 step_mm = 25.4*OFFSET_INCREMENT_MIL/1000;
552
553 if( wxGetMouseState().ShiftDown( ) )
554 step_mm = 25.4*OFFSET_INCREMENT_MIL_FINE/1000;;
555 }
556
557 double value_mm = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits, textCtrl->GetValue() )
558 / pcbIUScale.IU_PER_MM;
559
560 value_mm += ( step_mm * aSign );
561 value_mm = std::max( -MAX_OFFSET, value_mm );
562 value_mm = std::min( value_mm, MAX_OFFSET );
563
564 textCtrl->SetValue( formatOffsetValue( value_mm ) );
565}
566
567
569{
570 wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( event.GetEventObject() );
571
572 wxCHECK( textCtrl, /* void */ );
573
574 double step = SCALE_INCREMENT;
575
576 if( event.ShiftDown( ) )
578
579 if( event.GetWheelRotation() >= 0 )
580 step = -step;
581
582 double value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::UNSCALED, textCtrl->GetValue() );
583
584 value += step;
585 value = std::max( 1/MAX_SCALE, value );
586 value = std::min( value, MAX_SCALE );
587
588 textCtrl->SetValue( formatScaleValue( value ) );
589}
590
591
593{
594 wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( event.GetEventObject() );
595
596 wxCHECK( textCtrl, /* void */ );
597
598 double step = ROTATION_INCREMENT;
599
600 if( event.ShiftDown( ) )
602
603 if( event.GetWheelRotation() >= 0 )
604 step = -step;
605
606 double value = rotationFromString( textCtrl->GetValue() );
607
608 value += step;
609
610 textCtrl->SetValue( formatRotationValue( value ) );
611}
612
613
615{
616 wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( event.GetEventObject() );
617
618 wxCHECK( textCtrl, /* void */ );
619
620 double step_mm = OFFSET_INCREMENT_MM;
621
622 if( event.ShiftDown( ) )
623 step_mm = OFFSET_INCREMENT_MM_FINE;
624
626 {
627 step_mm = 25.4*OFFSET_INCREMENT_MIL/1000.0;
628
629 if( event.ShiftDown( ) )
630 step_mm = 25.4*OFFSET_INCREMENT_MIL_FINE/1000.0;
631 }
632
633 if( event.GetWheelRotation() >= 0 )
634 step_mm = -step_mm;
635
636 double value_mm = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits, textCtrl->GetValue() )
637 / pcbIUScale.IU_PER_MM;
638
639 value_mm += step_mm;
640 value_mm = std::max( -MAX_OFFSET, value_mm );
641 value_mm = std::min( value_mm, MAX_OFFSET );
642
643 textCtrl->SetValue( formatOffsetValue( value_mm ) );
644}
645
646
647void PANEL_PREVIEW_3D_MODEL::onUnitsChanged( wxCommandEvent& aEvent )
648{
650 / pcbIUScale.IU_PER_MM;
652 / pcbIUScale.IU_PER_MM;
654 / pcbIUScale.IU_PER_MM;
655
656 PCB_BASE_FRAME* frame = static_cast<PCB_BASE_FRAME*>( aEvent.GetClientData() );
657 m_userUnits = frame->GetUserUnits();
658
659 xoff->SetValue( formatOffsetValue( xoff_mm ) );
660 yoff->SetValue( formatOffsetValue( yoff_mm ) );
661 zoff->SetValue( formatOffsetValue( zoff_mm ) );
662
663 aEvent.Skip();
664}
665
666
667void PANEL_PREVIEW_3D_MODEL::onPanelShownEvent( wxCommandEvent& aEvent )
668{
669 if( m_spaceMouse )
670 {
671 m_spaceMouse->SetFocus( static_cast<bool>( aEvent.GetInt() ) );
672 }
673
674 aEvent.Skip();
675}
676
677
679{
680 m_dummyFootprint->Models().clear();
681
683 {
684 if( model.m_Show )
685 m_dummyFootprint->Models().push_back( model );
686 }
687
688 if( aReloadRequired )
689 m_previewPane->ReloadRequest();
690
691 m_previewPane->Request_refresh();
692}
693
694
696{
697 m_dummyBoard->SetEmbeddedFilesDelegate( aDelegate );
698}
699
700
702{
703 KIWAY_HOLDER* kiwayHolder = dynamic_cast<KIWAY_HOLDER*>( wxGetTopLevelParent( this ) );
704
705 if( kiwayHolder && kiwayHolder->GetType() == KIWAY_HOLDER::DIALOG )
706 static_cast<DIALOG_SHIM*>( kiwayHolder )->OnModify();
707}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
constexpr EDA_IU_SCALE unityScale
Definition base_units.h:115
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
@ show_board_body
@ options_3drender
@ FPHOLDER
Definition board.h:315
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:990
Container for design settings for a BOARD object.
void SetEnabledLayers(const LSET &aMask)
Change the bit-mask of enabled layers to aMask.
int GetBoardThickness() const
The full thickness of the board including copper and masks.
void SetBoardThickness(int aThickness)
Manage layers needed to make a physical board.
void RemoveAll()
Delete all items in list and clear the list.
void BuildDefaultStackupList(const BOARD_DESIGN_SETTINGS *aSettings, int aActiveCopperLayersCount=0)
Create a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:68
int ShowModal() override
EDA_3D_ACTIONS.
Implement a canvas based on a wxGLCanvas.
Handle view actions for various 3D canvases.
VECTOR3D m_Offset
3D model offset (mm)
Definition footprint.h:122
double m_Opacity
Definition footprint.h:123
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition footprint.h:121
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition footprint.h:120
A mix in class which holds the location of a wxWindow's KIWAY.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
HOLDER_TYPE GetType() const
static const LSET & FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
Definition lset.cpp:722
static const LSET & BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition lset.cpp:729
wxString Result() const
bool Process(const wxString &aString)
static const wxGLAttributes GetAttributesList(ANTIALIASING_MODE aAntiAliasingMode, bool aAlpha=false)
Get a list of attributes to pass to wxGLCanvas.
PANEL_PREVIEW_3D_MODEL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxString formatOffsetValue(double aValue)
void onMouseWheelRot(wxMouseEvent &event) override
void View3DSettings(wxCommandEvent &event) override
void onOpacitySlider(wxCommandEvent &event) override
void setBodyStyleView(wxCommandEvent &event) override
void onMouseWheelScale(wxMouseEvent &event) override
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS m_initialRender
The 3d viewer Render initial settings (must be saved and restored)
void UpdateDummyFootprint(bool aRelaodRequired=true)
Copy shapes from the current shape list which are flagged for preview to the copy of footprint that i...
wxString formatScaleValue(double aValue)
void doIncrementRotation(wxSpinEvent &aEvent, double aSign)
void loadSettings()
Load 3D relevant settings from the user configuration.
void OnMenuEvent(wxMenuEvent &aEvent)
The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu events aren't ...
void onUnitsChanged(wxCommandEvent &aEvent)
void doIncrementOffset(wxSpinEvent &aEvent, double aSign)
PANEL_PREVIEW_3D_MODEL(wxWindow *aParent, PCB_BASE_FRAME *aFrame, FOOTPRINT *aFootprint, std::vector< FP_3DMODEL > *aParentModelList)
void SetEmbeddedFilesDelegate(EMBEDDED_FILES *aDelegate)
void doIncrementScale(wxSpinEvent &aEvent, double aSign)
void updateOrientation(wxCommandEvent &event) override
It will receive the events from editing the fields.
wxString formatRotationValue(double aValue)
void onMouseWheelOffset(wxMouseEvent &event) override
std::unique_ptr< NL_FOOTPRINT_PROPERTIES_PLUGIN > m_spaceMouse
void onPanelShownEvent(wxCommandEvent &aEvent)
void SetSelectedModel(int idx)
Set the currently selected index in the model list so that the scale/rotation/offset controls can be ...
std::vector< FP_3DMODEL > * m_parentModelList
EDA_UNITS m_userUnits
Index into m_parentInfoList.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Return the BOARD_DESIGN_SETTINGS for the open project.
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:541
static S3D_CACHE * Get3DCacheManager(PROJECT *aProject, bool updateProjDir=false)
Return a pointer to an instance of the 3D cache manager.
wxTextCtrl wrapper to handle math expression evaluation.
void SetValue(const wxString &aValue) override
Set a new value in evaluator buffer and display it in the wxTextCtrl.
TOOL_MANAGER * m_toolManager
TOOL_DISPATCHER * m_toolDispatcher
ACTIONS * m_actions
Master controller class:
EDA_UNITS GetUserUnits() const
A modified version of the wxInfoBar class that allows us to:
Definition wx_infobar.h:77
An extension of WX_TEXT_ENTRY_DIALOG that uses UNIT_BINDER to request a dimension (e....
int GetValue()
Return the value in internal units.
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:411
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:29
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue to a double.
KICOMMON_API wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
KICOMMON_API wxFont GetStatusFont(wxWindow *aWindow)
declaration of the nl_footprint_properties_plugin class
Declaration of the cogl_att_list class.
static double rotationFromString(const wxString &aValue)
Ensure -MAX_ROTATION <= rotation <= MAX_ROTATION.
static wxString evaluateTextCtrl(const wxString &aValue)
#define MAX_SCALE
#define MAX_ROTATION
#define MAX_OFFSET
#define OFFSET_INCREMENT_MM_FINE
#define OFFSET_INCREMENT_MIL
#define SCALE_INCREMENT
#define ROTATION_INCREMENT_FINE
#define OFFSET_INCREMENT_MM
#define ROTATION_INCREMENT
#define OFFSET_INCREMENT_MIL_FINE
#define SCALE_INCREMENT_FINE
#define PANEL_PREVIEW_3D_MODEL_ID
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
T * GetAppSettings(const char *aFilename)
KIBIS_MODEL * model