当前位置: 首页>>代码示例>>C++>>正文


C++ QSizeF::scale方法代码示例

本文整理汇总了C++中QSizeF::scale方法的典型用法代码示例。如果您正苦于以下问题:C++ QSizeF::scale方法的具体用法?C++ QSizeF::scale怎么用?C++ QSizeF::scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSizeF的用法示例。


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

示例1: diagramSize

QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s )
{
  Q_UNUSED( c );
  QSizeF size;

  if ( attributes.isEmpty() )
  {
    return QSizeF(); //zero size if no attributes
  }

  double maxValue = attributes.at( 0 ).toDouble();

  for ( int i = 0; i < attributes.count(); ++i )
  {
    maxValue = qMax( attributes.at( i ).toDouble(), maxValue );
  }

  switch ( s.diagramOrientation )
  {
    case QgsDiagramSettings::Up:
    case QgsDiagramSettings::Down:
      mScaleFactor = maxValue / s.size.height();
      size.scale( s.barWidth * s.categoryColors.size(), s.size.height(), Qt::IgnoreAspectRatio );
      break;

    case QgsDiagramSettings::Right:
    case QgsDiagramSettings::Left:
    default: // just in case...
      mScaleFactor = maxValue / s.size.width();
      size.scale( s.size.width(), s.barWidth * s.categoryColors.size(), Qt::IgnoreAspectRatio );
      break;
  }

  return size;
}
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:35,代码来源:qgshistogramdiagram.cpp

示例2: adjustSize

void ContentWindowController::adjustSize( const SizeState state )
{
    switch( state )
    {
    case SIZE_1TO1:
        resize( _contentWindow->getContent()->getPreferredDimensions(), CENTER);
        break;

    case SIZE_LARGE:
    {
        const QSizeF wallSize = _displayGroup->getCoordinates().size();
        resize( LARGE_SIZE_SCALE * wallSize, CENTER );
    } break;

    case SIZE_FULLSCREEN:
    {
        QSizeF size = _contentWindow->getContent()->getDimensions();
        size.scale( _displayGroup->getCoordinates().size(),
                    Qt::KeepAspectRatio );
        constrainSize( size );
        _contentWindow->setCoordinates( _getCenteredCoordinates( size ));
    } break;

    default:
        return;
    }
}
开发者ID:BlueBrain,项目名称:DisplayCluster,代码行数:27,代码来源:ContentWindowController.cpp

示例3: reviewCrosshairLinePositions

void AMCrosshairOverlayVideoWidget::reviewCrosshairLinePositions()
{

	QSizeF viewSize = videoItem_->size();
	// first we need to find out the native size of the video. (Well, actually just the aspect ratio, but...)
	QSizeF videoSize = videoItem_->nativeSize();

	// scale the video size to the view size, obeying the transformation mode
	QSizeF scaledSize = videoSize;
	scaledSize.scale(viewSize, videoItem_->aspectRatioMode());

	// now, scaledSize will either be:
		// same as viewSize, if view and video have same aspect ratio, or the video is being stretched with Qt::IgnoreAspectRatio
		// One dimension the same, other dimension smaller than viewSize, if Qt::KeepAspectRatio
		// or One dimension the same, other dimension LARGER than viewSize, if Qt::KeepAspectRatioByExpanding

	QRectF activeRect = QRectF(QPointF((viewSize.width()-scaledSize.width())/2,
									   (viewSize.height()-scaledSize.height())/2),
							   scaledSize);

	// activeRect is now a rectangle in scene coordinates that covers the actual area of the video [not the area of the videoWidget, which may be smaller or larger depending on the aspect ratio mode and aspect ratio of the actual video feed]

	qreal xSceneCoord = activeRect.left() + crosshairX_*activeRect.width();
	qreal ySceneCoord = activeRect.top() + crosshairY_*activeRect.height();

	crosshairXLine_->setLine(xSceneCoord, activeRect.top(), xSceneCoord, activeRect.bottom());
	crosshairYLine_->setLine(activeRect.left(), ySceneCoord, activeRect.right(), ySceneCoord);
}
开发者ID:acquaman,项目名称:acquaman,代码行数:28,代码来源:AMCrosshairOverlayVideoWidget.cpp

示例4: updateRects

void QRendererVideoWidgetBackend::updateRects()
{
    QRect rect = m_widget->rect();

    if (m_nativeSize.isEmpty()) {
        m_boundingRect = QRect();
    } else if (m_aspectRatioMode == Qt::IgnoreAspectRatio) {
        m_boundingRect = rect;
        m_sourceRect = QRectF(0, 0, 1, 1);
    } else if (m_aspectRatioMode == Qt::KeepAspectRatio) {
        QSize size = m_nativeSize;
        size.scale(rect.size(), Qt::KeepAspectRatio);

        m_boundingRect = QRect(0, 0, size.width(), size.height());
        m_boundingRect.moveCenter(rect.center());

        m_sourceRect = QRectF(0, 0, 1, 1);
    } else if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) {
        m_boundingRect = rect;

        QSizeF size = rect.size();
        size.scale(m_nativeSize, Qt::KeepAspectRatio);

        m_sourceRect = QRectF(
                0, 0, size.width() / m_nativeSize.width(), size.height() / m_nativeSize.height());
        m_sourceRect.moveCenter(QPointF(0.5, 0.5));
    }
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:28,代码来源:qvideowidget.cpp

示例5: availableRect

QRectF QtSvgDialGauge::availableRect(QSvgRenderer * renderObject) const
{
    // Calculating the layout:
    QSizeF svgSize = renderObject->defaultSize();
    svgSize.scale(size(), Qt::KeepAspectRatio);
    return QRectF(QPointF(0.0, 0.0), svgSize);
}
开发者ID:Linux-enCaja,项目名称:SIE,代码行数:7,代码来源:qtsvgdialgauge.cpp

示例6: updateBoundingRect

void VlcQmlVideoObject::updateBoundingRect()
{
    _boundingRect = QRectF(0, 0, _frameSize.width(), _frameSize.height());

    updateAspectRatio();

    QSizeF scaledFrameSize = _boundingRect.size();
    if (_aspectRatio == Vlc::Ignore) {
        scaledFrameSize.scale(_geometry.size(), Qt::IgnoreAspectRatio);
    } else {
        scaledFrameSize.scale(_geometry.size(), Qt::KeepAspectRatio);
    }
    _boundingRect.setSize( scaledFrameSize );

    updateCropRatio();

    _boundingRect.moveCenter(_geometry.center());
}
开发者ID:Pau1S,项目名称:vlc-qt,代码行数:18,代码来源:QmlVideoObject.cpp

示例7: scale

void ContentWindowController::scale( const QPointF& center,
                                     const double pixelDelta )
{
    QSizeF newSize = _contentWindow->getCoordinates().size();
    newSize.scale( newSize.width() + pixelDelta,
                   newSize.height() + pixelDelta,
                   pixelDelta < 0 ? Qt::KeepAspectRatio
                                  : Qt::KeepAspectRatioByExpanding );
    _resize( center, newSize );
}
开发者ID:BlueBrain,项目名称:DisplayCluster,代码行数:10,代码来源:ContentWindowController.cpp

示例8: adjustWindowsAspectRatioToContent

void DisplayGroupController::adjustWindowsAspectRatioToContent()
{
    for (ContentWindowPtr window : _group.getContentWindows())
    {
        QSizeF exactSize = window->getContent().getDimensions();
        exactSize.scale(window->getCoordinates().size(), Qt::KeepAspectRatio);
        window->setWidth(exactSize.width());
        window->setHeight(exactSize.height());
    }
}
开发者ID:ppodhajski,项目名称:Tide,代码行数:10,代码来源:DisplayGroupController.cpp

示例9: sipNoMethod

static PyObject *meth_QSizeF_scale(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QSizeF * a0;
        Qt::AspectRatioMode a1;
        QSizeF *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ9E", &sipSelf, sipType_QSizeF, &sipCpp, sipType_QSizeF, &a0, sipType_Qt_AspectRatioMode, &a1))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->scale(*a0,a1);
            Py_END_ALLOW_THREADS

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    {
        qreal a0;
        qreal a1;
        Qt::AspectRatioMode a2;
        QSizeF *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BddE", &sipSelf, sipType_QSizeF, &sipCpp, &a0, &a1, sipType_Qt_AspectRatioMode, &a2))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->scale(a0,a1,a2);
            Py_END_ALLOW_THREADS

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QSizeF, sipName_scale, NULL);

    return NULL;
}
开发者ID:ClydeMojura,项目名称:android-python27,代码行数:42,代码来源:sipQtCoreQSizeF.cpp

示例10: diagramSize

