/** * @file XTPChartSeriesPoint.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(__XTPCHARTSERIESPOINT_H__) # define __XTPCHARTSERIESPOINT_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPChartSeries; class CXTPChartSeriesView; class CXTPChartSeriesPointCollection; /** * @brief * CXTPChartSeriesPoint is a kind of CXTPChartElement. This class * represents chart series point. */ class _XTP_EXT_CLASS CXTPChartSeriesPoint : public CXTPChartElement { DECLARE_DYNAMIC(CXTPChartSeriesPoint); public: /** * @brief * Default constructor, makes a CXTPChartSeriesPoint object. */ CXTPChartSeriesPoint(); /** * @brief * Overloaded constructor makes a CXTPChartSeriesPoint object. * * @param strArgument CXTPChartString denoting the argument. * @param dValue A double value for the point. */ CXTPChartSeriesPoint(const CXTPChartString& strArgument, double dValue); /** * @brief * Constructor makes a CXTPChartSeriesPoint object from the parameters. * * @param dArgument A double value denoting the argument. * @param dValue A double value for the point. */ CXTPChartSeriesPoint(double dArgument, double dValue); /** * @brief * Constructor overload which makes a CXTPChartSeriesPoint object from * an argument and a pair of values. * * @param dArgument Double value denoting the argument. * @param dValue1 First value for the point. * @param dValue2 Second value for the point. */ CXTPChartSeriesPoint(double dArgument, double dValue1, double dValue2); /** * @brief * Constructor overload which makes a CXTPChartSeriesPoint object from * an argument and a pair of values. * * @param strArgument CXTPChartString denoting the argument. * @param dValue1 First value for the point. * @param dValue2 Second value for the point. */ CXTPChartSeriesPoint(const CXTPChartString& strArgument, double dValue1, double dValue2); /** * @brief * Constructor overload which makes a CXTPChartSeriesPoint object from * an argument and four values. * * @param strArgument String value denoting the argument. * @param dValue1 Double value for the point. * @param dValue2 Second value for the point. * @param dValue3 Third value for the point. * @param dValue4 Fourth value for the point. */ CXTPChartSeriesPoint(const CXTPChartString& strArgument, double dValue1, double dValue2, double dValue3, double dValue4); /** * @brief * Constructor overload which makes a CXTPChartSeriesPoint object from * an argument and four values. * * @param dArgument Double value denoting the argument. * @param dValue1 Double value for the point. * @param dValue2 Second value for the point. * @param dValue3 Third value for the point. * @param dValue4 Fourth value for the point. */ CXTPChartSeriesPoint(double dArgument, double dValue1, double dValue2, double dValue3, double dValue4); /** * @brief * Destroys a CXTPChartSeriesPoint object, handles cleanup. */ virtual ~CXTPChartSeriesPoint(); public: /** * @brief * Gets the value at a specified index. * * @param nIndex Zero-based index. * * @return * The double value at the specified index. */ double GetValue(int nIndex) const; /** * @brief * Sets the value at a specified index. * * @param nIndex Zero-based index. * @param dValue Double value to be set. */ void SetValue(int nIndex, double dValue); CXTPChartColor GetColor() const; void SetColor(const CXTPChartColor& clr); /** * @brief * This function returns the string argument of a point. * * @return * A CXTPChartString value argument of the point. */ CXTPChartString GetArgument() const; /** * @brief * Gets the double value of the argument of a point. * * @return * A double value argument of the point. */ double GetArgumentValue() const; /** * @brief * Sets the double value of the argument of a point. * * @param dArgument Double value to be set. */ void SetArgumentValue(double dArgument); /** * @brief * Gets the double value of the string argument of a point. * * @return * A double value corresponding to the string argument of the point. */ double GetInternalArgumentValue() const; /** * @brief * Sets the double value of the string argument of a point. * * @param dInternalArgument Double value to be set. */ void SetInternalArgumentValue(double dInternalArgument); /** * @brief * This function returns the palette index used. * * @return * An int value corresponding to the chosen palette index. */ int GetPaletteIndex() const; /** * @brief * This function returns the previous point in the series. * * @return * A CXTPChartSeriesPoint pointer corresponding to the previous point * in the series. */ CXTPChartSeriesPoint* GetPreviousPoint() const; /** * @brief * This function returns the next point in the series. * * @return * A CXTPChartSeriesPoint pointer corresponding to the next point * in the series. */ CXTPChartSeriesPoint* GetNextPoint() const; /** * @brief * Sets new point legend text. * * @param lpszLegendText New legend text pointer. * * @see * GetLegendText */ void SetLegendText(LPCTSTR lpszLegendText); /** @cond */ _XTP_DEPRECATED_IN_FAVOR(SetLegendText) void SetLegentText(LPCTSTR lpszLegendText) { SetLegendText(lpszLegendText); } /** @endcond */ /** * @brief * Obtains current point legend text. * * @return * Current point legent text. * * @see * SetLegendText */ CXTPChartString GetLegendText() const; /** * @brief * Gets the current value length in characters. * * @return * Number of characters of the current value. */ int GetValueLength() const; /** * @brief * Sets the current value length in characters. * * @param nLength New length of the value. */ void SetValueLength(int nLength); CXTPChartSeries* GetSeries() const; /** * @brief * Call this member to set the tooltip of the action. * * @param lpszTooltip Tooltip to be set. * * @see * SetCaption, SetDescription, SetPrompt */ void SetTooltipText(LPCTSTR lpszTooltip); /** * @brief * Call this member to get the action's tooltip. * * @return * Tooltip of the control. */ CXTPChartString GetTooltipText() const; /** * @brief * Sets point label text. * * @param lpszLabelText Label text pointer. */ void SetLabelText(LPCTSTR lpszLabelText); /** * @brief * Gets point label text. * * @return * Current label text string. */ CXTPChartString GetLabelText() const; public: virtual void DoPropExchange(CXTPPropExchange* pPX); protected: /** * @brief * This function handles so internal, argument type conversions. */ void CommonConstruct(); protected: CXTPChartString m_strArgument; /**< String argument.*/ double m_dArgument; /**< Double value of argument.*/ double m_dValues[4]; /**< The array of values.*/ int m_nLength; /**< The size of the array, m_dValues.*/ double m_dInternalArgument; /**< The double value of the string argument.*/ int m_nPaletteIndex; /**< The chosen palette index.*/ int m_nIndex; /**< Number of elements present in the array m_dValues.*/ CXTPChartString m_strLegentText; /**< Text to show in legend*/ CXTPChartString m_strTooltipText; CXTPChartString m_strLabelText; CXTPChartColor m_clrPoint; public: BOOL m_bSpecial; # ifdef _XTP_ACTIVEX public: /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPChartSeriesPoint); afx_msg LPDISPATCH OleGetPreviousPoint(); afx_msg LPDISPATCH OleGetNextPoint(); afx_msg void OleSetArgumentValue(double dNewValue); afx_msg void OleSetArgumentString(LPCTSTR lpszText); afx_msg BSTR OleGetArgumentString(); afx_msg void OleSetSpecial(BOOL bSpecial); afx_msg BOOL OleGetSpecial(); afx_msg BSTR OleGetLegendText(); afx_msg void OleSetLegendText(LPCTSTR lpszText); afx_msg BSTR OleGetLabelText(); afx_msg void OleSetLabelText(LPCTSTR lpszText); afx_msg OLE_COLOR OleGetColor(); afx_msg void OleSetColor(OLE_COLOR clr); /** @endcond */ # endif protected: friend class CXTPChartSeriesPointCollection; friend class CXTPChartContent; friend class CXTPChartSeriesVirtualPointCollection; friend class CXTPChartSeriesTrendlinePointCollection; }; /** * @brief * CXTPChartSeriesPointCollection class represents a collection of chart * series points. */ class _XTP_EXT_CLASS CXTPChartSeriesPointCollection : public CXTPChartElementCollection { /** @cond */ DECLARE_DYNAMIC(CXTPChartSeriesPointCollection) /** @endcond */ public: /** * @brief * Constructs CXTPChartSeriesPointCollection object. */ CXTPChartSeriesPointCollection(); /** * @brief * Destroys a CXTPChartSeriesPointCollection object, handles cleanup. */ virtual ~CXTPChartSeriesPointCollection(); public: /** * @brief * This function adds a point represented by the class CXTPChartSeriesPoint * to the internal array of points. * * @param pPoint The pointer to a CXTPChartSeriesPoint object. * * @return * The pointer to the CXTPChartSeriesPoint object, which is added to the object array. */ CXTPChartSeriesPoint* Add(CXTPChartSeriesPoint* pPoint); /** * @brief * Call this function to get the pointer to the CXTPChartSeriesPoint object * at a particular index. * * @param nIndex The zero-based index. * * @return * The pointer to the CXTPChartSeriesPoint object, which stays at the index nIndex. */ virtual CXTPChartSeriesPoint* GetAt(int nIndex) const; /** * @brief * Call this method to add a batch of points. * * @param nCount Number of points to add. * * @details * This method is an optimized way to add a large number of points; * memory will be allocated once for all of them. */ void AddPoints(int nCount); /** * @brief * Call this method to get the arithmetic mean of the point collection. * * @param nValue Index of the value. * * @return * The arithmetic mean of the series collection. */ virtual double GetArithmeticMean(int nValue) const; /** * @brief * Call this method to get the variance of the point collection. * * @param nValue Index of the value. * * @return * The variance of the series collection. */ virtual double GetVariance(int nValue) const; /** * @brief * Call this method to get the standard deviation of the point collection. * * @param nValue Index of the value. * * @return * The standard deviation of the series collection. */ virtual double GetStandardDeviation(int nValue) const; /** * @brief * Call this method to get the moving average of the point collection. * * @param nValue Index of the value. * @param nFrom Index of the point. * @param nTo Index of the point. * * @return * The moving average of the series collection. */ virtual double GetMovingAverage(int nValue, int nFrom, int nTo) const; /** * @brief * Call this method to get the minimum of the point collection. * @param nValue Index of the value. * @return Returns minimum */ virtual double GetMinimum(int nValue) const; /** * @brief * Call this method to get the maximum of the point collection. * @param nValue Index of the value. * @return Returns maximum */ virtual double GetMaximum(int nValue) const; virtual void GetSlopeQualitative(int nValue, double& dSlope, double& dIntercept) const; virtual void GetSlopeNumerical(int nValue, double& dSlope, double& dIntercept) const; public: virtual void DoPropExchange(CXTPPropExchange* pPX); protected: # ifdef _XTP_ACTIVEX public: /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPChartSeriesPointCollection); afx_msg long OleGetItemCount(); afx_msg LPDISPATCH OleGetItem(long nIndex); DECLARE_ENUM_VARIANT(CXTPChartSeriesPointCollection) afx_msg LPDISPATCH OleAdd(const VARIANT& varArgument, const VARIANT& varValue); afx_msg LPDISPATCH OleAdd4(const VARIANT& varArgument, double varValue1, double varValue2, double varValue3, double varValue4); afx_msg LPDISPATCH OleAdd2(const VARIANT& varArgument, double varValue1, double varValue2); /** @endcond */ # endif friend class CXTPChartSeries; }; ////////////////////////////////////////////////////////////////////////// // CXTPChartSeriesVirtualPointCollection class _XTP_EXT_CLASS CXTPChartSeriesVirtualPointCollection : public CXTPChartSeriesPointCollection { DECLARE_DYNAMIC(CXTPChartSeriesVirtualPointCollection); typedef double(CALLBACK* GETPOINTVALUEPTR)(CXTPChartSeries* pSeries, double x); public: CXTPChartSeriesVirtualPointCollection(double dMinRange, double dMaxRange, double dStep, GETPOINTVALUEPTR pCallbackPtr); virtual ~CXTPChartSeriesVirtualPointCollection(); public: virtual CXTPChartSeriesPoint* GetAt(int nIndex) const; virtual int GetCount() const; protected: double m_dMinRange; double m_dMaxRange; double m_dStep; int m_nCount; CXTPChartSeriesPoint* m_pVirtualPoint; GETPOINTVALUEPTR m_pCallbackPtr; }; AFX_INLINE CXTPChartSeriesPoint* CXTPChartSeriesPointCollection::GetAt(int nIndex) const { return nIndex >= 0 && nIndex < m_arrElements.GetSize() ? (CXTPChartSeriesPoint*)m_arrElements.GetAt(nIndex) : NULL; } AFX_INLINE CXTPChartString CXTPChartSeriesPoint::GetArgument() const { return m_strArgument; } AFX_INLINE double CXTPChartSeriesPoint::GetArgumentValue() const { return m_dArgument; } AFX_INLINE double CXTPChartSeriesPoint::GetInternalArgumentValue() const { return m_dInternalArgument; } AFX_INLINE void CXTPChartSeriesPoint::SetInternalArgumentValue(double dInternalArgument) { m_dInternalArgument = dInternalArgument; } AFX_INLINE int CXTPChartSeriesPoint::GetPaletteIndex() const { return m_nPaletteIndex; } AFX_INLINE void CXTPChartSeriesPoint::SetLegendText(LPCTSTR lpszLegendText) { m_strLegentText = lpszLegendText; OnChartChanged(); } AFX_INLINE CXTPChartString CXTPChartSeriesPoint::GetLegendText() const { return m_strLegentText; } AFX_INLINE int CXTPChartSeriesPoint::GetValueLength() const { return m_nLength; } AFX_INLINE void CXTPChartSeriesPoint::SetValueLength(int nLength) { m_nLength = nLength; } AFX_INLINE CXTPChartColor CXTPChartSeriesPoint::GetColor() const { return m_clrPoint; } AFX_INLINE void CXTPChartSeriesPoint::SetColor(const CXTPChartColor& clr) { m_clrPoint = clr; OnChartChanged(); } AFX_INLINE CXTPChartString CXTPChartSeriesPoint::GetTooltipText() const { return m_strTooltipText; } AFX_INLINE void CXTPChartSeriesPoint::SetTooltipText(LPCTSTR lpszTooltip) { m_strTooltipText = lpszTooltip; } AFX_INLINE CXTPChartString CXTPChartSeriesPoint::GetLabelText() const { return m_strLabelText; } AFX_INLINE void CXTPChartSeriesPoint::SetLabelText(LPCTSTR lpszLabelText) { m_strLabelText = lpszLabelText; OnChartChanged(); } AFX_INLINE void CXTPChartSeriesPoint::SetArgumentValue(double dArgument) { m_dArgument = dArgument; OnChartChanged(); } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPCHARTSERIESPOINT_H__) /** @endcond */