Sketcher: Implement hints for for all drawing tools and modes (consolidates previous PRs into a single PR) (#21632)
* Implement hints for arc * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Change hint text to lower case per comments and style guide * Sketcher: Add input hint to Point tool Adds a structured input hint ("🖱 pick point location") to the Point tool using Gui::InputHint. Hint appears immediately upon tool activation and uses the new `%1` icon injection pattern with MouseLeft. * Sketcher: Add structured input hints for Polyline (LineSet) tool - Adds context-sensitive input hints to the Polyline (LineSet) tool using Gui::InputHint. - Shows "pick first point" and "pick next point" with MouseLeft, and "right-click to finish" with MouseRight, updating as the tool state changes. - Hints appear in the status area to guide users through polyline creation. * Cleanup 'using' and short form of syntax per PR comment * Cleanup 'using' and short form of syntax per PR comment * Add Escape Key to cancel hints * Add MouseRight to cancel hint * MouseRight and Escape Key hints for all states * Sketcher: Add context-sensitive input hints to Line tool - Implements updateHints() for DrawSketchHandlerLine to show "pick first point" and "pick second point" actions with appropriate mouse icons. - Hints update dynamically based on tool state for improved user guidance. * Sketcher: Add context-sensitive input hints to Circle tool - Implements updateHints() for DrawSketchHandlerCircle to show appropriate hints for center and 3-rim construction methods. - Hints update dynamically based on tool state to guide user actions. * Remove cancel hints per PR/Discord feedback discussion * Sketcher: Refine Arc tool input hints for construction method - updateHints() now explicitly distinguishes between Center and ThreeRim construction methods. - Shows accurate context-sensitive hints for both arc creation modes. - Removes generic else for future-proofing and clarity. * Remove cancel hints per Discord discussion * Refactor to use using and short form of class names per PR feedback * Sketcher: Refactor Polygon tool to use new input hints mechanism - Replaces legacy getToolHints() with updateHints() following the modern pattern by @kadet - Ensures consistent, context-sensitive hints for Polygon tool, matching Arc, Line, and Circle tools - Removes cancel hints per maintainer feedback * Sketcher: Refactor Circle tool to use new input hints mechanism - Implements updateHints() for DrawSketchHandlerCircle - Provides context-sensitive hints for both center and 3-rim construction methods - Ensures consistency with Arc, Line, and Polygon tools * Sketcher: Update Rectangle tool to use new input hints mechanism - Implements updateHints() for DrawSketchHandlerRectangle - Provides context-sensitive hints for all supported rectangle construction methods - Ensures consistency with Arc, Line, Circle, and Polygon tools Note: All rectangle construction modes are supported and can be cycled after tool activation, even if not all are directly shown in the UI. * Sketcher: Refactor Slot tool to use new input hints mechanism - Implements updateHints() for DrawSketchHandlerSlot - Provides context-sensitive hints for all slot drawing steps - Ensures consistency with other Sketcher tools * Sketcher: Refactor Arc Slot tool to use new input hints mechanism - Implements updateHints() for DrawSketchHandlerArcSlot - Provides context-sensitive hints for both ArcSlot and RectangleSlot construction methods - Ensures consistency with other Sketcher tools * Sketcher: Refactor B-spline tool to use new input hints mechanism - Implements updateHints() for DrawSketchHandlerBSpline - Provides context-sensitive hints for all B-spline drawing steps - Ensures consistency with other Sketcher tools * Sketcher: Refactor Arc of Parabola tool to use new input hints mechanism - Implements updateHints() for DrawSketchHandlerArcOfParabola - Provides context-sensitive hints for each step of arc of parabola creation - Ensures consistency with other Sketcher tools * Sketcher: Refactor Arc of Ellipse tool to use new input hints mechanism - Implements updateHints() for DrawSketchHandlerArcOfEllipse - Provides context-sensitive hints for each step of arc of ellipse creation - Ensures consistency with other Sketcher tools * Sketcher: Add input hints to Arc of Hyperbola tool - Implements updateHints() for DrawSketchHandlerArcOfHyperbola - Provides context-sensitive hints for each step of arc of hyperbola creation - Ensures consistency with other Sketcher tools - Note: This only adds hints to the existing tool code; no refactor to controller/state machine pattern * Sketcher: Add M key hint to polyline tool - Adds a hint for the M key ("change mode") in the polyline (lineset) tool when drawing subsequent segments. - Improves discoverability of cycling segment/transition modes while drawing. * Merge branch 'sketcher-hints-circle' into sketcher-hints-all-drawing-tools * Restore updateHints() for Circle from sketcher-hints-circle branch * Refactor Sketcher tools to use getToolHints() for input hints (most tools updated, a few pending fine-tuning) * Sketcher: Ensure input hints update after every state change in LineSet tool - Explicitly call updateHint() after all Mode/state transitions in DrawSketchHandlerLineSet. - Fixes missing or stale input hints when using the polyline/lineset tool with custom state machine. - Brings hint update behavior in line with other Sketcher drawing tools. * Sketcher: Refactor Slot tool to use new input hints mechanism * Call updateHint() after setting mode * Sketcher: Add getToolHints() override to Rectangle handler for unified input hints - Revert inccorect previous inadvertent deletions (reverted to main) - Implements getToolHints() in DrawSketchHandlerRectangle to provide context-sensitive input hints. - Brings Rectangle tool in line with other Sketcher handlers using the standard input hint system. - No changes to controller or parameter adaptation logic. * Sketcher: Remove redundant 'click' from Point tool hint text - Change '%1 click to place a point' to '%1 place a point' - Mouse cursor already indicates clicking is needed - Makes hint text more concise and focused on the action * - Change remove implied 'click to finish" to just 'finish' - Mouse cursor already indicates clicking is needed - Makes hint text more concise and focused on the action" * Refactor all handlers to modern compact enum pattern per PR feedback - Use 'using enum Gui::InputHint::UserInput;' for cleaner enum usage - Direct return statements instead of intermediate variables - QObject::tr() for concise translation calls - Consistent modern pattern across all handlers - Improved readability and maintainability - Also implmemented getToolHints() in ArcSlot. * Add M key hint functionality to tools with multiple construction methods: - Circle: Center ↔ 3-point modes - Arc: Center ↔ 3-point modes - Rectangle: Diagonal → Center → 3-corner → Center+2-corner modes - Line: Point+length+angle → Point+width+height → 2-point modes - B-Spline: Control points ↔ Knots modes (+ construction-method-aware hints) Features: - Add 'M switch mode' hints to make mode switching discoverable - Add doConstructionMethodChanged() template specializations to update hints - Use generic 'switch mode' text for initial implementation (vs specific mode names) - Maintain consistent hint patterns across all tools - Preserve existing functionality while adding discoverability Users can now press M to cycle through construction methods in any multi-mode drawing tool and see the mode switching option in the hints panel. This first implementation uses generic 'switch mode' hint to avoid the complexity of tracking mode cycles with drop downs, etc. This would be where integrating hints into the underlying state machine might help * Per PR review feedback, replace repeated inline 'switch mode' hint definitions with const variables: - Define 'const InputHint switchModeHint' once per tool function - Use variable reference in all hint lists instead of inline creation - Reduces code duplication from 30+ repetitions to 5 clean definitions Affected tools: Circle, Arc, Rectangle, Line, B-Spline Improves maintainability - hint text changes only need updates in one location per tool. Follows DRY principle and reviewer feedback. No functional changes - same hints displayed to users. * Per PR feedback, remove repetitive 'arc slot' prefix from hint messages: - 'pick arc slot center' → 'pick slot center' - 'pick arc slot radius' → 'pick slot radius' - 'pick arc slot angle' → 'pick slot angle' - 'pick arc slot width' → 'pick slot width' Context is already clear from the active tool. Follows reviewer feedback to make hints more concise and less verbose. Improves readability while maintaining clarity * per PR feedback, Change 'change mode' to 'switch mode' to match all other drawing tools. * remove hanging Claude * per PR review, restore accidentally deleted Rectangle adaptParameters method Add back DSHRectangleController::adaptParameters template specialization that was accidentally removed during manual file reconstruction. This method handles parameter updates during Rectangle tool interaction, including checkbox synchronization for M key mode switching and proper state management when transitioning between construction methods. Without this method, mode switching leaves the tool in an inconsistent state with misaligned parameters and out-of-sync checkboxes. Addresses reviewer feedback - this functionality should not be removed. * Clean up placeholder comment per PR review feedback * Refactor Arc hints to declarative data-driven architecture Inspired by early feedback regarding separation of code and data, this refactors the Arc tool hints from functional logic to a pure declarative table-driven system. Key improvements: - Pure data-driven hint lookup via static table - Complete separation of hint data from control logic - Elimination of nested if/switch complexity - Establishes reusable pattern for other drawing tools - Maintains identical functionality with a cleaner architecture This creates a scalable template that other sketcher tools and workbenches can adopt, demonstrating proper usage of the InputHint framework through declarative configuration rather than imperative code." * Convert Point tool to declarative hint system Apply the proven declarative pattern to Point tool: - Replace functional getToolHints() with table lookup - Single state tool demonstrates pattern scalability - Maintains identical functionality with cleaner architecture * Convert Line tool to declarative hint system Apply declarative pattern to Line tool with 3 construction methods: - OnePointLengthAngle, OnePointWidthHeight, TwoPoints - All method/state combinations properly handled - Maintains identical functionality with cleaner architecture * Refine Arc tool declarative hints - address maintainer feedback - Use camelCase naming convention (switchModeHint, getArcHintTable) - Move tr() calls to runtime to fix translation caching issues - Preserve declarative table structure with runtime generation - Add structure comments for maintainability - Maintains identical functionality with cleaner implementation * Refine Point tool declarative hints - address feedback - Use camelCase naming (getPointHintTable) - Move tr() calls to runtime to fix translation issues - Preserve simple declarative structure - Point tool has no construction methods, keeps single-state simplicity * Refine Line tool declarative hints - address feedback - Use camelCase naming (switchModeHint, getLineHintTable) - Move tr() calls to runtime to fix translation issues - Preserve declarative table structure with 3 construction methods - Maintains all functionality for OnePointLengthAngle, OnePointWidthHeight, TwoPoints modes * Convert Arc of Ellipse to declarative hint system - Replace functional switch statement with declarative table approach - Use camelCase naming and runtime tr() calls - Maintains 4-state workflow: center, axis, start, end points - Consistent with refined declarative pattern used in Arc/Point/Line tools * Convert Circle to declarative hint system - Replace nested if/switch statements with declarative table approach - Use camelCase naming and runtime tr() calls - Support both Center and ThreeRim construction methods - Maintains all state transitions: center/rim points - Consistent with refined declarative pattern * Convert Polygon to declarative hint system - Replace switch statement with declarative table approach - Use camelCase naming and runtime tr() calls - Simple 2-state tool: center selection and rotation/size - Preserves polygon-specific hints (U/J keys for side count) - Consistent with refined declarative pattern * Convert Slot to declarative hint system - Replace switch statement with declarative table approach - Use camelCase naming and runtime tr() calls - Simple 3-state tool: start point, end point, radius - Consistent with refined declarative pattern * Convert Arc Slot to declarative hint system - Replace switch statement with declarative table approach - Use camelCase naming and runtime tr() calls - 4-state tool: center, radius, angle, width - Consistent with refined declarative pattern * Convert Arc of Hyperbola to declarative hint system - Replace switch statement with declarative table approach - Use camelCase naming and runtime tr() calls - 4-state tool: center, axis, start point, end point - Consistent with refined declarative pattern * Convert Parabola to declarative hint system - Replace switch statement with declarative table approach - Use camelCase naming and runtime tr() calls - 4-state tool: focus point, axis, starting point, end point - Consistent with refined declarative pattern * Convert B-spline to declarative hint system - Replace nested if/switch statements with declarative table approach - Use camelCase naming and runtime tr() calls - Support both ControlPoints and Knots construction methods - Preserves special finish functionality (MouseRight) - Consistent with refined declarative pattern * Convert Ellipse to declarative hint system - Replace nested if/switch statements with declarative table approach - Use camelCase naming and runtime tr() calls - Support both Center and ThreeRim construction methods - 3-state workflow for each method - Consistent with refined declarative pattern * Convert LineSet to declarative hint system - Replace switch statement with declarative table approach - Use camelCase naming and runtime tr() calls - 2-mode tool: first point, then multi-point with finish/switch - Preserves finish and mode switching functionality - Consistent with refined declarative pattern * Convert Rectangle to declarative hint system - Replace nested switch statements with declarative table approach - Use camelCase naming and runtime tr() calls - Support all 4 construction methods: Diagonal, CenterAndCorner, ThreePoints, CenterAnd3Points - Each method has 4-state workflow with switch mode functionality - Consistent with refined declarative pattern --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -28,7 +28,8 @@
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/CommandT.h>
|
||||
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/InputHint.h>
|
||||
#include <Mod/Part/App/Geometry2d.h>
|
||||
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
@@ -41,6 +42,9 @@
|
||||
|
||||
#include "CircleEllipseConstructionMethod.h"
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace SketcherGui
|
||||
@@ -84,6 +88,11 @@ public:
|
||||
~DrawSketchHandlerArc() override = default;
|
||||
|
||||
private:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupArcHints(constructionMethod(), state());
|
||||
}
|
||||
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
switch (state()) {
|
||||
@@ -423,6 +432,21 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
// Hint table structures
|
||||
struct HintEntry
|
||||
{
|
||||
ConstructionMethod method;
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
// Static declaration
|
||||
static Gui::InputHint switchModeHint();
|
||||
static HintTable getArcHintTable();
|
||||
static std::list<Gui::InputHint> lookupArcHints(ConstructionMethod method, SelectMode state);
|
||||
|
||||
private:
|
||||
Base::Vector2d centerPoint, firstPoint, secondPoint;
|
||||
double radius, startAngle, endAngle, arcAngle;
|
||||
@@ -887,6 +911,66 @@ void DSHArcController::addConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
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<Gui::InputHint> 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<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/InputHint.h>
|
||||
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
@@ -218,6 +219,8 @@ public:
|
||||
setAngleSnapping(false);
|
||||
Mode = STATUS_Close;
|
||||
}
|
||||
|
||||
updateHint();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -382,6 +385,9 @@ public:
|
||||
// ViewProvider
|
||||
}
|
||||
}
|
||||
|
||||
updateHint();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -397,8 +403,52 @@ protected:
|
||||
Base::Vector2d centerPoint, axisPoint, startingPoint, endPoint;
|
||||
double rx, ry, startAngle, endAngle, arcAngle, arcAngle_t;
|
||||
std::vector<AutoConstraint> sugConstr1, sugConstr2, sugConstr3, sugConstr4;
|
||||
|
||||
private:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupArcOfEllipseHints(Mode);
|
||||
}
|
||||
|
||||
private:
|
||||
struct HintEntry
|
||||
{
|
||||
int mode;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getArcOfEllipseHintTable();
|
||||
static std::list<Gui::InputHint> lookupArcOfEllipseHints(int mode);
|
||||
};
|
||||
|
||||
DrawSketchHandlerArcOfEllipse::HintTable DrawSketchHandlerArcOfEllipse::getArcOfEllipseHintTable()
|
||||
{
|
||||
return {// Structure: {mode, {hints...}}
|
||||
{STATUS_SEEK_First,
|
||||
{{QObject::tr("%1 pick ellipse center"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{STATUS_SEEK_Second,
|
||||
{{QObject::tr("%1 pick axis point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{STATUS_SEEK_Third,
|
||||
{{QObject::tr("%1 pick arc start point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{STATUS_SEEK_Fourth,
|
||||
{{QObject::tr("%1 pick arc end point"), {Gui::InputHint::UserInput::MouseLeft}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerArcOfEllipse::lookupArcOfEllipseHints(int mode)
|
||||
{
|
||||
const auto arcOfEllipseHintTable = getArcOfEllipseHintTable();
|
||||
|
||||
auto it = std::find_if(arcOfEllipseHintTable.begin(),
|
||||
arcOfEllipseHintTable.end(),
|
||||
[mode](const HintEntry& entry) {
|
||||
return entry.mode == mode;
|
||||
});
|
||||
|
||||
return (it != arcOfEllipseHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/InputHint.h>
|
||||
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
@@ -210,6 +211,8 @@ public:
|
||||
|
||||
Mode = STATUS_Close;
|
||||
}
|
||||
|
||||
updateHint();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -391,6 +394,7 @@ public:
|
||||
// ViewProvider
|
||||
}
|
||||
}
|
||||
updateHint();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -407,8 +411,52 @@ protected:
|
||||
Base::Vector2d centerPoint, axisPoint, startingPoint, endPoint;
|
||||
double arcAngle, arcAngle_t;
|
||||
std::vector<AutoConstraint> sugConstr1, sugConstr2, sugConstr3, sugConstr4;
|
||||
|
||||
private:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupArcOfHyperbolaHints(Mode);
|
||||
}
|
||||
|
||||
private:
|
||||
struct HintEntry
|
||||
{
|
||||
int mode;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getArcOfHyperbolaHintTable();
|
||||
static std::list<Gui::InputHint> lookupArcOfHyperbolaHints(int mode);
|
||||
};
|
||||
|
||||
DrawSketchHandlerArcOfHyperbola::HintTable
|
||||
DrawSketchHandlerArcOfHyperbola::getArcOfHyperbolaHintTable()
|
||||
{
|
||||
return {// Structure: {mode, {hints...}}
|
||||
{STATUS_SEEK_First,
|
||||
{{QObject::tr("%1 pick center point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{STATUS_SEEK_Second,
|
||||
{{QObject::tr("%1 pick axis point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{STATUS_SEEK_Third,
|
||||
{{QObject::tr("%1 pick arc start point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{STATUS_SEEK_Fourth,
|
||||
{{QObject::tr("%1 pick arc end point"), {Gui::InputHint::UserInput::MouseLeft}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerArcOfHyperbola::lookupArcOfHyperbolaHints(int mode)
|
||||
{
|
||||
const auto arcOfHyperbolaHintTable = getArcOfHyperbolaHintTable();
|
||||
|
||||
auto it = std::find_if(arcOfHyperbolaHintTable.begin(),
|
||||
arcOfHyperbolaHintTable.end(),
|
||||
[mode](const HintEntry& entry) {
|
||||
return entry.mode == mode;
|
||||
});
|
||||
|
||||
return (it != arcOfHyperbolaHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/InputHint.h>
|
||||
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
@@ -193,6 +194,8 @@ public:
|
||||
endPoint = onSketchPos;
|
||||
Mode = STATUS_Close;
|
||||
}
|
||||
|
||||
updateHint();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -313,6 +316,7 @@ public:
|
||||
// ViewProvider
|
||||
}
|
||||
}
|
||||
updateHint();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -328,9 +332,52 @@ protected:
|
||||
Base::Vector2d focusPoint, axisPoint, startingPoint, endPoint;
|
||||
double startAngle, endAngle, arcAngle, arcAngle_t;
|
||||
std::vector<AutoConstraint> sugConstr1, sugConstr2, sugConstr3, sugConstr4;
|
||||
|
||||
private:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupParabolaHints(Mode);
|
||||
}
|
||||
|
||||
private:
|
||||
struct HintEntry
|
||||
{
|
||||
int mode;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getParabolaHintTable();
|
||||
static std::list<Gui::InputHint> lookupParabolaHints(int mode);
|
||||
};
|
||||
|
||||
DrawSketchHandlerArcOfParabola::HintTable DrawSketchHandlerArcOfParabola::getParabolaHintTable()
|
||||
{
|
||||
return {// Structure: {mode, {hints...}}
|
||||
{STATUS_SEEK_First,
|
||||
{{QObject::tr("%1 pick focus point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{STATUS_SEEK_Second,
|
||||
{{QObject::tr("%1 pick axis point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{STATUS_SEEK_Third,
|
||||
{{QObject::tr("%1 pick starting point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{STATUS_SEEK_Fourth,
|
||||
{{QObject::tr("%1 pick end point"), {Gui::InputHint::UserInput::MouseLeft}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerArcOfParabola::lookupParabolaHints(int mode)
|
||||
{
|
||||
const auto parabolaHintTable = getParabolaHintTable();
|
||||
|
||||
auto it = std::find_if(parabolaHintTable.begin(),
|
||||
parabolaHintTable.end(),
|
||||
[mode](const HintEntry& entry) {
|
||||
return entry.mode == mode;
|
||||
});
|
||||
|
||||
return (it != parabolaHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
#endif // SKETCHERGUI_DrawSketchHandlerArcOfParabola_H
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/InputHint.h>
|
||||
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
@@ -93,6 +94,23 @@ public:
|
||||
~DrawSketchHandlerArcSlot() override = default;
|
||||
|
||||
private:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupArcSlotHints(state());
|
||||
}
|
||||
|
||||
private:
|
||||
struct HintEntry
|
||||
{
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getArcSlotHintTable();
|
||||
static std::list<Gui::InputHint> lookupArcSlotHints(SelectMode state);
|
||||
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
switch (state()) {
|
||||
@@ -938,6 +956,32 @@ void DSHArcSlotController::addConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
DrawSketchHandlerArcSlot::HintTable DrawSketchHandlerArcSlot::getArcSlotHintTable()
|
||||
{
|
||||
return {// Structure: {SelectMode, {hints...}}
|
||||
{SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick slot center"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick slot radius"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{SelectMode::SeekThird,
|
||||
{{QObject::tr("%1 pick slot angle"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{SelectMode::SeekFourth,
|
||||
{{QObject::tr("%1 pick slot width"), {Gui::InputHint::UserInput::MouseLeft}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerArcSlot::lookupArcSlotHints(SelectMode state)
|
||||
{
|
||||
const auto arcSlotHintTable = getArcSlotHintTable();
|
||||
|
||||
auto it = std::find_if(arcSlotHintTable.begin(),
|
||||
arcSlotHintTable.end(),
|
||||
[state](const HintEntry& entry) {
|
||||
return entry.state == state;
|
||||
});
|
||||
|
||||
return (it != arcSlotHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
|
||||
#include <Gui/InputHint.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
#include "DrawSketchDefaultWidgetController.h"
|
||||
@@ -95,6 +95,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupBSplineHints(constructionMethod(), state());
|
||||
}
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
prevCursorPosition = onSketchPos;
|
||||
@@ -788,6 +792,21 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
struct HintEntry
|
||||
{
|
||||
ConstructionMethod method;
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static Gui::InputHint switchModeHint();
|
||||
static HintTable getBSplineHintTable();
|
||||
static std::list<Gui::InputHint> lookupBSplineHints(ConstructionMethod method,
|
||||
SelectMode state);
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -1086,6 +1105,8 @@ void DSHBSplineController::doConstructionMethodChanged()
|
||||
syncConstructionMethodComboboxToHandler();
|
||||
bool byCtrlPoints = handler->constructionMethod() == ConstructionMethod::ControlPoints;
|
||||
toolWidget->setParameterVisible(WParameter::First, byCtrlPoints);
|
||||
|
||||
handler->updateHint();
|
||||
}
|
||||
|
||||
|
||||
@@ -1193,10 +1214,55 @@ void DSHBSplineController::addConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
Gui::InputHint DrawSketchHandlerBSpline::switchModeHint()
|
||||
{
|
||||
return {QObject::tr("%1 switch mode"), {Gui::InputHint::UserInput::KeyM}};
|
||||
}
|
||||
|
||||
DrawSketchHandlerBSpline::HintTable DrawSketchHandlerBSpline::getBSplineHintTable()
|
||||
{
|
||||
const auto switchHint = switchModeHint();
|
||||
return {
|
||||
// Structure: {ConstructionMethod, SelectMode, {hints...}}
|
||||
|
||||
// ControlPoints method
|
||||
{ConstructionMethod::ControlPoints,
|
||||
SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick first control point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{ConstructionMethod::ControlPoints,
|
||||
SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick next control point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
{QObject::tr("%1 finish B-spline"), {Gui::InputHint::UserInput::MouseRight}},
|
||||
switchHint}},
|
||||
|
||||
// Knots method
|
||||
{ConstructionMethod::Knots,
|
||||
SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick first knot"), {Gui::InputHint::UserInput::MouseLeft}}, switchHint}},
|
||||
{ConstructionMethod::Knots,
|
||||
SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick next knot"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
{QObject::tr("%1 finish B-spline"), {Gui::InputHint::UserInput::MouseRight}},
|
||||
switchHint}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerBSpline::lookupBSplineHints(ConstructionMethod method,
|
||||
SelectMode state)
|
||||
{
|
||||
const auto bSplineHintTable = getBSplineHintTable();
|
||||
|
||||
auto it = std::find_if(bSplineHintTable.begin(),
|
||||
bSplineHintTable.end(),
|
||||
[method, state](const HintEntry& entry) {
|
||||
return entry.method == method && entry.state == state;
|
||||
});
|
||||
|
||||
return (it != bSplineHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
// TODO: On pressing, say, W, modify last pole's weight
|
||||
// TODO: On pressing, say, M, modify next knot's multiplicity
|
||||
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/InputHint.h>
|
||||
|
||||
#include <Mod/Part/App/Geometry2d.h>
|
||||
|
||||
@@ -77,6 +78,11 @@ public:
|
||||
~DrawSketchHandlerCircle() override = default;
|
||||
|
||||
private:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupCircleHints(constructionMethod(), state());
|
||||
}
|
||||
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
switch (state()) {
|
||||
@@ -302,6 +308,19 @@ private:
|
||||
}
|
||||
|
||||
private:
|
||||
struct HintEntry
|
||||
{
|
||||
ConstructionMethod method;
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static Gui::InputHint switchModeHint();
|
||||
static HintTable getCircleHintTable();
|
||||
static std::list<Gui::InputHint> lookupCircleHints(ConstructionMethod method, SelectMode state);
|
||||
|
||||
Base::Vector2d centerPoint, firstPoint, secondPoint;
|
||||
double radius;
|
||||
bool isDiameter;
|
||||
@@ -605,6 +624,13 @@ void DSHCircleController::doChangeDrawSketchHandlerMode()
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void DSHCircleController::doConstructionMethodChanged()
|
||||
{
|
||||
// Just update hints - combobox already handled by framework
|
||||
handler->updateHint();
|
||||
}
|
||||
|
||||
template<>
|
||||
void DSHCircleController::addConstraints()
|
||||
{
|
||||
@@ -701,6 +727,54 @@ void DSHCircleController::addConstraints()
|
||||
// No constraint possible for 3 rim circle.
|
||||
}
|
||||
|
||||
Gui::InputHint DrawSketchHandlerCircle::switchModeHint()
|
||||
{
|
||||
return {QObject::tr("%1 switch mode"), {Gui::InputHint::UserInput::KeyM}};
|
||||
}
|
||||
|
||||
DrawSketchHandlerCircle::HintTable DrawSketchHandlerCircle::getCircleHintTable()
|
||||
{
|
||||
const auto switchHint = switchModeHint();
|
||||
return {
|
||||
// Structure: {ConstructionMethod, SelectMode, {hints...}}
|
||||
|
||||
// Center method
|
||||
{ConstructionMethod::Center,
|
||||
SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick circle center"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{ConstructionMethod::Center,
|
||||
SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick rim point"), {Gui::InputHint::UserInput::MouseLeft}}, switchHint}},
|
||||
|
||||
// ThreeRim method
|
||||
{ConstructionMethod::ThreeRim,
|
||||
SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick first rim point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{ConstructionMethod::ThreeRim,
|
||||
SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick second rim point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{ConstructionMethod::ThreeRim,
|
||||
SelectMode::SeekThird,
|
||||
{{QObject::tr("%1 pick third rim point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerCircle::lookupCircleHints(ConstructionMethod method,
|
||||
SelectMode state)
|
||||
{
|
||||
const auto circleHintTable = getCircleHintTable();
|
||||
|
||||
auto it = std::find_if(circleHintTable.begin(),
|
||||
circleHintTable.end(),
|
||||
[method, state](const HintEntry& entry) {
|
||||
return entry.method == method && entry.state == state;
|
||||
});
|
||||
|
||||
return (it != circleHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
|
||||
@@ -84,6 +84,24 @@ 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());
|
||||
}
|
||||
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
switch (state()) {
|
||||
@@ -952,7 +970,47 @@ 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
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/InputHint.h>
|
||||
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
@@ -37,6 +38,9 @@
|
||||
#include "GeometryCreationMode.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace SketcherGui
|
||||
{
|
||||
|
||||
@@ -251,6 +255,24 @@ private:
|
||||
isConstructionMode());
|
||||
}
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupLineHints(static_cast<int>(constructionMethod()), static_cast<int>(state()));
|
||||
}
|
||||
|
||||
struct HintEntry
|
||||
{
|
||||
int constructionMethod;
|
||||
int state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static Gui::InputHint switchModeHint();
|
||||
static HintTable getLineHintTable();
|
||||
static std::list<Gui::InputHint> lookupLineHints(int method, int state);
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -796,6 +818,65 @@ void DSHLineController::addConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
Gui::InputHint DrawSketchHandlerLine::switchModeHint()
|
||||
{
|
||||
return {QObject::tr("%1 switch mode"), {Gui::InputHint::UserInput::KeyM}};
|
||||
}
|
||||
|
||||
DrawSketchHandlerLine::HintTable DrawSketchHandlerLine::getLineHintTable()
|
||||
{
|
||||
const auto switchHint = switchModeHint();
|
||||
return {// Structure: {constructionMethod, state, {hints...}}
|
||||
|
||||
// OnePointLengthAngle (0)
|
||||
{0,
|
||||
0,
|
||||
{// SeekFirst
|
||||
{QObject::tr("%1 pick first point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{0,
|
||||
1,
|
||||
{// SeekSecond
|
||||
{QObject::tr("%1 pick second point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
|
||||
// OnePointWidthHeight (1)
|
||||
{1,
|
||||
0,
|
||||
{// SeekFirst
|
||||
{QObject::tr("%1 pick first point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{1,
|
||||
1,
|
||||
{// SeekSecond
|
||||
{QObject::tr("%1 pick second point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
|
||||
// TwoPoints (2)
|
||||
{2,
|
||||
0,
|
||||
{// SeekFirst
|
||||
{QObject::tr("%1 pick first point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{2,
|
||||
1,
|
||||
{// SeekSecond
|
||||
{QObject::tr("%1 pick second point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerLine::lookupLineHints(int method, int state)
|
||||
{
|
||||
const auto lineHintTable = getLineHintTable();
|
||||
|
||||
auto it = std::find_if(lineHintTable.begin(),
|
||||
lineHintTable.end(),
|
||||
[method, state](const HintEntry& entry) {
|
||||
return entry.constructionMethod == method && entry.state == state;
|
||||
});
|
||||
|
||||
return (it != lineHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/InputHint.h>
|
||||
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
@@ -96,16 +97,6 @@ public:
|
||||
SNAP_MODE_45Degree
|
||||
};
|
||||
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
using UserInput = Gui::InputHint::UserInput;
|
||||
|
||||
return {
|
||||
{QWidget::tr("%1 change mode"), {UserInput::KeyM}},
|
||||
{QWidget::tr("%1 start drawing"), {UserInput::MouseLeft}},
|
||||
{QWidget::tr("%1 stop drawing"), {UserInput::MouseRight}},
|
||||
};
|
||||
}
|
||||
|
||||
void registerPressedKey(bool pressed, int key) override
|
||||
{
|
||||
@@ -341,6 +332,7 @@ public:
|
||||
|
||||
bool pressButton(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
|
||||
if (Mode == STATUS_SEEK_First) {
|
||||
|
||||
EditCurve[0] = onSketchPos; // this may be overwritten if previousCurve is found
|
||||
@@ -447,6 +439,9 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateHint();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -719,6 +714,9 @@ public:
|
||||
mouseMove(onSketchPos); // trigger an update of EditCurve
|
||||
}
|
||||
}
|
||||
|
||||
updateHint();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -762,11 +760,27 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
struct HintEntry
|
||||
{
|
||||
int mode;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getLineSetHintTable();
|
||||
static std::list<Gui::InputHint> lookupLineSetHints(int mode);
|
||||
|
||||
QString getCrosshairCursorSVGName() const override
|
||||
{
|
||||
return QStringLiteral("Sketcher_Pointer_Create_Lineset");
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupLineSetHints(Mode);
|
||||
}
|
||||
|
||||
protected:
|
||||
SELECT_MODE Mode;
|
||||
SEGMENT_MODE SegmentMode;
|
||||
@@ -827,7 +841,29 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
DrawSketchHandlerLineSet::HintTable DrawSketchHandlerLineSet::getLineSetHintTable()
|
||||
{
|
||||
return {// Structure: {mode, {hints...}}
|
||||
{STATUS_SEEK_First,
|
||||
{{QObject::tr("%1 pick first point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{STATUS_SEEK_Second,
|
||||
{{QObject::tr("%1 pick next point"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
{QObject::tr("%1 finish"), {Gui::InputHint::UserInput::MouseRight}},
|
||||
{QObject::tr("%1 switch mode"), {Gui::InputHint::UserInput::KeyM}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerLineSet::lookupLineSetHints(int mode)
|
||||
{
|
||||
const auto lineSetHintTable = getLineSetHintTable();
|
||||
|
||||
auto it = std::find_if(lineSetHintTable.begin(),
|
||||
lineSetHintTable.end(),
|
||||
[mode](const HintEntry& entry) {
|
||||
return entry.mode == mode;
|
||||
});
|
||||
|
||||
return (it != lineSetHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/InputHint.h>
|
||||
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
@@ -35,6 +36,9 @@
|
||||
#include "DrawSketchDefaultWidgetController.h"
|
||||
#include "DrawSketchControllableHandler.h"
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace SketcherGui
|
||||
{
|
||||
|
||||
@@ -59,6 +63,11 @@ public:
|
||||
~DrawSketchHandlerPoint() override = default;
|
||||
|
||||
private:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupPointHints(static_cast<int>(state()));
|
||||
}
|
||||
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
switch (state()) {
|
||||
@@ -125,6 +134,17 @@ private:
|
||||
|
||||
private:
|
||||
Base::Vector2d editPoint;
|
||||
|
||||
struct HintEntry
|
||||
{
|
||||
int stateValue;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getPointHintTable();
|
||||
static std::list<Gui::InputHint> lookupPointHints(int stateValue);
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -265,6 +285,25 @@ void DSHPointController::addConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
DrawSketchHandlerPoint::HintTable DrawSketchHandlerPoint::getPointHintTable()
|
||||
{
|
||||
return {// Structure: {ConstructionMethod, SelectMode, {hints...}}
|
||||
{0, {{QObject::tr("%1 place a point"), {Gui::InputHint::UserInput::MouseLeft}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerPoint::lookupPointHints(int stateValue)
|
||||
{
|
||||
const auto pointHintTable = getPointHintTable();
|
||||
|
||||
auto it = std::find_if(pointHintTable.begin(),
|
||||
pointHintTable.end(),
|
||||
[stateValue](const HintEntry& entry) {
|
||||
return entry.stateValue == stateValue;
|
||||
});
|
||||
|
||||
return (it != pointHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/InputHint.h>
|
||||
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
@@ -74,29 +75,6 @@ public:
|
||||
{}
|
||||
~DrawSketchHandlerPolygon() override = default;
|
||||
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
using UserInput = Gui::InputHint::UserInput;
|
||||
|
||||
switch (state()) {
|
||||
case SelectMode::SeekFirst:
|
||||
return {
|
||||
{QWidget::tr("%1 pick polygon center"), {UserInput::MouseLeft}},
|
||||
{QWidget::tr("%1/%2 increase / decrease number of sides"),
|
||||
{UserInput::KeyU, UserInput::KeyJ}},
|
||||
};
|
||||
case SelectMode::SeekSecond:
|
||||
return {
|
||||
{QWidget::tr("%1 pick rotation and size"), {UserInput::MouseMove}},
|
||||
{QWidget::tr("%1 confirm"), {UserInput::MouseLeft}},
|
||||
{QWidget::tr("%1/%2 increase / decrease number of sides"),
|
||||
{UserInput::KeyU, UserInput::KeyJ}},
|
||||
};
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
@@ -284,6 +262,23 @@ private:
|
||||
prevCorner = newCorner;
|
||||
}
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupPolygonHints(state());
|
||||
}
|
||||
|
||||
private:
|
||||
struct HintEntry
|
||||
{
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getPolygonHintTable();
|
||||
static std::list<Gui::InputHint> lookupPolygonHints(SelectMode state);
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -552,6 +547,32 @@ void DSHPolygonController::addConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
DrawSketchHandlerPolygon::HintTable DrawSketchHandlerPolygon::getPolygonHintTable()
|
||||
{
|
||||
return {// Structure: {SelectMode, {hints...}}
|
||||
{SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick polygon center"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
{QObject::tr("%1/%2 increase / decrease number of sides"),
|
||||
{Gui::InputHint::UserInput::KeyU, Gui::InputHint::UserInput::KeyJ}}}},
|
||||
{SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick rotation and size"), {Gui::InputHint::UserInput::MouseMove}},
|
||||
{QObject::tr("%1 confirm"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
{QObject::tr("%1/%2 increase / decrease number of sides"),
|
||||
{Gui::InputHint::UserInput::KeyU, Gui::InputHint::UserInput::KeyJ}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerPolygon::lookupPolygonHints(SelectMode state)
|
||||
{
|
||||
const auto polygonHintTable = getPolygonHintTable();
|
||||
|
||||
auto it = std::find_if(polygonHintTable.begin(),
|
||||
polygonHintTable.end(),
|
||||
[state](const HintEntry& entry) {
|
||||
return entry.state == state;
|
||||
});
|
||||
|
||||
return (it != polygonHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
|
||||
#include <Gui/InputHint.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
#include "DrawSketchDefaultWidgetController.h"
|
||||
@@ -109,6 +109,25 @@ public:
|
||||
~DrawSketchHandlerRectangle() override = default;
|
||||
|
||||
private:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupRectangleHints(constructionMethod(), state());
|
||||
}
|
||||
|
||||
private:
|
||||
struct HintEntry
|
||||
{
|
||||
ConstructionMethods::RectangleConstructionMethod method;
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static Gui::InputHint switchModeHint();
|
||||
static HintTable getRectangleHintTable();
|
||||
static std::list<Gui::InputHint>
|
||||
lookupRectangleHints(ConstructionMethods::RectangleConstructionMethod method, SelectMode state);
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
using std::numbers::pi;
|
||||
@@ -2658,7 +2677,110 @@ void DSHRectangleController::addConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void DSHRectangleController::doConstructionMethodChanged()
|
||||
{
|
||||
handler->updateHint();
|
||||
}
|
||||
|
||||
Gui::InputHint DrawSketchHandlerRectangle::switchModeHint()
|
||||
{
|
||||
return {QObject::tr("%1 switch mode"), {Gui::InputHint::UserInput::KeyM}};
|
||||
}
|
||||
|
||||
DrawSketchHandlerRectangle::HintTable DrawSketchHandlerRectangle::getRectangleHintTable()
|
||||
{
|
||||
const auto switchHint = switchModeHint();
|
||||
return {// Structure: {ConstructionMethod, SelectMode, {hints...}}
|
||||
|
||||
// Diagonal method
|
||||
{ConstructionMethods::RectangleConstructionMethod::Diagonal,
|
||||
SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick first corner"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::Diagonal,
|
||||
SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick opposite corner"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::Diagonal,
|
||||
SelectMode::SeekThird,
|
||||
{{QObject::tr("%1 set corner radius or frame thickness"),
|
||||
{Gui::InputHint::UserInput::MouseMove}},
|
||||
switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::Diagonal,
|
||||
SelectMode::SeekFourth,
|
||||
{{QObject::tr("%1 set frame thickness"), {Gui::InputHint::UserInput::MouseMove}},
|
||||
switchHint}},
|
||||
|
||||
// CenterAndCorner method
|
||||
{ConstructionMethods::RectangleConstructionMethod::CenterAndCorner,
|
||||
SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick center"), {Gui::InputHint::UserInput::MouseLeft}}, switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::CenterAndCorner,
|
||||
SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick corner"), {Gui::InputHint::UserInput::MouseLeft}}, switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::CenterAndCorner,
|
||||
SelectMode::SeekThird,
|
||||
{{QObject::tr("%1 set corner radius or frame thickness"),
|
||||
{Gui::InputHint::UserInput::MouseMove}},
|
||||
switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::CenterAndCorner,
|
||||
SelectMode::SeekFourth,
|
||||
{{QObject::tr("%1 set frame thickness"), {Gui::InputHint::UserInput::MouseMove}},
|
||||
switchHint}},
|
||||
|
||||
// ThreePoints method
|
||||
{ConstructionMethods::RectangleConstructionMethod::ThreePoints,
|
||||
SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick first corner"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::ThreePoints,
|
||||
SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick second corner"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::ThreePoints,
|
||||
SelectMode::SeekThird,
|
||||
{{QObject::tr("%1 pick third corner"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::ThreePoints,
|
||||
SelectMode::SeekFourth,
|
||||
{{QObject::tr("%1 set corner radius or frame thickness"),
|
||||
{Gui::InputHint::UserInput::MouseMove}},
|
||||
switchHint}},
|
||||
|
||||
// CenterAnd3Points method
|
||||
{ConstructionMethods::RectangleConstructionMethod::CenterAnd3Points,
|
||||
SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick center"), {Gui::InputHint::UserInput::MouseLeft}}, switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::CenterAnd3Points,
|
||||
SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick first corner"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::CenterAnd3Points,
|
||||
SelectMode::SeekThird,
|
||||
{{QObject::tr("%1 pick second corner"), {Gui::InputHint::UserInput::MouseLeft}},
|
||||
switchHint}},
|
||||
{ConstructionMethods::RectangleConstructionMethod::CenterAnd3Points,
|
||||
SelectMode::SeekFourth,
|
||||
{{QObject::tr("%1 set corner radius or frame thickness"),
|
||||
{Gui::InputHint::UserInput::MouseMove}},
|
||||
switchHint}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerRectangle::lookupRectangleHints(
|
||||
ConstructionMethods::RectangleConstructionMethod method,
|
||||
SelectMode state)
|
||||
{
|
||||
const auto rectangleHintTable = getRectangleHintTable();
|
||||
|
||||
auto it = std::find_if(rectangleHintTable.begin(),
|
||||
rectangleHintTable.end(),
|
||||
[method, state](const HintEntry& entry) {
|
||||
return entry.method == method && entry.state == state;
|
||||
});
|
||||
|
||||
return (it != rectangleHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <Gui/Notifications.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/InputHint.h>
|
||||
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
@@ -80,6 +81,11 @@ public:
|
||||
~DrawSketchHandlerSlot() override = default;
|
||||
|
||||
private:
|
||||
std::list<Gui::InputHint> getToolHints() const override
|
||||
{
|
||||
return lookupSlotHints(state());
|
||||
}
|
||||
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
switch (state()) {
|
||||
@@ -343,6 +349,17 @@ private:
|
||||
double radius, length, angle;
|
||||
bool isHorizontal, isVertical;
|
||||
int firstCurve;
|
||||
|
||||
struct HintEntry
|
||||
{
|
||||
SelectMode state;
|
||||
std::list<Gui::InputHint> hints;
|
||||
};
|
||||
|
||||
using HintTable = std::vector<HintEntry>;
|
||||
|
||||
static HintTable getSlotHintTable();
|
||||
static std::list<Gui::InputHint> lookupSlotHints(SelectMode state);
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -675,6 +692,29 @@ void DSHSlotController::addConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
DrawSketchHandlerSlot::HintTable DrawSketchHandlerSlot::getSlotHintTable()
|
||||
{
|
||||
return {// Structure: {SelectMode, {hints...}}
|
||||
{SelectMode::SeekFirst,
|
||||
{{QObject::tr("%1 pick slot start point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{SelectMode::SeekSecond,
|
||||
{{QObject::tr("%1 pick slot end point"), {Gui::InputHint::UserInput::MouseLeft}}}},
|
||||
{SelectMode::SeekThird,
|
||||
{{QObject::tr("%1 set slot radius"), {Gui::InputHint::UserInput::MouseMove}}}}};
|
||||
}
|
||||
|
||||
std::list<Gui::InputHint> DrawSketchHandlerSlot::lookupSlotHints(SelectMode state)
|
||||
{
|
||||
const auto slotHintTable = getSlotHintTable();
|
||||
|
||||
auto it =
|
||||
std::find_if(slotHintTable.begin(), slotHintTable.end(), [state](const HintEntry& entry) {
|
||||
return entry.state == state;
|
||||
});
|
||||
|
||||
return (it != slotHintTable.end()) ? it->hints : std::list<Gui::InputHint> {};
|
||||
}
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user