2023-09-26 17:31:45 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-11-08 12:29:14 +00:00
|
|
|
* Copyright (C) 2023 CERN
|
2023-09-26 17:31:45 +00:00
|
|
|
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FOOTPRINT_CHOOSER_FRAME_H
|
|
|
|
#define FOOTPRINT_CHOOSER_FRAME_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <wx/gdicmn.h>
|
|
|
|
#include <pcb_base_frame.h>
|
|
|
|
#include <pcbnew_settings.h>
|
|
|
|
#include <netlist_reader/pcb_netlist.h>
|
2023-11-08 12:29:14 +00:00
|
|
|
#include <lib_tree_model.h>
|
2023-12-08 15:40:19 +00:00
|
|
|
#include <3d_canvas/board_adapter.h>
|
|
|
|
#include <3d_rendering/track_ball.h>
|
2023-09-26 17:31:45 +00:00
|
|
|
|
|
|
|
class PANEL_FOOTPRINT_CHOOSER;
|
2023-09-29 16:02:57 +00:00
|
|
|
class wxCheckBox;
|
2023-12-08 15:40:19 +00:00
|
|
|
class BITMAP_BUTTON;
|
|
|
|
class BOARD;
|
|
|
|
class CAMERA;
|
2023-09-26 17:31:45 +00:00
|
|
|
|
|
|
|
namespace PCB { struct IFACE; }
|
|
|
|
|
|
|
|
|
|
|
|
class FOOTPRINT_CHOOSER_FRAME : public PCB_BASE_FRAME
|
|
|
|
{
|
|
|
|
public:
|
2023-09-29 16:02:57 +00:00
|
|
|
~FOOTPRINT_CHOOSER_FRAME();
|
2023-09-26 17:31:45 +00:00
|
|
|
|
|
|
|
///< @copydoc PCB_BASE_FRAME::GetModel()
|
|
|
|
BOARD_ITEM_CONTAINER* GetModel() const override { return nullptr; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aFootprint an optional FPID string to initialize the viewer with and to
|
|
|
|
* return a selected footprint through.
|
|
|
|
*/
|
|
|
|
bool ShowModal( wxString* aFootprint, wxWindow* aParent ) override;
|
|
|
|
|
|
|
|
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
|
|
|
|
|
2023-11-03 10:34:00 +00:00
|
|
|
/**
|
|
|
|
* Force the position of the dialog to a new position. This mimics the DIALOG_SHIM
|
|
|
|
* implementation.
|
|
|
|
* @param aNewPosition is the new forced position
|
|
|
|
*/
|
|
|
|
void SetPosition( const wxPoint& aNewPosition );
|
|
|
|
|
|
|
|
bool Show( bool show ) override;
|
|
|
|
|
2023-09-26 17:31:45 +00:00
|
|
|
protected:
|
|
|
|
FOOTPRINT_CHOOSER_FRAME( KIWAY* aKiway, wxWindow* aParent );
|
|
|
|
|
|
|
|
private:
|
2023-11-08 12:29:14 +00:00
|
|
|
bool filterFootprint( LIB_TREE_NODE& aNode );
|
2024-03-15 17:21:23 +00:00
|
|
|
void Show3DViewerFrame();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if the footprint must be displayed to the footprint panel
|
|
|
|
* when returning false, the 3D panel is displayed.
|
|
|
|
* true is returnned in footprint mode or in 3D mode using a separate 3D viewer frame
|
|
|
|
*/
|
|
|
|
bool displayFootprintPanel();
|
|
|
|
|
|
|
|
/// @copydoc PCB_BASE_FRAME::Update3DView
|
|
|
|
void Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle = nullptr ) override;
|
2023-09-29 16:02:57 +00:00
|
|
|
|
2023-09-26 17:31:45 +00:00
|
|
|
void OnPaint( wxPaintEvent& aEvent );
|
|
|
|
void OnOK( wxCommandEvent& aEvent );
|
|
|
|
|
|
|
|
void doCloseWindow() override;
|
2023-09-29 16:02:57 +00:00
|
|
|
void closeFootprintChooser( wxCommandEvent& aEvent );
|
2023-09-26 17:31:45 +00:00
|
|
|
|
|
|
|
WINDOW_SETTINGS* GetWindowSettings( APP_SETTINGS_BASE* aCfg ) override;
|
|
|
|
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh ) const override;
|
2024-03-15 17:21:23 +00:00
|
|
|
|
|
|
|
void on3DviewReq( wxCommandEvent& event );
|
|
|
|
void onFpViewReq( wxCommandEvent& event );
|
|
|
|
void onExternalViewer3DEnable( wxCommandEvent& aEvent );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show hide footprint view panel and/or 3d view panel according to the options
|
|
|
|
* (display 3D shapes and use external 3D viewer)
|
|
|
|
*/
|
|
|
|
void updatePanelsVisibility();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Must be called after loading a new footprint: update footprint and/or 3D views
|
|
|
|
*/
|
|
|
|
void updateViews();
|
2023-12-08 15:40:19 +00:00
|
|
|
|
|
|
|
// A command event sent by a PANEL_FOOTPRINT_CHOOSER will fire this event:
|
2024-03-15 17:21:23 +00:00
|
|
|
void onFpChanged( wxCommandEvent& event );
|
2023-12-08 15:40:19 +00:00
|
|
|
|
|
|
|
void build3DCanvas();
|
2023-09-26 17:31:45 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
|
|
|
|
friend struct PCB::IFACE; // constructor called from here only
|
|
|
|
|
|
|
|
private:
|
|
|
|
PANEL_FOOTPRINT_CHOOSER* m_chooserPanel;
|
2023-12-08 15:40:19 +00:00
|
|
|
bool m_showFpMode; // True to show the footprint, false for 3D model
|
2023-09-29 16:02:57 +00:00
|
|
|
wxCheckBox* m_filterByPinCount;
|
|
|
|
wxCheckBox* m_filterByFPFilters;
|
2024-03-15 17:21:23 +00:00
|
|
|
wxCheckBox* m_show3DViewer;
|
2023-09-29 16:02:57 +00:00
|
|
|
|
2023-12-08 15:40:19 +00:00
|
|
|
BOARD_ADAPTER m_boardAdapter;
|
|
|
|
EDA_3D_CANVAS* m_preview3DCanvas;
|
|
|
|
CAMERA& m_currentCamera;
|
|
|
|
TRACK_BALL m_trackBallCamera;
|
|
|
|
BOARD* m_dummyBoard;
|
|
|
|
BITMAP_BUTTON* m_grButtonFpView;
|
|
|
|
BITMAP_BUTTON* m_grButton3DView;
|
|
|
|
|
2023-09-29 16:02:57 +00:00
|
|
|
int m_pinCount;
|
|
|
|
std::vector<std::unique_ptr<EDA_PATTERN_MATCH>> m_fpFilters;
|
2023-09-26 17:31:45 +00:00
|
|
|
|
|
|
|
// On MacOS (at least) SetFocus() calls made in the constructor will fail because a
|
|
|
|
// window that isn't yet visible will return false to AcceptsFocus(). So we must delay
|
|
|
|
// the initial-focus SetFocus() call to the first paint event.
|
|
|
|
bool m_firstPaintEvent;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FOOTPRINT_CHOOSER_FRAME_H
|