2018-10-04 14:43:10 +00:00
|
|
|
#ifndef slic3r_GUI_ObjectManipulation_hpp_
|
|
|
|
#define slic3r_GUI_ObjectManipulation_hpp_
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2018-11-09 17:39:07 +00:00
|
|
|
#include "GUI_ObjectSettings.hpp"
|
2018-10-08 12:02:12 +00:00
|
|
|
#include "GLCanvas3D.hpp"
|
2018-10-04 14:43:10 +00:00
|
|
|
|
2018-11-23 10:54:06 +00:00
|
|
|
class wxStaticText;
|
2018-10-04 14:43:10 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
|
|
|
|
class ObjectManipulation : public OG_Settings
|
|
|
|
{
|
2019-01-02 12:42:29 +00:00
|
|
|
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
2019-01-07 09:53:48 +00:00
|
|
|
struct Cache
|
|
|
|
{
|
|
|
|
Vec3d position;
|
|
|
|
Vec3d rotation;
|
|
|
|
Vec3d scale;
|
|
|
|
Vec3d size;
|
|
|
|
|
|
|
|
std::string move_label_string;
|
|
|
|
std::string rotate_label_string;
|
|
|
|
std::string scale_label_string;
|
|
|
|
|
2019-01-08 08:51:58 +00:00
|
|
|
struct Instance
|
|
|
|
{
|
|
|
|
int object_idx;
|
|
|
|
int instance_idx;
|
|
|
|
Vec3d box_size;
|
|
|
|
|
|
|
|
Instance() { reset(); }
|
|
|
|
void reset() { this->object_idx = -1; this->instance_idx = -1; this->box_size = Vec3d::Zero(); }
|
|
|
|
void set(int object_idx, int instance_idx, const Vec3d& box_size) { this->object_idx = object_idx; this->instance_idx = instance_idx; this->box_size = box_size; }
|
|
|
|
bool matches(int object_idx, int instance_idx) const { return (this->object_idx == object_idx) && (this->instance_idx == instance_idx); }
|
|
|
|
bool matches_object(int object_idx) const { return (this->object_idx == object_idx); }
|
|
|
|
bool matches_instance(int instance_idx) const { return (this->instance_idx == instance_idx); }
|
|
|
|
};
|
2019-01-07 09:53:48 +00:00
|
|
|
|
2019-01-08 08:51:58 +00:00
|
|
|
Instance instance;
|
2019-01-07 09:53:48 +00:00
|
|
|
|
|
|
|
Cache() : position(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX)) , rotation(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX))
|
|
|
|
, scale(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX)) , size(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX))
|
|
|
|
, move_label_string("") , rotate_label_string("") , scale_label_string("")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Cache m_cache;
|
2019-01-02 12:42:29 +00:00
|
|
|
#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
|
2018-12-18 09:10:14 +00:00
|
|
|
|
2018-11-22 14:12:09 +00:00
|
|
|
wxStaticText* m_move_Label = nullptr;
|
2018-12-18 10:11:06 +00:00
|
|
|
wxStaticText* m_scale_Label = nullptr;
|
|
|
|
wxStaticText* m_rotate_Label = nullptr;
|
2018-11-14 15:24:36 +00:00
|
|
|
|
2019-01-02 12:42:29 +00:00
|
|
|
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
2018-12-20 19:12:26 +00:00
|
|
|
// Needs to be updated from OnIdle?
|
|
|
|
bool m_dirty = false;
|
2019-01-02 12:42:29 +00:00
|
|
|
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
2018-12-20 19:12:26 +00:00
|
|
|
// Cached labels for the delayed update, not localized!
|
|
|
|
std::string m_new_move_label_string;
|
|
|
|
std::string m_new_rotate_label_string;
|
|
|
|
std::string m_new_scale_label_string;
|
|
|
|
Vec3d m_new_position;
|
|
|
|
Vec3d m_new_rotation;
|
|
|
|
Vec3d m_new_scale;
|
|
|
|
Vec3d m_new_size;
|
|
|
|
bool m_new_enabled;
|
2019-01-08 12:34:47 +00:00
|
|
|
bool m_uniform_scale {false};
|
2018-12-20 19:12:26 +00:00
|
|
|
|
2018-10-04 14:43:10 +00:00
|
|
|
public:
|
|
|
|
ObjectManipulation(wxWindow* parent);
|
|
|
|
~ObjectManipulation() {}
|
|
|
|
|
2018-11-09 17:39:07 +00:00
|
|
|
void Show(const bool show) override;
|
|
|
|
bool IsShown() override;
|
|
|
|
void UpdateAndShow(const bool show) override;
|
|
|
|
|
2018-12-20 19:12:26 +00:00
|
|
|
void update_settings_value(const GLCanvas3D::Selection& selection);
|
2018-10-04 14:43:10 +00:00
|
|
|
|
2018-12-20 19:12:26 +00:00
|
|
|
// Called from the App to update the UI if dirty.
|
|
|
|
void update_if_dirty();
|
|
|
|
|
2019-01-08 12:34:47 +00:00
|
|
|
void set_uniform_scaling(const bool uniform_scale) { m_uniform_scale = uniform_scale;}
|
|
|
|
bool get_uniform_scaling() const { return m_uniform_scale; }
|
|
|
|
|
2018-12-20 19:12:26 +00:00
|
|
|
private:
|
2018-10-08 12:02:12 +00:00
|
|
|
void reset_settings_value();
|
2018-12-20 19:12:26 +00:00
|
|
|
|
2018-12-18 09:10:14 +00:00
|
|
|
// update size values after scale unit changing or "gizmos"
|
|
|
|
void update_size_value(const Vec3d& size);
|
2018-10-04 14:43:10 +00:00
|
|
|
// update rotation value after "gizmos"
|
|
|
|
void update_rotation_value(const Vec3d& rotation);
|
|
|
|
|
2018-11-14 15:24:36 +00:00
|
|
|
// change values
|
|
|
|
void change_position_value(const Vec3d& position);
|
2018-11-15 10:15:24 +00:00
|
|
|
void change_rotation_value(const Vec3d& rotation);
|
|
|
|
void change_scale_value(const Vec3d& scale);
|
2018-12-18 09:10:14 +00:00
|
|
|
void change_size_value(const Vec3d& size);
|
2018-10-04 14:43:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
#endif // slic3r_GUI_ObjectManipulation_hpp_
|