Merge branch 'dev' of https://github.com/prusa3d/Slic3r into dev
This commit is contained in:
commit
bb24ae9f03
4 changed files with 91 additions and 78 deletions
|
@ -507,6 +507,7 @@ void GLCanvas3D::Bed::_render_prusa(float theta) const
|
||||||
if (triangles_vcount > 0)
|
if (triangles_vcount > 0)
|
||||||
{
|
{
|
||||||
::glEnable(GL_DEPTH_TEST);
|
::glEnable(GL_DEPTH_TEST);
|
||||||
|
::glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
::glEnable(GL_BLEND);
|
::glEnable(GL_BLEND);
|
||||||
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
@ -535,6 +536,7 @@ void GLCanvas3D::Bed::_render_prusa(float theta) const
|
||||||
::glDisable(GL_TEXTURE_2D);
|
::glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
::glDisable(GL_BLEND);
|
::glDisable(GL_BLEND);
|
||||||
|
::glDepthMask(GL_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,7 +1042,7 @@ void GLCanvas3D::LayersEditing::_render_profile(const PrintObject& print_object,
|
||||||
// Make the vertical bar a bit wider so the layer height curve does not touch the edge of the bar region.
|
// Make the vertical bar a bit wider so the layer height curve does not touch the edge of the bar region.
|
||||||
layer_height_max *= 1.12;
|
layer_height_max *= 1.12;
|
||||||
|
|
||||||
coordf_t max_z = unscale<double>(print_object.size(2));
|
double max_z = unscale<double>(print_object.size(2));
|
||||||
double layer_height = dynamic_cast<const ConfigOptionFloat*>(print_object.config.option("layer_height"))->value;
|
double layer_height = dynamic_cast<const ConfigOptionFloat*>(print_object.config.option("layer_height"))->value;
|
||||||
float l = bar_rect.get_left();
|
float l = bar_rect.get_left();
|
||||||
float w = bar_rect.get_right() - l;
|
float w = bar_rect.get_right() - l;
|
||||||
|
@ -1062,7 +1064,7 @@ void GLCanvas3D::LayersEditing::_render_profile(const PrintObject& print_object,
|
||||||
const ModelObject* model_object = print_object.model_object();
|
const ModelObject* model_object = print_object.model_object();
|
||||||
if (model_object->layer_height_profile_valid)
|
if (model_object->layer_height_profile_valid)
|
||||||
{
|
{
|
||||||
const std::vector<coordf_t>& profile = model_object->layer_height_profile;
|
const std::vector<double>& profile = model_object->layer_height_profile;
|
||||||
|
|
||||||
::glColor3f(0.0f, 0.0f, 1.0f);
|
::glColor3f(0.0f, 0.0f, 1.0f);
|
||||||
::glBegin(GL_LINE_STRIP);
|
::glBegin(GL_LINE_STRIP);
|
||||||
|
@ -2079,7 +2081,7 @@ void GLCanvas3D::set_bed_shape(const Pointfs& shape)
|
||||||
bool new_shape = m_bed.set_shape(shape);
|
bool new_shape = m_bed.set_shape(shape);
|
||||||
|
|
||||||
// Set the origin and size for painting of the coordinate system axes.
|
// Set the origin and size for painting of the coordinate system axes.
|
||||||
m_axes.origin = Vec3d(0.0, 0.0, (coordf_t)GROUND_Z);
|
m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z);
|
||||||
set_axes_length(0.3f * (float)m_bed.get_bounding_box().max_size());
|
set_axes_length(0.3f * (float)m_bed.get_bounding_box().max_size());
|
||||||
|
|
||||||
if (new_shape)
|
if (new_shape)
|
||||||
|
@ -2098,7 +2100,7 @@ void GLCanvas3D::set_auto_bed_shape()
|
||||||
{
|
{
|
||||||
// draw a default square bed around object center
|
// draw a default square bed around object center
|
||||||
const BoundingBoxf3& bbox = volumes_bounding_box();
|
const BoundingBoxf3& bbox = volumes_bounding_box();
|
||||||
coordf_t max_size = bbox.max_size();
|
double max_size = bbox.max_size();
|
||||||
const Vec3d center = bbox.center();
|
const Vec3d center = bbox.center();
|
||||||
|
|
||||||
Pointfs bed_shape;
|
Pointfs bed_shape;
|
||||||
|
@ -2111,7 +2113,7 @@ void GLCanvas3D::set_auto_bed_shape()
|
||||||
set_bed_shape(bed_shape);
|
set_bed_shape(bed_shape);
|
||||||
|
|
||||||
// Set the origin for painting of the coordinate system axes.
|
// Set the origin for painting of the coordinate system axes.
|
||||||
m_axes.origin = Vec3d(center(0), center(1), (coordf_t)GROUND_Z);
|
m_axes.origin = Vec3d(center(0), center(1), (double)GROUND_Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::set_axes_length(float length)
|
void GLCanvas3D::set_axes_length(float length)
|
||||||
|
@ -2352,13 +2354,13 @@ void GLCanvas3D::render()
|
||||||
float theta = m_camera.get_theta();
|
float theta = m_camera.get_theta();
|
||||||
bool is_custom_bed = m_bed.is_custom();
|
bool is_custom_bed = m_bed.is_custom();
|
||||||
|
|
||||||
|
// picking pass
|
||||||
_picking_pass();
|
_picking_pass();
|
||||||
|
|
||||||
|
// draw scene
|
||||||
_render_background();
|
_render_background();
|
||||||
|
|
||||||
_render_current_gizmo();
|
if (is_custom_bed) // untextured bed needs to be rendered before objects
|
||||||
|
|
||||||
// untextured bed needs to be rendered before objects
|
|
||||||
if (is_custom_bed)
|
|
||||||
{
|
{
|
||||||
_render_bed(theta);
|
_render_bed(theta);
|
||||||
// disable depth testing so that axes are not covered by ground
|
// disable depth testing so that axes are not covered by ground
|
||||||
|
@ -2366,13 +2368,16 @@ void GLCanvas3D::render()
|
||||||
}
|
}
|
||||||
_render_objects();
|
_render_objects();
|
||||||
|
|
||||||
// textured bed needs to be rendered after objects
|
if (!is_custom_bed) // textured bed needs to be rendered after objects
|
||||||
if (!is_custom_bed)
|
|
||||||
{
|
{
|
||||||
_render_axes(true);
|
_render_axes(true);
|
||||||
_render_bed(theta);
|
_render_bed(theta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_render_current_gizmo();
|
||||||
_render_cutting_plane();
|
_render_cutting_plane();
|
||||||
|
|
||||||
|
// draw overlays
|
||||||
_render_gizmos_overlay();
|
_render_gizmos_overlay();
|
||||||
_render_warning_texture();
|
_render_warning_texture();
|
||||||
_render_legend_texture();
|
_render_legend_texture();
|
||||||
|
@ -2463,7 +2468,7 @@ void GLCanvas3D::reload_scene(bool force)
|
||||||
if ((extruders_count > 1) && semm && wt && !co)
|
if ((extruders_count > 1) && semm && wt && !co)
|
||||||
{
|
{
|
||||||
// Height of a print (Show at least a slab)
|
// Height of a print (Show at least a slab)
|
||||||
coordf_t height = std::max(m_model->bounding_box().max(2), 10.0);
|
double height = std::max(m_model->bounding_box().max(2), 10.0);
|
||||||
|
|
||||||
float x = dynamic_cast<const ConfigOptionFloat*>(m_config->option("wipe_tower_x"))->value;
|
float x = dynamic_cast<const ConfigOptionFloat*>(m_config->option("wipe_tower_x"))->value;
|
||||||
float y = dynamic_cast<const ConfigOptionFloat*>(m_config->option("wipe_tower_y"))->value;
|
float y = dynamic_cast<const ConfigOptionFloat*>(m_config->option("wipe_tower_y"))->value;
|
||||||
|
@ -3208,7 +3213,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
m_mouse.drag.start_position_3D = Vec3d((coordf_t)pos(0), (coordf_t)pos(1), 0.0);
|
m_mouse.drag.start_position_3D = Vec3d((double)pos(0), (double)pos(1), 0.0);
|
||||||
}
|
}
|
||||||
else if (evt.MiddleIsDown() || evt.RightIsDown())
|
else if (evt.MiddleIsDown() || evt.RightIsDown())
|
||||||
{
|
{
|
||||||
|
@ -3302,7 +3307,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
}
|
}
|
||||||
else if (evt.Moving())
|
else if (evt.Moving())
|
||||||
{
|
{
|
||||||
m_mouse.position = Vec2d((coordf_t)pos(0), (coordf_t)pos(1));
|
m_mouse.position = Vec2d((double)pos(0), (double)pos(1));
|
||||||
// Only refresh if picking is enabled, in that case the objects may get highlighted if the mouse cursor hovers over.
|
// Only refresh if picking is enabled, in that case the objects may get highlighted if the mouse cursor hovers over.
|
||||||
if (m_picking_enabled)
|
if (m_picking_enabled)
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
|
@ -3671,9 +3676,9 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co
|
||||||
::glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
|
::glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
|
||||||
|
|
||||||
// camera axes
|
// camera axes
|
||||||
Vec3d right((coordf_t)matrix[0], (coordf_t)matrix[4], (coordf_t)matrix[8]);
|
Vec3d right((double)matrix[0], (double)matrix[4], (double)matrix[8]);
|
||||||
Vec3d up((coordf_t)matrix[1], (coordf_t)matrix[5], (coordf_t)matrix[9]);
|
Vec3d up((double)matrix[1], (double)matrix[5], (double)matrix[9]);
|
||||||
Vec3d forward((coordf_t)matrix[2], (coordf_t)matrix[6], (coordf_t)matrix[10]);
|
Vec3d forward((double)matrix[2], (double)matrix[6], (double)matrix[10]);
|
||||||
|
|
||||||
Vec3d bb_min = bbox.min;
|
Vec3d bb_min = bbox.min;
|
||||||
Vec3d bb_max = bbox.max;
|
Vec3d bb_max = bbox.max;
|
||||||
|
@ -3691,11 +3696,11 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co
|
||||||
vertices.push_back(bb_max);
|
vertices.push_back(bb_max);
|
||||||
vertices.emplace_back(bb_min(0), bb_max(1), bb_max(2));
|
vertices.emplace_back(bb_min(0), bb_max(1), bb_max(2));
|
||||||
|
|
||||||
coordf_t max_x = 0.0;
|
double max_x = 0.0;
|
||||||
coordf_t max_y = 0.0;
|
double max_y = 0.0;
|
||||||
|
|
||||||
// margin factor to give some empty space around the bbox
|
// margin factor to give some empty space around the bbox
|
||||||
coordf_t margin_factor = 1.25;
|
double margin_factor = 1.25;
|
||||||
|
|
||||||
for (const Vec3d v : vertices)
|
for (const Vec3d v : vertices)
|
||||||
{
|
{
|
||||||
|
@ -3704,8 +3709,8 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co
|
||||||
Vec3d proj_on_plane = pos - pos.dot(forward) * forward;
|
Vec3d proj_on_plane = pos - pos.dot(forward) * forward;
|
||||||
|
|
||||||
// calculates vertex coordinate along camera xy axes
|
// calculates vertex coordinate along camera xy axes
|
||||||
coordf_t x_on_plane = proj_on_plane.dot(right);
|
double x_on_plane = proj_on_plane.dot(right);
|
||||||
coordf_t y_on_plane = proj_on_plane.dot(up);
|
double y_on_plane = proj_on_plane.dot(up);
|
||||||
|
|
||||||
max_x = std::max(max_x, margin_factor * std::abs(x_on_plane));
|
max_x = std::max(max_x, margin_factor * std::abs(x_on_plane));
|
||||||
max_y = std::max(max_y, margin_factor * std::abs(y_on_plane));
|
max_y = std::max(max_y, margin_factor * std::abs(y_on_plane));
|
||||||
|
@ -3718,7 +3723,7 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co
|
||||||
max_y *= 2.0;
|
max_y *= 2.0;
|
||||||
|
|
||||||
const Size& cnv_size = get_canvas_size();
|
const Size& cnv_size = get_canvas_size();
|
||||||
return (float)std::min((coordf_t)cnv_size.get_width() / max_x, (coordf_t)cnv_size.get_height() / max_y);
|
return (float)std::min((double)cnv_size.get_width() / max_x, (double)cnv_size.get_height() / max_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_deregister_callbacks()
|
void GLCanvas3D::_deregister_callbacks()
|
||||||
|
@ -3819,8 +3824,8 @@ void GLCanvas3D::_picking_pass() const
|
||||||
|
|
||||||
::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
m_gizmos.render_current_gizmo_for_picking_pass(_selected_volumes_bounding_box());
|
|
||||||
_render_volumes(true);
|
_render_volumes(true);
|
||||||
|
m_gizmos.render_current_gizmo_for_picking_pass(_selected_volumes_bounding_box());
|
||||||
|
|
||||||
if (m_multisample_allowed)
|
if (m_multisample_allowed)
|
||||||
::glEnable(GL_MULTISAMPLE);
|
::glEnable(GL_MULTISAMPLE);
|
||||||
|
@ -4155,7 +4160,7 @@ Vec3d GLCanvas3D::_mouse_to_3d(const Point& mouse_pos, float* z)
|
||||||
|
|
||||||
GLdouble out_x, out_y, out_z;
|
GLdouble out_x, out_y, out_z;
|
||||||
::gluUnProject((GLdouble)mouse_pos(0), (GLdouble)y, (GLdouble)mouse_z, modelview_matrix, projection_matrix, viewport, &out_x, &out_y, &out_z);
|
::gluUnProject((GLdouble)mouse_pos(0), (GLdouble)y, (GLdouble)mouse_z, modelview_matrix, projection_matrix, viewport, &out_x, &out_y, &out_z);
|
||||||
return Vec3d((coordf_t)out_x, (coordf_t)out_y, (coordf_t)out_z);
|
return Vec3d((double)out_x, (double)out_y, (double)out_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3d GLCanvas3D::_mouse_to_bed_3d(const Point& mouse_pos)
|
Vec3d GLCanvas3D::_mouse_to_bed_3d(const Point& mouse_pos)
|
||||||
|
@ -5110,7 +5115,7 @@ void GLCanvas3D::_load_shells()
|
||||||
}
|
}
|
||||||
|
|
||||||
// adds wipe tower's volume
|
// adds wipe tower's volume
|
||||||
coordf_t max_z = m_print->objects[0]->model_object()->get_model()->bounding_box().max(2);
|
double max_z = m_print->objects[0]->model_object()->get_model()->bounding_box().max(2);
|
||||||
const PrintConfig& config = m_print->config;
|
const PrintConfig& config = m_print->config;
|
||||||
unsigned int extruders_count = config.nozzle_diameter.size();
|
unsigned int extruders_count = config.nozzle_diameter.size();
|
||||||
if ((extruders_count > 1) && config.single_extruder_multi_material && config.wipe_tower && !config.complete_objects) {
|
if ((extruders_count > 1) && config.single_extruder_multi_material && config.wipe_tower && !config.complete_objects) {
|
||||||
|
@ -5183,8 +5188,8 @@ void GLCanvas3D::_update_gcode_volumes_visibility(const GCodePreviewData& previe
|
||||||
void GLCanvas3D::_update_toolpath_volumes_outside_state()
|
void GLCanvas3D::_update_toolpath_volumes_outside_state()
|
||||||
{
|
{
|
||||||
// tolerance to avoid false detection at bed edges
|
// tolerance to avoid false detection at bed edges
|
||||||
static const coordf_t tolerance_x = 0.05;
|
static const double tolerance_x = 0.05;
|
||||||
static const coordf_t tolerance_y = 0.05;
|
static const double tolerance_y = 0.05;
|
||||||
|
|
||||||
BoundingBoxf3 print_volume;
|
BoundingBoxf3 print_volume;
|
||||||
if (m_config != nullptr)
|
if (m_config != nullptr)
|
||||||
|
|
|
@ -295,19 +295,31 @@ void GLGizmoRotate::on_update(const Linef3& mouse_ray)
|
||||||
|
|
||||||
double theta = ::acos(clamp(-1.0, 1.0, new_dir.dot(orig_dir)));
|
double theta = ::acos(clamp(-1.0, 1.0, new_dir.dot(orig_dir)));
|
||||||
if (cross2(orig_dir, new_dir) < 0.0)
|
if (cross2(orig_dir, new_dir) < 0.0)
|
||||||
theta = 2.0 * (coordf_t)PI - theta;
|
theta = 2.0 * (double)PI - theta;
|
||||||
|
|
||||||
// snap
|
|
||||||
double len = mouse_pos.norm();
|
double len = mouse_pos.norm();
|
||||||
|
|
||||||
|
// snap to snap region
|
||||||
double in_radius = (double)m_radius / 3.0;
|
double in_radius = (double)m_radius / 3.0;
|
||||||
double out_radius = 2.0 * (double)in_radius;
|
double out_radius = 2.0 * (double)in_radius;
|
||||||
if ((in_radius <= len) && (len <= out_radius))
|
if ((in_radius <= len) && (len <= out_radius))
|
||||||
{
|
{
|
||||||
coordf_t step = 2.0 * (coordf_t)PI / (coordf_t)SnapRegionsCount;
|
double step = 2.0 * (double)PI / (double)SnapRegionsCount;
|
||||||
theta = step * (coordf_t)std::round(theta / step);
|
theta = step * (double)std::round(theta / step);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// snap to scale
|
||||||
|
in_radius = (double)m_radius;
|
||||||
|
out_radius = in_radius + (double)ScaleLongTooth;
|
||||||
|
if ((in_radius <= len) && (len <= out_radius))
|
||||||
|
{
|
||||||
|
double step = 2.0 * (double)PI / (double)ScaleStepsCount;
|
||||||
|
theta = step * (double)std::round(theta / step);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theta == 2.0 * (coordf_t)PI)
|
if (theta == 2.0 * (double)PI)
|
||||||
theta = 0.0;
|
theta = 0.0;
|
||||||
|
|
||||||
m_angle = (float)theta;
|
m_angle = (float)theta;
|
||||||
|
@ -373,11 +385,7 @@ void GLGizmoRotate::on_render(const BoundingBoxf3& box) const
|
||||||
|
|
||||||
void GLGizmoRotate::on_render_for_picking(const BoundingBoxf3& box) const
|
void GLGizmoRotate::on_render_for_picking(const BoundingBoxf3& box) const
|
||||||
{
|
{
|
||||||
#if ENABLE_GIZMOS_3D
|
|
||||||
::glEnable(GL_DEPTH_TEST);
|
|
||||||
#else
|
|
||||||
::glDisable(GL_DEPTH_TEST);
|
::glDisable(GL_DEPTH_TEST);
|
||||||
#endif // ENABLE_GIZMOS_3D
|
|
||||||
|
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
transform_to_local();
|
transform_to_local();
|
||||||
|
@ -513,7 +521,7 @@ void GLGizmoRotate::transform_to_local() const
|
||||||
}
|
}
|
||||||
case Y:
|
case Y:
|
||||||
{
|
{
|
||||||
::glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
|
::glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
|
||||||
::glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
::glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -543,7 +551,7 @@ Vec3d GLGizmoRotate::mouse_position_in_local_plane(const Linef3& mouse_ray) cons
|
||||||
case Y:
|
case Y:
|
||||||
{
|
{
|
||||||
m.rotate(Eigen::AngleAxisd(-(double)PI, Vec3d::UnitZ()));
|
m.rotate(Eigen::AngleAxisd(-(double)PI, Vec3d::UnitZ()));
|
||||||
m.rotate(Eigen::AngleAxisd(-half_pi, Vec3d::UnitX()));
|
m.rotate(Eigen::AngleAxisd(half_pi, Vec3d::UnitX()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -841,7 +849,7 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
||||||
{
|
{
|
||||||
::glEnable(GL_DEPTH_TEST);
|
::glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
Vec3d offset_vec((double)Offset, (double)Offset, (double)Offset);
|
Vec3d offset_vec = (double)Offset * Vec3d::Ones();
|
||||||
|
|
||||||
m_box = BoundingBoxf3(box.min - offset_vec, box.max + offset_vec);
|
m_box = BoundingBoxf3(box.min - offset_vec, box.max + offset_vec);
|
||||||
const Vec3d& center = m_box.center();
|
const Vec3d& center = m_box.center();
|
||||||
|
@ -926,7 +934,7 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
||||||
|
|
||||||
void GLGizmoScale3D::on_render_for_picking(const BoundingBoxf3& box) const
|
void GLGizmoScale3D::on_render_for_picking(const BoundingBoxf3& box) const
|
||||||
{
|
{
|
||||||
::glEnable(GL_DEPTH_TEST);
|
::glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i)
|
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,10 +82,10 @@ bool GLToolbarItem::is_separator() const
|
||||||
|
|
||||||
void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const
|
void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const
|
||||||
{
|
{
|
||||||
GLTexture::render_sub_texture(tex_id, left, right, bottom, top, _get_uvs(texture_size, border_size, icon_size, gap_size));
|
GLTexture::render_sub_texture(tex_id, left, right, bottom, top, get_uvs(texture_size, border_size, icon_size, gap_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
GLTexture::Quad_UVs GLToolbarItem::_get_uvs(unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const
|
GLTexture::Quad_UVs GLToolbarItem::get_uvs(unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const
|
||||||
{
|
{
|
||||||
GLTexture::Quad_UVs uvs;
|
GLTexture::Quad_UVs uvs;
|
||||||
|
|
||||||
|
@ -209,11 +209,11 @@ float GLToolbar::get_width() const
|
||||||
default:
|
default:
|
||||||
case Layout::Horizontal:
|
case Layout::Horizontal:
|
||||||
{
|
{
|
||||||
return _get_width_horizontal();
|
return get_width_horizontal();
|
||||||
}
|
}
|
||||||
case Layout::Vertical:
|
case Layout::Vertical:
|
||||||
{
|
{
|
||||||
return _get_width_vertical();
|
return get_width_vertical();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,11 +225,11 @@ float GLToolbar::get_height() const
|
||||||
default:
|
default:
|
||||||
case Layout::Horizontal:
|
case Layout::Horizontal:
|
||||||
{
|
{
|
||||||
return _get_height_horizontal();
|
return get_height_horizontal();
|
||||||
}
|
}
|
||||||
case Layout::Vertical:
|
case Layout::Vertical:
|
||||||
{
|
{
|
||||||
return _get_height_vertical();
|
return get_height_vertical();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,12 +279,12 @@ void GLToolbar::update_hover_state(const Vec2d& mouse_pos)
|
||||||
default:
|
default:
|
||||||
case Layout::Horizontal:
|
case Layout::Horizontal:
|
||||||
{
|
{
|
||||||
_update_hover_state_horizontal(mouse_pos);
|
update_hover_state_horizontal(mouse_pos);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Layout::Vertical:
|
case Layout::Vertical:
|
||||||
{
|
{
|
||||||
_update_hover_state_vertical(mouse_pos);
|
update_hover_state_vertical(mouse_pos);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,11 +300,11 @@ int GLToolbar::contains_mouse(const Vec2d& mouse_pos) const
|
||||||
default:
|
default:
|
||||||
case Layout::Horizontal:
|
case Layout::Horizontal:
|
||||||
{
|
{
|
||||||
return _contains_mouse_horizontal(mouse_pos);
|
return contains_mouse_horizontal(mouse_pos);
|
||||||
}
|
}
|
||||||
case Layout::Vertical:
|
case Layout::Vertical:
|
||||||
{
|
{
|
||||||
return _contains_mouse_vertical(mouse_pos);
|
return contains_mouse_vertical(mouse_pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,12 +358,12 @@ void GLToolbar::render() const
|
||||||
default:
|
default:
|
||||||
case Layout::Horizontal:
|
case Layout::Horizontal:
|
||||||
{
|
{
|
||||||
_render_horizontal();
|
render_horizontal();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Layout::Vertical:
|
case Layout::Vertical:
|
||||||
{
|
{
|
||||||
_render_vertical();
|
render_vertical();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -371,27 +371,27 @@ void GLToolbar::render() const
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLToolbar::_get_width_horizontal() const
|
float GLToolbar::get_width_horizontal() const
|
||||||
{
|
{
|
||||||
return _get_main_size();
|
return get_main_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLToolbar::_get_width_vertical() const
|
float GLToolbar::get_width_vertical() const
|
||||||
{
|
{
|
||||||
return m_icons_texture.items_icon_size;
|
return m_icons_texture.items_icon_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLToolbar::_get_height_horizontal() const
|
float GLToolbar::get_height_horizontal() const
|
||||||
{
|
{
|
||||||
return m_icons_texture.items_icon_size;
|
return m_icons_texture.items_icon_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLToolbar::_get_height_vertical() const
|
float GLToolbar::get_height_vertical() const
|
||||||
{
|
{
|
||||||
return _get_main_size();
|
return get_main_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLToolbar::_get_main_size() const
|
float GLToolbar::get_main_size() const
|
||||||
{
|
{
|
||||||
float size = 0.0f;
|
float size = 0.0f;
|
||||||
for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
|
for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
|
||||||
|
@ -408,7 +408,7 @@ float GLToolbar::_get_main_size() const
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLToolbar::_update_hover_state_horizontal(const Vec2d& mouse_pos)
|
void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos)
|
||||||
{
|
{
|
||||||
float zoom = m_parent.get_camera_zoom();
|
float zoom = m_parent.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
@ -488,7 +488,7 @@ void GLToolbar::_update_hover_state_horizontal(const Vec2d& mouse_pos)
|
||||||
m_parent.set_tooltip(tooltip);
|
m_parent.set_tooltip(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLToolbar::_update_hover_state_vertical(const Vec2d& mouse_pos)
|
void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos)
|
||||||
{
|
{
|
||||||
float zoom = m_parent.get_camera_zoom();
|
float zoom = m_parent.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
@ -568,7 +568,7 @@ void GLToolbar::_update_hover_state_vertical(const Vec2d& mouse_pos)
|
||||||
m_parent.set_tooltip(tooltip);
|
m_parent.set_tooltip(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GLToolbar::_contains_mouse_horizontal(const Vec2d& mouse_pos) const
|
int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos) const
|
||||||
{
|
{
|
||||||
float zoom = m_parent.get_camera_zoom();
|
float zoom = m_parent.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
@ -609,7 +609,7 @@ int GLToolbar::_contains_mouse_horizontal(const Vec2d& mouse_pos) const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GLToolbar::_contains_mouse_vertical(const Vec2d& mouse_pos) const
|
int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos) const
|
||||||
{
|
{
|
||||||
float zoom = m_parent.get_camera_zoom();
|
float zoom = m_parent.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
@ -650,7 +650,7 @@ int GLToolbar::_contains_mouse_vertical(const Vec2d& mouse_pos) const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLToolbar::_render_horizontal() const
|
void GLToolbar::render_horizontal() const
|
||||||
{
|
{
|
||||||
unsigned int tex_id = m_icons_texture.texture.get_id();
|
unsigned int tex_id = m_icons_texture.texture.get_id();
|
||||||
int tex_size = m_icons_texture.texture.get_width();
|
int tex_size = m_icons_texture.texture.get_width();
|
||||||
|
@ -684,7 +684,7 @@ void GLToolbar::_render_horizontal() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLToolbar::_render_vertical() const
|
void GLToolbar::render_vertical() const
|
||||||
{
|
{
|
||||||
unsigned int tex_id = m_icons_texture.texture.get_id();
|
unsigned int tex_id = m_icons_texture.texture.get_id();
|
||||||
int tex_size = m_icons_texture.texture.get_width();
|
int tex_size = m_icons_texture.texture.get_width();
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
void render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const;
|
void render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLTexture::Quad_UVs _get_uvs(unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const;
|
GLTexture::Quad_UVs get_uvs(unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GLToolbar
|
class GLToolbar
|
||||||
|
@ -155,18 +155,18 @@ public:
|
||||||
void render() const;
|
void render() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _get_width_horizontal() const;
|
float get_width_horizontal() const;
|
||||||
float _get_width_vertical() const;
|
float get_width_vertical() const;
|
||||||
float _get_height_horizontal() const;
|
float get_height_horizontal() const;
|
||||||
float _get_height_vertical() const;
|
float get_height_vertical() const;
|
||||||
float _get_main_size() const;
|
float get_main_size() const;
|
||||||
void _update_hover_state_horizontal(const Vec2d& mouse_pos);
|
void update_hover_state_horizontal(const Vec2d& mouse_pos);
|
||||||
void _update_hover_state_vertical(const Vec2d& mouse_pos);
|
void update_hover_state_vertical(const Vec2d& mouse_pos);
|
||||||
int _contains_mouse_horizontal(const Vec2d& mouse_pos) const;
|
int contains_mouse_horizontal(const Vec2d& mouse_pos) const;
|
||||||
int _contains_mouse_vertical(const Vec2d& mouse_pos) const;
|
int contains_mouse_vertical(const Vec2d& mouse_pos) const;
|
||||||
|
|
||||||
void _render_horizontal() const;
|
void render_horizontal() const;
|
||||||
void _render_vertical() const;
|
void render_vertical() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
|
|
Loading…
Reference in a new issue