mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
ENABLE_3DCONNEXION_DEVICES -> Refactored Mouse3DController to simplify code
This commit is contained in:
parent
b15757a126
commit
f315681804
2 changed files with 27 additions and 89 deletions
|
@ -24,8 +24,6 @@ class Mouse3DController
|
|||
static const float DefaultRotationScale;
|
||||
|
||||
private:
|
||||
mutable std::mutex m_mutex;
|
||||
|
||||
Vec3d m_translation;
|
||||
Vec3f m_rotation;
|
||||
std::vector<unsigned int> m_buttons;
|
||||
|
@ -36,19 +34,19 @@ class Mouse3DController
|
|||
public:
|
||||
State();
|
||||
|
||||
void set_translation(const Vec3d& translation);
|
||||
void set_rotation(const Vec3f& rotation);
|
||||
void set_button(unsigned int id);
|
||||
void reset_buttons();
|
||||
void set_translation(const Vec3d& translation) { m_translation = translation; }
|
||||
void set_rotation(const Vec3f& rotation) { m_rotation = rotation; }
|
||||
void set_button(unsigned int id) { m_buttons.push_back(id); }
|
||||
void reset_buttons() { return m_buttons.clear(); }
|
||||
|
||||
const Vec3d& get_translation() const;
|
||||
const Vec3f& get_rotation() const;
|
||||
const std::vector<unsigned int>& get_buttons() const;
|
||||
const Vec3d& get_translation() const { return m_translation; }
|
||||
const Vec3f& get_rotation() const { return m_rotation; }
|
||||
const std::vector<unsigned int>& get_buttons() const { return m_buttons; }
|
||||
|
||||
bool has_translation() const;
|
||||
bool has_rotation() const;
|
||||
bool has_translation_or_rotation() const;
|
||||
bool has_any_button() const;
|
||||
bool has_translation() const { return !m_translation.isApprox(Vec3d::Zero()); }
|
||||
bool has_rotation() const { return !m_rotation.isApprox(Vec3f::Zero()); }
|
||||
bool has_translation_or_rotation() const { return !m_translation.isApprox(Vec3d::Zero()) && !m_rotation.isApprox(Vec3f::Zero()); }
|
||||
bool has_any_button() const { return !m_buttons.empty(); }
|
||||
|
||||
double get_translation_scale() const { return m_translation_scale; }
|
||||
void set_translation_scale(double scale) { m_translation_scale = scale; }
|
||||
|
@ -62,6 +60,7 @@ class Mouse3DController
|
|||
|
||||
bool m_initialized;
|
||||
mutable State m_state;
|
||||
std::mutex m_mutex;
|
||||
std::thread m_thread;
|
||||
hid_device* m_device;
|
||||
std::string m_device_str;
|
||||
|
@ -82,7 +81,7 @@ public:
|
|||
bool has_translation_or_rotation() const { return m_state.has_translation_or_rotation(); }
|
||||
bool has_any_button() const { return m_state.has_any_button(); }
|
||||
|
||||
bool apply(Camera& camera) { return m_state.apply(camera); }
|
||||
bool apply(Camera& camera);
|
||||
|
||||
bool is_settings_dialog_shown() const { return m_settings_dialog; }
|
||||
void show_settings_dialog(bool show) { m_settings_dialog = show; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue