Merge branch 'master' into fs_QuadricEdgeCollapse
This commit is contained in:
commit
5ac2809426
14
resources/shaders/picking.fs
Normal file
14
resources/shaders/picking.fs
Normal file
@ -0,0 +1,14 @@
|
||||
#version 110
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform bool viewed_from_top;
|
||||
|
||||
varying float world_pos_z;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (viewed_from_top && world_pos_z < 0.0)
|
||||
discard;
|
||||
|
||||
gl_FragColor = uniform_color;
|
||||
}
|
11
resources/shaders/picking.vs
Normal file
11
resources/shaders/picking.vs
Normal file
@ -0,0 +1,11 @@
|
||||
#version 110
|
||||
|
||||
uniform mat4 world_matrix;
|
||||
|
||||
varying float world_pos_z;
|
||||
|
||||
void main()
|
||||
{
|
||||
world_pos_z = (world_matrix * gl_Vertex).z;
|
||||
gl_Position = ftransform();
|
||||
}
|
@ -1087,7 +1087,12 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware) {
|
||||
bool use_machine_limits = false;
|
||||
const ConfigOptionEnum<MachineLimitsUsage>* machine_limits_usage = config.option<ConfigOptionEnum<MachineLimitsUsage>>("machine_limits_usage");
|
||||
if (machine_limits_usage != nullptr)
|
||||
use_machine_limits = machine_limits_usage->value != MachineLimitsUsage::Ignore;
|
||||
|
||||
if (use_machine_limits && (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware)) {
|
||||
const ConfigOptionFloats* machine_max_acceleration_x = config.option<ConfigOptionFloats>("machine_max_acceleration_x");
|
||||
if (machine_max_acceleration_x != nullptr)
|
||||
m_time_processor.machine_limits.machine_max_acceleration_x.values = machine_max_acceleration_x->values;
|
||||
@ -1171,8 +1176,13 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
|
||||
m_time_processor.machines[i].travel_acceleration = (max_travel_acceleration > 0.0f) ? max_travel_acceleration : DEFAULT_TRAVEL_ACCELERATION;
|
||||
}
|
||||
|
||||
if (m_time_processor.machine_limits.machine_max_acceleration_x.values.size() > 1)
|
||||
enable_stealth_time_estimator(true);
|
||||
if (m_flavor == gcfMarlinLegacy || m_flavor == gcfMarlinFirmware) {
|
||||
const ConfigOptionBool* silent_mode = config.option<ConfigOptionBool>("silent_mode");
|
||||
if (silent_mode != nullptr) {
|
||||
if (silent_mode->value && m_time_processor.machine_limits.machine_max_acceleration_x.values.size() > 1)
|
||||
enable_stealth_time_estimator(true);
|
||||
}
|
||||
}
|
||||
|
||||
const ConfigOptionBool* use_volumetric_e = config.option<ConfigOptionBool>("use_volumetric_e");
|
||||
if (use_volumetric_e != nullptr)
|
||||
|
@ -1418,6 +1418,7 @@ const std::vector<std::string>& PhysicalPrinter::printer_options()
|
||||
static std::vector<std::string> s_opts;
|
||||
if (s_opts.empty()) {
|
||||
s_opts = {
|
||||
"preset_name", // temporary option to compatibility with older Slicer
|
||||
"preset_names",
|
||||
"printer_technology",
|
||||
"host_type",
|
||||
@ -1481,6 +1482,15 @@ void PhysicalPrinter::update_preset_names_in_config()
|
||||
values.clear();
|
||||
for (auto preset : preset_names)
|
||||
values.push_back(preset);
|
||||
|
||||
// temporary workaround for compatibility with older Slicer
|
||||
{
|
||||
std::string name;
|
||||
for (auto el : preset_names)
|
||||
name += el + ";";
|
||||
name.pop_back();
|
||||
config.set_key_value("preset_name", new ConfigOptionString(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,18 +352,12 @@ bool Print::has_brim() const
|
||||
return std::any_of(m_objects.begin(), m_objects.end(), [](PrintObject *object) { return object->has_brim(); });
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
bool Print::sequential_print_horizontal_clearance_valid(const Print& print, Polygons* polygons)
|
||||
#else
|
||||
static inline bool sequential_print_horizontal_clearance_valid(const Print &print)
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
{
|
||||
Polygons convex_hulls_other;
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (polygons != nullptr)
|
||||
polygons->clear();
|
||||
std::vector<size_t> intersecting_idxs;
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
std::map<ObjectID, Polygon> map_model_object_to_convex_hull;
|
||||
for (const PrintObject *print_object : print.objects()) {
|
||||
@ -408,7 +402,6 @@ static inline bool sequential_print_horizontal_clearance_valid(const Print &prin
|
||||
// instance.shift is a position of a centered object, while model object may not be centered.
|
||||
// Convert the shift from the PrintObject's coordinates into ModelObject's coordinates by removing the centering offset.
|
||||
convex_hull.translate(instance.shift - print_object->center_offset());
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
// if output needed, collect indices (inside convex_hulls_other) of intersecting hulls
|
||||
for (size_t i = 0; i < convex_hulls_other.size(); ++i) {
|
||||
if (!intersection((Polygons)convex_hulls_other[i], (Polygons)convex_hull).empty()) {
|
||||
@ -420,15 +413,10 @@ static inline bool sequential_print_horizontal_clearance_valid(const Print &prin
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!intersection(convex_hulls_other, (Polygons)convex_hull).empty())
|
||||
return false;
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
convex_hulls_other.emplace_back(std::move(convex_hull));
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (!intersecting_idxs.empty()) {
|
||||
// use collected indices (inside convex_hulls_other) to update output
|
||||
std::sort(intersecting_idxs.begin(), intersecting_idxs.end());
|
||||
@ -438,7 +426,6 @@ static inline bool sequential_print_horizontal_clearance_valid(const Print &prin
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -583,9 +583,7 @@ public:
|
||||
const PrintRegion& get_print_region(size_t idx) const { return *m_print_regions[idx]; }
|
||||
const ToolOrdering& get_tool_ordering() const { return m_wipe_tower_data.tool_ordering; }
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
static bool sequential_print_horizontal_clearance_valid(const Print& print, Polygons* polygons = nullptr);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
protected:
|
||||
// Invalidates the step, and its depending steps in Print.
|
||||
|
@ -317,6 +317,12 @@ void PrintConfigDef::init_common_params()
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionStrings());
|
||||
|
||||
// temporary workaround for compatibility with older Slicer
|
||||
{
|
||||
def = this->add("preset_name", coString);
|
||||
def->set_default_value(new ConfigOptionString());
|
||||
}
|
||||
|
||||
def = this->add("printhost_authorization_type", coEnum);
|
||||
def->label = L("Authorization Type");
|
||||
// def->tooltip = L("");
|
||||
|
@ -66,8 +66,6 @@
|
||||
// Enable to push object instances under the bed
|
||||
#define ENABLE_ALLOW_NEGATIVE_Z (1 && ENABLE_2_4_0_ALPHA0)
|
||||
#define DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA (1 && ENABLE_ALLOW_NEGATIVE_Z)
|
||||
// Enable visualization of objects clearance for sequential prints
|
||||
#define ENABLE_SEQUENTIAL_LIMITS (1 && ENABLE_2_4_0_ALPHA0)
|
||||
// Enable delayed rendering of transparent volumes
|
||||
#define ENABLE_DELAYED_TRANSPARENT_VOLUMES_RENDERING (1 && ENABLE_2_4_0_ALPHA0)
|
||||
|
||||
|
@ -107,9 +107,7 @@ void Bed3D::Axes::render() const
|
||||
glsafe(::glPopMatrix());
|
||||
};
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (!m_arrow.is_initialized())
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
const_cast<GLModel*>(&m_arrow)->init_from(stilized_arrow(16, DefaultTipRadius, DefaultTipLength, DefaultStemRadius, m_stem_length));
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
@ -122,30 +120,15 @@ void Bed3D::Axes::render() const
|
||||
shader->set_uniform("emission_factor", 0.0);
|
||||
|
||||
// x axis
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, { 0.75f, 0.0f, 0.0f, 1.0f });
|
||||
#else
|
||||
std::array<float, 4> color = { 0.75f, 0.0f, 0.0f, 1.0f };
|
||||
shader->set_uniform("uniform_color", color);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
render_axis(Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 }).cast<float>());
|
||||
|
||||
// y axis
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, { 0.0f, 0.75f, 0.0f, 1.0f });
|
||||
#else
|
||||
color = { 0.0f, 0.75f, 0.0f, 1.0f };
|
||||
shader->set_uniform("uniform_color", color);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
render_axis(Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 }).cast<float>());
|
||||
|
||||
// z axis
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, { 0.0f, 0.0f, 0.75f, 1.0f });
|
||||
#else
|
||||
color = { 0.0f, 0.0f, 0.75f, 1.0f };
|
||||
shader->set_uniform("uniform_color", color);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
render_axis(Geometry::assemble_transform(m_origin).cast<float>());
|
||||
|
||||
shader->stop_using();
|
||||
@ -425,9 +408,7 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
|
||||
}
|
||||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (bottom)
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
glsafe(::glDepthMask(GL_FALSE));
|
||||
|
||||
glsafe(::glEnable(GL_BLEND));
|
||||
@ -473,9 +454,7 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
|
||||
glsafe(::glDisable(GL_BLEND));
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (bottom)
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
glsafe(::glDepthMask(GL_TRUE));
|
||||
|
||||
shader->stop_using();
|
||||
@ -491,9 +470,7 @@ void Bed3D::render_model() const
|
||||
GLModel* model = const_cast<GLModel*>(&m_model);
|
||||
|
||||
if (model->get_filename() != m_model_filename && model->init_from_file(m_model_filename)) {
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
model->set_color(-1, m_model_color);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
// move the model so that its origin (0.0, 0.0, 0.0) goes into the bed shape center and a bit down to avoid z-fighting with the texture quad
|
||||
Vec3d shift = m_bounding_box.center();
|
||||
@ -508,9 +485,6 @@ void Bed3D::render_model() const
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if !ENABLE_SEQUENTIAL_LIMITS
|
||||
shader->set_uniform("uniform_color", m_model_color);
|
||||
#endif // !ENABLE_SEQUENTIAL_LIMITS
|
||||
shader->set_uniform("emission_factor", 0.0);
|
||||
::glPushMatrix();
|
||||
::glTranslated(m_model_offset.x(), m_model_offset.y(), m_model_offset.z());
|
||||
|
@ -205,9 +205,7 @@ void GCodeViewer::SequentialRangeCap::reset() {
|
||||
void GCodeViewer::SequentialView::Marker::init()
|
||||
{
|
||||
m_model.init_from(stilized_arrow(16, 2.0f, 4.0f, 1.0f, 8.0f));
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
m_model.set_color(-1, { 1.0f, 1.0f, 1.0f, 0.5f });
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
}
|
||||
|
||||
void GCodeViewer::SequentialView::Marker::set_world_position(const Vec3f& position)
|
||||
@ -229,9 +227,6 @@ void GCodeViewer::SequentialView::Marker::render() const
|
||||
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||
|
||||
shader->start_using();
|
||||
#if !ENABLE_SEQUENTIAL_LIMITS
|
||||
shader->set_uniform("uniform_color", m_color);
|
||||
#endif // !ENABLE_SEQUENTIAL_LIMITS
|
||||
shader->set_uniform("emission_factor", 0.0);
|
||||
|
||||
glsafe(::glPushMatrix());
|
||||
|
@ -505,9 +505,6 @@ public:
|
||||
Vec3f m_world_position;
|
||||
Transform3f m_world_transform;
|
||||
float m_z_offset{ 0.5f };
|
||||
#if !ENABLE_SEQUENTIAL_LIMITS
|
||||
std::array<float, 4> m_color{ 1.0f, 1.0f, 1.0f, 0.5f };
|
||||
#endif // !ENABLE_SEQUENTIAL_LIMITS
|
||||
bool m_visible{ true };
|
||||
|
||||
public:
|
||||
@ -516,9 +513,6 @@ public:
|
||||
const BoundingBoxf3& get_bounding_box() const { return m_model.get_bounding_box(); }
|
||||
|
||||
void set_world_position(const Vec3f& position);
|
||||
#if !ENABLE_SEQUENTIAL_LIMITS
|
||||
void set_color(const std::array<float, 4>& color) { m_color = color; }
|
||||
#endif // !ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
bool is_visible() const { return m_visible; }
|
||||
void set_visible(bool visible) { m_visible = visible; }
|
||||
|
@ -788,7 +788,6 @@ void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position, GLCanvas3D& canvas
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void GLCanvas3D::SequentialPrintClearance::set_polygons(const Polygons& polygons)
|
||||
{
|
||||
m_perimeter.reset();
|
||||
@ -875,7 +874,6 @@ void GLCanvas3D::SequentialPrintClearance::render()
|
||||
|
||||
shader->stop_using();
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, SimpleEvent);
|
||||
@ -893,9 +891,7 @@ wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_ROTATED, Vec3dEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED, SimpleEvent);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent);
|
||||
@ -1489,9 +1485,7 @@ void GLCanvas3D::render()
|
||||
_render_objects(GLVolumeCollection::ERenderType::Transparent);
|
||||
#endif // ENABLE_DELAYED_TRANSPARENT_VOLUMES_RENDERING
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
_render_sequential_clearance();
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
_render_selection_center();
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
@ -2986,7 +2980,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
m_mouse.set_start_position_3D_as_invalid();
|
||||
m_mouse.position = pos.cast<double>();
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (evt.Dragging() && current_printer_technology() == ptFFF && fff_print()->config().complete_objects) {
|
||||
switch (m_gizmos.get_current_type())
|
||||
{
|
||||
@ -3000,7 +2993,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
default: { break; }
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
return;
|
||||
}
|
||||
@ -3124,9 +3116,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
m_mouse.drag.move_volume_idx = volume_idx;
|
||||
m_selection.start_dragging();
|
||||
m_mouse.drag.start_position_3D = m_mouse.scene_position;
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
m_sequential_print_clearance_first_displacement = true;
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
m_moving = true;
|
||||
}
|
||||
}
|
||||
@ -3172,10 +3162,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
}
|
||||
|
||||
m_selection.translate(cur_pos - m_mouse.drag.start_position_3D);
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (current_printer_technology() == ptFFF && fff_print()->config().complete_objects)
|
||||
update_sequential_clearance();
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
wxGetApp().obj_manipul()->set_dirty();
|
||||
m_dirty = true;
|
||||
}
|
||||
@ -3455,9 +3443,7 @@ void GLCanvas3D::do_move(const std::string& snapshot_type)
|
||||
if (wipe_tower_origin != Vec3d::Zero())
|
||||
post_event(Vec3dEvent(EVT_GLCANVAS_WIPETOWER_MOVED, std::move(wipe_tower_origin)));
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
reset_sequential_print_clearance();
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
m_dirty = true;
|
||||
}
|
||||
@ -3805,7 +3791,6 @@ void GLCanvas3D::mouse_up_cleanup()
|
||||
m_canvas->ReleaseMouse();
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void GLCanvas3D::update_sequential_clearance()
|
||||
{
|
||||
if (current_printer_technology() != ptFFF || !fff_print()->config().complete_objects)
|
||||
@ -3895,7 +3880,6 @@ void GLCanvas3D::update_sequential_clearance()
|
||||
set_sequential_print_clearance_render_fill(false);
|
||||
set_sequential_print_clearance_polygons(polygons);
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
bool GLCanvas3D::_is_shown_on_screen() const
|
||||
{
|
||||
@ -5158,7 +5142,6 @@ void GLCanvas3D::_render_selection() const
|
||||
m_selection.render(scale_factor);
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void GLCanvas3D::_render_sequential_clearance()
|
||||
{
|
||||
if (m_layers_editing.is_enabled() || m_gizmos.is_dragging())
|
||||
@ -5177,7 +5160,6 @@ void GLCanvas3D::_render_sequential_clearance()
|
||||
|
||||
m_sequential_print_clearance.render();
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
void GLCanvas3D::_render_selection_center() const
|
||||
@ -5288,28 +5270,50 @@ void GLCanvas3D::_render_volumes_for_picking() const
|
||||
{
|
||||
static const GLfloat INV_255 = 1.0f / 255.0f;
|
||||
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
auto* shader = wxGetApp().get_shader("picking");
|
||||
if (!shader)
|
||||
return;
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
|
||||
// do not cull backfaces to show broken geometry, if any
|
||||
glsafe(::glDisable(GL_CULL_FACE));
|
||||
|
||||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
shader->start_using();
|
||||
shader->set_uniform("viewed_from_top", wxGetApp().plater()->get_camera().is_looking_downward());
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
|
||||
const Transform3d& view_matrix = wxGetApp().plater()->get_camera().get_view_matrix();
|
||||
for (size_t type = 0; type < 2; ++ type) {
|
||||
GLVolumeWithIdAndZList to_render = volumes_to_render(m_volumes.volumes, (type == 0) ? GLVolumeCollection::ERenderType::Opaque : GLVolumeCollection::ERenderType::Transparent, view_matrix);
|
||||
for (const GLVolumeWithIdAndZ& volume : to_render)
|
||||
if (!volume.first->disabled && ((volume.first->composite_id.volume_id >= 0) || m_render_sla_auxiliaries)) {
|
||||
if (!volume.first->disabled && (volume.first->composite_id.volume_id >= 0 || m_render_sla_auxiliaries)) {
|
||||
// Object picking mode. Render the object with a color encoding the object index.
|
||||
unsigned int id = volume.second.first;
|
||||
unsigned int r = (id & (0x000000FF << 0)) << 0;
|
||||
unsigned int g = (id & (0x000000FF << 8)) >> 8;
|
||||
unsigned int b = (id & (0x000000FF << 16)) >> 16;
|
||||
unsigned int a = picking_checksum_alpha_channel(r, g, b);
|
||||
glsafe(::glColor4f((GLfloat)r * INV_255, (GLfloat)g * INV_255, (GLfloat)b * INV_255, (GLfloat)a * INV_255));
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
std::array<float, 4> color = { (float)r * INV_255, (float)g * INV_255, (float)b * INV_255, (float)a * INV_255 };
|
||||
shader->set_uniform("uniform_color", color);
|
||||
shader->set_uniform("world_matrix", volume.first->world_matrix());
|
||||
#else
|
||||
glsafe(::glColor4f((GLfloat)r * INV_255, (GLfloat)g * INV_255, (GLfloat)b * INV_255, (GLfloat)a * INV_255));
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
|
||||
volume.first->render();
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
shader->stop_using();
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
|
||||
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
|
||||
|
@ -121,9 +121,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_SCALED, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_ROTATED, Vec3dEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED, SimpleEvent);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent);
|
||||
@ -500,7 +498,6 @@ private:
|
||||
|
||||
void load_arrange_settings();
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
class SequentialPrintClearance
|
||||
{
|
||||
GLModel m_fill;
|
||||
@ -521,7 +518,6 @@ private:
|
||||
|
||||
SequentialPrintClearance m_sequential_print_clearance;
|
||||
bool m_sequential_print_clearance_first_displacement{ true };
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
public:
|
||||
explicit GLCanvas3D(wxGLCanvas* canvas);
|
||||
@ -770,7 +766,6 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void reset_sequential_print_clearance() {
|
||||
m_sequential_print_clearance.set_visible(false);
|
||||
m_sequential_print_clearance.set_render_fill(false);
|
||||
@ -790,7 +785,6 @@ public:
|
||||
}
|
||||
|
||||
void update_sequential_clearance();
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
const Print* fff_print() const;
|
||||
const SLAPrint* sla_print() const;
|
||||
@ -829,9 +823,7 @@ private:
|
||||
#endif // ENABLE_DELAYED_TRANSPARENT_VOLUMES_RENDERING
|
||||
void _render_gcode() const;
|
||||
void _render_selection() const;
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void _render_sequential_clearance();
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
void _render_selection_center() const;
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
|
@ -2,10 +2,8 @@
|
||||
#include "GLModel.hpp"
|
||||
|
||||
#include "3DScene.hpp"
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
#include "GUI_App.hpp"
|
||||
#include "GLShader.hpp"
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
#include "libslic3r/TriangleMesh.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
@ -18,7 +16,6 @@
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void GLModel::init_from(const InitializationData& data)
|
||||
{
|
||||
if (!m_render_data.empty()) // call reset() if you want to reuse this model
|
||||
@ -56,44 +53,10 @@ void GLModel::init_from(const InitializationData& data)
|
||||
send_to_gpu(rdata, vertices, indices);
|
||||
m_render_data.emplace_back(rdata);
|
||||
}
|
||||
#else
|
||||
void GLModel::init_from(const GLModelInitializationData& data)
|
||||
{
|
||||
assert(!data.positions.empty() && !data.triangles.empty());
|
||||
assert(data.positions.size() == data.normals.size());
|
||||
|
||||
if (m_vbo_id > 0) // call reset() if you want to reuse this model
|
||||
return;
|
||||
|
||||
// vertices/normals data
|
||||
std::vector<float> vertices(6 * data.positions.size());
|
||||
for (size_t i = 0; i < data.positions.size(); ++i) {
|
||||
size_t offset = i * 6;
|
||||
::memcpy(static_cast<void*>(&vertices[offset]), static_cast<const void*>(data.positions[i].data()), 3 * sizeof(float));
|
||||
::memcpy(static_cast<void*>(&vertices[3 + offset]), static_cast<const void*>(data.normals[i].data()), 3 * sizeof(float));
|
||||
}
|
||||
|
||||
// indices data
|
||||
std::vector<unsigned int> indices(3 * data.triangles.size());
|
||||
for (size_t i = 0; i < data.triangles.size(); ++i) {
|
||||
for (size_t j = 0; j < 3; ++j) {
|
||||
indices[i * 3 + j] = static_cast<unsigned int>(data.triangles[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
m_indices_count = static_cast<unsigned int>(indices.size());
|
||||
m_bounding_box = BoundingBoxf3();
|
||||
for (size_t i = 0; i < data.positions.size(); ++i) {
|
||||
m_bounding_box.merge(data.positions[i].cast<double>());
|
||||
}
|
||||
|
||||
send_to_gpu(vertices, indices);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
}
|
||||
|
||||
void GLModel::init_from(const TriangleMesh& mesh)
|
||||
{
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (!m_render_data.empty()) // call reset() if you want to reuse this model
|
||||
return;
|
||||
|
||||
@ -122,32 +85,6 @@ void GLModel::init_from(const TriangleMesh& mesh)
|
||||
|
||||
send_to_gpu(data, vertices, indices);
|
||||
m_render_data.emplace_back(data);
|
||||
#else
|
||||
if (m_vbo_id > 0) // call reset() if you want to reuse this model
|
||||
return;
|
||||
|
||||
std::vector<float> vertices = std::vector<float>(18 * mesh.stl.stats.number_of_facets);
|
||||
std::vector<unsigned int> indices = std::vector<unsigned int>(3 * mesh.stl.stats.number_of_facets);
|
||||
|
||||
unsigned int vertices_count = 0;
|
||||
for (uint32_t i = 0; i < mesh.stl.stats.number_of_facets; ++i) {
|
||||
const stl_facet& facet = mesh.stl.facet_start[i];
|
||||
for (uint32_t j = 0; j < 3; ++j) {
|
||||
uint32_t offset = i * 18 + j * 6;
|
||||
::memcpy(static_cast<void*>(&vertices[offset]), static_cast<const void*>(facet.vertex[j].data()), 3 * sizeof(float));
|
||||
::memcpy(static_cast<void*>(&vertices[3 + offset]), static_cast<const void*>(facet.normal.data()), 3 * sizeof(float));
|
||||
}
|
||||
for (uint32_t j = 0; j < 3; ++j) {
|
||||
indices[i * 3 + j] = vertices_count + j;
|
||||
}
|
||||
vertices_count += 3;
|
||||
}
|
||||
|
||||
m_indices_count = static_cast<unsigned int>(indices.size());
|
||||
m_bounding_box = mesh.bounding_box();
|
||||
|
||||
send_to_gpu(vertices, indices);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
}
|
||||
|
||||
bool GLModel::init_from_file(const std::string& filename)
|
||||
@ -175,7 +112,6 @@ bool GLModel::init_from_file(const std::string& filename)
|
||||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void GLModel::set_color(int entity_id, const std::array<float, 4>& color)
|
||||
{
|
||||
for (size_t i = 0; i < m_render_data.size(); ++i) {
|
||||
@ -183,11 +119,9 @@ void GLModel::set_color(int entity_id, const std::array<float, 4>& color)
|
||||
m_render_data[i].color = color;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
void GLModel::reset()
|
||||
{
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
for (RenderData& data : m_render_data) {
|
||||
// release gpu memory
|
||||
if (data.ibo_id > 0)
|
||||
@ -197,27 +131,12 @@ void GLModel::reset()
|
||||
}
|
||||
|
||||
m_render_data.clear();
|
||||
#else
|
||||
// release gpu memory
|
||||
if (m_ibo_id > 0) {
|
||||
glsafe(::glDeleteBuffers(1, &m_ibo_id));
|
||||
m_ibo_id = 0;
|
||||
}
|
||||
|
||||
if (m_vbo_id > 0) {
|
||||
glsafe(::glDeleteBuffers(1, &m_vbo_id));
|
||||
m_vbo_id = 0;
|
||||
}
|
||||
|
||||
m_indices_count = 0;
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
m_bounding_box = BoundingBoxf3();
|
||||
m_filename = std::string();
|
||||
}
|
||||
|
||||
void GLModel::render() const
|
||||
{
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
for (const RenderData& data : m_render_data) {
|
||||
if (data.vbo_id == 0 || data.ibo_id == 0)
|
||||
continue;
|
||||
@ -252,29 +171,8 @@ void GLModel::render() const
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
}
|
||||
#else
|
||||
if (m_vbo_id == 0 || m_ibo_id == 0)
|
||||
return;
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_vbo_id));
|
||||
glsafe(::glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), (const void*)0));
|
||||
glsafe(::glNormalPointer(GL_FLOAT, 6 * sizeof(float), (const void*)(3 * sizeof(float))));
|
||||
|
||||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ibo_id));
|
||||
glsafe(::glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(m_indices_count), GL_UNSIGNED_INT, (const void*)0));
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||
|
||||
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void GLModel::send_to_gpu(RenderData& data, const std::vector<float>& vertices, const std::vector<unsigned int>& indices)
|
||||
{
|
||||
assert(data.vbo_id == 0);
|
||||
@ -292,24 +190,7 @@ void GLModel::send_to_gpu(RenderData& data, const std::vector<float>& vertices,
|
||||
glsafe(::glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned int), indices.data(), GL_STATIC_DRAW));
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||
}
|
||||
#else
|
||||
void GLModel::send_to_gpu(const std::vector<float>& vertices, const std::vector<unsigned int>& indices)
|
||||
{
|
||||
// vertex data -> send to gpu
|
||||
glsafe(::glGenBuffers(1, &m_vbo_id));
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_vbo_id));
|
||||
glsafe(::glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), vertices.data(), GL_STATIC_DRAW));
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
|
||||
// indices data -> send to gpu
|
||||
glsafe(::glGenBuffers(1, &m_ibo_id));
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ibo_id));
|
||||
glsafe(::glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned int), indices.data(), GL_STATIC_DRAW));
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
GLModel::InitializationData stilized_arrow(int resolution, float tip_radius, float tip_height, float stem_radius, float stem_height)
|
||||
{
|
||||
auto append_vertex = [](GLModel::InitializationData::Entity& entity, const Vec3f& position, const Vec3f& normal) {
|
||||
@ -321,24 +202,12 @@ GLModel::InitializationData stilized_arrow(int resolution, float tip_radius, flo
|
||||
entity.indices.emplace_back(v2);
|
||||
entity.indices.emplace_back(v3);
|
||||
};
|
||||
#else
|
||||
GLModelInitializationData stilized_arrow(int resolution, float tip_radius, float tip_height, float stem_radius, float stem_height)
|
||||
{
|
||||
auto append_vertex = [](GLModelInitializationData& data, const Vec3f& position, const Vec3f& normal) {
|
||||
data.positions.emplace_back(position);
|
||||
data.normals.emplace_back(normal);
|
||||
};
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
resolution = std::max(4, resolution);
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
GLModel::InitializationData data;
|
||||
GLModel::InitializationData::Entity entity;
|
||||
entity.type = GLModel::PrimitiveType::Triangles;
|
||||
#else
|
||||
GLModelInitializationData data;
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
const float angle_step = 2.0f * M_PI / static_cast<float>(resolution);
|
||||
std::vector<float> cosines(resolution);
|
||||
@ -352,7 +221,6 @@ GLModelInitializationData stilized_arrow(int resolution, float tip_radius, float
|
||||
|
||||
const float total_height = tip_height + stem_height;
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
// tip vertices/normals
|
||||
append_vertex(entity, { 0.0f, 0.0f, total_height }, Vec3f::UnitZ());
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
@ -414,72 +282,9 @@ GLModelInitializationData stilized_arrow(int resolution, float tip_radius, float
|
||||
}
|
||||
|
||||
data.entities.emplace_back(entity);
|
||||
#else
|
||||
// tip vertices/normals
|
||||
append_vertex(data, { 0.0f, 0.0f, total_height }, Vec3f::UnitZ());
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
append_vertex(data, { tip_radius * sines[i], tip_radius * cosines[i], stem_height }, { sines[i], cosines[i], 0.0f });
|
||||
}
|
||||
|
||||
// tip triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
int v3 = (i < resolution - 1) ? i + 2 : 1;
|
||||
data.triangles.emplace_back(0, i + 1, v3);
|
||||
}
|
||||
|
||||
// tip cap outer perimeter vertices
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
append_vertex(data, { tip_radius * sines[i], tip_radius * cosines[i], stem_height }, -Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
// tip cap inner perimeter vertices
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
append_vertex(data, { stem_radius * sines[i], stem_radius * cosines[i], stem_height }, -Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
// tip cap triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
int v2 = (i < resolution - 1) ? i + resolution + 2 : resolution + 1;
|
||||
int v3 = (i < resolution - 1) ? i + 2 * resolution + 2 : 2 * resolution + 1;
|
||||
data.triangles.emplace_back(i + resolution + 1, v3, v2);
|
||||
data.triangles.emplace_back(i + resolution + 1, i + 2 * resolution + 1, v3);
|
||||
}
|
||||
|
||||
// stem bottom vertices
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
append_vertex(data, { stem_radius * sines[i], stem_radius * cosines[i], stem_height }, { sines[i], cosines[i], 0.0f });
|
||||
}
|
||||
|
||||
// stem top vertices
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
append_vertex(data, { stem_radius * sines[i], stem_radius * cosines[i], 0.0f }, { sines[i], cosines[i], 0.0f });
|
||||
}
|
||||
|
||||
// stem triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
int v2 = (i < resolution - 1) ? i + 3 * resolution + 2 : 3 * resolution + 1;
|
||||
int v3 = (i < resolution - 1) ? i + 4 * resolution + 2 : 4 * resolution + 1;
|
||||
data.triangles.emplace_back(i + 3 * resolution + 1, v3, v2);
|
||||
data.triangles.emplace_back(i + 3 * resolution + 1, i + 4 * resolution + 1, v3);
|
||||
}
|
||||
|
||||
// stem cap vertices
|
||||
append_vertex(data, Vec3f::Zero(), -Vec3f::UnitZ());
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
append_vertex(data, { stem_radius * sines[i], stem_radius * cosines[i], 0.0f }, -Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
// stem cap triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
int v3 = (i < resolution - 1) ? i + 5 * resolution + 3 : 5 * resolution + 2;
|
||||
data.triangles.emplace_back(5 * resolution + 1, v3, i + 5 * resolution + 2);
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
GLModel::InitializationData circular_arrow(int resolution, float radius, float tip_height, float tip_width, float stem_width, float thickness)
|
||||
{
|
||||
auto append_vertex = [](GLModel::InitializationData::Entity& entity, const Vec3f& position, const Vec3f& normal) {
|
||||
@ -491,24 +296,12 @@ GLModel::InitializationData circular_arrow(int resolution, float radius, float t
|
||||
entity.indices.emplace_back(v2);
|
||||
entity.indices.emplace_back(v3);
|
||||
};
|
||||
#else
|
||||
GLModelInitializationData circular_arrow(int resolution, float radius, float tip_height, float tip_width, float stem_width, float thickness)
|
||||
{
|
||||
auto append_vertex = [](GLModelInitializationData& data, const Vec3f& position, const Vec3f& normal) {
|
||||
data.positions.emplace_back(position);
|
||||
data.normals.emplace_back(normal);
|
||||
};
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
resolution = std::max(2, resolution);
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
GLModel::InitializationData data;
|
||||
GLModel::InitializationData::Entity entity;
|
||||
entity.type = GLModel::PrimitiveType::Triangles;
|
||||
#else
|
||||
GLModelInitializationData data;
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
const float half_thickness = 0.5f * thickness;
|
||||
const float half_stem_width = 0.5f * stem_width;
|
||||
@ -518,7 +311,6 @@ GLModelInitializationData circular_arrow(int resolution, float radius, float tip
|
||||
const float inner_radius = radius - half_stem_width;
|
||||
const float step_angle = 0.5f * PI / static_cast<float>(resolution);
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
// tip
|
||||
// top face vertices
|
||||
append_vertex(entity, { 0.0f, outer_radius, half_thickness }, Vec3f::UnitZ());
|
||||
@ -664,156 +456,9 @@ GLModelInitializationData circular_arrow(int resolution, float radius, float tip
|
||||
}
|
||||
|
||||
data.entities.emplace_back(entity);
|
||||
#else
|
||||
// tip
|
||||
// top face vertices
|
||||
append_vertex(data, { 0.0f, outer_radius, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(data, { 0.0f, radius + half_tip_width, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(data, { -tip_height, radius, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(data, { 0.0f, radius - half_tip_width, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(data, { 0.0f, inner_radius, half_thickness }, Vec3f::UnitZ());
|
||||
|
||||
// top face triangles
|
||||
data.triangles.emplace_back(0, 1, 2);
|
||||
data.triangles.emplace_back(0, 2, 4);
|
||||
data.triangles.emplace_back(4, 2, 3);
|
||||
|
||||
// bottom face vertices
|
||||
append_vertex(data, { 0.0f, outer_radius, -half_thickness }, -Vec3f::UnitZ());
|
||||
append_vertex(data, { 0.0f, radius + half_tip_width, -half_thickness }, -Vec3f::UnitZ());
|
||||
append_vertex(data, { -tip_height, radius, -half_thickness }, -Vec3f::UnitZ());
|
||||
append_vertex(data, { 0.0f, radius - half_tip_width, -half_thickness }, -Vec3f::UnitZ());
|
||||
append_vertex(data, { 0.0f, inner_radius, -half_thickness }, -Vec3f::UnitZ());
|
||||
|
||||
// bottom face triangles
|
||||
data.triangles.emplace_back(5, 7, 6);
|
||||
data.triangles.emplace_back(5, 9, 7);
|
||||
data.triangles.emplace_back(9, 8, 7);
|
||||
|
||||
// side faces vertices
|
||||
append_vertex(data, { 0.0f, outer_radius, -half_thickness }, Vec3f::UnitX());
|
||||
append_vertex(data, { 0.0f, radius + half_tip_width, -half_thickness }, Vec3f::UnitX());
|
||||
append_vertex(data, { 0.0f, outer_radius, half_thickness }, Vec3f::UnitX());
|
||||
append_vertex(data, { 0.0f, radius + half_tip_width, half_thickness }, Vec3f::UnitX());
|
||||
|
||||
Vec3f normal(-half_tip_width, tip_height, 0.0f);
|
||||
normal.normalize();
|
||||
append_vertex(data, { 0.0f, radius + half_tip_width, -half_thickness }, normal);
|
||||
append_vertex(data, { -tip_height, radius, -half_thickness }, normal);
|
||||
append_vertex(data, { 0.0f, radius + half_tip_width, half_thickness }, normal);
|
||||
append_vertex(data, { -tip_height, radius, half_thickness }, normal);
|
||||
|
||||
normal = Vec3f(-half_tip_width, -tip_height, 0.0f);
|
||||
normal.normalize();
|
||||
append_vertex(data, { -tip_height, radius, -half_thickness }, normal);
|
||||
append_vertex(data, { 0.0f, radius - half_tip_width, -half_thickness }, normal);
|
||||
append_vertex(data, { -tip_height, radius, half_thickness }, normal);
|
||||
append_vertex(data, { 0.0f, radius - half_tip_width, half_thickness }, normal);
|
||||
|
||||
append_vertex(data, { 0.0f, radius - half_tip_width, -half_thickness }, Vec3f::UnitX());
|
||||
append_vertex(data, { 0.0f, inner_radius, -half_thickness }, Vec3f::UnitX());
|
||||
append_vertex(data, { 0.0f, radius - half_tip_width, half_thickness }, Vec3f::UnitX());
|
||||
append_vertex(data, { 0.0f, inner_radius, half_thickness }, Vec3f::UnitX());
|
||||
|
||||
// side face triangles
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
int ii = i * 4;
|
||||
data.triangles.emplace_back(10 + ii, 11 + ii, 13 + ii);
|
||||
data.triangles.emplace_back(10 + ii, 13 + ii, 12 + ii);
|
||||
}
|
||||
|
||||
// stem
|
||||
// top face vertices
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
float angle = static_cast<float>(i) * step_angle;
|
||||
append_vertex(data, { inner_radius * ::sin(angle), inner_radius * ::cos(angle), half_thickness }, Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
float angle = static_cast<float>(i) * step_angle;
|
||||
append_vertex(data, { outer_radius * ::sin(angle), outer_radius * ::cos(angle), half_thickness }, Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
// top face triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
data.triangles.emplace_back(26 + i, 27 + i, 27 + resolution + i);
|
||||
data.triangles.emplace_back(27 + i, 28 + resolution + i, 27 + resolution + i);
|
||||
}
|
||||
|
||||
// bottom face vertices
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
float angle = static_cast<float>(i) * step_angle;
|
||||
append_vertex(data, { inner_radius * ::sin(angle), inner_radius * ::cos(angle), -half_thickness }, -Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
float angle = static_cast<float>(i) * step_angle;
|
||||
append_vertex(data, { outer_radius * ::sin(angle), outer_radius * ::cos(angle), -half_thickness }, -Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
// bottom face triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
data.triangles.emplace_back(28 + 2 * resolution + i, 29 + 3 * resolution + i, 29 + 2 * resolution + i);
|
||||
data.triangles.emplace_back(29 + 2 * resolution + i, 29 + 3 * resolution + i, 30 + 3 * resolution + i);
|
||||
}
|
||||
|
||||
// side faces vertices and triangles
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
float angle = static_cast<float>(i) * step_angle;
|
||||
float c = ::cos(angle);
|
||||
float s = ::sin(angle);
|
||||
append_vertex(data, { inner_radius * s, inner_radius * c, -half_thickness }, { -s, -c, 0.0f });
|
||||
}
|
||||
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
float angle = static_cast<float>(i) * step_angle;
|
||||
float c = ::cos(angle);
|
||||
float s = ::sin(angle);
|
||||
append_vertex(data, { inner_radius * s, inner_radius * c, half_thickness }, { -s, -c, 0.0f });
|
||||
}
|
||||
|
||||
int first_id = 26 + 4 * (resolution + 1);
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
int ii = first_id + i;
|
||||
data.triangles.emplace_back(ii, ii + 1, ii + resolution + 2);
|
||||
data.triangles.emplace_back(ii, ii + resolution + 2, ii + resolution + 1);
|
||||
}
|
||||
|
||||
append_vertex(data, { inner_radius, 0.0f, -half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { outer_radius, 0.0f, -half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { inner_radius, 0.0f, half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { outer_radius, 0.0f, half_thickness }, -Vec3f::UnitY());
|
||||
|
||||
first_id = 26 + 6 * (resolution + 1);
|
||||
data.triangles.emplace_back(first_id, first_id + 1, first_id + 3);
|
||||
data.triangles.emplace_back(first_id, first_id + 3, first_id + 2);
|
||||
|
||||
for (int i = resolution; i >= 0; --i) {
|
||||
float angle = static_cast<float>(i) * step_angle;
|
||||
float c = ::cos(angle);
|
||||
float s = ::sin(angle);
|
||||
append_vertex(data, { outer_radius * s, outer_radius * c, -half_thickness }, { s, c, 0.0f });
|
||||
}
|
||||
|
||||
for (int i = resolution; i >= 0; --i) {
|
||||
float angle = static_cast<float>(i) * step_angle;
|
||||
float c = ::cos(angle);
|
||||
float s = ::sin(angle);
|
||||
append_vertex(data, { outer_radius * s, outer_radius * c, +half_thickness }, { s, c, 0.0f });
|
||||
}
|
||||
|
||||
first_id = 30 + 6 * (resolution + 1);
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
int ii = first_id + i;
|
||||
data.triangles.emplace_back(ii, ii + 1, ii + resolution + 2);
|
||||
data.triangles.emplace_back(ii, ii + resolution + 2, ii + resolution + 1);
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
GLModel::InitializationData straight_arrow(float tip_width, float tip_height, float stem_width, float stem_height, float thickness)
|
||||
{
|
||||
auto append_vertex = [](GLModel::InitializationData::Entity& entity, const Vec3f& position, const Vec3f& normal) {
|
||||
@ -829,16 +474,6 @@ GLModel::InitializationData straight_arrow(float tip_width, float tip_height, fl
|
||||
GLModel::InitializationData data;
|
||||
GLModel::InitializationData::Entity entity;
|
||||
entity.type = GLModel::PrimitiveType::Triangles;
|
||||
#else
|
||||
GLModelInitializationData straight_arrow(float tip_width, float tip_height, float stem_width, float stem_height, float thickness)
|
||||
{
|
||||
auto append_vertex = [](GLModelInitializationData& data, const Vec3f& position, const Vec3f& normal) {
|
||||
data.positions.emplace_back(position);
|
||||
data.normals.emplace_back(normal);
|
||||
};
|
||||
|
||||
GLModelInitializationData data;
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
const float half_thickness = 0.5f * thickness;
|
||||
const float half_stem_width = 0.5f * stem_width;
|
||||
@ -846,7 +481,6 @@ GLModelInitializationData straight_arrow(float tip_width, float tip_height, floa
|
||||
const float total_height = tip_height + stem_height;
|
||||
|
||||
// top face vertices
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
append_vertex(entity, { half_stem_width, 0.0, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(entity, { half_stem_width, stem_height, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(entity, { half_tip_width, stem_height, half_thickness }, Vec3f::UnitZ());
|
||||
@ -926,86 +560,6 @@ GLModelInitializationData straight_arrow(float tip_width, float tip_height, floa
|
||||
}
|
||||
|
||||
data.entities.emplace_back(entity);
|
||||
#else
|
||||
append_vertex(data, { half_stem_width, 0.0, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(data, { half_stem_width, stem_height, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(data, { half_tip_width, stem_height, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(data, { 0.0, total_height, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(data, { -half_tip_width, stem_height, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(data, { -half_stem_width, stem_height, half_thickness }, Vec3f::UnitZ());
|
||||
append_vertex(data, { -half_stem_width, 0.0, half_thickness }, Vec3f::UnitZ());
|
||||
|
||||
// top face triangles
|
||||
data.triangles.emplace_back(0, 1, 6);
|
||||
data.triangles.emplace_back(6, 1, 5);
|
||||
data.triangles.emplace_back(4, 5, 3);
|
||||
data.triangles.emplace_back(5, 1, 3);
|
||||
data.triangles.emplace_back(1, 2, 3);
|
||||
|
||||
// bottom face vertices
|
||||
append_vertex(data, { half_stem_width, 0.0, -half_thickness }, -Vec3f::UnitZ());
|
||||
append_vertex(data, { half_stem_width, stem_height, -half_thickness }, -Vec3f::UnitZ());
|
||||
append_vertex(data, { half_tip_width, stem_height, -half_thickness }, -Vec3f::UnitZ());
|
||||
append_vertex(data, { 0.0, total_height, -half_thickness }, -Vec3f::UnitZ());
|
||||
append_vertex(data, { -half_tip_width, stem_height, -half_thickness }, -Vec3f::UnitZ());
|
||||
append_vertex(data, { -half_stem_width, stem_height, -half_thickness }, -Vec3f::UnitZ());
|
||||
append_vertex(data, { -half_stem_width, 0.0, -half_thickness }, -Vec3f::UnitZ());
|
||||
|
||||
// bottom face triangles
|
||||
data.triangles.emplace_back(7, 13, 8);
|
||||
data.triangles.emplace_back(13, 12, 8);
|
||||
data.triangles.emplace_back(12, 11, 10);
|
||||
data.triangles.emplace_back(8, 12, 10);
|
||||
data.triangles.emplace_back(9, 8, 10);
|
||||
|
||||
// side faces vertices
|
||||
append_vertex(data, { half_stem_width, 0.0, -half_thickness }, Vec3f::UnitX());
|
||||
append_vertex(data, { half_stem_width, stem_height, -half_thickness }, Vec3f::UnitX());
|
||||
append_vertex(data, { half_stem_width, 0.0, half_thickness }, Vec3f::UnitX());
|
||||
append_vertex(data, { half_stem_width, stem_height, half_thickness }, Vec3f::UnitX());
|
||||
|
||||
append_vertex(data, { half_stem_width, stem_height, -half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { half_tip_width, stem_height, -half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { half_stem_width, stem_height, half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { half_tip_width, stem_height, half_thickness }, -Vec3f::UnitY());
|
||||
|
||||
Vec3f normal(tip_height, half_tip_width, 0.0f);
|
||||
normal.normalize();
|
||||
append_vertex(data, { half_tip_width, stem_height, -half_thickness }, normal);
|
||||
append_vertex(data, { 0.0, total_height, -half_thickness }, normal);
|
||||
append_vertex(data, { half_tip_width, stem_height, half_thickness }, normal);
|
||||
append_vertex(data, { 0.0, total_height, half_thickness }, normal);
|
||||
|
||||
normal = Vec3f(-tip_height, half_tip_width, 0.0f);
|
||||
normal.normalize();
|
||||
append_vertex(data, { 0.0, total_height, -half_thickness }, normal);
|
||||
append_vertex(data, { -half_tip_width, stem_height, -half_thickness }, normal);
|
||||
append_vertex(data, { 0.0, total_height, half_thickness }, normal);
|
||||
append_vertex(data, { -half_tip_width, stem_height, half_thickness }, normal);
|
||||
|
||||
append_vertex(data, { -half_tip_width, stem_height, -half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { -half_stem_width, stem_height, -half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { -half_tip_width, stem_height, half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { -half_stem_width, stem_height, half_thickness }, -Vec3f::UnitY());
|
||||
|
||||
append_vertex(data, { -half_stem_width, stem_height, -half_thickness }, -Vec3f::UnitX());
|
||||
append_vertex(data, { -half_stem_width, 0.0, -half_thickness }, -Vec3f::UnitX());
|
||||
append_vertex(data, { -half_stem_width, stem_height, half_thickness }, -Vec3f::UnitX());
|
||||
append_vertex(data, { -half_stem_width, 0.0, half_thickness }, -Vec3f::UnitX());
|
||||
|
||||
append_vertex(data, { -half_stem_width, 0.0, -half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { half_stem_width, 0.0, -half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { -half_stem_width, 0.0, half_thickness }, -Vec3f::UnitY());
|
||||
append_vertex(data, { half_stem_width, 0.0, half_thickness }, -Vec3f::UnitY());
|
||||
|
||||
// side face triangles
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
int ii = i * 4;
|
||||
data.triangles.emplace_back(14 + ii, 15 + ii, 17 + ii);
|
||||
data.triangles.emplace_back(14 + ii, 17 + ii, 16 + ii);
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -12,18 +12,8 @@ class TriangleMesh;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
#if !ENABLE_SEQUENTIAL_LIMITS
|
||||
struct GLModelInitializationData
|
||||
{
|
||||
std::vector<Vec3f> positions;
|
||||
std::vector<Vec3f> normals;
|
||||
std::vector<Vec3i> triangles;
|
||||
};
|
||||
#endif // !ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
class GLModel
|
||||
{
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
public:
|
||||
enum class PrimitiveType : unsigned char
|
||||
{
|
||||
@ -58,11 +48,6 @@ namespace GUI {
|
||||
|
||||
private:
|
||||
std::vector<RenderData> m_render_data;
|
||||
#else
|
||||
unsigned int m_vbo_id{ 0 };
|
||||
unsigned int m_ibo_id{ 0 };
|
||||
size_t m_indices_count{ 0 };
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
BoundingBoxf3 m_bounding_box;
|
||||
std::string m_filename;
|
||||
@ -71,38 +56,25 @@ namespace GUI {
|
||||
GLModel() = default;
|
||||
virtual ~GLModel() { reset(); }
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void init_from(const InitializationData& data);
|
||||
#else
|
||||
void init_from(const GLModelInitializationData& data);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
void init_from(const TriangleMesh& mesh);
|
||||
bool init_from_file(const std::string& filename);
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
// if entity_id == -1 set the color of all entities
|
||||
void set_color(int entity_id, const std::array<float, 4>& color);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
void reset();
|
||||
void render() const;
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
bool is_initialized() const { return !m_render_data.empty(); }
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
const BoundingBoxf3& get_bounding_box() const { return m_bounding_box; }
|
||||
const std::string& get_filename() const { return m_filename; }
|
||||
|
||||
private:
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void send_to_gpu(RenderData& data, const std::vector<float>& vertices, const std::vector<unsigned int>& indices);
|
||||
#else
|
||||
void send_to_gpu(const std::vector<float>& vertices, const std::vector<unsigned int>& indices);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
};
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
// create an arrow with cylindrical stem and conical tip, with the given dimensions and resolution
|
||||
// the origin of the arrow is in the center of the stem cap
|
||||
// the arrow has its axis of symmetry along the Z axis and is pointing upward
|
||||
@ -120,22 +92,6 @@ namespace GUI {
|
||||
// the arrow is contained in XY plane and has its main axis along the Y axis
|
||||
// used to render sidebar hints for position and scale
|
||||
GLModel::InitializationData straight_arrow(float tip_width, float tip_height, float stem_width, float stem_height, float thickness);
|
||||
#else
|
||||
// create an arrow with cylindrical stem and conical tip, with the given dimensions and resolution
|
||||
// the origin of the arrow is in the center of the stem cap
|
||||
// the arrow has its axis of symmetry along the Z axis and is pointing upward
|
||||
GLModelInitializationData stilized_arrow(int resolution, float tip_radius, float tip_height, float stem_radius, float stem_height);
|
||||
|
||||
// create an arrow whose stem is a quarter of circle, with the given dimensions and resolution
|
||||
// the origin of the arrow is in the center of the circle
|
||||
// the arrow is contained in the 1st quadrant of the XY plane and is pointing counterclockwise
|
||||
GLModelInitializationData circular_arrow(int resolution, float radius, float tip_height, float tip_width, float stem_width, float thickness);
|
||||
|
||||
// create an arrow with the given dimensions
|
||||
// the origin of the arrow is in the center of the stem cap
|
||||
// the arrow is contained in XY plane and has its main axis along the Y axis
|
||||
GLModelInitializationData straight_arrow(float tip_width, float tip_height, float stem_width, float stem_height, float thickness);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
@ -50,6 +50,10 @@ std::pair<bool, std::string> GLShadersManager::init()
|
||||
);
|
||||
// used to render variable layers heights in 3d editor
|
||||
valid &= append_shader("variable_layer_height", { "variable_layer_height.vs", "variable_layer_height.fs" });
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
// used to render volumes during picking pass
|
||||
valid &= append_shader("picking", { "picking.vs", "picking.fs" });
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
|
||||
return { valid, error };
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "format.hpp"
|
||||
#include "I18N.hpp"
|
||||
|
||||
#include "libslic3r/LocalesUtils.hpp"
|
||||
@ -199,9 +200,9 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (const std::exception & /* e */)
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
// int i = 0;//no reason, just experiment
|
||||
wxLogError(format_wxstr(_L("Internal error when changing value for %1%: %2%"), opt_key, e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1413,7 +1413,7 @@ void ObjectList::load_part(ModelObject& model_object, std::vector<ModelVolume*>&
|
||||
|
||||
if (from_galery) {
|
||||
GalleryDialog dlg(this);
|
||||
if (dlg.ShowModal() == wxID_CANCEL)
|
||||
if (dlg.ShowModal() == wxID_CLOSE)
|
||||
return;
|
||||
dlg.get_input_files(input_files);
|
||||
if (input_files.IsEmpty())
|
||||
@ -1472,7 +1472,7 @@ void ObjectList::load_modifier(ModelObject& model_object, std::vector<ModelVolum
|
||||
|
||||
if (from_galery) {
|
||||
GalleryDialog dlg(this);
|
||||
if (dlg.ShowModal() == wxID_CANCEL)
|
||||
if (dlg.ShowModal() == wxID_CLOSE)
|
||||
return;
|
||||
dlg.get_input_files(input_files);
|
||||
if (input_files.IsEmpty())
|
||||
@ -1684,18 +1684,22 @@ void ObjectList::load_shape_object_from_gallery()
|
||||
|
||||
wxArrayString input_files;
|
||||
GalleryDialog gallery_dlg(this);
|
||||
if (gallery_dlg.ShowModal() == wxID_CANCEL)
|
||||
if (gallery_dlg.ShowModal() == wxID_CLOSE)
|
||||
return;
|
||||
gallery_dlg.get_input_files(input_files);
|
||||
if (input_files.IsEmpty())
|
||||
return;
|
||||
load_shape_object_from_gallery(input_files);
|
||||
}
|
||||
|
||||
void ObjectList::load_shape_object_from_gallery(const wxArrayString& input_files)
|
||||
{
|
||||
std::vector<boost::filesystem::path> paths;
|
||||
for (const auto& file : input_files)
|
||||
paths.push_back(into_path(file));
|
||||
|
||||
assert(!paths.empty());
|
||||
wxString snapshot_label = (paths.size() == 1 ? _L("Add Shape") : _L("Add Shapes")) + ": " +
|
||||
wxString snapshot_label = (paths.size() == 1 ? _L("Add Shape from Gallery") : _L("Add Shapes from Gallery")) + ": " +
|
||||
wxString::FromUTF8(paths.front().filename().string().c_str());
|
||||
for (size_t i = 1; i < paths.size(); ++i)
|
||||
snapshot_label += ", " + wxString::FromUTF8(paths[i].filename().string().c_str());
|
||||
|
@ -245,6 +245,7 @@ public:
|
||||
void load_generic_subobject(const std::string& type_name, const ModelVolumeType type);
|
||||
void load_shape_object(const std::string &type_name);
|
||||
void load_shape_object_from_gallery();
|
||||
void load_shape_object_from_gallery(const wxArrayString& input_files);
|
||||
void load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center = true);
|
||||
void del_object(const int obj_idx);
|
||||
void del_subobject_item(wxDataViewItem& item);
|
||||
|
@ -64,7 +64,7 @@ bool GalleryDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& f
|
||||
}
|
||||
|
||||
|
||||
GalleryDialog::GalleryDialog(wxWindow* parent) :
|
||||
GalleryDialog::GalleryDialog(wxWindow* parent, bool modify_gallery/* = false*/) :
|
||||
DPIDialog(parent, wxID_ANY, _L("Shapes Gallery"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
@ -90,9 +90,13 @@ GalleryDialog::GalleryDialog(wxWindow* parent) :
|
||||
});
|
||||
#endif
|
||||
|
||||
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
|
||||
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxOK | wxCLOSE);
|
||||
wxButton* ok_btn = static_cast<wxButton*>(FindWindowById(wxID_OK, this));
|
||||
ok_btn->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(!m_selected_items.empty()); });
|
||||
if (modify_gallery) {
|
||||
ok_btn->SetLabel(_L("Add to bed"));
|
||||
ok_btn->SetToolTip(_L("Add selected shape(s) to the bed"));
|
||||
}
|
||||
|
||||
auto add_btn = [this, buttons]( size_t pos, int& ID, wxString title, wxString tooltip,
|
||||
void (GalleryDialog::* method)(wxEvent&),
|
||||
@ -144,7 +148,7 @@ void GalleryDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
{
|
||||
const int& em = em_unit();
|
||||
|
||||
msw_buttons_rescale(this, em, { ID_BTN_ADD_CUSTOM_SHAPE, ID_BTN_DEL_CUSTOM_SHAPE, ID_BTN_REPLACE_CUSTOM_PNG, wxID_OK, wxID_CANCEL });
|
||||
msw_buttons_rescale(this, em, { ID_BTN_ADD_CUSTOM_SHAPE, ID_BTN_DEL_CUSTOM_SHAPE, ID_BTN_REPLACE_CUSTOM_PNG, wxID_OK, wxID_CLOSE });
|
||||
|
||||
wxSize size = wxSize(55 * em, 35 * em);
|
||||
m_list_ctrl->SetMinSize(size);
|
||||
|
@ -41,7 +41,7 @@ class GalleryDialog : public DPIDialog
|
||||
void update();
|
||||
|
||||
public:
|
||||
GalleryDialog(wxWindow* parent);
|
||||
GalleryDialog(wxWindow* parent, bool modify_gallery = false);
|
||||
~GalleryDialog();
|
||||
|
||||
void get_input_files(wxArrayString& input_files);
|
||||
|
@ -63,11 +63,7 @@ void GLGizmoBase::Grabber::render(float size, const std::array<float, 4>& render
|
||||
|
||||
GLShaderProgram* shader = picking ? nullptr : wxGetApp().get_current_shader();
|
||||
if (shader != nullptr)
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
const_cast<GLModel*>(&cube)->set_color(-1, render_color);
|
||||
#else
|
||||
shader->set_uniform("uniform_color", render_color);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
else
|
||||
glsafe(::glColor4fv(render_color.data())); // picking
|
||||
|
||||
|
@ -150,11 +150,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons
|
||||
}
|
||||
|
||||
if (shader && ! picking)
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
const_cast<GLModel*>(&m_vbo_cylinder)->set_color(-1 , render_color);
|
||||
#else
|
||||
shader->set_uniform("uniform_color", render_color);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
else // picking
|
||||
glsafe(::glColor4fv(render_color.data()));
|
||||
|
||||
|
@ -208,11 +208,7 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
||||
if (! picking) {
|
||||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.1);
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
const_cast<GLModel*>(&m_vbo_cone)->set_color(-1, color);
|
||||
#else
|
||||
shader->set_uniform("uniform_color", color);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
} else
|
||||
glsafe(::glColor4fv(color.data()));
|
||||
|
||||
|
@ -339,12 +339,9 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
||||
if (! picking) {
|
||||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.1);
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
const_cast<GLModel*>(&m_cone)->set_color(-1, color);
|
||||
#else
|
||||
shader->set_uniform("uniform_color", color);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
} else
|
||||
}
|
||||
else
|
||||
glsafe(::glColor4fv(color.data()));
|
||||
|
||||
glsafe(::glPushMatrix());
|
||||
|
@ -167,12 +167,8 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
||||
}
|
||||
}
|
||||
if (shader && ! picking) {
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
const_cast<GLModel*>(&m_cone)->set_color(-1, render_color);
|
||||
const_cast<GLModel*>(&m_sphere)->set_color(-1, render_color);
|
||||
#else
|
||||
shader->set_uniform("uniform_color", render_color);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
shader->set_uniform("emission_factor", 0.5);
|
||||
}
|
||||
else // picking
|
||||
@ -231,11 +227,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
||||
render_color[2] = 0.7f;
|
||||
render_color[3] = 0.7f;
|
||||
if (shader) {
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
const_cast<GLModel*>(&m_cylinder)->set_color(-1, render_color);
|
||||
#else
|
||||
shader->set_uniform("uniform_color", render_color);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
shader->set_uniform("emission_factor", 0.5);
|
||||
}
|
||||
for (const sla::DrainHole& drain_hole : m_c->selection_info()->model_object()->sla_drain_holes) {
|
||||
|
@ -644,10 +644,8 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
||||
selection.start_dragging();
|
||||
start_dragging();
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
// Let the plater know that the dragging started
|
||||
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED));
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
if (m_current == Flatten) {
|
||||
// Rotate the object so the normal points downward:
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include "MsgDialog.hpp"
|
||||
#include "Notebook.hpp"
|
||||
#include "GUI_Factories.hpp"
|
||||
#include "GUI_ObjectList.hpp"
|
||||
#include "GalleryDialog.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <dbt.h>
|
||||
@ -1394,6 +1396,18 @@ void MainFrame::init_menubar_as_editor()
|
||||
[this](){return can_change_view(); }, this);
|
||||
}
|
||||
|
||||
windowMenu->AppendSeparator();
|
||||
append_menu_item(windowMenu, wxID_ANY, _L("Modify Shapes Gallery") + "\tCtrl+G", _L("Open the dialog to modify shapes gallery"),
|
||||
[this](wxCommandEvent&) {
|
||||
GalleryDialog dlg(this, true);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
wxArrayString input_files;
|
||||
dlg.get_input_files(input_files);
|
||||
if (!input_files.IsEmpty())
|
||||
m_plater->sidebar().obj_list()->load_shape_object_from_gallery(input_files);
|
||||
}
|
||||
}, "cog", nullptr, []() {return true; }, this);
|
||||
|
||||
windowMenu->AppendSeparator();
|
||||
append_menu_item(windowMenu, wxID_ANY, _L("Print &Host Upload Queue") + "\tCtrl+J", _L("Display the Print Host Upload Queue window"),
|
||||
[this](wxCommandEvent&) { m_printhost_queue_dlg->Show(); }, "upload_queue", nullptr, []() {return true; }, this);
|
||||
|
@ -904,7 +904,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
|
||||
case coPoints:
|
||||
if (opt_key == "bed_shape")
|
||||
ret = config.option<ConfigOptionPoints>(opt_key)->values;
|
||||
if (opt_key == "thumbnails")
|
||||
else if (opt_key == "thumbnails")
|
||||
ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
|
||||
else
|
||||
ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx);
|
||||
|
@ -1760,9 +1760,7 @@ struct Plater::priv
|
||||
void on_wipetower_moved(Vec3dEvent&);
|
||||
void on_wipetower_rotated(Vec3dEvent&);
|
||||
void on_update_geometry(Vec3dsEvent<2>&);
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void on_3dcanvas_mouse_dragging_started(SimpleEvent&);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
void on_3dcanvas_mouse_dragging_finished(SimpleEvent&);
|
||||
|
||||
void show_action_buttons(const bool is_ready_to_slice) const;
|
||||
@ -1941,9 +1939,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||
view3D_canvas->Bind(EVT_GLCANVAS_INSTANCE_SCALED, [this](SimpleEvent&) { update(); });
|
||||
view3D_canvas->Bind(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, [this](Event<bool>& evt) { this->sidebar->enable_buttons(evt.data); });
|
||||
view3D_canvas->Bind(EVT_GLCANVAS_UPDATE_GEOMETRY, &priv::on_update_geometry, this);
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
view3D_canvas->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED, &priv::on_3dcanvas_mouse_dragging_started, this);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
view3D_canvas->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, &priv::on_3dcanvas_mouse_dragging_finished, this);
|
||||
view3D_canvas->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); });
|
||||
view3D_canvas->Bind(EVT_GLCANVAS_RESETGIZMOS, [this](SimpleEvent&) { reset_all_gizmos(); });
|
||||
@ -2814,9 +2810,7 @@ void Plater::priv::reset()
|
||||
reset_gcode_toolpaths();
|
||||
gcode_result.reset();
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
view3D->get_canvas3d()->reset_sequential_print_clearance();
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
// Stop and reset the Print content.
|
||||
this->background_process.reset();
|
||||
@ -3025,19 +3019,17 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
||||
// Pass a warning from validation and either show a notification,
|
||||
// or hide the old one.
|
||||
process_validation_warning(warning);
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (printer_technology == ptFFF) {
|
||||
view3D->get_canvas3d()->reset_sequential_print_clearance();
|
||||
view3D->get_canvas3d()->set_as_dirty();
|
||||
view3D->get_canvas3d()->request_extra_frame();
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// The print is not valid.
|
||||
// Show error as notification.
|
||||
notification_manager->push_slicing_error_notification(err);
|
||||
return_state |= UPDATE_BACKGROUND_PROCESS_INVALID;
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (printer_technology == ptFFF) {
|
||||
const Print* print = background_process.fff_print();
|
||||
Polygons polygons;
|
||||
@ -3047,10 +3039,9 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
||||
view3D->get_canvas3d()->set_sequential_print_clearance_render_fill(true);
|
||||
view3D->get_canvas3d()->set_sequential_print_clearance_polygons(polygons);
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
}
|
||||
|
||||
} else if (! this->delayed_error_message.empty()) {
|
||||
}
|
||||
else if (! this->delayed_error_message.empty()) {
|
||||
// Reusing the old state.
|
||||
return_state |= UPDATE_BACKGROUND_PROCESS_INVALID;
|
||||
}
|
||||
@ -4031,12 +4022,10 @@ void Plater::priv::on_update_geometry(Vec3dsEvent<2>&)
|
||||
// TODO
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
void Plater::priv::on_3dcanvas_mouse_dragging_started(SimpleEvent&)
|
||||
{
|
||||
view3D->get_canvas3d()->reset_sequential_print_clearance();
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
// Update the scene from the background processing,
|
||||
// if the update message was received during mouse manipulation.
|
||||
|
@ -1820,16 +1820,13 @@ void Selection::render_bounding_box(const BoundingBoxf3& box, float* color) cons
|
||||
glsafe(::glEnd());
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
static std::array<float, 4> get_color(Axis axis)
|
||||
{
|
||||
return { AXES_COLOR[axis][0], AXES_COLOR[axis][1], AXES_COLOR[axis][2], AXES_COLOR[axis][3] };
|
||||
};
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
void Selection::render_sidebar_position_hints(const std::string& sidebar_field) const
|
||||
{
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (boost::ends_with(sidebar_field, "x")) {
|
||||
glsafe(::glRotated(-90.0, 0.0, 0.0, 1.0));
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, get_color(X));
|
||||
@ -1844,33 +1841,10 @@ void Selection::render_sidebar_position_hints(const std::string& sidebar_field)
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, get_color(Z));
|
||||
m_arrow.render();
|
||||
}
|
||||
#else
|
||||
auto set_color = [](Axis axis) {
|
||||
GLShaderProgram* shader = wxGetApp().get_current_shader();
|
||||
if (shader != nullptr) {
|
||||
shader->set_uniform("uniform_color", AXES_COLOR[axis]);
|
||||
shader->set_uniform("emission_factor", 0.0);
|
||||
}
|
||||
};
|
||||
|
||||
if (boost::ends_with(sidebar_field, "x")) {
|
||||
set_color(X);
|
||||
glsafe(::glRotated(-90.0, 0.0, 0.0, 1.0));
|
||||
m_arrow.render();
|
||||
} else if (boost::ends_with(sidebar_field, "y")) {
|
||||
set_color(Y);
|
||||
m_arrow.render();
|
||||
} else if (boost::ends_with(sidebar_field, "z")) {
|
||||
set_color(Z);
|
||||
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
|
||||
m_arrow.render();
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
}
|
||||
|
||||
void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field) const
|
||||
{
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
auto render_sidebar_rotation_hint = [this]() {
|
||||
m_curved_arrow.render();
|
||||
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
|
||||
@ -1891,34 +1865,6 @@ void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field)
|
||||
const_cast<GLModel*>(&m_curved_arrow)->set_color(-1, get_color(Z));
|
||||
render_sidebar_rotation_hint();
|
||||
}
|
||||
#else
|
||||
auto set_color = [](Axis axis) {
|
||||
GLShaderProgram* shader = wxGetApp().get_current_shader();
|
||||
if (shader != nullptr) {
|
||||
shader->set_uniform("uniform_color", AXES_COLOR[axis]);
|
||||
shader->set_uniform("emission_factor", 0.0);
|
||||
}
|
||||
};
|
||||
|
||||
auto render_sidebar_rotation_hint = [this]() {
|
||||
m_curved_arrow.render();
|
||||
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
|
||||
m_curved_arrow.render();
|
||||
};
|
||||
|
||||
if (boost::ends_with(sidebar_field, "x")) {
|
||||
set_color(X);
|
||||
glsafe(::glRotated(90.0, 0.0, 1.0, 0.0));
|
||||
render_sidebar_rotation_hint();
|
||||
} else if (boost::ends_with(sidebar_field, "y")) {
|
||||
set_color(Y);
|
||||
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
|
||||
render_sidebar_rotation_hint();
|
||||
} else if (boost::ends_with(sidebar_field, "z")) {
|
||||
set_color(Z);
|
||||
render_sidebar_rotation_hint();
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
}
|
||||
|
||||
void Selection::render_sidebar_scale_hints(const std::string& sidebar_field) const
|
||||
@ -1926,9 +1872,7 @@ void Selection::render_sidebar_scale_hints(const std::string& sidebar_field) con
|
||||
bool uniform_scale = requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling();
|
||||
|
||||
auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis) {
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
const_cast<GLModel*>(&m_arrow)->set_color(-1, uniform_scale ? UNIFORM_SCALE_COLOR : get_color(axis));
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
GLShaderProgram* shader = wxGetApp().get_current_shader();
|
||||
if (shader != nullptr)
|
||||
shader->set_uniform("emission_factor", 0.0);
|
||||
|
Loading…
Reference in New Issue
Block a user