本文整理汇总了C++中QRectF::normalized方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::normalized方法的具体用法?C++ QRectF::normalized怎么用?C++ QRectF::normalized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::normalized方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zoom
void QwtPlotZoomer::zoom( const QRectF &rect )
{
if ( d_data->maxStackDepth >= 0 &&
int( d_data->zoomRectIndex ) >= d_data->maxStackDepth )
{
return;
}
const QRectF zoomRect = rect.normalized();
if ( zoomRect != d_data->zoomStack[d_data->zoomRectIndex] )
{
for ( uint i = d_data->zoomStack.count() - 1;
i > d_data->zoomRectIndex; i-- )
{
( void )d_data->zoomStack.pop();
}
d_data->zoomStack.push( zoomRect );
d_data->zoomRectIndex++;
rescale();
Q_EMIT zoomed( zoomRect );
}
}
示例2: boundingRect
/*!
\return Bounding rectangle of the data
\sa QwtPlotRasterItem::interval()
*/
QRectF QwtPlotRasterItem::boundingRect() const
{
const QwtInterval intervalX = interval( Qt::XAxis );
const QwtInterval intervalY = interval( Qt::YAxis );
if ( !intervalX.isValid() && !intervalY.isValid() )
return QRectF(); // no bounding rect
QRectF r;
if ( intervalX.isValid() )
{
r.setLeft( intervalX.minValue() );
r.setRight( intervalX.maxValue() );
}
else
{
r.setLeft(-0.5 * FLT_MAX);
r.setWidth(FLT_MAX);
}
if ( intervalY.isValid() )
{
r.setTop( intervalY.minValue() );
r.setBottom( intervalY.maxValue() );
}
else
{
r.setTop(-0.5 * FLT_MAX);
r.setHeight(FLT_MAX);
}
return r.normalized();
}
示例3: mouseMoveEvent
void ImageScene::mouseMoveEvent(QGraphicsSceneMouseEvent* in_mEvent) {
if (m_pPixmap == NULL) {
return;
}
qreal x = in_mEvent->scenePos().x(), y = in_mEvent->scenePos().y();
if ( x < m_pPixmap->offset().x() ) {
x = m_pPixmap->offset().x();
} else if ( x - m_pPixmap->offset().x() >= m_pPixmap->pixmap().rect().width() ) {
x = m_pPixmap->pixmap().rect().width() + m_pPixmap->offset().x() - 1;
}
if ( y < m_pPixmap->offset().y() ) {
y = m_pPixmap->offset().y();
} else if ( y - m_pPixmap->offset().y() >= m_pPixmap->pixmap().rect().height() ) {
y = m_pPixmap->pixmap().rect().height() + m_pPixmap->offset().y() - 1;
}
if (m_pSelection != NULL) {
QRectF rect;
rect.setCoords ( m_SelectionPosition.x(),
m_SelectionPosition.y(),
x,y );
m_pSelection->setRect ( rect.normalized());
} else {
m_pSelection = QGraphicsScene::addRect (x,y,0,0, m_SelectionPen, m_SelectionBrush);
m_pSelection->setParentItem (m_pPixmap);
m_SelectionPosition = m_pSelection->rect().topLeft();
}
if ( m_pSelection->rect().width() < 1 ||
m_pSelection->rect().height() < 1 )
{
m_pSelection->setVisible(false);
} else {
m_pSelection->setVisible(true);
}
}
示例4: TGeometry
TShape::TShape(const enum TShapeType ShapeType_, const QRectF &Rect_, const QString& Name_,
const unsigned FillColor_, const unsigned BorderColor_, const unsigned BorderWidth_)
: TGeometry(Name_), m_ShapeType(ShapeType_), m_FillColor(FillColor_),
m_BorderColor(BorderColor_), m_BorderWidth(BorderWidth_)
{
setGeometryType("Shape");
m_BoundingBoxF = Rect_.normalized();
m_TextPosition = Middle;
}
示例5: boundingRect
//! \brief Return bounding rectangle arround a wireline
QRectF WireLine::boundingRect() const
{
QRectF rect;
rect.setTopLeft(p1());
rect.setBottomRight(p2());
rect = rect.normalized();
rect.adjust(-m_adjust, -m_adjust, +m_adjust, +m_adjust);
return rect;
}
示例6: invTransform
/*!
Transform a rectangle from paint to scale coordinates
\param xMap X map
\param yMap Y map
\param rect Rectangle in paint coordinates
\return Rectangle in scale coordinates
\sa transform()
*/
QRectF QwtScaleMap::invTransform( const QwtScaleMap &xMap,
const QwtScaleMap &yMap, const QRectF &rect )
{
const double x1 = xMap.invTransform( rect.left() );
const double x2 = xMap.invTransform( rect.right() - 1 );
const double y1 = yMap.invTransform( rect.top() );
const double y2 = yMap.invTransform( rect.bottom() - 1 );
const QRectF r( x1, y1, x2 - x1, y2 - y1 );
return r.normalized();
}
示例7: move
void MapHelperUniversal::move(const QRectF &rgn)
{
Q_D(MapHelperUniversal);
if (d->states.testFlag(stMove))
return;
MapSubHelperMove *sub = new MapSubHelperMove(d->map);
d->addSubhelper(sub);
if (!rgn.isEmpty())
sub->initData(rgn.normalized());
}
示例8: getHandleRect
/***********************************************************************
*Funtion : Get the handle rect
*Return : QRectF handle rect.
*Parameter: handle id.
**********************************************************************/
QRectF SamDrawItemBase::getHandleRect(int iHandleID, QRectF &qrcBondingRect)
{
QRectF qrRect;
// get the center of the handle in logical coords
QPointF qpPoint = getHandle(iHandleID, qrcBondingRect);
/*Set the rect and normalize it*/
qrRect.setRect(qpPoint.rx()-SAMDRAW_TRACKER_POS_OFT, qpPoint.ry()-SAMDRAW_TRACKER_POS_OFT, SAMDRAW_TRACKER_SIZE, SAMDRAW_TRACKER_SIZE);
qrRect = qrRect.normalized();
return qrRect;
}
示例9: firstDataInterval
/**
* @brief GridItem::firstDataInterval Determins the first grid interval in data space.
*/
QRectF GridItem::firstDataInterval(QRectF dataRect) const
{
QSizeF interval(m_minDistance, m_minDistance);
interval = m_transform->sceneToData(interval);
interval = niceInterval(interval);
if (m_useManualInterval) {
interval.setWidth(std::max(m_manualInterval.width(), interval.width()));
interval.setHeight(std::max(m_manualInterval.height(), interval.height()));
}
QPointF start = intervalStart(dataRect.normalized().topLeft(), interval, QPointF());
return QRectF(start, interval);
}
示例10: attemptResize
void QgsLayoutItemGroup::attemptResize( const QgsLayoutSize &size, bool includesFrame )
{
if ( !mLayout )
return;
if ( !shouldBlockUndoCommands() )
mLayout->undoStack()->beginMacro( tr( "Resize Group" ) );
QRectF oldRect = rect();
QSizeF newSizeLayoutUnits = mLayout->convertToLayoutUnits( size );
QRectF newRect;
newRect.setSize( newSizeLayoutUnits );
//also resize all items within the group
for ( QgsLayoutItem *item : qgis::as_const( mItems ) )
{
if ( !item )
continue;
std::unique_ptr< QgsAbstractLayoutUndoCommand > command;
if ( !shouldBlockUndoCommands() )
{
command.reset( createCommand( QString(), 0 ) );
command->saveBeforeState();
}
QRectF itemRect = mapRectFromItem( item, item->rect() );
QgsLayoutUtils::relativeResizeRect( itemRect, oldRect, newRect );
itemRect = itemRect.normalized();
QPointF newPos = mapToScene( itemRect.topLeft() );
QgsLayoutSize itemSize = mLayout->convertFromLayoutUnits( itemRect.size(), item->sizeWithUnits().units() );
item->attemptResize( itemSize, includesFrame );
// translate new position to current item units
QgsLayoutPoint itemPos = mLayout->convertFromLayoutUnits( newPos, item->positionWithUnits().units() );
item->attemptMove( itemPos, false );
if ( command )
{
command->saveAfterState();
mLayout->undoStack()->push( command.release() );
}
}
QgsLayoutItem::attemptResize( size );
if ( !shouldBlockUndoCommands() )
mLayout->undoStack()->endMacro();
resetBoundingRect();
}
示例11: firstSceneInterval
/**
* @brief GridItem::firstSceneInterval Determins the first grid interval in scene space
*/
QRectF GridItem::firstSceneInterval(QRectF sceneRect) const
{
QSizeF interval(m_minDistance, m_minDistance);
interval = m_transform->sceneToData(interval);
interval = niceInterval(interval);
if (m_useManualInterval) {
interval.setWidth(std::max(m_manualInterval.width(), interval.width()));
interval.setHeight(std::max(m_manualInterval.height(), interval.height()));
}
interval = m_transform->dataToScene(interval);
interval = QSizeF(std::fabs(interval.width()), std::fabs(interval.height()));
QPointF start = intervalStart(sceneRect.normalized().topLeft(), interval, m_transform->origin());
return QRectF(start, interval);
}
示例12:
/*! Find a minimal rectangle that encapsulates the polygon. The
rectangle is returned in the QRectF object.
*/
QRectF Polygon2D::GetSurroundingRectangle() const
{
QRectF rc;
if(m_vecV.size()) {
Point2D pt1, pt2;
GetSurroundingRectangle(pt1, pt2);
rc.setCoords(
pt1.GetX(), pt2.GetY(), // left, top
pt2.GetX(), pt1.GetY() // right, bottom.
);
}
return rc.normalized();
}
示例13: scaleRect
/*!
\return Normalized bounding rectangle of the axes
\sa QwtPlot::autoReplot(), QwtPlot::replot().
*/
QRectF QwtPlotPicker::scaleRect() const
{
QRectF rect;
if ( plot() )
{
const QwtScaleDiv &xs = plot()->axisScaleDiv( xAxis() );
const QwtScaleDiv &ys = plot()->axisScaleDiv( yAxis() );
rect = QRectF( xs.lowerBound(), ys.lowerBound(),
xs.range(), ys.range() );
rect = rect.normalized();
}
return rect;
}
示例14: viewToCellCoordinates
QRect CanvasBase::viewToCellCoordinates(const QRectF& viewRect) const
{
register Sheet * const sheet = activeSheet();
if (!sheet)
return QRect();
// NOTE Stefan: Do not consider the layout direction in this case.
const QRectF rect = viewConverter()->viewToDocument(viewRect.normalized()).translated(offset());
qreal tmp;
const int left = sheet->leftColumn(rect.left(), tmp);
const int right = sheet->rightColumn(rect.right());
const int top = sheet->topRow(rect.top(), tmp);
const int bottom = sheet->bottomRow(rect.bottom());
return QRect(left, top, right - left + 1, bottom - top + 1);
}
示例15: painterSaver
/**
* Draws a 3D cuboid by extending a 2D rectangle in the z-axis
*
* @param rect The rectangle to draw
* @param brush The brush fill the surfaces of the cuboid with
* @param pen The pen to draw the edges with
* @param props The 3D properties to use for drawing the cuboid
* @return The drawn cuboid as a polygon
*/
QPolygonF StockDiagram::Private::ThreeDPainter::drawThreeDRect( const QRectF &rect, const QBrush &brush,
const QPen &pen, const ThreeDProperties &props )
{
// Restores the painting properties when destroyed
PainterSaver painterSaver( painter );
// Make sure that the top really is the top
const QRectF normalizedRect = rect.normalized();
// Calculate all the four sides of the rectangle
const QLineF topSide = QLineF( normalizedRect.topLeft(), normalizedRect.topRight() );
const QLineF bottomSide = QLineF( normalizedRect.bottomLeft(), normalizedRect.bottomRight() );
const QLineF leftSide = QLineF( normalizedRect.topLeft(), normalizedRect.bottomLeft() );
const QLineF rightSide = QLineF( normalizedRect.topRight(), normalizedRect.bottomRight() );
QPolygonF drawnPolygon;
// Shorter names are easier on the eyes
const qreal angle = props.angle;
// Only top and right side is visible
if ( angle >= 0.0 && angle < 90.0 ) {
drawnPolygon = drawnPolygon.united( drawThreeDLine( topSide, brush, pen, props ) );
drawnPolygon = drawnPolygon.united( drawThreeDLine( rightSide, brush, pen, props ) );
// Only top and left side is visible
} else if ( angle >= 90.0 && angle < 180.0 ) {
drawnPolygon = drawnPolygon.united( drawThreeDLine( topSide, brush, pen, props ) );
drawnPolygon = drawnPolygon.united( drawThreeDLine( leftSide, brush, pen, props ) );
// Only bottom and left side is visible
} else if ( angle >= 180.0 && angle < 270.0 ) {
drawnPolygon = drawnPolygon.united( drawThreeDLine( bottomSide, brush, pen, props ) );
drawnPolygon = drawnPolygon.united( drawThreeDLine( leftSide, brush, pen, props ) );
// Only bottom and right side is visible
} else if ( angle >= 270.0 && angle <= 360.0 ) {
drawnPolygon = drawnPolygon.united( drawThreeDLine( bottomSide, brush, pen, props ) );
drawnPolygon = drawnPolygon.united( drawThreeDLine( rightSide, brush, pen, props ) );
}
// Draw the front side
painter->setPen( pen );
painter->setBrush( brush );
painter->drawRect( normalizedRect );
return drawnPolygon;
}