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, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <set>
23#include <vector>
24#include <wx/string.h>
25#include <wx/listctrl.h>
26
30#include <math/vector3.h>
31
32class PCB_EDIT_FRAME;
33class BOARD;
34class FOOTPRINT;
35class EDA_3D_CANVAS;
36
37
50{
51public:
54
57 bool HasMissingModels() const { return !m_missing.empty(); }
58
64
67 static int CountUnresolvedWrlReferences( PCB_EDIT_FRAME* aFrame );
68
74 static int AutoMigrateByFilename( PCB_EDIT_FRAME* aFrame );
75
76protected:
77 void OnMissingSelected( wxListEvent& event ) override;
78 void OnCandidateSelected( wxListEvent& event ) override;
79 void OnAddSearchDirectoryClick( wxCommandEvent& event ) override;
80 void OnOpenExternalFileClick( wxCommandEvent& event ) override;
81 void OnReplaceClick( wxCommandEvent& event ) override;
82 void OnKeepClick( wxCommandEvent& event ) override;
83
84private:
87 {
88 wxString m_absPath;
89 wxString m_stem;
90 wxString m_parent;
91 };
92
95 {
96 wxString m_absPath;
97 wxString m_display;
98 int m_score;
99 };
100
102 void buildCatalog();
103 void scanDirectory( const wxString& aDir );
104 void populateMissingList();
105 void rankAllCandidates();
106 std::vector<MATCH_CANDIDATE> rankCandidatesFor( const wxString& aWrlFilename ) const;
107
109 void initPreviewBoard();
110
115 void showPreview( int aMissingIndex, const wxString& aCandAbsPath );
116 void populateCandidatesList( int aMissingIndex );
117
121 void updateMissingItemStyle( int aMissingIndex );
122
126
128
137
142 {
143 VECTOR3D m_scale { 1, 1, 1 };
144 VECTOR3D m_rotation { 0, 0, 0 };
145 VECTOR3D m_offset { 0, 0, 0 };
146 double m_opacity = 1.0;
147 };
148
151 std::vector<wxString> m_missing;
154 std::vector<MISSING_XFORM> m_missingXform;
158 std::vector<const FOOTPRINT*> m_missingRepFp;
160 std::vector<std::vector<MATCH_CANDIDATE>> m_candidatesPerMissing;
163 std::vector<int> m_selectedPerMissing;
164
166 std::vector<CATALOG_ENTRY> m_catalog;
168 std::set<wxString> m_scannedDirs;
169};
Helper class to handle information needed to display 3D board.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
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