void Canvas::drawPoint(const QPoint &point) { LayerPointer l = layers.selectedLayer(); if(l.isNull() || l->isLocked() || l->isHided()){ setCursor(Qt::ForbiddenCursor); return; } // setCursor(Qt::CrossCursor); updateCursor(brush_->width()); brush_->setSurface(l->imagePtr()); brush_->start(point); int rad = (brush_->width() / 2) + 2; update(QRect(lastPoint, point).normalized() .adjusted(-rad, -rad, +rad, +rad)); QVariantMap point_j; point_j.insert("x", point.x()); point_j.insert("y", point.y()); QVariantMap map; map.insert("brush", QVariant(brushInfo())); map.insert("layer", QVariant(currentLayer())); map.insert("point", QVariant(point_j)); map.insert("userid", QVariant(userId())); QVariantMap bigMap; bigMap.insert("info", map); bigMap.insert("action", "drawpoint"); QByteArray tmp = toJson(QVariant(bigMap)); emit sendData(tmp); }
void Canvas::drawLineTo(const QPoint &endPoint) { LayerPointer l = layers.selectedLayer(); if(l.isNull() || l->isLocked() || l->isHided()){ setCursor(Qt::ForbiddenCursor); return; } // setCursor(Qt::CrossCursor); updateCursor(brush_->width()); brush_->setSurface(l->imagePtr()); brush_->lineTo(endPoint); update(); QVariantMap start_j; start_j.insert("x", this->lastPoint.x()); start_j.insert("y", this->lastPoint.y()); QVariantMap end_j; end_j.insert("x", endPoint.x()); end_j.insert("y", endPoint.y()); QVariantMap map; map.insert("brush", QVariant(brushInfo())); map.insert("start", QVariant(start_j)); map.insert("end", QVariant(end_j)); map.insert("layer", QVariant(currentLayer())); map.insert("userid", QVariant(userId())); QVariantMap bigMap; bigMap.insert("info", map); bigMap.insert("action", "drawline"); QByteArray tmp = toJson(QVariant(bigMap)); emit sendData(tmp); }