Пример #1
0
bool tAdaptiveLayoutXmlHandler::startElement( const QString& namespaceURI, const QString& localName,
    const QString& name, const QXmlAttributes& attributes )
{
    Q_UNUSED(namespaceURI);
    Q_UNUSED(localName);
    if( name == "Space" )
    {
        m_SpaceRef.SetSize(ToSize(attributes.value("size")));
    }
    else if( name == "Layer" )
    {
        m_pCurrentLayer = &m_SpaceRef.AddLayer(AdaptiveLayout::tSpace::Layer());
    }
    else if( name == "Lod" )
    {
        if( m_pCurrentLayer == 0 )
        {
            m_ErrorStr = "Bad xml format: no Layer object in current context";
            return false;
        }
        m_pCurrentLayer->lods.push_back(AdaptiveLayout::tLod(ToGeometry(attributes.value("geometry"), false)));
        m_pCurrentLod = &m_pCurrentLayer->lods.back();

        QStringList ids = attributes.value("actors").split(',', QString::SkipEmptyParts);
        foreach( const QString &str, ids )
        {
            m_pCurrentLod->AddActor(str.toInt());
        }
        QString mode = attributes.value("mode");
        if( mode == "fill" )
        {
            m_pCurrentLod->SetMode(AdaptiveLayout::tLod::eModeFill);
        }
    }
Пример #2
0
Matrix4x4
Layer::SnapTransform(const Matrix4x4& aTransform,
                     const gfxRect& aSnapRect,
                     Matrix* aResidualTransform)
{
  if (aResidualTransform) {
    *aResidualTransform = Matrix();
  }

  Matrix matrix2D;
  Matrix4x4 result;
  if (mManager->IsSnappingEffectiveTransforms() &&
      aTransform.Is2D(&matrix2D) &&
      gfx::Size(1.0, 1.0) <= ToSize(aSnapRect.Size()) &&
      matrix2D.PreservesAxisAlignedRectangles()) {
    IntPoint transformedTopLeft = RoundedToInt(matrix2D * ToPoint(aSnapRect.TopLeft()));
    IntPoint transformedTopRight = RoundedToInt(matrix2D * ToPoint(aSnapRect.TopRight()));
    IntPoint transformedBottomRight = RoundedToInt(matrix2D * ToPoint(aSnapRect.BottomRight()));

    Matrix snappedMatrix = gfxUtils::TransformRectToRect(aSnapRect,
      transformedTopLeft, transformedTopRight, transformedBottomRight);

    result = Matrix4x4::From2D(snappedMatrix);
    if (aResidualTransform && !snappedMatrix.IsSingular()) {
      // set aResidualTransform so that aResidual * snappedMatrix == matrix2D.
      // (i.e., appying snappedMatrix after aResidualTransform gives the
      // ideal transform.
      Matrix snappedMatrixInverse = snappedMatrix;
      snappedMatrixInverse.Invert();
      *aResidualTransform = matrix2D * snappedMatrixInverse;
    }
  } else {
    result = aTransform;
  }
  return result;
}