代码拉取完成,页面将自动刷新
同步操作将从 yupengDuan/GraphicsShape 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "gsshapeitem.h"
#include <QPainter>
#include <QDebug>
GsShapeItem::GsShapeItem(GsShapeType type, QRectF rectF,QGraphicsObject *parent):
m_boundRectF(rectF),
QGraphicsObject(parent)
{
// setCacheMode(ItemCoordinateCache);
setFlags(ItemIsMovable | ItemIsSelectable);
m_type = type;
}
GsShapeItem::~GsShapeItem()
{
}
QRectF GsShapeItem::boundingRect() const
{
return m_boundRectF;
}
int GsShapeItem::type() const
{
return Type_ShapeItem;
}
void GsShapeItem::drawShape(QPointF p1, QPointF p2)
{
m_firstPoint = p1;
m_lastPoint = p2;
update();
}
void GsShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->setRenderHint(QPainter::Antialiasing);
QColor color = Qt::red;//(rand()%255,rand()%255,rand()%255);
painter->setBrush(color);
painter->setPen(QPen(color,3,Qt::SolidLine,Qt::RoundCap,Qt::RoundJoin));
switch (m_type) {
case Shape_Line:
painter->drawLine(m_firstPoint,m_lastPoint);
break;
case Shape_Rectange:
painter->drawRect(QRectF(m_firstPoint,m_lastPoint));
break;
case Shape_Circle:
painter->drawEllipse(m_firstPoint.x(),m_firstPoint.y(),
qAbs(m_lastPoint.y() - m_firstPoint.y()),
qAbs(m_lastPoint.y() - m_firstPoint.y()));
break;
case Shape_Oval:
painter->drawEllipse(QRectF(m_firstPoint,m_lastPoint));
break;
default:
break;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。