QSizeF QgsTextDiagram::diagramSize( const QgsFeature& feature, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is )
{
  Q_UNUSED( c );

  QVariant attrVal;
  if ( is.classificationAttributeIsExpression )
  {
    QgsExpression* expression = getExpression( is.classificationAttributeExpression, feature.fields() );
    attrVal = expression->evaluate( feature );
  }
  else
  {
    attrVal = feature.attributes()[is.classificationAttribute];
  }

  if ( !attrVal.isValid() )
  {
    return QSizeF(); //zero size if attribute is missing
  }

  double scaledValue = attrVal.toDouble();
  double scaledLowerValue = is.lowerValue;
  double scaledUpperValue = is.upperValue;
  double scaledLowerSizeWidth = is.lowerSize.width();
  double scaledLowerSizeHeight = is.lowerSize.height();
  double scaledUpperSizeWidth = is.upperSize.width();
  double scaledUpperSizeHeight = is.upperSize.height();

  // interpolate the squared value if scale by area
  if ( s.scaleByArea )
  {
    scaledValue = sqrt( scaledValue );
    scaledLowerValue = sqrt( scaledLowerValue );
    scaledUpperValue = sqrt( scaledUpperValue );
    scaledLowerSizeWidth = sqrt( scaledLowerSizeWidth );
    scaledLowerSizeHeight = sqrt( scaledLowerSizeHeight );
    scaledUpperSizeWidth = sqrt( scaledUpperSizeWidth );
    scaledUpperSizeHeight = sqrt( scaledUpperSizeHeight );
  }

  //interpolate size
  double scaledRatio = ( scaledValue - scaledLowerValue ) / ( scaledUpperValue - scaledLowerValue );

  QSizeF size = QSizeF( is.upperSize.width() * scaledRatio + is.lowerSize.width() * ( 1 - scaledRatio ),
                        is.upperSize.height() * scaledRatio + is.lowerSize.height() * ( 1 - scaledRatio ) );

  // Scale, if extension is smaller than the specified minimum
  if ( size.width() <= s.minimumSize && size.height() <= s.minimumSize )
  {
    size.scale( s.minimumSize, s.minimumSize, Qt::KeepAspectRatio );
  }

  return size;
}
开发者ID:ACorradini,项目名称:QGIS,代码行数:54,代码来源:qgstextdiagram.cpp

示例11: updateMap

// calculates outer(image) and inner(view area) squares
void MapOverlay::updateMap(const QSizeF& windowSz, const QRectF& drawingRect)
{
    if(windowSz.height() < drawingRect.height()
            || windowSz.width() < drawingRect.width()) {
        this->show();
    
        d->outerRect.setX(0);
        d->outerRect.setY(0);
    
        QSizeF outerSz = drawingRect.size();
    
        outerSz.scale(d->mapSz, d->mapSz, Qt::KeepAspectRatio);
        d->outerRect.setSize(outerSz);

        float widthDiff = (float) windowSz.width() / drawingRect.width();
        float heightDiff = (float) windowSz.height() / drawingRect.height();

        if (widthDiff > 1)
            widthDiff = 1;

        if (heightDiff > 1)
            heightDiff = 1;

        float width = outerSz.width() * widthDiff;
        float height = outerSz.height() * heightDiff;

        QSizeF innerSz(width, height);
        d->innerRect.setSize(innerSz);
        
        float xSpeedDiff = (float) innerSz.width() / windowSz.width();
        float ySpeedDiff = (float) innerSz.height() / windowSz.height();

        float x = (float) -drawingRect.left() * xSpeedDiff;
        float y = (float) -drawingRect.top() * ySpeedDiff;

        if (x < 0)
            x = 0;

        if (y < 0)
            y = 0;

        d->innerRect.moveTo(QPointF(x, y));
        
        //move to bottom left border
        d->outerRect.translate(d->mapSz - d->outerRect.width(),
                            d->mapSz - d->outerRect.height());
        d->innerRect.translate(d->mapSz - d->outerRect.width(),
                            d->mapSz - d->outerRect.height());
        update();
    }
    else {
        this->hide();
    }
}
开发者ID:xsmart,项目名称:qimgv,代码行数:55,代码来源:mapoverlay.cpp

示例12: constrainSize

void ContentWindowController::constrainSize( QSizeF& windowSize ) const
{
    const QSizeF& maxSize = getMaxSize();
    if( windowSize > maxSize )
    {
        windowSize.scale( maxSize, Qt::KeepAspectRatio );
        return;
    }

    const QSizeF& minSize = getMinSize();
    if( windowSize < minSize )
        windowSize = _contentWindow->getCoordinates().size();
}
开发者ID:BlueBrain,项目名称:DisplayCluster,代码行数:13,代码来源:ContentWindowController.cpp

示例13: diagramSize

QSizeF QgsPieDiagram::diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is )
{
  Q_UNUSED( c );
  QVariant attrVal = attributes[is.classificationAttribute];
  if ( !attrVal.isValid() )
  {
    return QSizeF(); //zero size if attribute is missing
  }

  double scaledValue = attrVal.toDouble();
  double scaledLowerValue = is.lowerValue;
  double scaledUpperValue = is.upperValue;
  double scaledLowerSizeWidth = is.lowerSize.width();
  double scaledLowerSizeHeight = is.lowerSize.height();
  double scaledUpperSizeWidth = is.upperSize.width();
  double scaledUpperSizeHeight = is.upperSize.height();

  // interpolate the squared value if scale by area
  if ( s.scaleByArea )
  {
    scaledValue = sqrt( scaledValue );
    scaledLowerValue = sqrt( scaledLowerValue );
    scaledUpperValue = sqrt( scaledUpperValue );
    scaledLowerSizeWidth = sqrt( scaledLowerSizeWidth );
    scaledLowerSizeHeight = sqrt( scaledLowerSizeHeight );
    scaledUpperSizeWidth = sqrt( scaledUpperSizeWidth );
    scaledUpperSizeHeight = sqrt( scaledUpperSizeHeight );
  }

  //interpolate size
  double scaledRatio = ( scaledValue - scaledLowerValue ) / ( scaledUpperValue - scaledLowerValue );

  QSizeF size = QSizeF( is.upperSize.width() * scaledRatio + is.lowerSize.width() * ( 1 - scaledRatio ),
                        is.upperSize.height() * scaledRatio + is.lowerSize.height() * ( 1 - scaledRatio ) );

  // Scale, if extension is smaller than the specified minimum
  if ( size.width() <= s.minimumSize && size.height() <= s.minimumSize )
  {
    bool p = false; // preserve height == width
    if ( size.width() == size.height() )
      p = true;

    size.scale( s.minimumSize, s.minimumSize, Qt::KeepAspectRatio );

    // If height == width, recover here (overwrite floating point errors)
    if ( p )
      size.setWidth( size.height() );
  }

  return size;
}
开发者ID:ChowZenki,项目名称:QGIS,代码行数:51,代码来源:qgspiediagram.cpp

示例14: updateRects

void QGraphicsVideoItemPrivate::updateRects()
{
    q_ptr->prepareGeometryChange();
    QSizeF videoSize;
    if (nativeSize.isEmpty()) {
        videoSize = rect.size();
    } else if (aspectRatioMode == Qt::IgnoreAspectRatio) {
        videoSize = rect.size();
    } else {
        // KeepAspectRatio or KeepAspectRatioByExpanding
        videoSize = nativeSize;
        videoSize.scale(rect.size(), aspectRatioMode);
    }
    displayRect = QRectF(QPointF(0, 0), videoSize);
    displayRect.moveCenter(rect.center());
    boundingRect = displayRect.intersected(rect);
}
开发者ID:KDE,项目名称:android-qt-mobility,代码行数:17,代码来源:qgraphicsvideoitem_overlay.cpp

示例15: resizeCanvas

void CAPresentationHandler::resizeCanvas (const QSizeF& canvasSize)
{
    QSizeF pageSize = d->paView->activePage()->boundingRect().size();
    QGraphicsWidget* canvasItem = canvas()->canvasItem();
    QSizeF newSize (pageSize);
    newSize.scale (canvasSize, Qt::KeepAspectRatio);

    if (canvasSize.width() < canvasSize.height()) {
        canvasItem->setGeometry (0, (canvasSize.height() - newSize.height()) / 2,
                                 newSize.width(), newSize.height());
        documentController()->canvasController()->zoomHandler()->setZoom (canvasSize.width() / pageSize.width() * 0.75);
    } else {
        canvasItem->setGeometry ( (canvasSize.width() - newSize.width()) / 2, 0,
                                  newSize.width(), newSize.height());
        documentController()->canvasController()->zoomHandler()->setZoom (canvasSize.height() / pageSize.height() * 0.75);
    }
}
开发者ID:nemomobile-packages,项目名称:calligra,代码行数:17,代码来源:CAPresentationHandler.cpp


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