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(); QVariantMap colorMap = brushInfo["color"].toMap(); QColor color(colorMap["red"].toInt(), colorMap["green"].toInt(), colorMap["blue"].toInt(), colorMap["alpha"].toInt()); if(remoteBrush.contains(userid)){ BrushPointer t = remoteBrush[userid]; if(brushName != t->brushInfo()["name"].toString()){ BrushPointer newOne = brushFactory(brushName); 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->setSurface(l->imagePtr()); newOne->setWidth(width); newOne->setColor(color); newOne->lineTo(end); remoteBrush[userid] = newOne; } update(); }
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(); QColor color = brushInfo["color"].value<QColor>(); if(remoteBrush.contains(userid)){ BrushPointer t = remoteBrush[userid]; if(brushInfo != t->brushInfo()){ BrushPointer newOne = brushFactory(brushName); newOne->setDirectDraw(true); 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->setDirectDraw(true); newOne->setSurface(l->imagePtr()); newOne->setWidth(width); newOne->setColor(color); newOne->start(point); remoteBrush[userid] = newOne; } update(); }
void Canvas::changeBrush(const QString &name) { QVariantMap currentSettings; QPixmap *sur = brush_->surface(); QString brushName = name.toLower(); brushName.chop(6); if(localBrush.contains(brushName)){ brush_ = localBrush[brushName]; currentSettings = brush_->brushInfo(); }else{ brush_ = brushFactory(brushName); localBrush.insert(brushName, brush_); currentSettings = brush_->defaultInfo(); } brush_->setDirectDraw(true); brush_->setSurface(sur); updateCursor(brush_->width()); emit newBrushSettings(currentSettings); }