Exemplo n.º 1
0
void Canvas::remoteDrawLine(const QPoint &start, const QPoint &end,
                            const QVariantMap &brushInfo,
                            const QString &layer,
                            const quint64 userid)
{
    if(!layers.exists(layer)){
        return;
    }
    LayerPointer l = layers.layerFrom(layer);

    QString brushName = brushInfo["name"].toString();
    int width = brushInfo["width"].toInt();
    QColor color = brushInfo["color"].value<QColor>();

    if(remoteBrush.contains(userid)){
        BrushPointer t = remoteBrush[userid];
        if(brushName != t->brushInfo()["name"].toString()){
            BrushPointer newOne = brushFactory(brushName);
            newOne->setDirectDraw(true);
            newOne->setSurface(l->imagePtr());
            newOne->setWidth(width);
            newOne->setColor(color);
            newOne->lineTo(end);
            remoteBrush[userid] = newOne;
            t.clear();
        }else{
            BrushPointer original = remoteBrush[userid];
            original->setSurface(l->imagePtr());
            original->setWidth(width);
            original->setColor(color);
            original->lineTo(end);
        }
    }else{
        BrushPointer newOne = brushFactory(brushName);
        newOne->setDirectDraw(true);
        newOne->setSurface(l->imagePtr());
        newOne->setWidth(width);
        newOne->setColor(color);
        newOne->lineTo(end);
        remoteBrush[userid] = newOne;
    }

    update();
}
Exemplo n.º 2
0
void Canvas::remoteDrawPoint(const QPoint &point, const QVariantMap &brushInfo,
                             const QString &layer,
                             const quint64 userid)
{
    if(!layers.exists(layer)) return;
    LayerPointer l = layers.layerFrom(layer);

    QString brushName = brushInfo["name"].toString();
    int width = brushInfo["width"].toInt();
    QVariantMap colorMap = brushInfo["color"].toMap();
    QColor color(colorMap["red"].toInt(),
            colorMap["green"].toInt(),
            colorMap["blue"].toInt(),
            colorMap["alpha"].toInt());
//    QColor color = brushInfo["color"].value<QColor>();

    if(remoteBrush.contains(userid)){
        BrushPointer t = remoteBrush[userid];
        if(brushInfo != t->brushInfo()){
            BrushPointer newOne = brushFactory(brushName);
            newOne->setSurface(l->imagePtr());
            newOne->setWidth(width);
            newOne->setColor(color);
            newOne->start(point);
            remoteBrush[userid] = newOne;
            t.clear();
        }else{
            BrushPointer original = remoteBrush[userid];
            original->setSurface(l->imagePtr());
            original->setWidth(width);
            original->setColor(color);
            original->start(point);
        }
    }else{
        BrushPointer newOne = brushFactory(brushName);
        newOne->setSurface(l->imagePtr());
        newOne->setWidth(width);
        newOne->setColor(color);
        newOne->start(point);
        remoteBrush[userid] = newOne;
    }

    update();
}