31#include <wx/checkbox.h>
37#include "wx/display.h"
73#define MODAL_FRAME ( wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN \
74 | wxWANTS_CHARS | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP )
81 m_filterByPinCount( nullptr ),
82 m_filterByFPFilters( nullptr ),
84 m_currentCamera( m_trackBallCamera ),
87 m_firstPaintEvent( true )
95 wxPanel* bottomPanel =
new wxPanel(
this );
96 wxBoxSizer* bottomSizer =
new wxBoxSizer( wxVERTICAL );
97 wxBoxSizer* frameSizer =
new wxBoxSizer( wxVERTICAL );
108 wxCommandEvent
dummy;
128 wxBoxSizer* buttonsSizer =
new wxBoxSizer( wxHORIZONTAL );
130 buttonsSizer->Add( 0, 0, 1, 0, 5 );
134 buttonsSizer->Add( separator, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
140 buttonsSizer->Add(
m_grButton3DView, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
146 buttonsSizer->Add(
m_grButtonFpView, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
148 separator =
new BITMAP_BUTTON( bottomPanel, wxID_ANY, wxNullBitmap );
150 buttonsSizer->Add( separator, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
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 );
155 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
156 wxButton* okButton =
new wxButton( bottomPanel, wxID_OK );
157 wxButton* cancelButton =
new wxButton( bottomPanel, wxID_CANCEL );
159 sdbSizer->AddButton( okButton );
160 sdbSizer->AddButton( cancelButton );
163 buttonsSizer->Add( 20, 0, 0, 0, 5 );
164 buttonsSizer->Add( sdbSizer, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
165 bottomSizer->Add( buttonsSizer, 0, wxEXPAND, 5 );
167 bottomPanel->SetSizer( bottomSizer );
168 frameSizer->Add( bottomPanel, 0, wxEXPAND );
170 SetSizer( frameSizer );
172 SetTitle( GetTitle() + wxString::Format(
_(
" (%d items loaded)" ),
191 Connect( FP_SELECTION_EVENT,
213 Disconnect( FP_SELECTION_EVENT,
229 if( aEvent.IsChecked() )
240 viewer3D->Close(
true );
249 bool do_reload_board =
true;
254 do_reload_board =
false;
262 if( do_reload_board )
268 bool aRefresh,
const wxString* aTitle )
271 wxString footprintName;
274 footprintName << fpID.
Format();
276 wxString title =
_(
"3D Viewer" ) + wxT(
" \u2014 " ) + footprintName;
287 return cfg->m_FootprintChooser.filter_on_pin_count;
299 return cfg->m_FootprintChooser.use_fp_filters;
307 if( aNode.
m_Type == LIB_TREE_NODE::TYPE::LIBRARY )
316 [](
LIB_ID& id, std::vector<std::unique_ptr<EDA_PATTERN_MATCH>>& filters ) ->
bool
321 for(
const std::unique_ptr<EDA_PATTERN_MATCH>&
filter : filters )
326 if(
filter->GetPattern().Contains( wxS(
":" ) ) )
327 name =
id.GetUniStringLibNickname().Lower() + wxS(
":" );
329 name +=
id.GetUniStringLibItemName().Lower();
368 wxCHECK_MSG( cfg,
nullptr, wxT(
"config not existing" ) );
390 const std::string& payload = mail.
GetPayload();
397 wxWindow* filtersWindow = filtersSizer->GetContainingWindow();
408 std::map<wxString, wxString> pinNames;
409 std::vector<std::string> strings =
split( payload,
"\r" );
411 if( strings.size() >= 1 && !strings[0].empty() )
413 for(
const wxString&
pin : wxSplit( strings[0],
'\t' ) )
414 pinNames[
pin.BeforeFirst(
' ' ) ] =
pin.AfterFirst(
' ' );
420 msg.Printf(
_(
"Filter by pin count (%d)" ),
m_pinCount );
424 [&]( wxCommandEvent& evt )
434 if( strings.size() >= 2 && !strings[1].empty() )
436 for(
const wxString&
filter : wxSplit( strings[1],
' ' ) )
438 m_fpFilters.push_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD_ANCHORED>() );
442 msg.Printf(
_(
"Apply footprint filters (%s)" ), strings[1] );
446 [&]( wxCommandEvent& evt )
465 s_dialogRect = wxRect( wxWindow::GetPosition(), wxWindow::GetSize() );
468 GetSizer()->SetSizeHints(
this );
480 if( aFootprint && !aFootprint->IsEmpty() )
484 fpid.
Parse( *aFootprint,
true );
496 PCB_BASE_FRAME::SetPosition( aNewPosition );
511 PCB_BASE_FRAME::Raise();
513 ret = PCB_BASE_FRAME::Show( show );
518 if( savedDialogRect.GetSize().x != 0 && savedDialogRect.GetSize().y != 0 )
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 ),
529 if( wxDisplay::GetFromWindow(
this ) == wxNOT_FOUND )
534 s_dialogRect = wxRect( wxWindow::GetPosition(), wxWindow::GetSize() );
535 ret = PCB_BASE_FRAME::Show( show );
562 wxString footprint = fpID.
Format();
642 viewer3D->Close(
true );
constexpr EDA_IU_SCALE pcbIUScale
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
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.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
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.
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
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
MAIL_T Command()
Returns the MAIL_T associated with this mail.
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...
void SetModal(bool aIsModal)
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
bool IsValid() const
Check if this LID_ID is valid.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
static const wxGLAttributes GetAttributesList(ANTIALIASING_MODE aAntiAliasingMode, bool aAlpha=false)
Get a list of attributes to pass to wxGLCanvas.
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.
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
static S3D_CACHE * Get3DCacheManager(PROJECT *aProject, bool updateProjDir=false)
Return a pointer to an instance of the 3D cache manager.
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.
Declaration of the eda_3d_viewer class.
#define FOOTPRINT_CHOOSER_FRAME_NAME
@ FRAME_FOOTPRINT_CHOOSER
PGM_BASE & Pgm()
The global Program "get" accessor.
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.
constexpr int mmToIU(double mm) const
Stores the common settings that are saved and loaded for each window / frame.