• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setSceneRect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中setSceneRect函数的典型用法代码示例。如果您正苦于以下问题:C++ setSceneRect函数的具体用法?C++ setSceneRect怎么用?C++ setSceneRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setSceneRect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: views

void GraphicsCardSelectionScene::calculateScene()
{
    // check if there is a view this scene is drawn in
    if(views().isEmpty()) return;
    QGraphicsView *view = views().first();

    int n = items().count();
    if(n < 1) return; 

    qreal w, h, xoffset;
    qreal f = 1.0;

    do {
        w = view->viewport()->width() * f * 0.8; // the width of the arc
        h = view->viewport()->height() * f * 0.6; // the height of the arc
        xoffset = w / n;
        f -= 0.1;
    } while(xoffset >= 45.0 && f > 0.1);

    qreal x = - xoffset * ((n == 1) ? 0 : (n / 2)); // starting position
    qreal r = (w*w + h*h) / (2 * h); // the radius of the circle as a function of w and h

    if(n % 2) x -= xoffset / 2;

    for(int i = 0; i < n; ++i)
    {
        GraphicsGameCardItem *item;
        item = static_cast<GraphicsGameCardItem*>(items().at(i));

        qreal y = r + qSqrt(r*r - x*x); // the y offset for this card on the arc

        item->setOffset(x, -y);
        item->setTransformOriginPoint(item->offset());
        item->setRotation(360 * qAsin(x/r) / (2 * M_PI)); // the card's rotation angle as degrees
        x += xoffset;
    }

    QRectF rect = sceneRect();
    setSceneRect(rect.x(), rect.y() -50.0, rect.width(), rect.height() +50.0);
}
开发者ID:rku,项目名称:Settleboard,代码行数:40,代码来源:GraphicsCardSelectionScene.cpp


示例2: setSceneRect

void CurvedTreeGraphicsScene::updateTree()
{
    m_height = m_stepCount * g_settings->treeStepHeight;
    setSceneRect(0.0, 0.0, m_width, m_height);
    QPen pen = getTreePen();

    //Since curved trees can be very narrow during early stages
    //of a simulation, it will be drawn wider if it takes up less
    //than a defined fraction of the available width.

    double minX = 1.0;
    double maxX = 0.0;
    for (std::list<CurvedTreeLine *>::iterator i = m_lines.begin(); i != m_lines.end(); ++i)
    {
        CurvedTreeLine * line = *i;
        for (size_t j = 0; j < line->m_points.size(); ++j)
        {
            double pointX = line->m_points[j].x();
            if (pointX < minX)
                minX = pointX;
            if (pointX > maxX)
                maxX = pointX;
        }
    }
    double rangeFromCentre = std::max(maxX - 0.5, 0.5 - minX);

    //0.45 is the target range: taking up most of the available space.
    //If it is less than this, we'll widen the tree.
    //If it is more, the widening factor will be less than 1 and the
    //tree will be narrowed.
    double wideningFactor = 0.45 / rangeFromCentre;

    //A very narrow tree will look odd if overly widened, so limit
    //widening to a factor of 20.
    if (wideningFactor > 20.0)
        wideningFactor = 20.0;

    for (std::list<CurvedTreeLine *>::iterator i = m_lines.begin(); i != m_lines.end(); ++i)
        (*i)->updateLine(m_height, m_width, pen, wideningFactor);
}
开发者ID:rrwick,项目名称:Bugraft,代码行数:40,代码来源:curvedtreegraphicsscene.cpp


示例3: removeItem

void Segmenter::init(DividerList* divlist, QString imagepath)
{

    // clear the divider list
    if (m_dividers != NULL) {
        DividerList::iterator iter;
        for (iter = m_dividers->begin(); iter != m_dividers->end(); iter++) {
            if ((*iter)->scene() == this) {
                removeItem(*iter);
            }
        }
    }

    // set the bg image to the new path
    m_imagebg->setPixmap(QPixmap(imagepath));

    // make sure the scene  bounds the image properly
    setSceneRect(m_imagebg->boundingRect());

    // refresh the height of the marker dividers
    m_markerdivider->refreshHeight();
    //this->views().first()->fitInView(m_imagebg->boundingRect(), Qt::KeepAspectRatio);

    // set out divider list to point to the given one
    m_dividers = divlist;

    // draw any existing dividers into the scene by setting their
    // parent item to the image bg
    DividerList::iterator iter;
    for (iter = m_dividers->begin(); iter != m_dividers->end(); iter++)
        (*iter)->setParentItem(m_imagebg);

    // ensure the move focus belongs to the draw marker dividers
    grabDivider(m_markerdivider);

    update();

    // FIXME: move this logic somewhere nicer
    emit dividersChanged();
}
开发者ID:vitorio,项目名称:ocropodium.tshelper,代码行数:40,代码来源:segmenter.cpp


示例4: size

void NetworkEditorView::fitNetwork() {
    const ProcessorNetwork* network = InviwoApplication::getPtr()->getProcessorNetwork();
    if (network) {
        if (network->getProcessors().size() > 0) {
            QRectF br = networkEditor_->itemsBoundingRect().adjusted(-50, -50, 50, 50);
            QSizeF viewsize = size();
            QSizeF brsize = br.size();

            if (brsize.width() < viewsize.width()) {
                br.setLeft(br.left() - 0.5*(viewsize.width() - brsize.width()));
                br.setRight(br.right() + 0.5*(viewsize.width() - brsize.width()));
            }
            if (brsize.height() < viewsize.height()) {
                br.setTop(br.top() - 0.5*(viewsize.height() - brsize.height()));
                br.setBottom(br.bottom() + 0.5*(viewsize.height() - brsize.height()));
            }

            setSceneRect(br);
            fitInView(br, Qt::KeepAspectRatio);
        }
    }
}
开发者ID:david12345678901,项目名称:inviwo,代码行数:22,代码来源:networkeditorview.cpp


示例5: 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);
            if (col == 0)
                playersByColumn[col][row]->setPos(phasesToolbar->getWidth(), playersByColumn[col][row]->y());
            else
                playersByColumn[col][row]->setPos(phasesToolbar->getWidth() + (newWidth - phasesToolbar->getWidth()) / 2, playersByColumn[col][row]->y());
        }
}
开发者ID:JennyDjinn,项目名称:Cockatrice,代码行数:39,代码来源:gamescene.cpp


示例6: sceneRect

void chatGraphicsScene::verticalReposition()
{
    m_verticalPosForNewMessage = 0;

    chatMsgGraphicsItem* item = 0;
    for(int i = 0; i < m_items.size(); ++i)
    {
        item = m_items.at(i);
        item->setViewWidth(views().at(0)->size().width());
        item->setPos(0, m_verticalPosForNewMessage);
        int height = item->boundingRect().height();
        m_verticalPosForNewMessage = m_verticalPosForNewMessage + height + m_verticalSpacing;
    }

    QRectF rect = sceneRect();
    if(item)
    {
        rect.setHeight(m_verticalPosForNewMessage);
        rect.setWidth(item->getMaxWidth() + item->getBoxStartLength() - 4);
        setSceneRect(rect);
    }
}
开发者ID:berndhs,项目名称:qxmpp,代码行数:22,代码来源:chatGraphicsScene.cpp


示例7: QGraphicsView

CSceneWidget::CSceneWidget(qint32 compkey, qint32 width, qint32 height, QWidget *parent) :
    QGraphicsView(parent),
    _compkey(compkey),
    _currentItem(NULL),
    m_currentImage(NULL),
    _resizeBegin(false),
    m_gridEnabled(false),
    m_cellWidth(10),
    _timerId(0),
    _aspectRatioMode(Qt::KeepAspectRatio)
{
    initSceneMenu();
    initItemsMenu();

    QGraphicsScene *scene = new QGraphicsScene(this);
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    scene->setSceneRect(0,0,width,height);
    setScene(scene);
    setSceneRect(0,0,width,height);
    setTransformationAnchor(AnchorUnderMouse);
    setCacheMode(CacheBackground);
    setViewportUpdateMode(BoundingRectViewportUpdate);
    setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing
                                      | QGraphicsView::DontClipPainter
                                      | QGraphicsView::DontSavePainterState);

    setMouseTracking(true);

    CGraphicsItem *background = new CGraphicsItem(_compkey);
    background->setPos(0,0);
    background->setSize(QSize(width,height));
    background->setImageFitMode(CGraphicsItem::ImageStretch/*ImageFit*/);
    scene->addItem(background);
    //scene->addWidget(new QLabel("use +/- for zoming")); // TODO: tempory removed

    SettingsManager setting("Video");
    setEnabledOpenGl(setting.getBoolValue("OpenGL"));
    _timerId = startTimer(1000 / 25);
}
开发者ID:slima4,项目名称:zgui-qt,代码行数:39,代码来源:scenewidget.cpp


示例8: resizeEvent

    virtual void resizeEvent(QResizeEvent *event) {
        QGraphicsView::resizeEvent(event);
        QGraphicsScene *scene = this->scene();
        if (scene) {
            QRectF newSceneRect(0, 0, event->size().width(), event->size().height());
            scene->setSceneRect(newSceneRect);
            if (scene->sceneRect().size() != event->size()) {
                QSizeF from(scene->sceneRect().size());
                QSizeF to(event->size());
                QTransform transform;
                transform.scale(to.width() / from.width(), to.height() / from.height());
                setTransform(transform);
            } else {
                resetTransform();
            }
            setSceneRect(scene->sceneRect());
        }

        MainWindow *main_window = qobject_cast<MainWindow *>(parentWidget());
        if (main_window)
            main_window->fitBackgroundBrush();
    }
开发者ID:kissthink,项目名称:QSanguosha-For-Hegemony,代码行数:22,代码来源:mainwindow.cpp


示例9: if

QVariant ReportRectEntity::itemChange(GraphicsItemChange change, const QVariant &value)
{
    if (change == ItemPositionChange && scene()) {
        QPointF newPos = value.toPointF();

        newPos = dynamic_cast<ReportScene*>(scene())->gridPoint(newPos);
        if (newPos.x() < 0)
            newPos.setX(0);
        else if (newPos.x() > (scene()->width() - rect().width()))
            newPos.setX(scene()->width() - rect().width());

        if (newPos.y() < 0)
            newPos.setY(0);
        else if (newPos.y() > (scene()->height() - rect().height()))
            newPos.setY(scene()->height() - rect().height());

        return newPos;
    } else if (change == ItemPositionHasChanged && scene()) {
        m_ppos->setScenePos(value.toPointF());
    } else if (change == ItemSceneHasChanged && scene() && m_psize) {
        QPointF newPos = pos();

        newPos = dynamic_cast<ReportScene*>(scene())->gridPoint(newPos);
        if (newPos.x() < 0)
            newPos.setX(0);
        else if (newPos.x() > (scene()->width() - rect().width()))
            newPos.setX(scene()->width() - rect().width());

        if (newPos.y() < 0)
            newPos.setY(0);
        else if (newPos.y() > (scene()->height() - rect().height()))
            newPos.setY(scene()->height() - rect().height());

        setSceneRect(newPos, m_psize->toScene());
    }

    return QGraphicsItem::itemChange(change, value);
}
开发者ID:JeremiasE,项目名称:KFormula,代码行数:38,代码来源:reportrectentity.cpp


示例10: QGraphicsScene

DrawingCanvas::DrawingCanvas(DrawingInfo *info, FileParser *in_parser, QObject *parent)
		: QGraphicsScene(parent),
		parser(in_parser),
		drawingInfo(info),
		myBackgroundColor(Qt::white),
		myMoveCursor(QPixmap(":/images/cursor_move.png")),
		myRotateCursor(QPixmap(":/images/cursor_rotate.png")),
		myBackgroundAlpha(DEFAULT_BACKGROUND_OPACITY/100.0*255)
{
	myMode 				= Select;
	bondline 			= 0;
	selectionRectangle 	= 0;
	myArrow             = 0;
	myTempMoveItem      = 0;
    // Hack to make the background border disappear (unless background color is changed)
	//myBackgroundColor.setAlpha(myBackgroundAlpha);
	myBackgroundColor.setAlpha(0);

	setBackgroundBrush(QBrush(myBackgroundColor));
	setSceneRect(QRectF(0, 0, DEFAULT_SCENE_SIZE_X,  DEFAULT_SCENE_SIZE_Y));

	// If the user provided a filename from the command line, there's a molecule in the parser.
	// The filename is empty, however if that molecule came from a project.
	if(parser->numMolecules() && !in_parser->fileName().isEmpty()) {
		loadFromParser();
	}

	//	xRot = yRot = zRot = 0;
	//	for(int r = 0; r < 3; r++)
	//	{
	//		for(int c = 0; c < 3; c++)
	//		{
	//			rotationMatrix[r][c] = ((r == c) ? 1 : 0);
	//			//printf("%6.4f ", rotationMatrix[r][c]);
	//		}
	//		//printf("\n");
	//	}
}
开发者ID:yu-shang,项目名称:cheMVP,代码行数:38,代码来源:drawingcanvas.cpp


示例11: Q_UNUSED

void KoReportDesignerItemText::slotPropertyChanged(KoProperty::Set &s, KoProperty::Property &p)
{
    Q_UNUSED(s);

    if (p.name() == "Position") {
        m_pos.setUnitPos(p.value().toPointF(), KRPos::DontUpdateProperty);
    } else if (p.name() == "Size") {
        m_size.setUnitSize(p.value().toSizeF(), KRPos::DontUpdateProperty);
    } else if (p.name() == "Name") {
        //For some reason p.oldValue returns an empty string
        if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) {
            p.setValue(m_oldName);
        } else {
            m_oldName = p.value().toString();
        }
    }

    setSceneRect(m_pos.toScene(), m_size.toScene(), DontUpdateProperty);
    if (m_reportDesigner)
        m_reportDesigner->setModified(true);
    if (scene())
        scene()->update();
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:23,代码来源:KoReportDesignerItemText.cpp


示例12: float

void GraphicsScene::drawBackground(QPainter *painter, const QRectF &)
{
    float width = float(painter->device()->width());
    float height = float(painter->device()->height());
    setSceneRect(0, 0, width, height);

    painter->beginNativePainting();
    setStates();

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_PROJECTION);
    gluPerspective(60.0, width / height, 0.01, 15.0);

    glMatrixMode(GL_MODELVIEW);
    glTranslatef(0,0,-4);
    glScalef(1.5,1,-2);
    emit render();

    defaultStates();

    painter->endNativePainting();
}
开发者ID:klutt,项目名称:Twotball,代码行数:23,代码来源:graphicsscene.cpp


示例13: QGraphicsView

Viewport::Viewport(QGraphicsScene* scene, QWidget* parent)
    : QGraphicsView(parent), scene(scene),
      scale(100), pitch(0), yaw(0), angle_locked(false),
      view_selector(new ViewSelector(this)),
      mouse_info(new QGraphicsTextItem("\n")),
      scene_info(new QGraphicsTextItem()), hover(false),
      gl_initialized(false), ui_hidden(false)
{
    setScene(scene);
    setStyleSheet("QGraphicsView { border-style: none; }");

    setSceneRect(-width()/2, -height()/2, width(), height());
    setRenderHints(QPainter::Antialiasing);

    auto gl = new QOpenGLWidget(this);
    setViewport(gl);

    for (auto i : {mouse_info, scene_info})
    {
        i->setDefaultTextColor(Colors::base04);
        scene->addItem(i);
    }
}
开发者ID:kidaa,项目名称:antimony,代码行数:23,代码来源:viewport.cpp


示例14: mapToScene

void CityLordView::mouseMoveEvent(QMouseEvent * e){
    int move;
    QPointF currentPos = mapToScene(e->pos());
    if(startMouse.x() < currentPos.x() and currentPos.x()>-1520){   // -rows*baselength
        move = currentPos.x()-startMouse.x();
        px-= move;
        lastPos.setX(lastPos.x()-move);
    }else if(startMouse.x() > currentPos.x() and currentPos.x()<1520){  // rows*baselength
        move = startMouse.x()-currentPos.x();
        px+= move;
        lastPos.setX(lastPos.x()+move);
    }
    if(startMouse.y() < currentPos.y() and currentPos.y()>0){   // 0
        move = currentPos.y()-startMouse.y();
        py-=move;
        lastPos.setY(lastPos.y()-move);
    }else if(startMouse.y() > currentPos.y() and currentPos.y()<1500){// columns*baseheight
        move = startMouse.y()-currentPos.y();
        py+=move;
        lastPos.setY(lastPos.y()+move);
    }
    lastPos = currentPos;
    setSceneRect(-((WIDTH/2)-(BASE.width()/2))+px, py, WIDTH-2, HEIGHT-2);
}
开发者ID:HqWisen,项目名称:CityLord,代码行数:24,代码来源:citylordview.cpp


示例15: legendRenderer

void QgsComposerLegend::adjustBoxSize()
{
  if ( !mSizeToContents )
    return;

  if ( !mInitialMapScaleCalculated )
  {
    // this is messy - but until we have painted the item we have no knowledge of the current DPI
    // and so cannot correctly calculate the map scale. This results in incorrect size calculations
    // for marker symbols with size in map units, causing the legends to initially expand to huge
    // sizes if we attempt to calculate the box size first.
    return;
  }

  QgsLegendRenderer legendRenderer( mLegendModel.get(), mSettings );
  QSizeF size = legendRenderer.minimumSize();
  QgsDebugMsg( QString( "width = %1 height = %2" ).arg( size.width() ).arg( size.height() ) );
  if ( size.isValid() )
  {
    QRectF targetRect = QRectF( pos().x(), pos().y(), size.width(), size.height() );
    //set new rect, respecting position mode and data defined size/position
    setSceneRect( evalItemRect( targetRect, true ) );
  }
}
开发者ID:GeoCat,项目名称:QGIS,代码行数:24,代码来源:qgscomposerlegend.cpp


示例16: qMax

void
AnimatorScene::setSimulationBoundaries (QPointF minPoint, QPointF maxPoint)
{
  m_minPoint = minPoint;
  m_maxPoint = maxPoint;
  qreal boundaryWidth = m_maxPoint.x () * 0.1;
  qreal boundaryHeight = m_maxPoint.y () * 0.2;
  qreal boundary = qMax (boundaryWidth, boundaryHeight);

  m_sceneMinPoint = QPointF (m_minPoint.x () - boundary, m_minPoint.y () - boundary);
  m_sceneMaxPoint = QPointF (m_maxPoint.x () + boundary, m_maxPoint.y () + boundary);

  // Make it square
  qreal minimum = qMin (m_sceneMinPoint.x (), m_sceneMinPoint.y ());
  m_sceneMinPoint = QPointF (minimum, minimum);
  qreal maximum = qMax (m_sceneMaxPoint.x (), m_sceneMaxPoint.y ());
  m_sceneMaxPoint = QPointF (maximum, maximum);
  if ((m_sceneMaxPoint.x () == 0) && (m_sceneMaxPoint.y () == 0))
    {
      m_sceneMaxPoint = QPointF (1, 1);
    }

  setSceneRect (QRectF (m_sceneMinPoint, m_sceneMaxPoint));
}
开发者ID:apanda,项目名称:pilo-ns3,代码行数:24,代码来源:animatorscene.cpp


示例17: setRenderHints

//______________________________________________________________________________
YSPTView::YSPTView(QMenuBar *mb)
{
    //creates the view with a shared menubar

    // Sets up the subclassed QGraphicsView

    setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);


    //Set-up the scene

    fPt = new YSPeriodicTable(this);
    setScene(fPt);

    //Set-up the view
    setSceneRect(fPt->sceneRect());

    //Use ScrollHand Drag Mode to enable Panning
    setDragMode(ScrollHandDrag);

    fMenuBar = mb;
    CreateActions();
    CreateMenus();
}
开发者ID:yschutz,项目名称:QPeriodicTableWidget,代码行数:25,代码来源:YSPTView.cpp


示例18: QGraphicsScene

// TODO: redesign in Qt way ;)
// i.e. crop as opacity mask not a copy
AvatarEditScene::AvatarEditScene(QObject *parent)
    : QGraphicsScene(parent)
{
    setSceneRect(0, 0, 480, 360);

    isSizing = false;
    isDragged = false;

    crop = QRect(0, 0, 100, 100);

    // background
    setBackgroundBrush(QPixmap(":/images/transparent.png"));
    // scaled photo
    photoItem = addPixmap(QPixmap());
    // gray it down
    photoBlurItem = addRect(QRect(), Qt::NoPen, QBrush(QColor(255, 255, 255, 127)));
    // crop
    cropItem = addPixmap(QPixmap());
    // cropper
    QPixmap pixmap = getCropper();
    cropper = pixmap.rect();
    cropperItem = addPixmap(pixmap);
    cropperItem->setOpacity(0.5);
}
开发者ID:gitter-badger,项目名称:simplechatclient,代码行数:26,代码来源:avatar_edit_scene.cpp


示例19: setSceneRect

void WorkbenchGraphicsScene::initialize()
{
	setSceneRect(0,0,640, 480);
}
开发者ID:pholz,项目名称:UberCode,代码行数:4,代码来源:WorkbenchGraphicsScene.cpp


示例20: newSceneRect

void QgsComposerItem::move( double dx, double dy )
{
  QRectF newSceneRect( pos().x() + dx, pos().y() + dy, rect().width(), rect().height() );
  setSceneRect( evalItemRect( newSceneRect ) );
}
开发者ID:exlimit,项目名称:QGIS,代码行数:5,代码来源:qgscomposeritem.cpp



注:本文中的setSceneRect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setScore函数代码示例发布时间:2022-05-30
下一篇:
C++ setScene函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap