本文整理汇总了C++中QPointF::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ QPointF::isNull方法的具体用法?C++ QPointF::isNull怎么用?C++ QPointF::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPointF
的用法示例。
在下文中一共展示了QPointF::isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert
/*!
\class HsAnchorPointInBottomRight
\brief Diagonal widget positioning algorithm.
Sets widget's lower right corner to follow content area's diagonal.
Widgets are positioned to certain offset to each other.
*/
HsWidgetPositioningOnWidgetAdd::Result HsAnchorPointInBottomRight::convert(
const QRectF &contentArea,
const QList<QRectF> &existingRects,
const QList<QRectF> &newRects,
const QPointF &startPoint)
{
Q_UNUSED(existingRects);
HsWidgetPositioningOnWidgetAdd::Result result;
QList<QRectF> toGeometries;
//Offset for widgets' bottom right position to each other
qreal k = contentArea.height()/contentArea.width(); //slope of the diagonal
qreal offset_x = offset/(sqrt(k + 1));
qreal offset_y = k*offset_x;
QPointF offsetPoint(offset_x, offset_y);
QPointF anchorPoint;
if(startPoint.isNull()){
QLineF diagonal(contentArea.topLeft(), contentArea.bottomRight());
QLineF widgetRightSide(contentArea.center().x()+ newRects.at(0).width()/2,
contentArea.top(),
contentArea.center().x()+ newRects.at(0).width()/2,
contentArea.bottom());
// right side line intersection with diagonal will be bottom right position
// for the first rect
if(QLineF::BoundedIntersection !=
diagonal.intersect(widgetRightSide, &anchorPoint)) {
result.calculatedRects = newRects;
return result; //Return original since undefined error.
//In this case widget's must be wider than the content area.
}
} else {
anchorPoint = startPoint - offsetPoint;
}
QRectF widgetRect;
for(int i=0;i<newRects.count();++i) {
widgetRect = newRects.at(i);
widgetRect.moveBottomRight(anchorPoint);
//if widget rect doesn't fit, try to move it
if(!contentArea.contains(widgetRect)) {
/*! precondition is that
widget's max height < content area height
widget's max widht < content area width
*/
widgetRect.moveBottomRight(contentArea.bottomRight());
// anchorPoin is always previous bottom right
anchorPoint = widgetRect.bottomRight();
}
toGeometries << widgetRect;
anchorPoint -= offsetPoint;
}
result.calculatedRects = toGeometries;
return result;
}
示例2: load
bool ContentLoader::load( const QString& filename,
const QPointF& windowCenterPosition,
const QSizeF& windowSize )
{
put_flog( LOG_INFO, "opening: '%s'", filename.toLocal8Bit().constData( ));
ContentPtr content = ContentFactory::getContent( filename );
if( !content )
{
put_flog( LOG_WARN, "ignoring unsupported file: '%s'",
filename.toLocal8Bit().constData( ));
return false;
}
ContentWindowPtr contentWindow( new ContentWindow( content ));
ContentWindowController controller( *contentWindow, *displayGroup_ );
if( windowSize.isValid( ))
controller.resize( windowSize );
else
controller.adjustSize( SIZE_LARGE );
if( windowCenterPosition.isNull( ))
controller.moveCenterTo( displayGroup_->getCoordinates().center( ));
else
controller.moveCenterTo( windowCenterPosition );
displayGroup_->addContentWindow( contentWindow );
return true;
}
示例3: trackerText
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
virtual QwtText trackerText(const QPoint& pos) const override
{
QwtText txt;
const RiuSummaryQwtPlot* sumPlot = dynamic_cast<const RiuSummaryQwtPlot*>(this->plot());
if (sumPlot)
{
int closestYAxis = QwtPlot::yLeft;
QString timeString;
QString valueString;
QPointF closestPoint = sumPlot->closestCurvePoint(pos, &valueString, &timeString, &closestYAxis);
if (!closestPoint.isNull())
{
QString str = valueString;
if (!timeString.isEmpty())
{
str += QString(" (%1)").arg(timeString);
}
txt.setText(str);
}
RiuSummaryQwtPlot* nonConstPlot = const_cast<RiuSummaryQwtPlot*>(sumPlot);
nonConstPlot->updateClosestCurvePointMarker(closestPoint, closestYAxis);
}
return txt;
}
示例4: wheelEvent
void NetworkEditorView::wheelEvent(QWheelEvent* e) {
QPointF numPixels = e->pixelDelta() / 5.0;
QPointF numDegrees = e->angleDelta() / 8.0 / 15;
if (e->modifiers() == Qt::ControlModifier) {
if (!numPixels.isNull()) {
zoom(qPow(1.05, numPixels.y()));
} else if (!numDegrees.isNull()) {
zoom(qPow(1.05, numDegrees.y()));
}
} else {
QGraphicsView::wheelEvent(e);
}
e->accept();
}
示例5: mouseMoveEvent
void MapWindow::mouseMoveEvent(QMouseEvent *ev)
{
#if QT_VERSION < 0x050000
QPointF delta = ev->posF() - m_lastPos;
#else
QPointF delta = ev->localPos() - m_lastPos;
#endif
if (!delta.isNull()) {
if (ev->buttons() == Qt::LeftButton && ev->modifiers() & Qt::ShiftModifier) {
m_map->setPitch(m_map->pitch() - delta.y());
} else if (ev->buttons() == Qt::LeftButton) {
m_map->moveBy(delta);
} else if (ev->buttons() == Qt::RightButton) {
#if QT_VERSION < 0x050000
m_map->rotateBy(m_lastPos, ev->posF());
#else
m_map->rotateBy(m_lastPos, ev->localPos());
#endif
}
}
#if QT_VERSION < 0x050000
m_lastPos = ev->posF();
#else
m_lastPos = ev->localPos();
#endif
ev->accept();
}
示例6: setOption
bool PunchFilter::setOption(int option, const QVariant &value)
{
bool bOK = true;
switch (option) {
case QtImageFilter::Radius:
{
double radius = value.toDouble(&bOK);
if (bOK) m_Radius = radius;
}
break;
case QtImageFilter::Center:
{
QPointF center = value.toPointF();
if (center.isNull()) {
bOK = false;
} else {
m_Center = center;
}
}
break;
case QtImageFilter::Force:
{
double force = value.toDouble(&bOK);
if (bOK) m_Force = force;
}
break;
default:
bOK = false;
break;
}
return bOK;
}
示例7: addPoint
void QtBasicGraph::addPoint(const QPointF &value)
{
QPointF oldval;
if (!m_values.isEmpty())
oldval = m_values.last();
if (!oldval.isNull() && value.x() < oldval.x()) {
qWarning("QtBasicGraph::addPoint(): the new point's x value is less than the last point's x value.");
return;
}
m_values << value;
if (!oldval.isNull()) {
qreal deltaf = width() * ((value.x() - oldval.x()) / m_xrange);
int delta = (int) deltaf;
m_scroll_error += (deltaf - qreal(delta));
if (m_scroll_error > qreal(1.0)) {
m_scroll_error--;
delta++;
}
if (delta < width()) {
scroll(-delta, 0);
update(width() - delta - 3, 0, delta + 3, height());
} else {
m_scroll_error = 0;
update();
}
// purge old data
qreal left = value.x() - m_xrange;
int i;
for (i = 0; i < m_values.size(); ++i) {
if (m_values[i].x() > left)
break;
}
i--;
if (i > 0 && i < (m_values.size() - 1))
m_values.erase(m_values.begin(), m_values.begin() + i);
}
}
示例8: untouched
void TscoreClef::untouched(const QPointF& scenePos) {
if (!scenePos.isNull() && m_tapTimer.hasExpired(300)) {
QGraphicsSceneMouseEvent me(QEvent::MouseButtonPress);
me.setPos(mapFromScene(scenePos));
me.setButton(Qt::LeftButton);
mousePressEvent(&me);
}
}
示例9: setSymbolData
void SymbolDataEditor::setSymbolData(const QPointF _inPoint, const QPointF _outPoint, const QRectF _limits)
{
if (scene->items().isEmpty())
return;
QRectF symbolRect = scene->items(Qt::AscendingOrder).at(Item::SymbolItem)->boundingRect();
symbolRect.moveTopLeft(scene->items(Qt::AscendingOrder).at(Item::SymbolItem)->pos());
symbolRect.adjust(symbolRect.width() / 4, symbolRect.height() / 4,
-symbolRect.width() / 4, -symbolRect.height() / 4);
//try to set data automatically if they're not set
if (_inPoint.isNull())
{
if (setupPoints)
inPoint = getBeginPoint();
else
{
inPoint = symbolRect.topLeft();
inPoint.ry() += symbolRect.height() / 2;
}
}
else
inPoint = fromStored(_inPoint);
if (_outPoint.isNull())
{
if (setupPoints)
outPoint = getEndPoint();
else
{
outPoint = symbolRect.topRight();
outPoint.ry() += symbolRect.height() / 2;
}
}
else
outPoint = fromStored(_outPoint);
if (_limits.isNull())
limits = symbolRect;
else
limits = QRectF(fromStored(_limits.topLeft()),
fromStored(_limits.bottomRight()));
correctLimits();
addDataItems();
}
示例10: matrixChanged
void
ZoomWidget::moveViewWorldCs( const QPointF & d )
{
if ( d.isNull() )
return;
wm_.translate( d.x(), -d.y() );
emit matrixChanged( wm_ );
}
示例11: viewportMoved
void KisPrescaledProjection::viewportMoved(const QPointF &offset)
{
// FIXME: \|/
if (m_d->prescaledQImage.isNull()) return;
if (offset.isNull()) return;
QPoint alignedOffset = offset.toPoint();
if(offset != alignedOffset) {
/**
* We can't optimize anything when offset is float :(
* Just prescale entire image.
*/
dbgRender << "prescaling the entire image because the offset is float";
preScale();
return;
}
QImage newImage = QImage(m_d->viewportSize, QImage::Format_ARGB32);
newImage.fill(0);
/**
* TODO: viewport rects should be cropped by the borders of
* the image, because it may be requested to read/write
* outside QImage and copyQImage will not chatch it
*/
QRect newViewportRect = QRect(QPoint(0,0), m_d->viewportSize);
QRect oldViewportRect = newViewportRect.translated(alignedOffset);
QRegion updateRegion = newViewportRect;
QRect savedArea = newViewportRect & oldViewportRect;
if(!savedArea.isEmpty()) {
copyQImage(alignedOffset.x(), alignedOffset.y(), &newImage, m_d->prescaledQImage);
updateRegion -= savedArea;
}
QPainter gc(&newImage);
QVector<QRect> rects = updateRegion.rects();
foreach(const QRect &rect, rects) {
QRect imageRect =
m_d->coordinatesConverter->viewportToImage(rect).toAlignedRect();
QVector<QRect> patches =
KritaUtils::splitRectIntoPatches(imageRect, m_d->updatePatchSize);
foreach(const QRect& rc, patches) {
QRect viewportPatch =
m_d->coordinatesConverter->imageToViewport(rc).toAlignedRect();
KisPPUpdateInfoSP info = getInitialUpdateInformation(QRect());
fillInUpdateInformation(viewportPatch, info);
drawUsingBackend(gc, info);
}
示例12: plotLineForSelected
void NavigationView::plotLineForSelected() {
if (scene()->selectedItems().count()<2)
return;
QLineF vectorLine(scene()->selectedItems().at(0)->pos(), scene()->selectedItems().at(1)->pos());
QLineF sides[4] = {
QLineF(0, 0, 0, scene()->height()),
QLineF(scene()->width(), 0, scene()->width(), scene()->height()),
QLineF(0, 0, scene()->width(), 0),
QLineF(0, scene()->height(), scene()->width(), scene()->height())
};
QPointF yStart;
QPointF xStart;
int i=0;
while(yStart.isNull()) {
if (vectorLine.intersect(sides[i++], &yStart)!=QLineF::BoundedIntersection) {
qDebug("could not intersect y");
}
i++;
}
i=1;
while(xStart.isNull()) {
if (vectorLine.intersect(sides[i++], &xStart)!=QLineF::BoundedIntersection) {
qDebug("could not intersect x");
}
}
//IntersectionLineItem lineItem(QLineF(yStart, xStart);
QPen linePen(Qt::black);
linePen.setWidth(3);
QGraphicsLineItem * line = scene()->addLine(QLineF(yStart, xStart));
line->setPen(linePen);
line->setFlag(QGraphicsItem::ItemIsSelectable, true);
emit newLineAdded(mapSceneToGeo(scene()->selectedItems().at(0)->pos()), mapSceneToGeo(scene()->selectedItems().at(1)->pos()));
}
示例13: updateCurrentTime
void updateCurrentTime(int ms) {
QPointF point = m_cache.at(ms);
if (! point.isNull()) {
++ m_hits;
} else {
point = m_path.pointAtPercent(qreal(ms) / m_duration);
m_cache[ms] = point;
++ m_misses;
}
if (m_target) m_target->setPos(point);
}
示例14: timerEventWhileScrolling
void QKineticScrollerPrivate::timerEventWhileScrolling()
{
qreal deltaTime = qreal(scrollRelativeTimer.restart()) / 1000;
qreal time = qreal(scrollAbsoluteTimer.elapsed()) / 1000;
// calculate the velocity for the passed interval deltatime.
// using the midpoint of the interval gives a better precision than using just time.
QPointF newVelocity = calculateVelocity(time - deltaTime / 2);
QPointF deltaPos = newVelocity * deltaTime * pixelPerMeter;
// -- move (convert from [m/s] to [pix/frame]
if (!deltaPos.isNull())
setContentPositionHelper(deltaPos);
qKSDebug() << "QKS::timerEventWhileScrolling() -- DeltaPos:" << deltaPos << "- NewVel:" << newVelocity << "- Time:" << time;
if (newVelocity.isNull() ||
(releaseVelocity.isNull() && !scrollToX && !scrollToY && !overshootX && !overshootY))
// if (newVelocity.isNull())
setState(QKineticScroller::StateInactive);
}
示例15: translate
void QPolygonF::translate(const QPointF &offset)
{
if (offset.isNull())
return;
QPointF *p = data();
int i = size();
while (i--) {
*p += offset;
++p;
}
}