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"
|
2019-03-19 14:58:18 +00:00
|
|
|
#include "GLCanvas3D.hpp"
|
2018-10-04 14:43:10 +00:00
|
|
|
|
2019-04-29 15:24:05 +00:00
|
|
|
class wxBitmapComboBox;
|
2018-11-23 10:54:06 +00:00
|
|
|
class wxStaticText;
|
2019-04-24 23:45:00 +00:00
|
|
|
class LockButton;
|
2019-04-24 14:04:47 +00:00
|
|
|
class wxStaticBitmap;
|
2018-10-04 14:43:10 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
namespace GUI {
|
|
|
|
|
2019-03-19 12:30:21 +00:00
|
|
|
class Selection;
|
2018-10-04 14:43:10 +00:00
|
|
|
|
|
|
|
class ObjectManipulation : public OG_Settings
|
|
|
|
{
|
2019-01-07 09:53:48 +00:00
|
|
|
struct Cache
|
|
|
|
{
|
|
|
|
Vec3d position;
|
2019-04-24 17:03:05 +00:00
|
|
|
Vec3d position_rounded;
|
2019-01-07 09:53:48 +00:00
|
|
|
Vec3d rotation;
|
2019-04-24 17:03:05 +00:00
|
|
|
Vec3d rotation_rounded;
|
2019-01-07 09:53:48 +00:00
|
|
|
Vec3d scale;
|
2019-04-24 17:03:05 +00:00
|
|
|
Vec3d scale_rounded;
|
2019-01-07 09:53:48 +00:00
|
|
|
Vec3d size;
|
2019-04-24 17:03:05 +00:00
|
|
|
Vec3d size_rounded;
|
2019-01-07 09:53:48 +00:00
|
|
|
|
2019-04-29 16:10:08 +00:00
|
|
|
wxString move_label_string;
|
|
|
|
wxString rotate_label_string;
|
|
|
|
wxString scale_label_string;
|
2019-01-07 09:53:48 +00:00
|
|
|
|
2019-01-28 14:50:02 +00:00
|
|
|
Cache() { reset(); }
|
|
|
|
void reset()
|
2019-01-07 09:53:48 +00:00
|
|
|
{
|
2019-04-24 17:03:05 +00:00
|
|
|
position = position_rounded = Vec3d(DBL_MAX, DBL_MAX, DBL_MAX);
|
|
|
|
rotation = rotation_rounded = Vec3d(DBL_MAX, DBL_MAX, DBL_MAX);
|
|
|
|
scale = scale_rounded = Vec3d(DBL_MAX, DBL_MAX, DBL_MAX);
|
|
|
|
size = size_rounded = Vec3d(DBL_MAX, DBL_MAX, DBL_MAX);
|
2019-04-29 16:10:08 +00:00
|
|
|
move_label_string = wxString();
|
|
|
|
rotate_label_string = wxString();
|
|
|
|
scale_label_string = wxString();
|
2019-01-07 09:53:48 +00:00
|
|
|
}
|
2019-01-28 14:50:02 +00:00
|
|
|
bool is_valid() const { return position != Vec3d(DBL_MAX, DBL_MAX, DBL_MAX); }
|
2019-01-07 09:53:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Cache m_cache;
|
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-09-18 13:10:36 +00:00
|
|
|
wxStaticText* m_item_name = nullptr;
|
|
|
|
wxStaticText* m_empty_str = nullptr;
|
|
|
|
|
2019-05-17 12:17:49 +00:00
|
|
|
// Non-owning pointers to the reset buttons, so we can hide and show them.
|
|
|
|
ScalableButton* m_reset_scale_button = nullptr;
|
|
|
|
ScalableButton* m_reset_rotation_button = nullptr;
|
2019-06-19 08:46:42 +00:00
|
|
|
ScalableButton* m_drop_to_bed_button = nullptr;
|
2019-06-05 09:23:30 +00:00
|
|
|
|
|
|
|
// Mirroring buttons and their current state
|
|
|
|
enum MirrorButtonState {
|
|
|
|
mbHidden,
|
|
|
|
mbShown,
|
|
|
|
mbActive
|
|
|
|
};
|
|
|
|
std::array<std::pair<ScalableButton*, MirrorButtonState>, 3> m_mirror_buttons;
|
|
|
|
|
|
|
|
// Bitmaps for the mirroring buttons.
|
2019-06-03 08:40:15 +00:00
|
|
|
ScalableBitmap m_mirror_bitmap_on;
|
|
|
|
ScalableBitmap m_mirror_bitmap_off;
|
2019-06-05 09:23:30 +00:00
|
|
|
ScalableBitmap m_mirror_bitmap_hidden;
|
2019-05-17 12:17:49 +00:00
|
|
|
|
2018-12-20 19:12:26 +00:00
|
|
|
// Needs to be updated from OnIdle?
|
|
|
|
bool m_dirty = false;
|
|
|
|
// 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;
|
2019-09-18 13:10:36 +00:00
|
|
|
bool m_new_enabled {true};
|
2019-01-24 09:24:10 +00:00
|
|
|
bool m_uniform_scale {true};
|
2019-04-24 09:01:59 +00:00
|
|
|
// Does the object manipulation panel work in World or Local coordinates?
|
|
|
|
bool m_world_coordinates = true;
|
2019-04-24 23:45:00 +00:00
|
|
|
LockButton* m_lock_bnt{ nullptr };
|
2019-04-24 17:03:05 +00:00
|
|
|
wxBitmapComboBox* m_word_local_combo = nullptr;
|
2018-12-20 19:12:26 +00:00
|
|
|
|
2019-04-29 13:27:59 +00:00
|
|
|
ScalableBitmap m_manifold_warning_bmp;
|
2019-04-24 11:33:05 +00:00
|
|
|
wxStaticBitmap* m_fix_throught_netfab_bitmap;
|
|
|
|
|
2019-01-31 13:12:07 +00:00
|
|
|
#ifndef __APPLE__
|
|
|
|
// Currently focused option name (empty if none)
|
|
|
|
std::string m_focused_option;
|
|
|
|
#endif // __APPLE__
|
|
|
|
|
2019-09-18 13:10:36 +00:00
|
|
|
wxFlexGridSizer* m_main_grid_sizer;
|
|
|
|
wxFlexGridSizer* m_labels_grid_sizer;
|
|
|
|
wxFlexGridSizer* m_editors_grid_sizer;
|
|
|
|
|
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;
|
|
|
|
|
2019-05-03 10:36:26 +00:00
|
|
|
void set_dirty() { m_dirty = true; }
|
2018-12-20 19:12:26 +00:00
|
|
|
// Called from the App to update the UI if dirty.
|
|
|
|
void update_if_dirty();
|
|
|
|
|
2019-04-25 07:24:33 +00:00
|
|
|
void set_uniform_scaling(const bool uniform_scale);
|
2019-01-08 12:34:47 +00:00
|
|
|
bool get_uniform_scaling() const { return m_uniform_scale; }
|
2019-04-24 09:01:59 +00:00
|
|
|
// Does the object manipulation panel work in World or Local coordinates?
|
2019-04-24 17:03:05 +00:00
|
|
|
void set_world_coordinates(const bool world_coordinates) { m_world_coordinates = world_coordinates; this->UpdateAndShow(true); }
|
2019-04-24 09:01:59 +00:00
|
|
|
bool get_world_coordinates() const { return m_world_coordinates; }
|
2019-01-08 12:34:47 +00:00
|
|
|
|
2019-01-28 14:50:02 +00:00
|
|
|
void reset_cache() { m_cache.reset(); }
|
2019-01-31 13:12:07 +00:00
|
|
|
#ifndef __APPLE__
|
|
|
|
// On Windows and Linux, emulates a kill focus event on the currently focused option (if any)
|
|
|
|
// Used only in ObjectList wxEVT_DATAVIEW_SELECTION_CHANGED handler which is called before the regular kill focus event
|
|
|
|
// bound to this class when changing selection in the objects list
|
|
|
|
void emulate_kill_focus();
|
|
|
|
#endif // __APPLE__
|
2019-01-28 14:50:02 +00:00
|
|
|
|
2019-09-18 13:10:36 +00:00
|
|
|
void update_item_name(const wxString &item_name);
|
2019-05-02 07:54:18 +00:00
|
|
|
void update_warning_icon_state(const wxString& tooltip);
|
2019-04-29 13:27:59 +00:00
|
|
|
void msw_rescale();
|
2019-04-24 11:33:05 +00:00
|
|
|
|
2018-12-20 19:12:26 +00:00
|
|
|
private:
|
2018-10-08 12:02:12 +00:00
|
|
|
void reset_settings_value();
|
2019-05-03 10:36:26 +00:00
|
|
|
void update_settings_value(const Selection& selection);
|
2018-12-20 19:12:26 +00:00
|
|
|
|
2019-05-17 12:17:49 +00:00
|
|
|
// Show or hide scale/rotation reset buttons if needed
|
|
|
|
void update_reset_buttons_visibility();
|
2019-06-03 08:40:15 +00:00
|
|
|
//Show or hide mirror buttons
|
|
|
|
void update_mirror_buttons_visibility();
|
2018-10-04 14:43:10 +00:00
|
|
|
|
2018-11-14 15:24:36 +00:00
|
|
|
// change values
|
2019-08-01 09:18:11 +00:00
|
|
|
void change_position_value(int axis, double value);
|
|
|
|
void change_rotation_value(int axis, double value);
|
|
|
|
void change_scale_value(int axis, double value);
|
|
|
|
void change_size_value(int axis, double value);
|
|
|
|
void do_scale(int axis, const Vec3d &scale) const;
|
2019-01-31 13:12:07 +00:00
|
|
|
|
2019-04-24 09:01:59 +00:00
|
|
|
void on_change(t_config_option_key opt_key, const boost::any& value);
|
2019-01-31 13:12:07 +00:00
|
|
|
void on_fill_empty_value(const std::string& opt_key);
|
2018-10-04 14:43:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
#endif // slic3r_GUI_ObjectManipulation_hpp_
|