示例#1
0
bool MgCmdManagerImpl::doAction(const MgMotion* sender, int action)
{
    MgView* view = sender->view;
    MgSelection *sel = getSelection();
    bool ret = false;
    
    switch (action) {
        case kMgActionSelAll:
            ret = sel && sel->selectAll(sender);
            break;
            
        case kMgActionSelReset:
            if (sel) sel->resetSelection(sender);
            break;
            
        case kMgActionDraw:
            ret = setCommand(sender, "@draw", NULL);
            break;
            
        case kMgActionCancel:
            ret = setCommand(sender, "select", NULL);
            break;
            
        case kMgActionDelete:
            ret = sel && sel->deleteSelection(sender);
            break;
            
        case kMgActionClone:
            ret = sel && sel->cloneSelection(sender);
            break;

        case kMgActionGroup:
            ret = sel && sel->groupSelection(sender);
            break;

        case kMgActionUngroup:
            ret = sel && sel->ungroupSelection(sender);
            break;
            
        case kMgActionFixedLength:
        case kMgActionFreeLength:
            ret = sel && sel->setFixedLength(sender, !sel->isFixedLength(view));
            break;
            
        case kMgActionLocked:
        case kMgActionUnlocked:
            ret = sel && sel->setLocked(sender, !sel->isLocked(view));
            break;
            
        case kMgActionEditVertex:
        case kMgActionHideVertex:
            ret = sel && sel->setEditMode(sender, !sel->isEditMode(view));
            break;
            
        case kMgActionClosed:
        case kMgActionOpened:
            ret = sel && sel->switchClosed(sender);
            break;
            
        case kMgActionAddVertex:
            ret = sel && sel->insertVertext(sender);
            break;
            
        case kMgActionDelVertex:
            ret = sel && sel->deleteVertext(sender);
            break;
            
        case kMgActionOverturn:
            ret = sel && sel->overturnPolygon(sender);
            break;
            
        default: {
            ret = sender->view->getCmdSubject()->doAction(sender, action);
            MgCommand* cmd = getCommand();
            ret = ret || (cmd && cmd->doContextAction(sender, action));
            
            if (!ret && cmd && !cmd->isDrawingCommand()) {
                ret = sender->view->getCmdSubject()->doEndAction(sender, action);
                cmd = findCommand(_drawcmd.c_str());
                ret = ret || (cmd && cmd->doContextAction(sender, action));
            }
            break;
        }
    }
    LOGD("doAction(%d) %s", action, ret ? "ok" : "fail");
    
    return ret;
}
示例#2
0
bool TransformCmd::doContextAction(const MgMotion* sender, int action)
{
    return _lastCmd && _lastCmd->doContextAction(sender, action);
}