KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 <mrluzeiro@ua.pt>
5 * Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
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
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 ) :
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 BOARD_DESIGN_SETTINGS parent_bds = aFrame->GetDesignSettings();
73 dummy_bds.SetBoardThickness( parent_bds.GetBoardThickness() );
76 dummy_board_stackup.RemoveAll();
77 dummy_board_stackup.BuildDefaultStackupList( &dummy_bds, 2 );
78
79 m_selected = -1;
80
81 m_previewLabel->SetFont( KIUI::GetStatusFont( this ) );
82
83 // Set the bitmap of 3D view buttons:
84 m_bpvTop->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_top ) );
85 m_bpvFront->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_front ) );
86 m_bpvBack->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_back ) );
87 m_bpvLeft->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_left ) );
88 m_bpvRight->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_right ) );
89 m_bpvBottom->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_bottom ) );
90 m_bpvISO->SetBitmap( KiBitmapBundle( BITMAPS::ortho ) );
91 m_bpvBodyStyle->SetBitmap( KiBitmapBundle( BITMAPS::show_board_body ) );
92 m_bpUpdate->SetBitmap( KiBitmapBundle( BITMAPS::reload ) );
93 m_bpSettings->SetBitmap( KiBitmapBundle( BITMAPS::options_3drender ) );
94
95 // Set the min and max values of spin buttons (mandatory on Linux)
96 // They are not used, so they are set to min and max 32 bits int values
97 // (the min and max values supported by a wxSpinButton)
98 // It avoids blocking the up or down arrows when reaching this limit after
99 // a few clicks.
100 wxSpinButton* spinButtonList[] =
101 {
105 };
106
107 for( wxSpinButton* button : spinButtonList )
108 button->SetRange(INT_MIN, INT_MAX );
109
110 m_parentModelList = aParentModelList;
111
112 m_dummyFootprint = new FOOTPRINT( *aFootprint );
114
115 // Ensure the footprint is shown like in Fp editor: rot 0, not flipped
116 // to avoid mistakes when setting the3D shape position/rotation
118 m_dummyFootprint->Flip( m_dummyFootprint->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
119
121
122
124
125 // Create the 3D canvas
126 m_previewPane = new EDA_3D_CANVAS( this,
127 OGL_ATT_LIST::GetAttributesList( ANTIALIASING_MODE::AA_8X ),
129 PROJECT_PCB::Get3DCacheManager( &aFrame->Prj() ) );
130
131 try
132 {
133 m_spaceMouse = std::make_unique<NL_FOOTPRINT_PROPERTIES_PLUGIN>( m_previewPane );
134 m_spaceMouse->SetFocus( true );
135 }
136 catch( const std::system_error& e )
137 {
138 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
139 }
140
143
144 // Force display 3D models, regardless the 3D viewer options.
146
147 loadSettings();
148
149 // Create the manager
151 m_toolManager->SetEnvironment( m_dummyBoard, nullptr, nullptr, nullptr, this );
152
156
157 // Register tools
160
161 // Run the viewer control tool, it is supposed to be always active
162 m_toolManager->InvokeTool( "3DViewer.Control" );
163
164 m_infobar = new WX_INFOBAR( this );
166
167 m_SizerPanelView->Add( m_infobar, 0, wxEXPAND, 0 );
168 m_SizerPanelView->Add( m_previewPane, 1, wxEXPAND, 5 );
169
170 for( wxEventType eventType : { wxEVT_MENU_OPEN, wxEVT_MENU_CLOSE, wxEVT_MENU_HIGHLIGHT } )
171 {
172 Connect( eventType, wxMenuEventHandler( PANEL_PREVIEW_3D_MODEL::OnMenuEvent ), nullptr,
173 this );
174 }
175
176 aFrame->Connect( EDA_EVT_UNITS_CHANGED,
177 wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL::onUnitsChanged ),
178 nullptr, this );
179
180 Bind( wxCUSTOM_PANEL_SHOWN_EVENT, &PANEL_PREVIEW_3D_MODEL::onPanelShownEvent, this );
181}
182
183
185{
186 // Restore the 3D viewer Render settings, that can be modified by the panel tools
189
190 delete m_dummyBoard;
191 delete m_previewPane;
192}
193
194
195void PANEL_PREVIEW_3D_MODEL::OnMenuEvent( wxMenuEvent& aEvent )
196{
197 if( !m_toolDispatcher )
198 aEvent.Skip();
199 else
201}
202
203
205{
206 wxCHECK_RET( m_previewPane, wxT( "Cannot load settings to null canvas" ) );
207
208 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
209
210 // TODO(JE) use all control options
212
215
216 if( cfg )
217 {
218 // Save the 3D viewer render settings, to restore it after closing the preview
220
221 m_boardAdapter.m_Cfg = cfg;
222
226 }
227}
228
229
235static double rotationFromString( const wxString& aValue )
236{
238 aValue );
239
240 if( rotation > MAX_ROTATION )
241 {
242 int n = KiROUND( rotation / MAX_ROTATION );
243 rotation -= MAX_ROTATION * n;
244 }
245 else if( rotation < -MAX_ROTATION )
246 {
247 int n = KiROUND( -rotation / MAX_ROTATION );
248 rotation += MAX_ROTATION * n;
249 }
250
251 return rotation;
252}
253
254
256{
257 return wxString::Format( wxT( "%.4f" ),
258 aValue );
259}
260
261
263{
264 // Sigh. Did we really need differentiated +/- 0.0?
265 if( aValue == -0.0 )
266 aValue = 0.0;
267
268 return wxString::Format( wxT( "%.2f%s" ),
269 aValue,
270 EDA_UNIT_UTILS::GetText( EDA_UNITS::DEGREES ) );
271}
272
273
275{
276 // Convert from internal units (mm) to user units
277 if( m_userUnits == EDA_UNITS::INCH )
278 aValue /= 25.4;
279 else if( m_userUnits == EDA_UNITS::MILS )
280 aValue /= 25.4 / 1e3;
281
282 return wxString::Format( wxT( "%.6f%s" ),
283 aValue,
285}
286
287
289{
290 if( m_parentModelList && idx >= 0 && idx < (int) m_parentModelList->size() )
291 {
292 m_selected = idx;
293 const FP_3DMODEL& modelInfo = m_parentModelList->at( (unsigned) m_selected );
294
295 // Use ChangeValue() instead of SetValue(). It's not the user making the change, so we
296 // don't want to generate wxEVT_GRID_CELL_CHANGED events.
297 xscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.x ) );
298 yscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.y ) );
299 zscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.z ) );
300
301 // Rotation is stored in the file as positive-is-CW, but we use positive-is-CCW in the GUI
302 // to match the rest of KiCad
303 xrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.x ) );
304 yrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.y ) );
305 zrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.z ) );
306
307 xoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.x ) );
308 yoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.y ) );
309 zoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.z ) );
310
311 m_opacity->SetValue( modelInfo.m_Opacity * 100.0 );
312 }
313 else
314 {
315 m_selected = -1;
316
317 xscale->ChangeValue( wxEmptyString );
318 yscale->ChangeValue( wxEmptyString );
319 zscale->ChangeValue( wxEmptyString );
320
321 xrot->ChangeValue( wxEmptyString );
322 yrot->ChangeValue( wxEmptyString );
323 zrot->ChangeValue( wxEmptyString );
324
325 xoff->ChangeValue( wxEmptyString );
326 yoff->ChangeValue( wxEmptyString );
327 zoff->ChangeValue( wxEmptyString );
328
329 m_opacity->SetValue( 100 );
330 }
331}
332
333
334void PANEL_PREVIEW_3D_MODEL::updateOrientation( wxCommandEvent &event )
335{
336 if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
337 {
338 // Write settings back to the parent
339 FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
340
342 pcbIUScale, EDA_UNITS::UNSCALED, xscale->GetValue() );
344 pcbIUScale, EDA_UNITS::UNSCALED, yscale->GetValue() );
346 pcbIUScale, EDA_UNITS::UNSCALED, zscale->GetValue() );
347
348 // Rotation is stored in the file as positive-is-CW, but we use positive-is-CCW in the GUI
349 // to match the rest of KiCad
350 modelInfo->m_Rotation.x = -rotationFromString( xrot->GetValue() );
351 modelInfo->m_Rotation.y = -rotationFromString( yrot->GetValue() );
352 modelInfo->m_Rotation.z = -rotationFromString( zrot->GetValue() );
353
355 xoff->GetValue() )
358 yoff->GetValue() )
361 zoff->GetValue() )
363
364 // Update the dummy footprint for the preview
365 UpdateDummyFootprint( false );
366 onModify();
367 }
368}
369
370
371void PANEL_PREVIEW_3D_MODEL::onOpacitySlider( wxCommandEvent& event )
372{
373 if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
374 {
375 // Write settings back to the parent
376 FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
377
378 modelInfo->m_Opacity = m_opacity->GetValue() / 100.0;
379
380 // Update the dummy footprint for the preview
381 UpdateDummyFootprint( false );
382 onModify();
383 }
384}
385
386
387void PANEL_PREVIEW_3D_MODEL::setBodyStyleView( wxCommandEvent& event )
388{
389 // turn ON or OFF options to show the board body if OFF, solder paste, soldermask
390 // and board body are hidden, to allows a good view of the 3D model and its pads.
392
393 if( !cfg )
394 return;
395
397
399 m_previewPane->Refresh();
400}
401
402
403void PANEL_PREVIEW_3D_MODEL::View3DSettings( wxCommandEvent& event )
404{
406 int thickness = bds.GetBoardThickness();
407
408 WX_UNIT_ENTRY_DIALOG dlg( m_parentFrame, _( "3D Preview Options" ), _( "Board thickness:" ),
409 thickness );
410
411 if( dlg.ShowModal() != wxID_OK )
412 return;
413
414 bds.SetBoardThickness( dlg.GetValue() );
415
417 boardStackup.RemoveAll();
418 boardStackup.BuildDefaultStackupList( &bds, 2 );
419
420 UpdateDummyFootprint( true );
421
423 m_previewPane->Refresh();
424}
425
426
427void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double aSign )
428{
429 wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
430
431 wxTextCtrl * textCtrl = xscale;
432
433 if( spinCtrl == m_spinYscale )
434 textCtrl = yscale;
435 else if( spinCtrl == m_spinZscale )
436 textCtrl = zscale;
437
438 double step = SCALE_INCREMENT;
439
440 if( wxGetMouseState().ShiftDown( ) )
442
443 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
444 textCtrl->GetValue() );
445
446 curr_value += ( step * aSign );
447 curr_value = std::max( 1/MAX_SCALE, curr_value );
448 curr_value = std::min( curr_value, MAX_SCALE );
449
450 textCtrl->SetValue( formatScaleValue( curr_value ) );
451}
452
453
454void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aSign )
455{
456 wxSpinButton* spinCtrl = (wxSpinButton*) aEvent.GetEventObject();
457 wxTextCtrl* textCtrl = xrot;
458
459 if( spinCtrl == m_spinYrot )
460 textCtrl = yrot;
461 else if( spinCtrl == m_spinZrot )
462 textCtrl = zrot;
463
464 double step = ROTATION_INCREMENT;
465
466 if( wxGetMouseState().ShiftDown( ) )
468
469 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
470 textCtrl->GetValue() );
471
472 curr_value += ( step * aSign );
473 curr_value = std::max( -MAX_ROTATION, curr_value );
474 curr_value = std::min( curr_value, MAX_ROTATION );
475
476 textCtrl->SetValue( formatRotationValue( curr_value ) );
477}
478
479
480void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double aSign )
481{
482 wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
483
484 wxTextCtrl * textCtrl = xoff;
485
486 if( spinCtrl == m_spinYoffset )
487 textCtrl = yoff;
488 else if( spinCtrl == m_spinZoffset )
489 textCtrl = zoff;
490
491 double step_mm = OFFSET_INCREMENT_MM;
492
493 if( wxGetMouseState().ShiftDown( ) )
494 step_mm = OFFSET_INCREMENT_MM_FINE;
495
496 if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCH )
497 {
498 step_mm = 25.4*OFFSET_INCREMENT_MIL/1000;
499
500 if( wxGetMouseState().ShiftDown( ) )
501 step_mm = 25.4*OFFSET_INCREMENT_MIL_FINE/1000;;
502 }
503
505 textCtrl->GetValue() )
507
508 curr_value_mm += ( step_mm * aSign );
509 curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm );
510 curr_value_mm = std::min( curr_value_mm, MAX_OFFSET );
511
512 textCtrl->SetValue( formatOffsetValue( curr_value_mm ) );
513}
514
515
517{
518 wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
519
520 double step = SCALE_INCREMENT;
521
522 if( event.ShiftDown( ) )
524
525 if( event.GetWheelRotation() >= 0 )
526 step = -step;
527
528 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
529 textCtrl->GetValue() );
530
531 curr_value += step;
532 curr_value = std::max( 1/MAX_SCALE, curr_value );
533 curr_value = std::min( curr_value, MAX_SCALE );
534
535 textCtrl->SetValue( formatScaleValue( curr_value ) );
536}
537
538
540{
541 wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
542
543 double step = ROTATION_INCREMENT;
544
545 if( event.ShiftDown( ) )
547
548 if( event.GetWheelRotation() >= 0 )
549 step = -step;
550
551 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
552 textCtrl->GetValue() );
553
554 curr_value += step;
555 curr_value = std::max( -MAX_ROTATION, curr_value );
556 curr_value = std::min( curr_value, MAX_ROTATION );
557
558 textCtrl->SetValue( formatRotationValue( curr_value ) );
559}
560
561
563{
564 wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
565
566 double step_mm = OFFSET_INCREMENT_MM;
567
568 if( event.ShiftDown( ) )
569 step_mm = OFFSET_INCREMENT_MM_FINE;
570
571 if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCH )
572 {
573 step_mm = 25.4*OFFSET_INCREMENT_MIL/1000.0;
574
575 if( event.ShiftDown( ) )
576 step_mm = 25.4*OFFSET_INCREMENT_MIL_FINE/1000.0;
577 }
578
579 if( event.GetWheelRotation() >= 0 )
580 step_mm = -step_mm;
581
583 textCtrl->GetValue() )
585
586 curr_value_mm += step_mm;
587 curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm );
588 curr_value_mm = std::min( curr_value_mm, MAX_OFFSET );
589
590 textCtrl->SetValue( formatOffsetValue( curr_value_mm ) );
591}
592
593
594void PANEL_PREVIEW_3D_MODEL::onUnitsChanged( wxCommandEvent& aEvent )
595{
597 xoff->GetValue() )
600 yoff->GetValue() )
603 zoff->GetValue() )
605
606 PCB_BASE_FRAME* frame = static_cast<PCB_BASE_FRAME*>( aEvent.GetClientData() );
607 m_userUnits = frame->GetUserUnits();
608
609 xoff->SetValue( formatOffsetValue( xoff_mm ) );
610 yoff->SetValue( formatOffsetValue( yoff_mm ) );
611 zoff->SetValue( formatOffsetValue( zoff_mm ) );
612
613 aEvent.Skip();
614}
615
616
617void PANEL_PREVIEW_3D_MODEL::onPanelShownEvent( wxCommandEvent& aEvent )
618{
619 if( m_spaceMouse )
620 {
621 m_spaceMouse->SetFocus( static_cast<bool>( aEvent.GetInt() ) );
622 }
623
624 aEvent.Skip();
625}
626
627
629{
630 m_dummyFootprint->Models().clear();
631
632 for( FP_3DMODEL& model : *m_parentModelList )
633 {
634 if( model.m_Show )
635 m_dummyFootprint->Models().push_back( model );
636 }
637
638 if( aReloadRequired )
640
642}
643
644
646{
647 KIWAY_HOLDER* kiwayHolder = dynamic_cast<KIWAY_HOLDER*>( wxGetTopLevelParent( this ) );
648
649 if( kiwayHolder && kiwayHolder->GetType() == KIWAY_HOLDER::DIALOG )
650 static_cast<DIALOG_SHIM*>( kiwayHolder )->OnModify();
651}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:111
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)
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:93
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:297
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:1060
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:309
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition: board.cpp:195
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:946
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:52
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.
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2538
bool IsFlipped() const
Definition: footprint.h:396
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: footprint.cpp:2397
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:225
VECTOR2I GetPosition() const override
Definition: footprint.h:229
VECTOR3D m_Offset
3D model offset (mm)
Definition: footprint.h:106
double m_Opacity
Definition: footprint.h:107
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: footprint.h:105
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: footprint.h:104
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 LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
Definition: lset.cpp:683
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:690
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.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Return the BOARD_DESIGN_SETTINGS for the open project.
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:687
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
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(const wxString &aFilename)
Return a handle to the a given settings by type.
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:401
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:497
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:127
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:1071
see class PGM_BASE
const double IU_PER_MM
Definition: base_units.h:76