Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Алгоритмы > Алгоритм рисования exploded pie chart


Автор: Therion 20.4.2010, 15:56
Доброе время суток. 
Нужен алгоритм рисования exploded pie chart. 
В наличии функция рисования обычного pie chart или pie chart с 3D тенью:
Код

void CPie::DrawItems()
{
    CPoint center = GetCenter();

    ChartDataSeriesType data = GetData();
    DataType degrees = 0;
    DataType arcCount = 0;
    DataType sum = std::accumulate(boost::get<0>(data).begin(), boost::get<0>(data).end(), 
        boost::numeric_cast<DataType>(0));

    std::vector<CColor>::const_iterator iter = GetColors().begin();

    foreach (DataType i, boost::get<0>(data))
    {
        degrees = (boost::numeric_cast<DataType>(360.00003) * i) / sum;
        CColor color = *iter;
        ++iter;

        CArc* arc1 = new CArc(this, center , GetRadius(), (GetDepth() > 0) ? (GetRadius() / 2) : GetRadius(), 
            arcCount, arcCount + degrees, color);

        // Draw 3D shadow
        if (GetDepth() > 0)
        {
            for (DataType j = center.Y * (DataType)1.05; j >= center.Y; j--) 
            {
                DataType end = arcCount + degrees;
                if ((arcCount + degrees) >= (DataType)180)
                {
                    if (arcCount < (DataType)180)
                        end = (DataType)180;
                    else
                        break;
                }

                CArc* arc2 = new CArc(this, CPoint(center.X, j), GetRadius(), GetRadius()/ 2,
                    arcCount, end, color.GetShadowColor(50));
            }
        }

        arcCount += degrees;
    }
}

Заранее благодарю за помощь.

Автор: Therion 7.9.2012, 10:01
Решено

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)