mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 06:33:57 -06:00
Measure: Port of BBS' improved version of measure gizmo
Co-authored-by: zhou.xu <zhou.xu@bambulab.com>
This commit is contained in:
parent
1088d0a6c7
commit
6e9257c8ac
16 changed files with 1672 additions and 866 deletions
|
@ -743,6 +743,7 @@ public:
|
|||
m_scene_raycaster.set_gizmos_on_top(value);
|
||||
}
|
||||
|
||||
float get_explosion_ratio() { return m_explosion_ratio; }
|
||||
void reset_explosion_ratio() { m_explosion_ratio = 1.0; }
|
||||
void on_change_color_mode(bool is_dark, bool reinit = true);
|
||||
const bool get_dark_mode_status() { return m_is_dark; }
|
||||
|
|
|
@ -1412,5 +1412,84 @@ GLModel::Geometry smooth_torus(unsigned int primary_resolution, unsigned int sec
|
|||
return data;
|
||||
}
|
||||
|
||||
GLModel::Geometry init_plane_data(const indexed_triangle_set& its, const std::vector<int>& triangle_indices, float normal_offset)
|
||||
{
|
||||
GLModel::Geometry init_data;
|
||||
init_data.format = { GUI::GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3 };
|
||||
init_data.reserve_indices(3 * triangle_indices.size());
|
||||
init_data.reserve_vertices(3 * triangle_indices.size());
|
||||
unsigned int i = 0;
|
||||
for (int idx : triangle_indices) {
|
||||
Vec3f v0 = its.vertices[its.indices[idx][0]];
|
||||
Vec3f v1 = its.vertices[its.indices[idx][1]];
|
||||
Vec3f v2 = its.vertices[its.indices[idx][2]];
|
||||
const Vec3f n = (v1 - v0).cross(v2 - v0).normalized();
|
||||
if (std::abs(normal_offset) > 0.0) {
|
||||
v0 = v0 + n * normal_offset;
|
||||
v1 = v1 + n * normal_offset;
|
||||
v2 = v2 + n * normal_offset;
|
||||
}
|
||||
init_data.add_vertex(v0, n);
|
||||
init_data.add_vertex(v1, n);
|
||||
init_data.add_vertex(v2, n);
|
||||
init_data.add_triangle(i, i + 1, i + 2);
|
||||
i += 3;
|
||||
}
|
||||
|
||||
return init_data;
|
||||
}
|
||||
|
||||
GLModel::Geometry init_torus_data(unsigned int primary_resolution,
|
||||
unsigned int secondary_resolution,
|
||||
const Vec3f & center,
|
||||
float radius,
|
||||
float thickness,
|
||||
const Vec3f & model_axis,
|
||||
const Transform3f &world_trafo)
|
||||
{
|
||||
const unsigned int torus_sector_count = std::max<unsigned int>(4, primary_resolution);
|
||||
const unsigned int section_sector_count = std::max<unsigned int>(4, secondary_resolution);
|
||||
const float torus_sector_step = 2.0f * float(M_PI) / float(torus_sector_count);
|
||||
const float section_sector_step = 2.0f * float(M_PI) / float(section_sector_count);
|
||||
|
||||
GLModel::Geometry data;
|
||||
data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3 };
|
||||
data.reserve_vertices(torus_sector_count * section_sector_count);
|
||||
data.reserve_indices(torus_sector_count * section_sector_count * 2 * 3);
|
||||
|
||||
// vertices
|
||||
const Transform3f local_to_world_matrix = world_trafo * Geometry::translation_transform(center.cast<double>()).cast<float>() *
|
||||
Eigen::Quaternion<float>::FromTwoVectors(Vec3f::UnitZ(), model_axis);
|
||||
for (unsigned int i = 0; i < torus_sector_count; ++i) {
|
||||
const float section_angle = torus_sector_step * i;
|
||||
const Vec3f radius_dir(std::cos(section_angle), std::sin(section_angle), 0.0f);
|
||||
const Vec3f local_section_center = radius * radius_dir;
|
||||
const Vec3f world_section_center = local_to_world_matrix * local_section_center;
|
||||
const Vec3f local_section_normal = local_section_center.normalized().cross(Vec3f::UnitZ()).normalized();
|
||||
const Vec3f world_section_normal = (Vec3f) (local_to_world_matrix.matrix().block(0, 0, 3, 3) * local_section_normal).normalized();
|
||||
const Vec3f base_v = thickness * radius_dir;
|
||||
for (unsigned int j = 0; j < section_sector_count; ++j) {
|
||||
const Vec3f v = Eigen::AngleAxisf(section_sector_step * j, world_section_normal) * base_v;
|
||||
data.add_vertex(world_section_center + v, (Vec3f) v.normalized());
|
||||
}
|
||||
}
|
||||
|
||||
// triangles
|
||||
for (unsigned int i = 0; i < torus_sector_count; ++i) {
|
||||
const unsigned int ii = i * section_sector_count;
|
||||
const unsigned int ii_next = ((i + 1) % torus_sector_count) * section_sector_count;
|
||||
for (unsigned int j = 0; j < section_sector_count; ++j) {
|
||||
const unsigned int j_next = (j + 1) % section_sector_count;
|
||||
const unsigned int i0 = ii + j;
|
||||
const unsigned int i1 = ii_next + j;
|
||||
const unsigned int i2 = ii_next + j_next;
|
||||
const unsigned int i3 = ii + j_next;
|
||||
data.add_triangle(i0, i1, i2);
|
||||
data.add_triangle(i0, i2, i3);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -247,7 +247,15 @@ namespace GUI {
|
|||
// the origin of the torus is in its center
|
||||
GLModel::Geometry smooth_torus(unsigned int primary_resolution, unsigned int secondary_resolution, float radius, float thickness);
|
||||
|
||||
} // namespace GUI
|
||||
GLModel::Geometry init_plane_data(const indexed_triangle_set &its, const std::vector<int> &triangle_indices,float normal_offset = 0.0f);
|
||||
GLModel::Geometry init_torus_data(unsigned int primary_resolution,
|
||||
unsigned int secondary_resolution,
|
||||
const Vec3f & center,
|
||||
float radius,
|
||||
float thickness,
|
||||
const Vec3f & model_axis,
|
||||
const Transform3f &world_trafo);
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_GLModel_hpp_
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "slic3r/GUI/GLModel.hpp"
|
||||
#include "slic3r/GUI/MeshUtils.hpp"
|
||||
#include "slic3r/GUI/SceneRaycaster.hpp"
|
||||
#include "slic3r/GUI/3DScene.hpp"
|
||||
|
||||
#include <cereal/archives/binary.hpp>
|
||||
|
||||
|
@ -181,6 +182,13 @@ public:
|
|||
|
||||
virtual bool apply_clipping_plane() { return true; }
|
||||
|
||||
/// <summary>
|
||||
/// Implement when want to process mouse events in gizmo
|
||||
/// Click, Right click, move, drag, ...
|
||||
/// </summary>
|
||||
/// <param name="mouse_event">Keep information about mouse click</param>
|
||||
/// <returns>Return True when use the information and don't want to propagate it otherwise False.</returns>
|
||||
virtual bool on_mouse(const wxMouseEvent &mouse_event) { return false; }
|
||||
unsigned int get_sprite_id() const { return m_sprite_id; }
|
||||
|
||||
int get_hover_id() const { return m_hover_id; }
|
||||
|
@ -209,14 +217,6 @@ public:
|
|||
/// </summary>
|
||||
virtual void data_changed(bool is_serializing){};
|
||||
|
||||
/// <summary>
|
||||
/// Implement when want to process mouse events in gizmo
|
||||
/// Click, Right click, move, drag, ...
|
||||
/// </summary>
|
||||
/// <param name="mouse_event">Keep information about mouse click</param>
|
||||
/// <returns>Return True when use the information and don't want to propagate it otherwise False.</returns>
|
||||
virtual bool on_mouse(const wxMouseEvent &mouse_event) { return false; }
|
||||
|
||||
void register_raycasters_for_picking() { register_grabbers_for_picking(); on_register_raycasters_for_picking(); }
|
||||
void unregister_raycasters_for_picking() { unregister_grabbers_for_picking(); on_unregister_raycasters_for_picking(); }
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,16 +12,85 @@
|
|||
namespace Slic3r {
|
||||
|
||||
enum class ModelVolumeType : int;
|
||||
|
||||
namespace Measure { class Measuring; }
|
||||
|
||||
|
||||
namespace GUI {
|
||||
|
||||
enum class SLAGizmoEventType : unsigned char;
|
||||
enum class EMeasureMode : unsigned char {
|
||||
ONLY_MEASURE,
|
||||
ONLY_ASSEMBLY
|
||||
};
|
||||
enum class AssemblyMode : unsigned char {
|
||||
FACE_FACE,
|
||||
POINT_POINT,
|
||||
};
|
||||
static const Slic3r::ColorRGBA SELECTED_1ST_COLOR = {0.25f, 0.75f, 0.75f, 1.0f};
|
||||
static const Slic3r::ColorRGBA SELECTED_2ND_COLOR = {0.75f, 0.25f, 0.75f, 1.0f};
|
||||
static const Slic3r::ColorRGBA NEUTRAL_COLOR = {0.5f, 0.5f, 0.5f, 1.0f};
|
||||
static const Slic3r::ColorRGBA HOVER_COLOR = ColorRGBA::GREEN();
|
||||
|
||||
static const int POINT_ID = 100;
|
||||
static const int EDGE_ID = 200;
|
||||
static const int CIRCLE_ID = 300;
|
||||
static const int PLANE_ID = 400;
|
||||
static const int SEL_SPHERE_1_ID = 501;
|
||||
static const int SEL_SPHERE_2_ID = 502;
|
||||
|
||||
static const float TRIANGLE_BASE = 10.0f;
|
||||
static const float TRIANGLE_HEIGHT = TRIANGLE_BASE * 1.618033f;
|
||||
|
||||
static const std::string CTRL_STR =
|
||||
#ifdef __APPLE__
|
||||
"⌘"
|
||||
#else
|
||||
"Ctrl"
|
||||
#endif //__APPLE__
|
||||
;
|
||||
|
||||
class TransformHelper
|
||||
{
|
||||
struct Cache
|
||||
{
|
||||
std::array<int, 4> viewport;
|
||||
Matrix4d ndc_to_ss_matrix;
|
||||
Transform3d ndc_to_ss_matrix_inverse;
|
||||
};
|
||||
static Cache s_cache;
|
||||
|
||||
public:
|
||||
static Vec3d model_to_world(const Vec3d &model, const Transform3d &world_matrix);
|
||||
static Vec4d world_to_clip(const Vec3d &world, const Matrix4d &projection_view_matrix);
|
||||
static Vec3d clip_to_ndc(const Vec4d &clip);
|
||||
static Vec2d ndc_to_ss(const Vec3d &ndc, const std::array<int, 4> &viewport);
|
||||
static Vec4d model_to_clip(const Vec3d &model, const Transform3d &world_matrix, const Matrix4d &projection_view_matrix);
|
||||
static Vec3d model_to_ndc(const Vec3d &model, const Transform3d &world_matrix, const Matrix4d &projection_view_matrix);
|
||||
static Vec2d model_to_ss(const Vec3d &model, const Transform3d &world_matrix, const Matrix4d &projection_view_matrix, const std::array<int, 4> &viewport);
|
||||
static Vec2d world_to_ss(const Vec3d &world, const Matrix4d &projection_view_matrix, const std::array<int, 4> &viewport);
|
||||
static const Matrix4d & ndc_to_ss_matrix(const std::array<int, 4> &viewport);
|
||||
static const Transform3d ndc_to_ss_matrix_inverse(const std::array<int, 4> &viewport);
|
||||
|
||||
private:
|
||||
static void update(const std::array<int, 4> &viewport);
|
||||
};
|
||||
|
||||
class GLGizmoMeasure : public GLGizmoBase
|
||||
{
|
||||
protected:
|
||||
using PickRaycaster = SceneRaycasterItem;
|
||||
enum GripperType {
|
||||
UNDEFINE,
|
||||
POINT,
|
||||
EDGE,
|
||||
CIRCLE,
|
||||
CIRCLE_1,
|
||||
CIRCLE_2,
|
||||
PLANE,
|
||||
PLANE_1,
|
||||
PLANE_2,
|
||||
SPHERE_1,
|
||||
SPHERE_2,
|
||||
};
|
||||
|
||||
enum class EMode : unsigned char
|
||||
{
|
||||
FeatureSelection,
|
||||
|
@ -69,30 +138,49 @@ class GLGizmoMeasure : public GLGizmoBase
|
|||
}
|
||||
};
|
||||
|
||||
struct VolumeCacheItem
|
||||
{
|
||||
const ModelObject* object{ nullptr };
|
||||
const ModelInstance* instance{ nullptr };
|
||||
const ModelVolume* volume{ nullptr };
|
||||
Transform3d world_trafo;
|
||||
//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);
|
||||
}
|
||||
};
|
||||
// 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;
|
||||
//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};
|
||||
|
||||
std::unique_ptr<Measure::Measuring> m_measuring; // PIMPL
|
||||
|
||||
//first feature
|
||||
PickingModel m_sphere;
|
||||
PickingModel m_cylinder;
|
||||
PickingModel m_circle;
|
||||
PickingModel m_plane;
|
||||
struct CircleGLModel
|
||||
{
|
||||
PickingModel circle;
|
||||
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};
|
||||
PickingModel plane;
|
||||
};
|
||||
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;
|
||||
|
@ -101,40 +189,36 @@ class GLGizmoMeasure : public GLGizmoBase
|
|||
};
|
||||
Dimensioning m_dimensioning;
|
||||
|
||||
// Uses a standalone raycaster and not the shared one because of the
|
||||
// difference in how the mesh is updated
|
||||
std::unique_ptr<MeshRaycaster> m_raycaster;
|
||||
|
||||
std::vector<GLModel> m_plane_models_cache;
|
||||
std::map<int, std::shared_ptr<SceneRaycasterItem>> m_raycasters;
|
||||
std::map<GLVolume*, std::shared_ptr<PickRaycaster>> m_mesh_raycaster_map;
|
||||
std::map<GripperType, std::shared_ptr<PickRaycaster>> m_gripper_id_raycast_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;
|
||||
Vec3d m_distance;
|
||||
// used to keep the raycasters for point/center spheres
|
||||
std::vector<std::shared_ptr<SceneRaycasterItem>> m_selected_sphere_raycasters;
|
||||
//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;
|
||||
struct SceneRaycasterState
|
||||
{
|
||||
std::shared_ptr<SceneRaycasterItem> raycaster{ nullptr };
|
||||
bool state{true};
|
||||
|
||||
};
|
||||
std::vector<SceneRaycasterState> m_scene_raycasters;
|
||||
|
||||
// These hold information to decide whether recalculation is necessary:
|
||||
float m_last_inv_zoom{ 0.0f };
|
||||
std::optional<Measure::SurfaceFeature> m_last_circle;
|
||||
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
|
||||
|
||||
Vec2d m_mouse_pos{ Vec2d::Zero() };
|
||||
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 };
|
||||
int m_pending_scale{ 0 };
|
||||
bool m_set_center_coincidence{false};
|
||||
bool m_editing_distance{ false };
|
||||
bool m_is_editing_distance_first_frame{ true };
|
||||
|
||||
bool m_can_set_xyz_distance{false};
|
||||
void update_if_needed();
|
||||
|
||||
void disable_scene_raycasters();
|
||||
|
@ -148,7 +232,6 @@ class GLGizmoMeasure : public GLGizmoBase
|
|||
|
||||
public:
|
||||
GLGizmoMeasure(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
|
||||
/// <summary>
|
||||
/// Apply rotation on select plane
|
||||
/// </summary>
|
||||
|
@ -158,12 +241,12 @@ public:
|
|||
|
||||
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);
|
||||
virtual 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"); }
|
||||
//std::string get_action_snapshot_name() const override { return _u8L("Measure gizmo editing"); }
|
||||
|
||||
protected:
|
||||
bool on_init() override;
|
||||
|
@ -172,20 +255,56 @@ protected:
|
|||
void on_render() override;
|
||||
void on_set_state() override;
|
||||
|
||||
//virtual void on_render_for_picking() override;
|
||||
void show_selection_ui();
|
||||
void show_distance_xyz_ui();
|
||||
//void show_point_point_assembly();
|
||||
void init_render_input_window();
|
||||
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
|
||||
virtual void on_register_raycasters_for_picking() override;
|
||||
virtual void on_unregister_raycasters_for_picking() override;
|
||||
|
||||
void remove_selected_sphere_raycaster(int id);
|
||||
void update_measurement_result();
|
||||
|
||||
// Orca
|
||||
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 update_single_mesh_pick(GLVolume* v);
|
||||
|
||||
private:
|
||||
std::string format_double(double value);
|
||||
std::string format_vec3(const Vec3d &v);
|
||||
std::string surface_feature_type_as_string(Measure::SurfaceFeatureType type);
|
||||
std::string point_on_feature_type_as_string(Measure::SurfaceFeatureType type, int hover_id);
|
||||
std::string center_on_feature_type_as_string(Measure::SurfaceFeatureType type);
|
||||
bool is_feature_with_center(const Measure::SurfaceFeature &feature);
|
||||
Vec3d get_feature_offset(const Measure::SurfaceFeature &feature);
|
||||
|
||||
void reset_all_feature();
|
||||
void reset_feature1_render();
|
||||
void reset_feature2_render();
|
||||
void reset_feature1();
|
||||
void reset_feature2();
|
||||
bool is_two_volume_in_same_model_object();
|
||||
Measure::Measuring* get_measuring_of_mesh(GLVolume *v, Transform3d &tran);
|
||||
void update_world_plane_features(Measure::Measuring *cur_measuring, Measure::SurfaceFeature &feautre);
|
||||
void update_feature_by_tran(Measure::SurfaceFeature & feature);
|
||||
void set_distance(bool same_model_object, const Vec3d &displacement, bool take_shot = true);
|
||||
protected:
|
||||
// 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;
|
||||
bool m_show_reset_first_tip{false};
|
||||
bool m_selected_wrong_feature_waring_tip{false};
|
||||
EMeasureMode m_measure_mode{EMeasureMode::ONLY_MEASURE};
|
||||
AssemblyMode m_assembly_mode{AssemblyMode::FACE_FACE};
|
||||
bool m_flip_volume_2{false};
|
||||
float m_space_size;
|
||||
float m_input_size_max;
|
||||
bool m_use_inches;
|
||||
bool m_only_select_plane{false};
|
||||
std::string m_units;
|
||||
mutable bool m_same_model_object;
|
||||
mutable unsigned int m_current_active_imgui_id;
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
@ -61,7 +61,8 @@ std::vector<size_t> GLGizmosManager::get_selectable_idxs() const
|
|||
out.reserve(m_gizmos.size());
|
||||
if (m_parent.get_canvas_type() == GLCanvas3D::CanvasAssembleView) {
|
||||
for (size_t i = 0; i < m_gizmos.size(); ++i)
|
||||
if (m_gizmos[i]->get_sprite_id() == (unsigned int)MmuSegmentation)
|
||||
if (m_gizmos[i]->get_sprite_id() == (unsigned int) Measure ||
|
||||
m_gizmos[i]->get_sprite_id() == (unsigned int) MmuSegmentation)
|
||||
out.push_back(i);
|
||||
}
|
||||
else {
|
||||
|
@ -158,7 +159,7 @@ void GLGizmosManager::switch_gizmos_icon_filename()
|
|||
case(EType::MeshBoolean):
|
||||
gizmo->set_icon_filename(m_is_dark ? "toolbar_meshboolean_dark.svg" : "toolbar_meshboolean.svg");
|
||||
break;
|
||||
case(EType::Measure):
|
||||
case (EType::Measure):
|
||||
gizmo->set_icon_filename(m_is_dark ? "toolbar_measure_dark.svg" : "toolbar_measure.svg");
|
||||
break;
|
||||
}
|
||||
|
@ -342,6 +343,8 @@ bool GLGizmosManager::check_gizmos_closed_except(EType type) const
|
|||
|
||||
void GLGizmosManager::set_hover_id(int id)
|
||||
{
|
||||
// Measure handles hover by itself
|
||||
if (m_current == EType::Measure) { return; }
|
||||
if (!m_enabled || m_current == Undefined)
|
||||
return;
|
||||
|
||||
|
@ -703,14 +706,7 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case WXK_BACK:
|
||||
case WXK_DELETE:
|
||||
{
|
||||
if ((m_current == Cut || m_current == Measure) && gizmo_event(SLAGizmoEventType::Delete))
|
||||
processed = true;
|
||||
|
||||
break;
|
||||
}
|
||||
//skip some keys when gizmo
|
||||
case 'A':
|
||||
case 'a':
|
||||
{
|
||||
|
@ -737,14 +733,12 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt)
|
|||
//}
|
||||
|
||||
|
||||
//case WXK_BACK:
|
||||
//case WXK_DELETE:
|
||||
//{
|
||||
// if ((m_current == SlaSupports || m_current == Hollow) && gizmo_event(SLAGizmoEventType::Delete))
|
||||
// processed = true;
|
||||
|
||||
// break;
|
||||
//}
|
||||
case WXK_BACK:
|
||||
case WXK_DELETE: {
|
||||
if ((m_current == Cut || m_current == Measure) && gizmo_event(SLAGizmoEventType::Delete))
|
||||
processed = true;
|
||||
break;
|
||||
}
|
||||
//case 'A':
|
||||
//case 'a':
|
||||
//{
|
||||
|
@ -845,7 +839,6 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
|
|||
else if (keyCode == WXK_SHIFT)
|
||||
gizmo_event(SLAGizmoEventType::ShiftUp, Vec2d::Zero(), evt.ShiftDown(), evt.AltDown(), evt.CmdDown());
|
||||
}
|
||||
|
||||
// if (processed)
|
||||
// m_parent.set_cursor(GLCanvas3D::Standard);
|
||||
}
|
||||
|
|
|
@ -161,7 +161,9 @@ const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_ORANGE_LIGHT;
|
|||
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = COL_BUTTON_HOVERED;
|
||||
|
||||
//BBS
|
||||
|
||||
const ImVec4 ImGuiWrapper::COL_RED = ImVec4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
const ImVec4 ImGuiWrapper::COL_GREEN = ImVec4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
const ImVec4 ImGuiWrapper::COL_BLUE = ImVec4(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
const ImVec4 ImGuiWrapper::COL_BLUE_LIGHT = ImVec4(0.122f, 0.557f, 0.918f, 1.0f);
|
||||
const ImVec4 ImGuiWrapper::COL_GREEN_LIGHT = { 0.f, 156 / 255.f, 136 / 255.f, 0.25f }; // ORCA used on various places like text selection bg. Replaced with orca color
|
||||
const ImVec4 ImGuiWrapper::COL_HOVER = { 0.933f, 0.933f, 0.933f, 1.0f };
|
||||
|
@ -856,6 +858,10 @@ bool ImGuiWrapper::radio_button(const wxString &label, bool active)
|
|||
return ImGui::RadioButton(label_utf8.c_str(), active);
|
||||
}
|
||||
|
||||
ImVec4 ImGuiWrapper::to_ImVec4(const ColorRGB &color) {
|
||||
return {color.r(), color.g(), color.b(), 1.0};
|
||||
}
|
||||
|
||||
bool ImGuiWrapper::input_double(const std::string &label, const double &value, const std::string &format)
|
||||
{
|
||||
return ImGui::InputDouble(label.c_str(), const_cast<double*>(&value), 0.0f, 0.0f, format.c_str(), ImGuiInputTextFlags_CharsDecimal);
|
||||
|
@ -943,6 +949,19 @@ void ImGuiWrapper::text(const wxString &label)
|
|||
ImGuiWrapper::text(label_utf8.c_str());
|
||||
}
|
||||
|
||||
void ImGuiWrapper::warning_text(const char *label)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImGuiWrapper::to_ImVec4(ColorRGB::WARNING()));
|
||||
this->text(label);
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
void ImGuiWrapper::warning_text(const wxString &all_text)
|
||||
{
|
||||
auto label_utf8 = into_u8(all_text);
|
||||
warning_text(label_utf8.c_str());
|
||||
}
|
||||
|
||||
void ImGuiWrapper::text_colored(const ImVec4& color, const char* label)
|
||||
{
|
||||
ImGui::TextColored(color, "%s", label);
|
||||
|
|
|
@ -134,6 +134,7 @@ public:
|
|||
bool button(const wxString& label, float width, float height);
|
||||
bool button(const wxString& label, const ImVec2 &size, bool enable); // default size = ImVec2(0.f, 0.f)
|
||||
bool radio_button(const wxString &label, bool active);
|
||||
static ImVec4 to_ImVec4(const ColorRGB &color);
|
||||
bool input_double(const std::string &label, const double &value, const std::string &format = "%.3f");
|
||||
bool input_double(const wxString &label, const double &value, const std::string &format = "%.3f");
|
||||
bool input_vec3(const std::string &label, const Vec3d &value, float width, const std::string &format = "%.3f");
|
||||
|
@ -144,6 +145,8 @@ public:
|
|||
static void text(const char *label);
|
||||
static void text(const std::string &label);
|
||||
static void text(const wxString &label);
|
||||
void warning_text(const char *all_text);
|
||||
void warning_text(const wxString &all_text);
|
||||
static void text_colored(const ImVec4& color, const char* label);
|
||||
static void text_colored(const ImVec4& color, const std::string& label);
|
||||
static void text_colored(const ImVec4& color, const wxString& label);
|
||||
|
@ -323,6 +326,9 @@ public:
|
|||
static const ImVec4 COL_BUTTON_ACTIVE;
|
||||
|
||||
//BBS add more colors
|
||||
static const ImVec4 COL_RED;
|
||||
static const ImVec4 COL_GREEN;
|
||||
static const ImVec4 COL_BLUE;
|
||||
static const ImVec4 COL_BLUE_LIGHT;
|
||||
static const ImVec4 COL_GREEN_LIGHT;
|
||||
static const ImVec4 COL_HOVER;
|
||||
|
|
|
@ -21,6 +21,9 @@ class SceneRaycasterItem
|
|||
Transform3d m_trafo;
|
||||
|
||||
public:
|
||||
SceneRaycasterItem(int id, const MeshRaycaster& raycaster)
|
||||
: m_id(id), m_raycaster(&raycaster), m_trafo(Transform3d::Identity()), m_use_back_faces(false)
|
||||
{}
|
||||
SceneRaycasterItem(int id, const MeshRaycaster& raycaster, const Transform3d& trafo, bool use_back_faces = false)
|
||||
: m_id(id), m_raycaster(&raycaster), m_trafo(trafo), m_use_back_faces(use_back_faces)
|
||||
{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue