同步操作将从 yupengDuan/GraphicsShape 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "gsrootitem.h"#include <QDebug>#include "gsshapebaseitem.h"#include "gsshapelineitem.h"#include <QGraphicsScene>GsRootItem::GsRootItem(const QSizeF &size, QGraphicsObject *parent):QGraphicsObject (parent),m_size(size){m_pTempLayer = new GsTempCanvasLayer(size,this);m_pTempLayer->setZValue(10);m_pShapeFactory = new GsShapeFactory();}GsRootItem::~GsRootItem(){SAFE_DELETE(m_pShapeFactory);}void GsRootItem::drawPress(int id, const QPointF &p){ShapeInfo info;info.firstPos = p;info.type = getCurType();m_Objs.insert(id,info);}void GsRootItem::drawMove(int id, const QPointF &lastPoint, const QPointF &curPoint){if(!m_Objs.contains(id)){return;}ShapeInfo info = m_Objs.value(id);m_pTempLayer->drawShape(info.type,info.firstPos,curPoint);}void GsRootItem::drawRelease(int id, const QPointF &point){if(!m_Objs.contains(id)){return;}ShapeInfo info = m_Objs.value(id);drawRealShape(info.type,info.firstPos,point);m_Objs.remove(id);m_pTempLayer->clear();}void GsRootItem::clear(){QList<QGraphicsItem*> items = this->childItems();QList<QGraphicsItem*>::iterator it = items.begin();while(it != items.end()){QGraphicsItem* item = *it++;if(item->type() == Type_ShapeItem){delete item;item = nullptr;}}}QRectF GsRootItem::boundingRect() const{return QRectF(0,0,m_size.width(),m_size.height());}void GsRootItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){painter->setPen(Qt::NoPen);painter->setBrush(Qt::white);painter->drawRect(this->boundingRect());}void GsRootItem::drawRealShape(GsShapeType type, QPointF p1, QPointF p2){//计算图形绘制区域QRectF rect;rect.setX(qMin(p1.x(),p2.x()));rect.setY(qMin(p1.y(),p2.y()));if(type == Shape_Circle){rect.setWidth(qAbs(p1.y() - p2.y()));rect.setHeight(qAbs(p1.y() - p2.y()));}else{rect.setWidth(qAbs(p1.x() - p2.x()));rect.setHeight(qAbs(p1.y() - p2.y()));}rect.adjust(-5,-5,5,5);GsShapeBaseItem * item = m_pShapeFactory->getShapeItem(type,rect,this);item->drawShape(p1,p2);}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。