//-----------------------------------------------------------------------
Real AbsolutePixelCountLodStrategy::getValueImpl(const MovableObject *movableObject, const Ogre::Camera *camera) const
{
    // Get viewport
    const Viewport *viewport = camera->getViewport();

    // Get viewport area
    Real viewportArea = static_cast<Real>(viewport->getActualWidth() * viewport->getActualHeight());

    // Get area of unprojected circle with object bounding radius
    Real boundingArea = Math::PI * Math::Sqr(movableObject->getBoundingRadius());

    // Base computation on projection type
    switch (camera->getProjectionType())
    {
    case PT_PERSPECTIVE:
    {
        // Get camera distance
        Real distanceSquared = movableObject->getParentNode()->getSquaredViewDepth(camera);

        // Check for 0 distance
        if (distanceSquared <= std::numeric_limits<Real>::epsilon())
            return getBaseValue();

        // Get projection matrix (this is done to avoid computation of tan(FOV / 2))
        const Matrix4& projectionMatrix = camera->getProjectionMatrix();

        // Estimate pixel count
        return (boundingArea * viewportArea * projectionMatrix[0][0] * projectionMatrix[1][1]) / distanceSquared;
    }
    case PT_ORTHOGRAPHIC:
    {
        // Compute orthographic area
        Real orthoArea = camera->getOrthoWindowHeight() * camera->getOrthoWindowWidth();

        // Check for 0 orthographic area
        if (orthoArea <= std::numeric_limits<Real>::epsilon())
            return getBaseValue();

        // Estimate pixel count
        return (boundingArea * viewportArea) / orthoArea;
    }
    default:
    {
        // This case is not covered for obvious reasons
        throw;
    }
    }
}
Example #2
0
	Rect CoordConverter::screenToWindow(const Window& window, const Rect& rect)
	{
		Vector2 base(getBaseValue(window));

		// negate base position
		base.d_x = -base.d_x;
		base.d_y = -base.d_y;

		Rect tmp(rect);
		return tmp.offset(base);
	}
Example #3
0
	Rect CoordConverter::screenToWindow(const Window& window, const URect& rect)
	{
		Vector2 base(getBaseValue(window));
		Rect pixel(rect.asAbsolute(System::getSingleton().getRenderer()->getSize()));

		// negate base position
		base.d_x = -base.d_x;
		base.d_y = -base.d_y;

		return pixel.offset(base);
	}
