本文整理汇总了C++中QRectF::setBottomLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::setBottomLeft方法的具体用法?C++ QRectF::setBottomLeft怎么用?C++ QRectF::setBottomLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::setBottomLeft方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadData
void EnvRoomTemplate::LoadData(const QString & filename)
{
QFile file( filename );
if (!file.open( QIODevice::ReadOnly | QIODevice::Text )) {
return;
}
//set base path (for loading resources in same dir)
QTextStream ifs(&file);
//get num colliders
QStringList eachline = ifs.readLine().split(" ");
const int nColliders = eachline.last().toInt();
//read rectangular colliders
for (int i=0; i<nColliders; ++i) {
eachline = ifs.readLine().split(" ");
if (eachline[0].compare("CIRCLE") == 0) {
CircCollider c;
c.pos = QPointF(eachline[1].toFloat(), eachline[2].toFloat());
c.rad = eachline[3].toFloat();
if (eachline[4].compare("IN") == 0) {
c.rad -= 1.0f;
c.stay_inside = true;
}
else {
c.rad += 1.0f;
c.stay_inside = false;
}
circ_colliders.push_back(c);
}
else {
const float x1 = eachline[0].toFloat();
const float y1 = eachline[1].toFloat();
const float x2 = eachline[2].toFloat();
const float y2 = eachline[3].toFloat();
//NOTE: colliders are padded by 1 unit to enforce player's size and prevent viewplane clipping
QRectF c;
c.setBottomLeft(QPointF(qMin(x1, x2) - 1, qMin(y1, y2) - 1));
c.setTopRight(QPointF(qMax(x1, x2) + 1, qMax(y1, y2) + 1));
colliders.push_back(c);
}
}
//read mount points
eachline = ifs.readLine().split(" ");
const int nMounts = eachline.last().toInt();
for (int i=0; i<nMounts; ++i) {
eachline = ifs.readLine().split(" ");
const float px = eachline[0].toFloat();
const float py = eachline[1].toFloat();
const float pz = eachline[2].toFloat();
const float dx = eachline[3].toFloat();
const float dy = eachline[4].toFloat();
const float dz = eachline[5].toFloat();
mount_pts.push_back(QVector3D(px, py, pz));
mount_dirs.push_back(QVector3D(dx, dy, dz));
}
file.close();
}
示例2: mouseMoveEvent
void OverlayEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
QGraphicsScene::mouseMoveEvent(event);
if (event->isAccepted())
return;
if (qgpiSelected && (event->buttons() & Qt::LeftButton)) {
event->accept();
if (wfsHover == Qt::NoSection)
return;
QPointF delta = event->scenePos() - event->buttonDownScenePos(Qt::LeftButton);
bool square = event->modifiers() & Qt::ShiftModifier;
QRectF orig = selectedRect();
switch (wfsHover) {
case Qt::TitleBarArea:
orig.translate(delta);
break;
case Qt::TopSection:
orig.setTop(orig.top() + delta.y());
if (orig.height() < 8.0f)
orig.setTop(orig.bottom() - 8.0f);
if (square)
orig.setRight(orig.left() + orig.height());
break;
case Qt::BottomSection:
orig.setBottom(orig.bottom() + delta.y());
if (orig.height() < 8.0f)
orig.setBottom(orig.top() + 8.0f);
if (square)
orig.setRight(orig.left() + orig.height());
break;
case Qt::LeftSection:
orig.setLeft(orig.left() + delta.x());
if (orig.width() < 8.0f)
orig.setLeft(orig.right() - 8.0f);
if (square)
orig.setBottom(orig.top() + orig.width());
break;
case Qt::RightSection:
orig.setRight(orig.right() + delta.x());
if (orig.width() < 8.0f)
orig.setRight(orig.left() + 8.0f);
if (square)
orig.setBottom(orig.top() + orig.width());
break;
case Qt::TopLeftSection:
orig.setTopLeft(orig.topLeft() + delta);
if (orig.height() < 8.0f)
orig.setTop(orig.bottom() - 8.0f);
if (orig.width() < 8.0f)
orig.setLeft(orig.right() - 8.0f);
if (square) {
qreal size = qMin(orig.width(), orig.height());
QPointF sz(-size, -size);
orig.setTopLeft(orig.bottomRight() + sz);
}
break;
case Qt::TopRightSection:
orig.setTopRight(orig.topRight() + delta);
if (orig.height() < 8.0f)
orig.setTop(orig.bottom() - 8.0f);
if (orig.width() < 8.0f)
orig.setRight(orig.left() + 8.0f);
if (square) {
qreal size = qMin(orig.width(), orig.height());
QPointF sz(size, -size);
orig.setTopRight(orig.bottomLeft() + sz);
}
break;
case Qt::BottomLeftSection:
orig.setBottomLeft(orig.bottomLeft() + delta);
if (orig.height() < 8.0f)
orig.setBottom(orig.top() + 8.0f);
if (orig.width() < 8.0f)
orig.setLeft(orig.right() - 8.0f);
if (square) {
qreal size = qMin(orig.width(), orig.height());
QPointF sz(-size, size);
orig.setBottomLeft(orig.topRight() + sz);
}
break;
case Qt::BottomRightSection:
orig.setBottomRight(orig.bottomRight() + delta);
if (orig.height() < 8.0f)
orig.setBottom(orig.top() + 8.0f);
if (orig.width() < 8.0f)
orig.setRight(orig.left() + 8.0f);
if (square) {
qreal size = qMin(orig.width(), orig.height());
QPointF sz(size, size);
orig.setBottomRight(orig.topLeft() + sz);
}
break;
}
qgriSelected->setRect(orig);
//.........这里部分代码省略.........
示例3: slotMouseMove
//.........这里部分代码省略.........
}
disty = 20;
}
rectf.setTopRight(curPointItem);
}
else if(pos == KResizeFocus::SOUTH_EAST)
{
QPointF topRight = dashRect->rect().topRight();
QPointF bottomLeft = dashRect->rect().bottomLeft();
qreal disty = Util::GetPointDistLine(oppositePos,topRight,curPointItem);
qreal distx = Util::GetPointDistLine(oppositePos,bottomLeft,curPointItem);
if (distx < 20 || flagx != flagx1)
{
if (flagx)
{
curPointItem.setX(oppositePos.x() + 20);
}
else
{
curPointItem.setX(oppositePos.x() - 20);
}
distx = 20;
}
if (disty < 20 || flagy != flagy1)
{
if (flagy)
{
curPointItem.setY(oppositePos.y() + 20);
}
else
{
curPointItem.setY(oppositePos.y() - 20);
}
disty = 20;
}
rectf.setBottomRight(curPointItem);
}
else if(pos == KResizeFocus::SOUTH_WEST)
{
QPointF topLeft = dashRect->rect().topLeft();
QPointF bottomRight = dashRect->rect().bottomRight();
qreal disty = Util::GetPointDistLine(oppositePos,topLeft,curPointItem);
qreal distx = Util::GetPointDistLine(oppositePos,bottomRight,curPointItem);
if (distx < 20 || flagx != flagx1)
{
if (flagx)
{
curPointItem.setX(oppositePos.x() + 20);
}
else
{
curPointItem.setX(oppositePos.x() - 20);
}
distx = 20;
}
if (disty < 20 || flagy != flagy1)
{
if (flagy)
{
curPointItem.setY(oppositePos.y() + 20);
}
else
{
curPointItem.setY(oppositePos.y() - 20);
}
disty = 20;
}
rectf.setBottomLeft(curPointItem);
}
dashRect->setRect(rectf);
}
else if(myMode == MouseMode_ROTATE)
{
QPointF curPos = event->scenePos();
QPointF cpos = this->mapToScene(frame().center());
// qDebug()<<cpos;
qreal angleLast = Util::ComputeAngle(mLastRotatePoint, cpos);
qreal angleCur = Util::ComputeAngle(curPos, cpos);
qreal angle = angleCur - angleLast;
setAngle(angle);
mLastRotatePoint = curPos;
onRotate();
}
else if(myMode == MouseMode_MOVE)
{
onMoving();
}
else
{
QGraphicsItem::mouseMoveEvent(event);
}
}
示例4: qDebug
//.........这里部分代码省略.........
}
//TODO: this is sooooo lazy,
for(QVariant v:mLevelActorMapping){
QMap<QString,QVariant> tmp = v.toMap();
qDebug() << " Mapped LevelActorrr " << tmp;
mLevelActorMap.insert(tmp.firstKey(),tmp.first().toString());
}
Engine* engine = Engine::getInstance();
QQmlEngine* qmlEngine = engine->getQmlEngine();
// Check if bodies are referenced in the Actor Mapping Category
Body* b = nullptr;
std::string actorTypeString;
b2Body* body = mWorld->GetBodyList();
while(body){
actorTypeString = mBox2dJson.getCustomString(body,"actorType");
if(actorTypeString.empty() || actorTypeString == "none"){
b = Body::BodyFromb2Body(body);
if(b) b->setParent(this);
}else{
actorFromMapping(body,actorTypeString,qmlEngine);
}
body = body->GetNext();
}
// Use Nodes for parsing the specific type of node
//QList<LevelNode*> nodes = findChildren<LevelNode*>();
for(LevelNode* node: findChildren<LevelNode*>()) {
switch(node->type()) {
case LevelNode::BODY_REFERENCE:{
actorReferenceBody(node);
}break;
case LevelNode::ACTOR_COMPONENT_W_BODY:{
actorComponentWithBody(node,qmlEngine);
}break;
default:{
qDebug() << " unknown LevelNode type = " << node->type();
}
}
}
//check for images associated with the body.
int imageCount = 0;
body = nullptr;
b = nullptr;
QString image_path;
Actor* actor = nullptr;
ImageRenderer* img_renderer = nullptr;
std::vector<b2dJsonImage*> world_images;
imageCount = mBox2dJson.getAllImages(world_images);
for(b2dJsonImage* img: world_images)
{
if((body = img->body))
{
b = static_cast<Body*>(img->body->GetUserData());
if(b)
{
image_path = Util::getPathToLevel(QString::fromStdString(img->file));
actor = new Actor(b);
actor->setPosition(b->getPosition());
actor->setParent(this);
actor->setParentItem(this);
img_renderer = new ImageRenderer(actor);
img_renderer->setSource(image_path);
img_renderer->setSizeScale(img->scale);
img_renderer->setVisible(true);
img_renderer->setCacheRenderParams(body->GetType() == Body::StaticBody);
QRectF c;
c.setTopLeft(Box2dUtil::toQPointF(img->corners[0]));
c.setTopRight(Box2dUtil::toQPointF(img->corners[1]));
c.setBottomRight(Box2dUtil::toQPointF(img->corners[2]));
c.setBottomLeft(Box2dUtil::toQPointF(img->corners[3]));
img_renderer->setCustomLocalBox(c);
#ifdef D_PARSE
qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[0]);
qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[1]);
qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[2]);
qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[3]);
qDebug() << image_path << " render localbox " << c;
//TODO: fixe the scale ratio, to match box2d.
b2AABB aabb = img->getAABB();
qDebug() <<"Image aabb = " << Box2dUtil::toQRectF(aabb);
// img_renderer->setPosition(QPointF(img->center.x,img->center.y ));
qDebug() << "Image pos = " <<img_renderer->position();
#endif
}
}
}
}else{
qDebug() << "World null, Error Reading jsonfile: \n\t " << errorstring.c_str();
}
w = nullptr;
}
示例5: updateBottomLeft
void AbstractGraphicsRectItem::updateBottomLeft(const QPointF &newPos)
{
QRectF r = rect();
r.setBottomLeft(mapFromScene(newPos));
updateRect(r);
}
示例6: mouseMoveEvent
void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
QPointF newPos(event->scenePos());
if (k->notChange) {
k->notChange = false;
} else {
if (k->action == Scale) {
QRectF rect = k->parent->sceneBoundingRect();
QRectF parentRect = k->parent->sceneBoundingRect();
QRectF parentSquare = k->parent->boundingRect();
// SQA: Lines for debugging purposes
/*
scene()->addRect(rect, QPen(Qt::red));
scene()->addRect(parentRect, QPen(Qt::green));
*/
switch (k->typeNode) {
case TopLeft:
{
k->manager->setAnchor(parentSquare.bottomRight());
rect.setTopLeft(newPos);
break;
}
case TopRight:
{
k->manager->setAnchor(parentSquare.bottomLeft());
rect.setTopRight(newPos);
break;
}
case BottomRight:
{
k->manager->setAnchor(parentSquare.topLeft());
rect.setBottomRight(newPos);
break;
}
case BottomLeft:
{
k->manager->setAnchor(parentSquare.topRight());
rect.setBottomLeft(newPos);
break;
}
case Center:
{
break;
}
};
float sx = 1, sy = 1;
sx = static_cast<float>(rect.width()) / static_cast<float>(parentRect.width());
sy = static_cast<float>(rect.height()) / static_cast<float>(parentRect.height());
if (k->manager->proportionalScale()) {
k->manager->scale(sx, sx);
} else {
if (sx > 0 && sy > 0) {
k->manager->scale(sx, sy);
} else {
if (sx > 0)
k->manager->scale(sx, 1);
if (sy > 0)
k->manager->scale(1, sy);
}
}
} else if (k->action == Rotate) {
QPointF p1 = newPos;
QPointF p2 = k->parent->sceneBoundingRect().center();
k->manager->setAnchor(k->parent->boundingRect().center());
double a = (180 * TupGraphicalAlgorithm::angleForPos(p1, p2)) / M_PI;
k->manager->rotate(a-45);
}
}
if (k->typeNode == Center) {
k->parent->moveBy(event->scenePos().x() - scenePos().x() , event->scenePos().y() - scenePos().y());
event->accept();
}
}
示例7: mouseMoveEvent
//.........这里部分代码省略.........
orig.setRight(rect.right());
m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig); } break;
case RightBottom: {
m_geom.setBottomRight(m_origGeom.bottomRight() + d);
QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
QRectF orig = m_itemView->coreItem()->geometry();
// TODO: optimize
if (m_useMagnets) {
QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
absoluteGeometry.setBottomRight(absoluteGeometry.bottomRight() + (rect.bottomRight() - orig.bottomRight()));
QList<QPointF> pointsList;
QList<CuteReport::BaseItemInterface*> excludeItems;
pointsList << absoluteGeometry.bottomRight();
excludeItems << m_itemView->coreItem();
QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::HVDirection);
orig.setBottomRight(rect.bottomRight() +point);
} else
orig.setBottomRight(rect.bottomRight());
m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);
} break;
case Bottom: {
m_geom.setHeight(m_origGeom.height() + d.y());
QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
QRectF orig = m_itemView->coreItem()->geometry();
// TODO: optimize
if (m_useMagnets) {
QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
absoluteGeometry.setBottom(absoluteGeometry.bottom() + (rect.bottom() - orig.bottom()));
QList<QPointF> pointsList;
QList<CuteReport::BaseItemInterface*> excludeItems;
pointsList << absoluteGeometry.bottomLeft();
excludeItems << m_itemView->coreItem();
QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::VDirection);
orig.setBottom(rect.bottom()+ point.y());
} else
orig.setBottom(rect.bottom());
m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);
} break;
case LeftBottom: {
m_geom.setBottomLeft(m_origGeom.bottomLeft()+ d);
QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
QRectF orig = m_itemView->coreItem()->geometry();
// TODO: optimize
if (m_useMagnets) {
QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
absoluteGeometry.setBottomLeft(absoluteGeometry.bottomLeft() + (rect.bottomLeft() - orig.bottomLeft()));
QList<QPointF> pointsList;
QList<CuteReport::BaseItemInterface*> excludeItems;
pointsList << absoluteGeometry.bottomLeft();
excludeItems << m_itemView->coreItem();
QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::HVDirection);
orig.setBottomLeft(rect.bottomLeft() + point);
} else
orig.setBottomLeft(rect.bottomLeft());
m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);
} break;
case Left: {
m_geom.setLeft(m_origGeom.left() + d.x());
QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
QRectF orig = m_itemView->coreItem()->geometry();
// TODO: optimize
if (m_useMagnets) {
QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
absoluteGeometry.setLeft(absoluteGeometry.left() + (rect.left() - orig.left()));
QList<QPointF> pointsList;
QList<CuteReport::BaseItemInterface*> excludeItems;
pointsList << absoluteGeometry.bottomLeft();
excludeItems << m_itemView->coreItem();
QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::HDirection);
orig.setLeft(rect.left()+ point.x());
} else
orig.setLeft(rect.left());
m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);
// orig.setLeft(rect.left());
// m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);
} break;
default: break;
} // end switch
}