This commit is contained in:
bubnikv 2019-01-03 12:32:18 +01:00
commit c81ef2f567
5 changed files with 99 additions and 37 deletions

View File

@ -10,41 +10,41 @@
// Log debug messages to console when changing selection // Log debug messages to console when changing selection
#define ENABLE_SELECTION_DEBUG_OUTPUT 0 #define ENABLE_SELECTION_DEBUG_OUTPUT 0
//=============
// 1.42.0 techs
//=============
#define ENABLE_1_42_0 1
// Uses a unique opengl context
#define ENABLE_USE_UNIQUE_GLCONTEXT (1 && ENABLE_1_42_0)
// Disable synchronization of unselected instances
#define DISABLE_INSTANCES_SYNCH (0 && ENABLE_1_42_0)
// Keeps objects on bed while scaling them using the scale gizmo
#define ENABLE_ENSURE_ON_BED_WHILE_SCALING (1 && ENABLE_1_42_0)
// All rotations made using the rotate gizmo are done with respect to the world reference system
#define ENABLE_WORLD_ROTATIONS (1 && ENABLE_1_42_0)
// Scene's GUI made using imgui library
#define ENABLE_IMGUI (1 && ENABLE_1_42_0)
#define DISABLE_MOVE_ROTATE_SCALE_GIZMOS_IMGUI (1 && ENABLE_IMGUI)
// Modified Sla support gizmo
#define ENABLE_SLA_SUPPORT_GIZMO_MOD (1 && ENABLE_1_42_0)
// Removes the wxNotebook from plater
#define ENABLE_REMOVE_TABS_FROM_PLATER (1 && ENABLE_1_42_0)
// Use wxDataViewRender instead of wxDataViewCustomRenderer
#define ENABLE_NONCUSTOM_DATA_VIEW_RENDERING (0 && ENABLE_1_42_0)
// Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active
#define ENABLE_RENDER_SELECTION_CENTER (0 && ENABLE_1_42_0)
// Show visual hints in the 3D scene when sidebar matrix fields have focus
#define ENABLE_SIDEBAR_VISUAL_HINTS (1 && ENABLE_1_42_0)
// Separate rendering for opaque and transparent volumes
#define ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING (1 && ENABLE_1_42_0)
//==================== //====================
// 1.42.0.alpha1 techs // 1.42.0.alpha1 techs
//==================== //====================
#define ENABLE_1_42_0_ALPHA1 1 #define ENABLE_1_42_0_ALPHA1 1
#define ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION (1 && ENABLE_1_42_0_ALPHA1) // Uses a unique opengl context
#define ENABLE_USE_UNIQUE_GLCONTEXT (1 && ENABLE_1_42_0_ALPHA1)
// Disable synchronization of unselected instances
#define DISABLE_INSTANCES_SYNCH (0 && ENABLE_1_42_0_ALPHA1)
// Keeps objects on bed while scaling them using the scale gizmo
#define ENABLE_ENSURE_ON_BED_WHILE_SCALING (1 && ENABLE_1_42_0_ALPHA1)
// All rotations made using the rotate gizmo are done with respect to the world reference system
#define ENABLE_WORLD_ROTATIONS (1 && ENABLE_1_42_0_ALPHA1)
// Scene's GUI made using imgui library
#define ENABLE_IMGUI (1 && ENABLE_1_42_0_ALPHA1)
#define DISABLE_MOVE_ROTATE_SCALE_GIZMOS_IMGUI (1 && ENABLE_IMGUI)
// Modified Sla support gizmo
#define ENABLE_SLA_SUPPORT_GIZMO_MOD (1 && ENABLE_1_42_0_ALPHA1)
// Removes the wxNotebook from plater
#define ENABLE_REMOVE_TABS_FROM_PLATER (1 && ENABLE_1_42_0_ALPHA1)
// Use wxDataViewRender instead of wxDataViewCustomRenderer
#define ENABLE_NONCUSTOM_DATA_VIEW_RENDERING (0 && ENABLE_1_42_0_ALPHA1)
// Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active
#define ENABLE_RENDER_SELECTION_CENTER (0 && ENABLE_1_42_0_ALPHA1)
// Show visual hints in the 3D scene when sidebar matrix fields have focus
#define ENABLE_SIDEBAR_VISUAL_HINTS (1 && ENABLE_1_42_0_ALPHA1)
// Separate rendering for opaque and transparent volumes
#define ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING (1 && ENABLE_1_42_0_ALPHA1)
//====================
// 1.42.0.alpha2 techs
//====================
#define ENABLE_1_42_0_ALPHA2 1
#define ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION (1 && ENABLE_1_42_0_ALPHA2)
#endif // _technologies_h_ #endif // _technologies_h_

View File

