// MutFView.cpp : implementation of the CMutFView class // #include "stdafx.h" #include "MutF.h" #include "MutFDoc.h" #include "MutFView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMutFView IMPLEMENT_DYNCREATE(CMutFView, CView) BEGIN_MESSAGE_MAP(CMutFView, CView) //{{AFX_MSG_MAP(CMutFView) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMutFView construction/destruction CMutFView::CMutFView() { // TODO: add construction code here } CMutFView::~CMutFView() { delete thechartview; } BOOL CMutFView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } void CMutFView::Define3DGraph(void) { // Create data locally even though it should probably come from // the CMutFDoc class. realtype xdata[10] = {87, 88, 89, 90, 91, 92, 93, 94, 95, 96}; realtype Karpman[10] = {100, 120, 130, 180, 200, 250, 360, 370, 390, 430}; realtype MacGuard[10] = {70, 80, 90, 130, 160, 220, 230, 250, 240, 260}; realtype Infidel[10] = {40, 50, 110, 130, 120, 150, 170, 200, 200, 210}; realtype Annubus[10] = {30, 90, 100, 110, 120, 130, 150, 160, 190, 200}; realtype * FundZList[4] = {Karpman, MacGuard, Infidel, Annubus}; realtype *FundXList[4] = {xdata, xdata, xdata, xdata}; int numDataList[4] = {10, 10, 10, 10}; realtype width, basevalue, constvalue; int justify, indaxis, numpoints; RGBDType fillcolor; CString xtitle("Year"); CString ytitle(""); CString ztitle("Return"); CString TicStrings[4] = {"Karpman", "MacGuard", "Infidel", "Annubus"}; CChartObj3D *chartobj1, *chartobj2, *chartobj3, *chartobj4; GLViewRType chartpos; point3Dtype minscale, maxscale, chartrot, chartrect; point3Dtype light; thechartview->SetViewBkColor(RGBWHITE); thechart = thechartview->NewChart3D(); // Auto transform for multiple chart objects transform1 = thechart->AutoTransformN25D (FundXList, FundZList, numDataList, 4, 1.0, X_AXIS, 0); // Make y direction 4 units wide minscale = transform1->GetScaleMin(); maxscale = transform1->GetScaleMax(); maxscale.y = 4.0; minscale.z = 0.0; transform1->SetScale(&minscale, &maxscale); // Auto axes axes1 = thechart->AutoAxes(transform1); // Override tic mark spacing attributes axes1->SetAxisTicSpace(X_AXIS, 1.0); axes1->SetAxisNthTicMajor(X_AXIS, 1); axes1->SetAxisTicSpace(Y_AXIS, 1.0); axes1->SetAxisNthTicMajor(Y_AXIS, 1); axes1->SetAxisLabelsStrings(Y_AXIS, TicStrings, 4); // Set wall plane attributes axes1->SetWallPlane(XY_MINZ_PLANE, SetRGBD(0.0,0.2,0.4,0.0), SetRGBD(0.0,0.0,0.0,1.0)); axes1->SetPlaneGrid(XY_MINZ_PLANE,1,1, RGBBLACK, 1.0, 0, 1); axes1->SetAxisTitleString(X_AXIS,&xtitle); axes1->SetWallPlane(XZ_MINY_PLANE, SetRGBD(0.0,0.2,0.4,0.0), SetRGBD(0.0,0.0,0.0,1.0)); axes1->SetPlaneGrid(XZ_MINY_PLANE,1,1, RGBBLACK, 1.0, 0, 1); axes1->SetAxisTitleString(Y_AXIS, &ytitle); axes1->SetAxisTitlePlane(Y_AXIS, XZ_PLANE); axes1->SetWallPlane(YZ_MINX_PLANE, SetRGBD(0.0,0.2,0.4,0.0), SetRGBD(0.0,0.0,0.0,1.0)); axes1->SetPlaneGrid(YZ_MINX_PLANE,1,1, RGBBLACK, 1.0, 0, 1); axes1->SetAxisTitleString(Z_AXIS, &ztitle); // light source light.x = 0.1; light.y = 1.0; light.z = 1.0; light.v = 0; thechart->SetLightPosition(&light); thechart->SetColorMode(1); // Set chart headers thechart->ChartHeader->Title1->SetCharSize(1.0); thechart->ChartHeader->Title1->SetString("Mutual Fund Comparison"); thechart->ChartHeader->Title2->SetCharSize(0.5); thechart->ChartHeader->Title2->SetString("Total Return"); thechart->ChartHeader->Footer->SetCharSize(0.5); thechart->ChartHeader->Footer->SetString("Dividends Reinvested"); // Position chart within chart window AssignViewR(chartpos, 0.0, 0.0, 1.0, 1.0); thechart->SetChartPosition(&chartpos); thechart->SetFontSize(0.133); // Chart rotation within window chartrot.x = -40.0; chartrot.y = 0.0; chartrot.z = 10.0; transform1->SetRotate(&chartrot ); chartrect.x = 0.55; chartrect.y = 0.4; chartrect.z = 0.45; transform1->SetChartRect(&chartrect); // Chartobj #1 width = 0.5; basevalue = minscale.z; numpoints = 10; justify = JUSTIFY_MIN; indaxis = X_AXIS; constvalue = 0.0; fillcolor = RGBBLUE; chartobj1 = thechart->NewChartObj(transform1); chartobj1->AreaFillChart25D ( xdata, Karpman, basevalue, constvalue, numpoints, width, fillcolor, RGBBLACK, justify, indaxis); // Chartobj #2 constvalue = 1.0; fillcolor = RGBGREEN; chartobj2 = thechart->NewChartObj(transform1); chartobj2->AreaFillChart25D ( xdata, MacGuard, basevalue, constvalue, numpoints, width, fillcolor, RGBBLACK, justify, indaxis); // Chartobj #3 constvalue = 2.0; fillcolor = RGBRED; chartobj3 = thechart->NewChartObj(transform1); chartobj3->AreaFillChart25D ( xdata, Infidel, basevalue, constvalue, numpoints, width, fillcolor, RGBBLACK, justify, indaxis); constvalue = 3.0; fillcolor = RGBMAGENTA; // Chartobj #4 chartobj4 = thechart->NewChartObj(transform1); chartobj4->SetFillGap(0.02); chartobj4->AreaFillChart25D ( xdata, Annubus, basevalue, constvalue, numpoints, width, fillcolor, RGBBLACK, justify, indaxis); } ///////////////////////////////////////////////////////////////////////////// // CMutFView drawing void CMutFView::OnDraw(CDC* pDC) { CMutFDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); thechartview->DrawViewScreen(pDC); // TODO: add draw code for native data here } ///////////////////////////////////////////////////////////////////////////// // CMutFView printing BOOL CMutFView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CMutFView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CMutFView::OnPrint(CDC* pDC, CPrintInfo* pInfo) { // TODO: Add your specialized code here and/or call the base class thechartview->OnPrint(pDC, pInfo); } void CMutFView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CMutFView diagnostics #ifdef _DEBUG void CMutFView::AssertValid() const { CView::AssertValid(); } void CMutFView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CMutFDoc* CMutFView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMutFDoc))); return (CMutFDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMutFView message handlers void CMutFView::OnInitialUpdate() { CView::OnInitialUpdate(); thechartview = new CChartView3D(this); Define3DGraph(); // TODO: Add your specialized code here and/or call the base class }