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 <pgm_base.h>
40#include <project_pcb.h>
43#include <widgets/wx_infobar.h>
47
49 FOOTPRINT* aFootprint,
50 std::vector<FP_3DMODEL>* aParentModelList ) :
51 PANEL_PREVIEW_3D_MODEL_BASE( aParent, wxID_ANY ),
52 m_parentFrame( aFrame ),
53 m_previewPane( nullptr ),
54 m_infobar( nullptr ),
55 m_boardAdapter(),
56 m_currentCamera( m_trackBallCamera ),
57 m_trackBallCamera( 2 * RANGE_SCALE_3D )
58{
60
61 m_dummyBoard = new BOARD();
62
63 m_dummyBoard->SetProject( &aFrame->Prj(), true );
64
65 // This board will only be used to hold a footprint for viewing
66 m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER );
67
68 m_bodyStyleShowAll = true;
69
70 BOARD_DESIGN_SETTINGS parent_bds = aFrame->GetDesignSettings();
72 dummy_bds.SetBoardThickness( parent_bds.GetBoardThickness() );
75 dummy_board_stackup.RemoveAll();
76 dummy_board_stackup.BuildDefaultStackupList( &dummy_bds, 2 );
77
78 m_selected = -1;
79
80 m_previewLabel->SetFont( KIUI::GetStatusFont( this ) );
81
82 // Set the bitmap of 3D view buttons:
83 m_bpvTop->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_top ) );
84 m_bpvFront->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_front ) );
85 m_bpvBack->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_back ) );
86 m_bpvLeft->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_left ) );
87 m_bpvRight->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_right ) );
88 m_bpvBottom->SetBitmap( KiBitmapBundle( BITMAPS::axis3d_bottom ) );
89 m_bpvISO->SetBitmap( KiBitmapBundle( BITMAPS::ortho ) );
90 m_bpvBodyStyle->SetBitmap( KiBitmapBundle( BITMAPS::axis3d ) );
91 m_bpUpdate->SetBitmap( KiBitmapBundle( BITMAPS::reload ) );
92 m_bpSettings->SetBitmap( KiBitmapBundle( BITMAPS::options_3drender ) );
93
94 // Set the min and max values of spin buttons (mandatory on Linux)
95 // They are not used, so they are set to min and max 32 bits int values
96 // (the min and max values supported by a wxSpinButton)
97 // It avoids blocking the up or down arrows when reaching this limit after
98 // a few clicks.
99 wxSpinButton* spinButtonList[] =
100 {
104 };
105
106 for( wxSpinButton* button : spinButtonList )
107 button->SetRange(INT_MIN, INT_MAX );
108
109 m_parentModelList = aParentModelList;
110
111 m_dummyFootprint = new FOOTPRINT( *aFootprint );
113
114 // Ensure the footprint is shown like in Fp editor: rot 0, not flipped
115 // to avoid mistakes when setting the3D shape position/rotation
118
120
121
123
124 // Create the 3D canvas
125 m_previewPane = new EDA_3D_CANVAS( this,
126 OGL_ATT_LIST::GetAttributesList( ANTIALIASING_MODE::AA_8X ),
128 PROJECT_PCB::Get3DCacheManager( &aFrame->Prj() ) );
129
132 m_boardAdapter.m_IsPreviewer = true; // Force display 3D models, regardless the 3D viewer options
133
134 loadSettings();
135
136 // Create the manager
138 m_toolManager->SetEnvironment( m_dummyBoard, nullptr, nullptr, nullptr, this );
139
143
144 // Register tools
147
148 // Run the viewer control tool, it is supposed to be always active
149 m_toolManager->InvokeTool( "3DViewer.Control" );
150
151 m_infobar = new WX_INFOBAR( this );
153
154 m_SizerPanelView->Add( m_infobar, 0, wxEXPAND, 0 );
155 m_SizerPanelView->Add( m_previewPane, 1, wxEXPAND, 5 );
156
157 for( wxEventType eventType : { wxEVT_MENU_OPEN, wxEVT_MENU_CLOSE, wxEVT_MENU_HIGHLIGHT } )
158 {
159 Connect( eventType, wxMenuEventHandler( PANEL_PREVIEW_3D_MODEL::OnMenuEvent ), nullptr,
160 this );
161 }
162
163 aFrame->Connect( EDA_EVT_UNITS_CHANGED,
164 wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL::onUnitsChanged ),
165 nullptr, this );
166}
167
168
170{
171 // Restore the 3D viewer Render settings, that can be modified by the panel tools
174
175 delete m_dummyBoard;
176 delete m_previewPane;
177}
178
179
180void PANEL_PREVIEW_3D_MODEL::OnMenuEvent( wxMenuEvent& aEvent )
181{
182 if( !m_toolDispatcher )
183 aEvent.Skip();
184 else
186}
187
188
190{
191 wxCHECK_RET( m_previewPane, wxT( "Cannot load settings to null canvas" ) );
192
193 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
194
195 const DPI_SCALING_COMMON dpi{ settings, this };
196 m_previewPane->SetScaleFactor( dpi.GetScaleFactor() );
197
198 // TODO(JE) use all control options
200
201 EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
202
203 if( cfg )
204 {
205 // Save the 3D viewer render settings, to restore it after closing the preview
207
208 m_boardAdapter.m_Cfg = cfg;
209
213
214 // Ensure the board body is always shown, and do not use the settings of the 3D viewer
222 }
223}
224
225
231static double rotationFromString( const wxString& aValue )
232{
234
235 if( rotation > MAX_ROTATION )
236 {
237 int n = KiROUND( rotation / MAX_ROTATION );
238 rotation -= MAX_ROTATION * n;
239 }
240 else if( rotation < -MAX_ROTATION )
241 {
242 int n = KiROUND( -rotation / MAX_ROTATION );
243 rotation += MAX_ROTATION * n;
244 }
245
246 return rotation;
247}
248
249
251{
252 return wxString::Format( wxT( "%.4f" ),
253 aValue );
254}
255
256
258{
259 return wxString::Format( wxT( "%.2f%s" ),
260 aValue,
261 EDA_UNIT_UTILS::GetText( EDA_UNITS::DEGREES ) );
262}
263
264
266{
267 // Convert from internal units (mm) to user units
268 if( m_userUnits == EDA_UNITS::INCHES )
269 aValue /= 25.4;
270 else if( m_userUnits == EDA_UNITS::MILS )
271 aValue /= 25.4 / 1e3;
272
273 return wxString::Format( wxT( "%.6f%s" ),
274 aValue,
276}
277
278
280{
281 if( m_parentModelList && idx >= 0 && idx < (int) m_parentModelList->size() )
282 {
283 m_selected = idx;
284 const FP_3DMODEL& modelInfo = m_parentModelList->at( (unsigned) m_selected );
285
286 // Use ChangeValue() instead of SetValue(). It's not the user making the change, so we
287 // don't want to generate wxEVT_GRID_CELL_CHANGED events.
288 xscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.x ) );
289 yscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.y ) );
290 zscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.z ) );
291
292 xrot->ChangeValue( formatRotationValue( modelInfo.m_Rotation.x ) );
293 yrot->ChangeValue( formatRotationValue( modelInfo.m_Rotation.y ) );
294 zrot->ChangeValue( formatRotationValue( modelInfo.m_Rotation.z ) );
295
296 xoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.x ) );
297 yoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.y ) );
298 zoff->ChangeValue( formatOffsetValue( modelInfo.m_Offset.z ) );
299
300 m_opacity->SetValue( modelInfo.m_Opacity * 100.0 );
301 }
302 else
303 {
304 m_selected = -1;
305
306 xscale->ChangeValue( wxEmptyString );
307 yscale->ChangeValue( wxEmptyString );
308 zscale->ChangeValue( wxEmptyString );
309
310 xrot->ChangeValue( wxEmptyString );
311 yrot->ChangeValue( wxEmptyString );
312 zrot->ChangeValue( wxEmptyString );
313
314 xoff->ChangeValue( wxEmptyString );
315 yoff->ChangeValue( wxEmptyString );
316 zoff->ChangeValue( wxEmptyString );
317
318 m_opacity->SetValue( 100 );
319 }
320}
321
322
323void PANEL_PREVIEW_3D_MODEL::updateOrientation( wxCommandEvent &event )
324{
325 if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
326 {
327 // Write settings back to the parent
328 FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
329
331 pcbIUScale, EDA_UNITS::UNSCALED, xscale->GetValue() );
333 pcbIUScale, EDA_UNITS::UNSCALED, yscale->GetValue() );
335 pcbIUScale, EDA_UNITS::UNSCALED, zscale->GetValue() );
336
337 modelInfo->m_Rotation.x = rotationFromString( xrot->GetValue() );
338 modelInfo->m_Rotation.y = rotationFromString( yrot->GetValue() );
339 modelInfo->m_Rotation.z = rotationFromString( zrot->GetValue() );
340
342 xoff->GetValue() )
345 yoff->GetValue() )
348 zoff->GetValue() )
350
351 // Update the dummy footprint for the preview
352 UpdateDummyFootprint( false );
353 }
354}
355
356
357void PANEL_PREVIEW_3D_MODEL::onOpacitySlider( wxCommandEvent& event )
358{
359 if( m_parentModelList && m_selected >= 0 && m_selected < (int) m_parentModelList->size() )
360 {
361 // Write settings back to the parent
362 FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
363
364 modelInfo->m_Opacity = m_opacity->GetValue() / 100.0;
365
366 // Update the dummy footprint for the preview
367 UpdateDummyFootprint( false );
368 }
369}
370
371
372void PANEL_PREVIEW_3D_MODEL::setBodyStyleView( wxCommandEvent& event )
373{
374 // turn ON or OFF options to show the board body if OFF, soder paste, soldermask
375 // and board body are hidden, to allows a good view of the 3D model and its pads.
377
378 if( !cfg )
379 return;
380
382
388
390 m_previewPane->Refresh();
391}
392
393
394void PANEL_PREVIEW_3D_MODEL::View3DSettings( wxCommandEvent& event )
395{
397 int thickness = bds.GetBoardThickness();
398
399 WX_UNIT_ENTRY_DIALOG dlg( m_parentFrame, _( "3D Preview Options" ), _( "Board thickness:" ),
400 thickness );
401
402 if( dlg.ShowModal() != wxID_OK )
403 return;
404
405 bds.SetBoardThickness( dlg.GetValue() );
406
408 boardStackup.RemoveAll();
409 boardStackup.BuildDefaultStackupList( &bds, 2 );
410
411 UpdateDummyFootprint( true );
412
414 m_previewPane->Refresh();
415}
416
417
418void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double aSign )
419{
420 wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
421
422 wxTextCtrl * textCtrl = xscale;
423
424 if( spinCtrl == m_spinYscale )
425 textCtrl = yscale;
426 else if( spinCtrl == m_spinZscale )
427 textCtrl = zscale;
428
429 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
430 textCtrl->GetValue() );
431
432 curr_value += ( SCALE_INCREMENT * aSign );
433 curr_value = std::max( 1/MAX_SCALE, curr_value );
434 curr_value = std::min( curr_value, MAX_SCALE );
435
436 textCtrl->SetValue( formatScaleValue( curr_value ) );
437}
438
439
440void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aSign )
441{
442 wxSpinButton* spinCtrl = (wxSpinButton*) aEvent.GetEventObject();
443 wxTextCtrl* textCtrl = xrot;
444
445 if( spinCtrl == m_spinYrot )
446 textCtrl = yrot;
447 else if( spinCtrl == m_spinZrot )
448 textCtrl = zrot;
449
450 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
451 textCtrl->GetValue() );
452
453 curr_value += ( ROTATION_INCREMENT * aSign );
454 curr_value = std::max( -MAX_ROTATION, curr_value );
455 curr_value = std::min( curr_value, MAX_ROTATION );
456
457 textCtrl->SetValue( formatRotationValue( curr_value ) );
458}
459
460
461void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double aSign )
462{
463 wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
464
465 wxTextCtrl * textCtrl = xoff;
466
467 if( spinCtrl == m_spinYoffset )
468 textCtrl = yoff;
469 else if( spinCtrl == m_spinZoffset )
470 textCtrl = zoff;
471
472 double step_mm = OFFSET_INCREMENT_MM;
473 double curr_value_mm =
475 textCtrl->GetValue() )
477
478 if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCHES )
479 {
480 step_mm = 25.4*OFFSET_INCREMENT_MIL/1000;
481 }
482
483 curr_value_mm += ( step_mm * aSign );
484 curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm );
485 curr_value_mm = std::min( curr_value_mm, MAX_OFFSET );
486
487 textCtrl->SetValue( formatOffsetValue( curr_value_mm ) );
488}
489
490
492{
493 wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
494
495 double step = SCALE_INCREMENT;
496
497 if( event.ShiftDown( ) )
499
500 if( event.GetWheelRotation() >= 0 )
501 step = -step;
502
503 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
504 textCtrl->GetValue() );
505
506 curr_value += step;
507 curr_value = std::max( 1/MAX_SCALE, curr_value );
508 curr_value = std::min( curr_value, MAX_SCALE );
509
510 textCtrl->SetValue( formatScaleValue( curr_value ) );
511}
512
513
515{
516 wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
517
518 double step = ROTATION_INCREMENT_WHEEL;
519
520 if( event.ShiftDown( ) )
522
523 if( event.GetWheelRotation() >= 0 )
524 step = -step;
525
526 double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
527 textCtrl->GetValue() );
528
529 curr_value += step;
530 curr_value = std::max( -MAX_ROTATION, curr_value );
531 curr_value = std::min( curr_value, MAX_ROTATION );
532
533 textCtrl->SetValue( formatRotationValue( curr_value ) );
534}
535
536
538{
539 wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
540
541 double step_mm = OFFSET_INCREMENT_MM;
542
543 if( event.ShiftDown( ) )
544 step_mm = OFFSET_INCREMENT_MM_FINE;
545
546 if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCHES )
547 {
548 step_mm = 25.4*OFFSET_INCREMENT_MIL/1000.0;
549
550 if( event.ShiftDown( ) )
551 step_mm = 25.4*OFFSET_INCREMENT_MIL_FINE/1000.0;
552 }
553
554 if( event.GetWheelRotation() >= 0 )
555 step_mm = -step_mm;
556
558 textCtrl->GetValue() )
560
561 curr_value_mm += step_mm;
562 curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm );
563 curr_value_mm = std::min( curr_value_mm, MAX_OFFSET );
564
565 textCtrl->SetValue( formatOffsetValue( curr_value_mm ) );
566}
567
568
569void PANEL_PREVIEW_3D_MODEL::onUnitsChanged( wxCommandEvent& aEvent )
570{
572 xoff->GetValue() )
575 yoff->GetValue() )
578 zoff->GetValue() )
580
581 PCB_BASE_FRAME* frame = static_cast<PCB_BASE_FRAME*>( aEvent.GetClientData() );
582 m_userUnits = frame->GetUserUnits();
583
584 xoff->SetValue( formatOffsetValue( xoff_mm ) );
585 yoff->SetValue( formatOffsetValue( yoff_mm ) );
586 zoff->SetValue( formatOffsetValue( zoff_mm ) );
587
588 aEvent.Skip();
589}
590
591
593{
594 m_dummyFootprint->Models().clear();
595
596 for( FP_3DMODEL& model : *m_parentModelList )
597 {
598 if( model.m_Show )
599 m_dummyFootprint->Models().push_back( model );
600 }
601
602 if( aReloadRequired )
604
606}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:112
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
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:90
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:276
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:891
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:288
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition: board.cpp:199
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:806
Class to handle configuration and automatic determination of the DPI scale to use for canvases.
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:2128
bool IsFlipped() const
Definition: footprint.h:370
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:202
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1996
VECTOR2I GetPosition() const override
Definition: footprint.h:206
VECTOR3D m_Offset
3D model offset (mm)
Definition: footprint.h:98
double m_Opacity
Definition: footprint.h:99
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: footprint.h:97
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: footprint.h:96
void SetScaleFactor(double aFactor)
Set the canvas scale factor, probably for a hi-DPI display.
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:985
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:992
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.
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 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.
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: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:57
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:63
T z
Definition: vector3.h:64
T x
Definition: vector3.h:62
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:75
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:435
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:565
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:110
wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:127
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 ROTATION_INCREMENT_WHEEL_FINE
#define ROTATION_INCREMENT_WHEEL
#define SCALE_INCREMENT
#define OFFSET_INCREMENT_MM
#define ROTATION_INCREMENT
#define OFFSET_INCREMENT_MIL_FINE
#define SCALE_INCREMENT_FINE
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:119
const double IU_PER_MM
Definition: base_units.h:77
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85