Sketcher: Use generic tool hints table for DrawSketchHandlerScale
This commit is contained in:
@@ -135,7 +135,22 @@ public:
|
||||
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupScaleHints(state());
|
||||
using enum Gui::InputHint::UserInput;
|
||||
|
||||
return Gui::lookupHints<SelectMode>(
|
||||
state(),
|
||||
{
|
||||
{.state = SelectMode::SeekFirst,
|
||||
.hints =
|
||||
{
|
||||
{QObject::tr("%1 pick reference point"), {MouseLeft}},
|
||||
}},
|
||||
{.state = SelectMode::SeekSecond,
|
||||
.hints =
|
||||
{
|
||||
{QObject::tr("%1 set scale factor"), {MouseLeft}},
|
||||
}},
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -235,18 +250,6 @@ private:
|
||||
bool allowOriginConstraint; // Conserve constraints with origin
|
||||
double refLength, length, scaleFactor;
|
||||
|
||||
struct HintEntry
|
||||
{
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getScaleHintTable();
|
||||
static std::list<Gui::InputHint> lookupScaleHints(SelectMode state);
|
||||
|
||||
|
||||
void deleteOriginalGeos()
|
||||
{
|
||||
std::stringstream stream;
|
||||
@@ -487,30 +490,6 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
DrawSketchHandlerScale::HintTable DrawSketchHandlerScale::getScaleHintTable()
|
||||
{
|
||||
using enum Gui::InputHint::UserInput;
|
||||
|
||||
return {
|
||||
{.state = SelectMode::SeekFirst,
|
||||
.hints = {{QObject::tr("%1 pick reference point", "Sketcher Scale: hint"), {MouseLeft}}}},
|
||||
{.state = SelectMode::SeekSecond,
|
||||
.hints = {{QObject::tr("%1 set reference length", "Sketcher Scale: hint"), {MouseLeft}}}},
|
||||
{.state = SelectMode::SeekThird,
|
||||
.hints = {{QObject::tr("%1 set scale factor", "Sketcher Scale: hint"), {MouseLeft}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerScale::lookupScaleHints(SelectMode state)
|
||||
{
|
||||
const auto scaleHintTable = getScaleHintTable();
|
||||
|
||||
auto it = std::ranges::find_if(scaleHintTable, [state](const HintEntry& entry) {
|
||||
return entry.state == state;
|
||||
});
|
||||
|
||||
return (it != scaleHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
template<>
|
||||
auto DSHScaleControllerBase::getState(int labelindex) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user