@ -3648,6 +3648,10 @@ wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_QUESTION_MARK, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_QUESTION_MARK, SimpleEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_INCREASE_INSTANCES, Event<int>); wxDEFINE_EVENT(EVT_GLCANVAS_INCREASE_INSTANCES, Event<int>);
wxDEFINE_EVENT(EVT_GLCANVAS_INSTANCE_MOVED, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_INSTANCE_MOVED, SimpleEvent);
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
wxDEFINE_EVENT(EVT_GLCANVAS_INSTANCE_ROTATED, SimpleEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_INSTANCE_SCALED, SimpleEvent);
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent); wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>); wxDEFINE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>); wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
@ -5023,6 +5027,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
bool already_selected = m_selection.contains_volume(m_hover_volume_id); bool already_selected = m_selection.contains_volume(m_hover_volume_id);
bool shift_down = evt.ShiftDown(); bool shift_down = evt.ShiftDown();
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
Selection::IndicesList curr_idxs = m_selection.get_volume_idxs();
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
if (already_selected && shift_down) if (already_selected && shift_down)
m_selection.remove(m_hover_volume_id); m_selection.remove(m_hover_volume_id);
else else
@ -5031,11 +5039,21 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_selection.add(m_hover_volume_id, add_as_single); m_selection.add(m_hover_volume_id, add_as_single);
} }
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
if (curr_idxs != m_selection.get_volume_idxs())
{
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
m_gizmos.update_on_off_state(m_selection); m_gizmos.update_on_off_state(m_selection);
_update_gizmos_data(); _update_gizmos_data();
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
wxGetApp().obj_manipul()->update_settings_value(m_selection); wxGetApp().obj_manipul()->update_settings_value(m_selection);
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT)); post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
m_dirty = true; m_dirty = true;
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
}
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
} }
} }
@ -5408,6 +5426,15 @@ void GLCanvas3D::do_move()
ModelObject* model_object = m_model->objects[object_idx]; ModelObject* model_object = m_model->objects[object_idx];
if (model_object != nullptr) if (model_object != nullptr)
{ {
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
if (selection_mode == Selection::Instance)
model_object->instances[instance_idx]->set_offset(v->get_instance_offset());
else if (selection_mode == Selection::Volume)
model_object->volumes[volume_idx]->set_offset(v->get_volume_offset());
object_moved = true;
model_object->invalidate_bounding_box();
#else
if (selection_mode == Selection::Instance) if (selection_mode == Selection::Instance)
{ {
model_object->instances[instance_idx]->set_offset(v->get_instance_offset()); model_object->instances[instance_idx]->set_offset(v->get_instance_offset());
@ -5420,6 +5447,7 @@ void GLCanvas3D::do_move()
} }
if (object_moved) if (object_moved)
model_object->invalidate_bounding_box(); model_object->invalidate_bounding_box();
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
} }
} }
else if (object_idx == 1000) else if (object_idx == 1000)
@ -5490,7 +5518,12 @@ void GLCanvas3D::do_rotate()
m->translate_instance(i.second, shift); m->translate_instance(i.second, shift);
} }
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
if (!done.empty())
post_event(SimpleEvent(EVT_GLCANVAS_INSTANCE_ROTATED));
#else
post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
} }
void GLCanvas3D::do_scale() void GLCanvas3D::do_scale()
@ -5541,7 +5574,12 @@ void GLCanvas3D::do_scale()
m->translate_instance(i.second, shift); m->translate_instance(i.second, shift);
} }
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
if (!done.empty())
post_event(SimpleEvent(EVT_GLCANVAS_INSTANCE_ROTATED));
#else
post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
} }
void GLCanvas3D::do_flatten() void GLCanvas3D::do_flatten()

View File

@ -110,6 +110,10 @@ wxDECLARE_EVENT(EVT_GLCANVAS_QUESTION_MARK, SimpleEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_INCREASE_INSTANCES, Event<int>); // data: +1 => increase, -1 => decrease wxDECLARE_EVENT(EVT_GLCANVAS_INCREASE_INSTANCES, Event<int>); // data: +1 => increase, -1 => decrease
wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_MOVED, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_MOVED, SimpleEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent); wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent);
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_ROTATED, SimpleEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_SCALED, SimpleEvent);
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
wxDECLARE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>); wxDECLARE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event<bool>);
wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>); wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);

View File

@ -413,6 +413,10 @@ void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
canvas->get_selection().start_dragging(); canvas->get_selection().start_dragging();
canvas->get_selection().rotate(rad_rotation, selection.is_single_full_instance()); canvas->get_selection().rotate(rad_rotation, selection.is_single_full_instance());
canvas->do_rotate(); canvas->do_rotate();
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
m_cache_rotation = rotation;
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
} }
void ObjectManipulation::change_scale_value(const Vec3d& scale) void ObjectManipulation::change_scale_value(const Vec3d& scale)
@ -443,6 +447,10 @@ void ObjectManipulation::change_scale_value(const Vec3d& scale)
canvas->get_selection().start_dragging(); canvas->get_selection().start_dragging();
canvas->get_selection().scale(scaling_factor, false); canvas->get_selection().scale(scaling_factor, false);
canvas->do_scale(); canvas->do_scale();
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
m_cache_scale = scale;
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
} }
void ObjectManipulation::change_size_value(const Vec3d& size) void ObjectManipulation::change_size_value(const Vec3d& size)
@ -457,6 +465,10 @@ void ObjectManipulation::change_size_value(const Vec3d& size)
} }
change_scale_value(100.0 * Vec3d(size(0) / ref_size(0), size(1) / ref_size(1), size(2) / ref_size(2))); change_scale_value(100.0 * Vec3d(size(0) / ref_size(0), size(1) / ref_size(1), size(2) / ref_size(2)));
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
m_cache_size = size;
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
} }
} //namespace GUI } //namespace GUI

