/** * @file XTPChartPie.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPCHARTPIE_H__) # define __XTPCHARTPIE_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPChartPieBase; class CXTPChartDeviceCommand; class CXTPChartBounds; /** * @brief * This class abstracts an ellipse. */ class _XTP_EXT_CLASS CXTPChartEllipse { public: /** * @brief * Constructs a CXTPChartEllipse object. */ CXTPChartEllipse(); /** * @brief * Overloaded constructor, creates a CXTPChartSplineSeriesView object. * * @param ptCenter The center point of the ellipse. * @param dMajorSemiaxis The length of the major semi axis. * @param dMinorSemiaxis The length of the minor semi axis. */ CXTPChartEllipse(const CXTPPoint3d& ptCenter, double dMajorSemiaxis, double dMinorSemiaxis); public: /** * @brief * Call this function to get the area of the ellipse. * * @return A double value specifying the area of the ellipse. */ double GetArea() const; /** * @brief * Call this function to get the center of the ellipse. * * @return A CXTPPoint3d value specifying the center point of the ellipse. */ CXTPPoint3d GetCenter() const; /** * @brief * Call this function to get the finish angle from a start angle and area * of a sector. * @param areaSector Area sector value * @param startAngle The start angle in degree * @return A double value specifying the finish angle. */ double CalcEllipseSectorFinishAngle(double areaSector, double startAngle) const; public: /** * @brief * Call this function to convert polar coordinates to Cartesian co-ordinates. * * @param angle The angle in degrees. * @param radius The radius of the point. * * @return * A CXTPPoint3d specifying the Cartesian co-ordinate. */ CXTPPoint3d Polar2Cartesian(double angle, double radius) const; /** * @brief * Call this function to calculate the radius of the ellipse from * the given angle * * @param angle The angle in degrees. * * @return A double value specifying the radius of the ellipse. */ double CalcEllipseRadius(double angle) const; /** * @brief * Call this function to calculate the ellipse Cartesian point * on a given angle * * @param angle The angle in degrees. * * @return A CXTPPoint3d denoting the Cartesian coordinate. */ CXTPPoint3d CalcEllipsePoint(double angle) const; /** * @brief * Call this function to calculate the sector area from a start angle * and finish angle. * * @param startAngle The start angle in degree. * @param finishAngle The finish angle in degree. * * @return A double value specifying the sector area. */ double CalcEllipseSectorArea(double startAngle, double finishAngle) const; /** * @brief * Call this function to calculate the ellipse angle from the circle angle. * * @param angle The circle angle. * * @return A double value ellipse angle. */ double CalcEllipseAngleFromCircleAngle(double angle) const; /** * @brief * Call this function to apply the center point of the ellipse. * * @param point The center point. * * @return A CXTPPoint3d value specifying the new center point. */ CXTPPoint3d ApplyCenterPoint(const CXTPPoint3d& point) const; /** @cond */ double AtanMulTan(double multiplier, double tanAngle) const; /** @endcond */ public: CXTPPoint3d m_ptCenter; /**< The center of the ellipse.*/ double m_dMajorSemiaxis; /**< The major semi axis of the ellipse.*/ double m_dMinorSemiaxis; /**< The minor semi axis of the ellipse.*/ double m_dArea; /**< The area of the ellipse.*/ friend class CXTPChartPieBase; }; AFX_INLINE double CXTPChartEllipse::GetArea() const { return m_dArea; } /** * @brief * This class abstracts a pie chart. */ class _XTP_EXT_CLASS CXTPChartPieBase : public CObject { DECLARE_DYNAMIC(CXTPChartPieBase); protected: /** * @brief * Constructs a CXTPChartPieBase object. * * @param dStartAngle The start angle of the pie. * @param dFinishAngle The finish angle of the pie. * @param ellipse The ellipse associated with the pie. * @param nDepthPercent The depth percentage, in case of 3D chart. * @param nHolePercent The hole percentage. */ CXTPChartPieBase(double dStartAngle, double dFinishAngle, const CXTPChartEllipse& ellipse, int nDepthPercent, int nHolePercent); public: /** * @brief * Destroys a CXTPChartPieBase object, handles cleanup and deallocation. */ virtual ~CXTPChartPieBase(); public: /** * @brief * Call this function to calculate the ceter of the pie. * * @param basePoint The base point in the diagram. * * @return A CXTPPoint3d object denoting the center point of the pie. */ CXTPPoint3d CalculateCenter(const CXTPChartPointF& basePoint) const; public: /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of the pie. * * @param color The first color used for gradient pie. * @param color2 The second color used for gradient pie. * @param basePoint Reference to a CXTPChartPointF object. * * @return Returns a CXTPChartDeviceCommand object. This object handles * the rendering of an element in the chart. Here it handles * the drawing of the pie. */ virtual CXTPChartDeviceCommand* CreatePieDeviceCommand(const CXTPChartColor& color, const CXTPChartColor& color2, const CXTPChartPointF& basePoint) = 0; /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of the pie. * * @param color The first color used for gradient pie. * @param basePoint Reference to a CXTPChartPointF object. * @param nThickness Thickness. * * @return Returns a CXTPChartDeviceCommand object. This object handles * the rendering of an element in the chart. Here it handles * the drawing of the pie. */ virtual CXTPChartDeviceCommand* CreateBoundedPieDeviceCommand( const CXTPChartColor& color, int nThickness, const CXTPChartPointF& basePoint) = 0; /** * @brief * Call this function to get the half angle of the pie slice. * * @return A double specifying the half angle. */ double GetHalfAngle() const; /** * @brief * Call this function to get the start angle of the pie slice. * * @return A double specifying the start angle. */ double GetStartAngle() const; /** * @brief * Call this function to get the finish/start point of the pie slice. * * @return A CXTPChartPointF object specifying the finish/start point. */ CXTPChartPointF GetFinishPoint() const; /** * @brief * Call this function to get the finish/start point of the pie slice. * * @return A CXTPChartPointF object specifying the finish/start point. */ CXTPChartPointF GetStartPoint() const; /** * @brief * Call this function to get the center point of the pie slice. * * @return A CXTPChartPointF object specifying the center point. */ CXTPChartPointF GetCenterPoint() const; /** * @brief * Call this function to get the bounding rectangle of the pie chart. * * @return A CXTPChartRectF object specifying the bounds. */ CXTPChartRectF GetBounds() const; /** * @brief * Call this function to get the hole percentage of the pie chart. * * @return An integer specifying the percentage of hole in the pie chart. */ int GetHolePercent() const; protected: /** * @brief * Call this function to update the bounds of the pie when there is * a change in the start angle and/or sweep angle. */ void UpdateBounds(); /** @cond */ void UpdateBounds(CXTPChartBounds* bounds, CXTPChartEllipse& ellipse); /** @endcond */ protected: CXTPChartEllipse m_ellipse; /**< The ellipse associated with the pie chart.*/ double m_dStartAngle; /**< The start angle of the slice.*/ double m_dSweepAngle; /**< The sweep angle of the slice.*/ double m_depth; /**< The depth of the 3D pie.*/ int m_nHolePercent; /**< The hole percentage.*/ CXTPChartRectF m_anchorBounds; /**< The anchor bounds.*/ }; AFX_INLINE CXTPPoint3d CXTPChartEllipse::GetCenter() const { return m_ptCenter; } AFX_INLINE double CXTPChartPieBase::GetStartAngle() const { return m_dStartAngle; } AFX_INLINE int CXTPChartPieBase::GetHolePercent() const { return m_nHolePercent; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPCHARTPIE_H__) /** @endcond */