#pragma once

#include "DataElement.hpp"

/*
   Class: PieSlice

     Implements a pie slice data element.

     *Inherits* from <DataElement>.
*/
class PieSlice: public DataElement {
  public:
    /*
       Constructor: PieSlice

         Initializes the object.

       Parameters:

         pDataEntry - Pointer to the data entry object that shall be represented by the pie slice.
         fBeginValue - Accumulated data entry values of predecessor pie slices.
         fValueScaleFactor - Scale factor for all pie slices to scale the sum of all slices to 100 percent.
    */
    PieSlice(DataEntry* pDataEntry, float fBeginValue, float fValueScaleFactor);

    /*
       Destructor: ~PieSlice

         Releases all allocated resources.
    */
    ~PieSlice();


    /*
       Function: Draw

         Draws the pie slice. *Inherited* from <AlterableObject>.

       Parameters:

         pPainter - The QPainter object that shall be used for painting.
    */
    void Draw(QPainter* pPainter);

    /*
       Function: DrawLabels

         Unused function. *Inherited* from <AlterableObject>.

       Parameters:

         pPainter - Unused parameter.
    */
    void DrawLabels(QPainter* pPainter);

    /*
       Function: ChangePosition

         Changes the position of the pie slice. *Inherited* from <AlterableObject>.

       Parameters:

         fDeltaLeft - Total horizontal distance.
         fDeltaTop - Total vertical distance according to the upper vertices.
         fDeltaBottom - Unused parameter.
    */
    void ChangePosition(float fDeltaLeft, float fDeltaTop, float fDeltaBottom);

    /*
       Function: Scale

         Scales the object. *Inherited* from <DataElement>.

       Parameters:

         fDeltaWidth - Total horizontal scaling value.
         fDeltaHeight - Unused parameter.
    */
    void Scale(float fDeltaWidth, float fDeltaHeight);

    /*
       Function: ChangeAlpha

         Changes the alpha value of the pie slice. *Inherited* from <AlterableObject>.

       Parameters:

         fDeltaAlpha - Change of alpha value.
    */
    void ChangeAlpha(float fDeltaAlpha);

    /*
       Function: Rotate

         Rotates the pie slice.

       Parameters:

         fDeltaValue - Total rotation value inside a pie chart (100.0f equals 360 degrees).
    */
    void Rotate(float fDeltaValue);

    /*
       Function: SetBeginValue

         Sets the begin value of the pie slice.
         This function equals a rotation by the difference of fBeginValue minus the current begin value.

       Parameters:

         fBeginValue - The new begin value of the slice.
    */
    void SetBeginValue(float fBeginValue);

    /*
       Function: GetBeginValue

         Returns the begin value of the pie slice.

       Returns:

         The begin value of the pie slice.
    */
    float GetBeginValue();

    /*
       Function: SetWidth

         Sets the width of the pie slice.
         This function equals a scaling by the difference of fWidth minus the current width.

       Parameters:

         fWidth - The new width of the pie slice.
    */
    void SetWidth(float fWidth);

    /*
       Function: GetValueScaleFactor

         Returns the value scale factor of the pie slice.
         All pie slices of the same pie chart return the same value.

       Returns:

         The value scale factor of the pie slice.
    */
    float GetValueScaleFactor();

    /*
       Function: GetOutterVertices

         Returns the number of outter vertices (all vertices minus the center vertex).

       Returns:

         The number of outter vertices.
    */
    int GetOutterVertices();

  private:
    int iOutterVertices;
    float fBeginValue;
    float fValueScaleFactor;
};