Example #4
0
//----------------------------------------------------------------------------//
Rectf CoordConverter::screenToWindow(const Window& window, const URect& rect)
{
    Vector2f base(getBaseValue(window));
    Rectf pixel(asAbsolute(rect, window.getRootContainerSize()));

    // negate base position
    base.d_x = -base.d_x;
    base.d_y = -base.d_y;

    pixel.offset(base);
    return pixel;
}
void AnimationManager::setFirstFrameForNode(Node *node, const Sequence::Property &seqProp, const float tweenDuration){
	auto &keyframes = seqProp.keyframes;
	if (keyframes.empty()){
		// Use base value (no animation)
		auto baseValue = getBaseValue(node, seqProp.name);
//			NSAssert1(baseValue, @"No baseValue found for property (%@)", seqProp.name);
		setAnimatedProperty(seqProp.name, node, baseValue, tweenDuration);
	}else{
		// Use first keyframe
		auto &keyframe = keyframes[0];
		setAnimatedProperty(seqProp.name, node, keyframe.value, tweenDuration);
	}
}
Example #6
0
QVariant BaseSqlTableModel::data(const QModelIndex& index, int role) const {
    //qDebug() << this << "data()";
    if (!index.isValid() || (role != Qt::DisplayRole &&
                             role != Qt::EditRole &&
                             role != Qt::CheckStateRole &&
                             role != Qt::ToolTipRole)) {
        return QVariant();
    }

    int row = index.row();
    int column = index.column();

    // This value is the value in its most raw form. It was looked up either
    // from the SQL table or from the cached track layer.
    QVariant value = getBaseValue(index, role);

    // Format the value based on whether we are in a tooltip, display, or edit
    // role
    switch (role) {
        case Qt::ToolTipRole:
        case Qt::DisplayRole:
            if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_DURATION)) {
                int duration = value.toInt();
                if (duration > 0) {
                    value = Time::formatSeconds(duration);
                } else {
                    value = QString();
                }
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_RATING)) {
                if (qVariantCanConvert<int>(value))
                    value = qVariantFromValue(StarRating(value.toInt()));
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TIMESPLAYED)) {
                if (qVariantCanConvert<int>(value))
                    value =  QString("(%1)").arg(value.toInt());
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PLAYED)) {
                value = value.toBool();
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_DATETIMEADDED)) {
                QDateTime gmtDate = value.toDateTime();
                gmtDate.setTimeSpec(Qt::UTC);
                value = gmtDate.toLocalTime();
            } else if (column == fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_DATETIMEADDED)) {
                QDateTime gmtDate = value.toDateTime();
                gmtDate.setTimeSpec(Qt::UTC);
                value = gmtDate.toLocalTime();
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM_LOCK)) {
                value = value.toBool();
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_YEAR)) {
                value = Mixxx::TrackMetadata::formatCalendarYear(value.toString());
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TRACKNUMBER)) {
                int track_number = value.toInt();
                if (track_number <= 0) {
                    // clear invalid values
                    value = QString();
                }
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BITRATE)) {
                int bitrate = value.toInt();
                if (bitrate <= 0) {
                    // clear invalid values
                    value = QString();
                }
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY)) {
                // If we know the semantic key via the LIBRARYTABLE_KEY_ID
                // column (as opposed to the string representation of the key
                // currently stored in the DB) then lookup the key and render it
                // using the user's selected notation.
                int keyIdColumn = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY_ID);
                if (keyIdColumn != -1) {
                    mixxx::track::io::key::ChromaticKey key =
                            KeyUtils::keyFromNumericValue(
                                index.sibling(row, keyIdColumn).data().toInt());

                    if (key != mixxx::track::io::key::INVALID) {
                        // Render this key with the user-provided notation.
                        value = KeyUtils::keyToString(key);
                    }
                }
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_REPLAYGAIN)) {
                value = Mixxx::ReplayGain::ratioToString(value.toDouble());
            } // Otherwise, just use the column value.

            break;
        case Qt::EditRole:
            if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM)) {
                value = value.toDouble();
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TIMESPLAYED)) {
                value = index.sibling(
                    row, fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PLAYED)).data().toBool();
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_RATING)) {
                if (qVariantCanConvert<int>(value)) {
                    value = qVariantFromValue(StarRating(value.toInt()));
                }
            }
            break;
        case Qt::CheckStateRole:
            if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TIMESPLAYED)) {
                bool played = index.sibling(
                        row, fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PLAYED)).data().toBool();
                value = played ? Qt::Checked : Qt::Unchecked;
            } else if (column == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM)) {
                bool locked = index.sibling(
                        row, fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM_LOCK)).data().toBool();
                value = locked ? Qt::Checked : Qt::Unchecked;
            }
            break;
        default:
            break;
    }
    return value;
}
    //-----------------------------------------------------------------------
    Real ScaledPixelCountLodStrategy::getValueImpl(const MovableObject *movableObject, const Ogre::Camera *camera) const
    {
        // Get viewport
        const Viewport *viewport = camera->getViewport();

        // Get viewport area
        Real viewportArea = static_cast<Real>(viewport->getActualWidth() * viewport->getActualHeight());

        Ogre::Real boundingRadius = movableObject->getBoundingRadius();

        // Get area of unprojected circle with object bounding radius
        const Ogre::Vector3 nodeScale = movableObject->getParentNode()->getScale();

        if (!nodeScale.isNaN()) {
            //Get the largest scale of the parent node.
            //This is a bit inexact, since if the node is scaled with different values for the different axes we won't be using the most optimal one.
            //However, that would be too expensive (we would need to check with how the bounding box is rotated against the camera and so on.)
            //And further the vast majority of meshes we use are uniformly scaled.
            Ogre::Real scale = std::max(nodeScale.x, std::max(nodeScale.y, nodeScale.z));
            boundingRadius *= scale;
        }

        //Increase the bounding area by the scale
        Real boundingArea = Math::PI * Math::Sqr(boundingRadius);

        // Base computation on projection type
        switch (camera->getProjectionType())
        {
        case PT_PERSPECTIVE:
            {
                // Get camera distance
                Real distanceSquared = movableObject->getParentNode()->getSquaredViewDepth(camera);

                // Check for 0 distance
                if (distanceSquared <= std::numeric_limits<Real>::epsilon())
                    return getBaseValue();

                // Get projection matrix (this is done to avoid computation of tan(fov / 2))
                const Matrix4& projectionMatrix = camera->getProjectionMatrix();

                // Estimate pixel count
                return (boundingArea * viewportArea * projectionMatrix[0][0] * projectionMatrix[1][1]) / distanceSquared;
            }
        case PT_ORTHOGRAPHIC:
            {
                // Compute orthographic area
                Real orthoArea = camera->getOrthoWindowHeight() * camera->getOrthoWindowWidth();

                // Check for 0 orthographic area
                if (orthoArea <= std::numeric_limits<Real>::epsilon())
                    return getBaseValue();

                // Estimate pixel count
                return (boundingArea * viewportArea) / orthoArea;
            }
        default:
            {
                // This case is not covered for obvious reasons
                assert(0);
				return 0;
            }
        }
    }
Example #8
0
Vector2f CoordConverter::screenToWindow(const Window& window, const Vector2f& vec)
{
    return vec - getBaseValue(window);
}
Example #9
0
Vector2f CoordConverter::screenToWindow(const Window& window, const UVector2& vec)
{
    return asAbsolute(vec, window.getRootContainerSize()) - getBaseValue(window);
}
Example #10
0
	Rect CoordConverter::windowToScreen(const Window& window, const Rect& rect)
	{
		Rect tmp(rect);
		return tmp.offset(getBaseValue(window));
	}
Example #11
0
	Vector2 CoordConverter::windowToScreen(const Window& window, const Vector2& vec)
	{
		return getBaseValue(window) + vec;
	}
Example #12
0
	Vector2 CoordConverter::screenToWindow(const Window& window, const UVector2& vec)
	{
		return vec.asAbsolute(System::getSingleton().getRenderer()->getSize()) -
			getBaseValue(window);
	}
Example #13
0
	Rect CoordConverter::windowToScreen(const Window& window, const URect& rect)
	{
		Rect tmp(rect.asAbsolute(window.getPixelSize()));
		return tmp.offset(getBaseValue(window));
	}
Example #14
0
	Vector2 CoordConverter::windowToScreen(const Window& window, const UVector2& vec)
	{
		return getBaseValue(window) + vec.asAbsolute(window.getPixelSize());
	}
double TMyPaintBrushStyle::getParamValue(double_tag, int index) const
  { return getBaseValue((MyPaintBrushSetting)index); }