Add tooltips for combo items in rotation optimization dialog
This commit is contained in:
parent
8b5a63eaf8
commit
900814ff47
3 changed files with 26 additions and 33 deletions
|
@ -497,9 +497,6 @@ void GLGizmoRotate3D::on_render()
|
||||||
m_gizmos[Z].render();
|
m_gizmos[Z].render();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * GLGizmoRotate3D::RotoptimzeWindow::options[RotoptimizeJob::get_methods_count()];
|
|
||||||
bool GLGizmoRotate3D::RotoptimzeWindow::options_valid = false;
|
|
||||||
|
|
||||||
GLGizmoRotate3D::RotoptimzeWindow::RotoptimzeWindow(ImGuiWrapper * imgui,
|
GLGizmoRotate3D::RotoptimzeWindow::RotoptimzeWindow(ImGuiWrapper * imgui,
|
||||||
State & state,
|
State & state,
|
||||||
const Alignment &alignment)
|
const Alignment &alignment)
|
||||||
|
@ -517,19 +514,24 @@ GLGizmoRotate3D::RotoptimzeWindow::RotoptimzeWindow(ImGuiWrapper * imgui,
|
||||||
|
|
||||||
ImGui::PushItemWidth(200.f);
|
ImGui::PushItemWidth(200.f);
|
||||||
|
|
||||||
size_t methods_cnt = RotoptimizeJob::get_methods_count();
|
if (ImGui::BeginCombo(_L("Choose goal").c_str(), RotoptimizeJob::get_method_name(state.method_id).c_str())) {
|
||||||
if (!options_valid) {
|
for (size_t i = 0; i < RotoptimizeJob::get_methods_count(); ++i) {
|
||||||
for (size_t i = 0; i < methods_cnt; ++i)
|
if (ImGui::Selectable(RotoptimizeJob::get_method_name(i).c_str())) {
|
||||||
options[i] = RotoptimizeJob::get_method_names()[i].c_str();
|
state.method_id = i;
|
||||||
|
wxGetApp().app_config->set("sla_auto_rotate",
|
||||||
|
"method_id",
|
||||||
|
std::to_string(state.method_id));
|
||||||
|
}
|
||||||
|
|
||||||
options_valid = true;
|
if (ImGui::IsItemHovered())
|
||||||
|
ImGui::SetTooltip("%s", RotoptimizeJob::get_method_description(i).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
|
|
||||||
int citem = state.method_id;
|
if (ImGui::IsItemHovered())
|
||||||
if (ImGui::Combo(_L("Choose goal").c_str(), &citem, options, methods_cnt) ) {
|
ImGui::SetTooltip("%s", RotoptimizeJob::get_method_description(state.method_id).c_str());
|
||||||
state.method_id = citem;
|
|
||||||
wxGetApp().app_config->set("sla_auto_rotate", "method_id", std::to_string(state.method_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
|
|
@ -138,10 +138,6 @@ private:
|
||||||
|
|
||||||
class RotoptimzeWindow {
|
class RotoptimzeWindow {
|
||||||
ImGuiWrapper *m_imgui = nullptr;
|
ImGuiWrapper *m_imgui = nullptr;
|
||||||
|
|
||||||
static const char * options [];
|
|
||||||
static bool options_valid;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
|
|
|
@ -15,13 +15,13 @@ class RotoptimizeJob : public PlaterJob
|
||||||
using FindFn = std::function<Vec2d(const ModelObject & mo,
|
using FindFn = std::function<Vec2d(const ModelObject & mo,
|
||||||
const sla::RotOptimizeParams ¶ms)>;
|
const sla::RotOptimizeParams ¶ms)>;
|
||||||
|
|
||||||
struct FindMethod { std::string name; FindFn findfn; };
|
struct FindMethod { std::string name; FindFn findfn; std::string descr; };
|
||||||
|
|
||||||
static inline const FindMethod Methods[] = {
|
static inline const FindMethod Methods[] = {
|
||||||
{ L("Best surface quality"), sla::find_best_misalignment_rotation },
|
{ L("Best surface quality"), sla::find_best_misalignment_rotation, L("Optimize object rotation for best surface quality.") },
|
||||||
{ L("Least supports"), sla::find_least_supports_rotation },
|
{ L("Least supports"), sla::find_least_supports_rotation, L("Optimize object rotation to have minimum amount of overhangs needing support structures.") },
|
||||||
// Just a min area bounding box that is done for all methods anyway.
|
// Just a min area bounding box that is done for all methods anyway.
|
||||||
{ L("Z axis only"), nullptr }
|
{ L("Z axis only"), nullptr, L("Rotate the object only in Z axis to have the smallest bounding box.") }
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t m_method_id = 0;
|
size_t m_method_id = 0;
|
||||||
|
@ -52,20 +52,15 @@ public:
|
||||||
void finalize() override;
|
void finalize() override;
|
||||||
|
|
||||||
static constexpr size_t get_methods_count() { return std::size(Methods); }
|
static constexpr size_t get_methods_count() { return std::size(Methods); }
|
||||||
static const auto & get_method_names()
|
|
||||||
|
static std::string get_method_name(size_t i)
|
||||||
{
|
{
|
||||||
static bool m_method_names_valid = false;
|
return _utf8(Methods[i].name);
|
||||||
static std::array<std::string, std::size(Methods)> m_method_names;
|
}
|
||||||
|
|
||||||
if (!m_method_names_valid) {
|
static std::string get_method_description(size_t i)
|
||||||
|
{
|
||||||
for (size_t i = 0; i < std::size(Methods); ++i)
|
return _utf8(Methods[i].descr);
|
||||||
m_method_names[i] = _utf8(Methods[i].name);
|
|
||||||
|
|
||||||
m_method_names_valid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_method_names;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue