mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-14 03:01:47 +08:00
Tech ENABLE_GLBEGIN_GLEND_REMOVAL - GLSelectionRectangle rectangle
This commit is contained in:
parent
18e2cc2298
commit
f6f95808cc
@ -69,7 +69,11 @@ namespace GUI {
|
|||||||
m_state = Off;
|
m_state = Off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
void GLSelectionRectangle::render(const GLCanvas3D& canvas)
|
||||||
|
#else
|
||||||
void GLSelectionRectangle::render(const GLCanvas3D& canvas) const
|
void GLSelectionRectangle::render(const GLCanvas3D& canvas) const
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
{
|
{
|
||||||
if (!is_dragging())
|
if (!is_dragging())
|
||||||
return;
|
return;
|
||||||
@ -92,11 +96,13 @@ namespace GUI {
|
|||||||
float bottom = (float)std::min(start(1), end(1)) * inv_zoom;
|
float bottom = (float)std::min(start(1), end(1)) * inv_zoom;
|
||||||
|
|
||||||
glsafe(::glLineWidth(1.5f));
|
glsafe(::glLineWidth(1.5f));
|
||||||
|
#if !ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
float color[3];
|
float color[3];
|
||||||
color[0] = (m_state == Select) ? 0.3f : 1.0f;
|
color[0] = (m_state == Select) ? 0.3f : 1.0f;
|
||||||
color[1] = (m_state == Select) ? 1.0f : 0.3f;
|
color[1] = (m_state == Select) ? 1.0f : 0.3f;
|
||||||
color[2] = 0.3f;
|
color[2] = 0.3f;
|
||||||
glsafe(::glColor3fv(color));
|
glsafe(::glColor3fv(color));
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
@ -112,12 +118,58 @@ namespace GUI {
|
|||||||
glsafe(::glLineStipple(4, 0xAAAA));
|
glsafe(::glLineStipple(4, 0xAAAA));
|
||||||
glsafe(::glEnable(GL_LINE_STIPPLE));
|
glsafe(::glEnable(GL_LINE_STIPPLE));
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
if (shader != nullptr) {
|
||||||
|
shader->start_using();
|
||||||
|
|
||||||
|
if (!m_rectangle.is_initialized() || !m_old_start_corner.isApprox(m_start_corner) || !m_old_end_corner.isApprox(m_end_corner)) {
|
||||||
|
m_old_start_corner = m_start_corner;
|
||||||
|
m_old_end_corner = m_end_corner;
|
||||||
|
m_rectangle.reset();
|
||||||
|
|
||||||
|
GLModel::InitializationData init_data;
|
||||||
|
GLModel::InitializationData::Entity entity;
|
||||||
|
entity.type = GLModel::PrimitiveType::LineLoop;
|
||||||
|
entity.positions.reserve(4);
|
||||||
|
entity.positions.emplace_back(left, bottom, 0.0f);
|
||||||
|
entity.positions.emplace_back(right, bottom, 0.0f);
|
||||||
|
entity.positions.emplace_back(right, top, 0.0f);
|
||||||
|
entity.positions.emplace_back(left, top, 0.0f);
|
||||||
|
|
||||||
|
entity.normals.reserve(4);
|
||||||
|
for (size_t j = 0; j < 5; ++j) {
|
||||||
|
entity.normals.emplace_back(Vec3f::UnitZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.indices.reserve(6);
|
||||||
|
entity.indices.emplace_back(0);
|
||||||
|
entity.indices.emplace_back(1);
|
||||||
|
entity.indices.emplace_back(2);
|
||||||
|
entity.indices.emplace_back(2);
|
||||||
|
entity.indices.emplace_back(3);
|
||||||
|
entity.indices.emplace_back(0);
|
||||||
|
|
||||||
|
init_data.entities.emplace_back(entity);
|
||||||
|
m_rectangle.init_from(init_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorRGBA color(
|
||||||
|
(m_state == Select) ? 0.3f : 1.0f,
|
||||||
|
(m_state == Select) ? 1.0f : 0.3f,
|
||||||
|
0.3f, 1.0f);
|
||||||
|
m_rectangle.set_color(-1, color);
|
||||||
|
m_rectangle.render();
|
||||||
|
shader->stop_using();
|
||||||
|
}
|
||||||
|
#else
|
||||||
::glBegin(GL_LINE_LOOP);
|
::glBegin(GL_LINE_LOOP);
|
||||||
::glVertex2f((GLfloat)left, (GLfloat)bottom);
|
::glVertex2f((GLfloat)left, (GLfloat)bottom);
|
||||||
::glVertex2f((GLfloat)right, (GLfloat)bottom);
|
::glVertex2f((GLfloat)right, (GLfloat)bottom);
|
||||||
::glVertex2f((GLfloat)right, (GLfloat)top);
|
::glVertex2f((GLfloat)right, (GLfloat)top);
|
||||||
::glVertex2f((GLfloat)left, (GLfloat)top);
|
::glVertex2f((GLfloat)left, (GLfloat)top);
|
||||||
glsafe(::glEnd());
|
glsafe(::glEnd());
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
glsafe(::glPopAttrib());
|
glsafe(::glPopAttrib());
|
||||||
|
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#define slic3r_GLSelectionRectangle_hpp_
|
#define slic3r_GLSelectionRectangle_hpp_
|
||||||
|
|
||||||
#include "libslic3r/Point.hpp"
|
#include "libslic3r/Point.hpp"
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
#include "GLModel.hpp"
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
@ -30,7 +33,11 @@ public:
|
|||||||
// Disables the rectangle.
|
// Disables the rectangle.
|
||||||
void stop_dragging();
|
void stop_dragging();
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
void render(const GLCanvas3D& canvas);
|
||||||
|
#else
|
||||||
void render(const GLCanvas3D& canvas) const;
|
void render(const GLCanvas3D& canvas) const;
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
bool is_dragging() const { return m_state != Off; }
|
bool is_dragging() const { return m_state != Off; }
|
||||||
EState get_state() const { return m_state; }
|
EState get_state() const { return m_state; }
|
||||||
@ -43,9 +50,14 @@ public:
|
|||||||
float get_bottom() const { return std::min(m_start_corner(1), m_end_corner(1)); }
|
float get_bottom() const { return std::min(m_start_corner(1), m_end_corner(1)); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EState m_state = Off;
|
EState m_state{ Off };
|
||||||
Vec2d m_start_corner;
|
Vec2d m_start_corner{ Vec2d::Zero() };
|
||||||
Vec2d m_end_corner;
|
Vec2d m_end_corner{ Vec2d::Zero() };
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
GLModel m_rectangle;
|
||||||
|
Vec2d m_old_start_corner{ Vec2d::Zero() };
|
||||||
|
Vec2d m_old_end_corner{ Vec2d::Zero() };
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,6 +107,7 @@ void GLGizmoMove3D::on_render()
|
|||||||
|
|
||||||
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
auto render_grabber_connection = [this, ¢er](unsigned int id) {
|
auto render_grabber_connection = [this, ¢er](unsigned int id) {
|
||||||
if (m_grabbers[id].enabled) {
|
if (m_grabbers[id].enabled) {
|
||||||
if (!m_grabber_connections[id].model.is_initialized() || !m_grabber_connections[id].old_center.isApprox(center)) {
|
if (!m_grabber_connections[id].model.is_initialized() || !m_grabber_connections[id].old_center.isApprox(center)) {
|
||||||
@ -137,6 +138,7 @@ void GLGizmoMove3D::on_render()
|
|||||||
m_grabber_connections[id].model.render();
|
m_grabber_connections[id].model.render();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
if (m_hover_id == -1) {
|
if (m_hover_id == -1) {
|
||||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user