------------------------------------------------------------------------------
| 1519 | |
| 1520 | //------------------------------------------------------------------------------ |
| 1521 | void vtkOpenGLContextDevice2D::DrawEllipticArc( |
| 1522 | float x, float y, float rX, float rY, float startAngle, float stopAngle) |
| 1523 | { |
| 1524 | assert("pre: positive_rX" && rX >= 0); |
| 1525 | assert("pre: positive_rY" && rY >= 0); |
| 1526 | |
| 1527 | if (SkipDraw()) |
| 1528 | { |
| 1529 | return; |
| 1530 | } |
| 1531 | |
| 1532 | if (rX == 0.0f && rY == 0.0f) |
| 1533 | { |
| 1534 | // we make sure maxRadius will never be null. |
| 1535 | return; |
| 1536 | } |
| 1537 | |
| 1538 | // If the 'arc' is actually a full circle, gl2ps can just insert a circle |
| 1539 | // instead of using a polygonal approximation. |
| 1540 | if (IsFullCircle(startAngle, stopAngle)) |
| 1541 | { |
| 1542 | vtkOpenGLGL2PSHelper* gl2ps = vtkOpenGLGL2PSHelper::GetInstance(); |
| 1543 | if (gl2ps && gl2ps->GetActiveState() == vtkOpenGLGL2PSHelper::Capture) |
| 1544 | { |
| 1545 | this->DrawCircleGL2PS(x, y, rX, rY); |
| 1546 | return; |
| 1547 | } |
| 1548 | } |
| 1549 | |
| 1550 | vtkOpenGLClearErrorMacro(); |
| 1551 | |
| 1552 | int iterations = this->GetNumberOfArcIterations(rX, rY, startAngle, stopAngle); |
| 1553 | |
| 1554 | float* p = new float[2 * (iterations + 1)]; |
| 1555 | |
| 1556 | // step in radians. |
| 1557 | double step = vtkMath::RadiansFromDegrees(stopAngle - startAngle) / (iterations); |
| 1558 | |
| 1559 | // step have to be lesser or equal to maxStep computed inside |
| 1560 | // GetNumberOfIterations() |
| 1561 | double rstart = vtkMath::RadiansFromDegrees(startAngle); |
| 1562 | |
| 1563 | // we are iterating counterclockwise |
| 1564 | for (int i = 0; i <= iterations; ++i) |
| 1565 | { |
| 1566 | double a = rstart + i * step; |
| 1567 | p[2 * i] = rX * cos(a) + x; |
| 1568 | p[2 * i + 1] = rY * sin(a) + y; |
| 1569 | } |
| 1570 | |
| 1571 | this->DrawPolygon(p, iterations + 1); |
| 1572 | this->DrawPoly(p, iterations + 1); |
| 1573 | delete[] p; |
| 1574 | |
| 1575 | vtkOpenGLCheckErrorMacro("failed after DrawEllipseArc"); |
| 1576 | } |
| 1577 | |
| 1578 | //------------------------------------------------------------------------------ |
nothing calls this directly
no test coverage detected