Beispiel #1
0
void QAbstractAttribute::setBuffer(QAbstractBuffer *buffer)
{
    Q_D(QAbstractAttribute);
    if (d->m_buffer == buffer)
        return;

    if (d->m_buffer && d->m_changeArbiter) {
        QScenePropertyChangePtr change(new QScenePropertyChange(NodeRemoved, QSceneChange::Node, id()));
        change->setPropertyName("buffer");
        change->setValue(QVariant::fromValue(d->m_buffer->id()));
        d->notifyObservers(change);
    }

    // We need to add it as a child of the current node if it has been declared inline
    // Or not previously added as a child of the current node so that
    // 1) The backend gets notified about it's creation
    // 2) When the current node is destroyed, it gets destroyed as well
    if (buffer && !buffer->parent())
        buffer->setParent(this);

    d->m_buffer = buffer;
    const bool blocked = blockNotifications(true);
    emit bufferChanged();
    blockNotifications(blocked);

    if (d->m_buffer && d->m_changeArbiter) {
        QScenePropertyChangePtr change(new QScenePropertyChange(NodeAdded, QSceneChange::Node, id()));
        change->setPropertyName("buffer");
        change->setValue(QVariant::fromValue(buffer->id()));
        d->notifyObservers(change);
    }
}
Beispiel #2
0
void QMesh::setMeshName(const QString &meshName)
{
    Q_D(QMesh);
    if (d->m_meshName == meshName)
        return;
    d->m_meshName = meshName;
    d->updateFunctor();
    const bool blocked = blockNotifications(true);
    emit meshNameChanged(meshName);
    blockNotifications(blocked);
}
Beispiel #3
0
void QMesh::setSource(const QUrl& source)
{
    Q_D(QMesh);
    if (d->m_source == source)
        return;
    d->m_source = source;
    d->updateFunctor();
    const bool blocked = blockNotifications(true);
    emit sourceChanged(source);
    blockNotifications(blocked);
}
Beispiel #4
0
void QNode::setDefaultPropertyTrackingMode(QNode::PropertyTrackingMode mode)
{
    Q_D(QNode);
    if (d->m_defaultPropertyTrackMode == mode)
        return;

    d->m_defaultPropertyTrackMode = mode;
    // The backend doesn't care about such notification
    const bool blocked = blockNotifications(true);
    emit defaultPropertyTrackingModeChanged(mode);
    blockNotifications(blocked);
    d->updatePropertyTrackMode();
}
Beispiel #5
0
/*!
 * Defines a perspective projection based on \a fieldOfView, \a aspectRatio, \a
 * nearPlane, \a farPlane.
 */
void QCameraLens::setPerspectiveProjection(float fieldOfView, float aspectRatio,
                                           float nearPlane, float farPlane)
{
    Q_D(QCameraLens);
    bool block = blockNotifications(true);
    setFieldOfView(fieldOfView);
    setAspectRatio(aspectRatio);
    setNearPlane(nearPlane);
    setFarPlane(farPlane);
    setProjectionType(PerspectiveProjection);
    blockNotifications(block);
    d->updateProjectionMatrix();
}
Beispiel #6
0
/*!
 * Defines an orthographic projection based on \a left, \a right, \a bottom, \a
 * top, \a nearPlane, \a farPlane.
 */
void QCameraLens::setFrustumProjection(float left, float right,
                                       float bottom, float top,
                                       float nearPlane, float farPlane)
{
    Q_D(QCameraLens);
    bool block = blockNotifications(true);
    setLeft(left);
    setRight(right);
    setBottom(bottom);
    setTop(top);
    setNearPlane(nearPlane);
    setFarPlane(farPlane);
    setProjectionType(FrustumProjection);
    blockNotifications(block);
    d->updateProjectionMatrix();
}
Beispiel #7
0
// Note: should never be called from the ctor directly as the type may not be fully
// created yet
void QNode::setParent(QNode *parent)
{
    Q_D(QNode);

    // If we already have a parent don't do anything. Be careful to ensure
    // that QNode knows about the parent, not just QObject (by checking the ids)
    if (parentNode() == parent &&
            ((parent != nullptr && d->m_parentId == parentNode()->id()) || parent == nullptr))
        return;
    d->_q_setParentHelper(parent);

    // Block notifications as we want to let the _q_setParentHelper
    // manually handle them
    const bool blocked = blockNotifications(true);
    emit parentChanged(parent);
    blockNotifications(blocked);
}
Beispiel #8
0
/*!
    Called when one or more backend aspects sends a notification \a change to the
    current Qt3DCore::QNode instance.

    \note This method should be reimplemented in your subclasses to properly
    handle the \a change.
*/
void QNode::sceneChangeEvent(const QSceneChangePtr &change)
{
    Q_UNUSED(change);
    if (change->type() == Qt3DCore::PropertyUpdated) {
        // TODO: Do this more efficiently. We could pass the metaobject and property
        //       index to the animation aspect via the QChannelMapping. This would
        //       allow us to avoid the propertyIndex lookup here by sending them in
        //       a new subclass of QPropertyUpdateChange.
        // Try to find property and call setter
        auto e = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(change);
        const QMetaObject *mo = metaObject();
        const int propertyIndex = mo->indexOfProperty(e->propertyName());
        QMetaProperty mp = mo->property(propertyIndex);
        bool wasBlocked = blockNotifications(true);
        mp.write(this, e->value());
        blockNotifications(wasBlocked);
    } else {
        // Nothing is handling this change, warn the user.
        qWarning() << Q_FUNC_INFO << "sceneChangeEvent should have been subclassed";
    }
}