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 (C) 2015-2023 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
30#include <tool/tool_manager.h>
34#include <base_units.h>
35#include <bitmaps.h>
36#include <board.h>
38#include <dpi_scaling_common.h>
39#include <lset.h>
40#include <pgm_base.h>
41#include <project_pcb.h>
44#include <widgets/wx_infobar.h>
48
50
52 FOOTPRINT* aFootprint,
53 std::vector<FP_3DMODEL>* aParentModelList ) :
54 PANEL_PREVIEW_3D_MODEL_BASE( aParent, wxID_ANY ),
55 m_parentFrame( aFrame ),
56 m_previewPane( nullptr ),
57 m_infobar( nullptr ),
58 m_boardAdapter(),
59 m_currentCamera( m_trackBallCamera ),
60 m_trackBallCamera( 2 * RANGE_SCALE_3D )
61{
63
64 m_dummyBoard = new BOARD();
65
66 m_dummyBoard->SetProject( &aFrame->Prj(), true );
67
68 // This board will only be used to hold a footprint for viewing
69 m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER );
70
71 m_bodyStyleShowAll = true;
72
73 BOARD_DESIGN_SETTINGS parent_bds = aFrame->GetDesignSettings();
75 dummy_bds.SetBoardThickness( parent_bds.GetBoardThickness() );
78 dummy_board_stackup.RemoveAll();
79 dummy_board_stackup.BuildDefaultStackupList( &dummy_bds, 2 );
80
81 m_selected = -1;
82
83 m_previewLabel->SetFont( KIUI::GetStatusFont( this ) );
84
85 // Set the bitmap of 3D view buttons:
86 m_bpvTop->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_top ) );
87 m_bpvFront->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_front ) );
88 m_bpvBack->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_back ) );
89 m_bpvLeft->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_left ) );
90 m_bpvRight->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_right ) );
91 m_bpvBottom->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_bottom ) );
92 m_bpvISO->SetBitmap( KiBitmapBundle( BITMAPS::ortho ) );
93 m_bpvBodyStyle->SetBitmap( KiBitmapBundle( BITMAPS::axis3d ) );
94 m_bpUpdate->SetBitmap( KiBitmapBundle( BITMAPS::reload ) );
95 m_bpSettings->SetBitmap( KiBitmapBundle( BITMAPS::options_3drender ) );
96
97 // Set the min and max values of spin buttons (mandatory on Linux)
98 // They are not used, so they are set to min and max 32 bits int values
99 // (the min and max values supported by a wxSpinButton)
100 // It avoids blocking the up or down arrows when reaching this limit after
101 // a few clicks.
102 wxSpinButton* spinButtonList[] =
103 {
107 };
108
109 for( wxSpinButton* button : spinButtonList )
110 button->SetRange(INT_MIN, INT_MAX );
111
112 m_parentModelList = aParentModelList;
113
114 m_dummyFootprint = new FOOTPRINT( *aFootprint );
116
117 // Ensure the footprint is shown like in Fp editor: rot 0, not flipped
118 // to avoid mistakes when setting the3D shape position/rotation
120 m_dummyFootprint->Flip( m_dummyFootprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
121
123
124
126
127 // Create the 3D canvas
128 m_previewPane = new EDA_3D_CANVAS( this,
129 OGL_ATT_LIST::GetAttributesList( ANTIALIASING_MODE::AA_8X ),
131 PROJECT_PCB::Get3DCacheManager( &aFrame->Prj() ) );
132
134 m_spaceMouse->SetFocus( true );
135
138 m_boardAdapter.m_IsPreviewer = true; // Force display 3D models, regardless the 3D viewer options
139
140 loadSettings();
141
142 // Create the manager
144 m_toolManager->SetEnvironment( m_dummyBoard, nullptr, nullptr, nullptr, this );
145
149
150 // Register tools
153
154 // Run the viewer control tool, it is supposed to be always active
155 m_toolManager->InvokeTool( "3DViewer.Control" );
156
157 m_infobar = new WX_INFOBAR( this );
159
160 m_SizerPanelView->Add( m_infobar, 0, wxEXPAND, 0 );
161 m_SizerPanelView->Add( m_previewPane, 1, wxEXPAND, 5 );
162
163 for( wxEventType eventType : { wxEVT_MENU_OPEN, wxEVT_MENU_CLOSE, wxEVT_MENU_HIGHLIGHT } )
164 {
165 Connect( eventType, wxMenuEventHandler( PANEL_PREVIEW_3D_MODEL::OnMenuEvent ), nullptr,
166 this );
167 }
168
169 aFrame->Connect( EDA_EVT_UNITS_CHANGED,
170 wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL::onUnitsChanged ),
171 nullptr, this );
172
173 Bind( wxCUSTOM_PANEL_SHOWN_EVENT, &PANEL_PREVIEW_3D_MODEL::onPanelShownEvent, this );
174}
175
176
178{
179 // Restore the 3D viewer Render settings, that can be modified by the panel tools
182
183 delete m_spaceMouse;
184 delete m_dummyBoard;
185 delete m_previewPane;
186}
187
188
189void PANEL_PREVIEW_3D_MODEL::OnMenuEvent( wxMenuEvent& aEvent )
190{
191 if( !m_toolDispatcher )
192 aEvent.Skip();
193 else
195}
196
197
199{
200 wxCHECK_RET( m_previewPane, wxT( "Cannot load settings to null canvas" ) );
201
202 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
203
204 // TODO(JE) use all control options
206
207 auto* cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" );
208
209 if( cfg )
210 {
211 // Save the 3D viewer render settings, to restore it after closing the preview
212 m_initialRender = cfg->m_Render;
213
214 m_boardAdapter.m_Cfg = cfg;
215
216 m_previewPane->SetAnimationEnabled( cfg->m_Camera.animation_enabled );
217 m_previewPane->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier );
218 m_previewPane->SetProjectionMode( cfg->m_Camera.projection_mode );
219
220 // Ensure the board body is always shown, and do not use the settings of the 3D viewer
221 cfg->m_Render.show_copper_top = m_bodyStyleShowAll;
222 cfg->m_Render.show_copper_bottom = m_bodyStyleShowAll;
223 cfg->m_Render.show_soldermask_top = m_bodyStyleShowAll;
224 cfg->m_Render.show_soldermask_bottom = m_bodyStyleShowAll;
225 cfg->m_Render.show_solderpaste = m_bodyStyleShowAll;
226 cfg->m_Render.show_zones = m_bodyStyleShowAll;
227 cfg->m_Render.show_board_body = m_bodyStyleShowAll;
228 cfg->m_Render.use_board_editor_copper_colors = false;
229 }
230}
231
232
238static double rotationFromString( const wxString& aValue )
239{
241
242 if( rotation > MAX_ROTATION )
243 {
244 int n = KiROUND( rotation / MAX_ROTATION );
245 rotation -= MAX_ROTATION * n;
246 }
247 else if( rotation < -MAX_ROTATION )
248 {
249 int n = KiROUND( -rotation / MAX_ROTATION );
250 rotation += MAX_ROTATION * n;
251 }
252
253 return rotation;
254}
255
256
258{
259 return wxString::Format( wxT( "%.4f" ),
260 aValue );
261}
262
263
265{
266 // Sigh. Did we really need differentiated +/- 0.0?
267 if( aValue == -0.0 )
268 aValue = 0.0;
269
270 return wxString::Format( wxT( "%.2f%s" ),
271 aValue,
272 EDA_UNIT_UTILS::GetText( EDA_UNITS::DEGREES ) );
273}
274
275
277{
278 // Convert from internal units (mm) to user units
279 if( m_userUnits == EDA_UNITS::INCHES )
280 aValue /= 25.4;
281 else if( m_userUnits == EDA_UNITS::MILS )
282 aValue /= 25.4 / 1e3;
283
284 return wxString::Format( wxT( "%.6f%s" ),
285 aValue,
287}
288
289
291{
292 if( m_parentModelList && idx >= 0 && idx < (int) m_parentModelList->size() )
293 {
294 m_selected = idx;
295 const FP_3DMODEL& modelInfo = m_parentModelList->at( (unsigned) m_selected );
296
297 // Use ChangeValue() instead of SetValue(). It's not the user making the change, so we
298 // don't want to generate wxEVT_GRID_CELL_CHANGED events.
299 xscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.x ) );
300 yscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.y ) );
301 zscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.z ) );
302
303 // Rotation is stored in the file as postive-is-CW, but we use postive-is-CCW in the GUI
304 // to match the rest of KiCad
305 xrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.x ) );
306 yrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.y ) );
307 zrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.z ) );
308
309 xoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.x ) );
310 yoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.y ) );
311 zoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.z ) );
312
313 m_opacity->SetValue( modelInfo.m_Opacity * 100.0 );
314 }
315 else
316 {
317 m_selected = -1;
318
319 xscale->ChangeValue( wxEmptyString );
320 yscale->ChangeValue( wxEmptyString );
321 zscale->ChangeValue( wxEmptyString );
322
323 xrot->ChangeValue( wxEmptyString );
324 yrot->ChangeValue( wxEmptyString );
325 zrot->ChangeValue( wxEmptyString );
326
327 xoff->ChangeValue( wxEmptyString );
328 yoff->ChangeValue( wxEmptyString );
329 zoff->ChangeValue( wxEmptyString );
330
331 m_opacity->SetValue( 100 );
332 }
333}
334
335
336void PANEL_PREVIEW_3D_MODEL::updateOrientation( wxCommandEvent &event )
337{
338 if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
339 {
340 // Write settings back to the parent
341 FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
342
344 pcbIUScale, EDA_UNITS::UNSCALED, xscale->GetValue() );
346 pcbIUScale, EDA_UNITS::UNSCALED, yscale->GetValue() );
348 pcbIUScale, EDA_UNITS::UNSCALED, zscale->GetValue() );
349
350 // Rotation is stored in the file as postive-is-CW, but we use postive-is-CCW in the GUI
351 // to match the rest of KiCad
352 modelInfo->m_Rotation.x = -rotationFromString( xrot->GetValue() );
353 modelInfo->m_Rotation.y = -rotationFromString( yrot->GetValue() );
354 modelInfo->m_Rotation.z = -rotationFromString( zrot->GetValue() );
355
357 xoff->GetValue() )
360 yoff->GetValue() )
363 zoff->GetValue() )
365
366 // Update the dummy footprint for the preview
367 UpdateDummyFootprint( false );
368 onModify();
369 }
370}
371
372
373void PANEL_PREVIEW_3D_MODEL::onOpacitySlider( wxCommandEvent& event )
374{
375 if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
376 {
377 // Write settings back to the parent
378 FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
379
380 modelInfo->m_Opacity = m_opacity->GetValue() / 100.0;
381
382 // Update the dummy footprint for the preview
383 UpdateDummyFootprint( false );
384 onModify();
385 }
386}
387
388
389void PANEL_PREVIEW_3D_MODEL::setBodyStyleView( wxCommandEvent& event )
390{
391 // turn ON or OFF options to show the board body if OFF, soder paste, soldermask
392 // and board body are hidden, to allows a good view of the 3D model and its pads.
394
395 if( !cfg )
396 return;
397
399
405
407 m_previewPane->Refresh();
408}
409
410
411void PANEL_PREVIEW_3D_MODEL::View3DSettings( wxCommandEvent& event )
412{
414 int thickness = bds.GetBoardThickness();
415
416 WX_UNIT_ENTRY_DIALOG dlg( m_parentFrame, _( "3D Preview Options" ), _( "Board thickness:" ),
417 thickness );
418
419 if( dlg.ShowModal() != wxID_OK )
420 return;
421
422 bds.SetBoardThickness( dlg.GetValue() );
423
425 boardStackup.RemoveAll();
426 boardStackup.BuildDefaultStackupList( &bds, 2 );
427
428 UpdateDummyFootprint( true );
429
431 m_previewPane->Refresh();
432}
433
434
435void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double aSign )
436{
437 wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
438
439 wxTextCtrl * textCtrl = xscale;
440
441 if( spinCtrl == m_spinYscale )
442 textCtrl = yscale;
443 else if( spinCtrl == m_spinZscale )
444 textCtrl = zscale;
445
446 double step = SCALE_INCREMENT;
447
448 if( wxGetMouseState().ShiftDown( ) )
450
451 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
452 textCtrl->GetValue() );
453
454 curr_value += ( step * aSign );
455 curr_value = std::max( 1/MAX_SCALE, curr_value );
456 curr_value = std::min( curr_value, MAX_SCALE );
457
458 textCtrl->SetValue( formatScaleValue( curr_value ) );
459}
460
461
462void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aSign )
463{
464 wxSpinButton* spinCtrl = (wxSpinButton*) aEvent.GetEventObject();
465 wxTextCtrl* textCtrl = xrot;
466
467 if( spinCtrl == m_spinYrot )
468 textCtrl = yrot;
469 else if( spinCtrl == m_spinZrot )
470 textCtrl = zrot;
471
472 double step = ROTATION_INCREMENT;
473
474 if( wxGetMouseState().ShiftDown( ) )
476
477 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
478 textCtrl->GetValue() );
479
480 curr_value += ( step * aSign );
481 curr_value = std::max( -MAX_ROTATION, curr_value );
482 curr_value = std::min( curr_value, MAX_ROTATION );
483
484 textCtrl->SetValue( formatRotationValue( curr_value ) );
485}
486
487
488void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double aSign )
489{
490 wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
491
492 wxTextCtrl * textCtrl = xoff;
493
494 if( spinCtrl == m_spinYoffset )
495 textCtrl = yoff;
496 else if( spinCtrl == m_spinZoffset )
497 textCtrl = zoff;
498
499 double step_mm = OFFSET_INCREMENT_MM;
500
501 if( wxGetMouseState().ShiftDown( ) )
502 step_mm = OFFSET_INCREMENT_MM_FINE;
503
504 if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCHES )
505 {
506 step_mm = 25.4*OFFSET_INCREMENT_MIL/1000;
507
508 if( wxGetMouseState().ShiftDown( ) )
509 step_mm = 25.4*OFFSET_INCREMENT_MIL_FINE/1000;;
510 }
511
513 textCtrl->GetValue() )
515
516 curr_value_mm += ( step_mm * aSign );
517 curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm );
518 curr_value_mm = std::min( curr_value_mm, MAX_OFFSET );
519
520 textCtrl->SetValue( formatOffsetValue( curr_value_mm ) );
521}
522
523
525{
526 wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
527
528 double step = SCALE_INCREMENT;
529
530 if( event.ShiftDown( ) )
532
533 if( event.GetWheelRotation() >= 0 )
534 step = -step;
535
536 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
537 textCtrl->GetValue() );
538
539 curr_value += step;
540 curr_value = std::max( 1/MAX_SCALE, curr_value );
541 curr_value = std::min( curr_value, MAX_SCALE );
542
543 textCtrl->SetValue( formatScaleValue( curr_value ) );
544}
545
546
548{
549 wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
550
551 double step = ROTATION_INCREMENT;
552
553 if( event.ShiftDown( ) )
555
556 if( event.GetWheelRotation() >= 0 )
557 step = -step;
558
559 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
560 textCtrl->GetValue() );
561
562 curr_value += step;
563 curr_value = std::max( -MAX_ROTATION, curr_value );
564 curr_value = std::min( curr_value, MAX_ROTATION );
565
566 textCtrl->SetValue( formatRotationValue( curr_value ) );
567}
568
569
571{
572 wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
573
574 double step_mm = OFFSET_INCREMENT_MM;
575
576 if( event.ShiftDown( ) )
577 step_mm = OFFSET_INCREMENT_MM_FINE;
578
579 if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCHES )
580 {
581 step_mm = 25.4*OFFSET_INCREMENT_MIL/1000.0;
582
583 if( event.ShiftDown( ) )
584 step_mm = 25.4*OFFSET_INCREMENT_MIL_FINE/1000.0;
585 }
586
587 if( event.GetWheelRotation() >= 0 )
588 step_mm = -step_mm;
589
591 textCtrl->GetValue() )
593
594 curr_value_mm += step_mm;
595 curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm );
596 curr_value_mm = std::min( curr_value_mm, MAX_OFFSET );
597
598 textCtrl->SetValue( formatOffsetValue( curr_value_mm ) );
599}
600
601
602void PANEL_PREVIEW_3D_MODEL::onUnitsChanged( wxCommandEvent& aEvent )
603{
605 xoff->GetValue() )
608 yoff->GetValue() )
611 zoff->GetValue() )
613
614 PCB_BASE_FRAME* frame = static_cast<PCB_BASE_FRAME*>( aEvent.GetClientData() );
615 m_userUnits = frame->GetUserUnits();
616
617 xoff->SetValue( formatOffsetValue( xoff_mm ) );
618 yoff->SetValue( formatOffsetValue( yoff_mm ) );
619 zoff->SetValue( formatOffsetValue( zoff_mm ) );
620
621 aEvent.Skip();
622}
623
624
625void PANEL_PREVIEW_3D_MODEL::onPanelShownEvent( wxCommandEvent& aEvent )
626{
627 if( m_spaceMouse != nullptr )
628 {
629 m_spaceMouse->SetFocus( static_cast<bool>( aEvent.GetInt() ) );
630 }
631
632 aEvent.Skip();
633}
634
635
637{
638 m_dummyFootprint->Models().clear();
639
640 for( FP_3DMODEL& model : *m_parentModelList )
641 {
642 if( model.m_Show )
643 m_dummyFootprint->Models().push_back( model );
644 }
645
646 if( aReloadRequired )
648
650}
651
652
654{
655 if( DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( wxGetTopLevelParent( this ) ) )
656 dlg->OnModify();
657}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:111
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: board_adapter.h:66
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
bool m_IsPreviewer
true if we're in a 3D preview panel, false for the standard 3D viewer
void SetBoard(BOARD *aBoard) noexcept
Set current board to be rendered.
EDA_3D_VIEWER_SETTINGS * m_Cfg
bool m_MousewheelPanning
Container for design settings for a BOARD object.
void SetEnabledLayers(LSET aMask)
Change the bit-mask of enabled layers to aMask.
int GetBoardThickness() const
The full thickness of the board including copper and masks.
BOARD_STACKUP & GetStackupDescriptor()
void SetBoardThickness(int aThickness)
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:89
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.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:998
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:302
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition: board.cpp:197
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:890
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:88
int ShowModal() override
EDA_3D_ACTIONS.
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:49
void SetProjectionMode(int aMode)
void SetInfoBar(WX_INFOBAR *aInfoBar)
Definition: eda_3d_canvas.h:79
void SetAnimationEnabled(bool aEnable)
Enable or disable camera animation when switching to a pre-defined view.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void ReloadRequest(BOARD *aBoard=nullptr, S3D_CACHE *aCachePointer=nullptr)
void SetMovingSpeedMultiplier(int aMultiplier)
Set the camera animation moving speed multiplier option.
void Request_refresh(bool aRedrawImmediately=true)
Schedule a refresh update of the canvas.
EDA_3D_CONTROLLER.
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2411
bool IsFlipped() const
Definition: footprint.h:391
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: footprint.cpp:2283
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:220
VECTOR2I GetPosition() const override
Definition: footprint.h:224
VECTOR3D m_Offset
3D model offset (mm)
Definition: footprint.h:101
double m_Opacity
Definition: footprint.h:102
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: footprint.h:100
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: footprint.h:99
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
Definition: lset.cpp:772
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:779
The class that implements the public interface to the SpaceMouse plug-in.
void SetFocus(bool aFocus=true)
Set the connection to the 3Dconnexion driver to the focus state so that 3DMouse data is routed here.
static const wxGLAttributes GetAttributesList(ANTIALIASING_MODE aAntiAliasingMode, bool aAlpha=false)
Get a list of attributes to pass to wxGLCanvas.
Class PANEL_PREVIEW_3D_MODEL_BASE.
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
true if the board body is show
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.
NL_FOOTPRINT_PROPERTIES_PLUGIN * m_spaceMouse
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 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
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.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:679
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
static S3D_CACHE * Get3DCacheManager(PROJECT *aProject, bool updateProjDir=false)
Return a pointer to an instance of the 3D cache manager.
Definition: project_pcb.cpp:77
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
void SetBitmap(const wxBitmapBundle &aBmp)
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:169
ACTIONS * m_actions
Definition: tools_holder.h:168
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
Master controller class:
Definition: tool_manager.h:62
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void InitTools()
Initializes all registered tools.
EDA_UNITS GetUserUnits() const
T y
Definition: vector3.h:64
T z
Definition: vector3.h:65
T x
Definition: vector3.h:63
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:76
An extension of WX_TEXT_ENTRY_DIALOG that uses UNIT_BINDER to request a dimension (e....
int GetValue()
Returns the value in internal units.
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition: eda_angle.h:401
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function DoubleValueFromString converts aTextValue to a double.
Definition: eda_units.cpp:576
KICOMMON_API wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
Definition: eda_units.cpp:126
KICOMMON_API wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:130
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.
#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
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
const double IU_PER_MM
Definition: base_units.h:76