mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 00:31:11 -06:00
Merge branch 'master' of https://github.com/prusa3d/Slic3r into et_canvas_gui_refactoring
This commit is contained in:
commit
000542f48d
16 changed files with 362 additions and 313 deletions
|
@ -3948,24 +3948,27 @@ void GLCanvas3D::_render_sla_slices() const
|
|||
instance_transforms.push_back({ to_3d(unscale(inst.shift), 0.), Geometry::rad2deg(inst.rotation) });
|
||||
}
|
||||
|
||||
if ((bottom_obj_triangles.empty() || bottom_sup_triangles.empty() || top_obj_triangles.empty() || top_sup_triangles.empty()) && obj->is_step_done(slaposIndexSlices))
|
||||
if ((bottom_obj_triangles.empty() || bottom_sup_triangles.empty() || top_obj_triangles.empty() || top_sup_triangles.empty()) &&
|
||||
obj->is_step_done(slaposIndexSlices) && !obj->get_slice_index().empty())
|
||||
{
|
||||
double layer_height = print->default_object_config().layer_height.value;
|
||||
double initial_layer_height = print->material_config().initial_layer_height.value;
|
||||
LevelID key_zero = obj->get_slice_records().begin()->key();
|
||||
// Slice at the center of the slab starting at clip_min_z will be rendered for the lower plane.
|
||||
LevelID key_low = LevelID((clip_min_z - initial_layer_height + layer_height) / SCALING_FACTOR) + key_zero;
|
||||
// Slice at the center of the slab ending at clip_max_z will be rendered for the upper plane.
|
||||
LevelID key_high = LevelID((clip_max_z - initial_layer_height) / SCALING_FACTOR) + key_zero;
|
||||
auto slice_range = obj->get_slice_records(key_low - LevelID(SCALED_EPSILON), key_high - LevelID(SCALED_EPSILON));
|
||||
auto it_low = slice_range.begin();
|
||||
auto it_high = std::prev(slice_range.end());
|
||||
// Offset to avoid OpenGL Z fighting between the object's horizontal surfaces and the triangluated surfaces of the cuts.
|
||||
double plane_shift_z = 0.002f;
|
||||
|
||||
if (! it_low.is_end() && it_low->key() < key_low + LevelID(SCALED_EPSILON)) {
|
||||
const ExPolygons& obj_bottom = obj->get_slices_from_record(it_low, soModel);
|
||||
const ExPolygons& sup_bottom = obj->get_slices_from_record(it_low, soSupport);
|
||||
coord_t key_zero = obj->get_slice_index().front().print_level();
|
||||
// Slice at the center of the slab starting at clip_min_z will be rendered for the lower plane.
|
||||
coord_t key_low = coord_t((clip_min_z - initial_layer_height + layer_height) / SCALING_FACTOR) + key_zero;
|
||||
// Slice at the center of the slab ending at clip_max_z will be rendered for the upper plane.
|
||||
coord_t key_high = coord_t((clip_max_z - initial_layer_height) / SCALING_FACTOR) + key_zero;
|
||||
|
||||
const SliceRecord& slice_low = obj->closest_slice_to_print_level(key_low, coord_t(SCALED_EPSILON));
|
||||
const SliceRecord& slice_high = obj->closest_slice_to_print_level(key_high, coord_t(SCALED_EPSILON));
|
||||
|
||||
// Offset to avoid OpenGL Z fighting between the object's horizontal surfaces and the triangluated surfaces of the cuts.
|
||||
double plane_shift_z = 0.002;
|
||||
|
||||
if (slice_low.is_valid()) {
|
||||
const ExPolygons& obj_bottom = slice_low.get_slice(soModel);
|
||||
const ExPolygons& sup_bottom = slice_low.get_slice(soSupport);
|
||||
// calculate model bottom cap
|
||||
if (bottom_obj_triangles.empty() && !obj_bottom.empty())
|
||||
bottom_obj_triangles = triangulate_expolygons_3d(obj_bottom, clip_min_z - plane_shift_z, true);
|
||||
|
@ -3974,9 +3977,9 @@ void GLCanvas3D::_render_sla_slices() const
|
|||
bottom_sup_triangles = triangulate_expolygons_3d(sup_bottom, clip_min_z - plane_shift_z, true);
|
||||
}
|
||||
|
||||
if (! it_high.is_end() && it_high->key() < key_high + LevelID(SCALED_EPSILON)) {
|
||||
const ExPolygons& obj_top = obj->get_slices_from_record(it_high, soModel);
|
||||
const ExPolygons& sup_top = obj->get_slices_from_record(it_high, soSupport);
|
||||
if (slice_high.is_valid()) {
|
||||
const ExPolygons& obj_top = slice_high.get_slice(soModel);
|
||||
const ExPolygons& sup_top = slice_high.get_slice(soSupport);
|
||||
// calculate model top cap
|
||||
if (top_obj_triangles.empty() && !obj_top.empty())
|
||||
top_obj_triangles = triangulate_expolygons_3d(obj_top, clip_max_z + plane_shift_z, false);
|
||||
|
|
|
@ -203,7 +203,16 @@ bool GUI_App::OnInit()
|
|||
load_current_presets();
|
||||
|
||||
mainframe->Show(true);
|
||||
|
||||
/* Temporary workaround for the correct behavior of the Scrolled sidebar panel:
|
||||
* change min hight of object list to the normal min value (15 * wxGetApp().em_unit())
|
||||
* after first whole Mainframe updating/layouting
|
||||
*/
|
||||
if (obj_list()->GetMinSize().GetY() > 15 * em_unit())
|
||||
obj_list()->SetMinSize(wxSize(-1, 15 * em_unit()));
|
||||
|
||||
update_mode(); // update view mode after fix of the object_list size
|
||||
|
||||
m_initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -317,6 +326,13 @@ void GUI_App::recreate_GUI()
|
|||
|
||||
dlg.Update(90, _(L("Loading of a mode view")) + dots);
|
||||
|
||||
/* Temporary workaround for the correct behavior of the Scrolled sidebar panel:
|
||||
* change min hight of object list to the normal min value (15 * wxGetApp().em_unit())
|
||||
* after first whole Mainframe updating/layouting
|
||||
*/
|
||||
if (obj_list()->GetMinSize().GetY() > 15 * em_unit())
|
||||
obj_list()->SetMinSize(wxSize(-1, 15 * em_unit()));
|
||||
|
||||
update_mode();
|
||||
|
||||
// #ys_FIXME_delete_after_testing Do we still need this ?
|
||||
|
@ -633,12 +649,28 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||
}
|
||||
case ConfigMenuLanguage:
|
||||
{
|
||||
/* Before change application language, let's check unsaved changes
|
||||
* and draw user's attention to the application restarting after a language change
|
||||
*/
|
||||
wxMessageDialog dialog(nullptr,
|
||||
_(L("Application will be restarted after language change, "
|
||||
"and 3D-Scene will be cleaned.")) + "\n" +
|
||||
_(L("Please, check your changes before.")) + "\n\n" +
|
||||
_(L("Continue anyway?")),
|
||||
_(L("Attention!")),
|
||||
wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT);
|
||||
if ( dialog.ShowModal() != wxID_YES)
|
||||
return;
|
||||
|
||||
if (!wxGetApp().check_unsaved_changes())
|
||||
return;
|
||||
|
||||
wxArrayString names;
|
||||
wxArrayLong identifiers;
|
||||
get_installed_languages(names, identifiers);
|
||||
if (select_language(names, identifiers)) {
|
||||
save_language();
|
||||
show_info(mainframe->m_tabpanel, _(L("Application will be restarted")), _(L("Attention!")));
|
||||
// show_info(mainframe->m_tabpanel, _(L("Application will be restarted")), _(L("Attention!")));
|
||||
_3DScene::remove_all_canvases();// remove all canvas before recreate GUI
|
||||
recreate_GUI();
|
||||
}
|
||||
|
@ -674,11 +706,11 @@ bool GUI_App::check_unsaved_changes()
|
|||
// No changes, the application may close or reload presets.
|
||||
return true;
|
||||
// Ask the user.
|
||||
auto dialog = new wxMessageDialog(mainframe,
|
||||
wxMessageDialog dialog(mainframe,
|
||||
_(L("You have unsaved changes ")) + dirty + _(L(". Discard changes and continue anyway?")),
|
||||
_(L("Unsaved Presets")),
|
||||
wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT);
|
||||
return dialog->ShowModal() == wxID_YES;
|
||||
return dialog.ShowModal() == wxID_YES;
|
||||
}
|
||||
|
||||
bool GUI_App::checked_tab(Tab* tab)
|
||||
|
|
|
@ -127,7 +127,11 @@ ObjectList::~ObjectList()
|
|||
|
||||
void ObjectList::create_objects_ctrl()
|
||||
{
|
||||
SetMinSize(wxSize(-1, 15 * wxGetApp().em_unit()));
|
||||
/* Temporary workaround for the correct behavior of the Scrolled sidebar panel:
|
||||
* 1. set a height of the list to some big value
|
||||
* 2. change it to the normal min value (15 * wxGetApp().em_unit()) after first whole Mainframe updating/layouting
|
||||
*/
|
||||
SetMinSize(wxSize(-1, 3000));
|
||||
|
||||
m_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer->Add(this, 1, wxGROW);
|
||||
|
|
|
@ -772,12 +772,11 @@ void Preview::load_print_as_sla()
|
|||
std::vector<double> zs;
|
||||
double initial_layer_height = print->material_config().initial_layer_height.value;
|
||||
for (const SLAPrintObject* obj : print->objects())
|
||||
if (obj->is_step_done(slaposIndexSlices))
|
||||
if (obj->is_step_done(slaposIndexSlices) && !obj->get_slice_index().empty())
|
||||
{
|
||||
auto slicerecords = obj->get_slice_records();
|
||||
auto low_coord = slicerecords.begin()->key();
|
||||
for (auto& rec : slicerecords)
|
||||
zs.emplace_back(initial_layer_height + (rec.key() - low_coord) * SCALING_FACTOR);
|
||||
auto low_coord = obj->get_slice_index().front().print_level();
|
||||
for (auto& rec : obj->get_slice_index())
|
||||
zs.emplace_back(initial_layer_height + (rec.print_level() - low_coord) * SCALING_FACTOR);
|
||||
}
|
||||
sort_remove_duplicates(zs);
|
||||
|
||||
|
|
|
@ -232,13 +232,7 @@ std::array<float, 3> GLGizmoBase::picking_color_component(unsigned int id) const
|
|||
|
||||
void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const
|
||||
{
|
||||
float size = (float)box.max_size();
|
||||
|
||||
for (int i = 0; i < (int)m_grabbers.size(); ++i)
|
||||
{
|
||||
if (m_grabbers[i].enabled)
|
||||
m_grabbers[i].render((m_hover_id == i), size);
|
||||
}
|
||||
render_grabbers((float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0));
|
||||
}
|
||||
|
||||
void GLGizmoBase::render_grabbers(float size) const
|
||||
|
@ -252,7 +246,7 @@ void GLGizmoBase::render_grabbers(float size) const
|
|||
|
||||
void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
|
||||
{
|
||||
float size = (float)box.max_size();
|
||||
float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0);
|
||||
|
||||
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i)
|
||||
{
|
||||
|
@ -262,7 +256,7 @@ void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
|
|||
m_grabbers[i].color[0] = color[0];
|
||||
m_grabbers[i].color[1] = color[1];
|
||||
m_grabbers[i].color[2] = color[2];
|
||||
m_grabbers[i].render_for_picking(size);
|
||||
m_grabbers[i].render_for_picking(mean_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ void GLGizmoCut::on_render(const Selection& selection) const
|
|||
::glEnd();
|
||||
|
||||
std::copy(std::begin(GrabberColor), std::end(GrabberColor), m_grabbers[0].color);
|
||||
m_grabbers[0].render(m_hover_id == 0, box.max_size());
|
||||
m_grabbers[0].render(m_hover_id == 0, (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0));
|
||||
}
|
||||
|
||||
void GLGizmoCut::on_render_for_picking(const Selection& selection) const
|
||||
|
|
|
@ -216,7 +216,8 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
|||
if (m_quadric == nullptr)
|
||||
return;
|
||||
|
||||
double size = m_dragging ? (double)m_grabbers[axis].get_dragging_half_size((float)box.max_size()) : (double)m_grabbers[axis].get_half_size((float)box.max_size());
|
||||
float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0);
|
||||
double size = m_dragging ? (double)m_grabbers[axis].get_dragging_half_size(mean_size) : (double)m_grabbers[axis].get_half_size(mean_size);
|
||||
|
||||
float color[3];
|
||||
::memcpy((void*)color, (const void*)m_grabbers[axis].color, 3 * sizeof(float));
|
||||
|
|
|
@ -307,7 +307,8 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
|||
if (m_quadric == nullptr)
|
||||
return;
|
||||
|
||||
double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size((float)box.max_size()) : (double)m_grabbers[0].get_half_size((float)box.max_size());
|
||||
float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0);
|
||||
double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size(mean_size) : (double)m_grabbers[0].get_half_size(mean_size);
|
||||
|
||||
float color[3];
|
||||
::memcpy((void*)color, (const void*)m_grabbers[0].color, 3 * sizeof(float));
|
||||
|
|
|
@ -116,8 +116,6 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
Vec3d angles = Vec3d::Zero();
|
||||
Transform3d offsets_transform = Transform3d::Identity();
|
||||
|
||||
Vec3d grabber_size = Vec3d::Zero();
|
||||
|
||||
if (single_instance)
|
||||
{
|
||||
// calculate bounding box in instance local reference system
|
||||
|
@ -135,7 +133,6 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
angles = v->get_instance_rotation();
|
||||
// consider rotation+mirror only components of the transform for offsets
|
||||
offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror());
|
||||
grabber_size = v->get_instance_transformation().get_matrix(true, true, false, true) * box.size();
|
||||
}
|
||||
else if (single_volume)
|
||||
{
|
||||
|
@ -145,13 +142,9 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
angles = Geometry::extract_euler_angles(transform);
|
||||
// consider rotation+mirror only components of the transform for offsets
|
||||
offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror());
|
||||
grabber_size = v->get_volume_transformation().get_matrix(true, true, false, true) * box.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
box = selection.get_bounding_box();
|
||||
grabber_size = box.size();
|
||||
}
|
||||
|
||||
m_box = box;
|
||||
|
||||
|
@ -196,7 +189,9 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
|||
|
||||
::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f);
|
||||
|
||||
float grabber_mean_size = (float)(grabber_size(0) + grabber_size(1) + grabber_size(2)) / 3.0f;
|
||||
const BoundingBoxf3& selection_box = selection.get_bounding_box();
|
||||
|
||||
float grabber_mean_size = (float)((selection_box.size()(0) + selection_box.size()(1) + selection_box.size()(2)) / 3.0);
|
||||
|
||||
if (m_hover_id == -1)
|
||||
{
|
||||
|
|
|
@ -56,6 +56,14 @@ bool ImGuiWrapper::init()
|
|||
|
||||
void ImGuiWrapper::set_language(const std::string &language)
|
||||
{
|
||||
if (m_new_frame_open) {
|
||||
// ImGUI internally locks the font between NewFrame() and EndFrame()
|
||||
// NewFrame() might've been called here because of input from the 3D scene;
|
||||
// call EndFrame()
|
||||
ImGui::EndFrame();
|
||||
m_new_frame_open = false;
|
||||
}
|
||||
|
||||
const ImWchar *ranges = nullptr;
|
||||
size_t idx = language.find('_');
|
||||
std::string lang = (idx == std::string::npos) ? language : language.substr(0, idx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue