本文整理汇总了C++中sceneRect函数的典型用法代码示例。如果您正苦于以下问题:C++ sceneRect函数的具体用法?C++ sceneRect怎么用?C++ sceneRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sceneRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QFontMetrics
void eScopesScene::drawForeground(QPainter *painter, const QRectF &rect)
{
QGraphicsScene::drawForeground(painter, rect);
QFont fwFont = painter->font();
m_rowTextWidth = QFontMetrics(fwFont).width("0000");
const eU32 fwHeight = QFontMetrics(fwFont).height();
m_headerHeight = 2+2*fwHeight;
tfSong *song = m_seqView->getSong();
if (!song)
return;
for (eU32 i=0; i<tfSong::MAX_SEQ_TRACKS; i++)
{
if (song->getMuted(i))
{
painter->setPen(Qt::black);
painter->fillRect(
i*TRACK_WIDTH+m_rowTextWidth+2,
sceneRect().top()+m_headerHeight,
TRACK_WIDTH,
sceneRect().bottom()-m_headerHeight,
Qt::Dense4Pattern);
}
}
}
示例2: sceneRect
void GameScene::processViewSizeChange(const QSize &newSize)
{
viewSize = newSize;
qreal newRatio = ((qreal) newSize.width()) / newSize.height();
qreal minWidth = 0;
QList<qreal> minWidthByColumn;
for (int col = 0; col < playersByColumn.size(); ++col) {
minWidthByColumn.append(0);
for (int row = 0; row < playersByColumn[col].size(); ++row) {
qreal w = playersByColumn[col][row]->getMinimumWidth();
if (w > minWidthByColumn[col])
minWidthByColumn[col] = w;
}
minWidth += minWidthByColumn[col];
}
minWidth += phasesToolbar->getWidth();
qreal minRatio = minWidth / sceneRect().height();
qreal newWidth;
if (minRatio > newRatio) {
// Aspect ratio is dominated by table width.
newWidth = minWidth;
} else {
// Aspect ratio is dominated by window dimensions.
newWidth = newRatio * sceneRect().height();
}
setSceneRect(0, 0, newWidth, sceneRect().height());
qreal extraWidthPerColumn = (newWidth - minWidth) / playersByColumn.size();
for (int col = 0; col < playersByColumn.size(); ++col)
for (int row = 0; row < playersByColumn[col].size(); ++row)
playersByColumn[col][row]->processSceneSizeChange(minWidthByColumn[col] + extraWidthPerColumn);
}
示例3: Q_ASSERT
void GameScene::spawnPlayer()
{
Q_ASSERT(!m_player);
addItem(m_player = new GraphicsPlayerObject(PLAYER_HEALTH));
const auto playerSize = m_player->boundingRect().size();
QPointF pos{
sceneRect().width() / 2 - playerSize.width() / 2,
sceneRect().height()/* - playerSize.height()*/,
};
m_player->setPos(pos);
m_hudObject->setHealth(m_player->health());
addItem(m_player);
connect(m_player, &GraphicsPlayerObject::cannonTriggered, this,
&GameScene::planeShot);
connect(m_player, &GraphicsPlayerObject::exploded, this,
&GameScene::planeExploded);
connect(m_player, &GraphicsPlayerObject::damaged, m_hudObject,
&GraphicsHudObject::addScore);
connect(m_player, &GraphicsPlayerObject::damaged, m_hudObject,
&GraphicsHudObject::setHealth);
connect(m_player, &GraphicsPlayerObject::exploded, m_hudObject,
&GraphicsHudObject::playerDeath);
setFocusItem(m_player);
}
示例4: sceneRect
void CSharedPainterScene::drawBackgroundImage( boost::shared_ptr<CBackgroundImageItem> image )
{
backgroundImageItem_ = image;
if( image )
{
backgroundPixmap_ = image->createPixmap();
int newSceneW = sceneRect().width();
int newSceneH = sceneRect().height();
QSize size = backgroundPixmap_.size();
if( newSceneW < size.width() )
newSceneW = size.width();
if( newSceneH < size.height() )
newSceneH = size.height();
setSceneRect( 0, 0, newSceneW, newSceneH );
}
else
{
clearBackgroundImage();
return;
}
resetBackground( sceneRect () );
}
示例5: sceneRect
void PaintScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
qreal widthScene = sceneRect().width();
qreal sceneHeight = sceneRect().height();
QImage image(widthScene, sceneHeight,QImage::Format_RGB32);
//image.fill(Qt::white);
QPainter painter(&image);
painter.setRenderHint(QPainter::Antialiasing);
render(&painter);
QPoint newPos;
newPos.setX(event->scenePos().x());
newPos.setY(event->scenePos().y());
QPen pen;
pen.setWidth(brushWidth());
pen.setColor(brushColor());
painter.setPen(pen);
QString type("Pencil");
QRect rect = drawRect(type, painter, m_oldPos, newPos);
m_oldPos = newPos;
QBrush br(image);
br.setColor(Qt::transparent);
setBackgroundBrush(br);
update();
QGraphicsScene::mouseMoveEvent(event);
}
示例6: sceneRect
void ReportRectEntity::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
//Update and show properties
m_ppos->setScenePos(QPointF(sceneRect().x(), sceneRect().y()));
m_reportDesigner->changeSet(m_pset);
setSelected(true);
scene()->update();
}
示例7: expander
void GraphDrawingScene::expandSceneRect(const QPoint& position)
{
// start by creating a rectangle around the position that has been passed
QRect expander(position.x() - 250, position.y() - 250, 500, 500);
// calculate the bounding rectangle of what we already have and what we wan to add
setSceneRect(sceneRect().united(expander));
dynamic_cast<GraphDrawingView*>(parent())->setSceneRect(sceneRect());
}
示例8: setSceneRect
void MessageView::setWidth(int width)
{
setSceneRect(sceneRect().x(), sceneRect().y(), width, sceneRect().height());
QListIterator<YawnerNS::UiNS::ViewNS::MessageViewNS::MessageItem*> it(_messagesItems);
while (it.hasNext()) {
it.next()->setWidth(width - std::min(4, verticalScrollBar()->width()));
}
layoutItems(&_messagesItems);
}
示例9: connect
void SinglePlayerView::hideMsg()
{
connect( msgtline, SIGNAL( finished() ), this, SLOT( cleanUpMsg() ) );
msganimation->setPosAt( 0, sceneRect().center() - msg->boundingRect().center() );
msganimation->setScaleAt( 0, 1, 1 );
msganimation->setPosAt( 1, QPointF( sceneRect().center().x(), sceneRect().bottomRight().y() ) );
msganimation->setScaleAt( 1, 0.01, 0.01 );
msgtline->start();
}
示例10: sig_viewportScrolled
void MapView::scrollContentsBy(int dx, int dy)
{
QGraphicsView::scrollContentsBy( dx, dy );
emit sig_viewportScrolled(
std::max(0.0, (double)mapToScene(rect()).boundingRect().x() / (double)sceneRect().width()),
std::max(0.0, (double)mapToScene(rect()).boundingRect().y() / (double)sceneRect().height()));
}
示例11: pixmap
void GraphicsScene::printPage(int index, int percentual , QPainter &painter, QPrinter * printer)
{
QPixmap pixmap(painter.viewport().width(),painter.viewport().height()); /* virtual paper */
bool portrait = printer->orientation() == QPrinter::Portrait ? true : false;
const qreal wit = qMin(printer->pageRect().width(),printer->paperRect().width());
const qreal hei = qMin(printer->pageRect().height(),printer->paperRect().height());
const qreal faktor_print = qMax(wit,hei) / qMin(wit,hei);
const QRect Paper_Rect = printer->pageRect();
qreal onepagescene_HI = sceneRect().width() * faktor_print;
if (!portrait) {
onepagescene_HI = sceneRect().width() / faktor_print;
}
QRectF rectScenePiece = QRectF (0.,0.,sceneRect().width(),onepagescene_HI); /* first slice from scene */
const qreal page = sceneRect().height() / onepagescene_HI; /* page need */
int PageSumm = page;
if (page > PageSumm) {
PageSumm++; /* float to next int */
}
if ( index > PageSumm ) {
return; /* not having this page */
}
qreal InitOnYtop = 0;
if (index != 0) {
InitOnYtop = rectScenePiece.height() * index;
}
QRect pagepiece = QRect(0,InitOnYtop,rectScenePiece.width(),rectScenePiece.height());
//////////qDebug() << "### page " << index << "," << percentual << "," << printer->pageRect();
const qreal smallpart = qMax(pixmap.width(),pixmap.height()) / faktor_print;
QRectF AFormatPaper;
/* Paper dimension from printer Faktor run */
if (portrait) {
AFormatPaper = QRect(0,0,smallpart,qMax(pixmap.width(),pixmap.height()));
} else {
AFormatPaper = QRect(0,0,qMax(pixmap.width(),pixmap.height()),smallpart);
}
QRectF ZoomFaktorPage = Reduce(AFormatPaper,percentual); /* zoom rect */
QRect WhitePaper = CenterRectSlaveFromMaster(pixmap.rect(),AFormatPaper).toRect();
QRect RenderPage = CenterRectSlaveFromMaster(pixmap.rect(),ZoomFaktorPage).toRect();
painter.fillRect(painter.viewport(),QBrush(Qt::lightGray)); /* device to cover */
painter.fillRect(WhitePaper,QBrush(Qt::white)); /* paper */
/////////painter.fillRect(RenderPage,QBrush(Qt::red)); /* page result */
render(&painter,RenderPage,pagepiece,Qt::KeepAspectRatio);
}
示例12: tr
void OpenInfraPlatform::UserInterface::Alignment2DScene::exportToFile(QWidget* parent)
{
QString filter;
QString fn = QFileDialog::getSaveFileName(parent, tr("Save Vertical Alignment as..."), QString(), tr("PNG File (*.png);; JPG File (*.jpg);; PDF File (*.pdf);; SVG File (*.svg)"), &filter);
if(fn.isEmpty())
return;
if(filter == "PNG File (*.png)" || filter == "JPG File (*.jpg)")
{
QImage image(sceneRect().size().toSize(), QImage::Format::Format_ARGB32);
image.fill(Qt::darkGray);
QPainter painter(&image);
painter.setRenderHints(QPainter::Antialiasing);
render(&painter);
image.save(fn);
}
else
{
QPrinter printer;
QSvgGenerator svgGen;
QPaintDevice* device;
if(filter == "PDF File (*.pdf)")
{
printer.setResolution(QPrinter::HighResolution);
printer.setPageSize( QPrinter::A4 );
printer.setOrientation( QPrinter::Landscape );
printer.setOutputFormat( QPrinter::PdfFormat );
printer.setOutputFileName(fn);
device = &printer;
}
else if(filter == "SVG File (*.svg)")
{
QRectF rect = sceneRect();
svgGen.setFileName(fn);
svgGen.setSize(QSize(rect.width(),rect.height()));
svgGen.setViewBox(QRect(0,0,rect.width(),rect.height()));
svgGen.setTitle("Vertical Alignment");
device = &svgGen;
}
else
{
return;
}
QPainter painter(device);
configureColors(A2D_DrawState::A2D_Print);
render(&painter);
configureColors(A2D_DrawState::A2D_Draw);
}
}
示例13: fm
void
AnimatorScene::setSceneInfoText(QString text, bool show)
{
m_sceneInfoText->setText (text);
m_sceneInfoText->setVisible (show);
QFontMetrics fm (font ());
QRectF r = sceneRect ();
QPointF pos = QPointF ((sceneRect ().width () - fm.width (text))/2, r.center ().y ());
m_sceneInfoText->setPos (pos);
}
示例14: setSceneRect
void Tchart::ajustChartHeight() {
qreal factor = (viewport()->rect().height() / scene->sceneRect().height()) * 0.95;
if (viewport()->rect().width() > (scene->sceneRect().width() + qAbs(sceneRect().x())) * factor) {
setSceneRect(0, 0, viewport()->rect().width() / factor, scene->sceneRect().height());
} else {
setSceneRect(sceneRect().adjusted(-sceneRect().x(), 0, qAbs(sceneRect().x()), 0));
}
scale(factor, factor);
horizontalScrollBar()->setValue(horizontalScrollBar()->minimum());
}
示例15: backgroundBrush
void FormEditorGraphicsView::drawBackground(QPainter *painter, const QRectF &rect)
{
painter->save();
painter->setBrushOrigin(0, 0);
painter->fillRect(rect.intersected(sceneRect()), backgroundBrush());
// paint rect around editable area
painter->setPen(Qt::black);
QRectF frameRect = sceneRect().adjusted(0, 0, 0, 0);
painter->drawRect(frameRect);
painter->restore();
}