KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_model_file_preview.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 as published by
8 * the Free Software Foundation; either version 3 of the License, or (at your option)
9 * 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-3.0.html
19 */
20
21#ifndef PANEL_MODEL_FILE_PREVIEW_H
22#define PANEL_MODEL_FILE_PREVIEW_H
23
24#include <cstdint>
25#include <functional>
26#include <memory>
27
29
30#include <wx/panel.h>
31#include <wx/string.h>
32
34class S3DMODEL;
35class wxCheckBox;
36class wxFileDialog;
37
38class PANEL_MODEL_FILE_PREVIEW : public wxPanel
39{
40public:
41 struct RESULT
42 {
44
46 std::shared_ptr<const void> owner;
47 const S3DMODEL* model = nullptr;
48 wxString message;
49 };
50
51 using COMPLETION = std::function<void( uint64_t, RESULT )>;
52 using REQUEST = std::function<void( wxString, uint64_t, COMPLETION )>;
53 using CANCEL = std::function<void()>;
54
55 PANEL_MODEL_FILE_PREVIEW( wxWindow* aParent, REQUEST aRequest, CANCEL aCancel, bool aEmbedFile );
57
58 void SetSelectedFile( const wxString& aPath );
59 bool GetEmbedFile() const;
60
61private:
62 struct LIFETIME;
63
64 void ApplyResult( uint64_t aGeneration, RESULT aResult );
65
68 std::shared_ptr<LIFETIME> m_lifetime;
69 std::shared_ptr<const void> m_modelOwner;
71 wxCheckBox* m_embedFile = nullptr;
72 wxFileDialog* m_dialog = nullptr;
74 uint64_t m_generation = 0;
75};
76
77#endif // PANEL_MODEL_FILE_PREVIEW_H
Implement a canvas based on a wxGLCanvas.
std::shared_ptr< const void > m_modelOwner
std::shared_ptr< LIFETIME > m_lifetime
PANEL_MODEL_FILE_PREVIEW(wxWindow *aParent, REQUEST aRequest, CANCEL aCancel, bool aEmbedFile)
std::function< void(wxString, uint64_t, COMPLETION)> REQUEST
void SetSelectedFile(const wxString &aPath)
void ApplyResult(uint64_t aGeneration, RESULT aResult)
std::function< void(uint64_t, RESULT)> COMPLETION
MODEL_IMPORT_ERROR
std::shared_ptr< const void > owner
Keeps the imported model alive for as long as the panel shows it.
Store the a model based on meshes and materials.
Definition c3dmodel.h:111