/** * @file XTPChart3dPieSeriesLabelsViewDeviceCommand.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(__XTPCHART3DPIESERIESLABELSVIEWDEVICECOMMAND_H__) # define __XTPCHART3DPIESERIESLABELSVIEWDEVICECOMMAND_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPChart3dPieSeriesLabelsView; class CXTPChart3dPieSeriesLabelView; class CXTPChart3dPieSeriesPointView; class CXTPChart3dPieSeriesLabelDeviceCommand; class CXTPChart3dDeviceContext; class CXTPChart3dPieSeriesLabel; /** * @brief * Implements 3D chart pie series label device command. */ class _XTP_EXT_CLASS CXTPChart3dPieSeriesLabelDeviceCommand : public CXTPChart3dDeviceCommand { DECLARE_DYNAMIC(CXTPChart3dPieSeriesLabelDeviceCommand); public: /** * @brief * Constructs a CXTPChart3dPieSeriesLabelDeviceCommand object. * * @param pSeriesLabelView Associated series label view pointer. */ CXTPChart3dPieSeriesLabelDeviceCommand(CXTPChart3dPieSeriesLabelView* pSeriesLabelView); public: /** @cond */ virtual void ExecuteOverride(CXTPChartDeviceContext* pDC); /** @endcond */ /** * @brief * Obtains the label view object pointer. * * @return * Label view object pointer. */ CXTPChart3dPieSeriesLabelView* GetSeriesLabelView() const; /** * @brief * Returns TRUE if the label connector is bent. * * @return * TRUE if the label connector is bent, FALSE otherwise. */ BOOL IsBent() const; /** * @brief * Checks whether the command object is in a failed state. * * @return * TRUE if the command object is in a failed state, FALSE otherwise. * * @see * SetFailed */ BOOL IsFailed() const; /** * @brief * Sets the command object to a failed state. */ void SetFailed(); /** * @brief * Obtains the label rectangle. * * @return * Label rectangle. * * @see * SetLabelRect */ CRect GetLabelRect() const; /** * @brief * Sets the label rectangle. * * @param rcLabel Label rectangle. * * @see * GetLabelRect */ void SetLabelRect(CRect rcLabel); /** * @brief * Computes the connector vector. * * @param pDC Target device context pointer. * * @return * TRUE if the vector is successfully computed, FALSE otherwise. */ BOOL ComputeConnectorVector(CXTPChart3dDeviceContext* pDC); /** * @brief * Computes the connector bend. * * @param pDC Target device context pointer. * @param rcBoundaries Size of boundries. * * @return * TRUE if the bend is successfully computed, FALSE otherwise. */ BOOL ComputeConnectorBend(CXTPChart3dDeviceContext* pDC, CRect rcBoundaries); /** * @brief * Computes label. * * @param pDC Target device context pointer. */ void ComputeLabel(CXTPChart3dDeviceContext* pDC); /** * @brief * Determines the connector length factor value. * * @return * Connector length factor value. * * @see * SetConnectorLengthFactor */ double GetConnectorLengthFactor() const; /** * @brief * Sets the connector length factor value. * * @param dFactor New connector length factor value. * * @see * GetConnectorLengthFactor */ void SetConnectorLengthFactor(double dFactor); /** * @brief * Determines the connector endpoint vertical offset value. * * @return * Connector endpoint vertical offset value. * * @see * SetConnectorEndpointVerticalOffset */ double GetConnectorEndpointVerticalOffset() const; /** * @brief * Sets the connector endpoint vertical offset value. * * @param yOffset New connector endpoint vertical offset value. * * @see * GetConnectorEndpointVerticalOffset */ void SetConnectorEndpointVerticalOffset(double yOffset); /** * @brief * Sets the column anchor vertical position value. * * @param pDC Target device context. * @param y New column anchor vertical position value. * * @return * TRUE if the new value is successfully computed and applied, FALSE otherwise. */ BOOL SetColumnAnchorVerticalPosition(CXTPChart3dDeviceContext* pDC, int y); private: BOOL ComputeConnectorStartPoint(CXTPChart3dDeviceContext* pDC, CXTPPoint3d& ptStart, CPoint& ptProjected) const; CXTPPoint3d ComputeConnectorBendPoint() const; CXTPPoint3d ComputeConnectorEndPoint() const; CXTPPoint3d ComputeConnectorVectorEndPoint(const CXTPPoint3d& point) const; void ComputeLabel_TwoColumn(const CSize& szLabel, const CPoint& ptAnchor); void ComputeLabel_Outside(const CSize& szLabel, const CPoint& ptAnchorOrigin, const CPoint& ptAnchor); void ComputeLabel_InsideAndRadial(const CSize& szLabel, const CPoint& ptAnchor); protected: CXTPChart3dPieSeriesLabelView* m_pSeriesLabelView; CXTPChart3dPieSeriesPointView* m_pPointView; CRect m_rcLabel; BOOL m_bFailed; double m_dConnectorLengthFactor; double m_dConnectorEndpointVerticalOffset; }; AFX_INLINE BOOL CXTPChart3dPieSeriesLabelDeviceCommand::IsFailed() const { return m_bFailed; } AFX_INLINE void CXTPChart3dPieSeriesLabelDeviceCommand::SetFailed() { m_bFailed = TRUE; } AFX_INLINE CXTPChart3dPieSeriesLabelView* CXTPChart3dPieSeriesLabelDeviceCommand::GetSeriesLabelView() const { return m_pSeriesLabelView; } AFX_INLINE CRect CXTPChart3dPieSeriesLabelDeviceCommand::GetLabelRect() const { return m_rcLabel; } AFX_INLINE void CXTPChart3dPieSeriesLabelDeviceCommand::SetLabelRect(CRect rcLabel) { m_rcLabel = rcLabel; } AFX_INLINE double CXTPChart3dPieSeriesLabelDeviceCommand::GetConnectorLengthFactor() const { return m_dConnectorLengthFactor; } AFX_INLINE void CXTPChart3dPieSeriesLabelDeviceCommand::SetConnectorLengthFactor(double dFactor) { m_dConnectorLengthFactor = dFactor; } AFX_INLINE double CXTPChart3dPieSeriesLabelDeviceCommand::GetConnectorEndpointVerticalOffset() const { return m_dConnectorEndpointVerticalOffset; } AFX_INLINE void CXTPChart3dPieSeriesLabelDeviceCommand::SetConnectorEndpointVerticalOffset(double yOffset) { m_dConnectorEndpointVerticalOffset = yOffset; } /** * @brief * Represents device command for all pie series labels view. */ class _XTP_EXT_CLASS CXTPChart3dPieSeriesLabelsViewDeviceCommand : public CXTPChart3dDeviceCommand , private CXTPChartDeviceCommandEvents { public: /** * @brief * Constructs a command object instance. * * @param pSeriesLabelsView View pointer. */ CXTPChart3dPieSeriesLabelsViewDeviceCommand(CXTPChart3dPieSeriesLabelsView* pSeriesLabelsView); public: /** * @brief * Override this function to write the drawing code for specific objects. * * @param pDC A pointer to the chart device context. */ virtual void ExecuteOverride(CXTPChartDeviceContext* pDC); private: CXTPChart3dPieSeriesLabel* GetLabel() const; void ComputeLabelConnectorVectors(CXTPChart3dDeviceContext* pDC, BOOL& bNeedComputeBends); BOOL ComputeBendBoundaries(CXTPChart3dDeviceContext* pDC, CRect& rcBounaries); void ComputeLabelConnectorBends(CXTPChart3dDeviceContext* pDC, CRect rcBoundaries); void ComputeLabels(CXTPChart3dDeviceContext* pDC); BOOL ResolveLabelOverlaps(CXTPChart3dDeviceContext* pDC, const CRect& rcBoundaries); BOOL ResolveLabelOverlaps_ChangePositionInColumn(CXTPChart3dDeviceContext* pDC, BOOL bLeftDirected, const CRect& rcBoundaries); BOOL ResolveLabelOverlaps_ChangeConnectorLength(CXTPChart3dDeviceContext* pDC); CXTPChart3dPieSeriesLabelDeviceCommand* FindLabelDeviceCommand(CXTPChartDeviceCommand* pCommand) const; private: virtual void OnAfterExecute(CXTPChartDeviceCommand* pCommand, CXTPChartDeviceContext* pDC); struct CommandCallbackData { enum State { None, ComputeVector, ComputeBend, ComputeBendConnector, ColumnAnchorVericalPosition }; CommandCallbackData(State state = None); void SwitchTo(State state); State GetState() const; BOOL bSuccess; /**< for all*/ CXTPChart3dDeviceContext* pDC; /**< for ComputeVector, ComputeBend, ComputeBendConnector, ColumnAnchorVericalPosition*/ CXTPChart3dPieSeriesLabelDeviceCommand* pLabelCommand; /**< for ComputeVector, ComputeBendConnector*/ const CXTPPoint3d* ptBend; /**< for ComputeBend*/ LPRECT prcBoundaries; /**< for ComputeBend, ComputeBendConnector*/ int nNewYPos; /**< for ColumnAnchorVericalPosition*/ private: State state; }; CommandCallbackData m_CommandCallbackData; protected: CXTPChart3dPieSeriesLabelsView* m_pSeriesLabelsView; /**< View pointer*/ }; AFX_INLINE void CXTPChart3dPieSeriesLabelsViewDeviceCommand::CommandCallbackData::SwitchTo(State newState) { *this = CommandCallbackData(newState); } AFX_INLINE CXTPChart3dPieSeriesLabelsViewDeviceCommand::CommandCallbackData::State CXTPChart3dPieSeriesLabelsViewDeviceCommand::CommandCallbackData::GetState() const { return state; } AFX_INLINE CXTPChart3dPieSeriesLabelsViewDeviceCommand::CommandCallbackData::CommandCallbackData( State state) : bSuccess(FALSE) , pDC(NULL) , pLabelCommand(NULL) , ptBend(NULL) , prcBoundaries(NULL) , state(state) { } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPCHART3DPIESERIESLABELSVIEWDEVICECOMMAND_H__) /** @endcond */