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
31#include <tool/tool_manager.h>
35#include <base_units.h>
36#include <bitmaps.h>
37#include <board.h>
39#include <dpi_scaling_common.h>
40#include <lset.h>
41#include <pgm_base.h>
42#include <project_pcb.h>
45#include <widgets/wx_infobar.h>
49
51
53 FOOTPRINT* aFootprint,
54 std::vector<FP_3DMODEL>* aParentModelList ) :
56 m_parentFrame( aFrame ),
57 m_previewPane( nullptr ),
58 m_infobar( nullptr ),
59 m_boardAdapter(),
60 m_currentCamera( m_trackBallCamera ),
61 m_trackBallCamera( 2 * RANGE_SCALE_3D )
62{
64
65 m_dummyBoard = new BOARD();
66
67 m_dummyBoard->SetProject( &aFrame->Prj(), true );
69
70 // This board will only be used to hold a footprint for viewing
71 m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER );
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::show_board_body ) );
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
133 try
134 {
135 m_spaceMouse = std::make_unique<NL_FOOTPRINT_PROPERTIES_PLUGIN>( m_previewPane );
136 m_spaceMouse->SetFocus( true );
137 }
138 catch( const std::system_error& e )
139 {
140 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
141 }
142
145
146 // Force display 3D models, regardless the 3D viewer options.
148
149 loadSettings();
150
151 // Create the manager
153 m_toolManager->SetEnvironment( m_dummyBoard, nullptr, nullptr, nullptr, this );
154
158
159 // Register tools
162
163 // Run the viewer control tool, it is supposed to be always active
164 m_toolManager->InvokeTool( "3DViewer.Control" );
165
166 m_infobar = new WX_INFOBAR( this );
168
169 m_SizerPanelView->Add( m_infobar, 0, wxEXPAND, 0 );
170 m_SizerPanelView->Add( m_previewPane, 1, wxEXPAND, 5 );
171
172 for( wxEventType eventType : { wxEVT_MENU_OPEN, wxEVT_MENU_CLOSE, wxEVT_MENU_HIGHLIGHT } )
173 {
174 Connect( eventType, wxMenuEventHandler( PANEL_PREVIEW_3D_MODEL::OnMenuEvent ), nullptr,
175 this );
176 }
177
178 aFrame->Connect( EDA_EVT_UNITS_CHANGED,
179 wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL::onUnitsChanged ),
180 nullptr, this );
181
182 Bind( wxCUSTOM_PANEL_SHOWN_EVENT, &PANEL_PREVIEW_3D_MODEL::onPanelShownEvent, this );
183}
184
185
187{
188 // Restore the 3D viewer Render settings, that can be modified by the panel tools
191
192 delete m_dummyBoard;
193 delete m_previewPane;
194}
195
196
197void PANEL_PREVIEW_3D_MODEL::OnMenuEvent( wxMenuEvent& aEvent )
198{
199 if( !m_toolDispatcher )
200 aEvent.Skip();
201 else
203}
204
205
207{
208 wxCHECK_RET( m_previewPane, wxT( "Cannot load settings to null canvas" ) );
209
210 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
211
212 // TODO(JE) use all control options
214
215 if( EDA_3D_VIEWER_SETTINGS* cfg = GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) )
216 {
217 // Save the 3D viewer render settings, to restore it after closing the preview
218 m_initialRender = cfg->m_Render;
219
220 m_boardAdapter.m_Cfg = cfg;
221
222 m_previewPane->SetAnimationEnabled( cfg->m_Camera.animation_enabled );
223 m_previewPane->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier );
224 m_previewPane->SetProjectionMode( cfg->m_Camera.projection_mode );
225 }
226}
227
228
234static double rotationFromString( const wxString& aValue )
235{
237 aValue );
238
239 if( rotation > MAX_ROTATION )
240 {
241 int n = KiROUND( rotation / MAX_ROTATION );
242 rotation -= MAX_ROTATION * n;
243 }
244 else if( rotation < -MAX_ROTATION )
245 {
246 int n = KiROUND( -rotation / MAX_ROTATION );
247 rotation += MAX_ROTATION * n;
248 }
249
250 return rotation;
251}
252
253
255{
256 return wxString::Format( wxT( "%.4f" ),
257 aValue );
258}
259
260
262{
263 // Sigh. Did we really need differentiated +/- 0.0?
264 if( aValue == -0.0 )
265 aValue = 0.0;
266
267 return wxString::Format( wxT( "%.2f%s" ),
268 aValue,
269 EDA_UNIT_UTILS::GetText( EDA_UNITS::DEGREES ) );
270}
271
272
274{
275 // Convert from internal units (mm) to user units
276 if( m_userUnits == EDA_UNITS::INCH )
277 aValue /= 25.4;
278 else if( m_userUnits == EDA_UNITS::MILS )
279 aValue /= 25.4 / 1e3;
280
281 return wxString::Format( wxT( "%.6f%s" ),
282 aValue,
284}
285
286
288{
289 if( m_parentModelList && idx >= 0 && idx < (int) m_parentModelList->size() )
290 {
291 m_selected = idx;
292 const FP_3DMODEL& modelInfo = m_parentModelList->at( (unsigned) m_selected );
293
294 // Use ChangeValue() instead of SetValue(). It's not the user making the change, so we
295 // don't want to generate wxEVT_GRID_CELL_CHANGED events.
296 xscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.x ) );
297 yscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.y ) );
298 zscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.z ) );
299
300 // Rotation is stored in the file as positive-is-CW, but we use positive-is-CCW in the GUI
301 // to match the rest of KiCad
302 xrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.x ) );
303 yrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.y ) );
304 zrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.z ) );
305
306 xoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.x ) );
307 yoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.y ) );
308 zoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.z ) );
309
310 m_opacity->SetValue( modelInfo.m_Opacity * 100.0 );
311 }
312 else
313 {
314 m_selected = -1;
315
316 xscale->ChangeValue( wxEmptyString );
317 yscale->ChangeValue( wxEmptyString );
318 zscale->ChangeValue( wxEmptyString );
319
320 xrot->ChangeValue( wxEmptyString );
321 yrot->ChangeValue( wxEmptyString );
322 zrot->ChangeValue( wxEmptyString );
323
324 xoff->ChangeValue( wxEmptyString );
325 yoff->ChangeValue( wxEmptyString );
326 zoff->ChangeValue( wxEmptyString );
327
328 m_opacity->SetValue( 100 );
329 }
330}
331
332
333void PANEL_PREVIEW_3D_MODEL::updateOrientation( wxCommandEvent &event )
334{
335 if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
336 {
337 // Write settings back to the parent
338 FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
339
341 pcbIUScale, EDA_UNITS::UNSCALED, xscale->GetValue() );
343 pcbIUScale, EDA_UNITS::UNSCALED, yscale->GetValue() );
345 pcbIUScale, EDA_UNITS::UNSCALED, zscale->GetValue() );
346
347 // Rotation is stored in the file as positive-is-CW, but we use positive-is-CCW in the GUI
348 // to match the rest of KiCad
349 modelInfo->m_Rotation.x = -rotationFromString( xrot->GetValue() );
350 modelInfo->m_Rotation.y = -rotationFromString( yrot->GetValue() );
351 modelInfo->m_Rotation.z = -rotationFromString( zrot->GetValue() );
352
354 xoff->GetValue() )
357 yoff->GetValue() )
360 zoff->GetValue() )
362
363 // Update the dummy footprint for the preview
364 UpdateDummyFootprint( false );
365 onModify();
366 }
367}
368
369
370void PANEL_PREVIEW_3D_MODEL::onOpacitySlider( wxCommandEvent& event )
371{
372 if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
373 {
374 // Write settings back to the parent
375 FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
376
377 modelInfo->m_Opacity = m_opacity->GetValue() / 100.0;
378
379 // Update the dummy footprint for the preview
380 UpdateDummyFootprint( false );
381 onModify();
382 }
383}
384
385
386void PANEL_PREVIEW_3D_MODEL::setBodyStyleView( wxCommandEvent& event )
387{
388 // turn ON or OFF options to show the board body if OFF, solder paste, soldermask
389 // and board body are hidden, to allows a good view of the 3D model and its pads.
391
392 if( !cfg )
393 return;
394
396
398 m_previewPane->Refresh();
399}
400
401
402void PANEL_PREVIEW_3D_MODEL::View3DSettings( wxCommandEvent& event )
403{
405 int thickness = bds.GetBoardThickness();
406
407 WX_UNIT_ENTRY_DIALOG dlg( m_parentFrame, _( "3D Preview Options" ), _( "Board thickness:" ),
408 thickness );
409
410 if( dlg.ShowModal() != wxID_OK )
411 return;
412
413 bds.SetBoardThickness( dlg.GetValue() );
414
416 boardStackup.RemoveAll();
417 boardStackup.BuildDefaultStackupList( &bds, 2 );
418
419 UpdateDummyFootprint( true );
420
422 m_previewPane->Refresh();
423}
424
425
426void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double aSign )
427{
428 wxSpinButton* spinCtrl = dynamic_cast<wxSpinButton*>( event.GetEventObject() );
429
430 wxCHECK( spinCtrl, /* void */ );
431
432 wxTextCtrl * textCtrl = xscale;
433
434 if( spinCtrl == m_spinYscale )
435 textCtrl = yscale;
436 else if( spinCtrl == m_spinZscale )
437 textCtrl = zscale;
438
439 double step = SCALE_INCREMENT;
440
441 if( wxGetMouseState().ShiftDown( ) )
443
444 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
445 textCtrl->GetValue() );
446
447 curr_value += ( step * aSign );
448 curr_value = std::max( 1/MAX_SCALE, curr_value );
449 curr_value = std::min( curr_value, MAX_SCALE );
450
451 textCtrl->SetValue( formatScaleValue( curr_value ) );
452}
453
454
455void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aSign )
456{
457 wxSpinButton* spinCtrl = dynamic_cast<wxSpinButton*>( aEvent.GetEventObject() );
458
459 wxCHECK( spinCtrl, /* void */ );
460
461 wxTextCtrl* textCtrl = xrot;
462
463 if( spinCtrl == m_spinYrot )
464 textCtrl = yrot;
465 else if( spinCtrl == m_spinZrot )
466 textCtrl = zrot;
467
468 double step = ROTATION_INCREMENT;
469
470 if( wxGetMouseState().ShiftDown( ) )
472
473 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
474 textCtrl->GetValue() );
475
476 curr_value += ( step * aSign );
477 curr_value = std::max( -MAX_ROTATION, curr_value );
478 curr_value = std::min( curr_value, MAX_ROTATION );
479
480 textCtrl->SetValue( formatRotationValue( curr_value ) );
481}
482
483
484void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double aSign )
485{
486 wxSpinButton* spinCtrl = dynamic_cast<wxSpinButton*>( event.GetEventObject() );
487
488 wxCHECK( spinCtrl, /* void */ );
489
490 wxTextCtrl * textCtrl = xoff;
491
492 if( spinCtrl == m_spinYoffset )
493 textCtrl = yoff;
494 else if( spinCtrl == m_spinZoffset )
495 textCtrl = zoff;
496
497 double step_mm = OFFSET_INCREMENT_MM;
498
499 if( wxGetMouseState().ShiftDown( ) )
500 step_mm = OFFSET_INCREMENT_MM_FINE;
501
502 if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCH )
503 {
504 step_mm = 25.4*OFFSET_INCREMENT_MIL/1000;
505
506 if( wxGetMouseState().ShiftDown( ) )
507 step_mm = 25.4*OFFSET_INCREMENT_MIL_FINE/1000;;
508 }
509
511 textCtrl->GetValue() )
513
514 curr_value_mm += ( step_mm * aSign );
515 curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm );
516 curr_value_mm = std::min( curr_value_mm, MAX_OFFSET );
517
518 textCtrl->SetValue( formatOffsetValue( curr_value_mm ) );
519}
520
521
523{
524 wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( event.GetEventObject() );
525
526 wxCHECK( textCtrl, /* void */ );
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 = dynamic_cast<wxTextCtrl*>( event.GetEventObject() );
550
551 wxCHECK( textCtrl, /* void */ );
552
553 double step = ROTATION_INCREMENT;
554
555 if( event.ShiftDown( ) )
557
558 if( event.GetWheelRotation() >= 0 )
559 step = -step;
560
561 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
562 textCtrl->GetValue() );
563
564 curr_value += step;
565 curr_value = std::max( -MAX_ROTATION, curr_value );
566 curr_value = std::min( curr_value, MAX_ROTATION );
567
568 textCtrl->SetValue( formatRotationValue( curr_value ) );
569}
570
571
573{
574 wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( event.GetEventObject() );
575
576 wxCHECK( textCtrl, /* void */ );
577
578 double step_mm = OFFSET_INCREMENT_MM;
579
580 if( event.ShiftDown( ) )
581 step_mm = OFFSET_INCREMENT_MM_FINE;
582
583 if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCH )
584 {
585 step_mm = 25.4*OFFSET_INCREMENT_MIL/1000.0;
586
587 if( event.ShiftDown( ) )
588 step_mm = 25.4*OFFSET_INCREMENT_MIL_FINE/1000.0;
589 }
590
591 if( event.GetWheelRotation() >= 0 )
592 step_mm = -step_mm;
593
595 textCtrl->GetValue() )
597
598 curr_value_mm += step_mm;
599 curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm );
600 curr_value_mm = std::min( curr_value_mm, MAX_OFFSET );
601
602 textCtrl->SetValue( formatOffsetValue( curr_value_mm ) );
603}
604
605
606void PANEL_PREVIEW_3D_MODEL::onUnitsChanged( wxCommandEvent& aEvent )
607{
609 xoff->GetValue() )
612 yoff->GetValue() )
615 zoff->GetValue() )
617
618 PCB_BASE_FRAME* frame = static_cast<PCB_BASE_FRAME*>( aEvent.GetClientData() );
619 m_userUnits = frame->GetUserUnits();
620
621 xoff->SetValue( formatOffsetValue( xoff_mm ) );
622 yoff->SetValue( formatOffsetValue( yoff_mm ) );
623 zoff->SetValue( formatOffsetValue( zoff_mm ) );
624
625 aEvent.Skip();
626}
627
628
629void PANEL_PREVIEW_3D_MODEL::onPanelShownEvent( wxCommandEvent& aEvent )
630{
631 if( m_spaceMouse )
632 {
633 m_spaceMouse->SetFocus( static_cast<bool>( aEvent.GetInt() ) );
634 }
635
636 aEvent.Skip();
637}
638
639
641{
642 m_dummyFootprint->Models().clear();
643
644 for( FP_3DMODEL& model : *m_parentModelList )
645 {
646 if( model.m_Show )
647 m_dummyFootprint->Models().push_back( model );
648 }
649
650 if( aReloadRequired )
652
654}
655
656
658{
659 KIWAY_HOLDER* kiwayHolder = dynamic_cast<KIWAY_HOLDER*>( wxGetTopLevelParent( this ) );
660
661 if( kiwayHolder && kiwayHolder->GetType() == KIWAY_HOLDER::DIALOG )
662 static_cast<DIALOG_SHIM*>( kiwayHolder )->OnModify();
663}
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
#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(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.
BOARD_STACKUP & GetStackupDescriptor()
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.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:317
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:1147
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:329
void SetEmbeddedFilesDelegate(EMBEDDED_FILES *aDelegate)
Definition: board.h:1325
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition: board.cpp:196
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:1024
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:61
void OnModify()
int ShowModal() override
EDA_3D_ACTIONS.
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:51
void SetProjectionMode(int aMode)
void SetInfoBar(WX_INFOBAR *aInfoBar)
Definition: eda_3d_canvas.h:81
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.
Handle view actions for various 3D canvases.
virtual void SetParentGroup(EDA_GROUP *aGroup)
Definition: eda_item.h:115
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2595
bool IsFlipped() const
Definition: footprint.h:400
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: footprint.cpp:2454
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:223
VECTOR2I GetPosition() const override
Definition: footprint.h:227
VECTOR3D m_Offset
3D model offset (mm)
Definition: footprint.h:104
double m_Opacity
Definition: footprint.h:105
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: footprint.h:103
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: footprint.h:102
A mix in class which holds the location of a wxWindow's KIWAY.
Definition: kiway_holder.h:39
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
HOLDER_TYPE GetType() const
Definition: kiway_holder.h:48
static const LSET & FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
Definition: lset.cpp:705
static const LSET & BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:712
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
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 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:565
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
void SetBitmap(const wxBitmapBundle &aBmp)
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:171
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:173
ACTIONS * m_actions
Definition: tools_holder.h:172
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()
Initialize 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()
Return the value in internal units.
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition: eda_angle.h:411
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.
Definition: eda_units.cpp:569
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:144
KICOMMON_API wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:132
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
#define PANEL_PREVIEW_3D_MODEL_ID
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:902
see class PGM_BASE
const double IU_PER_MM
Definition: base_units.h:76