本文整理汇总了C++中QPointF::setY方法的典型用法代码示例。如果您正苦于以下问题:C++ QPointF::setY方法的具体用法?C++ QPointF::setY怎么用?C++ QPointF::setY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPointF
的用法示例。
在下文中一共展示了QPointF::setY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setVisible
void StelDialogLogBook::setVisible(bool v)
{
if (v)
{
QSize screenSize = StelMainWindow::getInstance().size();
if (dialog)
{
dialog->show();
StelMainView::getInstance().scene()->setActiveWindow(proxy);
// If the main window has been resized, it is possible the dialog
// will be off screen. Check for this and move it to a visible
// position if necessary
QPointF newPos = proxy->pos();
if (newPos.x()>=screenSize.width())
newPos.setX(screenSize.width() - dialog->size().width());
if (newPos.y()>=screenSize.height())
newPos.setY(screenSize.height() - dialog->size().height());
if (newPos != dialog->pos())
proxy->setPos(newPos);
proxy->setFocus();
return;
}
dialog = new QDialog(NULL);
connect(dialog, SIGNAL(rejected()), this, SLOT(close()));
createDialogContent();
proxy = new CustomProxy(NULL, Qt::Tool);
proxy->setWidget(dialog);
QRectF bound = proxy->boundingRect();
// centre with dialog according to current window size.
proxy->setPos((int)((screenSize.width()-bound.width())/2), (int)((screenSize.height()-bound.height())/2));
StelMainView::getInstance().scene()->addItem(proxy);
proxy->setWindowFrameMargins(2,0,2,2);
// The caching is buggy on all plateforms with Qt 4.5.2
#if QT_VERSION==0x040502
proxy->setCacheMode(QGraphicsItem::NoCache);
#else
proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
#endif
proxy->setZValue(100);
StelMainView::getInstance().scene()->setActiveWindow(proxy);
proxy->setFocus();
}
else
{
dialog->hide();
emit visibleChanged(false);
//proxy->clearFocus();
StelMainView::getInstance().scene()->setActiveWindow(0);
}
}
示例2: PointLePlusPres
/**
* Calcul le point sur la fleche le plus près du point donné en parametre
* @brief Fleche::PointLePlusPres
* @param Position La osition à analyser
* @return La position sur la fleche la plus proche
*/
QPointF Fleche::PointLePlusPres(QPointF Position)
{
//Calcul de la projection orthogonale de la position de la souris sur les segments verticaux de la flèche.
QPointF Retour ;
QPointF Projection ;
qreal Distance (0);
qreal DistanceMini(INFINITY) ;
QLineF LigneBase ;
QLineF LigneSourisProj ;
LigneSourisProj.setPoints(Position, Projection);
//Pour tout les segments
for(register int i = 0; i < this->ListePoints.length() -1; i++)
{
LigneBase.setPoints(this->ListePoints[i], this->ListePoints[i+1]);
//S'il sont verticaux
if(LigneBase.dx() == 0)
{
//On calcul les coordonnées du point
Projection.setX(this->ListePoints[i].x());
Projection.setY(Position.y());
//Si le point sort du segment
if(Projection.y() < this->ListePoints[i].y() || Projection.y() > this->ListePoints[i+1].y())
{
QLineF LigneSourisP1 ;
QLineF LigneSourisP2 ;
LigneSourisP1.setPoints(Position, this->ListePoints[i]);
LigneSourisP2.setPoints(Position, this->ListePoints[i+1]);
//On le recale sur l'extrémité la plus proche
if(LigneSourisP1.length() < LigneSourisP2.length())
{
Projection = this->ListePoints[i] ;
}
else
{
Projection = this->ListePoints[i+1] ;
}
}
//On renvois le point le plus proche de la souris
Distance = LigneSourisProj.length() ;
if(Distance < DistanceMini)
{
Retour = Projection ;
DistanceMini = Distance ;
}
}
}
return Retour;
}
示例3: itemChange
QVariant PdfFrameHandle::itemChange (GraphicsItemChange change,
const QVariant &value)
{
QVariant valueFiltered = value;
if (change == ItemPositionChange && scene()) {
QPointF sizeAsPointF (boundingRect().size().width(),
boundingRect().size().height());
// New position is in the value argument
QPointF newPos = valueFiltered.toPointF();
QPointF oldPos = pos ();
// This sequence is from http://www.qtcentre.org/threads/47248-How-to-efficiently-get-position-of-a-QGraphicsItem-in-view-coordinates
QRectF newRectItem (newPos,
QSize (boundingRect().size().width(),
boundingRect().size().height()));
QPolygonF newRectScene = mapToScene (newRectItem);
QPolygon newRectView = m_view.mapFromScene (newRectScene.boundingRect());
// Skip moving of this handle if it will go outside of the window
QRectF rectWindow = m_scene.sceneRect();
if (!rectWindow.contains (newRectView.boundingRect())) {
// Keep the item inside the scene rectangle
newPos.setX (qMin (rectWindow.right(), qMax (newPos.x(), rectWindow.left())));
newPos.setY (qMin (rectWindow.bottom(), qMax (newPos.y(), rectWindow.top())));
valueFiltered = (newPos);
}
// Skip moving of other handles, in response to the move of this handle, if event handling is (temporarily) off,
// to prevent an infinite loop
if (!m_disableEventsWhileMovingAutomatically) {
bool left = ((m_orientationFlags & PdfCropping::PDF_CROPPING_LEFT ) != 0);
bool right = ((m_orientationFlags & PdfCropping::PDF_CROPPING_RIGHT ) != 0);
bool top = ((m_orientationFlags & PdfCropping::PDF_CROPPING_TOP ) != 0);
bool bottom = ((m_orientationFlags & PdfCropping::PDF_CROPPING_BOTTOM) != 0);
if (left && top) {
m_pdfCropping.moveTL (newPos, oldPos);
} else if (right && top) {
m_pdfCropping.moveTR (newPos, oldPos);
} else if (right && bottom) {
m_pdfCropping.moveBR (newPos, oldPos);
} else if (left && bottom) {
m_pdfCropping.moveBL (newPos, oldPos);
}
}
}
return QGraphicsItem::itemChange(change, valueFiltered);
}
示例4: ensureVisible
void AbstractContent::ensureVisible(const QRectF & rect)
{
// keep the center inside the scene rect
QPointF center = pos();
if (!rect.contains(center)) {
center.setX(qBound(rect.left(), center.x(), rect.right()));
center.setY(qBound(rect.top(), center.y(), rect.bottom()));
setPos(center);
}
}
示例5: _setPointOfEllipseAtAngle
void EllipseTextureGraphicsItem::_setPointOfEllipseAtAngle(QPointF& point, const QPointF& center, float hRadius, float vRadius, float rotation, float circularAngle)
{
float xCirc = sin(circularAngle) * hRadius;
float yCirc = cos(circularAngle) * vRadius;
float distance = sqrt( xCirc*xCirc + yCirc*yCirc );
float angle = atan2( xCirc, yCirc );
rotation = 2*M_PI-rotation; // rotation needs to be inverted (CW <-> CCW)
point.setX( sin(angle + rotation) * distance + center.x() );
point.setY( cos(angle + rotation) * distance + center.y() );
}
示例6: mapWidgetToItem
QPointF ControlRuler::mapWidgetToItem(QPoint *point)
{
// double xscale = (double) m_pannedRect.width() / (double) width();
// double yscale = 1.0f / (double) height();
QPointF newpoint;
newpoint.setX(m_xScale*(point->x()) + m_pannedRect.left() - m_xOffset);
newpoint.setY(-m_yScale*(point->y()) + 1.0f);
return newpoint;
}
示例7: sample
const QPointF QQuickAngleDirection::sample(const QPointF &from)
{
Q_UNUSED(from);
QPointF ret;
qreal theta = m_angle*CONV - m_angleVariation*CONV + rand()/float(RAND_MAX) * m_angleVariation*CONV * 2;
qreal mag = m_magnitude- m_magnitudeVariation + rand()/float(RAND_MAX) * m_magnitudeVariation * 2;
ret.setX(mag * cos(theta));
ret.setY(mag * sin(theta));
return ret;
}
示例8: size
/**
* \brief Convertse QPointF variables from 2-vecs.
* @return
*/
QPointF RMat::QVec::toQPointF() const
{
Q_ASSERT( size() == 2);
QPointF result;
result.setX( operator[](0));
result.setY( operator[](1));
return result;
}
示例9: mapFromParent
QPointF Fidelity::GUI::ANodeItem::NodeCenterScenePosition() const
{
// Get adjusted local center position
QPointF center = mapFromParent(pos());
center.setX(center.x() + NodeSize / 2);
center.setY(center.y() + NodeSize / 2);
// Return position in scene coordinates
return(mapToScene(center));
}
示例10: topChanged
void PixmapItem::topChanged(const QString &top)
{
if(top.toInt() != pos().y())
emit itemChange();
QPointF p = pos();
p.setY(top.toInt());
setPos(p);
}
示例11: dragLeaveEvent
void CIndicatorToolScene::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
{
QString strXValue;
QString strYValue;
m_bDragOver = false;
if (event->mimeData()->hasColor())
{
event->setAccepted(true);
m_nDragColor = qvariant_cast<QColor>(event->mimeData()->colorData());
m_nColor = m_nDragColor;
//strXValue = QString(qvariant_cast<QByteArray>(event->mimeData()->data("xValue")).data());
//strYValue = QString(qvariant_cast<QByteArray>(event->mimeData()->data("yValue")).data());
strXValue = QString(event->mimeData()->data("xValue").data());
strYValue = QString(event->mimeData()->data("yValue").data());
// strXValue = "10";
// strYValue = "10";
}
CRectItem* pItem = NULL;
QPointF pointMousePos;
QPointF pointItemPos;
QPointF pointHot;
pointMousePos = event->scenePos();
pointHot.setX(strXValue.toInt());
pointHot.setY(strYValue.toInt());
pointItemPos.setX(pointMousePos.x() - pointHot.x());
pointItemPos.setY(pointMousePos.y() - pointHot.y());
pItem = new CRectItem();
pItem->setColor(m_nColor);
pItem->setItemPos(pointItemPos);
this->addItem(pItem);
pItem = NULL;
//QGraphicsScene::dragLeaveEvent(event);
update();
}
示例12: tile2mercator
QPointF tile2mercator(const QPoint &tile, int z)
{
QPointF m;
m.setX(tile.x() / pow(2.0, z) * 360.0 - 180);
qreal n = M_PI - 2.0 * M_PI * tile.y() / pow(2.0, z);
m.setY(rad2deg(atan(0.5 * (exp(n) - exp(-n)))));
return ll2mercator(m);
}
示例13: initialise
void AngleVariation::initialise()
{
// Calculate points positions
QPointF tempPoint = QPointF();
tempPoint.setX(branchLine.p2().x() - branchLine.p1().x());
tempPoint.setY(branchLine.p2().y() - branchLine.p1().y());
branchAngle = atan2(tempPoint.y(), tempPoint.x());
origPoint = findPoint(branchAngle - variationAngle);
variationPoint = calculateOpposingPoint(origPoint);
}
示例14: updatePos
void updatePos(){
QPointF c1 = start_->pos() + QPoint(kPeopleNodeRadius, kPeopleNodeRadius);
QPointF c2 = end_->pos() + QPoint(kPeopleNodeRadius, kPeopleNodeRadius);
QPointF delta = c2-c1;
qreal deltaLength = QLineF(c1, c2).length();
qreal ratio = (kPeopleNodeRadius + kConnectorGap) / deltaLength;
QPointF p1 = c1 + delta * ratio;
QPointF p2 = c2 - delta * ratio;
QLineF line;
line.setP1(p1);
line.setP2(p2);
setLine(line);
QPointF d = p1-p2;
{
static const qreal sinv = sin(kArrowAngle);
static const qreal cosv = cos(kArrowAngle);
QPointF vec;
vec.setX(d.x() * cosv - d.y() * sinv);
vec.setY(d.x() * sinv + d.y() * cosv);
qreal ratio = qSqrt(vec.x() * vec.x() + vec.y() * vec.y())/kArrowLength;
vec /= ratio;
arrow[0]->setLine(QLineF(p2, p2 + vec));
vec.setX(d.x() * cosv + d.y() * sinv);
vec.setY(-d.x() * sinv + d.y() * cosv);
vec /= ratio;
arrow[1]->setLine(QLineF(p2, p2 + vec));
}
label_->setPos((c1+c2)/2);
}
示例15:
QPointF Box2DBody::getWorldCenter() const
{
QPointF worldCenter;
if (mBody) {
const b2Vec2 ¢er = mBody->GetWorldCenter();
worldCenter.setX(center.x * scaleRatio);
worldCenter.setY(-center.y * scaleRatio);
}
return worldCenter;
}