| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include<cmath> |
| |
|
| | #include <QDockWidget> |
| |
|
| | #include "qg_actionhandler.h" |
| |
|
| | #include "lc_actionhandlerfactory.h" |
| | #include "lc_actionucscreate.h" |
| | #include "lc_defaultactioncontext.h" |
| | #include "lc_graphicviewport.h" |
| | #include "lc_snapmanager.h" |
| |
|
| | #include "qc_applicationwindow.h" |
| | #include "rs_actionlayerstogglelock.h" |
| | #include "rs_actionlibraryinsert.h" |
| | #include "rs_commandevent.h" |
| | #include "rs_commands.h" |
| | #include "rs_debug.h" |
| | #include "rs_dialogfactory.h" |
| | #include "rs_dialogfactoryinterface.h" |
| | #include "rs_graphicview.h" |
| | #include "rs_settings.h" |
| |
|
| | |
| | |
| | |
| | QG_ActionHandler::QG_ActionHandler(QC_ApplicationWindow *parent) |
| | :QObject(parent) { |
| | } |
| |
|
| | void QG_ActionHandler::killAllActions() const { |
| | if (view != nullptr) { |
| | view->killAllActions(); |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | RS_ActionInterface *QG_ActionHandler::getCurrentAction() const { |
| | if (view != nullptr) { |
| | return view->getCurrentAction(); |
| | } else { |
| | return nullptr; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | std::shared_ptr<RS_ActionInterface> QG_ActionHandler::setCurrentAction(RS2::ActionType id, void* data) const { |
| | RS_DEBUG->print("QG_ActionHandler::setCurrentAction()"); |
| | RS_DEBUG->print("QC_ActionHandler::setCurrentAction: view = %p, document = %p", view, document); |
| |
|
| | |
| | if (view==nullptr || document==nullptr) { |
| | RS_DEBUG->print(RS_Debug::D_WARNING,"QG_ActionHandler::setCurrentAction: graphic view or document is nullptr"); |
| | return nullptr; |
| | } |
| |
|
| | std::shared_ptr<RS_ActionInterface> a = createActionInstance(id, data); |
| |
|
| | if (a != nullptr) { |
| | view->setCurrentAction(a); |
| | } |
| |
|
| | RS_DEBUG->print("QG_ActionHandler::setCurrentAction(): OK"); |
| | return a; |
| | } |
| |
|
| | void QG_ActionHandler::setSnapManager(LC_SnapManager* snapManager) { |
| | m_snapManager = snapManager; |
| | } |
| |
|
| | std::shared_ptr<RS_ActionInterface> QG_ActionHandler::createActionInstance(RS2::ActionType id, void* data) const { |
| | return LC_ActionsHandlerFactory::createActionInstance(id, m_actionContext, data); |
| | } |
| |
|
| | |
| | |
| | |
| | QStringList QG_ActionHandler::getAvailableCommands() const { |
| | RS_ActionInterface* currentAction = getCurrentAction(); |
| |
|
| | if (currentAction != nullptr) { |
| | return currentAction->getAvailableCommands(); |
| | } else { |
| | QStringList cmd; |
| | cmd += "line"; |
| | cmd += "rectangle"; |
| | return cmd; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | bool QG_ActionHandler::keycode(const QString& code) { |
| | RS_DEBUG->print("QG_ActionHandler::keycode()"); |
| |
|
| | |
| | RS2::ActionType type = RS_COMMANDS->keycodeToAction(code); |
| | if (type != RS2::ActionNone) { |
| | bool result = m_snapManager->tryToProcessSnapActions(type); |
| | if (!result) { |
| | setCurrentAction(type); |
| | return true; |
| | } |
| | } |
| | return false; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | bool QG_ActionHandler::command(const QString& cmd){ |
| | if (view == nullptr) { |
| | return false; |
| | } |
| |
|
| | if (cmd.isEmpty()){ |
| | if (LC_GET_BOOL("Keyboard/ToggleFreeSnapOnSpace")) { |
| | RS_DEBUG->print("QG_ActionHandler::command: toggle Snap Free: begin"); |
| | bool isSnappingFree = m_snapManager->toggleTemporarySnapFree(); |
| | |
| | |
| | |
| |
|
| | RS_DEBUG->print("QG_ActionHandler::command: toggle Snap Free: OK"); |
| | } |
| | return true; |
| | } |
| |
|
| | RS_DEBUG->print("QG_ActionHandler::command: %s", cmd.toLatin1().data()); |
| | QString c = cmd.toLower().trimmed(); |
| |
|
| | if (c==tr("escape", "escape, go back from action steps")) { |
| | view->back(); |
| | RS_DEBUG->print("QG_ActionHandler::command: back"); |
| | return true; |
| | } |
| |
|
| | |
| | RS_CommandEvent commandEvent(cmd); |
| |
|
| | RS_DEBUG->print("QG_ActionHandler::command: trigger command event in graphic view"); |
| | view->commandEvent(&commandEvent); |
| |
|
| | |
| | |
| | |
| | if (!commandEvent.isAccepted()) { |
| |
|
| | RS_DEBUG->print("QG_ActionHandler::command: convert cmd to action type"); |
| | |
| | RS2::ActionType type = RS_COMMANDS->cmdToAction(cmd); |
| | if (type!=RS2::ActionNone) { |
| | RS_DEBUG->print("QG_ActionHandler::command: setting current action"); |
| | |
| | if (!m_snapManager->tryToProcessSnapActions(type)){ |
| | |
| | setCurrentAction(type); |
| | } |
| | RS_DEBUG->print("QG_ActionHandler::command: current action set"); |
| | return true; |
| | } |
| | }else{ |
| | return true; |
| | } |
| |
|
| | RS_DEBUG->print("QG_ActionHandler::command: current action not set"); |
| | return false; |
| | } |
| |
|
| |
|
| | void QG_ActionHandler::setSnaps(RS_SnapMode const& s) const { |
| | m_snapManager->setSnaps(s); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | void QG_ActionHandler::slotSnapMiddleManual(){ |
| | setCurrentAction(RS2::ActionSnapMiddleManual); |
| | } |
| |
|
| | void QG_ActionHandler::slotSetRelativeZero() { |
| | setCurrentAction(RS2::ActionSetRelativeZero); |
| | } |
| |
|
| | void QG_ActionHandler::slotLockRelativeZero(bool on){ |
| | m_snapManager->setRelativeZeroLock(on); |
| | |
| | view->getViewPort()->lockRelativeZero(on); |
| | } |
| |
|
| | void QG_ActionHandler::setDocumentAndView(RS_Document *doc, RS_GraphicView *graphicView){ |
| | m_actionContext->setDocumentAndView(doc, graphicView); |
| | if (m_snapManager != nullptr) { |
| | m_snapManager->setGraphicView(graphicView); |
| | } |
| | view = graphicView; |
| | document = doc; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|