31#include <wx/checkbox.h>
38#include "wx/display.h"
74#define MODAL_FRAME ( wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN \
75 | wxWANTS_CHARS | wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT )
82 m_filterByPinCount( nullptr ),
83 m_filterByFPFilters( nullptr ),
85 m_currentCamera( m_trackBallCamera ),
88 m_firstPaintEvent( true )
96 wxPanel* bottomPanel =
new wxPanel(
this );
97 wxBoxSizer* bottomSizer =
new wxBoxSizer( wxVERTICAL );
98 wxBoxSizer* frameSizer =
new wxBoxSizer( wxVERTICAL );
109 wxCommandEvent
dummy;
129 wxBoxSizer* buttonsSizer =
new wxBoxSizer( wxHORIZONTAL );
131 buttonsSizer->Add( 0, 0, 1, 0, 5 );
135 buttonsSizer->Add( separator, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
141 buttonsSizer->Add(
m_grButton3DView, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
147 buttonsSizer->Add(
m_grButtonFpView, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
149 separator =
new BITMAP_BUTTON( bottomPanel, wxID_ANY, wxNullBitmap );
151 buttonsSizer->Add( separator, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1 );
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 );
156 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
157 wxButton* okButton =
new wxButton( bottomPanel, wxID_OK );
158 wxButton* cancelButton =
new wxButton( bottomPanel, wxID_CANCEL );
160 sdbSizer->AddButton( okButton );
161 sdbSizer->AddButton( cancelButton );
164 buttonsSizer->Add( 20, 0, 0, 0, 5 );
165 buttonsSizer->Add( sdbSizer, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
166 bottomSizer->Add( buttonsSizer, 0, wxEXPAND, 5 );
168 bottomPanel->SetSizer( bottomSizer );
169 frameSizer->Add( bottomPanel, 0, wxEXPAND );
171 SetSizer( frameSizer );
173 SetTitle( GetTitle() + wxString::Format(
_(
" (%d items loaded)" ),
192 Connect( FP_SELECTION_EVENT,
219 Disconnect( FP_SELECTION_EVENT,
235 if( aEvent.IsChecked() )
246 viewer3D->Close(
true );
255 bool do_reload_board =
true;
260 do_reload_board =
false;
268 if( do_reload_board )
274 bool aRefresh,
const wxString* aTitle )
277 wxString footprintName;
280 footprintName << fpID.
Format();
282 wxString title =
_(
"3D Viewer" ) + wxT(
" \u2014 " ) + footprintName;
293 return cfg->m_FootprintChooser.filter_on_pin_count;
305 return cfg->m_FootprintChooser.use_fp_filters;
313 if( aNode.
m_Type == LIB_TREE_NODE::TYPE::LIBRARY )
322 [](
LIB_ID& id, std::vector<std::unique_ptr<EDA_PATTERN_MATCH>>& filters ) ->
bool
327 for(
const std::unique_ptr<EDA_PATTERN_MATCH>&
filter : filters )
332 if(
filter->GetPattern().Contains( wxS(
":" ) ) )
333 name =
id.GetUniStringLibNickname().Lower() + wxS(
":" );
335 name +=
id.GetUniStringLibItemName().Lower();
374 wxCHECK_MSG( cfg,
nullptr, wxT(
"config not existing" ) );
396 const std::string& payload = mail.
GetPayload();
403 wxWindow* filtersWindow = filtersSizer->GetContainingWindow();
414 std::map<wxString, wxString> pinNames;
415 std::vector<std::string> strings =
split( payload,
"\r" );
417 if( strings.size() >= 1 && !strings[0].empty() )
419 for(
const wxString&
pin : wxSplit( strings[0],
'\t' ) )
420 pinNames[
pin.BeforeFirst(
' ' ) ] =
pin.AfterFirst(
' ' );
426 msg.Printf(
_(
"Filter by pin count (%d)" ),
m_pinCount );
430 [&]( wxCommandEvent& evt )
440 if( strings.size() >= 2 && !strings[1].empty() )
442 for(
const wxString&
filter : wxSplit( strings[1],
' ' ) )
444 m_fpFilters.push_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD_ANCHORED>() );
448 msg.Printf(
_(
"Apply footprint filters (%s)" ), strings[1] );
452 [&]( wxCommandEvent& evt )
471 s_dialogRect = wxRect( wxWindow::GetPosition(), wxWindow::GetSize() );
474 GetSizer()->SetSizeHints(
this );
486 if( aFootprint && !aFootprint->IsEmpty() )
490 fpid.
Parse( *aFootprint,
true );
502 PCB_BASE_FRAME::SetPosition( aNewPosition );
517 PCB_BASE_FRAME::Raise();
519 ret = PCB_BASE_FRAME::Show( show );
524 if( savedDialogRect.GetSize().x != 0 && savedDialogRect.GetSize().y != 0 )
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 ),
535 if( wxDisplay::GetFromWindow(
this ) == wxNOT_FOUND )
540 s_dialogRect = wxRect( wxWindow::GetPosition(), wxWindow::GetSize() );
541 ret = PCB_BASE_FRAME::Show( show );
568 wxString footprint = fpID.
Format();
650 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 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
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.
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,...
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.