NEW: add gizmo function of Measure
Jira: STUDIO-6166 Referenced some code from PrusaSlicer,and i made some improvements: Change the measurement object to a local coordinate system and support measurement of multiple model_objects thanks for PrusaSlicer and enricoturri1966 commit 928a642eb94ae8f04aee26e8242deb836cc1d3c3 Author: enricoturri1966 <enricoturri@seznam.cz> Date: Fri Sep 2 11:24:06 2022 +0200 Measuring: Added features selection in GLGizmoMeasure Change-Id: I9cec73398f0cdbd9a7718cb1d52145bf2562d9e1
This commit is contained in:
parent
01a4f7df62
commit
023c1ef7cb
|
@ -491,7 +491,7 @@ void MeasuringImpl::extract_features(int plane_idx)
|
||||||
Vec3d cog = Vec3d::Zero();
|
Vec3d cog = Vec3d::Zero();
|
||||||
size_t counter = 0;
|
size_t counter = 0;
|
||||||
for (const std::vector<Vec3d>& b : plane.borders) {
|
for (const std::vector<Vec3d>& b : plane.borders) {
|
||||||
for (size_t i = 1; i < b.size(); ++i) {
|
for (size_t i = 0; i < b.size(); ++i) {
|
||||||
cog += b[i];
|
cog += b[i];
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
|
@ -931,8 +931,6 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||||
result.distance_infinite = std::make_optional(DistAndPoints{it->dist, it->from, it->to});
|
result.distance_infinite = std::make_optional(DistAndPoints{it->dist, it->from, it->to});
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
} else if (f2.get_type() == SurfaceFeatureType::Plane) {
|
} else if (f2.get_type() == SurfaceFeatureType::Plane) {
|
||||||
assert(measuring != nullptr);
|
|
||||||
|
|
||||||
const auto [from, to] = f1.get_edge();
|
const auto [from, to] = f1.get_edge();
|
||||||
const auto [idx, normal, origin] = f2.get_plane();
|
const auto [idx, normal, origin] = f2.get_plane();
|
||||||
|
|
||||||
|
@ -1190,14 +1188,12 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info.sqrDistance = distance * distance + N0dD * N0dD;
|
info.sqrDistance = distance * distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.distance_infinite = std::make_optional(DistAndPoints{ std::sqrt(candidates[0].sqrDistance), candidates[0].circle0Closest, candidates[0].circle1Closest }); // TODO
|
result.distance_infinite = std::make_optional(DistAndPoints{ std::sqrt(candidates[0].sqrDistance), candidates[0].circle0Closest, candidates[0].circle1Closest }); // TODO
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
} else if (f2.get_type() == SurfaceFeatureType::Plane) {
|
} else if (f2.get_type() == SurfaceFeatureType::Plane) {
|
||||||
assert(measuring != nullptr);
|
|
||||||
|
|
||||||
const auto [center, radius, normal1] = f1.get_circle();
|
const auto [center, radius, normal1] = f1.get_circle();
|
||||||
const auto [idx2, normal2, origin2] = f2.get_plane();
|
const auto [idx2, normal2, origin2] = f2.get_plane();
|
||||||
|
|
||||||
|
@ -1289,12 +1285,46 @@ void SurfaceFeature::translate(const Transform3d &tran)
|
||||||
}
|
}
|
||||||
case Measure::SurfaceFeatureType::Plane: {
|
case Measure::SurfaceFeatureType::Plane: {
|
||||||
// m_pt1 is normal;
|
// m_pt1 is normal;
|
||||||
|
Vec3d temp_pt1 = m_pt2 + m_pt1;
|
||||||
|
temp_pt1 = tran * temp_pt1;
|
||||||
m_pt2 = tran * m_pt2;
|
m_pt2 = tran * m_pt2;
|
||||||
|
m_pt1 = (temp_pt1 - m_pt2).normalized();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Measure::SurfaceFeatureType::Circle: {
|
case Measure::SurfaceFeatureType::Circle: {
|
||||||
m_pt1 = tran * m_pt1;
|
// m_pt1 is center;
|
||||||
// m_pt2 is normal;
|
// m_pt2 is normal;
|
||||||
|
auto local_normal = m_pt2;
|
||||||
|
auto local_center = m_pt1;
|
||||||
|
Vec3d temp_pt2 = local_normal + local_center;
|
||||||
|
temp_pt2 = tran * temp_pt2;
|
||||||
|
m_pt1 = tran * m_pt1;
|
||||||
|
auto world_center = m_pt1;
|
||||||
|
m_pt2 = (temp_pt2 - m_pt1).normalized();
|
||||||
|
auto get_point_projection_to_plane = [](const Vec3d& pt, const Vec3d& plane_origin, const Vec3d& plane_normal,Vec3d& intersection_pt )->bool {
|
||||||
|
auto normal = plane_normal.normalized();
|
||||||
|
auto BA=plane_origin-pt;
|
||||||
|
auto length = BA.dot(normal);
|
||||||
|
intersection_pt = pt + length * normal;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
auto calc_world_radius = [&local_center, &local_normal, &tran, &world_center, &get_point_projection_to_plane](const Vec3d &pt, double &value) {
|
||||||
|
Vec3d intersection_pt;
|
||||||
|
get_point_projection_to_plane(pt, local_center, local_normal, intersection_pt);
|
||||||
|
auto local_radius_pt = (intersection_pt - local_center).normalized() * value + local_center;
|
||||||
|
auto radius_pt = tran * local_radius_pt;
|
||||||
|
value = (radius_pt - world_center).norm();
|
||||||
|
};
|
||||||
|
//m_value is radius
|
||||||
|
float eps = 1e-2;
|
||||||
|
if ((local_normal-Vec3d(1,0,0)).norm()<1e-2) {
|
||||||
|
Vec3d new_pt = local_center + Vec3d(0, 1, 0);
|
||||||
|
calc_world_radius(new_pt, m_value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Vec3d new_pt= local_center + Vec3d(1, 0, 0);
|
||||||
|
calc_world_radius(new_pt,m_value);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
|
|
|
@ -137,6 +137,8 @@ set(SLIC3R_GUI_SOURCES
|
||||||
GUI/Gizmos/GLGizmoMmuSegmentation.hpp
|
GUI/Gizmos/GLGizmoMmuSegmentation.hpp
|
||||||
GUI/Gizmos/GLGizmoFaceDetector.cpp
|
GUI/Gizmos/GLGizmoFaceDetector.cpp
|
||||||
GUI/Gizmos/GLGizmoFaceDetector.hpp
|
GUI/Gizmos/GLGizmoFaceDetector.hpp
|
||||||
|
GUI/Gizmos/GLGizmoMeasure.cpp
|
||||||
|
GUI/Gizmos/GLGizmoMeasure.hpp
|
||||||
GUI/Gizmos/GLGizmoSeam.cpp
|
GUI/Gizmos/GLGizmoSeam.cpp
|
||||||
GUI/Gizmos/GLGizmoSeam.hpp
|
GUI/Gizmos/GLGizmoSeam.hpp
|
||||||
GUI/Gizmos/GLGizmoText.cpp
|
GUI/Gizmos/GLGizmoText.cpp
|
||||||
|
|
|
@ -200,7 +200,7 @@ public:
|
||||||
void set_common_data_pool(CommonGizmosDataPool* ptr) { m_c = ptr; }
|
void set_common_data_pool(CommonGizmosDataPool* ptr) { m_c = ptr; }
|
||||||
|
|
||||||
virtual bool apply_clipping_plane() { return true; }
|
virtual bool apply_clipping_plane() { return true; }
|
||||||
|
virtual bool on_mouse(const wxMouseEvent &mouse_event) { return false; }
|
||||||
unsigned int get_sprite_id() const { return m_sprite_id; }
|
unsigned int get_sprite_id() const { return m_sprite_id; }
|
||||||
|
|
||||||
int get_hover_id() const { return m_hover_id; }
|
int get_hover_id() const { return m_hover_id; }
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,209 @@
|
||||||
|
#ifndef slic3r_GLGizmoMeasure_hpp_
|
||||||
|
#define slic3r_GLGizmoMeasure_hpp_
|
||||||
|
|
||||||
|
#include "GLGizmoBase.hpp"
|
||||||
|
#include "slic3r/GUI/GLModel.hpp"
|
||||||
|
#include "slic3r/GUI/GUI_Utils.hpp"
|
||||||
|
#include "slic3r/GUI/I18N.hpp"
|
||||||
|
#include "libslic3r/Measure.hpp"
|
||||||
|
#include "libslic3r/Model.hpp"
|
||||||
|
|
||||||
|
namespace Slic3r {
|
||||||
|
|
||||||
|
enum class ModelVolumeType : int;
|
||||||
|
namespace Measure { class Measuring; }
|
||||||
|
namespace GUI {
|
||||||
|
|
||||||
|
enum class SLAGizmoEventType : unsigned char;
|
||||||
|
|
||||||
|
class GLGizmoMeasure : public GLGizmoBase
|
||||||
|
{
|
||||||
|
enum class EMode : unsigned char
|
||||||
|
{
|
||||||
|
FeatureSelection,
|
||||||
|
PointSelection
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SelectedFeatures
|
||||||
|
{
|
||||||
|
struct Item
|
||||||
|
{
|
||||||
|
bool is_center{ false };
|
||||||
|
std::optional<Measure::SurfaceFeature> source;
|
||||||
|
std::optional<Measure::SurfaceFeature> feature;
|
||||||
|
|
||||||
|
bool operator == (const Item& other) const {
|
||||||
|
return this->is_center == other.is_center && this->source == other.source && this->feature == other.feature;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator != (const Item& other) const {
|
||||||
|
return !operator == (other);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
is_center = false;
|
||||||
|
source.reset();
|
||||||
|
feature.reset();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Item first;
|
||||||
|
Item second;
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
first.reset();
|
||||||
|
second.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const SelectedFeatures & other) const {
|
||||||
|
if (this->first != other.first) return false;
|
||||||
|
return this->second == other.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator != (const SelectedFeatures & other) const {
|
||||||
|
return !operator == (other);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VolumeCacheItem
|
||||||
|
{
|
||||||
|
const ModelObject* object{ nullptr };
|
||||||
|
const ModelInstance* instance{ nullptr };
|
||||||
|
const ModelVolume* volume{ nullptr };
|
||||||
|
Transform3d world_trafo;
|
||||||
|
|
||||||
|
bool operator == (const VolumeCacheItem& other) const {
|
||||||
|
return this->object == other.object && this->instance == other.instance && this->volume == other.volume &&
|
||||||
|
this->world_trafo.isApprox(other.world_trafo);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<VolumeCacheItem> m_volumes_cache;
|
||||||
|
|
||||||
|
EMode m_mode{ EMode::FeatureSelection };
|
||||||
|
Measure::MeasurementResult m_measurement_result;
|
||||||
|
|
||||||
|
std::map<GLVolume*, std::shared_ptr<Measure::Measuring>> m_mesh_measure_map;
|
||||||
|
std::shared_ptr<Measure::Measuring> m_curr_measuring{nullptr};
|
||||||
|
|
||||||
|
//first feature
|
||||||
|
std::shared_ptr<GLModel> m_sphere{nullptr};
|
||||||
|
std::shared_ptr<GLModel> m_cylinder{nullptr};
|
||||||
|
struct CircleGLModel
|
||||||
|
{
|
||||||
|
std::shared_ptr<GLModel> circle{nullptr};
|
||||||
|
Measure::SurfaceFeature *last_circle_feature{nullptr};
|
||||||
|
float inv_zoom{0};
|
||||||
|
};
|
||||||
|
CircleGLModel m_curr_circle;
|
||||||
|
CircleGLModel m_feature_circle_first;
|
||||||
|
CircleGLModel m_feature_circle_second;
|
||||||
|
void init_circle_glmodel(GripperType gripper_type, const Measure::SurfaceFeature &feature, CircleGLModel &circle_gl_model, float inv_zoom);
|
||||||
|
|
||||||
|
struct PlaneGLModel {
|
||||||
|
int plane_idx{0};
|
||||||
|
std::shared_ptr<GLModel> plane{nullptr};
|
||||||
|
};
|
||||||
|
PlaneGLModel m_curr_plane;
|
||||||
|
PlaneGLModel m_feature_plane_first;
|
||||||
|
PlaneGLModel m_feature_plane_second;
|
||||||
|
void init_plane_glmodel(GripperType gripper_type, const Measure::SurfaceFeature &feature, PlaneGLModel &plane_gl_model);
|
||||||
|
|
||||||
|
struct Dimensioning
|
||||||
|
{
|
||||||
|
GLModel line;
|
||||||
|
GLModel triangle;
|
||||||
|
GLModel arc;
|
||||||
|
};
|
||||||
|
Dimensioning m_dimensioning;
|
||||||
|
bool m_show_reset_first_tip{false};
|
||||||
|
|
||||||
|
|
||||||
|
std::map<GLVolume*, std::shared_ptr<PickRaycaster>> m_mesh_raycaster_map;
|
||||||
|
std::vector<GLVolume*> m_hit_different_volumes;
|
||||||
|
std::vector<GLVolume*> m_hit_order_volumes;
|
||||||
|
GLVolume* m_last_hit_volume;
|
||||||
|
//std::vector<std::shared_ptr<GLModel>> m_plane_models_cache;
|
||||||
|
unsigned int m_last_active_item_imgui{0};
|
||||||
|
Vec3d m_buffered_distance;
|
||||||
|
// used to keep the raycasters for point/center spheres
|
||||||
|
//std::vector<std::shared_ptr<PickRaycaster>> m_selected_sphere_raycasters;
|
||||||
|
std::optional<Measure::SurfaceFeature> m_curr_feature;
|
||||||
|
std::optional<Vec3d> m_curr_point_on_feature_position;
|
||||||
|
|
||||||
|
// These hold information to decide whether recalculation is necessary:
|
||||||
|
float m_last_inv_zoom{ 0.0f };
|
||||||
|
std::optional<Measure::SurfaceFeature> m_last_circle_feature;
|
||||||
|
int m_last_plane_idx{ -1 };
|
||||||
|
|
||||||
|
bool m_mouse_left_down{ false }; // for detection left_up of this gizmo
|
||||||
|
bool m_mouse_left_down_mesh_deal{false};//for pick mesh
|
||||||
|
|
||||||
|
KeyAutoRepeatFilter m_shift_kar_filter;
|
||||||
|
|
||||||
|
SelectedFeatures m_selected_features;
|
||||||
|
bool m_pending_scale{ false };
|
||||||
|
bool m_editing_distance{ false };
|
||||||
|
bool m_is_editing_distance_first_frame{ true };
|
||||||
|
|
||||||
|
void update_if_needed();
|
||||||
|
|
||||||
|
void disable_scene_raycasters();
|
||||||
|
void restore_scene_raycasters_state();
|
||||||
|
|
||||||
|
void render_dimensioning();
|
||||||
|
|
||||||
|
#if ENABLE_MEASURE_GIZMO_DEBUG
|
||||||
|
void render_debug_dialog();
|
||||||
|
#endif // ENABLE_MEASURE_GIZMO_DEBUG
|
||||||
|
|
||||||
|
public:
|
||||||
|
GLGizmoMeasure(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||||
|
/// <summary>
|
||||||
|
/// Apply rotation on select plane
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mouse_event">Keep information about mouse click</param>
|
||||||
|
/// <returns>Return True when use the information otherwise False.</returns>
|
||||||
|
bool on_mouse(const wxMouseEvent &mouse_event) override;
|
||||||
|
|
||||||
|
void data_changed(bool is_serializing) override;
|
||||||
|
|
||||||
|
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
|
||||||
|
|
||||||
|
bool wants_enter_leave_snapshots() const override { return true; }
|
||||||
|
std::string get_gizmo_entering_text() const override { return _u8L("Entering Measure gizmo"); }
|
||||||
|
std::string get_gizmo_leaving_text() const override { return _u8L("Leaving Measure gizmo"); }
|
||||||
|
//std::string get_action_snapshot_name() const override { return _u8L("Measure gizmo editing"); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool on_init() override;
|
||||||
|
std::string on_get_name() const override;
|
||||||
|
bool on_is_activable() const override;
|
||||||
|
void on_render() override;
|
||||||
|
void on_set_state() override;
|
||||||
|
|
||||||
|
virtual void on_render_for_picking() override;
|
||||||
|
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
|
||||||
|
|
||||||
|
void remove_selected_sphere_raycaster(int id);
|
||||||
|
void update_measurement_result();
|
||||||
|
|
||||||
|
void show_tooltip_information(float caption_max, float x, float y);
|
||||||
|
void reset_all_pick();
|
||||||
|
void reset_gripper_pick(GripperType id,bool is_all = false);
|
||||||
|
void register_single_mesh_pick();
|
||||||
|
|
||||||
|
void reset_all_feature();
|
||||||
|
void reset_feature1();
|
||||||
|
void reset_feature2();
|
||||||
|
bool is_two_volume_in_same_model_object();
|
||||||
|
private:
|
||||||
|
// This map holds all translated description texts, so they can be easily referenced during layout calculations
|
||||||
|
// etc. When language changes, GUI is recreated and this class constructed again, so the change takes effect.
|
||||||
|
std::map<std::string, wxString> m_desc;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace GUI
|
||||||
|
} // namespace Slic3r
|
||||||
|
|
||||||
|
#endif // slic3r_GLGizmoMeasure_hpp_
|
|
@ -24,8 +24,12 @@ enum class SLAGizmoEventType : unsigned char {
|
||||||
Dragging,
|
Dragging,
|
||||||
Delete,
|
Delete,
|
||||||
SelectAll,
|
SelectAll,
|
||||||
|
CtrlDown,
|
||||||
|
CtrlUp,
|
||||||
|
ShiftDown,
|
||||||
ShiftUp,
|
ShiftUp,
|
||||||
AltUp,
|
AltUp,
|
||||||
|
Escape,
|
||||||
ApplyChanges,
|
ApplyChanges,
|
||||||
DiscardChanges,
|
DiscardChanges,
|
||||||
AutomaticGeneration,
|
AutomaticGeneration,
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "slic3r/GUI/Gizmos/GLGizmoSimplify.hpp"
|
#include "slic3r/GUI/Gizmos/GLGizmoSimplify.hpp"
|
||||||
#include "slic3r/GUI/Gizmos/GLGizmoText.hpp"
|
#include "slic3r/GUI/Gizmos/GLGizmoText.hpp"
|
||||||
#include "slic3r/GUI/Gizmos/GLGizmoMeshBoolean.hpp"
|
#include "slic3r/GUI/Gizmos/GLGizmoMeshBoolean.hpp"
|
||||||
|
#include "slic3r/GUI/Gizmos/GLGizmoMeasure.hpp"
|
||||||
|
|
||||||
#include "libslic3r/format.hpp"
|
#include "libslic3r/format.hpp"
|
||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
|
@ -175,6 +176,9 @@ void GLGizmosManager::switch_gizmos_icon_filename()
|
||||||
case(EType::MeshBoolean):
|
case(EType::MeshBoolean):
|
||||||
gizmo->set_icon_filename(m_is_dark ? "toolbar_meshboolean_dark.svg" : "toolbar_meshboolean.svg");
|
gizmo->set_icon_filename(m_is_dark ? "toolbar_meshboolean_dark.svg" : "toolbar_meshboolean.svg");
|
||||||
break;
|
break;
|
||||||
|
case (EType::Measure):
|
||||||
|
gizmo->set_icon_filename(m_is_dark ? "toolbar_measure_dark.svg" : "toolbar_measure.svg");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -211,6 +215,7 @@ bool GLGizmosManager::init()
|
||||||
m_gizmos.emplace_back(new GLGizmoSeam(m_parent, m_is_dark ? "toolbar_seam_dark.svg" : "toolbar_seam.svg", EType::Seam));
|
m_gizmos.emplace_back(new GLGizmoSeam(m_parent, m_is_dark ? "toolbar_seam_dark.svg" : "toolbar_seam.svg", EType::Seam));
|
||||||
m_gizmos.emplace_back(new GLGizmoText(m_parent, m_is_dark ? "toolbar_text_dark.svg" : "toolbar_text.svg", EType::Text));
|
m_gizmos.emplace_back(new GLGizmoText(m_parent, m_is_dark ? "toolbar_text_dark.svg" : "toolbar_text.svg", EType::Text));
|
||||||
m_gizmos.emplace_back(new GLGizmoMmuSegmentation(m_parent, m_is_dark ? "mmu_segmentation_dark.svg" : "mmu_segmentation.svg", EType::MmuSegmentation));
|
m_gizmos.emplace_back(new GLGizmoMmuSegmentation(m_parent, m_is_dark ? "mmu_segmentation_dark.svg" : "mmu_segmentation.svg", EType::MmuSegmentation));
|
||||||
|
m_gizmos.emplace_back(new GLGizmoMeasure(m_parent, m_is_dark ? "toolbar_measure_dark.svg" : "toolbar_measure.svg", EType::Measure));
|
||||||
m_gizmos.emplace_back(new GLGizmoSimplify(m_parent, "reduce_triangles.svg", EType::Simplify));
|
m_gizmos.emplace_back(new GLGizmoSimplify(m_parent, "reduce_triangles.svg", EType::Simplify));
|
||||||
//m_gizmos.emplace_back(new GLGizmoSlaSupports(m_parent, "sla_supports.svg", sprite_id++));
|
//m_gizmos.emplace_back(new GLGizmoSlaSupports(m_parent, "sla_supports.svg", sprite_id++));
|
||||||
//m_gizmos.emplace_back(new GLGizmoFaceDetector(m_parent, "face recognition.svg", sprite_id++));
|
//m_gizmos.emplace_back(new GLGizmoFaceDetector(m_parent, "face recognition.svg", sprite_id++));
|
||||||
|
@ -377,6 +382,7 @@ bool GLGizmosManager::check_gizmos_closed_except(EType type) const
|
||||||
|
|
||||||
void GLGizmosManager::set_hover_id(int id)
|
void GLGizmosManager::set_hover_id(int id)
|
||||||
{
|
{
|
||||||
|
if (m_current == EType::Measure) { return; }
|
||||||
if (!m_enabled || m_current == Undefined)
|
if (!m_enabled || m_current == Undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -678,6 +684,8 @@ bool GLGizmosManager::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_p
|
||||||
return dynamic_cast<GLGizmoMmuSegmentation*>(m_gizmos[MmuSegmentation].get())->gizmo_event(action, mouse_position, shift_down, alt_down, control_down);
|
return dynamic_cast<GLGizmoMmuSegmentation*>(m_gizmos[MmuSegmentation].get())->gizmo_event(action, mouse_position, shift_down, alt_down, control_down);
|
||||||
else if (m_current == Text)
|
else if (m_current == Text)
|
||||||
return dynamic_cast<GLGizmoText*>(m_gizmos[Text].get())->gizmo_event(action, mouse_position, shift_down, alt_down, control_down);
|
return dynamic_cast<GLGizmoText*>(m_gizmos[Text].get())->gizmo_event(action, mouse_position, shift_down, alt_down, control_down);
|
||||||
|
else if (m_current == Measure)
|
||||||
|
return dynamic_cast<GLGizmoMeasure *>(m_gizmos[Measure].get())->gizmo_event(action, mouse_position, shift_down, alt_down, control_down);
|
||||||
else if (m_current == Cut)
|
else if (m_current == Cut)
|
||||||
return dynamic_cast<GLGizmoAdvancedCut *>(m_gizmos[Cut].get())->gizmo_event(action, mouse_position, shift_down, alt_down, control_down);
|
return dynamic_cast<GLGizmoAdvancedCut *>(m_gizmos[Cut].get())->gizmo_event(action, mouse_position, shift_down, alt_down, control_down);
|
||||||
else if (m_current == MeshBoolean)
|
else if (m_current == MeshBoolean)
|
||||||
|
@ -810,7 +818,11 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
||||||
|
|
||||||
// when control is down we allow scene pan and rotation even when clicking over some object
|
// when control is down we allow scene pan and rotation even when clicking over some object
|
||||||
bool control_down = evt.CmdDown();
|
bool control_down = evt.CmdDown();
|
||||||
|
if (m_current != Undefined) {
|
||||||
|
// check if gizmo override method could be slower than simple call virtual function
|
||||||
|
// &m_gizmos[m_current]->on_mouse != &GLGizmoBase::on_mouse &&
|
||||||
|
m_gizmos[m_current]->on_mouse(evt);
|
||||||
|
}
|
||||||
// mouse anywhere
|
// mouse anywhere
|
||||||
if (evt.Moving()) {
|
if (evt.Moving()) {
|
||||||
m_tooltip = update_hover_state(mouse_pos);
|
m_tooltip = update_hover_state(mouse_pos);
|
||||||
|
@ -933,6 +945,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
||||||
// the gizmo got the event and took some action, there is no need to do anything more
|
// the gizmo got the event and took some action, there is no need to do anything more
|
||||||
processed = true;
|
processed = true;
|
||||||
else if (!selection.is_empty() && grabber_contains_mouse()) {
|
else if (!selection.is_empty() && grabber_contains_mouse()) {
|
||||||
|
if (m_current != Measure) {
|
||||||
update_data();
|
update_data();
|
||||||
selection.start_dragging();
|
selection.start_dragging();
|
||||||
start_dragging();
|
start_dragging();
|
||||||
|
@ -948,6 +961,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_parent.set_as_dirty();
|
m_parent.set_as_dirty();
|
||||||
|
}
|
||||||
processed = true;
|
processed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1079,9 +1093,10 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt)
|
||||||
// key ESC
|
// key ESC
|
||||||
case WXK_ESCAPE:
|
case WXK_ESCAPE:
|
||||||
{
|
{
|
||||||
if (m_current != Undefined)
|
if (m_current != Undefined) {
|
||||||
{
|
if (m_current == Measure && gizmo_event(SLAGizmoEventType::Escape)) {
|
||||||
if ((m_current != SlaSupports) || !gizmo_event(SLAGizmoEventType::DiscardChanges))
|
// do nothing
|
||||||
|
} else if ((m_current != SlaSupports) || !gizmo_event(SLAGizmoEventType::DiscardChanges))
|
||||||
reset_all_states();
|
reset_all_states();
|
||||||
|
|
||||||
processed = true;
|
processed = true;
|
||||||
|
@ -1116,13 +1131,11 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt)
|
||||||
|
|
||||||
|
|
||||||
//case WXK_BACK:
|
//case WXK_BACK:
|
||||||
//case WXK_DELETE:
|
case WXK_DELETE: {
|
||||||
//{
|
if ((m_current == Cut || m_current == Measure) && gizmo_event(SLAGizmoEventType::Delete))
|
||||||
// if ((m_current == SlaSupports || m_current == Hollow) && gizmo_event(SLAGizmoEventType::Delete))
|
processed = true;
|
||||||
// processed = true;
|
break;
|
||||||
|
}
|
||||||
// break;
|
|
||||||
//}
|
|
||||||
//case 'A':
|
//case 'A':
|
||||||
//case 'a':
|
//case 'a':
|
||||||
//{
|
//{
|
||||||
|
@ -1226,7 +1239,12 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
|
||||||
processed = true;
|
processed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (m_current == Measure) {
|
||||||
|
if (keyCode == WXK_CONTROL)
|
||||||
|
gizmo_event(SLAGizmoEventType::CtrlUp, Vec2d::Zero(), evt.ShiftDown(), evt.AltDown(), evt.CmdDown());
|
||||||
|
else if (keyCode == WXK_SHIFT)
|
||||||
|
gizmo_event(SLAGizmoEventType::ShiftUp, Vec2d::Zero(), evt.ShiftDown(), evt.AltDown(), evt.CmdDown());
|
||||||
|
}
|
||||||
// if (processed)
|
// if (processed)
|
||||||
// m_parent.set_cursor(GLCanvas3D::Standard);
|
// m_parent.set_cursor(GLCanvas3D::Standard);
|
||||||
}
|
}
|
||||||
|
@ -1305,6 +1323,11 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
|
||||||
// force extra frame to automatically update window size
|
// force extra frame to automatically update window size
|
||||||
wxGetApp().imgui()->set_requires_extra_frame();
|
wxGetApp().imgui()->set_requires_extra_frame();
|
||||||
}
|
}
|
||||||
|
} else if (m_current == Measure) {
|
||||||
|
if (keyCode == WXK_CONTROL)
|
||||||
|
gizmo_event(SLAGizmoEventType::CtrlDown, Vec2d::Zero(), evt.ShiftDown(), evt.AltDown(), evt.CmdDown());
|
||||||
|
else if (keyCode == WXK_SHIFT)
|
||||||
|
gizmo_event(SLAGizmoEventType::ShiftDown, Vec2d::Zero(), evt.ShiftDown(), evt.AltDown(), evt.CmdDown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue