コード例 #1
0
ファイル: mgcmderase.cpp プロジェクト: Vito2015/vgcore
bool MgCmdErase::touchEnded(const MgMotion* sender)
{
    MgShapes* s = sender->view->shapes();
    
    if (!m_delIds.empty()
        && sender->view->shapeWillDeleted(s->findShape(m_delIds.front()))) {
        int count = 0;
        std::vector<int>::iterator it = m_delIds.begin();
        
        for (; it != m_delIds.end(); ++it) {
            count += sender->view->removeShape(s->findShape(*it));
        }
        if (count > 0) {
            sender->view->regenAll(true);
            char buf[31];
            MgLocalized::formatString(buf, sizeof(buf), sender->view, "@shape_n_deleted", count);
            sender->view->showMessage(buf);
        }
    }
    
    m_delIds.clear();
    m_boxsel = false;
    sender->view->redraw();
    
    return true;
}
コード例 #2
0
ファイル: mgcmdmgr2.cpp プロジェクト: rhcad/touchvg-v0.6
void MgCmdManagerImpl::eraseWnd(const MgMotion* sender)
{
    Box2d snap(sender->view->xform()->getWndRectM());
    std::vector<int> delIds;
    void *it = NULL;
    MgShapes* s = sender->view->shapes();

    for (MgShape* shape = s->getFirstShape(it); shape; shape = s->getNextShape(it)) {
        if (shape->shape()->hitTestBox(snap)) {
            delIds.push_back(shape->getID());
        }
    }
    s->freeIterator(it);

    if (!delIds.empty()
            && sender->view->shapeWillDeleted(s->findShape(delIds.front()))) {
        MgShapesLock locker(MgShapesLock::Remove, sender->view);

        for (std::vector<int>::iterator i = delIds.begin(); i != delIds.end(); ++i) {
            MgShape* shape = s->findShape(*i);
            if (shape && sender->view->removeShape(shape)) {
                shape->release();
            }
        }
        sender->view->regenAll();
    }
}
コード例 #3
0
ファイル: mgcmderase.cpp プロジェクト: thinkfeed/touchvg
bool MgCmdErase::touchEnded(const MgMotion* sender)
{
    MgShapes* s = sender->view->shapes();
    
    if (!m_delIds.empty()
        && sender->view->shapeWillDeleted(s->findShape(m_delIds.front()))) {
        MgShapesLock locker(s, MgShapesLock::Remove);
        int count = 0;
        
        for (std::vector<int>::iterator it = m_delIds.begin(); it != m_delIds.end(); ++it) {
            MgShape* shape = s->findShape(*it);
            if (shape && sender->view->removeShape(shape)) {
                shape->release();
                count++;
            }
        }
        if (count > 0) {
            sender->view->regen();
        }
    }
    
    m_delIds.clear();
    m_boxsel = false;
    sender->view->redraw(false);
    
    return true;
}