本文整理汇总了C++中QVector4D::setW方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector4D::setW方法的具体用法?C++ QVector4D::setW怎么用?C++ QVector4D::setW使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector4D
的用法示例。
在下文中一共展示了QVector4D::setW方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: retrieveColor
inline void AssimpScene::retrieveColor(
const aiMaterial * mtl
, const char * pKey
, const unsigned int type
, const unsigned int index
, QVector4D & color
, const float r
, const float g
, const float b
, const float a)
{
aiColor4D acolor;
if (AI_SUCCESS == aiGetMaterialColor(mtl, pKey, type, index, &acolor))
{
color.setX(acolor.r);
color.setY(acolor.g);
color.setZ(acolor.b);
color.setW(acolor.a);
}
else
{
color.setX(r);
color.setY(g);
color.setZ(b);
color.setW(a);
}
}
示例2: getValue
void PropertyGroup::getValue(QVector4D & v)
{
v.setX(properties.at(0)->getValue());
v.setY(properties.at(1)->getValue());
v.setZ(properties.at(2)->getValue());
v.setW(properties.at(3)->getValue());
}
示例3: tmp
static QVector3D unproject( QVector3D v, const QMatrix4x4 &modelView, const QMatrix4x4 &projection, QRect viewport )
{
// Reimplementation of QVector3D::unproject() - see qtbase/src/gui/math3d/qvector3d.cpp
// The only difference is that the original implementation uses tolerance 1e-5
// (see qFuzzyIsNull()) as a protection against division by zero. For us it is however
// common to get lower values (e.g. as low as 1e-8 when zoomed out to the whole Earth with web mercator).
QMatrix4x4 inverse = QMatrix4x4( projection * modelView ).inverted();
QVector4D tmp( v, 1.0f );
tmp.setX( ( tmp.x() - float( viewport.x() ) ) / float( viewport.width() ) );
tmp.setY( ( tmp.y() - float( viewport.y() ) ) / float( viewport.height() ) );
tmp = tmp * 2.0f - QVector4D( 1.0f, 1.0f, 1.0f, 1.0f );
QVector4D obj = inverse * tmp;
if ( qgsDoubleNear( obj.w(), 0, 1e-10 ) )
obj.setW( 1.0f );
obj /= obj.w();
return obj.toVector3D();
}
示例4: unproject
QVector4D GLScene::unproject(const QVector3D & screen){
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
const qreal xNorm = (2.0f * ((screen.x() - viewport[0]) / (viewport[2] - viewport[0]))) - 1.0f;
const qreal yNorm = 1.0f - (2.0f * ((screen.y() - viewport[1]) / (viewport[3] - viewport[1])));
QMatrix4x4 pvMatrixInv = camera().projViewProduct().inverted();
QVector4D worldPoint = pvMatrixInv * QVector4D(xNorm, yNorm, screen.z(), 1);
if (worldPoint.w() == 0){
return QVector4D(0,0,0,0);
}
worldPoint.setW(1 / worldPoint.w());
worldPoint.setX(worldPoint.x() * worldPoint.w());
worldPoint.setY(worldPoint.y() * worldPoint.w());
return worldPoint;
}
示例5: setData
bool PropertyMatrixModel::setData(const QModelIndex &index, const QVariant &data, int role)
{
if (!index.isValid())
return false;
if (role != Qt::EditRole)
return false;
bool ok = false;
float floatData = data.toFloat(&ok);
if (!ok)
return false;
switch (m_matrix.type()) {
case QVariant::Vector2D: {
QVector2D value = m_matrix.value<QVector2D>();
switch (index.row()) {
case 0: value.setX(floatData); break;
case 1: value.setY(floatData); break;
}
m_matrix = value;
break;
}
case QVariant::Vector3D: {
QVector3D value = m_matrix.value<QVector3D>();
switch (index.row()) {
case 0: value.setX(floatData); break;
case 1: value.setY(floatData); break;
case 2: value.setZ(floatData); break;
}
m_matrix = value;
break;
}
case QVariant::Vector4D: {
QVector4D value = m_matrix.value<QVector4D>();
switch (index.row()) {
case 0: value.setX(floatData); break;
case 1: value.setY(floatData); break;
case 2: value.setZ(floatData); break;
case 3: value.setW(floatData); break;
}
m_matrix = value;
break;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
case QVariant::Quaternion: {
float pitch, yaw, roll;
const QQuaternion value = m_matrix.value<QQuaternion>();
value.getEulerAngles(&pitch, &yaw, &roll);
switch (index.row()) {
case 0: pitch = floatData; break;
case 1: yaw = floatData; break;
case 2: roll = floatData; break;
}
m_matrix = QQuaternion::fromEulerAngles(pitch, yaw, roll);
break;
}
#endif
case QVariant::Matrix: {
QMatrix value = m_matrix.value<QMatrix>();
switch (index.row() << 4 | index.column()) {
case 0x00: value.setMatrix(floatData, value.m12(), value.m21(), value.m22(), value.dx(), value.dy()); break;
case 0x01: value.setMatrix(value.m11(), floatData, value.m21(), value.m22(), value.dx(), value.dy()); break;
case 0x10: value.setMatrix(value.m11(), value.m12(), floatData, value.m22(), value.dx(), value.dy()); break;
case 0x11: value.setMatrix(value.m11(), value.m12(), value.m21(), floatData, value.dx(), value.dy()); break;
case 0x20: value.setMatrix(value.m11(), value.m12(), value.m21(), value.m22(), floatData, value.dy()); break;
case 0x21: value.setMatrix(value.m11(), value.m12(), value.m21(), value.m22(), value.dx(), floatData); break;
}
m_matrix = value;
break;
}
case QVariant::Transform: {
QTransform value = m_matrix.value<QTransform>();
switch (index.row() << 4 | index.column()) {
case 0x00: value.setMatrix(floatData, value.m12(), value.m13(), value.m21(), value.m22(), value.m23(), value.m31(), value.m32(), value.m33()); break;
case 0x01: value.setMatrix(value.m11(), floatData, value.m13(), value.m21(), value.m22(), value.m23(), value.m31(), value.m32(), value.m33()); break;
case 0x02: value.setMatrix(value.m11(), value.m12(), floatData, value.m21(), value.m22(), value.m23(), value.m31(), value.m32(), value.m33()); break;
case 0x10: value.setMatrix(value.m11(), value.m12(), value.m13(), floatData, value.m22(), value.m23(), value.m31(), value.m32(), value.m33()); break;
case 0x11: value.setMatrix(value.m11(), value.m12(), value.m13(), value.m21(), floatData, value.m23(), value.m31(), value.m32(), value.m33()); break;
case 0x12: value.setMatrix(value.m11(), value.m12(), value.m13(), value.m21(), value.m22(), floatData, value.m31(), value.m32(), value.m33()); break;
case 0x20: value.setMatrix(value.m11(), value.m12(), value.m13(), value.m21(), value.m22(), value.m23(), floatData, value.m32(), value.m33()); break;
case 0x21: value.setMatrix(value.m11(), value.m12(), value.m13(), value.m21(), value.m22(), value.m23(), value.m31(), floatData, value.m33()); break;
case 0x22: value.setMatrix(value.m11(), value.m12(), value.m13(), value.m21(), value.m22(), value.m23(), value.m31(), value.m32(), floatData); break;
}
m_matrix = value;
//.........这里部分代码省略.........
示例6: leftMouseDown
void CombinedNavRenderer::leftMouseDown( int x, int y )
{
float xf = static_cast<float>( x );
float yf = static_cast<float>( m_height - y );
QVector4D test;
test.setX( ( 2 * xf ) / m_width - 1 );
test.setY( ( 2 * yf ) / m_height - 1 );
test.setZ( 1 );
test.setW( 1 );
int xout;
int yout;
QVector4D out = m_mvpMatrix.inverted() * test;
QModelIndex mi;
if ( m_ratio > 1.5 )
{
xout = out.x() / m_dx;
if ( ( (float)out.x() / m_dx ) < m_nx )
{
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = out.y() / m_dy;
yout = qMax( 0, qMin( yout, static_cast<int>( m_ny - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_CORONAL, 0 );
}
else if ( ( (float)out.x() / m_dx ) < m_nx * 2 )
{
xout = xout - m_nx;
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = out.y() / m_dz;
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_AXIAL, 0 );
}
else
{
xout = xout - ( 2 * m_nx );
xout = qMax( 0, qMin( m_ny - xout - 1, static_cast<int>( m_ny - 1.0 ) ) );
yout = out.y() / m_dz;
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::CORONAL_AXIAL, 0 );
}
}
else if ( m_ratio < 0.66 )
{
yout = out.y() / m_dz;
if ( ( (float)out.y() / m_dz ) < m_nz )
{
xout = out.x() / m_dy;
xout = qMax( 0, qMin( m_ny - xout - 1, static_cast<int>( m_ny - 1.0 ) ) );
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::CORONAL_AXIAL, 0 );
}
else if ( ( (float)out.y() / m_dz ) < m_nz * 2 )
{
xout = out.x() / m_dx;
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = yout - m_nz;
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_AXIAL, 0 );
}
else
{
xout = out.x() / m_dx;
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = yout - ( 2 * m_nz );
yout = qMax( 0, qMin( yout, static_cast<int>( m_ny - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_CORONAL, 0 );
}
}
else
{
xout = out.x() / m_dx;
yout = out.y() / m_dy;
if ( ( (float)out.x() / m_dx ) < m_nx )
{
if ( ( (float)out.y() / m_dy ) < m_nz )
{
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = qMax( 0, qMin( yout, static_cast<int>( m_ny - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_CORONAL, 0 );
}
else
{
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = yout - m_ny;
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_AXIAL, 0 );
}
}
else
{
xout = xout - m_nx;
xout = qMax( 0, qMin( m_ny - xout- 1, static_cast<int>( m_ny - 1.0 ) ) );
yout = yout - m_ny;
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::CORONAL_AXIAL, 0 );
}
}
QPoint p( xout, yout );
//.........这里部分代码省略.........