// Funnel3dView.cpp // // (c)1998-2025 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // support@codejock.com // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "ChartBrowser.h" #include "BaseView.h" #include "ComponentSliderCtrl.h" #include "3dParametersDlg.h" #include "Funnel3dOptionsDlg.h" #include "Funnel3dView.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif // CFunnel3dView IMPLEMENT_DYNCREATE(CFunnel3dView, CBase3dView) CFunnel3dView::CFunnel3dView(UINT nID) : CBase3dView(nID) , m_pOptionsDlg(NULL) { m_strCaption = _T("3D Funnel Style"); } CFunnel3dView::~CFunnel3dView() { SAFE_DELETE(m_pOptionsDlg); } void CFunnel3dView::DoDataExchange(CDataExchange* pDX) { CBase3dView::DoDataExchange(pDX); DDX_Control(pDX, IDC_CHARTCONTROL, m_wndChartControl); } BEGIN_MESSAGE_MAP(CFunnel3dView, CBase3dView) END_MESSAGE_MAP() // CFunnel3dView diagnostics #ifdef _DEBUG void CFunnel3dView::AssertValid() const { CBase3dView::AssertValid(); } # ifndef _WIN32_WCE void CFunnel3dView::Dump(CDumpContext& dc) const { CBase3dView::Dump(dc); } # endif #endif //_DEBUG // CFunnel3dView message handlers void CFunnel3dView::OnInitialUpdate() { CBase3dView::OnInitialUpdate(); m_pOptionsDlg = new CFunnel3dOptionsDlg(*this, &m_wndTabControl); if (m_pOptionsDlg->Create(CFunnel3dOptionsDlg::IDD, &m_wndTabControl)) { m_pOptionsDlg->SetWindowText(_T("Options")); AddTab(0, m_pOptionsDlg); SetActiveTab(0); } else { TRACE(_T("Unable to create CFunnel3dOptionsDlg.\n")); } m_wndTabControl.SetCurSel(0); CreateChart(); } static CXTPChartSeriesPoint* CreateFunnelPoint(LPCTSTR lpszLegendText, double nYear, double nValue, double dWidth) { CXTPChartSeriesPoint* pPoint = new CXTPChartSeriesPoint(nYear, nValue, dWidth); pPoint->SetLegendText(lpszLegendText); return pPoint; } void CFunnel3dView::CreateChart() { CXTPChartContent* pContent = m_wndChartControl.GetContent(); pContent->GetLegend()->SetVisible(TRUE); pContent->GetLegend()->SetHorizontalAlignment(xtpChartLegendFar); pContent->GetLegend()->SetVerticalAlignment(xtpChartLegendFar); CXTPChartTitle* pTitle = pContent->GetTitles()->Add(new CXTPChartTitle()); pTitle->SetText(_T("Corporate Actives")); CXTPChartSeries* pSeries = pContent->GetSeries()->Add(new CXTPChartSeries()); pSeries->SetName(_T("Corporate Actives")); CXTPChart3dFunnelSeriesStyle* pStyle = new CXTPChart3dFunnelSeriesStyle(); pStyle->SetBaseEdgeCount(4); pStyle->SetHeightToWidthRatio(1.5); pStyle->Enable3dEdgeSmoothing(); pSeries->SetStyle(pStyle); CXTPChart3dRotation chartRotation = pStyle->Get3dRotation(); chartRotation.m_dYaw = 203; chartRotation.m_dPitch = 355; chartRotation.m_dRoll = 79; pStyle->Set3dRotation(chartRotation); CXTPChartSeriesPoint* pPoint = NULL; CXTPChartSeriesPointCollection* pPoints = pSeries->GetPoints(); BOOL bFunnel = TRUE; pPoints->Add(new CXTPChartSeriesPoint(_T("Cash US $216K"), 216)); pPoints->Add(new CXTPChartSeriesPoint(_T("Stocks US $150K"), 150)); pPoints->Add(new CXTPChartSeriesPoint(_T("Bonds US $100K"), 100)); pPoints->Add(new CXTPChartSeriesPoint(_T("Funds US $43K"), 43)); pStyle->GetLabel()->SetFormat(_T("{A}")); pSeries->SetPointLegendFormat(_T("{A}")); if (NULL != m_p3dParametersDlg) { CXTPChartDiagram3DAppearance* p3dAppearance = m_wndChartControl.GetContent()->GetAppearance()->GetDiagram3DAppearance(); _ASSERTE(NULL != p3dAppearance); m_p3dParametersDlg->SetRotation(pStyle->Get3dRotation()); m_p3dParametersDlg->SetLightPosition(p3dAppearance->LightPosition); m_p3dParametersDlg->SetLightModelAmbient(p3dAppearance->LightModelAmbientColor); m_p3dParametersDlg->SetLightAmbient(p3dAppearance->LightAmbientColor); m_p3dParametersDlg->SetLightDiffuse(p3dAppearance->LightDiffuseColor); m_p3dParametersDlg->SetLightSpecular(p3dAppearance->LightSpecularColor); m_p3dParametersDlg->SetMaterialEmission(p3dAppearance->MaterialEmissionColor); m_p3dParametersDlg->SetMaterialDiffuse(p3dAppearance->MaterialDiffuseColor); m_p3dParametersDlg->SetMaterialSpecular(p3dAppearance->MaterialSpecularColor); m_p3dParametersDlg->SetMaterialShininess(p3dAppearance->MaterialShininess); m_p3dParametersDlg->SetAntialiasing(p3dAppearance->Antialiasing); } } void CFunnel3dView::OnBnClickedCheckShowLabels() { if (NULL != m_pOptionsDlg) { CXTPChartSeriesCollection* pSeriesCollection = m_wndChartControl.GetContent()->GetSeries(); for (int i = 0; i < pSeriesCollection->GetCount(); i++) { CXTPChartSeriesStyle* pStyle = pSeriesCollection->GetAt(i)->GetStyle(); pStyle->GetLabel()->SetVisible(m_pOptionsDlg->GetShowLabelsValue()); } m_pOptionsDlg->GetDlgItem(IDC_COMBO_LABEL_POSITION) ->EnableWindow(m_pOptionsDlg->GetShowLabelsValue()); } } void CFunnel3dView::OnBnClickedCheckSmoothEdges() { if (NULL != m_pOptionsDlg) { CXTPChartSeriesCollection* pSeriesCollection = m_wndChartControl.GetContent()->GetSeries(); CXTPChart3dFunnelSeriesStyle* pFunnelStyle = (CXTPChart3dFunnelSeriesStyle*)pSeriesCollection->GetAt(0)->GetStyle(); pFunnelStyle->Enable3dEdgeSmoothing(m_pOptionsDlg->GetSmoothEdges()); } } void CFunnel3dView::OnBnClickedCheckEqualHeight() { if (NULL != m_pOptionsDlg) { CXTPChartSeriesCollection* pSeriesCollection = m_wndChartControl.GetContent()->GetSeries(); CXTPChart3dFunnelSeriesStyle* pFunnelStyle = (CXTPChart3dFunnelSeriesStyle*)pSeriesCollection->GetAt(0)->GetStyle(); pFunnelStyle->SetEqualHeight(m_pOptionsDlg->GetEqualHeight()); } } void CFunnel3dView::OnCbnSelChangeComboLabelPosition() { if (NULL != m_pOptionsDlg) { CXTPChartSeriesCollection* pSeriesCollection = m_wndChartControl.GetContent()->GetSeries(); CXTPChart3dFunnelSeriesStyle* pFunnelStyle = (CXTPChart3dFunnelSeriesStyle*)pSeriesCollection->GetAt(0)->GetStyle(); CXTPChartFunnelSeriesLabel* pLabel = (CXTPChartFunnelSeriesLabel*)pFunnelStyle->GetLabel(); pLabel->SetPosition( static_cast(m_pOptionsDlg->GetPositionValue())); } } void CFunnel3dView::OnCbnSelChangeComboBaseEdgeCount() { if (NULL != m_pOptionsDlg) { CXTPChartSeriesCollection* pSeriesCollection = m_wndChartControl.GetContent()->GetSeries(); CXTPChart3dFunnelSeriesStyle* pFunnelStyle = (CXTPChart3dFunnelSeriesStyle*)pSeriesCollection->GetAt(0)->GetStyle(); pFunnelStyle->SetBaseEdgeCount(m_pOptionsDlg->GetBaseEdgeCount()); } } void CFunnel3dView::OnCbnSelChangeComboPointDistance() { if (NULL != m_pOptionsDlg) { CXTPChartSeriesCollection* pSeriesCollection = m_wndChartControl.GetContent()->GetSeries(); CXTPChart3dFunnelSeriesStyle* pFunnelStyle = (CXTPChart3dFunnelSeriesStyle*)pSeriesCollection->GetAt(0)->GetStyle(); pFunnelStyle->SetPointDistance(m_pOptionsDlg->GetPointDistance()); } } void CFunnel3dView::OnCbnSelChangeComboHeightToWidthRatio() { if (NULL != m_pOptionsDlg) { CXTPChartSeriesCollection* pSeriesCollection = m_wndChartControl.GetContent()->GetSeries(); CXTPChart3dFunnelSeriesStyle* pFunnelStyle = DYNAMIC_DOWNCAST(CXTPChart3dFunnelSeriesStyle, pSeriesCollection->GetAt(0)->GetStyle()); _ASSERTE(NULL != pFunnelStyle); pFunnelStyle->SetHeightToWidthRatio(m_pOptionsDlg->GetHeightToWidthRatio()); } } void CFunnel3dView::OnCbnSelChangeComboTransparency() { if (NULL != m_pOptionsDlg) { CXTPChartSeriesCollection* pSeriesCollection = m_wndChartControl.GetContent()->GetSeries(); CXTPChart3dFunnelSeriesStyle* pFunnelStyle = DYNAMIC_DOWNCAST(CXTPChart3dFunnelSeriesStyle, pSeriesCollection->GetAt(0)->GetStyle()); _ASSERTE(NULL != pFunnelStyle); pFunnelStyle->SetTransparency(m_pOptionsDlg->GetTransparency()); } } CXTPChart3dRotation CFunnel3dView::GetChartRotation() const { CXTPChartSeriesCollection* pSeriesCollection = m_wndChartControl.GetContent()->GetSeries(); CXTPChart3dFunnelSeriesStyle* pFunnelStyle = DYNAMIC_DOWNCAST(CXTPChart3dFunnelSeriesStyle, pSeriesCollection->GetAt(0)->GetStyle()); _ASSERTE(NULL != pFunnelStyle); return pFunnelStyle->Get3dRotation(); } void CFunnel3dView::SetChartRotation(CXTPChart3dRotation rotation) { CXTPChartSeriesCollection* pSeriesCollection = m_wndChartControl.GetContent()->GetSeries(); CXTPChart3dFunnelSeriesStyle* pFunnelStyle = DYNAMIC_DOWNCAST(CXTPChart3dFunnelSeriesStyle, pSeriesCollection->GetAt(0)->GetStyle()); _ASSERTE(NULL != pFunnelStyle); pFunnelStyle->Set3dRotation(rotation); }