// GraphWindow.cpp : インプリメンテーション ファイル // #include "stdafx.h" #include "MeshEditor.h" #include "GraphWindow.h" #include #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // GraphWindow IMPLEMENT_DYNCREATE(GraphWindow, CFrameWnd) GraphWindow::GraphWindow() { value_N = 0; data_N = 0; data = NULL; value = NULL; sample = NULL; max = 1; } GraphWindow::~GraphWindow() { if(data != NULL) delete data; if(value != NULL) delete value; } BEGIN_MESSAGE_MAP(GraphWindow, CFrameWnd) //{{AFX_MSG_MAP(GraphWindow) ON_WM_SIZE() ON_WM_PAINT() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // GraphWindow メッセージ ハンドラ void GraphWindow::drawGraph() { if(data_N == 0) return; CRect rect; this->GetClientRect(&rect); CClientDC* dc = new CClientDC(this); //CDC *dc; //PAINTSTRUCT pstruct; //if(dc = BeginPaint(&pstruct)){ dc->FillRect(rect, NULL); dc->SetBkColor(RGB(255,255,255)); dc->SetTextColor(RGB(0,0,0)); CString s; s.Format("Clip Min: %f", min_v); dc->TextOut(0, 0, s); s.Format("Clip Max: %f", max_v); dc->TextOut(0, 20, s); s.Format("Average : %f", mid); dc->TextOut(0, 40, s); s.Format("Varience: %f", vari); dc->TextOut(0, 60, s); int x0 = 20; int y0 = rect.bottom - 20; int w = rect.Width()-30; int h = rect.Height()-30; float c[3]; for(int i=0 ;iconvertColor(sample[i], c); CPen pen(PS_SOLID, 1, RGB(255*c[0], 255*c[1], 255*c[2])); CPen *old_pen = dc->SelectObject(&pen); int x = i*w/value_N + x0; int y = -value[i]*h/max + y0; dc->MoveTo(x, y0); dc->LineTo(x,y); dc->SelectObject(old_pen); pen.DeleteObject(); } //} //EndPaint(&pstruct); delete dc; } void GraphWindow::setData(double *data, int data_N) { this->data = data; this->data_N = data_N; double S = 0; for(int i=0; i 255) index = 255; value[index+8*256]++; } } max = 0; for(i=0; idrawGraph(); } */ void GraphWindow::OnSize(UINT nType, int cx, int cy) { CFrameWnd::OnSize(nType, cx, cy); // TODO: この位置にメッセージ ハンドラ用のコードを追加してください if(cx <= 0 || cy <= 0) return; value_N = cx - 30; this->computValue(); this->drawGraph(); } void GraphWindow::computValue() { if(value != NULL) delete value; value = new int[value_N]; if(sample != NULL) delete sample; sample = new double[value_N]; for(int i=0; i= value_N) index = value_N-1; value[index]++; } max = 0; for(i=0; i