Merge remote-tracking branch 'origin/master' into ys_bug_fixing
This commit is contained in:
commit
144b9e1e9d
21 changed files with 1101 additions and 908 deletions
|
@ -321,7 +321,7 @@ include_directories(${GLEW_INCLUDE_DIRS})
|
|||
# l10n
|
||||
set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/localization")
|
||||
add_custom_target(pot
|
||||
COMMAND xgettext --keyword=L --from-code=UTF-8 --debug
|
||||
COMMAND xgettext --keyword=L --add-comments=TRN --from-code=UTF-8 --debug
|
||||
-f "${L10N_DIR}/list.txt"
|
||||
-o "${L10N_DIR}/Slic3rPE.pot"
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
|
|
|
@ -46,7 +46,7 @@ https://github.com/prusa3d/Slic3r/tree/master/resources/localization/list.txt.
|
|||
|
||||
2. Create template file(*.POT) with GNUgettext command:
|
||||
```
|
||||
xgettext --keyword=L --from-code=UTF-8 --debug -o Slic3rPE.pot -f list.txt
|
||||
xgettext --keyword=L --add-comments=TRN --from-code=UTF-8 --debug -o Slic3rPE.pot -f list.txt
|
||||
```
|
||||
|
||||
Use flag `--from-code=UTF-8` to specify that the source strings are in UTF-8 encoding
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -943,7 +943,7 @@ BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_
|
|||
// Calculate 2D convex hull of of a projection of the transformed printable volumes into the XY plane.
|
||||
// This method is cheap in that it does not make any unnecessary copy of the volume meshes.
|
||||
// This method is used by the auto arrange function.
|
||||
Polygon ModelObject::convex_hull_2d(const Transform3d &trafo_instance)
|
||||
Polygon ModelObject::convex_hull_2d(const Transform3d &trafo_instance) const
|
||||
{
|
||||
Points pts;
|
||||
for (const ModelVolume *v : this->volumes)
|
||||
|
|
|
@ -234,7 +234,7 @@ public:
|
|||
// Calculate 2D convex hull of of a projection of the transformed printable volumes into the XY plane.
|
||||
// This method is cheap in that it does not make any unnecessary copy of the volume meshes.
|
||||
// This method is used by the auto arrange function.
|
||||
Polygon convex_hull_2d(const Transform3d &trafo_instance);
|
||||
Polygon convex_hull_2d(const Transform3d &trafo_instance) const;
|
||||
|
||||
#if ENABLE_VOLUMES_CENTERING_FIXES
|
||||
void center_around_origin(bool include_modifiers = true);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "ModelArrange.hpp"
|
||||
#include "Model.hpp"
|
||||
#include "Geometry.hpp"
|
||||
#include "SVG.hpp"
|
||||
|
||||
#include <libnest2d.h>
|
||||
|
@ -551,7 +552,7 @@ ShapeData2D projectModelFromTop(const Slic3r::Model &model) {
|
|||
ret.reserve(s);
|
||||
|
||||
for(ModelObject* objptr : model.objects) {
|
||||
if(objptr) {
|
||||
if (! objptr->instances.empty()) {
|
||||
|
||||
// TODO export the exact 2D projection. Cannot do it as libnest2d
|
||||
// does not support concave shapes (yet).
|
||||
|
@ -572,23 +573,23 @@ ShapeData2D projectModelFromTop(const Slic3r::Model &model) {
|
|||
clpath = Slic3rMultiPoint_to_ClipperPath(p);
|
||||
}
|
||||
|
||||
Vec3d rotation0 = objptr->instances.front()->get_rotation();
|
||||
rotation0(2) = 0.;
|
||||
for(ModelInstance* objinst : objptr->instances) {
|
||||
if(objinst) {
|
||||
ClipperLib::Polygon pn;
|
||||
pn.Contour = clpath;
|
||||
ClipperLib::Polygon pn;
|
||||
pn.Contour = clpath;
|
||||
|
||||
// Efficient conversion to item.
|
||||
Item item(std::move(pn));
|
||||
// Efficient conversion to item.
|
||||
Item item(std::move(pn));
|
||||
|
||||
// Invalid geometries would throw exceptions when arranging
|
||||
if(item.vertexCount() > 3) {
|
||||
item.rotation(objinst->get_rotation(Z));
|
||||
item.translation({
|
||||
ClipperLib::cInt(objinst->get_offset(X)/SCALING_FACTOR),
|
||||
ClipperLib::cInt(objinst->get_offset(Y)/SCALING_FACTOR)
|
||||
});
|
||||
ret.emplace_back(objinst, item);
|
||||
}
|
||||
// Invalid geometries would throw exceptions when arranging
|
||||
if(item.vertexCount() > 3) {
|
||||
item.rotation(float(Geometry::rotation_diff_z(rotation0, objinst->get_rotation()))),
|
||||
item.translation({
|
||||
ClipperLib::cInt(objinst->get_offset(X)/SCALING_FACTOR),
|
||||
ClipperLib::cInt(objinst->get_offset(Y)/SCALING_FACTOR)
|
||||
});
|
||||
ret.emplace_back(objinst, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1139,31 +1139,29 @@ std::string Print::validate() const
|
|||
// Check horizontal clearance.
|
||||
{
|
||||
Polygons convex_hulls_other;
|
||||
for (const PrintObject *object : m_objects) {
|
||||
for (const PrintObject *print_object : m_objects) {
|
||||
assert(! print_object->model_object()->instances.empty());
|
||||
assert(! print_object->copies().empty());
|
||||
// Get convex hull of all meshes assigned to this print object.
|
||||
Polygon convex_hull;
|
||||
{
|
||||
Polygons mesh_convex_hulls;
|
||||
for (const std::vector<int> &volumes : object->region_volumes)
|
||||
for (int volume_id : volumes)
|
||||
mesh_convex_hulls.emplace_back(object->model_object()->volumes[volume_id]->mesh.convex_hull());
|
||||
// make a single convex hull for all of them
|
||||
convex_hull = Slic3r::Geometry::convex_hull(mesh_convex_hulls);
|
||||
}
|
||||
// Apply the same transformations we apply to the actual meshes when slicing them.
|
||||
object->model_object()->instances.front()->transform_polygon(&convex_hull);
|
||||
ModelInstance *model_instance0 = print_object->model_object()->instances.front();
|
||||
Vec3d rotation = model_instance0->get_rotation();
|
||||
rotation.z() = 0.;
|
||||
// Calculate the convex hull of a printable object centered around X=0,Y=0.
|
||||
// Grow convex hull with the clearance margin.
|
||||
// FIXME: Arrangement has different parameters for offsetting (jtMiter, limit 2)
|
||||
// which causes that the warning will be showed after arrangement with the
|
||||
// appropriate object distance. Even if I set this to jtMiter the warning still shows up.
|
||||
convex_hull = offset(convex_hull, scale_(m_config.extruder_clearance_radius.value)/2, jtRound, scale_(0.1)).front();
|
||||
Polygon convex_hull0 = offset(
|
||||
print_object->model_object()->convex_hull_2d(
|
||||
Geometry::assemble_transform(Vec3d::Zero(), rotation, model_instance0->get_scaling_factor(), model_instance0->get_mirror())),
|
||||
scale_(m_config.extruder_clearance_radius.value) / 2., jtRound, scale_(0.1)).front();
|
||||
// Now we check that no instance of convex_hull intersects any of the previously checked object instances.
|
||||
for (const Point © : object->m_copies) {
|
||||
Polygon p = convex_hull;
|
||||
p.translate(copy);
|
||||
if (! intersection(convex_hulls_other, p).empty())
|
||||
for (const Point © : print_object->m_copies) {
|
||||
Polygon convex_hull = convex_hull0;
|
||||
convex_hull.translate(copy);
|
||||
if (! intersection(convex_hulls_other, convex_hull).empty())
|
||||
return L("Some objects are too close; your extruder will collide with them.");
|
||||
polygons_append(convex_hulls_other, p);
|
||||
polygons_append(convex_hulls_other, convex_hull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2926,7 +2926,7 @@ CLIActionsConfigDef::CLIActionsConfigDef()
|
|||
|
||||
// Actions:
|
||||
def = this->add("export_obj", coBool);
|
||||
def->label = L("Export SVG");
|
||||
def->label = L("Export OBJ");
|
||||
def->tooltip = L("Export the model(s) as OBJ.");
|
||||
def->default_value = new ConfigOptionBool(false);
|
||||
|
||||
|
|
|
@ -598,8 +598,9 @@ std::string SLAPrint::validate() const
|
|||
for(SLAPrintObject * po : m_objects) {
|
||||
|
||||
const ModelObject *mo = po->model_object();
|
||||
bool supports_en = po->config().supports_enable.getBool();
|
||||
|
||||
if(po->config().supports_enable.getBool() &&
|
||||
if(supports_en &&
|
||||
mo->sla_points_status == sla::PointsStatus::UserModified &&
|
||||
mo->sla_support_points.empty())
|
||||
return L("Cannot proceed without support points! "
|
||||
|
@ -613,7 +614,7 @@ std::string SLAPrint::validate() const
|
|||
2 * cfg.head_back_radius_mm -
|
||||
cfg.head_penetration_mm;
|
||||
|
||||
if(pinhead_width > cfg.object_elevation_mm)
|
||||
if(supports_en && pinhead_width > cfg.object_elevation_mm)
|
||||
return L("Elevation is too low for object.");
|
||||
}
|
||||
|
||||
|
@ -696,6 +697,7 @@ void SLAPrint::process()
|
|||
po.closest_slice_record(po.m_slice_index, float(bb3d.min(Z)));
|
||||
|
||||
if(slindex_it == po.m_slice_index.end())
|
||||
//TRN To be shown at the status bar on SLA slicing error.
|
||||
throw std::runtime_error(L("Slicing had to be stopped "
|
||||
"due to an internal error."));
|
||||
|
||||
|
|
|
@ -160,17 +160,13 @@ PrintObjectSupportMaterial::PrintObjectSupportMaterial(const PrintObject *object
|
|||
m_support_material_interface_flow = m_support_material_flow;
|
||||
}
|
||||
|
||||
// Evaluate the XY gap between the object outer perimeters and the support structures.
|
||||
// Evaluate the XY gap between the object outer perimeters and the support structures.
|
||||
coordf_t external_perimeter_width = 0.;
|
||||
for (size_t region_id = 0; region_id < object->region_volumes.size(); ++ region_id) {
|
||||
if (! object->region_volumes[region_id].empty()) {
|
||||
const PrintRegionConfig &config = object->print()->get_region(region_id)->config();
|
||||
coordf_t width = config.external_perimeter_extrusion_width.get_abs_value(slicing_params.layer_height);
|
||||
if (width <= 0.)
|
||||
width = m_print_config->nozzle_diameter.get_at(config.perimeter_extruder-1);
|
||||
external_perimeter_width = std::max(external_perimeter_width, width);
|
||||
}
|
||||
}
|
||||
for (size_t region_id = 0; region_id < object->region_volumes.size(); ++ region_id)
|
||||
if (! object->region_volumes[region_id].empty())
|
||||
external_perimeter_width = std::max(external_perimeter_width,
|
||||
(coordf_t)object->print()->get_region(region_id)->flow(frExternalPerimeter, slicing_params.layer_height, false, false, -1, *object).width);
|
||||
m_gap_xy = m_object_config->support_material_xy_spacing.get_abs_value(external_perimeter_width);
|
||||
|
||||
m_can_merge_support_regions = m_object_config->support_material_extruder.value == m_object_config->support_material_interface_extruder.value;
|
||||
|
|
|
@ -635,6 +635,7 @@ void PageTemperatures::apply_custom_config(DynamicPrintConfig &config)
|
|||
|
||||
ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent)
|
||||
: wxPanel(parent)
|
||||
// XXX: use create_scaled_bitmap:
|
||||
, bg(GUI::from_u8(Slic3r::var("Slic3r_192px_transparent.png")), wxBITMAP_TYPE_PNG)
|
||||
, bullet_black(GUI::from_u8(Slic3r::var("bullet_black.png")), wxBITMAP_TYPE_PNG)
|
||||
, bullet_blue(GUI::from_u8(Slic3r::var("bullet_blue.png")), wxBITMAP_TYPE_PNG)
|
||||
|
@ -769,6 +770,8 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
|
|||
const int yoff_text = bullet_h > em_h ? (bullet_h - em_h) / 2 : 0;
|
||||
const int yinc = item_height();
|
||||
|
||||
int index_width = 0;
|
||||
|
||||
unsigned y = 0;
|
||||
for (size_t i = 0; i < items.size(); i++) {
|
||||
const Item& item = items[i];
|
||||
|
@ -780,8 +783,18 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
|
|||
else if (i < item_active) { dc.DrawBitmap(bullet_black, x, y + yoff_icon, false); }
|
||||
else if (i > item_active) { dc.DrawBitmap(bullet_white, x, y + yoff_icon, false); }
|
||||
|
||||
dc.DrawText(item.label, x + bullet_w + em/2, y + yoff_text);
|
||||
x += + bullet_w + em/2;
|
||||
const auto text_size = dc.GetTextExtent(item.label);
|
||||
dc.DrawText(item.label, x, y + yoff_text);
|
||||
|
||||
y += yinc;
|
||||
index_width = std::max(index_width, (int)x + text_size.x);
|
||||
}
|
||||
|
||||
if (GetMinSize().x < index_width) {
|
||||
CallAfter([this, index_width]() {
|
||||
SetMinSize(wxSize(index_width, GetMinSize().y));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,7 @@ void Field::PostInitialize()
|
|||
m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_sys_value(); }));
|
||||
|
||||
//set default bitmap
|
||||
wxBitmap bmp;
|
||||
bmp.LoadFile(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG);
|
||||
wxBitmap bmp = create_scaled_bitmap(m_parent, "bullet_white.png");
|
||||
set_undo_bitmap(&bmp);
|
||||
set_undo_to_sys_bitmap(&bmp);
|
||||
|
||||
|
|
|
@ -2374,6 +2374,10 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
|
|||
}
|
||||
}
|
||||
|
||||
// Inform gizmos about the event so they have the opportunity to react.
|
||||
if (m_gizmos.on_mouse_wheel(evt, *this))
|
||||
return;
|
||||
|
||||
// Calculate the zoom delta and apply it to the current zoom factor
|
||||
float zoom = (float)evt.GetWheelRotation() / (float)evt.GetWheelDelta();
|
||||
set_camera_zoom(zoom);
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "../Utils/PresetUpdater.hpp"
|
||||
#include "../Utils/PrintHost.hpp"
|
||||
#include "ConfigWizard_private.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
#include "slic3r/Config/Snapshot.hpp"
|
||||
#include "ConfigSnapshotDialog.hpp"
|
||||
#include "FirmwareDialog.hpp"
|
||||
|
@ -230,7 +230,7 @@ bool GUI_App::on_init_inner()
|
|||
// and after MainFrame is created & shown.
|
||||
// The extra CallAfter() is needed because of Mac, where this is the only way
|
||||
// to popup a modal dialog on start without screwing combo boxes.
|
||||
// This is ugly but I honestly found not better way to do it.
|
||||
// This is ugly but I honestly found no better way to do it.
|
||||
// Neither wxShowEvent nor wxWindowCreateEvent work reliably.
|
||||
static bool once = true;
|
||||
if (once) {
|
||||
|
|
|
@ -5,8 +5,11 @@
|
|||
#include <GL/glew.h>
|
||||
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/stattext.h>
|
||||
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectSettings.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||
#include "slic3r/GUI/PresetBundle.hpp"
|
||||
|
@ -92,28 +95,29 @@ void GLGizmoSlaSupports::on_render(const Selection& selection) const
|
|||
glsafe(::glEnable(GL_BLEND));
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
// we'll recover current look direction from the modelview matrix (in world coords):
|
||||
Eigen::Matrix<double, 4, 4, Eigen::DontAlign> modelview_matrix;
|
||||
::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data());
|
||||
Vec3d direction_to_camera(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]);
|
||||
m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z();
|
||||
|
||||
if (m_quadric != nullptr && selection.is_from_single_instance())
|
||||
render_points(selection, direction_to_camera, false);
|
||||
render_points(selection, false);
|
||||
|
||||
render_selection_rectangle();
|
||||
render_clipping_plane(selection, direction_to_camera);
|
||||
render_clipping_plane(selection);
|
||||
|
||||
glsafe(::glDisable(GL_BLEND));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const Vec3d& direction_to_camera) const
|
||||
void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection) const
|
||||
{
|
||||
if (m_clipping_plane_distance == 0.f)
|
||||
return;
|
||||
|
||||
if (m_clipping_plane_normal == Vec3d::Zero())
|
||||
reset_clipping_plane_normal();
|
||||
|
||||
const Vec3d& direction_to_camera = m_clipping_plane_normal;
|
||||
|
||||
// First cache instance transformation to be used later.
|
||||
const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
Transform3f instance_matrix = vol->get_instance_transformation().get_matrix().cast<float>();
|
||||
|
@ -137,9 +141,9 @@ void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const
|
|||
// In case either of these was recently changed, the cached triangulated ExPolygons are invalid now.
|
||||
// We are gonna recalculate them both for the object and for the support structures.
|
||||
if (m_clipping_plane_distance != m_old_clipping_plane_distance
|
||||
|| m_old_direction_to_camera != direction_to_camera) {
|
||||
|| m_old_clipping_plane_normal != direction_to_camera) {
|
||||
|
||||
m_old_direction_to_camera = direction_to_camera;
|
||||
m_old_clipping_plane_normal = direction_to_camera;
|
||||
m_old_clipping_plane_distance = m_clipping_plane_distance;
|
||||
|
||||
// Now initialize the TMS for the object, perform the cut and save the result.
|
||||
|
@ -198,8 +202,6 @@ void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const
|
|||
}
|
||||
|
||||
// At this point we have the triangulated cuts for both the object and supports - let's render.
|
||||
::glColor3f(1.0f, 0.37f, 0.0f);
|
||||
|
||||
if (! m_triangles.empty()) {
|
||||
::glPushMatrix();
|
||||
::glTranslated(0.0, 0.0, m_z_shift);
|
||||
|
@ -208,7 +210,8 @@ void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const
|
|||
q.setFromTwoVectors(Vec3f::UnitZ(), up);
|
||||
Eigen::AngleAxisf aa(q);
|
||||
::glRotatef(aa.angle() * (180./M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2));
|
||||
::glTranslatef(0.f, 0.f, -0.001f); // to make sure the cut is safely beyond the near clipping plane
|
||||
::glTranslatef(0.f, 0.f, 0.01f); // to make sure the cut does not intersect the structure itself
|
||||
::glColor3f(1.0f, 0.37f, 0.0f);
|
||||
::glBegin(GL_TRIANGLES);
|
||||
for (const Vec2f& point : m_triangles)
|
||||
::glVertex3f(point(0), point(1), height_mesh);
|
||||
|
@ -217,14 +220,16 @@ void GLGizmoSlaSupports::render_clipping_plane(const Selection& selection, const
|
|||
::glPopMatrix();
|
||||
}
|
||||
|
||||
if (! m_supports_triangles.empty()) {
|
||||
if (! m_supports_triangles.empty() && !m_editing_mode) {
|
||||
// The supports are hidden in the editing mode, so it makes no sense to render the cuts.
|
||||
::glPushMatrix();
|
||||
::glMultMatrixd(supports_trafo.data());
|
||||
Eigen::Quaternionf q;
|
||||
q.setFromTwoVectors(Vec3f::UnitZ(), up_supports);
|
||||
Eigen::AngleAxisf aa(q);
|
||||
::glRotatef(aa.angle() * (180./M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2));
|
||||
::glTranslatef(0.f, 0.f, -0.001f); // to make sure the cut is safely beyond the near clipping plane
|
||||
::glTranslatef(0.f, 0.f, 0.01f);
|
||||
::glColor3f(1.0f, 0.f, 0.37f);
|
||||
::glBegin(GL_TRIANGLES);
|
||||
for (const Vec2f& point : m_supports_triangles)
|
||||
::glVertex3f(point(0), point(1), height_supports);
|
||||
|
@ -284,16 +289,10 @@ void GLGizmoSlaSupports::render_selection_rectangle() const
|
|||
void GLGizmoSlaSupports::on_render_for_picking(const Selection& selection) const
|
||||
{
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
// we'll recover current look direction from the modelview matrix (in world coords):
|
||||
Eigen::Matrix<double, 4, 4, Eigen::DontAlign> modelview_matrix;
|
||||
::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data());
|
||||
Vec3d direction_to_camera(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]);
|
||||
|
||||
render_points(selection, direction_to_camera, true);
|
||||
render_points(selection, true);
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::render_points(const Selection& selection, const Vec3d& direction_to_camera, bool picking) const
|
||||
void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) const
|
||||
{
|
||||
if (!picking)
|
||||
glsafe(::glEnable(GL_LIGHTING));
|
||||
|
@ -312,7 +311,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, const Vec3d&
|
|||
const sla::SupportPoint& support_point = m_editing_mode_cache[i].support_point;
|
||||
const bool& point_selected = m_editing_mode_cache[i].selected;
|
||||
|
||||
if (is_point_clipped(support_point.pos.cast<double>(), direction_to_camera))
|
||||
if (is_point_clipped(support_point.pos.cast<double>()))
|
||||
continue;
|
||||
|
||||
// First decide about the color of the point.
|
||||
|
@ -386,8 +385,10 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, const Vec3d&
|
|||
|
||||
|
||||
|
||||
bool GLGizmoSlaSupports::is_point_clipped(const Vec3d& point, const Vec3d& direction_to_camera) const
|
||||
bool GLGizmoSlaSupports::is_point_clipped(const Vec3d& point) const
|
||||
{
|
||||
const Vec3d& direction_to_camera = m_clipping_plane_normal;
|
||||
|
||||
if (m_clipping_plane_distance == 0.f)
|
||||
return false;
|
||||
|
||||
|
@ -457,9 +458,6 @@ std::pair<Vec3f, Vec3f> GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse
|
|||
const Selection& selection = m_parent.get_selection();
|
||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
|
||||
// we'll recover current look direction from the modelview matrix (in world coords):
|
||||
Vec3d direction_to_camera(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]);
|
||||
|
||||
point1(2) -= m_z_shift;
|
||||
point2(2) -= m_z_shift;
|
||||
|
||||
|
@ -486,7 +484,7 @@ std::pair<Vec3f, Vec3f> GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse
|
|||
a = (m_V.row(m_F(fid, 1)) - m_V.row(m_F(fid, 0)));
|
||||
b = (m_V.row(m_F(fid, 2)) - m_V.row(m_F(fid, 0)));
|
||||
result = bc(0) * m_V.row(m_F(fid, 0)) + bc(1) * m_V.row(m_F(fid, 1)) + bc(2)*m_V.row(m_F(fid, 2));
|
||||
if (m_clipping_plane_distance == 0.f || !is_point_clipped(result.cast<double>(), direction_to_camera))
|
||||
if (m_clipping_plane_distance == 0.f || !is_point_clipped(result.cast<double>()))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -591,7 +589,7 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
::gluProject((GLdouble)pos(0), (GLdouble)pos(1), (GLdouble)pos(2), (GLdouble*)modelview_matrix.data(), (GLdouble*)projection_matrix.data(), (GLint*)viewport.data(), &out_x, &out_y, &out_z);
|
||||
out_y = m_canvas_height - out_y;
|
||||
|
||||
if (rectangle.contains(Point(out_x, out_y)) && !is_point_clipped(support_point.pos.cast<double>(), direction_to_camera.cast<double>())) {
|
||||
if (rectangle.contains(Point(out_x, out_y)) && !is_point_clipped(support_point.pos.cast<double>())) {
|
||||
bool is_obscured = false;
|
||||
// Cast a ray in the direction of the camera and look for intersection with the mesh:
|
||||
std::vector<igl::Hit> hits;
|
||||
|
@ -615,7 +613,7 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
|
||||
Vec3f bc = Vec3f(1-hit.u-hit.v, hit.u, hit.v); // barycentric coordinates of the hit
|
||||
Vec3f hit_pos = bc(0) * m_V.row(m_F(fid, 0)) + bc(1) * m_V.row(m_F(fid, 1)) + bc(2)*m_V.row(m_F(fid, 2));
|
||||
if (is_point_clipped(hit_pos.cast<double>(), direction_to_camera.cast<double>())) {
|
||||
if (is_point_clipped(hit_pos.cast<double>())) {
|
||||
hits.erase(hits.begin()+j);
|
||||
--j;
|
||||
}
|
||||
|
@ -707,6 +705,23 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
}
|
||||
}
|
||||
|
||||
if (action == SLAGizmoEventType::MouseWheelUp && control_down) {
|
||||
m_clipping_plane_distance = std::min(1.f, m_clipping_plane_distance + 0.01f);
|
||||
m_parent.set_as_dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == SLAGizmoEventType::MouseWheelDown && control_down) {
|
||||
m_clipping_plane_distance = std::max(0.f, m_clipping_plane_distance - 0.01f);
|
||||
m_parent.set_as_dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == SLAGizmoEventType::ResetClippingPlane) {
|
||||
reset_clipping_plane_normal();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -790,11 +805,12 @@ ClippingPlane GLGizmoSlaSupports::get_sla_clipping_plane() const
|
|||
if (!m_model_object || m_state == Off)
|
||||
return ClippingPlane::ClipsNothing();
|
||||
|
||||
Eigen::Matrix<GLdouble, 4, 4, Eigen::DontAlign> modelview_matrix;
|
||||
::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data());
|
||||
|
||||
//Eigen::Matrix<GLdouble, 4, 4, Eigen::DontAlign> modelview_matrix;
|
||||
//::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data());
|
||||
// we'll recover current look direction from the modelview matrix (in world coords):
|
||||
Vec3d direction_to_camera(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]);
|
||||
//Vec3d direction_to_camera(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]);
|
||||
|
||||
const Vec3d& direction_to_camera = m_clipping_plane_normal;
|
||||
float dist = direction_to_camera.dot(m_model_object->instances[m_active_instance]->get_offset() + Vec3d(0., 0., m_z_shift));
|
||||
|
||||
return ClippingPlane(-direction_to_camera.normalized(),(dist - (-m_active_instance_bb_radius) - m_clipping_plane_distance * 2*m_active_instance_bb_radius));
|
||||
|
@ -850,33 +866,32 @@ void GLGizmoSlaSupports::on_render_input_window(float x, float y, float bottom_l
|
|||
bool first_run = true; // This is a hack to redraw the button when all points are removed,
|
||||
// so it is not delayed until the background process finishes.
|
||||
RENDER_AGAIN:
|
||||
//m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
||||
//const ImVec2 window_size(m_imgui->scaled(18.f, 16.f));
|
||||
//ImGui::SetNextWindowPos(ImVec2(x, y - std::max(0.f, y+window_size.y-bottom_limit) ));
|
||||
//ImGui::SetNextWindowSize(ImVec2(window_size));
|
||||
|
||||
const float approx_height = m_imgui->scaled(18.0f);
|
||||
y = std::min(y, bottom_limit - approx_height);
|
||||
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
||||
|
||||
const ImVec2 window_size(m_imgui->scaled(17.f, 20.f));
|
||||
ImGui::SetNextWindowPos(ImVec2(x, y - std::max(0.f, y+window_size.y-bottom_limit) ));
|
||||
ImGui::SetNextWindowSize(ImVec2(window_size));
|
||||
|
||||
m_imgui->set_next_window_bg_alpha(0.5f);
|
||||
m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
ImGui::PushItemWidth(100.0f);
|
||||
ImGui::PushItemWidth(m_imgui->scaled(5.55f));
|
||||
|
||||
bool force_refresh = false;
|
||||
bool remove_selected = false;
|
||||
bool remove_all = false;
|
||||
|
||||
if (m_editing_mode) {
|
||||
m_imgui->text(_(L("Left mouse click - add point")));
|
||||
m_imgui->text(_(L("Right mouse click - remove point")));
|
||||
m_imgui->text(_(L("Shift + Left (+ drag) - select point(s)")));
|
||||
m_imgui->text(" "); // vertical gap
|
||||
|
||||
float diameter_upper_cap = static_cast<ConfigOptionFloat*>(wxGetApp().preset_bundle->sla_prints.get_edited_preset().config.option("support_pillar_diameter"))->value;
|
||||
if (m_new_point_head_diameter > diameter_upper_cap)
|
||||
m_new_point_head_diameter = diameter_upper_cap;
|
||||
|
||||
m_imgui->text(_(L("Head diameter: ")));
|
||||
ImGui::SameLine();
|
||||
ImGui::SameLine(m_imgui->scaled(6.66f));
|
||||
ImGui::PushItemWidth(m_imgui->scaled(8.33f));
|
||||
if (ImGui::SliderFloat("", &m_new_point_head_diameter, 0.1f, diameter_upper_cap, "%.1f")) {
|
||||
// value was changed
|
||||
for (auto& cache_entry : m_editing_mode_cache)
|
||||
|
@ -912,9 +927,9 @@ RENDER_AGAIN:
|
|||
}
|
||||
}
|
||||
else { // not in editing mode:
|
||||
ImGui::PushItemWidth(100.0f);
|
||||
ImGui::PushItemWidth(m_imgui->scaled(5.55f));
|
||||
m_imgui->text(_(L("Minimal points distance: ")));
|
||||
ImGui::SameLine();
|
||||
ImGui::SameLine(m_imgui->scaled(9.44f));
|
||||
|
||||
std::vector<const ConfigOption*> opts = get_config_options({"support_points_density_relative", "support_points_minimal_distance"});
|
||||
float density = static_cast<const ConfigOptionInt*>(opts[0])->value;
|
||||
|
@ -925,7 +940,7 @@ RENDER_AGAIN:
|
|||
m_model_object->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance;
|
||||
|
||||
m_imgui->text(_(L("Support points density: ")));
|
||||
ImGui::SameLine();
|
||||
ImGui::SameLine(m_imgui->scaled(9.44f));
|
||||
if (ImGui::SliderFloat(" ", &density, 0.f, 200.f, "%.f %%")) {
|
||||
value_changed = true;
|
||||
m_model_object->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density;
|
||||
|
@ -938,34 +953,51 @@ RENDER_AGAIN:
|
|||
});
|
||||
}
|
||||
|
||||
bool generate = m_imgui->button(_(L("Auto-generate points [A]")));
|
||||
bool generate = m_imgui->button(_(L("Auto-generate points")));
|
||||
|
||||
if (generate)
|
||||
auto_generate();
|
||||
|
||||
m_imgui->text("");
|
||||
if (m_imgui->button(_(L("Manual editing [M]"))))
|
||||
if (m_imgui->button(_(L("Manual editing"))))
|
||||
switch_to_editing_mode();
|
||||
|
||||
m_imgui->disabled_begin(m_editing_mode_cache.empty());
|
||||
remove_all = m_imgui->button(_(L("Remove all points")));
|
||||
m_imgui->disabled_end();
|
||||
|
||||
m_imgui->text("");
|
||||
|
||||
m_imgui->text(m_model_object->sla_points_status == sla::PointsStatus::None ? "No points (will be autogenerated)" :
|
||||
(m_model_object->sla_points_status == sla::PointsStatus::AutoGenerated ? "Autogenerated points (no modifications)" :
|
||||
(m_model_object->sla_points_status == sla::PointsStatus::UserModified ? "User-modified points" :
|
||||
(m_model_object->sla_points_status == sla::PointsStatus::Generating ? "Generation in progress..." : "UNKNOWN STATUS"))));
|
||||
// m_imgui->text("");
|
||||
// m_imgui->text(m_model_object->sla_points_status == sla::PointsStatus::None ? _(L("No points (will be autogenerated)")) :
|
||||
// (m_model_object->sla_points_status == sla::PointsStatus::AutoGenerated ? _(L("Autogenerated points (no modifications)")) :
|
||||
// (m_model_object->sla_points_status == sla::PointsStatus::UserModified ? _(L("User-modified points")) :
|
||||
// (m_model_object->sla_points_status == sla::PointsStatus::Generating ? _(L("Generation in progress...")) : "UNKNOWN STATUS"))));
|
||||
}
|
||||
|
||||
|
||||
// Following is rendered in both editing and non-editing mode:
|
||||
m_imgui->text("Clipping of view: ");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(150.0f);
|
||||
bool value_changed = ImGui::SliderFloat(" ", &m_clipping_plane_distance, 0.f, 1.f, "%.2f");
|
||||
|
||||
m_imgui->text("");
|
||||
if (m_clipping_plane_distance == 0.f)
|
||||
m_imgui->text("Clipping of view: ");
|
||||
else {
|
||||
if (m_imgui->button(_(L("Reset direction")))) {
|
||||
wxGetApp().CallAfter([this](){
|
||||
reset_clipping_plane_normal();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::SameLine(m_imgui->scaled(6.66f));
|
||||
ImGui::PushItemWidth(m_imgui->scaled(8.33f));
|
||||
ImGui::SliderFloat(" ", &m_clipping_plane_distance, 0.f, 1.f, "%.2f");
|
||||
|
||||
|
||||
if (m_imgui->button("?")) {
|
||||
wxGetApp().CallAfter([]() {
|
||||
SlaGizmoHelpDialog help_dlg;
|
||||
help_dlg.ShowModal();
|
||||
});
|
||||
}
|
||||
|
||||
m_imgui->end();
|
||||
|
||||
if (m_editing_mode != m_old_editing_state) { // user toggled between editing/non-editing mode
|
||||
|
@ -1207,5 +1239,77 @@ void GLGizmoSlaSupports::switch_to_editing_mode()
|
|||
m_editing_mode = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLGizmoSlaSupports::reset_clipping_plane_normal() const
|
||||
{
|
||||
Eigen::Matrix<double, 4, 4, Eigen::DontAlign> modelview_matrix;
|
||||
::glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix.data());
|
||||
m_clipping_plane_normal = Vec3d(modelview_matrix.data()[2], modelview_matrix.data()[6], modelview_matrix.data()[10]);
|
||||
m_parent.set_as_dirty();
|
||||
}
|
||||
|
||||
|
||||
SlaGizmoHelpDialog::SlaGizmoHelpDialog()
|
||||
: wxDialog(NULL, wxID_ANY, _(L("SLA gizmo keyboard shortcuts")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
const std::string &ctrl = GUI::shortkey_ctrl_prefix();
|
||||
const std::string &alt = GUI::shortkey_alt_prefix();
|
||||
|
||||
|
||||
// fonts
|
||||
const wxFont& font = wxGetApp().small_font();
|
||||
const wxFont& bold_font = wxGetApp().bold_font();
|
||||
|
||||
auto note_text = new wxStaticText(this, wxID_ANY, "Note: some shortcuts work in (non)editing mode only.");
|
||||
note_text->SetFont(font);
|
||||
|
||||
auto vsizer = new wxBoxSizer(wxVERTICAL);
|
||||
auto gridsizer = new wxFlexGridSizer(2, 5, 15);
|
||||
auto hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
hsizer->AddSpacer(20);
|
||||
hsizer->Add(vsizer);
|
||||
hsizer->AddSpacer(20);
|
||||
|
||||
vsizer->AddSpacer(20);
|
||||
vsizer->Add(note_text, 1, wxALIGN_CENTRE_HORIZONTAL);
|
||||
vsizer->AddSpacer(20);
|
||||
vsizer->Add(gridsizer);
|
||||
vsizer->AddSpacer(20);
|
||||
|
||||
std::vector<std::pair<std::string, wxString>> shortcuts;
|
||||
shortcuts.push_back(std::make_pair("Left click", _(L("Add point"))));
|
||||
shortcuts.push_back(std::make_pair("Right click", _(L("Remove point"))));
|
||||
shortcuts.push_back(std::make_pair("Drag", _(L("Move point"))));
|
||||
shortcuts.push_back(std::make_pair(ctrl+"Left click", _(L("Add point to selection"))));
|
||||
shortcuts.push_back(std::make_pair(alt+"Left click", _(L("Remove point from selection"))));
|
||||
shortcuts.push_back(std::make_pair("Shift+drag", _(L("Select by rectangle"))));
|
||||
shortcuts.push_back(std::make_pair(alt+"drag", _(L("Deselect by rectangle"))));
|
||||
shortcuts.push_back(std::make_pair(ctrl+"A", _(L("Select all points"))));
|
||||
shortcuts.push_back(std::make_pair("Delete", _(L("Remove selected points"))));
|
||||
shortcuts.push_back(std::make_pair(ctrl+"mouse wheel", _(L("Move clipping plane"))));
|
||||
shortcuts.push_back(std::make_pair("R", _(L("Reset clipping plane"))));
|
||||
shortcuts.push_back(std::make_pair("Enter", _(L("Apply changes"))));
|
||||
shortcuts.push_back(std::make_pair("Esc", _(L("Discard changes"))));
|
||||
shortcuts.push_back(std::make_pair("M", _(L("Switch to editing mode"))));
|
||||
shortcuts.push_back(std::make_pair("A", _(L("Auto-generate points"))));
|
||||
|
||||
for (const auto& pair : shortcuts) {
|
||||
auto shortcut = new wxStaticText(this, wxID_ANY, pair.first);
|
||||
auto desc = new wxStaticText(this, wxID_ANY, pair.second);
|
||||
shortcut->SetFont(bold_font);
|
||||
desc->SetFont(font);
|
||||
gridsizer->Add(shortcut, -1, wxALIGN_CENTRE_VERTICAL);
|
||||
gridsizer->Add(desc, -1, wxALIGN_CENTRE_VERTICAL);
|
||||
}
|
||||
|
||||
SetSizer(hsizer);
|
||||
hsizer->SetSizeHints(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "libslic3r/SLA/SLACommon.hpp"
|
||||
#include "libslic3r/SLAPrint.hpp"
|
||||
#include <wx/dialog.h>
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
@ -73,8 +74,8 @@ private:
|
|||
virtual void on_render_for_picking(const Selection& selection) const;
|
||||
|
||||
void render_selection_rectangle() const;
|
||||
void render_points(const Selection& selection, const Vec3d& direction_to_camera, bool picking = false) const;
|
||||
void render_clipping_plane(const Selection& selection, const Vec3d& direction_to_camera) const;
|
||||
void render_points(const Selection& selection, bool picking = false) const;
|
||||
void render_clipping_plane(const Selection& selection) const;
|
||||
bool is_mesh_update_necessary() const;
|
||||
void update_mesh();
|
||||
void update_cache_entry_normal(unsigned int i) const;
|
||||
|
@ -87,7 +88,8 @@ private:
|
|||
mutable std::vector<CacheEntry> m_editing_mode_cache; // a support point and whether it is currently selected
|
||||
float m_clipping_plane_distance = 0.f;
|
||||
mutable float m_old_clipping_plane_distance = 0.f;
|
||||
mutable Vec3d m_old_direction_to_camera;
|
||||
mutable Vec3d m_old_clipping_plane_normal;
|
||||
mutable Vec3d m_clipping_plane_normal = Vec3d::Zero();
|
||||
|
||||
enum SelectionRectangleStatus {
|
||||
srOff = 0,
|
||||
|
@ -108,8 +110,8 @@ private:
|
|||
mutable std::unique_ptr<TriangleMeshSlicer> m_supports_tms;
|
||||
|
||||
std::vector<const ConfigOption*> get_config_options(const std::vector<std::string>& keys) const;
|
||||
bool is_point_clipped(const Vec3d& point, const Vec3d& direction_to_camera) const;
|
||||
void find_intersecting_facets(const igl::AABB<Eigen::MatrixXf, 3>* aabb, const Vec3f& normal, double offset, std::vector<unsigned int>& out) const;
|
||||
bool is_point_clipped(const Vec3d& point) const;
|
||||
//void find_intersecting_facets(const igl::AABB<Eigen::MatrixXf, 3>* aabb, const Vec3f& normal, double offset, std::vector<unsigned int>& out) const;
|
||||
|
||||
// Methods that do the model_object and editing cache synchronization,
|
||||
// editing mode selection, etc:
|
||||
|
@ -125,6 +127,7 @@ private:
|
|||
void get_data_from_backend();
|
||||
void auto_generate();
|
||||
void switch_to_editing_mode();
|
||||
void reset_clipping_plane_normal() const;
|
||||
|
||||
protected:
|
||||
void on_set_state() override;
|
||||
|
@ -137,6 +140,12 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class SlaGizmoHelpDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
SlaGizmoHelpDialog();
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
|
|
|
@ -14,7 +14,10 @@ enum class SLAGizmoEventType {
|
|||
ApplyChanges,
|
||||
DiscardChanges,
|
||||
AutomaticGeneration,
|
||||
ManualEditing
|
||||
ManualEditing,
|
||||
MouseWheelUp,
|
||||
MouseWheelDown,
|
||||
ResetClippingPlane
|
||||
};
|
||||
|
||||
#include "slic3r/GUI/Gizmos/GLGizmoMove.hpp"
|
||||
|
|
|
@ -520,6 +520,23 @@ void GLGizmosManager::render_overlay(const GLCanvas3D& canvas, const Selection&
|
|||
glsafe(::glPopMatrix());
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GLGizmosManager::on_mouse_wheel(wxMouseEvent& evt, GLCanvas3D& canvas)
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
if (m_current == SlaSupports) {
|
||||
float rot = (float)evt.GetWheelRotation() / (float)evt.GetWheelDelta();
|
||||
if (gizmo_event((rot > 0.f ? SLAGizmoEventType::MouseWheelUp : SLAGizmoEventType::MouseWheelDown), Vec2d::Zero(), evt.ShiftDown(), evt.AltDown(), evt.ControlDown()))
|
||||
processed = true;
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas)
|
||||
{
|
||||
Point pos(evt.GetX(), evt.GetY());
|
||||
|
@ -761,6 +778,16 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas)
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'r' :
|
||||
case 'R' :
|
||||
{
|
||||
if ((m_current == SlaSupports) && gizmo_event(SLAGizmoEventType::ResetClippingPlane))
|
||||
processed = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
case WXK_BACK: // the low cost Apple solutions are not equipped with a Delete key, use Backspace instead.
|
||||
#else /* __APPLE__ */
|
||||
|
@ -794,7 +821,7 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas)
|
|||
}
|
||||
}
|
||||
|
||||
if (!processed)
|
||||
if (!processed && !evt.HasModifiers())
|
||||
{
|
||||
if (handle_shortcut(keyCode, canvas.get_selection()))
|
||||
{
|
||||
|
|
|
@ -157,6 +157,7 @@ public:
|
|||
const std::string& get_tooltip() const { return m_tooltip; }
|
||||
|
||||
bool on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas);
|
||||
bool on_mouse_wheel(wxMouseEvent& evt, GLCanvas3D& canvas);
|
||||
bool on_char(wxKeyEvent& evt, GLCanvas3D& canvas);
|
||||
bool on_key(wxKeyEvent& evt, GLCanvas3D& canvas);
|
||||
|
||||
|
|
|
@ -1169,8 +1169,8 @@ struct Plater::priv
|
|||
wxString project_filename;
|
||||
|
||||
BackgroundSlicingProcess background_process;
|
||||
std::atomic<bool> arranging;
|
||||
std::atomic<bool> rotoptimizing;
|
||||
bool arranging;
|
||||
bool rotoptimizing;
|
||||
bool delayed_scene_refresh;
|
||||
std::string delayed_error_message;
|
||||
|
||||
|
@ -1333,8 +1333,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
, view_toolbar(GLToolbar::Radio)
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
{
|
||||
arranging.store(false);
|
||||
rotoptimizing.store(false);
|
||||
arranging = false;
|
||||
rotoptimizing = false;
|
||||
background_process.set_fff_print(&fff_print);
|
||||
background_process.set_sla_print(&sla_print);
|
||||
background_process.set_gcode_preview_data(&gcode_preview_data);
|
||||
|
@ -2025,15 +2025,14 @@ void Plater::priv::mirror(Axis axis)
|
|||
|
||||
void Plater::priv::arrange()
|
||||
{
|
||||
// don't do anything if currently arranging. Then this is a re-entrance
|
||||
if(arranging.load()) return;
|
||||
|
||||
// Guard the arrange process
|
||||
arranging.store(true);
|
||||
if (arranging) { return; }
|
||||
arranging = true;
|
||||
Slic3r::ScopeGuard arranging_guard([this]() { arranging = false; });
|
||||
|
||||
wxBusyCursor wait;
|
||||
|
||||
this->background_process.stop();
|
||||
|
||||
unsigned count = 0;
|
||||
for(auto obj : model.objects) count += obj->instances.size();
|
||||
|
||||
|
@ -2049,14 +2048,14 @@ void Plater::priv::arrange()
|
|||
statusbar()->set_progress(count - st);
|
||||
statusbar()->set_status_text(msg);
|
||||
|
||||
// ok, this is dangerous, but we are protected by the atomic flag
|
||||
// ok, this is dangerous, but we are protected by the flag
|
||||
// 'arranging' and the arrange button is also disabled.
|
||||
// This call is needed for the cancel button to work.
|
||||
wxYieldIfNeeded();
|
||||
};
|
||||
|
||||
statusbar()->set_cancel_callback([this, statusfn](){
|
||||
arranging.store(false);
|
||||
arranging = false;
|
||||
statusfn(0, L("Arranging canceled"));
|
||||
});
|
||||
|
||||
|
@ -2092,7 +2091,7 @@ void Plater::priv::arrange()
|
|||
hint,
|
||||
false, // create many piles not just one pile
|
||||
[statusfn](unsigned st) { statusfn(st, arrangestr); },
|
||||
[this] () { return !arranging.load(); });
|
||||
[this] () { return !arranging; });
|
||||
} catch(std::exception& /*e*/) {
|
||||
GUI::show_error(this->q, L("Could not arrange model objects! "
|
||||
"Some geometries may be invalid."));
|
||||
|
@ -2101,7 +2100,6 @@ void Plater::priv::arrange()
|
|||
statusfn(0, L("Arranging done."));
|
||||
statusbar()->set_range(prev_range);
|
||||
statusbar()->set_cancel_callback(); // remove cancel button
|
||||
arranging.store(false);
|
||||
|
||||
// Do a full refresh of scene tree, including regenerating all the GLVolumes.
|
||||
//FIXME The update function shall just reload the modified matrices.
|
||||
|
@ -2116,11 +2114,12 @@ void Plater::priv::sla_optimize_rotation() {
|
|||
// running we should probably disable explicit slicing and background
|
||||
// processing
|
||||
|
||||
if(rotoptimizing.load()) return;
|
||||
rotoptimizing.store(true);
|
||||
if (rotoptimizing) { return; }
|
||||
rotoptimizing = true;
|
||||
Slic3r::ScopeGuard rotoptimizing_guard([this]() { rotoptimizing = false; });
|
||||
|
||||
int obj_idx = get_selected_object_idx();
|
||||
if(obj_idx < 0) { rotoptimizing.store(false); return; }
|
||||
if (obj_idx < 0) { return; }
|
||||
|
||||
ModelObject * o = model.objects[size_t(obj_idx)];
|
||||
|
||||
|
@ -2138,14 +2137,14 @@ void Plater::priv::sla_optimize_rotation() {
|
|||
};
|
||||
|
||||
statusbar()->set_cancel_callback([this, stfn](){
|
||||
rotoptimizing.store(false);
|
||||
rotoptimizing = false;
|
||||
stfn(0, L("Orientation search canceled"));
|
||||
});
|
||||
|
||||
auto r = sla::find_best_rotation(
|
||||
*o, .005f,
|
||||
[stfn](unsigned s) { stfn(s, L("Searching for optimal orientation")); },
|
||||
[this](){ return !rotoptimizing.load(); }
|
||||
[this](){ return !rotoptimizing; }
|
||||
);
|
||||
|
||||
const auto *bed_shape_opt = config->opt<ConfigOptionPoints>("bed_shape");
|
||||
|
@ -2158,7 +2157,7 @@ void Plater::priv::sla_optimize_rotation() {
|
|||
double mindist = 6.0; // FIXME
|
||||
double offs = mindist / 2.0 - EPSILON;
|
||||
|
||||
if(rotoptimizing.load()) // wasn't canceled
|
||||
if(rotoptimizing) // wasn't canceled
|
||||
for(ModelInstance * oi : o->instances) {
|
||||
oi->set_rotation({r[X], r[Y], r[Z]});
|
||||
|
||||
|
@ -2208,7 +2207,6 @@ void Plater::priv::sla_optimize_rotation() {
|
|||
stfn(0, L("Orientation found."));
|
||||
statusbar()->set_range(prev_range);
|
||||
statusbar()->set_cancel_callback();
|
||||
rotoptimizing.store(false);
|
||||
|
||||
update(true);
|
||||
}
|
||||
|
@ -2386,6 +2384,11 @@ unsigned int Plater::priv::update_background_process(bool force_validation)
|
|||
// Restart background processing thread based on a bitmask of UpdateBackgroundProcessReturnState.
|
||||
bool Plater::priv::restart_background_process(unsigned int state)
|
||||
{
|
||||
if (arranging || rotoptimizing) {
|
||||
// Avoid a race condition
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! this->background_process.empty() &&
|
||||
(state & priv::UPDATE_BACKGROUND_PROCESS_INVALID) == 0 &&
|
||||
( ((state & UPDATE_BACKGROUND_PROCESS_FORCE_RESTART) != 0 && ! this->background_process.finished()) ||
|
||||
|
@ -2612,6 +2615,11 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
void Plater::priv::on_slicing_update(SlicingStatusEvent &evt)
|
||||
{
|
||||
if (evt.status.percent >= -1) {
|
||||
if (arranging || rotoptimizing) {
|
||||
// Avoid a race condition
|
||||
return;
|
||||
}
|
||||
|
||||
this->statusbar()->set_progress(evt.status.percent);
|
||||
this->statusbar()->set_status_text(_(L(evt.status.text)) + wxString::FromUTF8("…"));
|
||||
}
|
||||
|
@ -3069,12 +3077,20 @@ bool Plater::priv::can_delete_all() const
|
|||
|
||||
bool Plater::priv::can_increase_instances() const
|
||||
{
|
||||
if (arranging || rotoptimizing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int obj_idx = get_selected_object_idx();
|
||||
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size());
|
||||
}
|
||||
|
||||
bool Plater::priv::can_decrease_instances() const
|
||||
{
|
||||
if (arranging || rotoptimizing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int obj_idx = get_selected_object_idx();
|
||||
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && (model.objects[obj_idx]->instances.size() > 1);
|
||||
}
|
||||
|
@ -3091,7 +3107,7 @@ bool Plater::priv::can_split_to_volumes() const
|
|||
|
||||
bool Plater::priv::can_arrange() const
|
||||
{
|
||||
return !model.objects.empty() && !arranging.load();
|
||||
return !model.objects.empty() && !arranging;
|
||||
}
|
||||
|
||||
bool Plater::priv::can_layers_editing() const
|
||||
|
@ -3232,9 +3248,9 @@ void Plater::remove_selected()
|
|||
|
||||
void Plater::increase_instances(size_t num)
|
||||
{
|
||||
if (! can_increase_instances()) { return; }
|
||||
|
||||
int obj_idx = p->get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
||||
ModelObject* model_object = p->model.objects[obj_idx];
|
||||
ModelInstance* model_instance = model_object->instances.back();
|
||||
|
@ -3266,9 +3282,9 @@ void Plater::increase_instances(size_t num)
|
|||
|
||||
void Plater::decrease_instances(size_t num)
|
||||
{
|
||||
if (! can_decrease_instances()) { return; }
|
||||
|
||||
int obj_idx = p->get_selected_object_idx();
|
||||
if (obj_idx == -1)
|
||||
return;
|
||||
|
||||
ModelObject* model_object = p->model.objects[obj_idx];
|
||||
if (model_object->instances.size() > num) {
|
||||
|
|
|
@ -27,7 +27,7 @@ static const std::string CONFIG_UPDATE_WIKI_URL("https://github.com/prusa3d/Slic
|
|||
// MsgUpdateSlic3r
|
||||
|
||||
MsgUpdateSlic3r::MsgUpdateSlic3r(const Semver &ver_current, const Semver &ver_online) :
|
||||
MsgDialog(nullptr, _(L("Update available")), wxString::Format(_(L("New version of % is available")), SLIC3R_APP_NAME)),
|
||||
MsgDialog(nullptr, _(L("Update available")), wxString::Format(_(L("New version of %s is available")), SLIC3R_APP_NAME)),
|
||||
ver_current(ver_current),
|
||||
ver_online(ver_online)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue