| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| |
|
| | #ifndef SKETCHERGUI_DrawSketchControllableHandler_H
|
| | #define SKETCHERGUI_DrawSketchControllableHandler_H
|
| |
|
| | #include <type_traits>
|
| |
|
| | #include "DrawSketchDefaultHandler.h"
|
| | #include "SnapManager.h"
|
| |
|
| | namespace SketcherGui
|
| | {
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | template<typename ControllerT>
|
| | class DrawSketchControllableHandler: public DrawSketchDefaultHandler<
|
| | typename ControllerT::HandlerType,
|
| | typename ControllerT::SelectModeType,
|
| | ControllerT::AutoConstraintInitialSize,
|
| | typename ControllerT::ContructionMethodType>
|
| | {
|
| |
|
| |
|
| | using HandlerType = typename ControllerT::HandlerType;
|
| | using SelectModeType = typename ControllerT::SelectModeType;
|
| | using ConstructionMethodType = typename ControllerT::ContructionMethodType;
|
| |
|
| |
|
| |
|
| |
|
| | using DSDefaultHandler
|
| | = DrawSketchDefaultHandler<HandlerType, SelectModeType, ControllerT::AutoConstraintInitialSize, ConstructionMethodType>;
|
| |
|
| | using ConstructionMachine = ConstructionMethodMachine<ConstructionMethodType>;
|
| |
|
| |
|
| |
|
| | friend ControllerT;
|
| |
|
| |
|
| | friend typename ControllerT::ControllerBase;
|
| |
|
| | public:
|
| | DrawSketchControllableHandler(
|
| | ConstructionMethodType constructionmethod = static_cast<ConstructionMethodType>(0)
|
| | )
|
| | : DSDefaultHandler(constructionmethod)
|
| | , toolWidgetManager(static_cast<HandlerType*>(this))
|
| | {}
|
| |
|
| | ~DrawSketchControllableHandler() override = default;
|
| |
|
| |
|
| |
|
| | void mouseMove(SnapManager::SnapHandle snapHandle) override
|
| | {
|
| | Base::Vector2d onSketchPos = snapHandle.compute();
|
| | toolWidgetManager.mouseMoved(onSketchPos);
|
| |
|
| | toolWidgetManager.enforceControlParameters(onSketchPos);
|
| | updateDataAndDrawToPosition(onSketchPos);
|
| | toolWidgetManager.adaptParameters(onSketchPos);
|
| | }
|
| |
|
| | bool pressButton(Base::Vector2d onSketchPos) override
|
| | {
|
| |
|
| |
|
| | toolWidgetManager.mouseMoved(onSketchPos);
|
| | toolWidgetManager.enforceControlParameters(onSketchPos);
|
| | updateDataAndDrawToPosition(onSketchPos);
|
| | toolWidgetManager.adaptParameters(onSketchPos);
|
| |
|
| | onButtonPressed(onSketchPos);
|
| | return true;
|
| | }
|
| |
|
| | bool releaseButton(Base::Vector2d onSketchPos) override
|
| | {
|
| | Q_UNUSED(onSketchPos);
|
| | DSDefaultHandler::finish();
|
| | return true;
|
| | }
|
| |
|
| |
|
| |
|
| | protected:
|
| |
|
| |
|
| | std::string getToolName() const override
|
| | {
|
| | return DrawSketchHandler::getToolName();
|
| | }
|
| | QString getCrosshairCursorSVGName() const override
|
| | {
|
| | return DrawSketchHandler::getCrosshairCursorSVGName();
|
| | }
|
| |
|
| |
|
| | private:
|
| |
|
| |
|
| |
|
| |
|
| | void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
| | {
|
| | Q_UNUSED(onSketchPos)
|
| | };
|
| |
|
| | void executeCommands() override {};
|
| | void createAutoConstraints() override {};
|
| |
|
| |
|
| |
|
| |
|
| | |
| | |
| |
|
| | void onButtonPressed(Base::Vector2d onSketchPos) override
|
| | {
|
| | DSDefaultHandler::onButtonPressed(onSketchPos);
|
| | }
|
| |
|
| | void beforeCreateAutoConstraints() override
|
| | {
|
| | toolWidgetManager.addConstraints();
|
| | }
|
| |
|
| | void onWidgetChanged() override
|
| | {
|
| | toolWidgetManager.initControls(DSDefaultHandler::toolwidget);
|
| | }
|
| |
|
| | void onReset() override
|
| | {
|
| | toolWidgetManager.resetControls();
|
| | }
|
| |
|
| | bool onModeChanged() override
|
| | {
|
| | DrawSketchHandler::resetPositionText();
|
| | DrawSketchHandler::updateHint();
|
| |
|
| | toolWidgetManager.onHandlerModeChanged();
|
| |
|
| | if (DSDefaultHandler::onModeChanged()) {
|
| |
|
| | toolWidgetManager.afterHandlerModeChanged();
|
| | }
|
| | return true;
|
| | }
|
| |
|
| | void onConstructionMethodChanged() override
|
| | {
|
| | toolWidgetManager.onConstructionMethodChanged();
|
| | }
|
| |
|
| | void registerPressedKey(bool pressed, int key) override
|
| | {
|
| | DSDefaultHandler::registerPressedKey(pressed, key);
|
| |
|
| | if (key == SoKeyboardEvent::U && !pressed && !this->isLastState()) {
|
| | toolWidgetManager.firstKeyShortcut();
|
| | }
|
| |
|
| | if (key == SoKeyboardEvent::J && !pressed && !this->isLastState()) {
|
| | toolWidgetManager.secondKeyShortcut();
|
| | }
|
| |
|
| | if (key == SoKeyboardEvent::R && !pressed && !this->isLastState()) {
|
| | toolWidgetManager.thirdKeyShortcut();
|
| | }
|
| |
|
| | if (key == SoKeyboardEvent::F && !pressed && !this->isLastState()) {
|
| | toolWidgetManager.fourthKeyShortcut();
|
| | }
|
| |
|
| | if (key == SoKeyboardEvent::TAB && !pressed) {
|
| | toolWidgetManager.tabShortcut();
|
| | }
|
| | }
|
| |
|
| |
|
| | protected:
|
| | ControllerT toolWidgetManager;
|
| | };
|
| |
|
| | }
|
| |
|
| |
|
| | #endif
|
| |
|