// -----------------------------------------------------------------------------
// CTestEdwinSettingPage::DoLayoutRect
// -----------------------------------------------------------------------------
//
void CTestEdwinSettingPage::DoLayoutRect()
    {
    TPoint topLeftPoint( KZero, KZero );
    TPoint bottomRightPoint( KTen, KTen );
    TRect rect( topLeftPoint, bottomRightPoint );
    iEdwinLayoutRect.LayoutRect( rect, KZero, KZero, KZero, KTen, KTen, KTen, KTen );
    iHorizontalShadow.LayoutRect( rect, KZero, KZero, KZero, KTen, KTen, KTen, KTen );
    iVerticalShadow.LayoutRect( rect, KZero, KZero, KZero, KTen, KTen, KTen, KTen );
    iOutlineFrame.LayoutRect( rect, KZero, KZero, KZero, KTen, KTen, KTen, KTen );
    }
void SelectionRectangle::setRect(const QPointF &firstPoint,
                                 const QPointF &secondPoint)
{
    double firstX = std::floor(firstPoint.x()) + 0.5;
    double firstY = std::floor(firstPoint.y()) + 0.5;
    double secondX = std::floor(secondPoint.x()) + 0.5;
    double secondY = std::floor(secondPoint.y()) + 0.5;
    QPointF topLeftPoint(firstX < secondX ? firstX : secondX, firstY < secondY ? firstY : secondY);
    QPointF bottomRightPoint(firstX > secondX ? firstX : secondX, firstY > secondY ? firstY : secondY);

    QRectF rect(topLeftPoint, bottomRightPoint);
    m_controlShape->setRect(rect);
}
/**************************************************************************
* AEarthWindow :: paintWorld - paint a view of Earth from space           *
**************************************************************************/
bool AEarthWindow :: computeWorld()
{
  const float
    xRadiusFactor[4] = {1.45, 1.55, 1.60, 1.65},
    yRadiusFactor[4] = {(0.7 - 1.0/8), (0.7 - 1.0/16),
                        (0.7 - 1.0/32), (0.7 - 1.0/64)};
  const IRectangle
    psRect(rect());

/*------------------------------------------------------------------------|
| Construct the IGRect2D space to form the background of the scene.       |
-------------------------------------------------------------------------*/

  IGPoint2D
     bottomLeftPoint(0, 0),
     bottomRightPoint(psRect.width(), 0),
     topLeftPoint(0, psRect.height()),
     topRightPoint(psRect.width(), psRect.height());

  spaceDimensions.setPoint(0, bottomLeftPoint);
  spaceDimensions.setPoint(1, bottomRightPoint);
  spaceDimensions.setPoint(2, topRightPoint);
  spaceDimensions.setPoint(3, topLeftPoint);

/*------------------------------------------------------------------------|
| Compute the dimensions for the earthArcs.                               |
-------------------------------------------------------------------------*/

  IGPoint2D centerPoint(psRect.width() / 2, -psRect.height() * 0.2);
  int xRad, yRad;
  for(int i=0;i<=atmosphereLayers;i++)
     {
        yRad = yRadiusFactor[i] * psRect.height();
        xRad = xRadiusFactor[i] * yRad;
        IGRect2D arcBoundsRect(0, 2 * yRad, 2 * xRad, 0);
        arcDimensions[i].setBounds(arcBoundsRect);
        arcDimensions[i].setCenter(centerPoint);
     }


/*------------------------------------------------------------------------|
| Call computeStars() to compuet the dimensions for the stars.            |
| Then call paintWorld() that uses all these dimensions to create the     |
| objects to be painted.                                                  |
-------------------------------------------------------------------------*/
  computeStars();
  paintWorld();
  refresh();
  return true;

} /* end AEarthWindow :: paintWorld(..) */
Esempio n. 4
0
void ConvertEffectsTest::addText_topLeftCorner() {
    QImage result(testImg);
    effects.setImage(&result);

    info.textPos = QPoint(0, 0);
    info.textUnitPair.first = Pixel;
    info.textUnitPair.second = Pixel;
    info.textFont.setFamily("DejaVu Sans");
    info.textFont.setPointSize(20);
    info.textString = "test string";
    info.textPosModifier = TopLeftCorner;
    info.textColor = Qt::green;
    info.textOpacity = 0.5;
    info.textRotation = 0;
    info.textFrame = false;

    effects.addText();

    QImage expected(testImg);
    QPoint topLeftPoint(0, 0);
    QFontMetrics fontMetrics(info.textFont, &expected);
    QRect rect = fontMetrics.boundingRect(info.textString);
    const int dx = 5;
    const int dy = 1;
    rect.adjust(-dx, -dy, dx, dy);
    rect.moveTopLeft(topLeftPoint);
    QPainter p(&expected);
    p.setPen(info.textColor);
    p.setFont(info.textFont);
    p.setOpacity(info.textOpacity);
    p.drawText(rect, Qt::AlignCenter, info.textString);

    result.save(QDir::tempPath() + "/sir_test_addText_topLeftCorner_result.bmp");
    expected.save(QDir::tempPath() + "/sir_test_addText_topLeftCorner_expected.bmp");
    QCOMPARE(result, expected);
}