Exemple #1
0
void MgCmdErase::gatherShapes(const MgMotion* sender, MgShapes* shapes)
{
    if (m_boxsel) {
        MgShapeT<MgRect> shape;
        
        GiContext ctxshap(0, GiColor(0, 0, 255, 128), 
                          isIntersectMode(sender) ? kGiLineDash : kGiLineSolid, GiColor(0, 0, 255, 32));
        *shape.context() = ctxshap;
        ((MgRect*)shape.shape())->setRect2P(sender->startPointM, sender->pointM);
        shapes->addShape(shape);
    }
}
Exemple #2
0
bool MgCmdErase::touchMoved(const MgMotion* sender)
{
    Box2d snap(sender->startPtM, sender->pointM);
    MgShapeIterator it(m_boxsel ? sender->view->shapes() : NULL);
    
    m_delIds.clear();
    while (const MgShape* shape = it.getNext()) {
        if ((isIntersectMode(sender) ? shape->shapec()->hitTestBox(snap)
             : snap.contains(shape->shapec()->getExtent()))
             && shape->shapec()->isVisible() && !shape->shapec()->isLocked()) {
            m_delIds.push_back(shape->getID());
        }
    }
    sender->view->redraw();
    
    return true;
}
Exemple #3
0
bool MgCmdErase::touchMoved(const MgMotion* sender)
{
    Box2d snap(sender->startPointM, sender->pointM);
    void *it = NULL;
    MgShape* shape = m_boxsel ? sender->view->shapes()->getFirstShape(it) : NULL;
    
    m_delIds.clear();
    for (; shape; shape = sender->view->shapes()->getNextShape(it)) {
        if (isIntersectMode(sender) ? shape->shape()->hitTestBox(snap)
            : snap.contains(shape->shape()->getExtent())) {
            m_delIds.push_back(shape->getID());
        }
    }
    sender->view->shapes()->freeIterator(it);
    sender->view->redraw(false);
    
    return true;
}
Exemple #4
0
bool MgCmdErase::draw(const MgMotion* sender, GiGraphics* gs)
{
    if (m_boxsel) {
        GiContext ctxshap(0, GiColor(0, 0, 255, 80), 
                          isIntersectMode(sender) ? GiContext::kDashLine : GiContext::kSolidLine,
                          GiColor(0, 0, 255, 24));
        gs->drawRect(&ctxshap, Box2d(sender->startPtM, sender->pointM));
    }
    
    GiContext ctx(-4, GiColor(64, 64, 64, 128));
    
    for (std::vector<int>::const_iterator it = m_delIds.begin(); it != m_delIds.end(); ++it) {
        const MgShape* shape = sender->view->shapes()->findShape(*it);
        if (shape) {
            shape->draw(1, *gs, &ctx, -1);
        }
    }
    
    return true;
}
Exemple #5
0
bool MgCmdErase::draw(const MgMotion* sender, GiGraphics* gs)
{
    if (m_boxsel) {
        GiContext ctxshap(0, GiColor(0, 0, 255, 80), 
                          isIntersectMode(sender) ? kGiLineDash : kGiLineSolid, GiColor(0, 0, 255, 24));
        
        bool antiAlias = gs->setAntiAliasMode(false);
        gs->drawRect(&ctxshap, Box2d(sender->startPointM, sender->pointM));
        gs->setAntiAliasMode(antiAlias);
    }
    
    GiContext ctx(-4, GiColor(64, 64, 64, 128));
    
    for (std::vector<int>::const_iterator it = m_delIds.begin(); it != m_delIds.end(); ++it) {
        MgShape* shape = sender->view->shapes()->findShape(*it);
        if (shape)
            shape->draw(1, *gs, &ctx);
    }
    
    return true;
}