KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_chooser_frame.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) 2023 CERN
5 * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <pgm_base.h>
26#include <kiface_base.h>
27#include <kiway.h>
28#include <kiway_express.h>
29#include <board.h>
30#include <wx/button.h>
31#include <wx/checkbox.h>
32#include <kiplatform/ui.h>
37#include "wx/display.h"
39#include <project_pcb.h>
42
43
44static wxArrayString s_FootprintHistoryList;
45static unsigned s_FootprintHistoryMaxCount = 8;
46
47static void AddFootprintToHistory( const wxString& aName )
48{
49 // Remove duplicates
50 for( int ii = (int) s_FootprintHistoryList.GetCount() - 1; ii >= 0; --ii )
51 {
52 if( s_FootprintHistoryList[ ii ] == aName )
53 s_FootprintHistoryList.RemoveAt( (size_t) ii );
54 }
55
56 // Add the new name at the beginning of the history list
57 s_FootprintHistoryList.Insert( aName, 0 );
58
59 // Remove extra names
61 s_FootprintHistoryList.RemoveAt( s_FootprintHistoryList.GetCount() - 1 );
62}
63
64
65BEGIN_EVENT_TABLE( FOOTPRINT_CHOOSER_FRAME, PCB_BASE_FRAME )
67 EVT_BUTTON( wxID_OK, FOOTPRINT_CHOOSER_FRAME::OnOK )
68 EVT_BUTTON( wxID_CANCEL, FOOTPRINT_CHOOSER_FRAME::closeFootprintChooser )
70END_EVENT_TABLE()
71
72
73#define MODAL_FRAME ( wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN \
74 | wxWANTS_CHARS | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP )
75
76
78 PCB_BASE_FRAME( aKiway, aParent, FRAME_FOOTPRINT_CHOOSER, _( "Footprint Chooser" ),
79 wxDefaultPosition, wxDefaultSize, MODAL_FRAME,
81 m_filterByPinCount( nullptr ),
82 m_filterByFPFilters( nullptr ),
83 m_boardAdapter(),
84 m_currentCamera( m_trackBallCamera ),
85 m_trackBallCamera( 2 * RANGE_SCALE_3D ),
86 m_pinCount( 0 ),
87 m_firstPaintEvent( true )
88{
89 SetModal( true );
90
91 m_showFpMode = true;
92 m_show3DMode = false;
93 m_messagePanel->Hide();
94
95 wxPanel* bottomPanel = new wxPanel( this );
96 wxBoxSizer* bottomSizer = new wxBoxSizer( wxVERTICAL );
97 wxBoxSizer* frameSizer = new wxBoxSizer( wxVERTICAL );
98
100 // Filter
101 [this]( LIB_TREE_NODE& aNode ) -> bool
102 {
103 return filterFootprint( aNode );
104 },
105 // Accept handler
106 [this]()
107 {
108 wxCommandEvent dummy;
109 OnOK( dummy );
110 },
111 // Escape handler
112 [this]()
113 {
114 DismissModal( false );
115 } );
116
117 frameSizer->Add( m_chooserPanel, 1, wxEXPAND );
118
119 SetBoard( new BOARD() );
120
121 // This board will only be used to hold a footprint for viewing
122 GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER );
123
124 build3DCanvas(); // must be called after creating m_chooserPanel
126
127 // buttonsSizer contains the BITMAP buttons
128 wxBoxSizer* buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
129
130 buttonsSizer->Add( 0, 0, 1, 0, 5 ); // Add spacer to right-align buttons
131
132 BITMAP_BUTTON* separator = new BITMAP_BUTTON( bottomPanel, wxID_ANY, wxNullBitmap );
133 separator->SetIsSeparator();
134 buttonsSizer->Add( separator, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
135
136 m_grButton3DView = new BITMAP_BUTTON( bottomPanel, wxID_ANY, wxNullBitmap );
138 m_grButton3DView->SetBitmap( KiBitmapBundle( BITMAPS::shape_3d ) );
140 buttonsSizer->Add( m_grButton3DView, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
141
142 m_grButtonFpView = new BITMAP_BUTTON( bottomPanel, wxID_ANY, wxNullBitmap );
144 m_grButtonFpView->SetBitmap( KiBitmapBundle( BITMAPS::module ) );
146 buttonsSizer->Add( m_grButtonFpView, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
147
148 separator = new BITMAP_BUTTON( bottomPanel, wxID_ANY, wxNullBitmap );
149 separator->SetIsSeparator();
150 buttonsSizer->Add( separator, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
151
152 m_show3DViewer = new wxCheckBox( bottomPanel, wxID_ANY, _( "Show 3D viewer in own window" ) );
153 buttonsSizer->Add( m_show3DViewer, 0, wxALL | wxALIGN_CENTER_VERTICAL, 3 );
154
155 wxStdDialogButtonSizer* sdbSizer = new wxStdDialogButtonSizer();
156 wxButton* okButton = new wxButton( bottomPanel, wxID_OK );
157 wxButton* cancelButton = new wxButton( bottomPanel, wxID_CANCEL );
158
159 sdbSizer->AddButton( okButton );
160 sdbSizer->AddButton( cancelButton );
161 sdbSizer->Realize();
162
163 buttonsSizer->Add( 20, 0, 0, 0, 5 ); // Add spacer
164 buttonsSizer->Add( sdbSizer, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
165 bottomSizer->Add( buttonsSizer, 0, wxEXPAND, 5 );
166
167 bottomPanel->SetSizer( bottomSizer );
168 frameSizer->Add( bottomPanel, 0, wxEXPAND );
169
170 SetSizer( frameSizer );
171
172 SetTitle( GetTitle() + wxString::Format( _( " (%d items loaded)" ),
174
175 Layout();
177
178 // Connect Events
179 m_grButton3DView->Connect( wxEVT_COMMAND_BUTTON_CLICKED ,
180 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::on3DviewReq ),
181 nullptr, this );
182
183 m_grButtonFpView->Connect( wxEVT_COMMAND_BUTTON_CLICKED ,
184 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::onFpViewReq ),
185 nullptr, this );
186
187 m_show3DViewer->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED ,
189 nullptr, this );
190
191 Connect( FP_SELECTION_EVENT, // custom event fired by a PANEL_FOOTPRINT_CHOOSER
192 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::onFpChanged ), nullptr, this );
193
194 // Needed on Linux to fix the position of widgets in bottomPanel
195 PostSizeEvent();
196}
197
198
200{
201 // Disconnect Events
202 m_grButton3DView->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
203 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::on3DviewReq ),
204 nullptr, this );
205 m_grButtonFpView->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
206 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::onFpViewReq ),
207 nullptr, this );
208
209 m_show3DViewer->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED ,
211 nullptr, this );
212
213 Disconnect( FP_SELECTION_EVENT,
214 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::onFpChanged ), nullptr, this );
215
216 if( PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
217 {
219 cfg->m_FootprintChooser.use_fp_filters = m_filterByFPFilters->GetValue();
220
222 cfg->m_FootprintChooser.filter_on_pin_count = m_filterByPinCount->GetValue();
223 }
224}
225
226
228{
229 if( aEvent.IsChecked() )
230 {
232 Show3DViewerFrame(); // show external 3D viewer
233 }
234 else
235 {
236 // Close the external 3D viewer frame, if it is still enabled
238
239 if( viewer3D )
240 viewer3D->Close( true );
241 }
242
244}
245
246
248{
249 bool do_reload_board = true; // reload board flag
250
251 // At EDA_3D_VIEWER_FRAME creation, the current board is loaded, so disable loading
252 // the current board if the 3D frame is not yet created
253 if( Get3DViewerFrame() == nullptr )
254 do_reload_board = false;
255
257
258 // A stronger version of Raise() which promotes the window to its parent's level.
260
261 // And load or update the current board (if needed)
262 if( do_reload_board )
263 Update3DView( true, true );
264}
265
266
268 bool aRefresh, const wxString* aTitle )
269{
271 wxString footprintName;
272
273 if( fpID.IsValid() )
274 footprintName << fpID.Format();
275
276 wxString title = _( "3D Viewer" ) + wxT( " \u2014 " ) + footprintName;
277 PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title );
278}
279
280
282{
284 return m_filterByPinCount->GetValue();
285
286 if( PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
287 return cfg->m_FootprintChooser.filter_on_pin_count;
288
289 return false;
290}
291
292
294{
296 return m_filterByFPFilters->GetValue();
297
298 if( PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
299 return cfg->m_FootprintChooser.use_fp_filters;
300
301 return false;
302}
303
304
306{
307 if( aNode.m_Type == LIB_TREE_NODE::TYPE::LIBRARY )
308 {
309 // Normally lib nodes get scored by the max of their children's scores. However, if a
310 // lib node *has* no children then the scorer will call the filter on the lib node itself,
311 // and we just want to return true if we're not filtering at all.
312 return !filterByPinCount() && !filterByFPFilters();
313 }
314
315 auto patternMatch =
316 []( LIB_ID& id, std::vector<std::unique_ptr<EDA_PATTERN_MATCH>>& filters ) -> bool
317 {
318 // The matching is case insensitive
319 wxString name;
320
321 for( const std::unique_ptr<EDA_PATTERN_MATCH>& filter : filters )
322 {
323 name.Empty();
324
325 // If the filter contains a ':' then include the library name in the pattern
326 if( filter->GetPattern().Contains( wxS( ":" ) ) )
327 name = id.GetUniStringLibNickname().Lower() + wxS( ":" );
328
329 name += id.GetUniStringLibItemName().Lower();
330
331 if( filter->Find( name ) )
332 return true;
333 }
334
335 return false;
336 };
337
338 if( m_pinCount > 0 && filterByPinCount() )
339 {
340 if( aNode.m_PinCount != m_pinCount )
341 return false;
342 }
343
344 if( !m_fpFilters.empty() && filterByFPFilters() )
345 {
346 if( !patternMatch( aNode.m_LibId, m_fpFilters ) )
347 return false;
348 }
349
350 return true;
351}
352
353
355{
356 // Only dismiss a modal frame once, so that the return values set by
357 // the prior DismissModal() are not bashed for ShowModal().
358 if( !IsDismissed() )
359 DismissModal( false );
360
361 // window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
362}
363
364
366{
367 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
368 wxCHECK_MSG( cfg, nullptr, wxT( "config not existing" ) );
369
370 return &cfg->m_FootprintViewer;
371}
372
373
375{
377
378 if( settings )
379 return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
380 else
382}
383
384
385static wxRect s_dialogRect( 0, 0, 0, 0 );
386
387
389{
390 const std::string& payload = mail.GetPayload();
391
392 switch( mail.Command() )
393 {
395 {
396 wxSizer* filtersSizer = m_chooserPanel->GetFiltersSizer();
397 wxWindow* filtersWindow = filtersSizer->GetContainingWindow();
398 wxString msg;
399
400 m_pinCount = 0;
401 m_fpFilters.clear();
402
403 /*
404 * Symbol netlist format:
405 * pinNumber pinName <tab> pinNumber pinName...
406 * fpFilter fpFilter...
407 */
408 std::map<wxString, wxString> pinNames;
409 std::vector<std::string> strings = split( payload, "\r" );
410
411 if( strings.size() >= 1 && !strings[0].empty() )
412 {
413 for( const wxString& pin : wxSplit( strings[0], '\t' ) )
414 pinNames[ pin.BeforeFirst( ' ' ) ] = pin.AfterFirst( ' ' );
415
416 m_pinCount = pinNames.size();
417
418 if( m_pinCount > 0 )
419 {
420 msg.Printf( _( "Filter by pin count (%d)" ), m_pinCount );
421 m_filterByPinCount = new wxCheckBox( filtersWindow, wxID_ANY, msg );
422
423 m_filterByPinCount->Bind( wxEVT_CHECKBOX,
424 [&]( wxCommandEvent& evt )
425 {
427 } );
428
429 if( PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
430 m_filterByPinCount->SetValue( cfg->m_FootprintChooser.filter_on_pin_count );
431 }
432 }
433
434 if( strings.size() >= 2 && !strings[1].empty() )
435 {
436 for( const wxString& filter : wxSplit( strings[1], ' ' ) )
437 {
438 m_fpFilters.push_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD_ANCHORED>() );
439 m_fpFilters.back()->SetPattern( filter.Lower() );
440 }
441
442 msg.Printf( _( "Apply footprint filters (%s)" ), strings[1] );
443 m_filterByFPFilters = new wxCheckBox( filtersWindow, wxID_ANY, msg );
444
445 m_filterByFPFilters->Bind( wxEVT_CHECKBOX,
446 [&]( wxCommandEvent& evt )
447 {
449 } );
450
451 if( PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
452 m_filterByFPFilters->SetValue( cfg->m_FootprintChooser.use_fp_filters );
453 }
454
456 m_chooserPanel->GetFiltersSizer()->Add( m_filterByFPFilters, 0, wxEXPAND|wxBOTTOM, 4 );
457
459 m_chooserPanel->GetFiltersSizer()->Add( m_filterByPinCount, 0, wxEXPAND|wxBOTTOM, 4 );
460
462
463 // Save the wxFormBuilder size of the dialog...
464 if( s_dialogRect.GetSize().x == 0 || s_dialogRect.GetSize().y == 0 )
465 s_dialogRect = wxRect( wxWindow::GetPosition(), wxWindow::GetSize() );
466
467 // ... and then give it a kick to get it to layout the new items
468 GetSizer()->SetSizeHints( this );
469 break;
470 }
471
472 default:
473 break;
474 }
475}
476
477
478bool FOOTPRINT_CHOOSER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
479{
480 if( aFootprint && !aFootprint->IsEmpty() )
481 {
482 LIB_ID fpid;
483
484 fpid.Parse( *aFootprint, true );
485
486 if( fpid.IsValid() )
488 }
489
490 return KIWAY_PLAYER::ShowModal( aFootprint, aParent );
491}
492
493
494void FOOTPRINT_CHOOSER_FRAME::SetPosition( const wxPoint& aNewPosition )
495{
496 PCB_BASE_FRAME::SetPosition( aNewPosition );
497
498 s_dialogRect.SetPosition( aNewPosition );
499}
500
501
503{
504 bool ret;
505
506 // Show or hide the window. If hiding, save current position and size.
507 // If showing, use previous position and size.
508 if( show )
509 {
510#ifndef __WINDOWS__
511 PCB_BASE_FRAME::Raise(); // Needed on OS X and some other window managers (i.e. Unity)
512#endif
513 ret = PCB_BASE_FRAME::Show( show );
514
515 // returns a zeroed-out default wxRect if none existed before.
516 wxRect savedDialogRect = s_dialogRect;
517
518 if( savedDialogRect.GetSize().x != 0 && savedDialogRect.GetSize().y != 0 )
519 {
520 SetSize( savedDialogRect.GetPosition().x, savedDialogRect.GetPosition().y,
521 std::max( wxWindow::GetSize().x, savedDialogRect.GetSize().x ),
522 std::max( wxWindow::GetSize().y, savedDialogRect.GetSize().y ),
523 0 );
524 }
525
526 // Be sure that the dialog appears in a visible area
527 // (the dialog position might have been stored at the time when it was
528 // shown on another display)
529 if( wxDisplay::GetFromWindow( this ) == wxNOT_FOUND )
530 Centre();
531 }
532 else
533 {
534 s_dialogRect = wxRect( wxWindow::GetPosition(), wxWindow::GetSize() );
535 ret = PCB_BASE_FRAME::Show( show );
536 }
537
538 return ret;
539}
540
541
542void FOOTPRINT_CHOOSER_FRAME::OnPaint( wxPaintEvent& aEvent )
543{
545 {
548
549 m_firstPaintEvent = false;
550 }
551
552 aEvent.Skip();
553}
554
555
556void FOOTPRINT_CHOOSER_FRAME::OnOK( wxCommandEvent& aEvent )
557{
559
560 if( fpID.IsValid() )
561 {
562 wxString footprint = fpID.Format();
563
564 AddFootprintToHistory( footprint );
565 DismissModal( true, footprint );
566 }
567 else
568 {
569 DismissModal( false );
570 }
571}
572
573
575{
576 Close( false );
577}
578
579
580void FOOTPRINT_CHOOSER_FRAME::onFpChanged( wxCommandEvent& event )
581{
582 updateViews();
583}
584
585
587{
588 // Create the dummy board used by the 3D canvas
590 m_dummyBoard->SetProject( &Prj(), true );
591
592 // This board will only be used to hold a footprint for viewing
593 m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER );
594
597 m_boardAdapter.m_IsPreviewer = true; // Force display 3D models, regardless the 3D viewer options
598
600 m_boardAdapter.m_Cfg = cfg;
601
602 // Build the 3D canvas
604 OGL_ATT_LIST::GetAttributesList( ANTIALIASING_MODE::AA_8X ),
607
608 m_chooserPanel->m_RightPanelSizer->Add( m_preview3DCanvas, 1, wxALL | wxEXPAND, 5 );
609 m_chooserPanel->m_RightPanel->Layout();
610
612 dummy_bds.SetBoardThickness( pcbIUScale.mmToIU( 1.6 ) );
615 dummy_board_stackup.RemoveAll();
616 dummy_board_stackup.BuildDefaultStackupList( &dummy_bds, 2 );
617}
618
619
620void FOOTPRINT_CHOOSER_FRAME::on3DviewReq( wxCommandEvent& event )
621{
622 if( m_show3DMode == true )
623 {
624 if( m_showFpMode == true )
625 {
626 m_show3DMode = false;
629 }
630 }
631 else
632 {
633 if( m_show3DViewer->IsChecked() )
634 {
636 }
637 else
638 {
639 // Close 3D viewer frame, if it is still enabled
641 if( viewer3D )
642 viewer3D->Close( true );
643 }
644
645 m_show3DMode = true;
648 }
649}
650
651
652void FOOTPRINT_CHOOSER_FRAME::onFpViewReq( wxCommandEvent& event )
653{
654 if( m_showFpMode == true )
655 {
656 if( m_show3DMode == true )
657 {
658 m_showFpMode = false;
661 }
662 }
663 else
664 {
665 m_showFpMode = true;
668 }
669}
670
671
673{
675 bool reloadFp = viewer3D || m_preview3DCanvas->IsShown();
676
677 if( reloadFp )
678 {
680
683
684 }
685
686 if( m_preview3DCanvas->IsShown() )
687 {
690 }
691
692 if( viewer3D )
693 {
694 Update3DView( true, true );
695 }
696
697 m_chooserPanel->m_RightPanel->Layout();
698 m_chooserPanel->m_RightPanel->Refresh();
699}
700
702{
704 viewFpPanel->Show( m_showFpMode );
706
707 updateViews();
708}
709
const char * name
Definition: DXF_plotter.cpp:57
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
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
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:92
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
Definition: bitmap_button.h:42
void SetIsRadioButton()
bool IsChecked() const
void Check(bool aCheck=true)
Check the control.
void SetIsSeparator()
Render button as a toolbar separator.
void SetBitmap(const wxBitmapBundle &aBmp)
Set the bitmap shown when the button is enabled.
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
Container for design settings for a BOARD object.
void SetEnabledLayers(LSET aMask)
Change the bit-mask of enabled layers to aMask.
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:282
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:882
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:294
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition: board.cpp:190
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition: board.cpp:1277
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:797
Color settings are a bit different than most of the settings objects in that there can be more than o...
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:49
void ReloadRequest(BOARD *aBoard=nullptr, S3D_CACHE *aCachePointer=nullptr)
void Request_refresh(bool aRedrawImmediately=true)
Schedule a refresh update of the canvas.
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
EDA_MSG_PANEL * m_messagePanel
void onFpViewReq(wxCommandEvent &event)
void updateViews()
Must be called after loading a new footprint: update footprint and/or 3D views.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
void closeFootprintChooser(wxCommandEvent &aEvent)
bool filterFootprint(LIB_TREE_NODE &aNode)
void on3DviewReq(wxCommandEvent &event)
void onFpChanged(wxCommandEvent &event)
FOOTPRINT_CHOOSER_FRAME(KIWAY *aKiway, wxWindow *aParent)
bool ShowModal(wxString *aFootprint, wxWindow *aParent) override
void OnPaint(wxPaintEvent &aEvent)
bool Show(bool show) override
void OnOK(wxCommandEvent &aEvent)
void updatePanelsVisibility()
Show hide footprint view panel and/or 3d view panel according to the options (display 3D shapes and u...
void SetPosition(const wxPoint &aNewPosition)
Force the position of the dialog to a new position.
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Receive KIWAY_EXPRESS messages from other players.
void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr) override
Update the 3D view, if the viewer is opened by this frame.
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_fpFilters
void onExternalViewer3DEnable(wxCommandEvent &aEvent)
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh) const override
Helper to retrieve the current color settings.
PANEL_FOOTPRINT_CHOOSER * m_chooserPanel
void SetPinFunctions(const std::map< wxString, wxString > &aPinFunctions)
Set the pin functions from the symbol's netlist.
EDA_ITEM * Clone() const override
Invoke a function on all children.
Definition: footprint.cpp:1986
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:40
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition: kiway_express.h:58
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition: kiway_express.h:50
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
bool IsDismissed()
void SetModal(bool aIsModal)
Definition: kiway_player.h:155
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:51
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:172
UTF8 Format() const
Definition: lib_id.cpp:118
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
enum TYPE m_Type
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.
wxWindow * GetFocusTarget() const
FOOTPRINT_PREVIEW_WIDGET * GetViewerPanel() const
void SetPreselect(const LIB_ID &aPreselect)
LIB_ID GetSelectedLibId() const
To be called after this dialog returns from ShowModal().
WINDOW_SETTINGS m_FootprintViewer
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
virtual void SetBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
BOARD * GetBoard() const
EDA_3D_VIEWER_FRAME * CreateAndShow3D_Frame()
Shows the 3D view frame.
EDA_3D_VIEWER_FRAME * Get3DViewerFrame()
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
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,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
#define _(s)
Declaration of the eda_3d_viewer class.
#define FOOTPRINT_CHOOSER_FRAME_NAME
static wxRect s_dialogRect(0, 0, 0, 0)
static wxArrayString s_FootprintHistoryList
static unsigned s_FootprintHistoryMaxCount
static void AddFootprintToHistory(const wxString &aName)
#define MODAL_FRAME
@ FRAME_FOOTPRINT_CHOOSER
Definition: frame_type.h:44
PROJECT & Prj()
Definition: kicad.cpp:595
@ MAIL_SYMBOL_NETLIST
Definition: mail_type.h:45
void FixupCancelButtonCmdKeyCollision(wxWindow *aWindow)
Definition: gtk/ui.cpp:94
void ReparentQuasiModal(wxNonOwnedWindow *aWindow)
Move a window's parent to be the top-level window and force the window to be on top.
Definition: gtk/ui.cpp:88
void ForceFocus(wxWindow *aWindow)
Pass the current focus to the window.
Definition: gtk/ui.cpp:67
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
std::vector< FAB_LAYER_COLOR > dummy
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Split the input string into a vector of output strings.
Definition: string_utils.h:310
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:74