KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_migrate_3d_models.h
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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23#pragma once
24
25#include <set>
26#include <vector>
27#include <wx/string.h>
28#include <wx/listctrl.h>
29
33#include <math/vector3.h>
34
35class PCB_EDIT_FRAME;
36class BOARD;
37class FOOTPRINT;
38class EDA_3D_CANVAS;
39
40
53{
54public:
57
60 bool HasMissingModels() const { return !m_missing.empty(); }
61
67
70 static int CountUnresolvedWrlReferences( PCB_EDIT_FRAME* aFrame );
71
77 static int AutoMigrateByFilename( PCB_EDIT_FRAME* aFrame );
78
79protected:
80 void OnMissingSelected( wxListEvent& event ) override;
81 void OnCandidateSelected( wxListEvent& event ) override;
82 void OnAddSearchDirectoryClick( wxCommandEvent& event ) override;
83 void OnOpenExternalFileClick( wxCommandEvent& event ) override;
84 void OnReplaceClick( wxCommandEvent& event ) override;
85 void OnKeepClick( wxCommandEvent& event ) override;
86
87private:
90 {
91 wxString m_absPath;
92 wxString m_stem;
93 wxString m_parent;
94 };
95
98 {
99 wxString m_absPath;
100 wxString m_display;
102 };
103
105 void buildCatalog();
106 void scanDirectory( const wxString& aDir );
107 void populateMissingList();
108 void rankAllCandidates();
109 std::vector<MATCH_CANDIDATE> rankCandidatesFor( const wxString& aWrlFilename ) const;
110
112 void initPreviewBoard();
113
118 void showPreview( int aMissingIndex, const wxString& aCandAbsPath );
119 void populateCandidatesList( int aMissingIndex );
120
124 void updateMissingItemStyle( int aMissingIndex );
125
129
131
140
145 {
146 VECTOR3D m_scale { 1, 1, 1 };
147 VECTOR3D m_rotation { 0, 0, 0 };
148 VECTOR3D m_offset { 0, 0, 0 };
149 double m_opacity = 1.0;
150 };
151
154 std::vector<wxString> m_missing;
157 std::vector<MISSING_XFORM> m_missingXform;
161 std::vector<const FOOTPRINT*> m_missingRepFp;
163 std::vector<std::vector<MATCH_CANDIDATE>> m_candidatesPerMissing;
166 std::vector<int> m_selectedPerMissing;
167
169 std::vector<CATALOG_ENTRY> m_catalog;
171 std::set<wxString> m_scannedDirs;
172};
Helper class to handle information needed to display 3D board.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:323
DIALOG_MIGRATE_3D_MODELS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Migrate 3D Models"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(900, 560), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
static int AutoMigrateByFilename(PCB_EDIT_FRAME *aFrame)
Silently rewrite unresolvable .wrl/.wrz references to STEP files whose filename stem matches in the s...
void OnKeepClick(wxCommandEvent &event) override
std::vector< int > m_selectedPerMissing
Which candidate index the user has selected for each missing entry.
std::vector< CATALOG_ENTRY > m_catalog
Catalog of STEP-compatible model paths, deduped by absolute path.
DIALOG_MIGRATE_3D_MODELS(PCB_EDIT_FRAME *aFrame)
std::vector< wxString > m_missing
Unique WRL filenames (as stored in FP_3DMODEL::m_Filename, i.e.
static bool BoardHasUnresolvedWrlReferences(PCB_EDIT_FRAME *aFrame)
Cheap precheck that avoids constructing the dialog (and its embedded 3D canvas) when the board has no...
void populateCandidatesList(int aMissingIndex)
void applyInitialSizeCaps()
Size the dialog on first construction: cap at 0.9 * parent width when opening for the first time,...
void updateMissingItemStyle(int aMissingIndex)
Apply bold styling to the missing-list row iff no replacement is currently selected (m_selectedPerMis...
void OnOpenExternalFileClick(wxCommandEvent &event) override
void OnAddSearchDirectoryClick(wxCommandEvent &event) override
std::vector< std::vector< MATCH_CANDIDATE > > m_candidatesPerMissing
Ranked candidates per missing filename, keyed by index into m_missing.
std::vector< MATCH_CANDIDATE > rankCandidatesFor(const wxString &aWrlFilename) const
void initPreviewBoard()
Set up the throwaway board/footprint that the preview canvas renders.
void showPreview(int aMissingIndex, const wxString &aCandAbsPath)
Replace the preview's footprint and model list to reflect the current missing-list selection + candid...
std::vector< MISSING_XFORM > m_missingXform
Source FP_3DMODEL transform per missing filename, used when building the candidate model for preview.
BOARD * m_dummyBoard
Preview pipeline.
void OnCandidateSelected(wxListEvent &event) override
bool HasMissingModels() const
Scan the board for unresolvable .wrl/.wrz references.
void scanDirectory(const wxString &aDir)
static int CountUnresolvedWrlReferences(PCB_EDIT_FRAME *aFrame)
Count of unique unresolvable .wrl/.wrz references on the board (deduplicated by filename).
FOOTPRINT * m_dummyFootprint
Owned by m_dummyBoard.
std::vector< const FOOTPRINT * > m_missingRepFp
Representative footprint per missing filename.
void OnMissingSelected(wxListEvent &event) override
void OnReplaceClick(wxCommandEvent &event) override
std::set< wxString > m_scannedDirs
Set of already-scanned directories (absolute path, case-normalised).
Implement a canvas based on a wxGLCanvas.
The main frame for Pcbnew.
An entry in the STEP catalog. m_absPath is the deduplication key.
wxString m_parent
Parent directory basename (e.g. "Resistor_SMD.3dshapes")
wxString m_absPath
Absolute on-disk path.
wxString m_stem
Filename without directory or extension.
A ranked candidate shown in column 2. A score of 0 means "keep existing".
wxString m_absPath
Absolute path, or empty for the "keep existing" row.
Transform data captured from the first FP_3DMODEL entry that referenced each missing WRL filename,...
Declaration for a track ball camera.
VECTOR3< double > VECTOR3D
Definition vector3.h:230