Sketcher: Use generic tool hints table for DrawSketchHandlerEllipse
This commit is contained in:
@@ -84,22 +84,56 @@ public:
|
||||
~DrawSketchHandlerEllipse() override = default;
|
||||
|
||||
private:
|
||||
struct HintEntry
|
||||
{
|
||||
ConstructionMethod method;
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getEllipseHintTable();
|
||||
static std::list<Gui::InputHint> lookupEllipseHints(ConstructionMethod method,
|
||||
SelectMode state);
|
||||
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupEllipseHints(constructionMethod(), state());
|
||||
using State = std::pair<ConstructionMethod, SelectMode>;
|
||||
using enum Gui::InputHint::UserInput;
|
||||
|
||||
const Gui::InputHint switchModeHint {QObject::tr("%1 switch mode"), {KeyM}};
|
||||
|
||||
return Gui::lookupHints<State>(
|
||||
{constructionMethod(), state()},
|
||||
{
|
||||
// Center method
|
||||
{.state = {ConstructionMethod::Center, SelectMode::SeekFirst},
|
||||
.hints =
|
||||
{
|
||||
{QObject::tr("%1 pick ellipse center"), {MouseLeft}},
|
||||
switchModeHint,
|
||||
}},
|
||||
{.state = {ConstructionMethod::Center, SelectMode::SeekSecond},
|
||||
.hints =
|
||||
{
|
||||
{QObject::tr("%1 pick axis endpoint"), {MouseLeft}},
|
||||
switchModeHint,
|
||||
}},
|
||||
{.state = {ConstructionMethod::Center, SelectMode::SeekThird},
|
||||
.hints =
|
||||
{
|
||||
{QObject::tr("%1 pick minor axis endpoint"), {MouseLeft}},
|
||||
switchModeHint,
|
||||
}},
|
||||
|
||||
// ThreeRim method
|
||||
{.state = {ConstructionMethod::ThreeRim, SelectMode::SeekFirst},
|
||||
.hints =
|
||||
{
|
||||
{QObject::tr("%1 pick first rim point"), {MouseLeft}},
|
||||
switchModeHint,
|
||||
}},
|
||||
{.state = {ConstructionMethod::ThreeRim, SelectMode::SeekSecond},
|
||||
.hints =
|
||||
{
|
||||
{QObject::tr("%1 pick second rim point"), {MouseLeft}},
|
||||
switchModeHint,
|
||||
}},
|
||||
{.state = {ConstructionMethod::ThreeRim, SelectMode::SeekThird},
|
||||
.hints =
|
||||
{
|
||||
{QObject::tr("%1 pick third rim point"), {MouseLeft}},
|
||||
switchModeHint,
|
||||
}},
|
||||
});
|
||||
}
|
||||
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
@@ -978,48 +1012,6 @@ void DSHEllipseController::addConstraints()
|
||||
}
|
||||
// No constraint possible for 3 rim ellipse.
|
||||
}
|
||||
|
||||
DrawSketchHandlerEllipse::HintTable DrawSketchHandlerEllipse::getEllipseHintTable()
|
||||
{
|
||||
return {
|
||||
// Structure: {ConstructionMethod, SelectMode, {hints...}}
|
||||
|
||||
// Center method
|
||||
{ConstructionMethod::Center,
|
||||
SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick ellipse center"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{ConstructionMethod::Center,
|
||||
SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick axis endpoint"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{ConstructionMethod::Center,
|
||||
SelectMode::SeekThird,
|
||||
{{QObject::tr("%1 pick minor axis endpoint"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
|
||||
// ThreeRim method
|
||||
{ConstructionMethod::ThreeRim,
|
||||
SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick first rim point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{ConstructionMethod::ThreeRim,
|
||||
SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick second rim point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{ConstructionMethod::ThreeRim,
|
||||
SelectMode::SeekThird,
|
||||
{{QObject::tr("%1 pick third rim point"), {Gui::InputHint::UserInput::MouseLeft}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerEllipse::lookupEllipseHints(ConstructionMethod method,
|
||||
SelectMode state)
|
||||
{
|
||||
const auto ellipseHintTable = getEllipseHintTable();
|
||||
|
||||
auto it = std::find_if(ellipseHintTable.begin(),
|
||||
ellipseHintTable.end(),
|
||||
[method, state](const HintEntry& entry) {
|
||||
return entry.method == method && entry.state == state;
|
||||
});
|
||||
|
||||
return (it != ellipseHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user