#include #include #include #include #include #include #include #include char GraphWindow::smszClassName[]={"GraphWindow"}; char GraphWindow::smszMenuName[]={""}; #pragma warning(disable:4355) GraphWindow::GraphWindow(GUIWindow &parentWindow,const Rect &winRect) { mPaintHandler.setCallback(this,&GraphWindow::paintHandler); mCreateHandler.setCallback(this,&GraphWindow::createHandler); mDestroyHandler.setCallback(this,&GraphWindow::destroyHandler); mKeyDownHandler.setCallback(this,&GraphWindow::keyDownHandler); mLeftButtonDownHandler.setCallback(this,&GraphWindow::leftButtonDownHandler); mDialogCodeHandler.setCallback(this,&GraphWindow::dialogCodeHandler); insertHandler(VectorHandler::PaintHandler,&mPaintHandler); insertHandler(VectorHandler::CreateHandler,&mCreateHandler); insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler); insertHandler(VectorHandler::KeyDownHandler,&mKeyDownHandler); insertHandler(VectorHandler::LeftButtonDownHandler,&mLeftButtonDownHandler); insertHandler(VectorHandler::DialogCodeHandler,&mDialogCodeHandler); registerClass(); createWindow(parentWindow,winRect); mGraph3D=new Graph3D(*this); mGraph3D.disposition(PointerDisposition::Delete); setPerspective(); show(SW_SHOW); update(); } GraphWindow::GraphWindow(const GraphWindow &/*someGraphWindow*/) { // private implementation } GraphWindow::~GraphWindow() { removeHandler(VectorHandler::PaintHandler,&mPaintHandler); removeHandler(VectorHandler::CreateHandler,&mCreateHandler); removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler); removeHandler(VectorHandler::KeyDownHandler,&mKeyDownHandler); removeHandler(VectorHandler::LeftButtonDownHandler,&mLeftButtonDownHandler); removeHandler(VectorHandler::DialogCodeHandler,&mDialogCodeHandler); } void GraphWindow::registerClass(void)const { HINSTANCE hInstance(processInstance()); WNDCLASS wndClass; if(::GetClassInfo(hInstance,smszClassName,(WNDCLASS FAR*)&wndClass))return; wndClass.style =CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS|CS_OWNDC; wndClass.lpfnWndProc =(WNDPROC)Window::WndProc; wndClass.cbClsExtra =0; wndClass.cbWndExtra =sizeof(GraphWindow*); wndClass.hInstance =hInstance; wndClass.hIcon =::LoadIcon(NULL,IDI_APPLICATION); wndClass.hCursor =::LoadCursor(NULL,IDC_ARROW); wndClass.hbrBackground =(HBRUSH)::GetStockObject(HOLLOW_BRUSH); wndClass.lpszMenuName =smszMenuName; wndClass.lpszClassName =smszClassName; ::RegisterClass(&wndClass); assert(0!=::GetClassInfo(hInstance,smszClassName,(WNDCLASS FAR*)&wndClass)); } void GraphWindow::createWindow(GUIWindow &parentWindow,const Rect &winRect) { Window::createWindow(WS_EX_CLIENTEDGE,String(smszClassName),String(smszMenuName), WS_CHILD|WS_OVERLAPPED|WS_CLIPCHILDREN|WS_BORDER,winRect, parentWindow,(HMENU)103,processInstance(),(LPSTR)this); show(SW_SHOW); update(); } CallbackData::ReturnType GraphWindow::paintHandler(CallbackData &someCallbackData) { if(!mGraph3D.isOkay())return (CallbackData::ReturnType)FALSE; PaintInformation *pPaintInfo=(PaintInformation*)someCallbackData.lParam(); mGraph3D->clearBits(); for(int rectIndex=0;rectIndexrectangle(colorRect,colorRect.paletteIndex()); } mGraph3D->bitBlt((PureDevice&)*pPaintInfo); return (CallbackData::ReturnType)FALSE; } CallbackData::ReturnType GraphWindow::createHandler(CallbackData &/*someCallbackData*/) { return (CallbackData::ReturnType)FALSE; } CallbackData::ReturnType GraphWindow::leftButtonDownHandler(CallbackData &/*someCallbackData*/) { setFocus(); return (CallbackData::ReturnType)FALSE; } CallbackData::ReturnType GraphWindow::dialogCodeHandler(CallbackData &/*someCallbackData*/) { return (CallbackData::ReturnType)DLGC_WANTARROWS|DLGC_WANTCHARS; } CallbackData::ReturnType GraphWindow::keyDownHandler(CallbackData &someCallbackData) { switch(someCallbackData.wParam()) { case inKey : if(shiftKeyPressed())mGraph3D->cameraTwistDegrees(mGraph3D->cameraTwistDegrees()-ThetaDelta); mGraph3D->viewPlaneDistance(mGraph3D->viewPlaneDistance()+ViewDelta); invalidate(FALSE); break; case outKey : if(shiftKeyPressed())mGraph3D->cameraTwistDegrees(mGraph3D->cameraTwistDegrees()+ThetaDelta); mGraph3D->viewPlaneDistance(mGraph3D->viewPlaneDistance()-ViewDelta); invalidate(FALSE); break; case UpArrow : if(handleUpArrow())invalidate(FALSE); break; case DownArrow : if(handleDownArrow())invalidate(FALSE); break; case LeftArrow : if(handleLeftArrow())invalidate(FALSE); break; case RightArrow : if(handleRightArrow())invalidate(FALSE); break; } return (CallbackData::ReturnType)FALSE; } CallbackData::ReturnType GraphWindow::destroyHandler(CallbackData &/*someCallbackData*/) { return (CallbackData::ReturnType)FALSE; } void GraphWindow::showFlows(Block &pureCashFlows,int baseMonths) { PureVector vectorInt; mGraphRects.remove(); setPerspective(); vectorInt.size(pureCashFlows.size()); for(int itemIndex=0;itemIndex &pureCashFlows,int baseMonths,PureVector &vectorInt,BYTE paletteIndex,int zDepth) { PureVector scrnInt; int widthAdjust(5); clamp(vectorInt); WORD sizeFactor(((((float)width()-20)/(float)widthAdjust)/(float)baseMonths)*100.00); SpacialTransform resample; resample.transform(vectorInt,scrnInt,sizeFactor); for(int itemIndex=0,xPoint=widthAdjust;itemIndex &vectorInt) { float factor=0.00; int vectorMax; if(!vectorInt.size())return; for(int itemIndex=0;itemIndexvectorMax)vectorMax=vectorInt[itemIndex]; } factor=(1.00/(float)vectorMax); for(itemIndex=0;itemIndexcameraPoint()); cameraPoint.y(cameraPoint.y()+TurnDelta); mGraph3D->cameraPoint(cameraPoint); return TRUE; } WORD GraphWindow::handleDownArrow(void) { Point3D cameraPoint(mGraph3D->cameraPoint()); cameraPoint.y(cameraPoint.y()-TurnDelta); mGraph3D->cameraPoint(cameraPoint); return TRUE; } WORD GraphWindow::handleLeftArrow(void) { Point3D cameraPoint(mGraph3D->cameraPoint()); if(shiftKeyPressed())mGraph3D->cameraTwistDegrees(mGraph3D->cameraTwistDegrees()-ThetaDelta); else cameraPoint.x(cameraPoint.x()+TurnDelta); mGraph3D->cameraPoint(cameraPoint); return TRUE; } WORD GraphWindow::handleRightArrow(void) { Point3D cameraPoint(mGraph3D->cameraPoint()); if(shiftKeyPressed())mGraph3D->cameraTwistDegrees(mGraph3D->cameraTwistDegrees()+ThetaDelta); else cameraPoint.x(cameraPoint.x()-TurnDelta); mGraph3D->cameraPoint(cameraPoint); return TRUE; } void GraphWindow::setPerspective(void) { mGraph3D->cameraTwistDegrees(134.64); mGraph3D->viewPlaneDistance(40); mGraph3D->cameraPoint(Point3D(-385,75,75)); mGraph3D->focusPoint(Point3D(0,0,1)); }