29#include <wx/checkbox.h>
30#include <wx/filedlg.h>
31#include <wx/filename.h>
34#include <wx/translation.h>
51 auto* sizer =
new wxBoxSizer( wxVERTICAL );
53 m_viewer->SetMinSize( FromDIP( wxSize( 520, 340 ) ) );
54 const int border = FromDIP( 4 );
55 sizer->Add(
m_viewer, 1, wxEXPAND | wxALL, border );
57 m_embedFile =
new wxCheckBox(
this, wxID_ANY,
_(
"Embed file" ) );
59 sizer->Add(
m_embedFile, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, border );
61 SetSizerAndFit( sizer );
65 m_dialog =
dynamic_cast<wxFileDialog*
>( wxGetTopLevelParent(
this ) );
67 Bind( wxEVT_UPDATE_UI,
68 [
this]( wxUpdateUIEvent& aEvent )
102 static_cast<unsigned long long>( generation ), aPath.c_str() );
106 if( aPath.IsEmpty() || !wxFileName::FileExists( aPath ) )
117 std::shared_ptr<LIFETIME> lifetime =
m_lifetime;
120 [lifetime]( uint64_t aCompletedGeneration,
RESULT aResult )
mutable
122 wxAppConsole* app = wxTheApp;
128 [lifetime, aCompletedGeneration,
result = std::move( aResult )]()
mutable
130 if( lifetime->panel )
131 lifetime->panel->ApplyResult( aCompletedGeneration, std::move(
result ) );
134 static_cast<unsigned long long>( aCompletedGeneration ) );
150 wxLogTrace(
traceModelPreview, wxS(
"discard stale generation=%llu current=%llu" ),
151 static_cast<unsigned long long>( aGeneration ),
static_cast<unsigned long long>(
m_generation ) );
160 std::shared_ptr<const void> previousOwner = std::move(
m_modelOwner );
163 wxLogTrace(
traceModelPreview, wxS(
"ready generation=%llu" ),
static_cast<unsigned long long>( aGeneration ) );
170 if( !aResult.
message.IsEmpty() )
define an internal structure to be used by the 3D renders
Implement a canvas based on a wxGLCanvas.
static const wxGLAttributes GetAttributesList(ANTIALIASING_MODE aAntiAliasingMode, bool aAlpha=false)
Get a list of attributes to pass to wxGLCanvas.
std::shared_ptr< const void > m_modelOwner
std::shared_ptr< LIFETIME > m_lifetime
bool GetEmbedFile() const
EDA_3D_MODEL_VIEWER * m_viewer
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()> CANCEL
~PANEL_MODEL_FILE_PREVIEW() override
Implements a model viewer canvas.
const wxChar *const traceModelPreview
Flag to enable native operating-system model preview debug output.
Declaration of the cogl_att_list class.
PANEL_MODEL_FILE_PREVIEW * panel
std::shared_ptr< const void > owner
Keeps the imported model alive for as long as the panel shows it.
S3D::MODEL_IMPORT_ERROR status
SMATERIAL * m_Materials
The materials list of this model.
unsigned int m_MeshesSize
Number of meshes in the array.
SMESH * m_Meshes
The meshes list of this model.
unsigned int m_MaterialsSize
Number of materials in the material array.
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.