diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h index 81c7faa2ea..69318de64c 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h @@ -90,7 +90,55 @@ public: private: std::list getToolHints() const override { - return lookupArcHints(constructionMethod(), state()); + using State = std::pair; + using enum Gui::InputHint::UserInput; + + const auto switchHint = + Gui::InputHint {.message = QObject::tr("%1 switch mode"), .sequences = {KeyM}}; + + return Gui::lookupHints( + {constructionMethod(), state()}, + { + // Center method + {.state = {ConstructionMethod::Center, SelectMode::SeekFirst}, + .hints = + { + {QObject::tr("%1 pick arc center"), {MouseLeft}}, + switchHint, + }}, + {.state = {ConstructionMethod::Center, SelectMode::SeekSecond}, + .hints = + { + {QObject::tr("%1 pick arc start point"), {MouseLeft}}, + switchHint, + }}, + {.state = {ConstructionMethod::Center, SelectMode::SeekThird}, + .hints = + { + {QObject::tr("%1 pick arc end point"), {MouseLeft}}, + switchHint, + }}, + + // ThreeRim method + {.state = {ConstructionMethod::ThreeRim, SelectMode::SeekFirst}, + .hints = + { + {QObject::tr("%1 pick first arc point"), {MouseLeft}}, + switchHint, + }}, + {.state = {ConstructionMethod::ThreeRim, SelectMode::SeekSecond}, + .hints = + { + {QObject::tr("%1 pick second arc point"), {MouseLeft}}, + switchHint, + }}, + {.state = {ConstructionMethod::ThreeRim, SelectMode::SeekThird}, + .hints = + { + {QObject::tr("%1 pick third arc point"), {MouseLeft}}, + switchHint, + }}, + }); } void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override @@ -432,21 +480,6 @@ private: } } - // Hint table structures - struct HintEntry - { - ConstructionMethod method; - SelectMode state; - std::list hints; - }; - - using HintTable = std::vector; - - // Static declaration - static Gui::InputHint switchModeHint(); - static HintTable getArcHintTable(); - static std::list lookupArcHints(ConstructionMethod method, SelectMode state); - private: Base::Vector2d centerPoint, firstPoint, secondPoint; double radius, startAngle, endAngle, arcAngle; @@ -928,60 +961,6 @@ void DSHArcController::doConstructionMethodChanged() handler->updateHint(); } -// Static member definitions -Gui::InputHint DrawSketchHandlerArc::switchModeHint() -{ - return {QObject::tr("%1 switch mode"), {Gui::InputHint::UserInput::KeyM}}; -} - -DrawSketchHandlerArc::HintTable DrawSketchHandlerArc::getArcHintTable() -{ - const auto switchHint = switchModeHint(); - return { - // Structure: {ConstructionMethod, SelectMode, {hints...}} - - // Center method - {ConstructionMethod::Center, - SelectMode::SeekFirst, - {{QObject::tr("%1 pick arc center"), {Gui::InputHint::UserInput::MouseLeft}}, switchHint}}, - {ConstructionMethod::Center, - SelectMode::SeekSecond, - {{QObject::tr("%1 pick arc start point"), {Gui::InputHint::UserInput::MouseLeft}}, - switchHint}}, - {ConstructionMethod::Center, - SelectMode::SeekThird, - {{QObject::tr("%1 pick arc end point"), {Gui::InputHint::UserInput::MouseLeft}}, - switchHint}}, - - // ThreeRim method - {ConstructionMethod::ThreeRim, - SelectMode::SeekFirst, - {{QObject::tr("%1 pick first arc point"), {Gui::InputHint::UserInput::MouseLeft}}, - switchHint}}, - {ConstructionMethod::ThreeRim, - SelectMode::SeekSecond, - {{QObject::tr("%1 pick second arc point"), {Gui::InputHint::UserInput::MouseLeft}}, - switchHint}}, - {ConstructionMethod::ThreeRim, - SelectMode::SeekThird, - {{QObject::tr("%1 pick third arc point"), {Gui::InputHint::UserInput::MouseLeft}}, - switchHint}}}; -} - -std::list DrawSketchHandlerArc::lookupArcHints(ConstructionMethod method, - SelectMode state) -{ - const auto arcHintTable = getArcHintTable(); - - auto it = std::find_if(arcHintTable.begin(), - arcHintTable.end(), - [method, state](const HintEntry& entry) { - return entry.method == method && entry.state == state; - }); - - return (it != arcHintTable.end()) ? it->hints : std::list {}; -} - } // namespace SketcherGui