/** * @file XTPChartAxisView.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(__XTPCHARTAXISVIEW_H__) # define __XTPCHARTAXISVIEW_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPChartDiagram2DAxisView; class CXTPChartAxisRange; class CXTPChartAxis; class CXTPChartSeriesView; /** * @brief * This class represents a tick mark in the axis. */ class _XTP_EXT_CLASS CXTPChartAxisViewTick { public: double m_dValue; /**< The value of the tick mark.*/ CXTPChartString m_strLabel; /**< The tick mark label.*/ CSize m_szBounds; /**< The boundary.*/ CXTPChartSizeF m_szLabel; /**< The size of the label.*/ }; class _XTP_EXT_CLASS CXTPChartAxisView : public CXTPChartElementView { protected: /** * @brief * Constructs a CXTPChartAxisView object. * * @param pAxis Pointer to a CXTPChartAxis object. * @param pParentView Pointer to a CXTPChartElementView object. */ CXTPChartAxisView(CXTPChartAxis* pAxis, CXTPChartElementView* pParentView); ~CXTPChartAxisView(); public: /** * @brief * Returns the associated axis. */ CXTPChartAxis* GetAxis() const; public: virtual void CreateView(CXTPChartDeviceContext* pDC) = 0; virtual void CalcSize(CXTPChartDeviceContext* pDC, CRect rcDiagram) = 0; virtual void SetBounds(CXTPChartDeviceContext* pDC, CRect rcBounds) = 0; public: /** * @brief * This function returns the spacing of the grid lines. * * @return A double value denoting the grid seperation. */ double GetGridSpacing() const; public: double GetRangeMinValue() const; double GetRangeMaxValue() const; double GetViewRangeMinValue() const; double GetViewRangeMaxValue() const; double GetAxisRangeMinValue() const; double GetAxisRangeMaxValue() const; double ValueToAxis(double dValue) const; double AxisToValue(double dValue) const; public: void AddLegendItems(); protected: /** * @brief * This function calculates the spacing of the grid lines. * * @param nAxisRangeDelta The difference between the min and max value of the range. * @param nScreenDelta The length of the diagram. If width is greater than height, * then nscreenDelta is width and vice versa. * @param nGridSpacingFactor The grid spacing factor. * * @return A double value denoting the grid separation. */ double CalculateGridSpacing(double nAxisRangeDelta, double nScreenDelta, double nGridSpacingFactor); public: CArray m_arrSeries; CXTPChartAxis* m_pAxis; /**< The chart axis.*/ double m_dGridSpacing; /**< The grid spacing.*/ }; /** * @brief * This class abstracts the view of a chart axis and its child items in * a bounding rectangle context. */ class _XTP_EXT_CLASS CXTPChartDiagram2DAxisView : public CXTPChartAxisView { public: /** * @brief * Constructs a CXTPChartDiagram2DAxisView object. * * @param pAxis Pointer to a CXTPChartAxis object. * @param pParentView Pointer to a CXTPChartElementView object. */ CXTPChartDiagram2DAxisView(CXTPChartAxis* pAxis, CXTPChartElementView* pParentView); /** * @brief * Destroys a CXTPChartDiagram2DAxisView object, handles cleanup and deallocation. */ ~CXTPChartDiagram2DAxisView(); public: CRect GetBounds() const; public: /** * @brief * Override this function to create a CXTPChartDeviceCommand object. This object * represents the rendering of an axis in the chart. * * @param pDC Pointer to a CXTPChartDeviceContext object. * * @return Returns a CXTPChartDeviceCommand object. This object handles * the rendering of an element in the chart. Here it handles * the drawing of an axis. */ virtual CXTPChartDeviceCommand* CreateDeviceCommand(CXTPChartDeviceContext* pDC); /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of the grid lines in a chart axis. * * @param pDC Pointer to a CXTPChartDeviceContext object. * @param rcPane The bounding rectange. * * @return Returns a pointer to a CXTPChartDeviceCommand object. This polymorphic object * handles the rendering of an element in the chart. Here it handles the drawing * of the grid lines in a chart axis. */ virtual CXTPChartDeviceCommand* CreateGridLinesDeviceCommand(CXTPChartDeviceContext* pDC, CRect rcPane); /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of the interlaced strips in the chart. * * @param pDC Pointer to a CXTPChartDeviceContext object. * @param rcPane The bounding rectange. * * @return Returns a pointer to a CXTPChartDeviceCommand object. This polymorphic object * handles the rendering of an element in the chart. Here it handles the drawing * of the interlaced strips in the chart. */ virtual CXTPChartDeviceCommand* CreateInterlacedDeviceCommand(CXTPChartDeviceContext* pDC, CRect rcPane); /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of the tick marks in the axis. * * @param pDC Pointer to a CXTPChartDeviceContext object. * * @return Returns a pointer to a CXTPChartDeviceCommand object. This polymorphic object * handles the rendering of an element in the chart. Here it handles the drawing * of the tick marks in the axis. */ virtual CXTPChartDeviceCommand* CreateTickMarksDeviceCommand(CXTPChartDeviceContext* pDC); virtual CXTPChartDeviceCommand* CreateScrollBarDeviceCommand(CXTPChartDeviceContext* pDC); void PerformMouseWheel(short zDelta, CPoint pt); void PerformPaneDragging(int dx, int dy); void OnLButtonDown(UINT nFlags, CPoint point); void OnMouseMove(UINT nFlags, CPoint point); /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of the labels in the axis. * * @param pDC Pointer to a CXTPChartDeviceContext object. * * @return Returns a pointer to a CXTPChartDeviceCommand object. This polymorphic object * handles the rendering of an element in the chart. Here it handles the drawing * of the labels in the axis. */ virtual CXTPChartDeviceCommand* CreateLabelsDeviceCommand(CXTPChartDeviceContext* pDC); /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of the axis title. * * @param pDC Pointer to a CXTPChartDeviceContext object. * * @return Returns a pointer to a CXTPChartDeviceCommand object. This polymorphic object * handles the rendering of an element in the chart. Here it handles the drawing * of the axis title. */ virtual CXTPChartDeviceCommand* CreateTitleDeviceCommand(CXTPChartDeviceContext* pDC); /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of the constant lines perpendicular to an axis. * * @param pDC Pointer to a CXTPChartDeviceContext object. * @param rcPane The bounding rectange. * @param bBehind TRUE for behind * * @return Returns a pointer to a CXTPChartDeviceCommand object. This polymorphic object * handles the rendering of an element in the chart. Here it handles the drawing * of the constant lines perpendicular to an axis. */ virtual CXTPChartDeviceCommand* CreateConstantLinesDeviceCommand(CXTPChartDeviceContext* pDC, CRect rcPane, BOOL bBehind); /** * @brief * This function creates a CXTPChartDeviceCommand object. This object * represents the rendering of the strips parallel to an axis. * * @param pDC Pointer to a CXTPChartDeviceContext object. * @param rcPane The bounding rectange. * * @return Returns a pointer to a CXTPChartDeviceCommand object. This polymorphic object * handles the rendering of an element in the chart. Here it handles the drawing * of the strips parallel to an axis. */ virtual CXTPChartDeviceCommand* CreateStripsDeviceCommand(CXTPChartDeviceContext* pDC, CRect rcPane); /** * @brief * Call this function to create the chart axis view. * * @param pDC The chart device context object. * * @details * This function creates the view of an axis and its constituent elements * (e.g. tick marks, labels, axis title, etc.). */ void CreateView(CXTPChartDeviceContext* pDC); /** * @brief * This function calculates the size of an axis, including its constituent elements * (e.g. tick marks, labels, axis title, etc.). * * @param pDC The chart device context object. * @param rcDiagram The rectangle of the diagram. */ void CalcSize(CXTPChartDeviceContext* pDC, CRect rcDiagram); /** * @brief * This function sets the bounds for the axis. * * @param pDC The chart device context object. * @param rcBounds The bounding rectangle. */ void SetBounds(CXTPChartDeviceContext* pDC, CRect rcBounds); /** * @brief * Call this function to get a point on the axis from a value within the range. * * @param nValue A point within the axis range. * @return Returns a point on the axis from a value within the range */ double ValueToPoint(double nValue) const; double PointToValue(int nPoint) const; /** * @brief * Call this function to get the distance of a point from the axis origin. * * @param nDistance A point within the axis range. * @return Returns distance to the point from axis origin */ double DistanceToPoint(double nDistance) const; double GetScale() const; BOOL IsScollBarVisible() const; /** * @brief * This function returns the size of the axis. * * @return The last computed axis size value. If the axis size value has not been * computed yet, a value of 0 will be returned instead. */ int GetSize() const; /** * @brief * This function checks if the axis is vertical. * * @return A BOOL value. TRUE if the axis is vertical, FALSE if the axis is horizontal. */ BOOL IsVertical() const; protected: /** * @brief * This function creates the axis tick marks. * * @param pDC The device context. * @param rcDiagram The bounding rectangle of the diagram. */ void CreateTickMarks(CXTPChartDeviceContext* pDC, CRect rcDiagram); public: CArray m_arrTicks; /**< The collection of tick marks.*/ CArray m_arrMinorTicks; protected: CRect m_rcBounds; /**< The diagram boundary.*/ int m_nSize; /**< The axis size;*/ CPoint m_ptOldPosition; CXTPChartRectF m_rcScrollBar; CXTPChartRectF m_rcThumb; }; AFX_INLINE CXTPChartAxis* CXTPChartAxisView::GetAxis() const { return m_pAxis; } AFX_INLINE int CXTPChartDiagram2DAxisView::GetSize() const { return m_nSize; } AFX_INLINE CRect CXTPChartDiagram2DAxisView::GetBounds() const { return m_rcBounds; } AFX_INLINE double CXTPChartAxisView::GetGridSpacing() const { return m_dGridSpacing; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPCHARTAXISVIEW_H__) /** @endcond */