mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-19 23:01:22 -06:00
ENH: Cut optimization, support for custom connectors
Change-Id: I65163314374fb74f0b16df47dacae82caa6fab0d (cherry picked from commit 7bacc2c2a89be471f6fee51dd07a42222a28b55a)
This commit is contained in:
parent
9f71a8c5dd
commit
cd4cddfca4
51 changed files with 3663 additions and 466 deletions
131
src/slic3r/GUI/CameraUtils.cpp
Normal file
131
src/slic3r/GUI/CameraUtils.cpp
Normal file
|
@ -0,0 +1,131 @@
|
|||
#include "CameraUtils.hpp"
|
||||
#include <igl/project.h> // projecting points
|
||||
#include <igl/unproject.h>
|
||||
|
||||
#include "slic3r/GUI/3DScene.hpp" // GLVolume
|
||||
#include "libslic3r/Geometry/ConvexHull.hpp"
|
||||
|
||||
using namespace Slic3r;
|
||||
using namespace GUI;
|
||||
|
||||
Points CameraUtils::project(const Camera & camera,
|
||||
const std::vector<Vec3d> &points)
|
||||
{
|
||||
Vec4i viewport(camera.get_viewport().data());
|
||||
|
||||
// Convert our std::vector to Eigen dynamic matrix.
|
||||
Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::DontAlign>
|
||||
pts(points.size(), 3);
|
||||
for (size_t i = 0; i < points.size(); ++i)
|
||||
pts.block<1, 3>(i, 0) = points[i];
|
||||
|
||||
// Get the projections.
|
||||
Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::DontAlign> projections;
|
||||
igl::project(pts, camera.get_view_matrix().matrix(),
|
||||
camera.get_projection_matrix().matrix(), viewport, projections);
|
||||
|
||||
Points result;
|
||||
result.reserve(points.size());
|
||||
int window_height = viewport[3];
|
||||
|
||||
// convert to points --> loss precision
|
||||
for (int i = 0; i < projections.rows(); ++i) {
|
||||
double x = projections(i, 0);
|
||||
double y = projections(i, 1);
|
||||
// opposit direction o Y
|
||||
result.emplace_back(x, window_height - y);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Point CameraUtils::project(const Camera &camera, const Vec3d &point)
|
||||
{
|
||||
// IMPROVE: do it faster when you need it (inspire in project multi point)
|
||||
return project(camera, std::vector{point}).front();
|
||||
}
|
||||
|
||||
Slic3r::Polygon CameraUtils::create_hull2d(const Camera & camera,
|
||||
const GLVolume &volume)
|
||||
{
|
||||
std::vector<Vec3d> vertices;
|
||||
const TriangleMesh *hull = volume.convex_hull();
|
||||
if (hull != nullptr) {
|
||||
const indexed_triangle_set &its = hull->its;
|
||||
vertices.reserve(its.vertices.size());
|
||||
// cast vector
|
||||
for (const Vec3f &vertex : its.vertices)
|
||||
vertices.emplace_back(vertex.cast<double>());
|
||||
} else {
|
||||
// Negative volume doesn't have convex hull so use bounding box
|
||||
auto bb = volume.bounding_box();
|
||||
Vec3d &min = bb.min;
|
||||
Vec3d &max = bb.max;
|
||||
vertices = {min,
|
||||
Vec3d(min.x(), min.y(), max.z()),
|
||||
Vec3d(min.x(), max.y(), min.z()),
|
||||
Vec3d(min.x(), max.y(), max.z()),
|
||||
Vec3d(max.x(), min.y(), min.z()),
|
||||
Vec3d(max.x(), min.y(), max.z()),
|
||||
Vec3d(max.x(), max.y(), min.z()),
|
||||
max};
|
||||
}
|
||||
|
||||
const Transform3d &trafoMat =
|
||||
volume.get_instance_transformation().get_matrix() *
|
||||
volume.get_volume_transformation().get_matrix();
|
||||
for (Vec3d &vertex : vertices)
|
||||
vertex = trafoMat * vertex.cast<double>();
|
||||
|
||||
Points vertices_2d = project(camera, vertices);
|
||||
return Geometry::convex_hull(vertices_2d);
|
||||
}
|
||||
|
||||
void CameraUtils::ray_from_screen_pos(const Camera &camera, const Vec2d &position, Vec3d &point, Vec3d &direction) {
|
||||
switch (camera.get_type()) {
|
||||
case Camera::EType::Ortho: return ray_from_ortho_screen_pos(camera, position, point, direction);
|
||||
case Camera::EType::Perspective: return ray_from_persp_screen_pos(camera, position, point, direction);
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
Vec3d CameraUtils::screen_point(const Camera &camera, const Vec2d &position)
|
||||
{
|
||||
double height = camera.get_viewport().data()[3];
|
||||
// Y coordinate has opposit direction
|
||||
return Vec3d(position.x(), height - position.y(), 0.);
|
||||
}
|
||||
|
||||
void CameraUtils::ray_from_ortho_screen_pos(const Camera &camera, const Vec2d &position, Vec3d &point, Vec3d &direction)
|
||||
{
|
||||
assert(camera.get_type() == Camera::EType::Ortho);
|
||||
Matrix4d modelview = camera.get_view_matrix().matrix();
|
||||
Matrix4d projection = camera.get_projection_matrix().matrix();
|
||||
Vec4i viewport(camera.get_viewport().data());
|
||||
igl::unproject(screen_point(camera,position), modelview, projection, viewport, point);
|
||||
direction = camera.get_dir_forward();
|
||||
}
|
||||
void CameraUtils::ray_from_persp_screen_pos(const Camera &camera, const Vec2d &position, Vec3d &point, Vec3d &direction)
|
||||
{
|
||||
assert(camera.get_type() == Camera::EType::Perspective);
|
||||
Matrix4d modelview = camera.get_view_matrix().matrix();
|
||||
Matrix4d projection = camera.get_projection_matrix().matrix();
|
||||
Vec4i viewport(camera.get_viewport().data());
|
||||
igl::unproject(screen_point(camera, position), modelview, projection, viewport, point);
|
||||
direction = point - camera.get_position();
|
||||
}
|
||||
|
||||
Vec2d CameraUtils::get_z0_position(const Camera &camera, const Vec2d & coor)
|
||||
{
|
||||
Vec3d p0, dir;
|
||||
ray_from_screen_pos(camera, coor, p0, dir);
|
||||
|
||||
// is approx zero
|
||||
if ((fabs(dir.z()) - 1e-4) < 0)
|
||||
return Vec2d(std::numeric_limits<double>::max(),
|
||||
std::numeric_limits<double>::max());
|
||||
|
||||
// find position of ray cross plane(z = 0)
|
||||
double t = p0.z() / dir.z();
|
||||
Vec3d p = p0 - t * dir;
|
||||
return Vec2d(p.x(), p.y());
|
||||
}
|
69
src/slic3r/GUI/CameraUtils.hpp
Normal file
69
src/slic3r/GUI/CameraUtils.hpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
#ifndef slic3r_CameraUtils_hpp_
|
||||
#define slic3r_CameraUtils_hpp_
|
||||
|
||||
#include "Camera.hpp"
|
||||
#include "libslic3r/Point.hpp"
|
||||
namespace Slic3r {
|
||||
class GLVolume;
|
||||
}
|
||||
|
||||
namespace Slic3r::GUI {
|
||||
/// <summary>
|
||||
/// Help divide camera data and camera functions
|
||||
/// This utility work with camera data by static funtions
|
||||
/// </summary>
|
||||
class CameraUtils
|
||||
{
|
||||
public:
|
||||
CameraUtils() = delete; // only static functions
|
||||
|
||||
/// <summary>
|
||||
/// Project point throw camera to 2d coordinate into imgui window
|
||||
/// </summary>
|
||||
/// <param name="camera">Projection params</param>
|
||||
/// <param name="points">Point to project.</param>
|
||||
/// <returns>projected points by camera into coordinate of camera.
|
||||
/// x(from left to right), y(from top to bottom)</returns>
|
||||
static Points project(const Camera& camera, const std::vector<Vec3d> &points);
|
||||
static Point project(const Camera& camera, const Vec3d &point);
|
||||
|
||||
/// <summary>
|
||||
/// Create hull around GLVolume in 2d space of camera
|
||||
/// </summary>
|
||||
/// <param name="camera">Projection params</param>
|
||||
/// <param name="volume">Outline by 3d object</param>
|
||||
/// <returns>Polygon around object</returns>
|
||||
static Polygon create_hull2d(const Camera &camera, const GLVolume &volume);
|
||||
|
||||
/// <summary>
|
||||
/// Create ray(point and direction) for screen coordinate
|
||||
/// </summary>
|
||||
/// <param name="camera">Definition of camera</param>
|
||||
/// <param name="position">Position on screen(aka mouse position) </param>
|
||||
/// <param name="point">OUT start of ray</param>
|
||||
/// <param name="direction">OUT direction of ray</param>
|
||||
static void ray_from_screen_pos(const Camera &camera, const Vec2d &position, Vec3d &point, Vec3d &direction);
|
||||
static void ray_from_ortho_screen_pos(const Camera &camera, const Vec2d &position, Vec3d &point, Vec3d &direction);
|
||||
static void ray_from_persp_screen_pos(const Camera &camera, const Vec2d &position, Vec3d &point, Vec3d &direction);
|
||||
|
||||
/// <summary>
|
||||
/// Unproject mouse coordinate to get position in space where z coor is zero
|
||||
/// Platter surface should be in z == 0
|
||||
/// </summary>
|
||||
/// <param name="camera">Projection params</param>
|
||||
/// <param name="coor">Mouse position</param>
|
||||
/// <returns>Position on platter under mouse</returns>
|
||||
static Vec2d get_z0_position(const Camera &camera, const Vec2d &coor);
|
||||
|
||||
/// <summary>
|
||||
/// Create 3d screen point from 2d position
|
||||
/// </summary>
|
||||
/// <param name="camera">Define camera viewport</param>
|
||||
/// <param name="position">Position on screen(aka mouse position)</param>
|
||||
/// <returns>Point represented screen coor in 3d</returns>
|
||||
static Vec3d screen_point(const Camera &camera, const Vec2d &position);
|
||||
|
||||
};
|
||||
} // Slic3r::GUI
|
||||
|
||||
#endif /* slic3r_CameraUtils_hpp_ */
|
|
@ -3861,6 +3861,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
default: { break; }
|
||||
}
|
||||
}
|
||||
else if (evt.LeftUp() &&
|
||||
m_gizmos.get_current_type() == GLGizmosManager::EType::Scale &&
|
||||
m_gizmos.get_current()->get_state() == GLGizmoBase::EState::On) {
|
||||
wxGetApp().obj_list()->selection_changed();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -6632,9 +6637,14 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
|
|||
else
|
||||
m_volumes.set_z_range(-FLT_MAX, FLT_MAX);
|
||||
|
||||
GLGizmosManager& gm = get_gizmos_manager();
|
||||
GLGizmoBase* current_gizmo = gm.get_current();
|
||||
if (m_canvas_type == CanvasAssembleView) {
|
||||
m_volumes.set_clipping_plane(m_gizmos.get_assemble_view_clipping_plane().get_data());
|
||||
}
|
||||
else if (current_gizmo && !current_gizmo->apply_clipping_plane()) {
|
||||
m_volumes.set_clipping_plane(ClippingPlane::ClipsNothing().get_data());
|
||||
}
|
||||
else {
|
||||
m_volumes.set_clipping_plane(m_camera_clipping_plane.get_data());
|
||||
}
|
||||
|
|
|
@ -44,6 +44,10 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||
valid &= append_shader("gouraud_light_instanced", { "gouraud_light_instanced.vs", "gouraud_light_instanced.fs" });
|
||||
// used to render extrusion and travel paths as lines in gcode preview
|
||||
valid &= append_shader("toolpaths_lines", { "toolpaths_lines.vs", "toolpaths_lines.fs" });
|
||||
|
||||
// used to render cut connectors
|
||||
valid &= append_shader("gouraud_light_uniform", {"gouraud_light_uniform.vs", "gouraud_light_uniform.fs"});
|
||||
|
||||
// used to render objects in 3d editor
|
||||
//if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 0)) {
|
||||
if (0) {
|
||||
|
|
|
@ -914,6 +914,20 @@ void MenuFactory::append_menu_items_mirror(wxMenu* menu)
|
|||
[]() { return plater()->can_mirror(); }, m_parent);
|
||||
}
|
||||
|
||||
void MenuFactory::append_menu_item_invalidate_cut_info(wxMenu *menu)
|
||||
{
|
||||
const wxString menu_name = _L("Invalidate cut info");
|
||||
|
||||
auto menu_item_id = menu->FindItem(menu_name);
|
||||
if (menu_item_id != wxNOT_FOUND)
|
||||
// Delete old menu item if selected object isn't cut
|
||||
menu->Destroy(menu_item_id);
|
||||
|
||||
if (obj_list()->has_selected_cut_object())
|
||||
append_menu_item(menu, wxID_ANY, menu_name, "", [](wxCommandEvent &) { obj_list()->invalidate_cut_info_for_selection(); },
|
||||
"", menu, []() { return true; }, m_parent);
|
||||
}
|
||||
|
||||
MenuFactory::MenuFactory()
|
||||
{
|
||||
for (int i = 0; i < mtCount; i++) {
|
||||
|
@ -1235,6 +1249,7 @@ wxMenu* MenuFactory::object_menu()
|
|||
append_menu_item_change_filament(&m_object_menu);
|
||||
append_menu_items_convert_unit(&m_object_menu);
|
||||
append_menu_items_flush_options(&m_object_menu);
|
||||
append_menu_item_invalidate_cut_info(&m_object_menu);
|
||||
return &m_object_menu;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,6 +136,8 @@ private:
|
|||
void append_menu_item_merge_to_single_object(wxMenu* menu);
|
||||
void append_menu_item_merge_parts_to_single_part(wxMenu *menu);
|
||||
void append_menu_items_mirror(wxMenu *menu);
|
||||
void append_menu_item_invalidate_cut_info(wxMenu *menu);
|
||||
|
||||
//void append_menu_items_instance_manipulation(wxMenu *menu);
|
||||
//void update_menu_items_instance_manipulation(MenuType type);
|
||||
//BBS add bbl menu item
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "wx/uiaction.h"
|
||||
#include <wx/renderer.h>
|
||||
#endif /* __WXMSW__ */
|
||||
#include "Gizmos/GLGizmoScale.hpp"
|
||||
|
||||
namespace Slic3r
|
||||
{
|
||||
|
@ -927,6 +928,8 @@ void ObjectList::selection_changed()
|
|||
|
||||
fix_multiselection_conflicts();
|
||||
|
||||
fix_cut_selection();
|
||||
|
||||
// update object selection on Plater
|
||||
if (!m_prevent_canvas_selection_update)
|
||||
update_selections_on_canvas();
|
||||
|
@ -2264,9 +2267,9 @@ int ObjectList::load_mesh_part(const TriangleMesh &mesh, const wxString &name, c
|
|||
}
|
||||
|
||||
//BBS
|
||||
void ObjectList::del_object(const int obj_idx, bool refresh_immediately)
|
||||
bool ObjectList::del_object(const int obj_idx, bool refresh_immediately)
|
||||
{
|
||||
wxGetApp().plater()->delete_object_from_model(obj_idx, refresh_immediately);
|
||||
return wxGetApp().plater()->delete_object_from_model(obj_idx, refresh_immediately);
|
||||
}
|
||||
|
||||
// Delete subobject
|
||||
|
@ -2283,6 +2286,7 @@ void ObjectList::del_subobject_item(wxDataViewItem& item)
|
|||
|
||||
wxDataViewItem parent = m_objects_model->GetParent(item);
|
||||
|
||||
InfoItemType item_info_type = m_objects_model->GetInfoItemType(item);
|
||||
if (type & itSettings)
|
||||
del_settings_from_config(parent);
|
||||
else if (type & itInstanceRoot && obj_idx != -1)
|
||||
|
@ -2292,7 +2296,7 @@ void ObjectList::del_subobject_item(wxDataViewItem& item)
|
|||
else if (type & itLayer && obj_idx != -1)
|
||||
del_layer_from_object(obj_idx, m_objects_model->GetLayerRangeByItem(item));
|
||||
else if (type & itInfo && obj_idx != -1)
|
||||
del_info_item(obj_idx, m_objects_model->GetInfoItemType(item));
|
||||
del_info_item(obj_idx, item_info_type);
|
||||
else if (idx == -1)
|
||||
return;
|
||||
else if (!del_subobject_from_object(obj_idx, idx, type))
|
||||
|
@ -2304,8 +2308,11 @@ void ObjectList::del_subobject_item(wxDataViewItem& item)
|
|||
m_objects_model->UpdateWarningIcon(parent, icon_name);
|
||||
}
|
||||
|
||||
m_objects_model->Delete(item);
|
||||
update_info_items(obj_idx);
|
||||
if (!(type & itInfo) || item_info_type != InfoItemType::CutConnectors) {
|
||||
// Connectors Item is already updated/deleted inside the del_info_item()
|
||||
m_objects_model->Delete(item);
|
||||
update_info_items(obj_idx);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectList::del_info_item(const int obj_idx, InfoItemType type)
|
||||
|
@ -2329,6 +2336,13 @@ void ObjectList::del_info_item(const int obj_idx, InfoItemType type)
|
|||
mv->mmu_segmentation_facets.reset();
|
||||
break;
|
||||
|
||||
case InfoItemType::CutConnectors:
|
||||
if (!del_from_cut_object(true)) {
|
||||
// there is no need to post EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS if nothing was changed
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
// BBS: remove Sinking
|
||||
case InfoItemType::Undef : assert(false); break;
|
||||
}
|
||||
|
@ -2399,6 +2413,38 @@ void ObjectList::del_layers_from_object(const int obj_idx)
|
|||
changed_object(obj_idx);
|
||||
}
|
||||
|
||||
bool ObjectList::del_from_cut_object(bool is_cut_connector, bool is_model_part/* = false*/, bool is_negative_volume/* = false*/)
|
||||
{
|
||||
const long buttons_style = is_cut_connector ? (wxYES | wxNO | wxCANCEL) : (wxYES | wxCANCEL);
|
||||
|
||||
const wxString title = is_cut_connector ? _L("Delete connector from object which is a part of cut") :
|
||||
is_model_part ? _L("Delete solid part from object which is a part of cut") :
|
||||
is_negative_volume ? _L("Delete negative volume from object which is a part of cut") : "";
|
||||
|
||||
const wxString msg_end = is_cut_connector ? ("\n" + _L("To save cut correspondence you can delete all connectors from all related objects.")) : "";
|
||||
|
||||
InfoDialog dialog(wxGetApp().plater(), title,
|
||||
_L("This action will break a cut correspondence.\n"
|
||||
"After that model consistency can't be guaranteed .\n"
|
||||
"\n"
|
||||
"To manipulate with solid parts or negative volumes you have to invalidate cut infornation first." + msg_end ),
|
||||
false, buttons_style | wxCANCEL_DEFAULT | wxICON_WARNING);
|
||||
|
||||
dialog.SetButtonLabel(wxID_YES, _L("Invalidate cut info"));
|
||||
if (is_cut_connector)
|
||||
dialog.SetButtonLabel(wxID_NO, _L("Delete all connectors"));
|
||||
|
||||
const int answer = dialog.ShowModal();
|
||||
if (answer == wxID_CANCEL)
|
||||
return false;
|
||||
|
||||
if (answer == wxID_YES)
|
||||
invalidate_cut_info_for_selection();
|
||||
else if (answer == wxID_NO)
|
||||
delete_all_connectors_for_selection();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, const int type)
|
||||
{
|
||||
assert(idx >= 0);
|
||||
|
@ -2423,6 +2469,11 @@ bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, con
|
|||
Slic3r::GUI::show_error(nullptr, _L("Deleting the last solid part is not allowed."));
|
||||
return false;
|
||||
}
|
||||
if (object->is_cut() && (volume->is_model_part() || volume->is_negative_volume())) {
|
||||
del_from_cut_object(volume->is_cut_connector(), volume->is_model_part(), volume->is_negative_volume());
|
||||
// in any case return false to break the deletion
|
||||
return false;
|
||||
}
|
||||
|
||||
take_snapshot("Delete part");
|
||||
|
||||
|
@ -2927,6 +2978,9 @@ bool ObjectList::can_split_instances()
|
|||
|
||||
bool ObjectList::can_merge_to_multipart_object() const
|
||||
{
|
||||
if (has_selected_cut_object())
|
||||
return false;
|
||||
|
||||
if (printer_technology() == ptSLA)
|
||||
return false;
|
||||
|
||||
|
@ -2954,6 +3008,97 @@ bool ObjectList::can_merge_to_single_object() const
|
|||
return (*m_objects)[obj_idx]->volumes.size() > 1;
|
||||
}
|
||||
|
||||
bool ObjectList::has_selected_cut_object() const
|
||||
{
|
||||
wxDataViewItemArray sels;
|
||||
GetSelections(sels);
|
||||
if (sels.IsEmpty())
|
||||
return false;
|
||||
|
||||
for (wxDataViewItem item : sels) {
|
||||
const int obj_idx = m_objects_model->GetObjectIdByItem(item);
|
||||
if (obj_idx >= 0 && object(obj_idx)->is_cut())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ObjectList::invalidate_cut_info_for_selection()
|
||||
{
|
||||
const wxDataViewItem item = GetSelection();
|
||||
if (item) {
|
||||
const int obj_idx = m_objects_model->GetObjectIdByItem(item);
|
||||
if (obj_idx >= 0)
|
||||
invalidate_cut_info_for_object(size_t(obj_idx));
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectList::invalidate_cut_info_for_object(int obj_idx)
|
||||
{
|
||||
ModelObject *init_obj = object(obj_idx);
|
||||
if (!init_obj->is_cut()) return;
|
||||
|
||||
take_snapshot("Invalidate cut info");
|
||||
|
||||
const CutObjectBase cut_id = init_obj->cut_id;
|
||||
// invalidate cut for related objects (which have the same cut_id)
|
||||
for (size_t idx = 0; idx < m_objects->size(); idx++)
|
||||
if (ModelObject *obj = object(int(idx)); obj->cut_id.is_equal(cut_id)) {
|
||||
obj->invalidate_cut();
|
||||
update_info_items(idx);
|
||||
add_volumes_to_object_in_list(idx);
|
||||
}
|
||||
|
||||
update_lock_icons_for_model();
|
||||
}
|
||||
|
||||
void ObjectList::delete_all_connectors_for_selection()
|
||||
{
|
||||
const wxDataViewItem item = GetSelection();
|
||||
if (item) {
|
||||
const int obj_idx = m_objects_model->GetObjectIdByItem(item);
|
||||
if (obj_idx >= 0)
|
||||
delete_all_connectors_for_object(size_t(obj_idx));
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectList::delete_all_connectors_for_object(int obj_idx)
|
||||
{
|
||||
ModelObject *init_obj = object(obj_idx);
|
||||
if (!init_obj->is_cut())
|
||||
return;
|
||||
|
||||
take_snapshot("Delete all connectors");
|
||||
|
||||
auto has_solid_mesh = [](ModelObject* obj) {
|
||||
for (const ModelVolume *volume : obj->volumes)
|
||||
if (volume->is_model_part()) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
const CutObjectBase cut_id = init_obj->cut_id;
|
||||
// Delete all connectors for related objects (which have the same cut_id)
|
||||
Model &model = wxGetApp().plater()->model();
|
||||
for (int idx = int(m_objects->size()) - 1; idx >= 0; idx--)
|
||||
if (ModelObject *obj = object(idx); obj->cut_id.is_equal(cut_id)) {
|
||||
obj->delete_connectors();
|
||||
|
||||
if (obj->volumes.empty() || !has_solid_mesh(obj)) {
|
||||
model.delete_object(idx);
|
||||
m_objects_model->Delete(m_objects_model->GetItemById(idx));
|
||||
continue;
|
||||
}
|
||||
|
||||
update_info_items(idx);
|
||||
add_volumes_to_object_in_list(idx);
|
||||
changed_object(int(idx));
|
||||
}
|
||||
|
||||
update_lock_icons_for_model();
|
||||
}
|
||||
|
||||
|
||||
// NO_PARAMETERS function call means that changed object index will be determine from Selection()
|
||||
void ObjectList::changed_object(const int obj_idx/* = -1*/) const
|
||||
{
|
||||
|
@ -2972,15 +3117,77 @@ void ObjectList::part_selection_changed()
|
|||
bool update_and_show_settings = false;
|
||||
bool update_and_show_layers = false;
|
||||
|
||||
bool enable_manipulation{true};
|
||||
bool disable_ss_manipulation{false};
|
||||
bool disable_ununiform_scale{false};
|
||||
|
||||
const auto item = GetSelection();
|
||||
// BBS
|
||||
if (item && (m_objects_model->GetItemType(item) & itPlate)) {
|
||||
if (item && m_objects_model->GetItemType(item) == itInfo && m_objects_model->GetInfoItemType(item) == InfoItemType::CutConnectors) {
|
||||
og_name = _L("Cut Connectors information");
|
||||
|
||||
update_and_show_manipulations = true;
|
||||
enable_manipulation = false;
|
||||
disable_ununiform_scale = true;
|
||||
}
|
||||
else if (item && (m_objects_model->GetItemType(item) & itPlate)) {
|
||||
// BBS
|
||||
// TODO: og for plate
|
||||
}
|
||||
else if ( multiple_selection() || (item && m_objects_model->GetItemType(item) == itInstanceRoot )) {
|
||||
const Selection& selection = scene_selection();
|
||||
// don't show manipulation panel for case of all Object's parts selection
|
||||
update_and_show_manipulations = !selection.is_single_full_instance();
|
||||
|
||||
if (selection.is_single_full_object()) {
|
||||
og_name = _L("Object manipulation");
|
||||
update_and_show_manipulations = true;
|
||||
|
||||
obj_idx = selection.get_object_idx();
|
||||
ModelObject *object = (*m_objects)[obj_idx];
|
||||
m_config = &object->config;
|
||||
disable_ss_manipulation = object->is_cut();
|
||||
}
|
||||
else {
|
||||
og_name = _L("Group manipulation");
|
||||
|
||||
// don't show manipulation panel for case of all Object's parts selection
|
||||
update_and_show_manipulations = !selection.is_single_full_instance();
|
||||
|
||||
if (int obj_idx = selection.get_object_idx(); obj_idx >= 0) {
|
||||
if (selection.is_any_volume() || selection.is_any_modifier())
|
||||
enable_manipulation = !(*m_objects)[obj_idx]->is_cut();
|
||||
else // if (item && m_objects_model->GetItemType(item) == itInstanceRoot)
|
||||
disable_ss_manipulation = (*m_objects)[obj_idx]->is_cut();
|
||||
}
|
||||
else {
|
||||
wxDataViewItemArray sels;
|
||||
GetSelections(sels);
|
||||
if (selection.is_single_full_object() || selection.is_multiple_full_instance()) {
|
||||
int obj_idx = m_objects_model->GetObjectIdByItem(sels.front());
|
||||
disable_ss_manipulation = (*m_objects)[obj_idx]->is_cut();
|
||||
} else if (selection.is_mixed() || selection.is_multiple_full_object()) {
|
||||
std::map<CutObjectBase, std::set<int>> cut_objects;
|
||||
|
||||
// find cut objects
|
||||
for (auto item : sels) {
|
||||
int obj_idx = m_objects_model->GetObjectIdByItem(item);
|
||||
const ModelObject *obj = object(obj_idx);
|
||||
if (obj->is_cut()) {
|
||||
if (cut_objects.find(obj->cut_id) == cut_objects.end())
|
||||
cut_objects[obj->cut_id] = std::set<int>{obj_idx};
|
||||
else
|
||||
cut_objects.at(obj->cut_id).insert(obj_idx);
|
||||
}
|
||||
}
|
||||
|
||||
// check if selected cut objects are "full selected"
|
||||
for (auto cut_object : cut_objects)
|
||||
if (cut_object.first.check_sum() != cut_object.second.size()) {
|
||||
disable_ss_manipulation = true;
|
||||
break;
|
||||
}
|
||||
disable_ununiform_scale = !cut_objects.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BBS: multi config editing
|
||||
update_and_show_settings = true;
|
||||
|
@ -3022,34 +3229,44 @@ void ObjectList::part_selection_changed()
|
|||
// BBS: select object to edit config
|
||||
m_config = &(*m_objects)[obj_idx]->config;
|
||||
update_and_show_settings = true;
|
||||
disable_ss_manipulation = (*m_objects)[obj_idx]->is_cut();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (type & itSettings) {
|
||||
if (parent_type & itObject) {
|
||||
og_name = _L("Object Settings to modify");
|
||||
m_config = &(*m_objects)[obj_idx]->config;
|
||||
}
|
||||
else if (parent_type & itVolume) {
|
||||
og_name = _L("Part Settings to modify");
|
||||
volume_id = m_objects_model->GetVolumeIdByItem(parent);
|
||||
m_config = &(*m_objects)[obj_idx]->volumes[volume_id]->config;
|
||||
}
|
||||
else if (parent_type & itLayer) {
|
||||
og_name = _L("Layer range Settings to modify");
|
||||
m_config = &get_item_config(parent);
|
||||
}
|
||||
update_and_show_settings = true;
|
||||
}
|
||||
else if (type & itVolume) {
|
||||
og_name = _L("Part manipulation");
|
||||
volume_id = m_objects_model->GetVolumeIdByItem(item);
|
||||
m_config = &(*m_objects)[obj_idx]->volumes[volume_id]->config;
|
||||
update_and_show_manipulations = true;
|
||||
m_config = &(*m_objects)[obj_idx]->volumes[volume_id]->config;
|
||||
update_and_show_settings = true;
|
||||
|
||||
const ModelVolume *volume = (*m_objects)[obj_idx]->volumes[volume_id];
|
||||
enable_manipulation = !((*m_objects)[obj_idx]->is_cut() && (volume->is_cut_connector() || volume->is_model_part()));
|
||||
}
|
||||
else if (type & itInstance) {
|
||||
og_name = _L("Instance manipulation");
|
||||
update_and_show_manipulations = true;
|
||||
|
||||
// fill m_config by object's values
|
||||
m_config = &(*m_objects)[obj_idx]->config;
|
||||
disable_ss_manipulation = (*m_objects)[obj_idx]->is_cut();
|
||||
}
|
||||
// BBS: remove height range logics
|
||||
}
|
||||
|
@ -3068,6 +3285,11 @@ void ObjectList::part_selection_changed()
|
|||
//wxGetApp().obj_manipul()->update_item_name(m_objects_model->GetName(item));
|
||||
//wxGetApp().obj_manipul()->update_warning_icon_state(get_mesh_errors_info(obj_idx, volume_id));
|
||||
}
|
||||
|
||||
GLGizmosManager &gizmos_mgr = wxGetApp().plater()->canvas3D()->get_gizmos_manager();
|
||||
|
||||
if (GLGizmoScale3D *scale = dynamic_cast<GLGizmoScale3D *>(gizmos_mgr.get_gizmo(GLGizmosManager::Scale)))
|
||||
scale->enable_ununiversal_scale(!disable_ununiform_scale);
|
||||
}
|
||||
|
||||
#if !NEW_OBJECT_SETTING
|
||||
|
@ -3162,6 +3384,33 @@ void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selectio
|
|||
wxDataViewItem item_obj = m_objects_model->GetItemById(obj_idx);
|
||||
assert(item_obj.IsOk());
|
||||
|
||||
// Cut connectors
|
||||
{
|
||||
wxDataViewItem item = m_objects_model->GetInfoItemByType(item_obj, InfoItemType::CutConnectors);
|
||||
bool shows = item.IsOk();
|
||||
bool should_show = model_object->is_cut() && model_object->has_connectors() && model_object->volumes.size() > 1;
|
||||
|
||||
if (!shows && should_show) {
|
||||
m_objects_model->AddInfoChild(item_obj, InfoItemType::CutConnectors);
|
||||
Expand(item_obj);
|
||||
if (added_object)
|
||||
wxGetApp().notification_manager()->push_updated_item_info_notification(InfoItemType::CutConnectors);
|
||||
} else if (shows && !should_show) {
|
||||
if (!selections) Unselect(item);
|
||||
m_objects_model->Delete(item);
|
||||
if (selections) {
|
||||
if (selections->Index(item) != wxNOT_FOUND) {
|
||||
// If info item was deleted from the list,
|
||||
// it's need to be deleted from selection array, if it was there
|
||||
selections->Remove(item);
|
||||
// Select item_obj, if info_item doesn't exist for item anymore, but was selected
|
||||
if (selections->Index(item_obj) == wxNOT_FOUND) selections->Add(item_obj);
|
||||
}
|
||||
} else
|
||||
Select(item_obj);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
bool shows = m_objects_model->IsSupportPainted(item_obj);
|
||||
bool should_show = printer_technology() == ptFFF
|
||||
|
@ -3285,24 +3534,12 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed,
|
|||
//const wxString& item_name = from_u8(item_name_str);
|
||||
const wxString& item_name = from_u8(model_object->name);
|
||||
std::string warning_bitmap = get_warning_icon_name(model_object->mesh().stats());
|
||||
const auto item = m_objects_model->AddObject(model_object, warning_bitmap);
|
||||
const auto item = m_objects_model->AddObject(model_object, warning_bitmap, model_object->is_cut());
|
||||
Expand(m_objects_model->GetParent(item));
|
||||
|
||||
update_info_items(obj_idx, nullptr, call_selection_changed);
|
||||
|
||||
// add volumes to the object
|
||||
if (model_object->volumes.size() > 1) {
|
||||
for (const ModelVolume* volume : model_object->volumes) {
|
||||
const wxDataViewItem& vol_item = m_objects_model->AddVolumeChild(item,
|
||||
from_u8(volume->name),
|
||||
volume->type(),
|
||||
get_warning_icon_name(volume->mesh().stats()),
|
||||
volume->config.has("extruder") ? volume->config.extruder() : 0,
|
||||
false);
|
||||
add_settings_item(vol_item, &volume->config.get());
|
||||
}
|
||||
Expand(item);
|
||||
}
|
||||
add_volumes_to_object_in_list(obj_idx);
|
||||
|
||||
// add instances to the object, if it has those
|
||||
if (model_object->instances.size()>1)
|
||||
|
@ -3336,6 +3573,68 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed,
|
|||
#endif //__WXMSW__
|
||||
}
|
||||
|
||||
static bool can_add_volumes_to_object(const ModelObject *object)
|
||||
{
|
||||
bool can = object->volumes.size() > 1;
|
||||
|
||||
if (can && object->is_cut()) {
|
||||
int no_connectors_cnt = 0;
|
||||
for (const ModelVolume *v : object->volumes)
|
||||
if (!v->is_cut_connector()) {
|
||||
if (!v->is_model_part())
|
||||
return true;
|
||||
no_connectors_cnt++;
|
||||
}
|
||||
can = no_connectors_cnt > 1;
|
||||
}
|
||||
|
||||
return can;
|
||||
}
|
||||
|
||||
wxDataViewItemArray ObjectList::add_volumes_to_object_in_list(size_t obj_idx, std::function<bool(const ModelVolume *)> add_to_selection /* = nullptr*/)
|
||||
{
|
||||
const bool is_prevent_list_events = m_prevent_list_events;
|
||||
m_prevent_list_events = true;
|
||||
|
||||
wxDataViewItem object_item = m_objects_model->GetItemById(int(obj_idx));
|
||||
m_objects_model->DeleteVolumeChildren(object_item);
|
||||
|
||||
wxDataViewItemArray items;
|
||||
|
||||
const ModelObject *object = (*m_objects)[obj_idx];
|
||||
// add volumes to the object
|
||||
if (can_add_volumes_to_object(object)) {
|
||||
if (object->volumes.size() > 1) {
|
||||
wxString obj_item_name = from_u8(object->name);
|
||||
if (m_objects_model->GetName(object_item) != obj_item_name)
|
||||
m_objects_model->SetName(obj_item_name, object_item);
|
||||
}
|
||||
|
||||
int volume_idx{-1};
|
||||
for (const ModelVolume *volume : object->volumes) {
|
||||
++volume_idx;
|
||||
if (object->is_cut() && volume->is_cut_connector())
|
||||
continue;
|
||||
|
||||
const wxDataViewItem &vol_item = m_objects_model->AddVolumeChild(
|
||||
object_item,
|
||||
from_u8(volume->name),
|
||||
volume->type(),
|
||||
get_warning_icon_name(volume->mesh().stats()),
|
||||
volume->config.has("extruder") ? volume->config.extruder() : 0,
|
||||
false);
|
||||
add_settings_item(vol_item, &volume->config.get());
|
||||
|
||||
if (add_to_selection && add_to_selection(volume))
|
||||
items.Add(vol_item);
|
||||
}
|
||||
Expand(object_item);
|
||||
}
|
||||
|
||||
m_prevent_list_events = is_prevent_list_events;
|
||||
return items;
|
||||
}
|
||||
|
||||
void ObjectList::delete_object_from_list()
|
||||
{
|
||||
auto item = GetSelection();
|
||||
|
@ -3370,8 +3669,12 @@ void ObjectList::delete_from_model_and_list(const ItemType type, const int obj_i
|
|||
take_snapshot("Delete selected");
|
||||
|
||||
if (type&itObject) {
|
||||
del_object(obj_idx);
|
||||
delete_object_from_list(obj_idx);
|
||||
bool was_cut = object(obj_idx)->is_cut();
|
||||
if (del_object(obj_idx)) {
|
||||
delete_object_from_list(obj_idx);
|
||||
if (was_cut)
|
||||
update_lock_icons_for_model();
|
||||
}
|
||||
}
|
||||
else {
|
||||
del_subobject_from_object(obj_idx, sub_obj_idx, type);
|
||||
|
@ -3398,12 +3701,16 @@ void ObjectList::delete_from_model_and_list(const std::vector<ItemForDelete>& it
|
|||
// refresh after del_object
|
||||
need_update = true;
|
||||
bool refresh_immediately = false;
|
||||
del_object(item->obj_idx, refresh_immediately);
|
||||
bool was_cut = object(item->obj_idx)->is_cut();
|
||||
if (!del_object(item->obj_idx, refresh_immediately))
|
||||
return;
|
||||
m_objects_model->Delete(m_objects_model->GetItemById(item->obj_idx));
|
||||
if (was_cut)
|
||||
update_lock_icons_for_model();
|
||||
}
|
||||
else {
|
||||
if (!del_subobject_from_object(item->obj_idx, item->sub_obj_idx, item->type))
|
||||
continue;
|
||||
return; //continue;
|
||||
if (item->type&itVolume) {
|
||||
m_objects_model->Delete(m_objects_model->GetItemByVolumeId(item->obj_idx, item->sub_obj_idx));
|
||||
// BBS
|
||||
|
@ -3441,6 +3748,14 @@ void ObjectList::delete_from_model_and_list(const std::vector<ItemForDelete>& it
|
|||
part_selection_changed();
|
||||
}
|
||||
|
||||
void ObjectList::update_lock_icons_for_model()
|
||||
{
|
||||
// update the icon for cut object
|
||||
for (size_t obj_idx = 0; obj_idx < (*m_objects).size(); ++obj_idx)
|
||||
if (!(*m_objects)[obj_idx]->is_cut())
|
||||
m_objects_model->UpdateCutObjectIcon(m_objects_model->GetItemById(int(obj_idx)), false);
|
||||
}
|
||||
|
||||
void ObjectList::delete_all_objects_from_list()
|
||||
{
|
||||
m_prevent_list_events = true;
|
||||
|
@ -3856,6 +4171,25 @@ bool ObjectList::is_selected(const ItemType type) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ObjectList::is_connectors_item_selected() const
|
||||
{
|
||||
const wxDataViewItem &item = GetSelection();
|
||||
if (item)
|
||||
return m_objects_model->GetItemType(item) == itInfo && m_objects_model->GetInfoItemType(item) == InfoItemType::CutConnectors;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ObjectList::is_connectors_item_selected(const wxDataViewItemArray &sels) const
|
||||
{
|
||||
for (auto item : sels)
|
||||
if (m_objects_model->GetItemType(item) == itInfo && m_objects_model->GetInfoItemType(item) == InfoItemType::CutConnectors)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int ObjectList::get_selected_layers_range_idx() const
|
||||
{
|
||||
const wxDataViewItem& item = GetSelection();
|
||||
|
@ -3991,11 +4325,18 @@ void ObjectList::update_selections()
|
|||
else {
|
||||
for (auto idx : selection.get_volume_idxs()) {
|
||||
const auto gl_vol = selection.get_volume(idx);
|
||||
if (gl_vol->volume_idx() >= 0)
|
||||
if (gl_vol->volume_idx() >= 0) {
|
||||
// Only add GLVolumes with non-negative volume_ids. GLVolumes with negative volume ids
|
||||
// are not associated with ModelVolumes, but they are temporarily generated by the backend
|
||||
// (for example, SLA supports or SLA pad).
|
||||
sels.Add(m_objects_model->GetItemByVolumeId(gl_vol->object_idx(), gl_vol->volume_idx()));
|
||||
int obj_idx = gl_vol->object_idx();
|
||||
int vol_idx = gl_vol->volume_idx();
|
||||
assert(obj_idx >= 0 && vol_idx >= 0);
|
||||
if (object(obj_idx)->volumes[vol_idx]->is_cut_connector())
|
||||
sels.Add(m_objects_model->GetInfoItemByType(m_objects_model->GetItemById(obj_idx), InfoItemType::CutConnectors));
|
||||
else
|
||||
sels.Add(m_objects_model->GetItemByVolumeId(obj_idx, vol_idx));
|
||||
}
|
||||
}
|
||||
m_selection_mode = smVolume; }
|
||||
}
|
||||
|
@ -4046,10 +4387,33 @@ void ObjectList::update_selections()
|
|||
if (sels.size() == 0 || m_selection_mode & smSettings)
|
||||
m_selection_mode = smUndef;
|
||||
|
||||
select_items(sels);
|
||||
if (fix_cut_selection(sels) || is_connectors_item_selected(sels)) {
|
||||
m_prevent_list_events = true;
|
||||
|
||||
// Scroll selected Item in the middle of an object list
|
||||
ensure_current_item_visible();
|
||||
// If some part is selected, unselect all items except of selected parts of the current object
|
||||
UnselectAll();
|
||||
SetSelections(sels);
|
||||
|
||||
m_prevent_list_events = false;
|
||||
|
||||
// update object selection on Plater
|
||||
if (!m_prevent_canvas_selection_update)
|
||||
update_selections_on_canvas();
|
||||
|
||||
// to update the toolbar and info sizer
|
||||
if (!GetSelection() || m_objects_model->GetItemType(GetSelection()) == itObject || is_connectors_item_selected()) {
|
||||
auto event = SimpleEvent(EVT_OBJ_LIST_OBJECT_SELECT);
|
||||
event.SetEventObject(this);
|
||||
wxPostEvent(this, event);
|
||||
}
|
||||
part_selection_changed();
|
||||
}
|
||||
else {
|
||||
select_items(sels);
|
||||
|
||||
// Scroll selected Item in the middle of an object list
|
||||
ensure_current_item_visible();
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectList::update_selections_on_canvas()
|
||||
|
@ -4083,16 +4447,27 @@ void ObjectList::update_selections_on_canvas()
|
|||
volume_idxs.insert(volume_idxs.end(), idxs.begin(), idxs.end());
|
||||
}
|
||||
else if (type == itInfo) {
|
||||
// When selecting an info item, select one instance of the
|
||||
// respective object - a gizmo may want to be opened.
|
||||
int inst_idx = selection.get_instance_idx();
|
||||
int scene_obj_idx = selection.get_object_idx();
|
||||
mode = Selection::Instance;
|
||||
// select first instance, unless an instance of the object is already selected
|
||||
if (scene_obj_idx == -1 || inst_idx == -1 || scene_obj_idx != obj_idx)
|
||||
inst_idx = 0;
|
||||
std::vector<unsigned int> idxs = selection.get_volume_idxs_from_instance(obj_idx, inst_idx);
|
||||
volume_idxs.insert(volume_idxs.end(), idxs.begin(), idxs.end());
|
||||
if (m_objects_model->GetInfoItemType(item) == InfoItemType::CutConnectors) {
|
||||
mode = Selection::Volume;
|
||||
|
||||
// When selecting CutConnectors info item, select all object volumes, which are marked as a connector
|
||||
const ModelObject *obj = object(obj_idx);
|
||||
for (unsigned int vol_idx = 0; vol_idx < obj->volumes.size(); vol_idx++)
|
||||
if (obj->volumes[vol_idx]->is_cut_connector()) {
|
||||
std::vector<unsigned int> idxs = selection.get_volume_idxs_from_volume(obj_idx, std::max(instance_idx, 0), vol_idx);
|
||||
volume_idxs.insert(volume_idxs.end(), idxs.begin(), idxs.end());
|
||||
}
|
||||
} else {
|
||||
// When selecting an info item, select one instance of the
|
||||
// respective object - a gizmo may want to be opened.
|
||||
int inst_idx = selection.get_instance_idx();
|
||||
int scene_obj_idx = selection.get_object_idx();
|
||||
mode = Selection::Instance;
|
||||
// select first instance, unless an instance of the object is already selected
|
||||
if (scene_obj_idx == -1 || inst_idx == -1 || scene_obj_idx != obj_idx) inst_idx = 0;
|
||||
std::vector<unsigned int> idxs = selection.get_volume_idxs_from_instance(obj_idx, inst_idx);
|
||||
volume_idxs.insert(volume_idxs.end(), idxs.begin(), idxs.end());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4108,6 +4483,9 @@ void ObjectList::update_selections_on_canvas()
|
|||
|
||||
if (sel_cnt == 1) {
|
||||
wxDataViewItem item = GetSelection();
|
||||
if (m_objects_model->GetInfoItemType(item) == InfoItemType::CutConnectors)
|
||||
selection.remove_all();
|
||||
|
||||
if (m_objects_model->GetItemType(item) & (itSettings | itInstanceRoot | itLayerRoot | itLayer))
|
||||
add_to_selection(m_objects_model->GetParent(item), selection, instance_idx, mode);
|
||||
else
|
||||
|
@ -4434,6 +4812,51 @@ void ObjectList::fix_multiselection_conflicts()
|
|||
m_prevent_list_events = false;
|
||||
}
|
||||
|
||||
void ObjectList::fix_cut_selection()
|
||||
{
|
||||
wxDataViewItemArray sels;
|
||||
GetSelections(sels);
|
||||
if (fix_cut_selection(sels)) {
|
||||
m_prevent_list_events = true;
|
||||
|
||||
// If some part is selected, unselect all items except of selected parts of the current object
|
||||
UnselectAll();
|
||||
SetSelections(sels);
|
||||
|
||||
m_prevent_list_events = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ObjectList::fix_cut_selection(wxDataViewItemArray &sels)
|
||||
{
|
||||
if (wxGetApp().plater()->canvas3D()->get_gizmos_manager().get_current_type() == GLGizmosManager::Scale) {
|
||||
for (const auto &item : sels) {
|
||||
if (m_objects_model->GetItemType(item) & (itInstance | itObject) ||
|
||||
(m_objects_model->GetItemType(item) & itSettings && m_objects_model->GetItemType(m_objects_model->GetParent(item)) & itObject)) {
|
||||
bool is_instance_selection = m_objects_model->GetItemType(item) & itInstance;
|
||||
|
||||
int object_idx = m_objects_model->GetObjectIdByItem(item);
|
||||
int inst_idx = is_instance_selection ? m_objects_model->GetInstanceIdByItem(item) : 0;
|
||||
|
||||
if (auto obj = object(object_idx); obj->is_cut()) {
|
||||
sels.Clear();
|
||||
|
||||
auto cut_id = obj->cut_id;
|
||||
|
||||
int objects_cnt = int((*m_objects).size());
|
||||
for (int obj_idx = 0; obj_idx < objects_cnt; ++obj_idx) {
|
||||
auto object = (*m_objects)[obj_idx];
|
||||
if (object->is_cut() && object->cut_id.has_same_id(cut_id))
|
||||
sels.Add(is_instance_selection ? m_objects_model->GetItemByInstanceId(obj_idx, inst_idx) : m_objects_model->GetItemById(obj_idx));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ModelVolume* ObjectList::get_selected_model_volume()
|
||||
{
|
||||
wxDataViewItem item = GetSelection();
|
||||
|
|
|
@ -286,12 +286,13 @@ public:
|
|||
// BBS
|
||||
void switch_to_object_process();
|
||||
int load_mesh_part(const TriangleMesh &mesh, const wxString &name, const TextInfo &text_info, bool is_temp);
|
||||
void del_object(const int obj_idx, bool refresh_immediately = true);
|
||||
bool del_object(const int obj_idx, bool refresh_immediately = true);
|
||||
void del_subobject_item(wxDataViewItem& item);
|
||||
void del_settings_from_config(const wxDataViewItem& parent_item);
|
||||
void del_instances_from_object(const int obj_idx);
|
||||
void del_layer_from_object(const int obj_idx, const t_layer_height_range& layer_range);
|
||||
void del_layers_from_object(const int obj_idx);
|
||||
bool del_from_cut_object(bool is_connector, bool is_model_part = false, bool is_negative_volume = false);
|
||||
bool del_subobject_from_object(const int obj_idx, const int idx, const int type);
|
||||
void del_info_item(const int obj_idx, InfoItemType type);
|
||||
void split();
|
||||
|
@ -310,6 +311,12 @@ public:
|
|||
bool can_merge_to_multipart_object() const;
|
||||
bool can_merge_to_single_object() const;
|
||||
|
||||
bool has_selected_cut_object() const;
|
||||
void invalidate_cut_info_for_selection();
|
||||
void invalidate_cut_info_for_object(int obj_idx);
|
||||
void delete_all_connectors_for_selection();
|
||||
void delete_all_connectors_for_object(int obj_idx);
|
||||
|
||||
wxPoint get_mouse_position_in_control() const { return wxGetMousePosition() - this->GetScreenPosition(); }
|
||||
int get_selected_obj_idx() const;
|
||||
ModelConfig& get_item_config(const wxDataViewItem& item) const;
|
||||
|
@ -319,6 +326,9 @@ public:
|
|||
|
||||
// Add object to the list
|
||||
void add_object_to_list(size_t obj_idx, bool call_selection_changed = true, bool notify_partplate = true);
|
||||
// Add object's volumes to the list
|
||||
// Return selected items, if add_to_selection is defined
|
||||
wxDataViewItemArray add_volumes_to_object_in_list(size_t obj_idx, std::function<bool(const ModelVolume *)> add_to_selection = nullptr);
|
||||
// Delete object from the list
|
||||
void delete_object_from_list();
|
||||
void delete_object_from_list(const size_t obj_idx);
|
||||
|
@ -326,6 +336,7 @@ public:
|
|||
void delete_instance_from_list(const size_t obj_idx, const size_t inst_idx);
|
||||
void delete_from_model_and_list(const ItemType type, const int obj_idx, const int sub_obj_idx);
|
||||
void delete_from_model_and_list(const std::vector<ItemForDelete>& items_for_delete);
|
||||
void update_lock_icons_for_model();
|
||||
// Delete all objects from the list
|
||||
void delete_all_objects_from_list();
|
||||
// Increase instances count
|
||||
|
@ -368,6 +379,8 @@ public:
|
|||
void init();
|
||||
bool multiple_selection() const ;
|
||||
bool is_selected(const ItemType type) const;
|
||||
bool is_connectors_item_selected() const;
|
||||
bool is_connectors_item_selected(const wxDataViewItemArray &sels) const;
|
||||
int get_selected_layers_range_idx() const;
|
||||
void set_selected_layers_range_idx(const int range_idx) { m_selected_layers_range_idx = range_idx; }
|
||||
void set_selection_mode(SELECTION_MODE mode) { m_selection_mode = mode; }
|
||||
|
@ -385,6 +398,9 @@ public:
|
|||
bool check_last_selection(wxString& msg_str);
|
||||
// correct current selections to avoid of the possible conflicts
|
||||
void fix_multiselection_conflicts();
|
||||
// correct selection in respect to the cut_id if any exists
|
||||
void fix_cut_selection();
|
||||
bool fix_cut_selection(wxDataViewItemArray &sels);
|
||||
|
||||
ModelVolume* get_selected_model_volume();
|
||||
void change_part_type();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,9 +3,15 @@
|
|||
|
||||
#include "GLGizmoBase.hpp"
|
||||
#include "GLGizmoRotate.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
enum class CutConnectorType : int;
|
||||
class ModelVolume;
|
||||
struct CutConnectorAttributes;
|
||||
|
||||
namespace GUI {
|
||||
enum class SLAGizmoEventType : unsigned char;
|
||||
|
||||
class GLGizmoAdvancedCut : public GLGizmoRotate3D
|
||||
{
|
||||
|
@ -42,8 +48,11 @@ private:
|
|||
|
||||
bool m_keep_upper;
|
||||
bool m_keep_lower;
|
||||
bool m_cut_to_parts;
|
||||
bool m_rotate_lower;
|
||||
bool m_place_on_cut_upper{true};
|
||||
bool m_place_on_cut_lower{false};
|
||||
bool m_rotate_upper{false};
|
||||
bool m_rotate_lower{false};
|
||||
|
||||
bool m_do_segment;
|
||||
double m_segment_smoothing_alpha;
|
||||
int m_segment_number;
|
||||
|
@ -54,25 +63,93 @@ private:
|
|||
|
||||
unsigned int m_last_active_id;
|
||||
|
||||
bool m_connectors_editing{false};
|
||||
bool m_show_shortcuts{false};
|
||||
|
||||
std::vector<std::pair<wxString, wxString>> m_shortcuts;
|
||||
double m_label_width{150.0};
|
||||
double m_control_width{ 200.0 };
|
||||
|
||||
CutConnectorType m_connector_type;
|
||||
size_t m_connector_style;
|
||||
size_t m_connector_shape_id;
|
||||
|
||||
float m_connector_depth_ratio{3.f};
|
||||
float m_connector_depth_ratio_tolerance{0.1f};
|
||||
|
||||
float m_connector_size{2.5f};
|
||||
float m_connector_size_tolerance{0.f};
|
||||
|
||||
TriangleMesh m_connector_mesh;
|
||||
bool m_has_invalid_connector{false};
|
||||
|
||||
// remember the connectors which is selected
|
||||
mutable std::vector<bool> m_selected;
|
||||
int m_selected_count{0};
|
||||
|
||||
Vec3d m_cut_plane_center{Vec3d::Zero()};
|
||||
Vec3d m_cut_plane_normal{Vec3d::UnitZ()};
|
||||
|
||||
Vec3d m_cut_line_begin{Vec3d::Zero()};
|
||||
Vec3d m_cut_line_end{Vec3d::Zero()};
|
||||
|
||||
Transform3d m_rotate_matrix{Transform3d::Identity()};
|
||||
|
||||
std::map<CutConnectorAttributes, GLModel> m_shapes;
|
||||
|
||||
struct InvalidConnectorsStatistics
|
||||
{
|
||||
unsigned int outside_cut_contour;
|
||||
unsigned int outside_bb;
|
||||
bool is_overlap;
|
||||
|
||||
void invalidate()
|
||||
{
|
||||
outside_cut_contour = 0;
|
||||
outside_bb = 0;
|
||||
is_overlap = false;
|
||||
}
|
||||
} m_info_stats;
|
||||
|
||||
//GLSelectionRectangle m_selection_rectangle;
|
||||
|
||||
public:
|
||||
GLGizmoAdvancedCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
|
||||
bool gizmo_event(SLAGizmoEventType action, const Vec2d &mouse_position, bool shift_down, bool alt_down, bool control_down);
|
||||
bool on_key(wxKeyEvent &evt);
|
||||
|
||||
double get_movement() const { return m_movement; }
|
||||
void set_movement(double movement) const;
|
||||
void finish_rotation();
|
||||
std::string get_tooltip() const override;
|
||||
|
||||
BoundingBoxf3 bounding_box() const;
|
||||
//BoundingBoxf3 transformed_bounding_box(const Vec3d &plane_center, bool revert_move = false) const;
|
||||
|
||||
bool is_looking_forward() const;
|
||||
|
||||
bool unproject_on_cut_plane(const Vec2d &mouse_pos, Vec3d &pos, Vec3d &pos_world);
|
||||
|
||||
virtual bool apply_clipping_plane() { return m_connectors_editing; }
|
||||
|
||||
protected:
|
||||
virtual bool on_init();
|
||||
virtual void on_load(cereal::BinaryInputArchive &ar) override;
|
||||
virtual void on_save(cereal::BinaryOutputArchive &ar) const override;
|
||||
virtual std::string on_get_name() const;
|
||||
virtual void on_set_state();
|
||||
virtual bool on_is_activable() const;
|
||||
virtual void on_start_dragging();
|
||||
virtual CommonGizmosDataID on_get_requirements() const override;
|
||||
virtual void on_start_dragging() override;
|
||||
virtual void on_stop_dragging() override;
|
||||
virtual void on_update(const UpdateData& data);
|
||||
virtual void on_render();
|
||||
virtual void on_render_for_picking();
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit);
|
||||
|
||||
void show_tooltip_information(float x, float y);
|
||||
|
||||
virtual void on_enable_grabber(unsigned int id)
|
||||
{
|
||||
if (id < 3)
|
||||
|
@ -97,6 +174,12 @@ protected:
|
|||
|
||||
private:
|
||||
void perform_cut(const Selection& selection);
|
||||
bool can_perform_cut() const;
|
||||
void apply_connectors_in_model(ModelObject *mo, bool &create_dowels_as_separate_object);
|
||||
|
||||
bool is_selection_changed(bool alt_down, bool shift_down);
|
||||
void select_connector(int idx, bool select);
|
||||
|
||||
double calc_projection(const Linef3& mouse_ray) const;
|
||||
Vec3d calc_plane_normal(const std::array<Vec3d, 4>& plane_points) const;
|
||||
Vec3d calc_plane_center(const std::array<Vec3d, 4>& plane_points) const;
|
||||
|
@ -107,6 +190,46 @@ private:
|
|||
std::array<Vec3d, 4> get_plane_points_world_coord() const;
|
||||
void reset_cut_plane();
|
||||
void reset_all();
|
||||
|
||||
// update the connectors position so that the connectors are on the cut plane
|
||||
void put_connectors_on_cut_plane(const Vec3d &cp_normal, double cp_offset);
|
||||
void update_clipper();
|
||||
// on render
|
||||
void render_cut_plane_and_grabbers();
|
||||
void render_connectors();
|
||||
void render_clipper_cut();
|
||||
void render_cut_line();
|
||||
void render_connector_model(GLModel &model, const std::array<float, 4>& color, Transform3d view_model_matrix);
|
||||
|
||||
void clear_selection();
|
||||
void init_connector_shapes();
|
||||
void set_connectors_editing(bool connectors_editing);
|
||||
void reset_connectors();
|
||||
void update_connector_shape();
|
||||
void apply_selected_connectors(std::function<void(size_t idx)> apply_fn);
|
||||
void select_all_connectors();
|
||||
void unselect_all_connectors();
|
||||
void validate_connector_settings();
|
||||
bool add_connector(CutConnectors &connectors, const Vec2d &mouse_position);
|
||||
bool delete_selected_connectors();
|
||||
bool is_outside_of_cut_contour(size_t idx, const CutConnectors &connectors, const Vec3d cur_pos);
|
||||
bool is_conflict_for_connector(size_t idx, const CutConnectors &connectors, const Vec3d cur_pos);
|
||||
void check_conflict_for_all_connectors();
|
||||
|
||||
// render input window
|
||||
void render_cut_plane_input_window(float x, float y, float bottom_limit);
|
||||
void init_connectors_input_window_data();
|
||||
void render_connectors_input_window(float x, float y, float bottom_limit);
|
||||
void render_input_window_warning() const;
|
||||
bool render_reset_button(const std::string &label_id, const std::string &tooltip) const;
|
||||
bool render_connect_type_radio_button(CutConnectorType type);
|
||||
|
||||
bool render_combo(const std::string &label, const std::vector<std::string> &lines, size_t &selection_idx);
|
||||
bool render_slider_double_input(const std::string &label, float &value_in, float &tolerance_in);
|
||||
|
||||
bool cut_line_processing() const;
|
||||
void discard_cut_line_processing();
|
||||
bool process_cut_line(SLAGizmoEventType action, const Vec2d &mouse_position);
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
@ -162,6 +162,8 @@ public:
|
|||
virtual std::string get_action_snapshot_name() { return "Gizmo action"; }
|
||||
void set_common_data_pool(CommonGizmosDataPool* ptr) { m_c = ptr; }
|
||||
|
||||
virtual bool apply_clipping_plane() { return true; }
|
||||
|
||||
unsigned int get_sprite_id() const { return m_sprite_id; }
|
||||
|
||||
int get_hover_id() const { return m_hover_id; }
|
||||
|
|
|
@ -336,8 +336,8 @@ bool GLGizmoHollow::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_pos
|
|||
if (action == SLAGizmoEventType::LeftUp) {
|
||||
if (m_wait_for_up_event) {
|
||||
m_wait_for_up_event = false;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// dragging the selection rectangle:
|
||||
|
|
|
@ -83,7 +83,7 @@ bool GLGizmoRotate::on_init()
|
|||
void GLGizmoRotate::on_start_dragging()
|
||||
{
|
||||
const BoundingBoxf3& box = m_parent.get_selection().get_bounding_box();
|
||||
m_center = box.center();
|
||||
m_center = m_custom_center == Vec3d::Zero() ? box.center() : m_custom_center;
|
||||
m_radius = Offset + box.radius();
|
||||
m_snap_coarse_in_radius = m_radius / 3.0f;
|
||||
m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius;
|
||||
|
@ -135,7 +135,7 @@ void GLGizmoRotate::on_render()
|
|||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
|
||||
if (m_hover_id != 0 && !m_grabbers[0].dragging) {
|
||||
m_center = box.center();
|
||||
m_center = m_custom_center == Vec3d::Zero() ? box.center() : m_custom_center;
|
||||
m_radius = Offset + box.radius();
|
||||
m_snap_coarse_in_radius = m_radius / 3.0f;
|
||||
m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius;
|
||||
|
|
|
@ -34,6 +34,7 @@ private:
|
|||
Axis m_axis;
|
||||
double m_angle;
|
||||
|
||||
mutable Vec3d m_custom_center{Vec3d::Zero()};
|
||||
mutable Vec3d m_center;
|
||||
mutable float m_radius;
|
||||
|
||||
|
@ -52,6 +53,8 @@ public:
|
|||
|
||||
std::string get_tooltip() const override;
|
||||
|
||||
void set_center(const Vec3d &point) { m_custom_center = point; }
|
||||
|
||||
protected:
|
||||
bool on_init() override;
|
||||
std::string on_get_name() const override { return ""; }
|
||||
|
@ -101,6 +104,13 @@ public:
|
|||
return tooltip;
|
||||
}
|
||||
|
||||
void set_center(const Vec3d &point)
|
||||
{
|
||||
m_gizmos[X].set_center(point);
|
||||
m_gizmos[Y].set_center(point);
|
||||
m_gizmos[Z].set_center(point);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool on_init() override;
|
||||
std::string on_get_name() const override;
|
||||
|
|
|
@ -63,6 +63,12 @@ std::string GLGizmoScale3D::get_tooltip() const
|
|||
return "";
|
||||
}
|
||||
|
||||
void GLGizmoScale3D::enable_ununiversal_scale(bool enable)
|
||||
{
|
||||
for (unsigned int i = 0; i < 6; ++i)
|
||||
m_grabbers[i].enabled = enable;
|
||||
}
|
||||
|
||||
bool GLGizmoScale3D::on_init()
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
|
@ -228,9 +234,11 @@ void GLGizmoScale3D::on_render()
|
|||
|
||||
// BBS: when select multiple objects, uniform scale can be deselected, display the connection(4,5)
|
||||
//if (single_instance || single_volume) {
|
||||
|
||||
if (m_grabbers[4].enabled && m_grabbers[5].enabled) {
|
||||
glsafe(::glColor4fv(m_grabbers[4].color.data()));
|
||||
render_grabbers_connection(4, 5);
|
||||
//}
|
||||
}
|
||||
|
||||
glsafe(::glColor4fv(m_grabbers[2].color.data()));
|
||||
render_grabbers_connection(6, 7);
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
|
||||
std::string get_tooltip() const override;
|
||||
|
||||
void enable_ununiversal_scale(bool enable);
|
||||
protected:
|
||||
virtual bool on_init() override;
|
||||
virtual std::string on_get_name() const override;
|
||||
|
|
|
@ -427,8 +427,8 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
if (action == SLAGizmoEventType::LeftUp) {
|
||||
if (m_wait_for_up_event) {
|
||||
m_wait_for_up_event = false;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// dragging the selection rectangle:
|
||||
|
|
|
@ -449,7 +449,26 @@ void ObjectClipper::set_position(double pos, bool keep_normal)
|
|||
get_pool()->get_canvas()->set_as_dirty();
|
||||
}
|
||||
|
||||
void ObjectClipper::set_range_and_pos(const Vec3d &cpl_normal, double cpl_offset, double pos)
|
||||
{
|
||||
m_clp.reset(new ClippingPlane(cpl_normal, cpl_offset));
|
||||
m_clp_ratio = pos;
|
||||
get_pool()->get_canvas()->set_as_dirty();
|
||||
}
|
||||
|
||||
bool ObjectClipper::is_projection_inside_cut(const Vec3d &point) const
|
||||
{
|
||||
return m_clp_ratio != 0. && std::any_of(m_clippers.begin(), m_clippers.end(), [point](const auto &cl) {
|
||||
return cl->is_projection_inside_cut(point);
|
||||
});
|
||||
}
|
||||
|
||||
bool ObjectClipper::has_valid_contour() const
|
||||
{
|
||||
return m_clp_ratio != 0. && std::any_of(m_clippers.begin(), m_clippers.end(), [](const auto &cl) {
|
||||
return cl->has_valid_contour();
|
||||
});
|
||||
}
|
||||
|
||||
void SupportsClipper::on_update()
|
||||
{
|
||||
|
|
|
@ -266,6 +266,10 @@ public:
|
|||
ClippingPlane* get_clipping_plane() const { return m_clp.get(); }
|
||||
void render_cut() const;
|
||||
|
||||
void set_range_and_pos(const Vec3d &cpl_normal, double cpl_offset, double pos);
|
||||
|
||||
bool is_projection_inside_cut(const Vec3d &point_in) const;
|
||||
bool has_valid_contour() const;
|
||||
|
||||
protected:
|
||||
void on_update() override;
|
||||
|
|
|
@ -627,6 +627,8 @@ bool GLGizmosManager::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_p
|
|||
return dynamic_cast<GLGizmoMmuSegmentation*>(m_gizmos[MmuSegmentation].get())->gizmo_event(action, mouse_position, shift_down, alt_down, control_down);
|
||||
else if (m_current == Text)
|
||||
return dynamic_cast<GLGizmoText*>(m_gizmos[Text].get())->gizmo_event(action, mouse_position, shift_down, alt_down, control_down);
|
||||
else if (m_current == Cut)
|
||||
return dynamic_cast<GLGizmoAdvancedCut *>(m_gizmos[Cut].get())->gizmo_event(action, mouse_position, shift_down, alt_down, control_down);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
@ -872,7 +874,8 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
m_tooltip.clear();
|
||||
|
||||
if (evt.LeftDown() && (!control_down || grabber_contains_mouse())) {
|
||||
if ((m_current == SlaSupports || m_current == Hollow || m_current == FdmSupports || m_current == Seam || m_current == MmuSegmentation || m_current == Text)
|
||||
if ((m_current == SlaSupports || m_current == Hollow || m_current == FdmSupports ||
|
||||
m_current == Seam || m_current == MmuSegmentation || m_current == Text || m_current == Cut)
|
||||
&& gizmo_event(SLAGizmoEventType::LeftDown, mouse_pos, evt.ShiftDown(), evt.AltDown()))
|
||||
// the gizmo got the event and took some action, there is no need to do anything more
|
||||
processed = true;
|
||||
|
@ -902,7 +905,8 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
// event was taken care of by the SlaSupports gizmo
|
||||
processed = true;
|
||||
}
|
||||
else if (evt.RightDown() && !control_down && selected_object_idx != -1 && (m_current == FdmSupports || m_current == Seam || m_current == MmuSegmentation)
|
||||
else if (evt.RightDown() && !control_down && selected_object_idx != -1
|
||||
&& (m_current == FdmSupports || m_current == Seam || m_current == MmuSegmentation || m_current == Cut)
|
||||
&& gizmo_event(SLAGizmoEventType::RightDown, mouse_pos)) {
|
||||
// event was taken care of by the FdmSupports / Seam / MMUPainting gizmo
|
||||
processed = true;
|
||||
|
@ -911,7 +915,8 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
&& (m_current == SlaSupports || m_current == Hollow || m_current == FdmSupports || m_current == Seam || m_current == MmuSegmentation))
|
||||
// don't allow dragging objects with the Sla gizmo on
|
||||
processed = true;
|
||||
else if (evt.Dragging() && !control_down && (m_current == SlaSupports || m_current == Hollow || m_current == FdmSupports || m_current == Seam || m_current == MmuSegmentation)
|
||||
else if (evt.Dragging() && !control_down
|
||||
&& (m_current == SlaSupports || m_current == Hollow || m_current == FdmSupports || m_current == Seam || m_current == MmuSegmentation || m_current == Cut)
|
||||
&& gizmo_event(SLAGizmoEventType::Dragging, mouse_pos, evt.ShiftDown(), evt.AltDown())) {
|
||||
// the gizmo got the event and took some action, no need to do anything more here
|
||||
m_parent.set_as_dirty();
|
||||
|
@ -924,10 +929,12 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
else if (evt.RightIsDown())
|
||||
gizmo_event(SLAGizmoEventType::RightUp, mouse_pos, evt.ShiftDown(), evt.AltDown(), true);
|
||||
}
|
||||
else if (evt.LeftUp() && (m_current == SlaSupports || m_current == Hollow || m_current == FdmSupports || m_current == Seam || m_current == MmuSegmentation) && !m_parent.is_mouse_dragging()) {
|
||||
else if (evt.LeftUp()
|
||||
&& (m_current == SlaSupports || m_current == Hollow || m_current == FdmSupports || m_current == Seam || m_current == MmuSegmentation || m_current == Cut)
|
||||
&& !m_parent.is_mouse_dragging()
|
||||
&& gizmo_event(SLAGizmoEventType::LeftUp, mouse_pos, evt.ShiftDown(), evt.AltDown(), control_down)) {
|
||||
// in case SLA/FDM gizmo is selected, we just pass the LeftUp event and stop processing - neither
|
||||
// object moving or selecting is suppressed in that case
|
||||
gizmo_event(SLAGizmoEventType::LeftUp, mouse_pos, evt.ShiftDown(), evt.AltDown(), control_down);
|
||||
processed = true;
|
||||
}
|
||||
else if (evt.LeftUp() && m_current == Flatten && m_gizmos[m_current]->get_hover_id() != -1) {
|
||||
|
@ -937,8 +944,9 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
//wxGetApp().obj_manipul()->set_dirty();
|
||||
processed = true;
|
||||
}
|
||||
else if (evt.RightUp() && (m_current == FdmSupports || m_current == Seam || m_current == MmuSegmentation) && !m_parent.is_mouse_dragging()) {
|
||||
gizmo_event(SLAGizmoEventType::RightUp, mouse_pos, evt.ShiftDown(), evt.AltDown(), control_down);
|
||||
else if (evt.RightUp() && (m_current == FdmSupports || m_current == Seam || m_current == MmuSegmentation || m_current == Cut)
|
||||
&& !m_parent.is_mouse_dragging()
|
||||
&& gizmo_event(SLAGizmoEventType::RightUp, mouse_pos, evt.ShiftDown(), evt.AltDown(), control_down)) {
|
||||
processed = true;
|
||||
}
|
||||
else if (evt.LeftUp()) {
|
||||
|
@ -1111,6 +1119,13 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
|
|||
const int keyCode = evt.GetKeyCode();
|
||||
bool processed = false;
|
||||
|
||||
// todo: zhimin Each gizmo should handle key event in it own on_key() function
|
||||
if (m_current == Cut) {
|
||||
if (GLGizmoAdvancedCut *gizmo_cut = dynamic_cast<GLGizmoAdvancedCut *>(get_current())) {
|
||||
return gizmo_cut->on_key(evt);
|
||||
}
|
||||
}
|
||||
|
||||
if (evt.GetEventType() == wxEVT_KEY_UP)
|
||||
{
|
||||
if (m_current == SlaSupports || m_current == Hollow)
|
||||
|
@ -1479,6 +1494,11 @@ GLGizmoBase* GLGizmosManager::get_current() const
|
|||
return ((m_current == Undefined) || m_gizmos.empty()) ? nullptr : m_gizmos[m_current].get();
|
||||
}
|
||||
|
||||
GLGizmoBase* GLGizmosManager::get_gizmo(GLGizmosManager::EType type) const
|
||||
{
|
||||
return ((type == Undefined) || m_gizmos.empty()) ? nullptr : m_gizmos[type].get();
|
||||
}
|
||||
|
||||
GLGizmosManager::EType GLGizmosManager::get_gizmo_from_name(const std::string& gizmo_name) const
|
||||
{
|
||||
std::vector<size_t> selectable_idxs = get_selectable_idxs();
|
||||
|
|
|
@ -230,6 +230,7 @@ public:
|
|||
|
||||
EType get_current_type() const { return m_current; }
|
||||
GLGizmoBase* get_current() const;
|
||||
GLGizmoBase *get_gizmo(GLGizmosManager::EType type) const;
|
||||
EType get_gizmo_from_name(const std::string& gizmo_name) const;
|
||||
|
||||
bool is_running() const;
|
||||
|
@ -311,7 +312,7 @@ public:
|
|||
//BBS: GUI refactor: GLToolbar adjust
|
||||
float get_scaled_total_height() const;
|
||||
float get_scaled_total_width() const;
|
||||
//GizmoObjectManipulation& get_object_manipulation() { return m_object_manipulation; }
|
||||
GizmoObjectManipulation& get_object_manipulation() { return m_object_manipulation; }
|
||||
bool get_uniform_scaling() const { return m_object_manipulation.get_uniform_scaling();}
|
||||
|
||||
private:
|
||||
|
|
|
@ -84,6 +84,10 @@ static const std::map<const wchar_t, std::string> font_icons = {
|
|||
|
||||
{ImGui::TextSearchIcon , "im_text_search" },
|
||||
{ImGui::TextSearchCloseIcon , "im_text_search_close" },
|
||||
|
||||
{ImGui::ExpandBtn , "expand_btn" },
|
||||
{ImGui::CollapseBtn , "collapse_btn" },
|
||||
{ImGui::RevertBtn , "revert_btn" },
|
||||
};
|
||||
static const std::map<const wchar_t, std::string> font_icons_large = {
|
||||
{ImGui::CloseNotifButton , "notification_close" },
|
||||
|
@ -2002,6 +2006,37 @@ void ImGuiWrapper::pop_button_disable_style() {
|
|||
ImGui::PopStyleColor(3);
|
||||
}
|
||||
|
||||
void ImGuiWrapper::push_combo_style(const float scale)
|
||||
{
|
||||
if (m_is_dark_mode) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0f * scale);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f * scale);
|
||||
ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGuiWrapper::COL_WINDOW_BG_DARK);
|
||||
ImGui::PushStyleColor(ImGuiCol_BorderActive, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0.00f, 0.68f, 0.26f, 0.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(0.00f, 0.68f, 0.26f, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.00f, 0.68f, 0.26f, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ScrollbarBg, ImGuiWrapper::COL_WINDOW_BG_DARK);
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, {1.00f, 1.00f, 1.00f, 0.0f});
|
||||
} else {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0f * scale);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f * scale);
|
||||
ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGuiWrapper::COL_WINDOW_BG);
|
||||
ImGui::PushStyleColor(ImGuiCol_BorderActive, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0.00f, 0.68f, 0.26f, 0.5f));
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(0.00f, 0.68f, 0.26f, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.00f, 0.68f, 0.26f, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ScrollbarBg, ImGuiWrapper::COL_WINDOW_BG);
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, {1.00f, 1.00f, 1.00f, 0.0f});
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiWrapper::pop_combo_style()
|
||||
{
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::PopStyleColor(7);
|
||||
}
|
||||
|
||||
void ImGuiWrapper::init_font(bool compress)
|
||||
{
|
||||
destroy_font();
|
||||
|
|
|
@ -213,6 +213,8 @@ public:
|
|||
static void pop_cancel_button_style();
|
||||
static void push_button_disable_style();
|
||||
static void pop_button_disable_style();
|
||||
static void push_combo_style(const float scale);
|
||||
static void pop_combo_style();
|
||||
|
||||
//BBS
|
||||
static int TOOLBAR_WINDOW_FLAGS;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <GL/glew.h>
|
||||
|
||||
#include <igl/unproject.h>
|
||||
#include "CameraUtils.hpp"
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
@ -75,7 +76,24 @@ void MeshClipper::render_cut()
|
|||
m_vertex_array.render();
|
||||
}
|
||||
|
||||
bool MeshClipper::is_projection_inside_cut(const Vec3d &point_in) const
|
||||
{
|
||||
if (!m_result || m_result->cut_islands.empty())
|
||||
return false;
|
||||
Vec3d point = m_result->trafo.inverse() * point_in;
|
||||
Point pt_2d = Point::new_scale(Vec2d(point.x(), point.y()));
|
||||
|
||||
for (const CutIsland &isl : m_result->cut_islands) {
|
||||
if (isl.expoly_bb.contains(pt_2d) && isl.expoly.contains(pt_2d))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MeshClipper::has_valid_contour() const
|
||||
{
|
||||
return m_result && std::any_of(m_result->cut_islands.begin(), m_result->cut_islands.end(), [](const CutIsland &isl) { return !isl.expoly.empty(); });
|
||||
}
|
||||
|
||||
void MeshClipper::recalculate_triangles()
|
||||
{
|
||||
|
@ -104,6 +122,9 @@ void MeshClipper::recalculate_triangles()
|
|||
tr.rotate(q);
|
||||
tr = m_trafo.get_matrix() * tr;
|
||||
|
||||
m_result = ClipResult();
|
||||
m_result->trafo = tr;
|
||||
|
||||
if (m_limiting_plane != ClippingPlane::ClipsNothing())
|
||||
{
|
||||
// Now remove whatever ended up below the limiting plane (e.g. sinking objects).
|
||||
|
@ -157,6 +178,13 @@ void MeshClipper::recalculate_triangles()
|
|||
}
|
||||
}
|
||||
|
||||
for (const ExPolygon &exp : expolys) {
|
||||
m_result->cut_islands.push_back(CutIsland());
|
||||
CutIsland &isl = m_result->cut_islands.back();
|
||||
isl.expoly = std::move(exp);
|
||||
isl.expoly_bb = get_extents(exp);
|
||||
}
|
||||
|
||||
m_triangles2d = triangulate_expolygons_2f(expolys, m_trafo.get_matrix().matrix().determinant() < 0.);
|
||||
|
||||
tr.pretranslate(0.001 * m_plane.get_normal().normalized()); // to avoid z-fighting
|
||||
|
@ -180,6 +208,14 @@ Vec3f MeshRaycaster::get_triangle_normal(size_t facet_idx) const
|
|||
return m_normals[facet_idx];
|
||||
}
|
||||
|
||||
void MeshRaycaster::line_from_mouse_pos_static(const Vec2d &mouse_pos, const Transform3d &trafo, const Camera &camera, Vec3d &point, Vec3d &direction)
|
||||
{
|
||||
CameraUtils::ray_from_screen_pos(camera, mouse_pos, point, direction);
|
||||
Transform3d inv = trafo.inverse();
|
||||
point = inv * point;
|
||||
direction = inv.linear() * direction;
|
||||
}
|
||||
|
||||
void MeshRaycaster::line_from_mouse_pos(const Vec2d& mouse_pos, const Transform3d& trafo, const Camera& camera,
|
||||
Vec3d& point, Vec3d& direction) const
|
||||
{
|
||||
|
|
|
@ -94,6 +94,9 @@ public:
|
|||
// be set in world coords.
|
||||
void render_cut();
|
||||
|
||||
bool is_projection_inside_cut(const Vec3d &point) const;
|
||||
bool has_valid_contour() const;
|
||||
|
||||
private:
|
||||
void recalculate_triangles();
|
||||
|
||||
|
@ -105,6 +108,18 @@ private:
|
|||
std::vector<Vec2f> m_triangles2d;
|
||||
GLIndexedVertexArray m_vertex_array;
|
||||
bool m_triangles_valid = false;
|
||||
|
||||
struct CutIsland
|
||||
{
|
||||
ExPolygon expoly;
|
||||
BoundingBox expoly_bb;
|
||||
};
|
||||
struct ClipResult
|
||||
{
|
||||
std::vector<CutIsland> cut_islands;
|
||||
Transform3d trafo; // this rotates the cut into world coords
|
||||
};
|
||||
std::optional<ClipResult> m_result; // the cut plane
|
||||
};
|
||||
|
||||
|
||||
|
@ -121,6 +136,9 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static void line_from_mouse_pos_static(const Vec2d &mouse_pos, const Transform3d &trafo,
|
||||
const Camera &camera, Vec3d &point, Vec3d &direction);
|
||||
|
||||
void line_from_mouse_pos(const Vec2d& mouse_pos, const Transform3d& trafo, const Camera& camera,
|
||||
Vec3d& point, Vec3d& direction) const;
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ void MsgDialog::SetButtonLabel(wxWindowID btn_id, const wxString& label, bool se
|
|||
|
||||
Button* MsgDialog::add_button(wxWindowID btn_id, bool set_focus /*= false*/, const wxString& label/* = wxString()*/)
|
||||
{
|
||||
Button* btn = new Button(this, label);
|
||||
Button* btn = new Button(this, label, "", 0, 0, btn_id);
|
||||
ButtonSizeType type;
|
||||
|
||||
if (label.length() < 5) {
|
||||
|
|
|
@ -1020,6 +1020,7 @@ void NotificationManager::UpdatedItemsInfoNotification::add_type(InfoItemType ty
|
|||
case InfoItemType::MmuSegmentation: text += format(_L_PLURAL("%1$d Object has color painting.", "%1$d Objects have color painting.",(*it).second), (*it).second) + "\n"; break;
|
||||
// BBS
|
||||
//case InfoItemType::Sinking: text += format(("%1$d Object has partial sinking.", "%1$d Objects have partial sinking.", (*it).second), (*it).second) + "\n"; break;
|
||||
case InfoItemType::CutConnectors: text += format(_L_PLURAL("%1$d object was loaded as a part of cut object.", "%1$d objects were loaded as parts of cut object", (*it).second), (*it).second) + "\n"; break;
|
||||
default: BOOST_LOG_TRIVIAL(error) << "Unknown InfoItemType: " << (*it).second; break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ static constexpr char LayerRootIcon[] = "blank";
|
|||
static constexpr char LayerIcon[] = "blank";
|
||||
static constexpr char WarningIcon[] = "obj_warning";
|
||||
static constexpr char WarningManifoldIcon[] = "obj_warning";
|
||||
static constexpr char LockIcon[] = "cut_";
|
||||
|
||||
ObjectDataViewModelNode::ObjectDataViewModelNode(PartPlate* part_plate, wxString name) :
|
||||
m_parent(nullptr),
|
||||
|
@ -65,6 +66,7 @@ const std::map<InfoItemType, InfoItemAtributes> INFO_ITEMS{
|
|||
//{ InfoItemType::CustomSeam, {L("Paint-on seam"), "seam_" }, },
|
||||
{ InfoItemType::MmuSegmentation, {L("Color painting"), "mmu_segmentation"}, },
|
||||
//{ InfoItemType::Sinking, {L("Sinking"), "objlist_sinking"}, },
|
||||
{ InfoItemType::CutConnectors, {L("Cut connectors"), "cut_connectors" }, },
|
||||
};
|
||||
|
||||
ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
|
||||
|
@ -411,6 +413,7 @@ ObjectDataViewModel::ObjectDataViewModel()
|
|||
m_volume_bmps = MenuFactory::get_volume_bitmaps();
|
||||
m_warning_bmp = create_scaled_bitmap(WarningIcon);
|
||||
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
|
||||
m_lock_bmp = create_scaled_bitmap(LockIcon);
|
||||
|
||||
for (auto item : INFO_ITEMS)
|
||||
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
|
||||
|
@ -490,7 +493,46 @@ wxDataViewItem ObjectDataViewModel::AddOutsidePlate(bool refresh)
|
|||
return plate_item;
|
||||
}
|
||||
|
||||
wxDataViewItem ObjectDataViewModel::AddObject(ModelObject* model_object, std::string warning_bitmap, bool refresh)
|
||||
void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode *node)
|
||||
{
|
||||
int vol_type = static_cast<int>(node->GetVolumeType());
|
||||
bool is_volume_node = vol_type >= 0;
|
||||
|
||||
if (!node->has_warning_icon() && !node->has_lock()) {
|
||||
node->SetBitmap(is_volume_node ? m_volume_bmps.at(vol_type) : m_empty_bmp);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string scaled_bitmap_name = std::string();
|
||||
if (node->has_warning_icon())
|
||||
scaled_bitmap_name += node->warning_icon_name();
|
||||
if (node->has_lock())
|
||||
scaled_bitmap_name += LockIcon;
|
||||
if (is_volume_node)
|
||||
scaled_bitmap_name += std::to_string(vol_type);
|
||||
|
||||
wxBitmap *bmp = m_bitmap_cache->find(scaled_bitmap_name);
|
||||
if (!bmp) {
|
||||
std::vector<wxBitmap> bmps;
|
||||
if (node->has_warning_icon())
|
||||
bmps.emplace_back(node->warning_icon_name() == WarningIcon ? m_warning_bmp : m_warning_manifold_bmp);
|
||||
if (node->has_lock())
|
||||
bmps.emplace_back(m_lock_bmp);
|
||||
if (is_volume_node)
|
||||
bmps.emplace_back(m_volume_bmps[vol_type]);
|
||||
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
|
||||
}
|
||||
|
||||
node->SetBitmap(*bmp);
|
||||
}
|
||||
|
||||
void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode *node, bool has_lock)
|
||||
{
|
||||
node->SetLock(has_lock);
|
||||
UpdateBitmapForNode(node);
|
||||
}
|
||||
|
||||
wxDataViewItem ObjectDataViewModel::AddObject(ModelObject *model_object, std::string warning_bitmap, bool has_lock, bool refresh)
|
||||
{
|
||||
// get object node params
|
||||
wxString name = from_u8(model_object->name);
|
||||
|
@ -512,6 +554,7 @@ wxDataViewItem ObjectDataViewModel::AddObject(ModelObject* model_object, std::st
|
|||
const wxString extruder_str = wxString::Format("%d", extruder);
|
||||
auto obj_node = new ObjectDataViewModelNode(name, extruder_str, plate_idx, model_object);
|
||||
obj_node->SetWarningBitmap(GetWarningBitmap(warning_bitmap), warning_bitmap);
|
||||
UpdateBitmapForNode(obj_node, has_lock);
|
||||
|
||||
if (plate_node != nullptr) {
|
||||
obj_node->m_parent = plate_node;
|
||||
|
@ -2138,6 +2181,7 @@ void ObjectDataViewModel::Rescale()
|
|||
m_volume_bmps = MenuFactory::get_volume_bitmaps();
|
||||
m_warning_bmp = create_scaled_bitmap(WarningIcon);
|
||||
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
|
||||
m_lock_bmp = create_scaled_bitmap(LockIcon);
|
||||
|
||||
for (auto item : INFO_ITEMS)
|
||||
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
|
||||
|
@ -2256,6 +2300,26 @@ void ObjectDataViewModel::UpdateWarningIcon(const wxDataViewItem& item, const st
|
|||
AddWarningIcon(item, warning_icon_name);
|
||||
}
|
||||
|
||||
void ObjectDataViewModel::UpdateCutObjectIcon(const wxDataViewItem &item, bool has_lock)
|
||||
{
|
||||
if (!item.IsOk())
|
||||
return;
|
||||
ObjectDataViewModelNode* node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||
if (node->has_lock() == has_lock)
|
||||
return;
|
||||
|
||||
node->SetLock(has_lock);
|
||||
UpdateBitmapForNode(node);
|
||||
|
||||
if (node->GetType() & itObject) {
|
||||
wxDataViewItemArray children;
|
||||
GetChildren(item, children);
|
||||
for (const wxDataViewItem &child : children)
|
||||
UpdateCutObjectIcon(child, has_lock);
|
||||
}
|
||||
ItemChanged(item);
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ enum class InfoItemType
|
|||
//CustomSeam,
|
||||
MmuSegmentation,
|
||||
//Sinking
|
||||
CutConnectors,
|
||||
};
|
||||
|
||||
class ObjectDataViewModelNode;
|
||||
|
@ -92,6 +93,7 @@ class ObjectDataViewModelNode
|
|||
PrintIndicator m_printable {piUndef};
|
||||
wxBitmap m_printable_icon;
|
||||
std::string m_warning_icon_name{ "" };
|
||||
bool m_has_lock{false}; // for cut object icon
|
||||
|
||||
std::string m_action_icon_name = "";
|
||||
ModelVolumeType m_volume_type;
|
||||
|
@ -224,6 +226,7 @@ public:
|
|||
void SetBitmap(const wxBitmap &icon) { m_bmp = icon; }
|
||||
void SetExtruder(const wxString &extruder) { m_extruder = extruder; }
|
||||
void SetWarningBitmap(const wxBitmap& icon, const std::string& warning_icon_name) { m_bmp = icon; m_warning_icon_name = warning_icon_name; }
|
||||
void SetLock(bool has_lock) { m_has_lock = has_lock; }
|
||||
const wxBitmap& GetBitmap() const { return m_bmp; }
|
||||
const wxString& GetName() const { return m_name; }
|
||||
ItemType GetType() const { return m_type; }
|
||||
|
@ -297,6 +300,8 @@ public:
|
|||
#endif /* NDEBUG */
|
||||
bool invalid() const { return m_idx < -1; }
|
||||
bool has_warning_icon() const { return !m_warning_icon_name.empty(); }
|
||||
std::string warning_icon_name() const { return m_warning_icon_name; }
|
||||
bool has_lock() const { return m_has_lock; }
|
||||
|
||||
private:
|
||||
friend class ObjectDataViewModel;
|
||||
|
@ -319,6 +324,7 @@ class ObjectDataViewModel :public wxDataViewModel
|
|||
wxBitmap m_empty_bmp;
|
||||
wxBitmap m_warning_bmp;
|
||||
wxBitmap m_warning_manifold_bmp;
|
||||
wxBitmap m_lock_bmp;
|
||||
|
||||
ObjectDataViewModelNode* m_plate_outside;
|
||||
|
||||
|
@ -330,7 +336,7 @@ public:
|
|||
void Init();
|
||||
|
||||
wxDataViewItem AddPlate(PartPlate* part_plate, wxString name = wxEmptyString, bool refresh = true);
|
||||
wxDataViewItem AddObject(ModelObject* model_object, std::string warning_bitmap, bool refresh = true);
|
||||
wxDataViewItem AddObject(ModelObject* model_object, std::string warning_bitmap, bool has_lock = false, bool refresh = true);
|
||||
wxDataViewItem AddVolumeChild( const wxDataViewItem &parent_item,
|
||||
const wxString &name,
|
||||
const Slic3r::ModelVolumeType volume_type,
|
||||
|
@ -462,6 +468,7 @@ public:
|
|||
void AddWarningIcon(const wxDataViewItem& item, const std::string& warning_name);
|
||||
void DeleteWarningIcon(const wxDataViewItem& item, const bool unmark_object = false);
|
||||
void UpdateWarningIcon(const wxDataViewItem& item, const std::string& warning_name);
|
||||
void UpdateCutObjectIcon(const wxDataViewItem &item, bool has_cut_icon);
|
||||
bool HasWarningIcon(const wxDataViewItem& item) const;
|
||||
t_layer_height_range GetLayerRangeByItem(const wxDataViewItem& item) const;
|
||||
|
||||
|
@ -482,6 +489,9 @@ private:
|
|||
wxBitmap& GetWarningBitmap(const std::string& warning_icon_name);
|
||||
void ReparentObject(ObjectDataViewModelNode* plate, ObjectDataViewModelNode* object);
|
||||
wxDataViewItem AddOutsidePlate(bool refresh = true);
|
||||
|
||||
void UpdateBitmapForNode(ObjectDataViewModelNode *node);
|
||||
void UpdateBitmapForNode(ObjectDataViewModelNode *node, bool has_lock);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1922,7 +1922,7 @@ struct Plater::priv
|
|||
void select_all();
|
||||
void deselect_all();
|
||||
void remove(size_t obj_idx);
|
||||
void delete_object_from_model(size_t obj_idx, bool refresh_immediately = true); //BBS
|
||||
bool delete_object_from_model(size_t obj_idx, bool refresh_immediately = true); //BBS
|
||||
void delete_all_objects_from_model();
|
||||
void reset(bool apply_presets_change = false);
|
||||
void center_selection();
|
||||
|
@ -4029,13 +4029,31 @@ void Plater::priv::remove(size_t obj_idx)
|
|||
}
|
||||
|
||||
|
||||
void Plater::priv::delete_object_from_model(size_t obj_idx, bool refresh_immediately)
|
||||
bool Plater::priv::delete_object_from_model(size_t obj_idx, bool refresh_immediately)
|
||||
{
|
||||
// check if object isn't cut
|
||||
// show warning message that "cut consistancy" will not be supported any more
|
||||
ModelObject *obj = model.objects[obj_idx];
|
||||
if (obj->is_cut()) {
|
||||
InfoDialog dialog(q, _L("Delete object which is a part of cut object"),
|
||||
_L("You try to delete an object which is a part of a cut object.\n"
|
||||
"This action will break a cut correspondence.\n"
|
||||
"After that model consistency can't be guaranteed."),
|
||||
false, wxYES | wxCANCEL | wxCANCEL_DEFAULT | wxICON_WARNING);
|
||||
dialog.SetButtonLabel(wxID_YES, _L("Delete"));
|
||||
if (dialog.ShowModal() == wxID_CANCEL)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string snapshot_label = "Delete Object";
|
||||
if (! model.objects[obj_idx]->name.empty())
|
||||
snapshot_label += ": " + model.objects[obj_idx]->name;
|
||||
if (!obj->name.empty())
|
||||
snapshot_label += ": " + obj->name;
|
||||
Plater::TakeSnapshot snapshot(q, snapshot_label);
|
||||
m_ui_jobs.cancel_all();
|
||||
|
||||
if (obj->is_cut())
|
||||
sidebar->obj_list()->invalidate_cut_info_for_object(obj_idx);
|
||||
|
||||
model.delete_object(obj_idx);
|
||||
//BBS: notify partplate the instance removed
|
||||
partplate_list.notify_instance_removed(obj_idx, -1);
|
||||
|
@ -4045,6 +4063,8 @@ void Plater::priv::delete_object_from_model(size_t obj_idx, bool refresh_immedia
|
|||
update();
|
||||
object_list_changed();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Plater::priv::delete_all_objects_from_model()
|
||||
|
@ -6825,22 +6845,29 @@ bool Plater::priv::has_assemble_view() const
|
|||
bool Plater::priv::can_scale_to_print_volume() const
|
||||
{
|
||||
const BuildVolume::Type type = this->bed.build_volume().type();
|
||||
return !view3D->get_canvas3d()->get_selection().is_empty() && (type == BuildVolume::Type::Rectangle || type == BuildVolume::Type::Circle);
|
||||
return !sidebar->obj_list()->has_selected_cut_object()
|
||||
&& !view3D->get_canvas3d()->get_selection().is_empty()
|
||||
&& (type == BuildVolume::Type::Rectangle || type == BuildVolume::Type::Circle);
|
||||
}
|
||||
#endif // ENABLE_ENHANCED_PRINT_VOLUME_FIT
|
||||
|
||||
bool Plater::priv::can_mirror() const
|
||||
{
|
||||
return get_selection().is_from_single_instance();
|
||||
return !sidebar->obj_list()->has_selected_cut_object()
|
||||
&& get_selection().is_from_single_instance();
|
||||
}
|
||||
|
||||
bool Plater::priv::can_replace_with_stl() const
|
||||
{
|
||||
return get_selection().get_volume_idxs().size() == 1;
|
||||
return !sidebar->obj_list()->has_selected_cut_object()
|
||||
&& get_selection().get_volume_idxs().size() == 1;
|
||||
}
|
||||
|
||||
bool Plater::priv::can_reload_from_disk() const
|
||||
{
|
||||
if (sidebar->obj_list()->has_selected_cut_object())
|
||||
return false;
|
||||
|
||||
#if ENABLE_RELOAD_FROM_DISK_REWORK
|
||||
// collect selected reloadable ModelVolumes
|
||||
std::vector<std::pair<int, int>> selected_volumes = reloadable_volumes(model, get_selection());
|
||||
|
@ -7049,7 +7076,8 @@ bool Plater::priv::can_increase_instances() const
|
|||
return false;
|
||||
|
||||
int obj_idx = get_selected_object_idx();
|
||||
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size());
|
||||
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size())
|
||||
&& !sidebar->obj_list()->has_selected_cut_object();
|
||||
}
|
||||
|
||||
bool Plater::priv::can_decrease_instances() const
|
||||
|
@ -7059,7 +7087,8 @@ bool Plater::priv::can_decrease_instances() const
|
|||
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);
|
||||
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && (model.objects[obj_idx]->instances.size() > 1)
|
||||
&& !sidebar->obj_list()->has_selected_cut_object();
|
||||
}
|
||||
|
||||
bool Plater::priv::can_split_to_objects() const
|
||||
|
@ -8871,7 +8900,7 @@ void Plater::trigger_restore_project(int skip_confirm)
|
|||
}
|
||||
|
||||
//BBS
|
||||
void Plater::delete_object_from_model(size_t obj_idx, bool refresh_immediately) { p->delete_object_from_model(obj_idx, refresh_immediately); }
|
||||
bool Plater::delete_object_from_model(size_t obj_idx, bool refresh_immediately) { return p->delete_object_from_model(obj_idx, refresh_immediately); }
|
||||
|
||||
//BBS: delete all from model
|
||||
void Plater::delete_all_objects_from_model()
|
||||
|
@ -9083,8 +9112,6 @@ void Plater::cut(size_t obj_idx, size_t instance_idx, std::array<Vec3d, 4> plane
|
|||
if (! attributes.has(ModelObjectCutAttribute::KeepUpper) && ! attributes.has(ModelObjectCutAttribute::KeepLower))
|
||||
return;
|
||||
|
||||
Plater::TakeSnapshot snapshot(this, "Cut by Plane");
|
||||
|
||||
wxBusyCursor wait;
|
||||
// BBS: replace z with plane_points
|
||||
const auto new_objects = object->cut(instance_idx, plane_points, attributes);
|
||||
|
@ -9092,6 +9119,14 @@ void Plater::cut(size_t obj_idx, size_t instance_idx, std::array<Vec3d, 4> plane
|
|||
remove(obj_idx);
|
||||
p->load_model_objects(new_objects);
|
||||
|
||||
// now process all updates of the 3d scene
|
||||
update();
|
||||
|
||||
// Update InfoItems in ObjectList after update() to use of a correct value of the GLCanvas3D::is_sinking(),
|
||||
// which is updated after a view3D->reload_scene(false, flags & (unsigned int)UpdateParams::FORCE_FULL_SCREEN_REFRESH) call
|
||||
for (size_t idx = 0; idx < p->model.objects.size(); idx++)
|
||||
wxGetApp().obj_list()->update_info_items(idx);
|
||||
|
||||
Selection& selection = p->get_selection();
|
||||
size_t last_id = p->model.objects.size() - 1;
|
||||
for (size_t i = 0; i < new_objects.size(); ++i)
|
||||
|
|
|
@ -293,7 +293,7 @@ public:
|
|||
int close_with_confirm(std::function<bool(bool yes_or_no)> second_check = nullptr); // BBS close project
|
||||
//BBS: trigger a restore project event
|
||||
void trigger_restore_project(int skip_confirm = 0);
|
||||
void delete_object_from_model(size_t obj_idx, bool refresh_immediately = true); // BBS support refresh immediately
|
||||
bool delete_object_from_model(size_t obj_idx, bool refresh_immediately = true); // BBS support refresh immediately
|
||||
void delete_all_objects_from_model(); //BBS delete all objects from model
|
||||
void set_selected_visible(bool visible);
|
||||
void remove_selected();
|
||||
|
|
|
@ -36,15 +36,15 @@ Button::Button()
|
|||
std::make_pair(*wxBLACK, (int) StateColor::Normal));
|
||||
}
|
||||
|
||||
Button::Button(wxWindow* parent, wxString text, wxString icon, long style, int iconSize)
|
||||
Button::Button(wxWindow* parent, wxString text, wxString icon, long style, int iconSize, wxWindowID btn_id)
|
||||
: Button()
|
||||
{
|
||||
Create(parent, text, icon, style, iconSize);
|
||||
Create(parent, text, icon, style, iconSize, btn_id);
|
||||
}
|
||||
|
||||
bool Button::Create(wxWindow* parent, wxString text, wxString icon, long style, int iconSize)
|
||||
bool Button::Create(wxWindow* parent, wxString text, wxString icon, long style, int iconSize, wxWindowID btn_id)
|
||||
{
|
||||
StaticBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
|
||||
StaticBox::Create(parent, btn_id, wxDefaultPosition, wxDefaultSize, style);
|
||||
state_handler.attach({&text_color});
|
||||
state_handler.update_binds();
|
||||
//BBS set default font
|
||||
|
|
|
@ -24,9 +24,9 @@ class Button : public StaticBox
|
|||
public:
|
||||
Button();
|
||||
|
||||
Button(wxWindow* parent, wxString text, wxString icon = "", long style = 0, int iconSize = 0);
|
||||
Button(wxWindow* parent, wxString text, wxString icon = "", long style = 0, int iconSize = 0, wxWindowID btn_id = wxID_ANY);
|
||||
|
||||
bool Create(wxWindow* parent, wxString text, wxString icon = "", long style = 0, int iconSize = 0);
|
||||
bool Create(wxWindow* parent, wxString text, wxString icon = "", long style = 0, int iconSize = 0, wxWindowID btn_id = wxID_ANY);
|
||||
|
||||
void SetLabel(const wxString& label) override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue