本文整理汇总了C++中BoxCollider::getRectToDraw方法的典型用法代码示例。如果您正苦于以下问题:C++ BoxCollider::getRectToDraw方法的具体用法?C++ BoxCollider::getRectToDraw怎么用?C++ BoxCollider::getRectToDraw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoxCollider
的用法示例。
在下文中一共展示了BoxCollider::getRectToDraw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
void ItemElement::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QGraphicsPixmapItem::paint(painter,option,widget);
if(qobject_cast<MainScene*>(scene())){
showColliders = qobject_cast<MainScene*>(scene())->showColliders();
if(this->isSelected()){
mRotateEnabled = qobject_cast<MainScene*>(scene())->rotate();
}
} else {
mRotateEnabled = false;
}
if(qobject_cast<SplitScene*>(scene())){
showColliders = true;
}
if(showColliders){
QRectF tmpRect;
QList<QGraphicsItem*> colliders = mTemplate->getColliderRoot()->childItems();
foreach(QGraphicsItem* col, colliders){
if(col->type() == QGraphicsItem::UserType+1){
BoxCollider* boxCol = static_cast<BoxCollider*>(col);
tmpRect = tmpRect.united(boxCol->getRectToDraw().boundingRect());
QPen pen(QColor(Qt::cyan));
pen.setWidth (1);
painter->setPen (pen);
painter->drawPolygon(boxCol->getRectToDraw());
painter->setBrush (QColor(Qt::green));
painter->setOpacity (0.3);
painter->drawPolygon(boxCol->getRectToDraw());
}
if(col->type() == QGraphicsItem::UserType+2){
MeshCollider* meshCol = static_cast<MeshCollider*>(col);
tmpRect = tmpRect.united(meshCol->getPolyToDraw().boundingRect());
QPen pen(QColor(Qt::cyan));
pen.setWidth (1);
painter->setPen (pen);
painter->drawPolygon(meshCol->getPolyToDraw());
painter->setBrush (QColor(Qt::green));
painter->setOpacity (0.3);
painter->drawPolygon(meshCol->getPolyToDraw());
}
if(col->type() == QGraphicsItem::UserType+3){
CircleCollider* cirCol = static_cast<CircleCollider*>(col);
int rad = (int)cirCol->getRadius();
QPointF center = cirCol->getCenter();
QPointF topLeft = QPointF(center.x() - rad,center.y() - rad);
QPointF bottomRight = QPointF((center.x() + rad),(center.y() + rad));
tmpRect = tmpRect.united(QRectF(topLeft,bottomRight));
QPen pen(QColor(Qt::cyan));
pen.setWidth (1);
painter->setPen (pen);
painter->drawEllipse(center,rad,rad);
painter->setBrush (QColor(Qt::green));
painter->setOpacity (0.3);
painter->drawEllipse(center,rad,rad);
}
updateColliderRect(tmpRect);
}
if(mRotateEnabled){
painter->drawEllipse(boundingRect().center(),50,50);
if(mItemDragged){
painter->setPen(QColor(Qt::darkGreen));
painter->setBrush(QColor(Qt::darkGreen));
// painter->drawPie(QRectF(boundingRect().center()-QPointF(50,-50),boundingRect().center()+QPointF(50,-50)),mRotationStartAngle*16,mRotationSpanAngle*16);
}
}
}
}