mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 08:11:11 -06:00
GCode Preview - Legend texture shown only when gcode is available
This commit is contained in:
parent
593d794655
commit
6ff9021e04
9 changed files with 61 additions and 30 deletions
|
@ -1229,6 +1229,11 @@ unsigned int _3DScene::LegendTexture::get_texture_height() const
|
|||
return m_tex_height;
|
||||
}
|
||||
|
||||
void _3DScene::LegendTexture::reset_texture()
|
||||
{
|
||||
_destroy_texture();
|
||||
}
|
||||
|
||||
bool _3DScene::LegendTexture::_create_texture(const Print& print, const wxBitmap& bitmap)
|
||||
{
|
||||
if ((m_tex_width == 0) || (m_tex_height == 0))
|
||||
|
@ -1270,6 +1275,8 @@ void _3DScene::LegendTexture::_destroy_texture()
|
|||
{
|
||||
::glDeleteTextures(1, &m_tex_id);
|
||||
m_tex_id = 0;
|
||||
m_tex_height = 0;
|
||||
m_tex_width = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1316,7 +1323,10 @@ void _3DScene::load_gcode_preview(const Print* print, GLVolumeCollection* volume
|
|||
_load_gcode_retractions(*print, *volumes, use_VBOs);
|
||||
_load_gcode_unretractions(*print, *volumes, use_VBOs);
|
||||
|
||||
_generate_legend_texture(*print);
|
||||
if (volumes->empty())
|
||||
reset_legend_texture();
|
||||
else
|
||||
_generate_legend_texture(*print);
|
||||
}
|
||||
|
||||
_update_gcode_volumes_visibility(*print, *volumes);
|
||||
|
@ -1337,6 +1347,11 @@ unsigned int _3DScene::get_legend_texture_height()
|
|||
return s_legend_texture.get_texture_height();
|
||||
}
|
||||
|
||||
void _3DScene::reset_legend_texture()
|
||||
{
|
||||
s_legend_texture.reset_texture();
|
||||
}
|
||||
|
||||
// Create 3D thick extrusion lines for a skirt and brim.
|
||||
// Adds a new Slic3r::GUI::3DScene::Volume to volumes.
|
||||
void _3DScene::_load_print_toolpaths(
|
||||
|
|
|
@ -403,20 +403,26 @@ class _3DScene
|
|||
unsigned int get_texture_width() const;
|
||||
unsigned int get_texture_height() const;
|
||||
|
||||
void reset_texture();
|
||||
|
||||
private:
|
||||
bool _create_texture(const Print& print, const wxBitmap& bitmap);
|
||||
void _destroy_texture();
|
||||
};
|
||||
|
||||
static LegendTexture s_legend_texture;
|
||||
|
||||
public:
|
||||
static void _glew_init();
|
||||
|
||||
static void load_gcode_preview(const Print* print, GLVolumeCollection* volumes, bool use_VBOs);
|
||||
|
||||
static unsigned int get_legend_texture_id();
|
||||
static unsigned int get_legend_texture_width();
|
||||
static unsigned int get_legend_texture_height();
|
||||
|
||||
static void reset_legend_texture();
|
||||
|
||||
static void _load_print_toolpaths(
|
||||
const Print *print,
|
||||
GLVolumeCollection *volumes,
|
||||
|
|
|
@ -191,13 +191,16 @@ void create_preset_tab(const char *name)
|
|||
|
||||
void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string items, bool initial_value)
|
||||
{
|
||||
wxCheckListBoxComboPopup* popup = new wxCheckListBoxComboPopup(-1);
|
||||
if (comboCtrl == nullptr)
|
||||
return;
|
||||
|
||||
wxCheckListBoxComboPopup* popup = new wxCheckListBoxComboPopup;
|
||||
if (popup != nullptr)
|
||||
{
|
||||
comboCtrl->SetPopupControl(popup);
|
||||
popup->SetStringValue(text);
|
||||
popup->Connect(-1, wxEVT_CHECKLISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnCheckListBox), nullptr, popup);
|
||||
popup->Connect(-1, wxEVT_LISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnListBoxSelection), nullptr, popup);
|
||||
popup->Connect(wxID_ANY, wxEVT_CHECKLISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnCheckListBox), nullptr, popup);
|
||||
popup->Connect(wxID_ANY, wxEVT_LISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnListBoxSelection), nullptr, popup);
|
||||
|
||||
std::vector<std::string> items_str;
|
||||
boost::split(items_str, items, boost::is_any_of("|"), boost::token_compress_off);
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
#include "wxExtensions.hpp"
|
||||
|
||||
const unsigned int wxCheckListBoxComboPopup::Height = 200;
|
||||
|
||||
wxCheckListBoxComboPopup::wxCheckListBoxComboPopup(wxWindowID id)
|
||||
: m_id(id)
|
||||
, m_text(wxEmptyString)
|
||||
{
|
||||
}
|
||||
const unsigned int wxCheckListBoxComboPopup::Height = 210;
|
||||
|
||||
bool wxCheckListBoxComboPopup::Create(wxWindow* parent)
|
||||
{
|
||||
return wxCheckListBox::Create(parent, m_id, wxPoint(0, 0));
|
||||
return wxCheckListBox::Create(parent, wxID_HIGHEST + 1, wxPoint(0, 0));
|
||||
}
|
||||
|
||||
wxWindow* wxCheckListBoxComboPopup::GetControl()
|
||||
|
@ -51,6 +45,7 @@ void wxCheckListBoxComboPopup::OnCheckListBox(wxCommandEvent& evt)
|
|||
if (cmb != nullptr)
|
||||
{
|
||||
wxCommandEvent event(wxEVT_CHECKLISTBOX, cmb->GetId());
|
||||
event.SetEventObject(cmb);
|
||||
cmb->ProcessWindowEvent(event);
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +63,6 @@ void wxCheckListBoxComboPopup::OnListBoxSelection(wxCommandEvent& evt)
|
|||
wxCommandEvent event(wxEVT_CHECKLISTBOX, GetId());
|
||||
event.SetInt(selId);
|
||||
event.SetEventObject(this);
|
||||
event.SetString(GetString(selId));
|
||||
ProcessEvent(event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,9 @@ class wxCheckListBoxComboPopup : public wxCheckListBox, public wxComboPopup
|
|||
{
|
||||
static const unsigned int Height;
|
||||
|
||||
wxWindowID m_id;
|
||||
wxString m_text;
|
||||
|
||||
public:
|
||||
explicit wxCheckListBoxComboPopup(wxWindowID id);
|
||||
|
||||
virtual bool Create(wxWindow* parent);
|
||||
virtual wxWindow* GetControl();
|
||||
virtual void SetStringValue(const wxString& value);
|
||||
|
|
|
@ -161,7 +161,12 @@ get_legend_texture_height()
|
|||
RETVAL = _3DScene::get_legend_texture_height();
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
|
||||
void
|
||||
reset_legend_texture()
|
||||
CODE:
|
||||
_3DScene::reset_legend_texture();
|
||||
|
||||
void
|
||||
_load_print_toolpaths(print, volumes, tool_colors, use_VBOs)
|
||||
Print *print;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue