Measure: Use Orca color schema

This commit is contained in:
Noisyfox 2023-10-31 16:36:28 +08:00
parent 2c00408d08
commit 4843cda535
10 changed files with 198 additions and 52 deletions

View file

@ -1238,6 +1238,7 @@ void GLGizmoMeasure::render_dimensioning()
const float value_str_width = 20.0f + ImGui::CalcTextSize(curr_value_str.c_str()).x;
static double edit_value = 0.0;
ImGuiWrapper::push_common_window_style(m_parent.get_scale());
const Vec2d label_position = 0.5 * (v1ss + v2ss);
m_imgui->set_next_window_pos(label_position.x(), viewport[3] - label_position.y(), ImGuiCond_Always, 0.0f, 1.0f);
m_imgui->set_next_window_bg_alpha(0.0f);
@ -1255,7 +1256,7 @@ void GLGizmoMeasure::render_dimensioning()
ImVec2 txt_size = ImGui::CalcTextSize(txt.c_str());
const ImGuiStyle& style = ImGui::GetStyle();
draw_list->AddRectFilled({ pos.x - style.FramePadding.x, pos.y + style.FramePadding.y }, { pos.x + txt_size.x + 2.0f * style.FramePadding.x , pos.y + txt_size.y + 2.0f * style.FramePadding.y },
ImGuiWrapper::to_ImU32(ColorRGBA(0.5f, 0.5f, 0.5f, 0.5f)));
ImGuiWrapper::to_ImU32(ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)));
ImGui::SetCursorScreenPos({ pos.x + style.FramePadding.x, pos.y });
m_imgui->text(txt);
ImGui::SameLine();
@ -1385,14 +1386,19 @@ void GLGizmoMeasure::render_dimensioning()
action_exit();
ImGui::SameLine();
ImGuiWrapper::push_confirm_button_style();
if (m_imgui->button(_CTX(L_CONTEXT("Scale", "Verb"), "Verb")))
action_scale(edit_value, curr_value);
ImGuiWrapper::pop_confirm_button_style();
ImGui::SameLine();
ImGuiWrapper::push_cancel_button_style();
if (m_imgui->button(_L("Cancel")))
action_exit();
ImGuiWrapper::pop_cancel_button_style();
ImGui::EndPopup();
}
ImGui::PopStyleVar(4);
ImGuiWrapper::pop_common_window_style();
};
auto point_edge = [this, shader](const Measure::SurfaceFeature& f1, const Measure::SurfaceFeature& f2) {
@ -1561,6 +1567,7 @@ void GLGizmoMeasure::render_dimensioning()
const Vec2d label_position_ss = TransformHelper::world_to_ss(label_position_world,
camera.get_projection_matrix().matrix() * camera.get_view_matrix().matrix(), viewport);
ImGuiWrapper::push_common_window_style(m_parent.get_scale());
m_imgui->set_next_window_pos(label_position_ss.x(), viewport[3] - label_position_ss.y(), ImGuiCond_Always, 0.0f, 1.0f);
m_imgui->set_next_window_bg_alpha(0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
@ -1573,11 +1580,12 @@ void GLGizmoMeasure::render_dimensioning()
ImVec2 txt_size = ImGui::CalcTextSize(txt.c_str());
const ImGuiStyle& style = ImGui::GetStyle();
draw_list->AddRectFilled({ pos.x - style.FramePadding.x, pos.y + style.FramePadding.y }, { pos.x + txt_size.x + 2.0f * style.FramePadding.x , pos.y + txt_size.y + 2.0f * style.FramePadding.y },
ImGuiWrapper::to_ImU32(ColorRGBA(0.5f, 0.5f, 0.5f, 0.5f)));
ImGuiWrapper::to_ImU32(ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)));
ImGui::SetCursorScreenPos({ pos.x + style.FramePadding.x, pos.y });
m_imgui->text(txt);
m_imgui->end();
ImGui::PopStyleVar();
ImGuiWrapper::pop_common_window_style();
};
auto arc_edge_plane = [this, arc_edge_edge](const Measure::SurfaceFeature& f1, const Measure::SurfaceFeature& f2) {
@ -1724,27 +1732,27 @@ void GLGizmoMeasure::render_debug_dialog()
{
auto add_feature_data = [this](const SelectedFeatures::Item& item) {
const std::string text = (item.source == item.feature) ? surface_feature_type_as_string(item.feature->get_type()) : point_on_feature_type_as_string(item.source->get_type(), m_hover_id);
add_strings_row_to_table(*m_imgui, "Type", ImGuiWrapper::COL_ORANGE_LIGHT, text, ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "Type", ImGuiWrapper::COL_ORCA, text, ImGui::GetStyleColorVec4(ImGuiCol_Text));
switch (item.feature->get_type())
{
case Measure::SurfaceFeatureType::Point:
{
add_strings_row_to_table(*m_imgui, "m_pt1", ImGuiWrapper::COL_ORANGE_LIGHT, format_vec3(item.feature->get_point()), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_pt1", ImGuiWrapper::COL_ORCA, format_vec3(item.feature->get_point()), ImGui::GetStyleColorVec4(ImGuiCol_Text));
break;
}
case Measure::SurfaceFeatureType::Edge:
{
auto [from, to] = item.feature->get_edge();
add_strings_row_to_table(*m_imgui, "m_pt1", ImGuiWrapper::COL_ORANGE_LIGHT, format_vec3(from), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_pt2", ImGuiWrapper::COL_ORANGE_LIGHT, format_vec3(to), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_pt1", ImGuiWrapper::COL_ORCA, format_vec3(from), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_pt2", ImGuiWrapper::COL_ORCA, format_vec3(to), ImGui::GetStyleColorVec4(ImGuiCol_Text));
break;
}
case Measure::SurfaceFeatureType::Plane:
{
auto [idx, normal, origin] = item.feature->get_plane();
add_strings_row_to_table(*m_imgui, "m_pt1", ImGuiWrapper::COL_ORANGE_LIGHT, format_vec3(normal), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_pt2", ImGuiWrapper::COL_ORANGE_LIGHT, format_vec3(origin), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_value", ImGuiWrapper::COL_ORANGE_LIGHT, format_double(idx), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_pt1", ImGuiWrapper::COL_ORCA, format_vec3(normal), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_pt2", ImGuiWrapper::COL_ORCA, format_vec3(origin), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_value", ImGuiWrapper::COL_ORCA, format_double(idx), ImGui::GetStyleColorVec4(ImGuiCol_Text));
break;
}
case Measure::SurfaceFeatureType::Circle:
@ -1752,15 +1760,15 @@ void GLGizmoMeasure::render_debug_dialog()
auto [center, radius, normal] = item.feature->get_circle();
const Vec3d on_circle = center + radius * Measure::get_orthogonal(normal, true);
radius = (on_circle - center).norm();
add_strings_row_to_table(*m_imgui, "m_pt1", ImGuiWrapper::COL_ORANGE_LIGHT, format_vec3(center), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_pt2", ImGuiWrapper::COL_ORANGE_LIGHT, format_vec3(normal), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_value", ImGuiWrapper::COL_ORANGE_LIGHT, format_double(radius), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_pt1", ImGuiWrapper::COL_ORCA, format_vec3(center), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_pt2", ImGuiWrapper::COL_ORCA, format_vec3(normal), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_value", ImGuiWrapper::COL_ORCA, format_double(radius), ImGui::GetStyleColorVec4(ImGuiCol_Text));
break;
}
}
std::optional<Vec3d> extra_point = item.feature->get_extra_point();
if (extra_point.has_value())
add_strings_row_to_table(*m_imgui, "m_pt3", ImGuiWrapper::COL_ORANGE_LIGHT, format_vec3(*extra_point), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "m_pt3", ImGuiWrapper::COL_ORCA, format_vec3(*extra_point), ImGui::GetStyleColorVec4(ImGuiCol_Text));
};
m_imgui->begin("Measure tool debug", ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
@ -1772,15 +1780,15 @@ void GLGizmoMeasure::render_debug_dialog()
case EMode::PointSelection: { txt = "Point selection"; break; }
default: { assert(false); break; }
}
add_strings_row_to_table(*m_imgui, "Mode", ImGuiWrapper::COL_ORANGE_LIGHT, txt, ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "Mode", ImGuiWrapper::COL_ORCA, txt, ImGui::GetStyleColorVec4(ImGuiCol_Text));
ImGui::EndTable();
}
ImGui::Separator();
if (ImGui::BeginTable("Hover", 2)) {
add_strings_row_to_table(*m_imgui, "Hover id", ImGuiWrapper::COL_ORANGE_LIGHT, std::to_string(m_hover_id), ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "Hover id", ImGuiWrapper::COL_ORCA, std::to_string(m_hover_id), ImGui::GetStyleColorVec4(ImGuiCol_Text));
const std::string txt = m_curr_feature.has_value() ? surface_feature_type_as_string(m_curr_feature->get_type()) : "None";
add_strings_row_to_table(*m_imgui, "Current feature", ImGuiWrapper::COL_ORANGE_LIGHT, txt, ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, "Current feature", ImGuiWrapper::COL_ORCA, txt, ImGui::GetStyleColorVec4(ImGuiCol_Text));
ImGui::EndTable();
}
@ -1790,14 +1798,14 @@ void GLGizmoMeasure::render_debug_dialog()
else {
const ImGuiTableFlags flags = ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersH;
if (m_selected_features.first.feature.has_value()) {
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Selection 1");
m_imgui->text_colored(ImGuiWrapper::COL_ORCA, "Selection 1");
if (ImGui::BeginTable("Selection 1", 2, flags)) {
add_feature_data(m_selected_features.first);
ImGui::EndTable();
}
}
if (m_selected_features.second.feature.has_value()) {
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Selection 2");
m_imgui->text_colored(ImGuiWrapper::COL_ORCA, "Selection 2");
if (ImGui::BeginTable("Selection 2", 2, flags)) {
add_feature_data(m_selected_features.second);
ImGui::EndTable();
@ -1896,7 +1904,7 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit
ImGui::TableSetColumnIndex(1);
m_imgui->text_colored(col_2_color, col_2);
ImGui::TableSetColumnIndex(2);
if (m_imgui->image_button(ImGui::ClipboardBtnIcon, _L("Copy to clipboard"))) {
if (m_imgui->image_button(m_is_dark_mode ? ImGui::ClipboardBtnDarkIcon : ImGui::ClipboardBtnIcon, _L("Copy to clipboard"))) {
wxTheClipboard->Open();
wxTheClipboard->SetData(new wxTextDataObject(col_1 + ": " + col_2));
wxTheClipboard->Close();
@ -1913,7 +1921,7 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit
const Measure::MeasurementResult& measure = m_measurement_result;
if (measure.angle.has_value()) {
ImGui::PushID("ClipboardAngle");
add_measure_row_to_table(_u8L("Angle"), ImGuiWrapper::COL_ORANGE_LIGHT, format_double(Geometry::rad2deg(measure.angle->angle)) + "°",
add_measure_row_to_table(_u8L("Angle"), ImGuiWrapper::COL_ORCA, format_double(Geometry::rad2deg(measure.angle->angle)) + "°",
ImGui::GetStyleColorVec4(ImGuiCol_Text));
++measure_row_count;
ImGui::PopID();
@ -1927,7 +1935,7 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit
if (use_inches)
distance = GizmoObjectManipulation::mm_to_in * distance;
ImGui::PushID("ClipboardDistanceInfinite");
add_measure_row_to_table(show_strict ? _u8L("Perpendicular distance") : _u8L("Distance"), ImGuiWrapper::COL_ORANGE_LIGHT, format_double(distance) + units,
add_measure_row_to_table(show_strict ? _u8L("Perpendicular distance") : _u8L("Distance"), ImGuiWrapper::COL_ORCA, format_double(distance) + units,
ImGui::GetStyleColorVec4(ImGuiCol_Text));
++measure_row_count;
ImGui::PopID();
@ -1937,7 +1945,7 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit
if (use_inches)
distance = GizmoObjectManipulation::mm_to_in * distance;
ImGui::PushID("ClipboardDistanceStrict");
add_measure_row_to_table(_u8L("Direct distance"), ImGuiWrapper::COL_ORANGE_LIGHT, format_double(distance) + units,
add_measure_row_to_table(_u8L("Direct distance"), ImGuiWrapper::COL_ORCA, format_double(distance) + units,
ImGui::GetStyleColorVec4(ImGuiCol_Text));
++measure_row_count;
ImGui::PopID();
@ -1947,7 +1955,7 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit
if (use_inches)
distance = GizmoObjectManipulation::mm_to_in * distance;
ImGui::PushID("ClipboardDistanceXYZ");
add_measure_row_to_table(_u8L("Distance XYZ"), ImGuiWrapper::COL_ORANGE_LIGHT, format_vec3(distance),
add_measure_row_to_table(_u8L("Distance XYZ"), ImGuiWrapper::COL_ORCA, format_vec3(distance),
ImGui::GetStyleColorVec4(ImGuiCol_Text));
++measure_row_count;
ImGui::PopID();
@ -1956,7 +1964,7 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit
// add dummy rows to keep dialog size fixed
for (unsigned int i = measure_row_count; i < max_measure_row_count; ++i) {
add_strings_row_to_table(*m_imgui, " ", ImGuiWrapper::COL_ORANGE_LIGHT, " ", ImGui::GetStyleColorVec4(ImGuiCol_Text));
add_strings_row_to_table(*m_imgui, " ", ImGuiWrapper::COL_ORCA, " ", ImGui::GetStyleColorVec4(ImGuiCol_Text));
}
ImGui::EndTable();
}

View file

@ -160,6 +160,9 @@ 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):
gizmo->set_icon_filename(m_is_dark ? "toolbar_measure_dark.svg" : "toolbar_measure.svg");
break;
}
}
@ -196,7 +199,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 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 GLGizmoMeasure(m_parent, "measure.svg", EType::Measure));
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 GLGizmoSlaSupports(m_parent, "sla_supports.svg", sprite_id++));
//m_gizmos.emplace_back(new GLGizmoFaceDetector(m_parent, "face recognition.svg", sprite_id++));