Code cleanup
This commit is contained in:
parent
a03d5178eb
commit
e7cc3c5f4a
@ -1467,7 +1467,6 @@ float GLCanvas3D::Gizmos::_get_total_overlay_height() const
|
|||||||
const unsigned char GLCanvas3D::WarningTexture::Background_Color[3] = { 9, 91, 134 };
|
const unsigned char GLCanvas3D::WarningTexture::Background_Color[3] = { 9, 91, 134 };
|
||||||
const unsigned char GLCanvas3D::WarningTexture::Opacity = 255;
|
const unsigned char GLCanvas3D::WarningTexture::Opacity = 255;
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
GLCanvas3D::WarningTexture::WarningTexture()
|
GLCanvas3D::WarningTexture::WarningTexture()
|
||||||
: GUI::GLTexture()
|
: GUI::GLTexture()
|
||||||
, m_original_width(0)
|
, m_original_width(0)
|
||||||
@ -1475,17 +1474,6 @@ GLCanvas3D::WarningTexture::WarningTexture()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int GLCanvas3D::WarningTexture::get_original_width() const
|
|
||||||
{
|
|
||||||
return m_original_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
int GLCanvas3D::WarningTexture::get_original_height() const
|
|
||||||
{
|
|
||||||
return m_original_height;
|
|
||||||
}
|
|
||||||
//############################################################################################################################################
|
|
||||||
|
|
||||||
bool GLCanvas3D::WarningTexture::generate(const std::string& msg)
|
bool GLCanvas3D::WarningTexture::generate(const std::string& msg)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
@ -1495,28 +1483,20 @@ bool GLCanvas3D::WarningTexture::generate(const std::string& msg)
|
|||||||
|
|
||||||
wxMemoryDC memDC;
|
wxMemoryDC memDC;
|
||||||
// select default font
|
// select default font
|
||||||
//############################################################################################################################################
|
|
||||||
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||||
font.MakeLarger();
|
font.MakeLarger();
|
||||||
memDC.SetFont(font);
|
memDC.SetFont(font);
|
||||||
|
|
||||||
// memDC.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
|
||||||
//############################################################################################################################################
|
|
||||||
|
|
||||||
// calculates texture size
|
// calculates texture size
|
||||||
wxCoord w, h;
|
wxCoord w, h;
|
||||||
memDC.GetTextExtent(msg, &w, &h);
|
memDC.GetTextExtent(msg, &w, &h);
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
int pow_of_two_size = next_highest_power_of_2((int)std::max(w, h));
|
int pow_of_two_size = next_highest_power_of_2((int)std::max(w, h));
|
||||||
|
|
||||||
m_original_width = (int)w;
|
m_original_width = (int)w;
|
||||||
m_original_height = (int)h;
|
m_original_height = (int)h;
|
||||||
m_width = pow_of_two_size;
|
m_width = pow_of_two_size;
|
||||||
m_height = pow_of_two_size;
|
m_height = pow_of_two_size;
|
||||||
// m_width = (int)w;
|
|
||||||
// m_height = (int)h;
|
|
||||||
//############################################################################################################################################
|
|
||||||
|
|
||||||
// generates bitmap
|
// generates bitmap
|
||||||
wxBitmap bitmap(m_width, m_height);
|
wxBitmap bitmap(m_width, m_height);
|
||||||
@ -1568,7 +1548,6 @@ bool GLCanvas3D::WarningTexture::generate(const std::string& msg)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
void GLCanvas3D::WarningTexture::render(const GLCanvas3D& canvas) const
|
void GLCanvas3D::WarningTexture::render(const GLCanvas3D& canvas) const
|
||||||
{
|
{
|
||||||
if ((m_id > 0) && (m_original_width > 0) && (m_original_height > 0) && (m_width > 0) && (m_height > 0))
|
if ((m_id > 0) && (m_original_width > 0) && (m_original_height > 0) && (m_width > 0) && (m_height > 0))
|
||||||
@ -1602,13 +1581,11 @@ void GLCanvas3D::WarningTexture::render(const GLCanvas3D& canvas) const
|
|||||||
::glEnable(GL_DEPTH_TEST);
|
::glEnable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//############################################################################################################################################
|
|
||||||
|
|
||||||
const unsigned char GLCanvas3D::LegendTexture::Squares_Border_Color[3] = { 64, 64, 64 };
|
const unsigned char GLCanvas3D::LegendTexture::Squares_Border_Color[3] = { 64, 64, 64 };
|
||||||
const unsigned char GLCanvas3D::LegendTexture::Background_Color[3] = { 9, 91, 134 };
|
const unsigned char GLCanvas3D::LegendTexture::Background_Color[3] = { 9, 91, 134 };
|
||||||
const unsigned char GLCanvas3D::LegendTexture::Opacity = 255;
|
const unsigned char GLCanvas3D::LegendTexture::Opacity = 255;
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
GLCanvas3D::LegendTexture::LegendTexture()
|
GLCanvas3D::LegendTexture::LegendTexture()
|
||||||
: GUI::GLTexture()
|
: GUI::GLTexture()
|
||||||
, m_original_width(0)
|
, m_original_width(0)
|
||||||
@ -1616,17 +1593,6 @@ GLCanvas3D::LegendTexture::LegendTexture()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int GLCanvas3D::LegendTexture::get_original_width() const
|
|
||||||
{
|
|
||||||
return m_original_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
int GLCanvas3D::LegendTexture::get_original_height() const
|
|
||||||
{
|
|
||||||
return m_original_height;
|
|
||||||
}
|
|
||||||
//############################################################################################################################################
|
|
||||||
|
|
||||||
bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors)
|
bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
@ -1659,7 +1625,6 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
|||||||
max_text_height = std::max(max_text_height, (int)h);
|
max_text_height = std::max(max_text_height, (int)h);
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
m_original_width = std::max(2 * Px_Border + title_width, 2 * (Px_Border + Px_Square_Contour) + Px_Square + Px_Text_Offset + max_text_width);
|
m_original_width = std::max(2 * Px_Border + title_width, 2 * (Px_Border + Px_Square_Contour) + Px_Square + Px_Text_Offset + max_text_width);
|
||||||
m_original_height = 2 * (Px_Border + Px_Square_Contour) + title_height + Px_Title_Offset + items_count * Px_Square;
|
m_original_height = 2 * (Px_Border + Px_Square_Contour) + title_height + Px_Title_Offset + items_count * Px_Square;
|
||||||
if (items_count > 1)
|
if (items_count > 1)
|
||||||
@ -1670,12 +1635,6 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
|||||||
m_width = pow_of_two_size;
|
m_width = pow_of_two_size;
|
||||||
m_height = pow_of_two_size;
|
m_height = pow_of_two_size;
|
||||||
|
|
||||||
// m_width = std::max(2 * Px_Border + title_width, 2 * (Px_Border + Px_Square_Contour) + Px_Square + Px_Text_Offset + max_text_width);
|
|
||||||
// m_height = 2 * (Px_Border + Px_Square_Contour) + title_height + Px_Title_Offset + items_count * Px_Square;
|
|
||||||
// if (items_count > 1)
|
|
||||||
// m_height += (items_count - 1) * Px_Square_Contour;
|
|
||||||
//############################################################################################################################################
|
|
||||||
|
|
||||||
// generates bitmap
|
// generates bitmap
|
||||||
wxBitmap bitmap(m_width, m_height);
|
wxBitmap bitmap(m_width, m_height);
|
||||||
|
|
||||||
@ -1783,7 +1742,6 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
void GLCanvas3D::LegendTexture::render(const GLCanvas3D& canvas) const
|
void GLCanvas3D::LegendTexture::render(const GLCanvas3D& canvas) const
|
||||||
{
|
{
|
||||||
if ((m_id > 0) && (m_original_width > 0) && (m_original_height > 0) && (m_width > 0) && (m_height > 0))
|
if ((m_id > 0) && (m_original_width > 0) && (m_original_height > 0) && (m_width > 0) && (m_height > 0))
|
||||||
@ -1817,7 +1775,6 @@ void GLCanvas3D::LegendTexture::render(const GLCanvas3D& canvas) const
|
|||||||
::glEnable(GL_DEPTH_TEST);
|
::glEnable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//############################################################################################################################################
|
|
||||||
|
|
||||||
GLGizmoBase* GLCanvas3D::Gizmos::_get_current() const
|
GLGizmoBase* GLCanvas3D::Gizmos::_get_current() const
|
||||||
{
|
{
|
||||||
@ -4016,36 +3973,7 @@ void GLCanvas3D::_render_warning_texture() const
|
|||||||
if (!m_warning_texture_enabled)
|
if (!m_warning_texture_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
m_warning_texture.render(*this);
|
m_warning_texture.render(*this);
|
||||||
|
|
||||||
// // If the warning texture has not been loaded into the GPU, do it now.
|
|
||||||
// unsigned int tex_id = m_warning_texture.get_id();
|
|
||||||
// if (tex_id > 0)
|
|
||||||
// {
|
|
||||||
// int w = m_warning_texture.get_width();
|
|
||||||
// int h = m_warning_texture.get_height();
|
|
||||||
// if ((w > 0) && (h > 0))
|
|
||||||
// {
|
|
||||||
// ::glDisable(GL_DEPTH_TEST);
|
|
||||||
// ::glPushMatrix();
|
|
||||||
// ::glLoadIdentity();
|
|
||||||
//
|
|
||||||
// const Size& cnv_size = get_canvas_size();
|
|
||||||
// float zoom = get_camera_zoom();
|
|
||||||
// float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
|
||||||
// float l = (-0.5f * (float)w) * inv_zoom;
|
|
||||||
// float t = (-0.5f * (float)cnv_size.get_height() + (float)h) * inv_zoom;
|
|
||||||
// float r = l + (float)w * inv_zoom;
|
|
||||||
// float b = t - (float)h * inv_zoom;
|
|
||||||
//
|
|
||||||
// GLTexture::render_texture(tex_id, l, r, b, t);
|
|
||||||
//
|
|
||||||
// ::glPopMatrix();
|
|
||||||
// ::glEnable(GL_DEPTH_TEST);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//############################################################################################################################################
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_render_legend_texture() const
|
void GLCanvas3D::_render_legend_texture() const
|
||||||
@ -4053,36 +3981,7 @@ void GLCanvas3D::_render_legend_texture() const
|
|||||||
if (!m_legend_texture_enabled)
|
if (!m_legend_texture_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
m_legend_texture.render(*this);
|
m_legend_texture.render(*this);
|
||||||
|
|
||||||
// // If the legend texture has not been loaded into the GPU, do it now.
|
|
||||||
// unsigned int tex_id = m_legend_texture.get_id();
|
|
||||||
// if (tex_id > 0)
|
|
||||||
// {
|
|
||||||
// int w = m_legend_texture.get_width();
|
|
||||||
// int h = m_legend_texture.get_height();
|
|
||||||
// if ((w > 0) && (h > 0))
|
|
||||||
// {
|
|
||||||
// ::glDisable(GL_DEPTH_TEST);
|
|
||||||
// ::glPushMatrix();
|
|
||||||
// ::glLoadIdentity();
|
|
||||||
//
|
|
||||||
// const Size& cnv_size = get_canvas_size();
|
|
||||||
// float zoom = get_camera_zoom();
|
|
||||||
// float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
|
||||||
// float l = (-0.5f * (float)cnv_size.get_width()) * inv_zoom;
|
|
||||||
// float t = (0.5f * (float)cnv_size.get_height()) * inv_zoom;
|
|
||||||
// float r = l + (float)w * inv_zoom;
|
|
||||||
// float b = t - (float)h * inv_zoom;
|
|
||||||
//
|
|
||||||
// GLTexture::render_texture(tex_id, l, r, b, t);
|
|
||||||
//
|
|
||||||
// ::glPopMatrix();
|
|
||||||
// ::glEnable(GL_DEPTH_TEST);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//############################################################################################################################################
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_render_layer_editing_overlay() const
|
void GLCanvas3D::_render_layer_editing_overlay() const
|
||||||
|
@ -402,24 +402,15 @@ public:
|
|||||||
static const unsigned char Background_Color[3];
|
static const unsigned char Background_Color[3];
|
||||||
static const unsigned char Opacity;
|
static const unsigned char Opacity;
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
int m_original_width;
|
int m_original_width;
|
||||||
int m_original_height;
|
int m_original_height;
|
||||||
//############################################################################################################################################
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//############################################################################################################################################
|
|
||||||
WarningTexture();
|
WarningTexture();
|
||||||
|
|
||||||
int get_original_width() const;
|
|
||||||
int get_original_height() const;
|
|
||||||
//############################################################################################################################################
|
|
||||||
|
|
||||||
bool generate(const std::string& msg);
|
bool generate(const std::string& msg);
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
void render(const GLCanvas3D& canvas) const;
|
void render(const GLCanvas3D& canvas) const;
|
||||||
//############################################################################################################################################
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LegendTexture : public GUI::GLTexture
|
class LegendTexture : public GUI::GLTexture
|
||||||
@ -433,24 +424,15 @@ public:
|
|||||||
static const unsigned char Background_Color[3];
|
static const unsigned char Background_Color[3];
|
||||||
static const unsigned char Opacity;
|
static const unsigned char Opacity;
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
int m_original_width;
|
int m_original_width;
|
||||||
int m_original_height;
|
int m_original_height;
|
||||||
//############################################################################################################################################
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//############################################################################################################################################
|
|
||||||
LegendTexture();
|
LegendTexture();
|
||||||
|
|
||||||
int get_original_width() const;
|
|
||||||
int get_original_height() const;
|
|
||||||
//############################################################################################################################################
|
|
||||||
|
|
||||||
bool generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
|
bool generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
|
||||||
|
|
||||||
//############################################################################################################################################
|
|
||||||
void render(const GLCanvas3D& canvas) const;
|
void render(const GLCanvas3D& canvas) const;
|
||||||
//############################################################################################################################################
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user