/** * @file XTPChartLineDeviceCommand.cpp * * @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 * */ #include "stdafx.h" #include "Common/Base/Diagnostic/XTPDisableAdvancedWarnings.h" #include #include "Common/Base/Diagnostic/XTPEnableAdvancedWarnings.h" #include "Common/XTPTypeId.h" #include "Common/Math/XTPMathUtils.h" #include "Common/XTPFramework.h" #include "Common/XTPSynchro.h" #include "Common/XTPSystemHelpers.h" #include "Common/XTPApplication.h" #include "Common/XTPSingleton.h" #include "Common/Base/Types/XTPPoint2.h" #include "Common/Base/Types/XTPPoint3.h" #include "Common/Base/Types/XTPSize.h" #include "Common/Base/Types/XTPRect.h" #include "Common/Math/XTPMathUtils.h" #include "Common/XTPTypeId.h" #include "Chart/Types/XTPChartTypes.h" #include "Chart/XTPChartDefines.h" #include "Chart/XTPChartElement.h" #include "Chart/Drawing/XTPChartDeviceCommand.h" #include "Chart/Drawing/XTPChartLineDeviceCommand.h" #include "Chart/Drawing/XTPChartDeviceContext.h" #include "Chart/Drawing/XTPChart3dDeviceContext.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ////////////////////////////////////////////////////////////////////////// // CXTPChartLineDeviceCommand CXTPChartLineDeviceCommand::CXTPChartLineDeviceCommand(const CXTPPoint2f& p1, const CXTPPoint2f& p2, const CXTPChartColor& color, int thickness) : m_p1(p1) , m_p2(p2) , m_color(color) , m_nThickness(thickness) { } CXTPChartElement* CXTPChartLineDeviceCommand::HitTest(CPoint point, CXTPChartElement* pParent) const { CXTPChartElement* pHitElement = NULL; if (CXTPMathUtils::HitTestLineSegment(m_p1.X, m_p1.Y, m_p2.X, m_p2.Y, point.x, point.y, m_nThickness)) { pHitElement = pParent; } return pHitElement; } ////////////////////////////////////////////////////////////////////////// // CXTPChartPolylineDeviceCommand CXTPChartPolylineDeviceCommand::CXTPChartPolylineDeviceCommand(const CXTPChartPoints& p, int thickness) { m_p.Copy(p); m_nThickness = thickness; } ////////////////////////////////////////////////////////////////////////// // CXTPChartSplineDeviceCommand CXTPChartSplineDeviceCommand::CXTPChartSplineDeviceCommand(const CXTPChartPoints& p, int thickness) { m_p.Copy(p); m_nThickness = thickness; } ////////////////////////////////////////////////////////////////////////// // CXTPChart3dLineDeviceCommand CXTPChart3dLineDeviceCommand::CXTPChart3dLineDeviceCommand(const CXTPPoint3d& p1, const CXTPPoint3d& p2, const CXTPChartColor& color, int thickness) : m_p1(p1) , m_p2(p2) , m_color(color) , m_nThickness(thickness) , m_bProjected(FALSE) { Set3D(); } CXTPChartElement* CXTPChart3dLineDeviceCommand::HitTest(CPoint point, CXTPChartElement* pParent) const { CXTPChartElement* pHitElement = NULL; if (m_bProjected && CXTPMathUtils::HitTestLineSegment(m_pt2d1.x, m_pt2d1.y, m_pt2d2.x, m_pt2d2.y, point.x, point.y, m_nThickness)) { pHitElement = pParent; } return pHitElement; } void CXTPChart3dLineDeviceCommand::AfterExecute(CXTPChartDeviceContext* pDC) { CXTPChart3dDeviceContext* p3DDC = DYNAMIC_DOWNCAST(CXTPChart3dDeviceContext, pDC); _ASSERTE(NULL != p3DDC); if (NULL != p3DDC) { m_bProjected = p3DDC->Project(m_p1, m_pt2d1) && p3DDC->Project(m_p2, m_pt2d2); } }