mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -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
|
@ -1605,23 +1605,25 @@ sub draw_legend {
|
||||||
my $tex_id = Slic3r::GUI::_3DScene::get_legend_texture_id;
|
my $tex_id = Slic3r::GUI::_3DScene::get_legend_texture_id;
|
||||||
if ($tex_id > 0)
|
if ($tex_id > 0)
|
||||||
{
|
{
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
my $tex_w = Slic3r::GUI::_3DScene::get_legend_texture_width;
|
my $tex_w = Slic3r::GUI::_3DScene::get_legend_texture_width;
|
||||||
my $tex_h = Slic3r::GUI::_3DScene::get_legend_texture_height;
|
my $tex_h = Slic3r::GUI::_3DScene::get_legend_texture_height;
|
||||||
|
if (($tex_w > 0) && ($tex_h > 0))
|
||||||
my ($cw, $ch) = $self->GetSizeWH;
|
{
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
my ($cw, $ch) = $self->GetSizeWH;
|
||||||
|
|
||||||
my $l = (-0.5 * $cw) / $self->_zoom;
|
my $l = (-0.5 * $cw) / $self->_zoom;
|
||||||
my $t = (0.5 * $ch) / $self->_zoom;
|
my $t = (0.5 * $ch) / $self->_zoom;
|
||||||
my $r = $l + $tex_w / $self->_zoom;
|
my $r = $l + $tex_w / $self->_zoom;
|
||||||
my $b = $t - $tex_h / $self->_zoom;
|
my $b = $t - $tex_h / $self->_zoom;
|
||||||
$self->_render_texture($tex_id, $l, $r, $b, $t);
|
$self->_render_texture($tex_id, $l, $r, $b, $t);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2038,4 +2040,8 @@ sub set_toolpaths_range {
|
||||||
$self->volumes->set_range($min_z, $max_z);
|
$self->volumes->set_range($min_z, $max_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub reset_legend_texture {
|
||||||
|
Slic3r::GUI::_3DScene::reset_legend_texture();
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -1261,6 +1261,8 @@ sub reslice {
|
||||||
$self->stop_background_process;
|
$self->stop_background_process;
|
||||||
# Rather perform one additional unnecessary update of the print object instead of skipping a pending async update.
|
# Rather perform one additional unnecessary update of the print object instead of skipping a pending async update.
|
||||||
$self->async_apply_config;
|
$self->async_apply_config;
|
||||||
|
# Reset gcode data
|
||||||
|
$self->{print}->clear_gcode_preview_data;
|
||||||
$self->statusbar->SetCancelCallback(sub {
|
$self->statusbar->SetCancelCallback(sub {
|
||||||
$self->stop_background_process;
|
$self->stop_background_process;
|
||||||
$self->statusbar->SetStatusText("Slicing cancelled");
|
$self->statusbar->SetStatusText("Slicing cancelled");
|
||||||
|
|
|
@ -290,6 +290,9 @@ sub load_print {
|
||||||
$self->set_z_range(0,0);
|
$self->set_z_range(0,0);
|
||||||
$self->slider_low->Hide;
|
$self->slider_low->Hide;
|
||||||
$self->slider_high->Hide;
|
$self->slider_high->Hide;
|
||||||
|
$self->{z_label_low}->SetLabel("");
|
||||||
|
$self->{z_label_high}->SetLabel("");
|
||||||
|
$self->canvas->reset_legend_texture();
|
||||||
$self->canvas->Refresh; # clears canvas
|
$self->canvas->Refresh; # clears canvas
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1229,6 +1229,11 @@ unsigned int _3DScene::LegendTexture::get_texture_height() const
|
||||||
return m_tex_height;
|
return m_tex_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _3DScene::LegendTexture::reset_texture()
|
||||||
|
{
|
||||||
|
_destroy_texture();
|
||||||
|
}
|
||||||
|
|
||||||
bool _3DScene::LegendTexture::_create_texture(const Print& print, const wxBitmap& bitmap)
|
bool _3DScene::LegendTexture::_create_texture(const Print& print, const wxBitmap& bitmap)
|
||||||
{
|
{
|
||||||
if ((m_tex_width == 0) || (m_tex_height == 0))
|
if ((m_tex_width == 0) || (m_tex_height == 0))
|
||||||
|
@ -1270,6 +1275,8 @@ void _3DScene::LegendTexture::_destroy_texture()
|
||||||
{
|
{
|
||||||
::glDeleteTextures(1, &m_tex_id);
|
::glDeleteTextures(1, &m_tex_id);
|
||||||
m_tex_id = 0;
|
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_retractions(*print, *volumes, use_VBOs);
|
||||||
_load_gcode_unretractions(*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);
|
_update_gcode_volumes_visibility(*print, *volumes);
|
||||||
|
@ -1337,6 +1347,11 @@ unsigned int _3DScene::get_legend_texture_height()
|
||||||
return s_legend_texture.get_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.
|
// Create 3D thick extrusion lines for a skirt and brim.
|
||||||
// Adds a new Slic3r::GUI::3DScene::Volume to volumes.
|
// Adds a new Slic3r::GUI::3DScene::Volume to volumes.
|
||||||
void _3DScene::_load_print_toolpaths(
|
void _3DScene::_load_print_toolpaths(
|
||||||
|
|
|
@ -403,20 +403,26 @@ class _3DScene
|
||||||
unsigned int get_texture_width() const;
|
unsigned int get_texture_width() const;
|
||||||
unsigned int get_texture_height() const;
|
unsigned int get_texture_height() const;
|
||||||
|
|
||||||
|
void reset_texture();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _create_texture(const Print& print, const wxBitmap& bitmap);
|
bool _create_texture(const Print& print, const wxBitmap& bitmap);
|
||||||
void _destroy_texture();
|
void _destroy_texture();
|
||||||
};
|
};
|
||||||
|
|
||||||
static LegendTexture s_legend_texture;
|
static LegendTexture s_legend_texture;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void _glew_init();
|
static void _glew_init();
|
||||||
|
|
||||||
static void load_gcode_preview(const Print* print, GLVolumeCollection* volumes, bool use_VBOs);
|
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_id();
|
||||||
static unsigned int get_legend_texture_width();
|
static unsigned int get_legend_texture_width();
|
||||||
static unsigned int get_legend_texture_height();
|
static unsigned int get_legend_texture_height();
|
||||||
|
|
||||||
|
static void reset_legend_texture();
|
||||||
|
|
||||||
static void _load_print_toolpaths(
|
static void _load_print_toolpaths(
|
||||||
const Print *print,
|
const Print *print,
|
||||||
GLVolumeCollection *volumes,
|
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)
|
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)
|
if (popup != nullptr)
|
||||||
{
|
{
|
||||||
comboCtrl->SetPopupControl(popup);
|
comboCtrl->SetPopupControl(popup);
|
||||||
popup->SetStringValue(text);
|
popup->SetStringValue(text);
|
||||||
popup->Connect(-1, wxEVT_CHECKLISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnCheckListBox), nullptr, popup);
|
popup->Connect(wxID_ANY, wxEVT_CHECKLISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnCheckListBox), nullptr, popup);
|
||||||
popup->Connect(-1, wxEVT_LISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnListBoxSelection), nullptr, popup);
|
popup->Connect(wxID_ANY, wxEVT_LISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnListBoxSelection), nullptr, popup);
|
||||||
|
|
||||||
std::vector<std::string> items_str;
|
std::vector<std::string> items_str;
|
||||||
boost::split(items_str, items, boost::is_any_of("|"), boost::token_compress_off);
|
boost::split(items_str, items, boost::is_any_of("|"), boost::token_compress_off);
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
|
|
||||||
const unsigned int wxCheckListBoxComboPopup::Height = 200;
|
const unsigned int wxCheckListBoxComboPopup::Height = 210;
|
||||||
|
|
||||||
wxCheckListBoxComboPopup::wxCheckListBoxComboPopup(wxWindowID id)
|
|
||||||
: m_id(id)
|
|
||||||
, m_text(wxEmptyString)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxCheckListBoxComboPopup::Create(wxWindow* parent)
|
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()
|
wxWindow* wxCheckListBoxComboPopup::GetControl()
|
||||||
|
@ -51,6 +45,7 @@ void wxCheckListBoxComboPopup::OnCheckListBox(wxCommandEvent& evt)
|
||||||
if (cmb != nullptr)
|
if (cmb != nullptr)
|
||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_CHECKLISTBOX, cmb->GetId());
|
wxCommandEvent event(wxEVT_CHECKLISTBOX, cmb->GetId());
|
||||||
|
event.SetEventObject(cmb);
|
||||||
cmb->ProcessWindowEvent(event);
|
cmb->ProcessWindowEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +63,6 @@ void wxCheckListBoxComboPopup::OnListBoxSelection(wxCommandEvent& evt)
|
||||||
wxCommandEvent event(wxEVT_CHECKLISTBOX, GetId());
|
wxCommandEvent event(wxEVT_CHECKLISTBOX, GetId());
|
||||||
event.SetInt(selId);
|
event.SetInt(selId);
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
event.SetString(GetString(selId));
|
|
||||||
ProcessEvent(event);
|
ProcessEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,9 @@ class wxCheckListBoxComboPopup : public wxCheckListBox, public wxComboPopup
|
||||||
{
|
{
|
||||||
static const unsigned int Height;
|
static const unsigned int Height;
|
||||||
|
|
||||||
wxWindowID m_id;
|
|
||||||
wxString m_text;
|
wxString m_text;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit wxCheckListBoxComboPopup(wxWindowID id);
|
|
||||||
|
|
||||||
virtual bool Create(wxWindow* parent);
|
virtual bool Create(wxWindow* parent);
|
||||||
virtual wxWindow* GetControl();
|
virtual wxWindow* GetControl();
|
||||||
virtual void SetStringValue(const wxString& value);
|
virtual void SetStringValue(const wxString& value);
|
||||||
|
|
|
@ -161,7 +161,12 @@ get_legend_texture_height()
|
||||||
RETVAL = _3DScene::get_legend_texture_height();
|
RETVAL = _3DScene::get_legend_texture_height();
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
RETVAL
|
RETVAL
|
||||||
|
|
||||||
|
void
|
||||||
|
reset_legend_texture()
|
||||||
|
CODE:
|
||||||
|
_3DScene::reset_legend_texture();
|
||||||
|
|
||||||
void
|
void
|
||||||
_load_print_toolpaths(print, volumes, tool_colors, use_VBOs)
|
_load_print_toolpaths(print, volumes, tool_colors, use_VBOs)
|
||||||
Print *print;
|
Print *print;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue