ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION set as default

This commit is contained in:
Enrico Turri 2019-01-28 16:06:44 +01:00
parent 1c0bc8a5f3
commit 6137cc48eb
6 changed files with 0 additions and 134 deletions

View File

@ -32,8 +32,6 @@
//====================
#define ENABLE_1_42_0_ALPHA2 1
// Improves navigation between sidebar fields
#define ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION (1 && ENABLE_1_42_0_ALPHA2)
// Adds print bed models to 3D scene
#define ENABLE_PRINT_BED_MODELS (1 && ENABLE_1_42_0_ALPHA2)
#endif // _technologies_h_

View File

@ -1618,10 +1618,8 @@ void GLCanvas3D::Selection::clear()
_update_type();
m_bounding_box_dirty = true;
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
// resets the cache in the sidebar
wxGetApp().obj_manipul()->reset_cache();
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
}
// Update the selection based on the map from old indices to new indices after m_volumes changed.
@ -3987,10 +3985,8 @@ wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_QUESTION_MARK, SimpleEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_INCREASE_INSTANCES, Event<int>);
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_ENABLE_ACTION_BUTTONS, Event<bool>);
wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
@ -5317,9 +5313,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
bool already_selected = m_selection.contains_volume(m_hover_volume_id);
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)
m_selection.remove(m_hover_volume_id);
@ -5336,21 +5330,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
#endif // ENABLE_MOVE_MIN_THRESHOLD
}
#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);
_update_gizmos_data();
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
wxGetApp().obj_manipul()->update_settings_value(m_selection);
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
m_dirty = true;
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
}
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
}
}
@ -5740,7 +5727,6 @@ void GLCanvas3D::do_move()
ModelObject* model_object = m_model->objects[object_idx];
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)
@ -5748,20 +5734,6 @@ void GLCanvas3D::do_move()
object_moved = true;
model_object->invalidate_bounding_box();
#else
if (selection_mode == Selection::Instance)
{
model_object->instances[instance_idx]->set_offset(v->get_instance_offset());
object_moved = true;
}
else if (selection_mode == Selection::Volume)
{
model_object->volumes[volume_idx]->set_offset(v->get_volume_offset());
object_moved = true;
}
if (object_moved)
model_object->invalidate_bounding_box();
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
}
}
else if (object_idx == 1000)
@ -5832,12 +5804,8 @@ void GLCanvas3D::do_rotate()
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));
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
}
void GLCanvas3D::do_scale()
@ -5888,12 +5856,8 @@ void GLCanvas3D::do_scale()
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));
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
}
void GLCanvas3D::do_flatten()

View File

@ -125,10 +125,8 @@ wxDECLARE_EVENT(EVT_GLCANVAS_QUESTION_MARK, SimpleEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_INCREASE_INSTANCES, Event<int>); // data: +1 => increase, -1 => decrease
wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_MOVED, SimpleEvent);
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_UPDATE_GEOMETRY, Vec3dsEvent<2>);
wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);

View File

@ -23,13 +23,11 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
m_og->set_grid_vgap(5);
m_og->m_on_change = [this](const std::string& opt_key, const boost::any& value) {
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
// needed to hide the visual hints in 3D scene
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
if (!m_cache.is_valid())
return;
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
std::vector<std::string> axes{ "_x", "_y", "_z" };
@ -49,23 +47,15 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
change_scale_value(new_value);
else if (param == "size")
change_size_value(new_value);
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
};
m_og->m_fill_empty_value = [this](const std::string& opt_key)
{
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
// needed to hide the visual hints in 3D scene
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
if (!m_cache.is_valid())
return;
#else
this->update_if_dirty();
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
std::string param;
std::copy(opt_key.begin(), opt_key.end() - 2, std::back_inserter(param));
@ -98,16 +88,10 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
}
m_og->set_value(opt_key, double_to_string(value));
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
};
m_og->m_set_focus = [this](const std::string& opt_key)
{
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
this->update_if_dirty();
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
// needed to show the visual hints in 3D scene
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, true);
};
@ -228,9 +212,6 @@ void ObjectManipulation::UpdateAndShow(const bool show)
{
if (show) {
update_settings_value(wxGetApp().plater()->canvas3D()->get_selection());
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
update_if_dirty();
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
}
OG_Settings::UpdateAndShow(show);
@ -249,7 +230,6 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele
m_new_rotation = volume->get_instance_rotation();
m_new_scale = volume->get_instance_scaling_factor();
int obj_idx = volume->object_idx();
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
int instance_idx = volume->instance_idx();
if ((0 <= obj_idx) && (obj_idx < (int)wxGetApp().model_objects()->size()))
{
@ -265,21 +245,12 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele
else
// this should never happen
m_new_size = Vec3d::Zero();
#else
if ((0 <= obj_idx) && (obj_idx < (int)wxGetApp().model_objects()->size()))
m_new_size = volume->get_instance_transformation().get_matrix(true, true) * (*wxGetApp().model_objects())[obj_idx]->raw_mesh_bounding_box().size();
else
// this should never happen
m_new_size = Vec3d::Zero();
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
m_new_enabled = true;
}
else if (selection.is_single_full_object())
{
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
m_cache.instance.reset();
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
const BoundingBoxf3& box = selection.get_bounding_box();
m_new_position = box.center();
@ -292,9 +263,7 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele
}
else if (selection.is_single_modifier() || selection.is_single_volume())
{
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
m_cache.instance.reset();
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
// the selection contains a single volume
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
@ -324,7 +293,6 @@ void ObjectManipulation::update_if_dirty()
if (!m_dirty)
return;
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
if (m_cache.move_label_string != _(m_new_move_label_string)+ ":")
{
m_cache.move_label_string = _(m_new_move_label_string)+ ":";
@ -401,37 +369,6 @@ void ObjectManipulation::update_if_dirty()
m_og->enable();
else
m_og->disable();
#else
m_move_Label->SetLabel(_(m_new_move_label_string));
m_rotate_Label->SetLabel(_(m_new_rotate_label_string));
m_scale_Label->SetLabel(_(m_new_scale_label_string));
m_og->set_value("position_x", double_to_string(m_new_position(0), 2));
m_og->set_value("position_y", double_to_string(m_new_position(1), 2));
m_og->set_value("position_z", double_to_string(m_new_position(2), 2));
m_cache_position = m_new_position;
auto scale = m_new_scale * 100.0;
m_og->set_value("scale_x", double_to_string(scale(0), 2));
m_og->set_value("scale_y", double_to_string(scale(1), 2));
m_og->set_value("scale_z", double_to_string(scale(2), 2));
m_cache_scale = scale;
m_og->set_value("size_x", double_to_string(m_new_size(0), 2));
m_og->set_value("size_y", double_to_string(m_new_size(1), 2));
m_og->set_value("size_z", double_to_string(m_new_size(2), 2));
m_cache_size = m_new_size;
m_og->set_value("rotation_x", double_to_string(round_nearest(Geometry::rad2deg(m_new_rotation(0)), 0), 2));
m_og->set_value("rotation_y", double_to_string(round_nearest(Geometry::rad2deg(m_new_rotation(1)), 0), 2));
m_og->set_value("rotation_z", double_to_string(round_nearest(Geometry::rad2deg(m_new_rotation(2)), 0), 2));
m_cache_rotation = m_new_rotation;
if (m_new_enabled)
m_og->enable();
else
m_og->disable();
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
m_dirty = false;
}
@ -443,9 +380,7 @@ void ObjectManipulation::reset_settings_value()
m_new_scale = Vec3d::Ones();
m_new_size = Vec3d::Zero();
m_new_enabled = false;
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
m_cache.instance.reset();
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
m_dirty = true;
}
@ -472,16 +407,10 @@ void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
}
canvas->get_selection().start_dragging();
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
canvas->get_selection().rotate(rad_rotation, selection.is_single_full_instance() || selection.requires_local_axes());
#else
canvas->get_selection().rotate(rad_rotation, selection.is_single_full_instance());
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
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)
@ -513,12 +442,10 @@ void ObjectManipulation::change_scale_value(const Vec3d& scale)
canvas->get_selection().scale(scaling_factor, false);
canvas->do_scale();
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
if (!m_cache.scale.isApprox(scale))
m_cache.instance.instance_idx = -1;
m_cache.scale = scale;
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
}
void ObjectManipulation::change_size_value(const Vec3d& size)
@ -526,7 +453,6 @@ void ObjectManipulation::change_size_value(const Vec3d& size)
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
Vec3d ref_size = m_cache.size;
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
if (selection.is_single_volume() || selection.is_single_modifier())
{
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
@ -564,15 +490,6 @@ void ObjectManipulation::change_size_value(const Vec3d& size)
canvas->do_scale();
m_cache.size = size;
#else
if (selection.is_single_full_instance())
{
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
ref_size = volume->bounding_box.size();
}
change_scale_value(100.0 * Vec3d(size(0) / ref_size(0), size(1) / ref_size(1), size(2) / ref_size(2)));
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
}
} //namespace GUI

View File

@ -15,7 +15,6 @@ namespace GUI {
class ObjectManipulation : public OG_Settings
{
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
struct Cache
{
Vec3d position;
@ -59,12 +58,6 @@ class ObjectManipulation : public OG_Settings
};
Cache m_cache;
#else
Vec3d m_cache_position{ 0., 0., 0. };
Vec3d m_cache_rotation{ 0., 0., 0. };
Vec3d m_cache_scale{ 100., 100., 100. };
Vec3d m_cache_size{ 0., 0., 0. };
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
wxStaticText* m_move_Label = nullptr;
wxStaticText* m_scale_Label = nullptr;
@ -100,9 +93,7 @@ public:
void set_uniform_scaling(const bool uniform_scale) { m_uniform_scale = uniform_scale;}
bool get_uniform_scaling() const { return m_uniform_scale; }
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
void reset_cache() { m_cache.reset(); }
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
private:
void reset_settings_value();

View File

@ -1175,10 +1175,8 @@ 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(); });
view3D_canvas->Bind(EVT_GLCANVAS_INSTANCE_MOVED, [this](SimpleEvent&) { update(); });
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_UPDATE_GEOMETRY, &priv::on_update_geometry, this);
view3D_canvas->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, &priv::on_3dcanvas_mouse_dragging_finished, this);