コード例 #1
0
ファイル: sieve.cpp プロジェクト: be9/oop_course_tasks
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

    switch (message)
    {
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // Parse the menu selections:
        switch (wmId)
        {
        case IDM_EXIT:
            DestroyWindow(hWnd);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_LBUTTONDOWN:
        {
            static bool started = false;
            if (!started)
            {
                if (!Algorithm::start() || !SetTimer(hWnd, timer, REDRAW_PERIOD, NULL))
                    ErrorExit(hWnd);
                started = true;
            }
            break;
        }
    case WM_PAINT:
        {
            hdc = BeginPaint(hWnd, &ps);

            PlotEvolution(hdc, 0, 0);
            PlotDensity(hdc, 0, PLOT_HEIGHT+2);

            EndPaint(hWnd, &ps);
            break;
        }
    case WM_TIMER:
        if (static_cast<UINT_PTR>(wParam) != timer)
            break;

        if (Algorithm::is_running())
        {
            InvalidateRect(hWnd, NULL, TRUE);
        }
        else
        {
            if (KillTimer(hWnd, timer) == 0)
            {
                ErrorExit(hWnd);
                break;
            }
            MessageBox(hWnd, _T("Calculation finished"), _T("Calculation finished"), MB_OK | MB_ICONINFORMATION);
            DestroyWindow(hWnd);
        }
        break;
    case WM_DESTROY:
        Algorithm::stop();
        Algorithm::deinit();
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
コード例 #2
0
ファイル: Visualization.cpp プロジェクト: Danvil/dasp
	slimage::Image3ub PlotDensity(const Eigen::MatrixXf& d) {
		return PlotDensity(d,
			d.minCoeff(), d.maxCoeff());
	}