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>
33#include <lset.h>
38#include "wx/display.h"
40#include <project_pcb.h>
43
44
45static wxArrayString s_FootprintHistoryList;
46static unsigned s_FootprintHistoryMaxCount = 8;
47
48static void AddFootprintToHistory( const wxString& aName )
49{
50 // Remove duplicates
51 for( int ii = (int) s_FootprintHistoryList.GetCount() - 1; ii >= 0; --ii )
52 {
53 if( s_FootprintHistoryList[ ii ] == aName )
54 s_FootprintHistoryList.RemoveAt( (size_t) ii );
55 }
56
57 // Add the new name at the beginning of the history list
58 s_FootprintHistoryList.Insert( aName, 0 );
59
60 // Remove extra names
62 s_FootprintHistoryList.RemoveAt( s_FootprintHistoryList.GetCount() - 1 );
63}
64
65
66BEGIN_EVENT_TABLE( FOOTPRINT_CHOOSER_FRAME, PCB_BASE_FRAME )
68 EVT_BUTTON( wxID_OK, FOOTPRINT_CHOOSER_FRAME::OnOK )
69 EVT_BUTTON( wxID_CANCEL, FOOTPRINT_CHOOSER_FRAME::closeFootprintChooser )
71END_EVENT_TABLE()
72
73
74#define MODAL_FRAME ( wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN \
75 | wxWANTS_CHARS | wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT )
76
77
79 PCB_BASE_FRAME( aKiway, aParent, FRAME_FOOTPRINT_CHOOSER, _( "Footprint Chooser" ),
80 wxDefaultPosition, wxDefaultSize, MODAL_FRAME,
82 m_filterByPinCount( nullptr ),
83 m_filterByFPFilters( nullptr ),
84 m_boardAdapter(),
85 m_currentCamera( m_trackBallCamera ),
86 m_trackBallCamera( 2 * RANGE_SCALE_3D ),
87 m_pinCount( 0 ),
88 m_firstPaintEvent( true )
89{
90 SetModal( true );
91
92 m_showFpMode = true;
93 m_show3DMode = false;
94 m_messagePanel->Hide();
95
96 wxPanel* bottomPanel = new wxPanel( this );
97 wxBoxSizer* bottomSizer = new wxBoxSizer( wxVERTICAL );
98 wxBoxSizer* frameSizer = new wxBoxSizer( wxVERTICAL );
99
101 // Filter
102 [this]( LIB_TREE_NODE& aNode ) -> bool
103 {
104 return filterFootprint( aNode );
105 },
106 // Accept handler
107 [this]()
108 {
109 wxCommandEvent dummy;
110 OnOK( dummy );
111 },
112 // Escape handler
113 [this]()
114 {
115 DismissModal( false );
116 } );
117
118 frameSizer->Add( m_chooserPanel, 1, wxEXPAND );
119
120 SetBoard( new BOARD() );
121
122 // This board will only be used to hold a footprint for viewing
123 GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER );
124
125 build3DCanvas(); // must be called after creating m_chooserPanel
127
128 // buttonsSizer contains the BITMAP buttons
129 wxBoxSizer* buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
130
131 buttonsSizer->Add( 0, 0, 1, 0, 5 ); // Add spacer to right-align buttons
132
133 BITMAP_BUTTON* separator = new BITMAP_BUTTON( bottomPanel, wxID_ANY, wxNullBitmap );
134 separator->SetIsSeparator();
135 buttonsSizer->Add( separator, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
136
137 m_grButton3DView = new BITMAP_BUTTON( bottomPanel, wxID_ANY, wxNullBitmap );
139 m_grButton3DView->SetBitmap( KiBitmapBundle( BITMAPS::shape_3d ) );
141 buttonsSizer->Add( m_grButton3DView, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
142
143 m_grButtonFpView = new BITMAP_BUTTON( bottomPanel, wxID_ANY, wxNullBitmap );
145 m_grButtonFpView->SetBitmap( KiBitmapBundle( BITMAPS::module ) );
147 buttonsSizer->Add( m_grButtonFpView, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
148
149 separator = new BITMAP_BUTTON( bottomPanel, wxID_ANY, wxNullBitmap );
150 separator->SetIsSeparator();
151 buttonsSizer->Add( separator, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
152
153 m_show3DViewer = new wxCheckBox( bottomPanel, wxID_ANY, _( "Show 3D viewer in own window" ) );
154 buttonsSizer->Add( m_show3DViewer, 0, wxALL | wxALIGN_CENTER_VERTICAL, 3 );
155
156 wxStdDialogButtonSizer* sdbSizer = new wxStdDialogButtonSizer();
157 wxButton* okButton = new wxButton( bottomPanel, wxID_OK );
158 wxButton* cancelButton = new wxButton( bottomPanel, wxID_CANCEL );
159
160 sdbSizer->AddButton( okButton );
161 sdbSizer->AddButton( cancelButton );
162 sdbSizer->Realize();
163
164 buttonsSizer->Add( 20, 0, 0, 0, 5 ); // Add spacer
165 buttonsSizer->Add( sdbSizer, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
166 bottomSizer->Add( buttonsSizer, 0, wxEXPAND, 5 );
167
168 bottomPanel->SetSizer( bottomSizer );
169 frameSizer->Add( bottomPanel, 0, wxEXPAND );
170
171 SetSizer( frameSizer );
172
173 SetTitle( GetTitle() + wxString::Format( _( " (%d items loaded)" ),
175
176 Layout();
178
179 // Connect Events
180 m_grButton3DView->Connect( wxEVT_COMMAND_BUTTON_CLICKED ,
181 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::on3DviewReq ),
182 nullptr, this );
183
184 m_grButtonFpView->Connect( wxEVT_COMMAND_BUTTON_CLICKED ,
185 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::onFpViewReq ),
186 nullptr, this );
187
188 m_show3DViewer->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED ,
190 nullptr, this );
191
192 Connect( FP_SELECTION_EVENT, // custom event fired by a PANEL_FOOTPRINT_CHOOSER
193 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::onFpChanged ), nullptr, this );
194
195 // Needed on Linux to fix the position of widgets in bottomPanel
196 PostSizeEvent();
197}
198
199
201{
202 // Work around assertion firing when we try to LockCtx on a hidden 3D canvas during dtor
203 wxCloseEvent dummy;
204 m_preview3DCanvas->Show();
206
207 // Disconnect Events
208 m_grButton3DView->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
209 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::on3DviewReq ),
210 nullptr, this );
211 m_grButtonFpView->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
212 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::onFpViewReq ),
213 nullptr, this );
214
215 m_show3DViewer->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED ,
217 nullptr, this );
218
219 Disconnect( FP_SELECTION_EVENT,
220 wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::onFpChanged ), nullptr, this );
221
222 if( PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
223 {
225 cfg->m_FootprintChooser.use_fp_filters = m_filterByFPFilters->GetValue();
226
228 cfg->m_FootprintChooser.filter_on_pin_count = m_filterByPinCount->GetValue();
229 }
230}
231
232
234{
235 if( aEvent.IsChecked() )
236 {
238 Show3DViewerFrame(); // show external 3D viewer
239 }
240 else
241 {
242 // Close the external 3D viewer frame, if it is still enabled
244
245 if( viewer3D )
246 viewer3D->Close( true );
247 }
248
250}
251
252
254{
255 bool do_reload_board = true; // reload board flag
256
257 // At EDA_3D_VIEWER_FRAME creation, the current board is loaded, so disable loading
258 // the current board if the 3D frame is not yet created
259 if( Get3DViewerFrame() == nullptr )
260 do_reload_board = false;
261
263
264 // A stronger version of Raise() which promotes the window to its parent's level.
265 KIPLATFORM::UI::ReparentModal( draw3DFrame );
266
267 // And load or update the current board (if needed)
268 if( do_reload_board )
269 Update3DView( true, true );
270}
271
272
274 bool aRefresh, const wxString* aTitle )
275{
277 wxString footprintName;
278
279 if( fpID.IsValid() )
280 footprintName << fpID.Format();
281
282 wxString title = _( "3D Viewer" ) + wxT( " \u2014 " ) + footprintName;
283 PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title );
284}
285
286
288{
290 return m_filterByPinCount->GetValue();
291
292 if( PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
293 return cfg->m_FootprintChooser.filter_on_pin_count;
294
295 return false;
296}
297
298
300{
302 return m_filterByFPFilters->GetValue();
303
304 if( PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
305 return cfg->m_FootprintChooser.use_fp_filters;
306
307 return false;
308}
309
310
312{
313 if( aNode.m_Type == LIB_TREE_NODE::TYPE::LIBRARY )
314 {
315 // Normally lib nodes get scored by the max of their children's scores. However, if a
316 // lib node *has* no children then the scorer will call the filter on the lib node itself,
317 // and we just want to return true if we're not filtering at all.
318 return !filterByPinCount() && !filterByFPFilters();
319 }
320
321 auto patternMatch =
322 []( LIB_ID& id, std::vector<std::unique_ptr<EDA_PATTERN_MATCH>>& filters ) -> bool
323 {
324 // The matching is case insensitive
325 wxString name;
326
327 for( const std::unique_ptr<EDA_PATTERN_MATCH>& filter : filters )
328 {
329 name.Empty();
330
331 // If the filter contains a ':' then include the library name in the pattern
332 if( filter->GetPattern().Contains( wxS( ":" ) ) )
333 name = id.GetUniStringLibNickname().Lower() + wxS( ":" );
334
335 name += id.GetUniStringLibItemName().Lower();
336
337 if( filter->Find( name ) )
338 return true;
339 }
340
341 return false;
342 };
343
344 if( m_pinCount > 0 && filterByPinCount() )
345 {
346 if( aNode.m_PinCount != m_pinCount )
347 return false;
348 }
349
350 if( !m_fpFilters.empty() && filterByFPFilters() )
351 {
352 if( !patternMatch( aNode.m_LibId, m_fpFilters ) )
353 return false;
354 }
355
356 return true;
357}
358
359
361{
362 // Only dismiss a modal frame once, so that the return values set by
363 // the prior DismissModal() are not bashed for ShowModal().
364 if( !IsDismissed() )
365 DismissModal( false );
366
367 // window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
368}
369
370
372{
373 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
374 wxCHECK_MSG( cfg, nullptr, wxT( "config not existing" ) );
375
376 return &cfg->m_FootprintViewer;
377}
378
379
381{
383
384 if( cfg )
385 return Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme );
386 else
388}
389
390
391static wxRect s_dialogRect( 0, 0, 0, 0 );
392
393
395{
396 const std::string& payload = mail.GetPayload();
397
398 switch( mail.Command() )
399 {
401 {
402 wxSizer* filtersSizer = m_chooserPanel->GetFiltersSizer();
403 wxWindow* filtersWindow = filtersSizer->GetContainingWindow();
404 wxString msg;
405
406 m_pinCount = 0;
407 m_fpFilters.clear();
408
409 /*
410 * Symbol netlist format:
411 * pinNumber pinName <tab> pinNumber pinName...
412 * fpFilter fpFilter...
413 */
414 std::map<wxString, wxString> pinNames;
415 std::vector<std::string> strings = split( payload, "\r" );
416
417 if( strings.size() >= 1 && !strings[0].empty() )
418 {
419 for( const wxString& pin : wxSplit( strings[0], '\t' ) )
420 pinNames[ pin.BeforeFirst( ' ' ) ] = pin.AfterFirst( ' ' );
421
422 m_pinCount = pinNames.size();
423
424 if( m_pinCount > 0 )
425 {
426 msg.Printf( _( "Filter by pin count (%d)" ), m_pinCount );
427 m_filterByPinCount = new wxCheckBox( filtersWindow, wxID_ANY, msg );
428
429 m_filterByPinCount->Bind( wxEVT_CHECKBOX,
430 [&]( wxCommandEvent& evt )
431 {
433 } );
434
435 if( PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
436 m_filterByPinCount->SetValue( cfg->m_FootprintChooser.filter_on_pin_count );
437 }
438 }
439
440 if( strings.size() >= 2 && !strings[1].empty() )
441 {
442 for( const wxString& filter : wxSplit( strings[1], ' ' ) )
443 {
444 m_fpFilters.push_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD_ANCHORED>() );
445 m_fpFilters.back()->SetPattern( filter.Lower() );
446 }
447
448 msg.Printf( _( "Apply footprint filters (%s)" ), strings[1] );
449 m_filterByFPFilters = new wxCheckBox( filtersWindow, wxID_ANY, msg );
450
451 m_filterByFPFilters->Bind( wxEVT_CHECKBOX,
452 [&]( wxCommandEvent& evt )
453 {
455 } );
456
457 if( PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
458 m_filterByFPFilters->SetValue( cfg->m_FootprintChooser.use_fp_filters );
459 }
460
462 m_chooserPanel->GetFiltersSizer()->Add( m_filterByFPFilters, 0, wxEXPAND|wxBOTTOM, 4 );
463
465 m_chooserPanel->GetFiltersSizer()->Add( m_filterByPinCount, 0, wxEXPAND|wxBOTTOM, 4 );
466
468
469 // Save the wxFormBuilder size of the dialog...
470 if( s_dialogRect.GetSize().x == 0 || s_dialogRect.GetSize().y == 0 )
471 s_dialogRect = wxRect( wxWindow::GetPosition(), wxWindow::GetSize() );
472
473 // ... and then give it a kick to get it to layout the new items
474 GetSizer()->SetSizeHints( this );
475 break;
476 }
477
478 default:
479 break;
480 }
481}
482
483
484bool FOOTPRINT_CHOOSER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
485{
486 if( aFootprint && !aFootprint->IsEmpty() )
487 {
488 LIB_ID fpid;
489
490 fpid.Parse( *aFootprint, true );
491
492 if( fpid.IsValid() )
494 }
495
496 return KIWAY_PLAYER::ShowModal( aFootprint, aParent );
497}
498
499
500void FOOTPRINT_CHOOSER_FRAME::SetPosition( const wxPoint& aNewPosition )
501{
502 PCB_BASE_FRAME::SetPosition( aNewPosition );
503
504 s_dialogRect.SetPosition( aNewPosition );
505}
506
507
509{
510 bool ret;
511
512 // Show or hide the window. If hiding, save current position and size.
513 // If showing, use previous position and size.
514 if( show )
515 {
516#ifndef __WINDOWS__
517 PCB_BASE_FRAME::Raise(); // Needed on OS X and some other window managers (i.e. Unity)
518#endif
519 ret = PCB_BASE_FRAME::Show( show );
520
521 // returns a zeroed-out default wxRect if none existed before.
522 wxRect savedDialogRect = s_dialogRect;
523
524 if( savedDialogRect.GetSize().x != 0 && savedDialogRect.GetSize().y != 0 )
525 {
526 SetSize( savedDialogRect.GetPosition().x, savedDialogRect.GetPosition().y,
527 std::max( wxWindow::GetSize().x, savedDialogRect.GetSize().x ),
528 std::max( wxWindow::GetSize().y, savedDialogRect.GetSize().y ),
529 0 );
530 }
531
532 // Be sure that the dialog appears in a visible area
533 // (the dialog position might have been stored at the time when it was
534 // shown on another display)
535 if( wxDisplay::GetFromWindow( this ) == wxNOT_FOUND )
536 Centre();
537 }
538 else
539 {
540 s_dialogRect = wxRect( wxWindow::GetPosition(), wxWindow::GetSize() );
541 ret = PCB_BASE_FRAME::Show( show );
542 }
543
544 return ret;
545}
546
547
548void FOOTPRINT_CHOOSER_FRAME::OnPaint( wxPaintEvent& aEvent )
549{
551 {
554
555 m_firstPaintEvent = false;
556 }
557
558 aEvent.Skip();
559}
560
561
562void FOOTPRINT_CHOOSER_FRAME::OnOK( wxCommandEvent& aEvent )
563{
565
566 if( fpID.IsValid() )
567 {
568 wxString footprint = fpID.Format();
569
570 AddFootprintToHistory( footprint );
571 DismissModal( true, footprint );
572 }
573 else
574 {
575 DismissModal( false );
576 }
577}
578
579
581{
582 Close( false );
583}
584
585
586void FOOTPRINT_CHOOSER_FRAME::onFpChanged( wxCommandEvent& event )
587{
588 updateViews();
589}
590
591
593{
594 // Create the dummy board used by the 3D canvas
596 m_dummyBoard->SetProject( &Prj(), true );
597
598 // This board will only be used to hold a footprint for viewing
599 m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER );
600
603 m_boardAdapter.m_IsPreviewer = true; // Force display 3D models, regardless the 3D viewer options
604
607
608 m_boardAdapter.m_Cfg = cfg;
609
610 // Build the 3D canvas
612 OGL_ATT_LIST::GetAttributesList( ANTIALIASING_MODE::AA_8X ),
615
616 m_chooserPanel->m_RightPanelSizer->Add( m_preview3DCanvas, 1, wxEXPAND, 5 );
617 m_chooserPanel->m_RightPanel->Layout();
618
620 dummy_bds.SetBoardThickness( pcbIUScale.mmToIU( 1.6 ) );
623 dummy_board_stackup.RemoveAll();
624 dummy_board_stackup.BuildDefaultStackupList( &dummy_bds, 2 );
625}
626
627
628void FOOTPRINT_CHOOSER_FRAME::on3DviewReq( wxCommandEvent& event )
629{
630 if( m_show3DMode == true )
631 {
632 if( m_showFpMode == true )
633 {
634 m_show3DMode = false;
637 }
638 }
639 else
640 {
641 if( m_show3DViewer->IsChecked() )
642 {
644 }
645 else
646 {
647 // Close 3D viewer frame, if it is still enabled
649 if( viewer3D )
650 viewer3D->Close( true );
651 }
652
653 m_show3DMode = true;
656 }
657}
658
659
660void FOOTPRINT_CHOOSER_FRAME::onFpViewReq( wxCommandEvent& event )
661{
662 if( m_showFpMode == true )
663 {
664 if( m_show3DMode == true )
665 {
666 m_showFpMode = false;
669 }
670 }
671 else
672 {
673 m_showFpMode = true;
676 }
677}
678
679
681{
683 bool reloadFp = viewer3D || m_preview3DCanvas->IsShown();
684
685 if( reloadFp )
686 {
688
691
692 }
693
694 if( m_preview3DCanvas->IsShown() )
695 {
698 }
699
700 if( viewer3D )
701 {
702 Update3DView( true, true );
703 }
704
705 m_chooserPanel->m_RightPanel->Layout();
706 m_chooserPanel->m_RightPanel->Refresh();
707}
708
710{
712 viewFpPanel->Show( m_showFpMode );
714
715 updateViews();
716}
717
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:290
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:1003
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:302
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition: board.cpp:197
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition: board.cpp:1399
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:895
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:51
void ReloadRequest(BOARD *aBoard=nullptr, S3D_CACHE *aCachePointer=nullptr)
void OnCloseWindow(wxCloseEvent &event)
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:2075
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:284
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:782
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:789
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
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
T * GetAppSettings(const wxString &aFilename)
Returns a handle to the a given settings by type If the settings have already been loaded,...
#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:597
@ MAIL_SYMBOL_NETLIST
Definition: mail_type.h:45
void FixupCancelButtonCmdKeyCollision(wxWindow *aWindow)
Definition: wxgtk/ui.cpp:94
void ForceFocus(wxWindow *aWindow)
Pass the current focus to the window.
Definition: wxgtk/ui.cpp:67
void ReparentModal(wxNonOwnedWindow *aWindow)
Move a window's parent to be the top-level window and force the window to be on top.
Definition: wxgtk/ui.cpp:88
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
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:317
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