View File

@ -936,6 +936,7 @@ struct Plater::priv
static const std::regex pattern_bundle; static const std::regex pattern_bundle;
static const std::regex pattern_3mf; static const std::regex pattern_3mf;
static const std::regex pattern_zip_amf; static const std::regex pattern_zip_amf;
static const std::regex pattern_any_amf;
priv(Plater *q, MainFrame *main_frame); priv(Plater *q, MainFrame *main_frame);
@ -1051,6 +1052,8 @@ private:
const std::regex Plater::priv::pattern_bundle(".*[.](amf|amf[.]xml|zip[.]amf|3mf|prusa)", std::regex::icase); const std::regex Plater::priv::pattern_bundle(".*[.](amf|amf[.]xml|zip[.]amf|3mf|prusa)", std::regex::icase);
const std::regex Plater::priv::pattern_3mf(".*3mf", std::regex::icase); const std::regex Plater::priv::pattern_3mf(".*3mf", std::regex::icase);
const std::regex Plater::priv::pattern_zip_amf(".*[.]zip[.]amf", std::regex::icase); const std::regex Plater::priv::pattern_zip_amf(".*[.]zip[.]amf", std::regex::icase);
const std::regex Plater::priv::pattern_any_amf(".*[.](amf|amf[.]xml|zip[.]amf)", std::regex::icase);
Plater::priv::priv(Plater *q, MainFrame *main_frame) Plater::priv::priv(Plater *q, MainFrame *main_frame)
: q(q) : q(q)
, main_frame(main_frame) , main_frame(main_frame)
@ -1196,6 +1199,10 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
{ if (evt.data == 1) this->q->increase_instances(); else if (this->can_decrease_instances()) this->q->decrease_instances(); }); { if (evt.data == 1) this->q->increase_instances(); else if (this->can_decrease_instances()) this->q->decrease_instances(); });
view3D_canvas->Bind(EVT_GLCANVAS_INSTANCE_MOVED, [this](SimpleEvent&) { update(); }); view3D_canvas->Bind(EVT_GLCANVAS_INSTANCE_MOVED, [this](SimpleEvent&) { update(); });
view3D_canvas->Bind(EVT_GLCANVAS_WIPETOWER_MOVED, &priv::on_wipetower_moved, this); view3D_canvas->Bind(EVT_GLCANVAS_WIPETOWER_MOVED, &priv::on_wipetower_moved, this);
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
view3D_canvas->Bind(EVT_GLCANVAS_INSTANCE_ROTATED, [this](SimpleEvent&) { update(); });
view3D_canvas->Bind(EVT_GLCANVAS_INSTANCE_SCALED, [this](SimpleEvent&) { update(); });
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
view3D_canvas->Bind(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, [this](Event<bool> &evt) { this->sidebar->enable_buttons(evt.data); }); view3D_canvas->Bind(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, [this](Event<bool> &evt) { this->sidebar->enable_buttons(evt.data); });
view3D_canvas->Bind(EVT_GLCANVAS_UPDATE_GEOMETRY, &priv::on_update_geometry, this); view3D_canvas->Bind(EVT_GLCANVAS_UPDATE_GEOMETRY, &priv::on_update_geometry, this);
view3D_canvas->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, &priv::on_3dcanvas_mouse_dragging_finished, this); view3D_canvas->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, &priv::on_3dcanvas_mouse_dragging_finished, this);
@ -1396,6 +1403,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
const bool type_3mf = std::regex_match(path.string(), pattern_3mf); const bool type_3mf = std::regex_match(path.string(), pattern_3mf);
const bool type_zip_amf = !type_3mf && std::regex_match(path.string(), pattern_zip_amf); const bool type_zip_amf = !type_3mf && std::regex_match(path.string(), pattern_zip_amf);
const bool type_any_amf = !type_3mf && std::regex_match(path.string(), pattern_any_amf);
Slic3r::Model model; Slic3r::Model model;
try { try {
@ -1451,7 +1459,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
} }
} }
if (type_3mf) { if (type_3mf || type_any_amf) {
for (ModelObject* model_object : model.objects) { for (ModelObject* model_object : model.objects) {
model_object->center_around_origin(); model_object->center_around_origin();
model_object->ensure_on_bed(); model_object->ensure_on_bed();