本文整理汇总了C++中QVector3D::toPointF方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector3D::toPointF方法的具体用法?C++ QVector3D::toPointF怎么用?C++ QVector3D::toPointF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector3D
的用法示例。
在下文中一共展示了QVector3D::toPointF方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawAxes
void ViewportView::drawAxes(QPainter* painter) const
{
// First, draw the axes.
auto m = getMatrix();
QVector3D o = m * QVector3D(0, 0, 0);
QVector3D x = m * QVector3D(1, 0, 0);
QVector3D y = m * QVector3D(0, 1, 0);
QVector3D z = m * QVector3D(0, 0, 1);
QList<QPair<QVector3D, QColor>> pts = {
{x, Colors::red},
{y, Colors::green},
{z, Colors::blue}};
// Sort the axes to fake proper z clipping
std::sort(pts.begin(), pts.end(),
[](QPair<QVector3D, QColor> a, QPair<QVector3D, QColor> b)
{ return a.first.z() < b.first.z(); });
for (auto p : pts)
{
painter->setPen(QPen(p.second, 2));
painter->drawLine(o.toPointF(), p.first.toPointF());
}
}
示例2: updateShotLines
/**
\brief When a station has been selected, this updates the shot lines
This shows the shot lines from the selected station. If no station is
currently selected, this will hide the lines
*/
void cwScrapStationView::updateShotLines() {
if(scrap() == nullptr) { return; }
if(scrap()->parentNote() == nullptr) { return; }
if(scrap()->parentNote()->parentTrip() == nullptr) { return; }
if(transformUpdater() == nullptr) { return; }
cwNoteStation noteStation = scrap()->station(selectedItemIndex());
//Get the current trip
cwNote* note = scrap()->parentNote();
cwTrip* trip = note->parentTrip();
cwCave* cave = trip->parentCave();
cwStationPositionLookup stationPositionLookup = cave->stationPositionLookup();
//Clear all the lines
ShotLines.clear();
if(noteStation.isValid() && stationPositionLookup.hasPosition(noteStation.name())) {
QString stationName = noteStation.name();
QSet<cwStation> neighboringStations = trip->neighboringStations(stationName);
//The position of the selected station
QVector3D selectedStationPos = stationPositionLookup.position(noteStation.name());
//Create the matrix to covert global position into note position
QMatrix4x4 noteTransformMatrix = scrap()->noteTransformation()->matrix(); //Matrix from page coordinates to cave coordinates
noteTransformMatrix = noteTransformMatrix.inverted(); //From cave coordinates to page coordinates
QMatrix4x4 notePageAspect = note->scaleMatrix().inverted(); //The note's aspect ratio
QMatrix4x4 offsetMatrix;
offsetMatrix.translate(-selectedStationPos);
QMatrix4x4 dotPerMeter;
dotPerMeter.scale(note->dotPerMeter(), note->dotPerMeter(), 1.0);
QMatrix4x4 noteStationOffset;
noteStationOffset.translate(QVector3D(noteStation.positionOnNote()));
QMatrix4x4 toNormalizedNote = noteStationOffset *
dotPerMeter *
notePageAspect *
noteTransformMatrix *
offsetMatrix;
//Go through all the neighboring stations and add the position to the line
foreach(cwStation station, neighboringStations) {
QVector3D currentPos = stationPositionLookup.position(station.name());
QVector3D normalizeNotePos = toNormalizedNote.map(currentPos);
ShotLines.append(QLineF(noteStation.positionOnNote(), normalizeNotePos.toPointF()));
}
示例3: mapToScene
QPointF GLScene::mapToScene(const QPointF &p){
// Code below will work OK while projection is ortogonal
// For some reason in perspective projection everything is flipped and not accurate
QVector4D rNear = unproject(QVector3D(p.x(), p.y(), -1));
QVector4D rFar = unproject(QVector3D(p.x(), p.y(), 1));
QVector<QVector3D> triangle;
triangle << QVector3D(0, 0, 0) << QVector3D(0, 1, 0) << QVector3D(1, 0, 0);
QVector3D normal = QVector3D::normal(triangle.at(0), triangle.at(1), triangle.at(2));
qreal d1 = QVector3D::dotProduct(rNear.toVector3D() - triangle.at(0), normal);
qreal d2 = QVector3D::dotProduct(rFar.toVector3D() - triangle.at(0), normal);
QVector3D point = rNear.toVector3D() + (rFar.toVector3D() - rNear.toVector3D()) * (-d2 / (d2 - d1));
return point.toPointF();
}
示例4: setPos
void CreatorItem::setPos(const QVector3D& pos)
{
QGraphicsItem::setPos(pos.toPointF());
QGraphicsItem::setZValue(pos.z());
}
示例5: updateTransformUpdate
//Caluclate the running profile rotation based on the stations
QMatrix4x4 toProfileRotation = cwScrap::toProfileRotation(selectedStationPos, currentPos);
toNormalizedNote = noteStationOffset *
dotPerMeter *
notePageAspect *
noteTransformMatrix *
profileDirection *
toProfileRotation *
offsetMatrix;
}
QVector3D normalizeNotePos = toNormalizedNote.map(currentPos);
ShotLines.append(QLineF(noteStation.positionOnNote(), normalizeNotePos.toPointF()));
}
}
LineDataDirty = true;
//Update the node geometry
update();
}
/**
* @brief cwScrapStationView::updateTransformUpdate
*
* Called when the transform update has changed
*/
void cwScrapStationView::updateTransformUpdate() {