/** * @file XTPChartTypes.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(__XTPCHARTTYPES_H__) # define __XTPCHARTTYPES_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPPropExchange; typedef CXTPPoint2f CXTPChartPointF, CXTPChartPoint2dF; typedef CXTPPoint3f CXTPChartPoint3dF; typedef CXTPSizeF CXTPChartSizeF; typedef CXTPRectF CXTPChartRectF; typedef CArray CXTPChartPoints, CXTPChartPoints2d; typedef CArray CXTPChartPoints3d; typedef CArray CXTPChartLineDashArray; typedef CString CXTPChartString; /** * @brief * This class abstracts a color entity. This object consists of an ARGB * value which represents a color. */ class _XTP_EXT_CLASS CXTPChartColor { public: typedef DWORD ARGB; public: /** * @brief * Default constructor, creates a CXTPChartColor object and initializes * the values. */ CXTPChartColor() { Argb = CXTPChartColor::Empty; } /** * @brief * Overloaded constructor, creates an opaque color object from the * specified Red, Green, Blue values. * * @param r Red value. * @param g Green value. * @param b Blue value. * * @details * The alpha channel value is set to 255. Hence the color is 100% opaque. * Color values are not premultiplied. */ CXTPChartColor(BYTE r, BYTE g, BYTE b) { Argb = MakeARGB(255, r, g, b); } /** * @brief * Overloaded constructor, creates a color object from the specified * Red, Green, Blue values. * * @param r Red value. * @param g Green value. * @param b Blue value. * @param a Aplha value. * * @details * Color values are not premultiplied. */ CXTPChartColor(BYTE a, BYTE r, BYTE g, BYTE b) { Argb = MakeARGB(a, r, g, b); } /** * @brief * Overloaded constructor, creates a color object from the specified * premultiplied ARGB values. * * @param argb The ARGB value. */ CXTPChartColor(ARGB argb) { Argb = argb; } /** * @brief * Call this function to get the alpha channel value of the color. * * @return A BYTE value specifying the alpha value. The range is from * 0 to 255. */ BYTE GetAlpha() const { return (BYTE)(Argb >> AlphaShift); } /** * @brief * Call this function to get the alpha channel value of the color. * * @return A BYTE value specifying the alpha value. The range is from * 0 to 255. */ BYTE GetA() const { return GetAlpha(); } /** * @brief * Call this function to get the RED channel value of the color. * * @return A BYTE value specifying the RED value. The range is from * 0 to 255. */ BYTE GetRed() const { return (BYTE)(Argb >> RedShift); } /** * @brief * Call this function to get the RED channel value of the color. * * @return A BYTE value specifying the RED value. The range is from * 0 to 255. */ BYTE GetR() const { return GetRed(); } /** * @brief * Call this function to get the GREEN channel value of the color. * * @return A BYTE value specifying the GREEN value. The range is from * 0 to 255. */ BYTE GetGreen() const { return (BYTE)(Argb >> GreenShift); } /** * @brief * Call this function to get the GREEN channel value of the color. * * @return A BYTE value specifying the GREEN value. The range is from * 0 to 255. */ BYTE GetG() const { return GetGreen(); } /** * @brief * Call this function to get the BLUE channel value of the color. * * @return A BYTE value specifying the BLUE value. The range is from * 0 to 255. */ BYTE GetBlue() const { return (BYTE)(Argb >> BlueShift); } /** * @brief * Call this function to get the BLUE channel value of the color. * * @return A BYTE value specifying the BLUE value. The range is from * 0 to 255. */ BYTE GetB() const { return GetBlue(); } /** * @brief * Clamps alpha color component to range 0..1. * * @return Alpha component value clamped to range 0..1. */ float ClampA() const { return static_cast(GetA()) / 255; } /** * @brief * Clamps red color component to range 0..1. * * @return Red component value clamped to range 0..1. */ float ClampR() const { return static_cast(GetR()) / 255; } /** * @brief * Clamps green color component to range 0..1. * * @return Green component value clamped to range 0..1. */ float ClampG() const { return static_cast(GetG()) / 255; } /** * @brief * Clamps blue color component to range 0..1. * * @return Blue component value clamped to range 0..1. */ float ClampB() const { return static_cast(GetB()) / 255; } /** * @brief * Call this function to get the ARGB value of the color object. * * @return An ARGB value specifying the color. */ ARGB GetValue() const { return Argb; } /** * @brief * Call this function to set the ARGB value of the color object. * * @param argb An ARGB value specifying the color. * @return void */ VOID SetValue(ARGB argb) { Argb = argb; } /** * @brief * Call this function to set the opaque color value from a COLORREF value. * * @param rgb A RGB value specifying the color. * * @details * The alpha channel value is set to 255. Hence the color is 100% opaque. * @return void */ VOID SetFromCOLORREF(COLORREF rgb) { Argb = MakeARGB(255, GetRValue(rgb), GetGValue(rgb), GetBValue(rgb)); } /** * @brief * Call this function to set the color value from a string value. * * @param lpsz The string contains the color values in a specified format. * * @details * The format should be "100,100,100,100" for ARGB values * or "100,100,100" for opaque color values */ void SetFromString(LPCTSTR lpsz); /** * @brief * Call this function to convert the object to a COLORREF value. * * @return An ARGB value specifying the color. */ COLORREF ToCOLORREF() const { return RGB(GetRed(), GetGreen(), GetBlue()); } /** * @brief * Call this function to check whether the color object is empty. * * @return A BOOL value. TRUE if the object is empty, FALSE otherwise. */ BOOL IsEmpty() const { return Argb == Empty; } /** * @brief * Obtains a "darker" color for the current color. * * @return A "darker" color value. */ CXTPChartColor GetDarkColor() const; public: // Common color constants const static ARGB AliceBlue; const static ARGB AntiqueWhite; const static ARGB Aqua; const static ARGB Aquamarine; const static ARGB Azure; const static ARGB Beige; const static ARGB Bisque; const static ARGB Black; const static ARGB BlanchedAlmond; const static ARGB Blue; const static ARGB BlueViolet; const static ARGB Brown; const static ARGB BurlyWood; const static ARGB CadetBlue; const static ARGB Chartreuse; const static ARGB Chocolate; const static ARGB Coral; const static ARGB CornflowerBlue; const static ARGB Cornsilk; const static ARGB Crimson; const static ARGB Cyan; const static ARGB DarkBlue; const static ARGB DarkCyan; const static ARGB DarkGoldenrod; const static ARGB DarkGray; const static ARGB DarkGreen; const static ARGB DarkKhaki; const static ARGB DarkMagenta; const static ARGB DarkOliveGreen; const static ARGB DarkOrange; const static ARGB DarkOrchid; const static ARGB DarkRed; const static ARGB DarkSalmon; const static ARGB DarkSeaGreen; const static ARGB DarkSlateBlue; const static ARGB DarkSlateGray; const static ARGB DarkTurquoise; const static ARGB DarkViolet; const static ARGB DeepPink; const static ARGB DeepSkyBlue; const static ARGB DimGray; const static ARGB DodgerBlue; const static ARGB Firebrick; const static ARGB FloralWhite; const static ARGB ForestGreen; const static ARGB Fuchsia; const static ARGB Gainsboro; const static ARGB GhostWhite; const static ARGB Gold; const static ARGB Goldenrod; const static ARGB Gray; const static ARGB Green; const static ARGB GreenYellow; const static ARGB Honeydew; const static ARGB HotPink; const static ARGB IndianRed; const static ARGB Indigo; const static ARGB Ivory; const static ARGB Khaki; const static ARGB Lavender; const static ARGB LavenderBlush; const static ARGB LawnGreen; const static ARGB LemonChiffon; const static ARGB LightBlue; const static ARGB LightCoral; const static ARGB LightCyan; const static ARGB LightGoldenrodYellow; const static ARGB LightGray; const static ARGB LightGreen; const static ARGB LightPink; const static ARGB LightSalmon; const static ARGB LightSeaGreen; const static ARGB LightSkyBlue; const static ARGB LightSlateGray; const static ARGB LightSteelBlue; const static ARGB LightYellow; const static ARGB Lime; const static ARGB LimeGreen; const static ARGB Linen; const static ARGB Magenta; const static ARGB Maroon; const static ARGB MediumAquamarine; const static ARGB MediumBlue; const static ARGB MediumOrchid; const static ARGB MediumPurple; const static ARGB MediumSeaGreen; const static ARGB MediumSlateBlue; const static ARGB MediumSpringGreen; const static ARGB MediumTurquoise; const static ARGB MediumVioletRed; const static ARGB MidnightBlue; const static ARGB MintCream; const static ARGB MistyRose; const static ARGB Moccas; const static ARGB NavajoWhite; const static ARGB Navy; const static ARGB OldLace; const static ARGB Olive; const static ARGB OliveDrab; const static ARGB Orange; const static ARGB OrangeRed; const static ARGB Orchid; const static ARGB PaleGoldenrod; const static ARGB PaleGreen; const static ARGB PaleTurquoise; const static ARGB PaleVioletRed; const static ARGB PapayaWhip; const static ARGB PeachPuff; const static ARGB Peru; const static ARGB Pink; const static ARGB Plum; const static ARGB PowderBlue; const static ARGB Purple; const static ARGB Red; const static ARGB RosyBrown; const static ARGB RoyalBlue; const static ARGB SaddleBrown; const static ARGB Salmon; const static ARGB SandyBrown; const static ARGB SeaGreen; const static ARGB SeaShell; const static ARGB Sienna; const static ARGB Silver; const static ARGB SkyBlue; const static ARGB SlateBlue; const static ARGB SlateGray; const static ARGB Snow; const static ARGB SpringGreen; const static ARGB SteelBlue; const static ARGB Tan; const static ARGB Teal; const static ARGB Thistle; const static ARGB Tomato; const static ARGB Transparent; const static ARGB Turquoise; const static ARGB Violet; const static ARGB Wheat; const static ARGB White; const static ARGB WhiteSmoke; const static ARGB Yellow; const static ARGB YellowGreen; const static ARGB Empty; /** * @brief * Enumeration for shift count of A, R, G, B components. */ enum { AlphaShift = 24, /**< Alpha component bit offset */ RedShift = 16, /**< Red component bit offset */ GreenShift = 8, /**< Green component bit offset */ BlueShift = 0 /**< Blue component bit offset */ }; /** * @brief * Enumeration for bit mask of A, R, G, B components. */ enum { AlphaMask = 0xff000000, /**< Alpha component bit mask */ RedMask = 0x00ff0000, /**< Red component bit mask */ GreenMask = 0x0000ff00, /**< Green component bit mask */ BlueMask = 0x000000ff /**< Blue component bit mask */ }; // Assemble A, R, G, B values into a 32-bit integer /** * @brief * Call this static function to assemble A, R, G, B values into a 32-bit * integer ARGB value. * * @param a The Alpha value. * @param r The Red value * @param g The Green value * @param b The Blue value * * @return A 32 bit ARGB value. */ static ARGB AFX_CDECL MakeARGB(BYTE a, BYTE r, BYTE g, BYTE b) { return (((ARGB)(b) << BlueShift) | ((ARGB)(g) << GreenShift) | ((ARGB)(r) << RedShift) | ((ARGB)(a) << AlphaShift)); } protected: ARGB Argb; /**< The 32 bit color value.*/ # ifdef _XTP_ACTIVEX /** @cond */ public: OLE_COLOR ToOleColor(); static CXTPChartColor AFX_CDECL FromOleColor(OLE_COLOR); /** @endcond */ # endif }; /** * @brief * This class abstracts a font entity. */ class _XTP_EXT_CLASS CXTPChartFont : public CXTPCmdTarget { public: /** * @brief * Default constructor, creates a CXTPChartFont object and initializes * the values. */ CXTPChartFont(); /** * @brief * Overloaded constructor, creates a font object from the LOGFONT structure. * * @param pLogFont A pointer to the LOGFONT structure. */ CXTPChartFont(LOGFONT* pLogFont); /** * @brief * Destructor, does the cleaning. */ virtual ~CXTPChartFont(); public: /** * @brief * Call this function to set the LOGFONT for this object. * * @param lf A pointer to the LOGFONT structure. */ void SetLogFont(LOGFONT* lf); public: /** * @brief * Call this static function to get Tahoma font with size 18. * * @return A pointer to the CXTPChartFont object. * * @details * This function creates a new CXTPChartFont and set the underlying font to * Tahoma with size 18. */ static CXTPChartFont* AFX_CDECL GetTahoma18(); /** * @brief * Call this static function to get Tahoma font with size 12. * * @return A pointer to the CXTPChartFont object. * * @details * This function creates a new CXTPChartFont and set the underlying font to * Tahoma with size 12. */ static CXTPChartFont* AFX_CDECL GetTahoma12(); /** * @brief * Call this static function to get Tahoma font with size 8. * * @return A pointer to the CXTPChartFont object. * * @details * This function creates a new CXTPChartFont and set the underlying font to * Tahoma with size 8. */ static CXTPChartFont* AFX_CDECL GetTahoma8(); /** * @brief * Call this function to do the cleanup. */ void Release(); # ifdef _XTP_ACTIVEX public: /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPChartFont); afx_msg void OleSetFont(LPFONTDISP pFontDisp); afx_msg LPFONTDISP OleGetFont(); /** @endcond */ # endif public: LOGFONT m_lf; /**< The LOGFONT variable.*/ }; /** * @brief * Represents a 3D rotation primitive for chart objects using * Euler angles Yaw, Pitch and Roll in degrees. */ class _XTP_EXT_CLASS CXTPChart3dRotation # ifdef _XTP_ACTIVEX : public CXTPCmdTarget # endif { # ifdef _XTP_ACTIVEX DECLARE_SERIAL(CXTPChart3dRotation) # endif public: /** * @brief * Constructs a rotation object with no rotation by default. */ CXTPChart3dRotation(); /** * @brief * Constructs a rotation object with no rotation by default. * * @param rhs Right-hand-side rotation object to copy data from. */ CXTPChart3dRotation(const CXTPChart3dRotation& rhs); /** * @brief * Constructs a rotation object with the provided rotation parameters. * * @param dYaw Yaw angle value in degrees. * @param dPitch Pitch angle value in degrees. * @param dRoll Roll angle value in degrees. */ CXTPChart3dRotation(double dYaw, double dPitch, double dRoll); /** * @brief * Checks if any rotation is applied. * * @return A BOOL value. TRUE if any rotation is applied, FALSE otherwise. */ BOOL IsRotated() const; /** * @brief * Reads rotation angle value from a string provided. * The values are expected to be comma-separated, floating point * values in the following order: "yaw, pitch, roll" * @param pString A string value in "yaw, pitch, roll" format to parse. */ void SetFromString(LPCTSTR pString); /** * @brief * Overloads default assignment operator. Assigns rotation components only. * @param rhs Right-hand-side rotation object to copy data from. * @return Self reference */ CXTPChart3dRotation& operator=(const CXTPChart3dRotation& rhs); double m_dYaw; /**< Yaw angle value in degrees*/ double m_dPitch; /**< Pitch angle value in degrees*/ double m_dRoll; /**< Roll angle value in degrees*/ # ifdef _XTP_ACTIVEX public: /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPChart3dRotation); DECLARE_OLECREATE_EX(CXTPChart3dRotation); /** @endcond */ # endif }; AFX_INLINE BOOL CXTPChart3dRotation::IsRotated() const { return 0 != m_dYaw || 0 != m_dPitch || 0 != m_dRoll; } AFX_INLINE CXTPChart3dRotation& CXTPChart3dRotation::operator=(const CXTPChart3dRotation& rhs) { m_dYaw = rhs.m_dYaw; m_dPitch = rhs.m_dPitch; m_dRoll = rhs.m_dRoll; return *this; } /** * @brief * Represents a 3D box build around included points and * provides useful and fast operations. */ class _XTP_EXT_CLASS CXTPChart3dBox { public: /** Point list collection type*/ typedef CList PointList; /** * @brief * Constructs an empty 3D box. */ CXTPChart3dBox(); /** * @brief * Constructs a copy of a provided 3D box. * * @param rhs A box to be constructed from. */ CXTPChart3dBox(const CXTPChart3dBox& rhs); public: /** * @brief * Performs box assignment in an efficient way. * * @param rhs A box to be assigned to. * * @return Self object reference. */ CXTPChart3dBox& operator=(const CXTPChart3dBox& rhs); /** * @brief * Determines if a box is valid, e.i. minimal points are less than or equal * to maximal points. * * @return A BOOL value. TRUE if a box is valid, FALSE otherwise. */ BOOL IsValid() const; /** * @brief * Includes a point into the box. If the point exceeds any box side * then the box size gets increased. * * @param pt A point to include into the box. * @param bCenterCandidate If TRUE, the point is considered a center candidate * when GetCenter is called for center candidates. * * @see * GetCenter */ void Include(const CXTPPoint3d& pt, BOOL bCenterCandidate = FALSE); /** * @brief * Includes a point into the box. If the point exceeds any box side * then the box size gets increased. * * @param x X coordinate of a point to include into the box. * @param y Y coordinate of a point to include into the box. * @param z Z coordinate of a point to include into the box. * @param bCenterCandidate If TRUE, the point is considered a center candidate * when GetCenter is called for center candidates. * * @see * GetCenter */ void Include(double x, double y, double z, BOOL bCenterCandidate = FALSE); /** * @brief * Includes a box into the box. The inclusion assumes stretching * to extreme points and copying only center candidates. * * @param box A box to include. * * @see * GetCenter */ void Include(const CXTPChart3dBox& box); /** * @brief * Obtains a minimal point in the box, i.e. a point with the minimal * coordinate value along 3D axes. * * @return A point with minimal coordinates. */ const CXTPPoint3d& GetMinPoint() const; /** * @brief * Obtains a maximal point in the box, i.e. a point with the maximal * coordinate value along 3D axes. * * @return A point with maximal coordinates. */ const CXTPPoint3d& GetMaxPoint() const; /** * @brief * Computes a center of the box. If bAmongstCenterCandidates is FALSE, * then the center of the box is computed as a medium point between * the minimal and maximal points. Otherwise the closest to the physical * box center point added with CentedCandidate = TRUE is returned. * * @param bAmongstCenterCandidates If TRUE, only center candidate points * are considered and the closest one to * the physical center is returned. * * @return A center box point. * * @see * Include */ CXTPPoint3d GetCenter(BOOL bAmongstCenterCandidates = FALSE) const; /** * @brief * Obtains box corners coordinates. * * @param pt An array of 3D box corners. The first 4 points represent * the far box face along the Z axis. The next 4 points represent * the close box face along the Z axis. */ void GetCorners(CXTPPoint3d (&pt)[8]) const; /** * @brief * Provides access to the list of center candidate points. * * @return A reference to the list of center candidate points. * * @see * GetCenter */ const PointList& GetCenterCandidates() const; private: CXTPPoint3d m_ptMin, m_ptMax; PointList m_CenterCandidates; }; AFX_INLINE void CXTPChart3dBox::Include(double x, double y, double z, BOOL bCenterCandidate /*= FALSE*/) { Include(CXTPPoint3d(x, y, z), bCenterCandidate); } AFX_INLINE const CXTPPoint3d& CXTPChart3dBox::GetMinPoint() const { return m_ptMin; } AFX_INLINE const CXTPPoint3d& CXTPChart3dBox::GetMaxPoint() const { return m_ptMax; } AFX_INLINE const CXTPChart3dBox::PointList& CXTPChart3dBox::GetCenterCandidates() const { return m_CenterCandidates; } _XTP_EXT_CLASS BOOL AFX_CDECL PX_Color(CXTPPropExchange* pPX, LPCTSTR pszPropName, CXTPChartColor& clrValue, CXTPChartColor clrDefault = CXTPChartColor::Empty); _XTP_EXT_CLASS BOOL AFX_CDECL PX_Font(CXTPPropExchange* pPX, LPCTSTR pszPropName, CXTPChartFont* pFont); _XTP_EXT_CLASS BOOL AFX_CDECL PX_Rotation(CXTPPropExchange* pPX, LPCTSTR pszPropName, CXTPChart3dRotation& rotation, CXTPChart3dRotation def = CXTPChart3dRotation()); # ifdef _XTP_ACTIVEX extern double AFX_CDECL VariantToDoubleEx(const VARIANT* pVariant); extern BOOL AFX_CDECL IsStringVariant(const VARIANT* pVariant); extern double AFX_CDECL VariantToDouble(const VARIANT* pVariant); # endif /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPCHARTTYPES_H__) /** @endcond */