⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rimshotview.cpp

📁 刚才是说明 现在是安装程序在 LINUX环境下进行编程的MPICH安装文件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//*  $Id: rimshotView.cpp,v 1.8 2002/09/27 21:11:16 toonen Exp $ * *  (C) 2001 by Argonne National Laboratory. *      See COPYRIGHT in top-level directory. */// rimshotView.cpp : implementation of the CRimshotView class//#include "stdafx.h"#include "rimshot.h"#include "rimshotDoc.h"#include "rimshotView.h"#include "rimshot_draw.h"#include "zoomdlg.h"#include "OffsetDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CRimshotViewIMPLEMENT_DYNCREATE(CRimshotView, CView)BEGIN_MESSAGE_MAP(CRimshotView, CView)	//{{AFX_MSG_MAP(CRimshotView)	ON_COMMAND(ID_NEXT, OnNext)	ON_COMMAND(ID_PREVIOUS, OnPrevious)	ON_COMMAND(ID_RESET_ZOOM, OnResetZoom)	ON_COMMAND(ID_ZOOM_IN, OnZoomIn)	ON_COMMAND(ID_ZOOM_OUT, OnZoomOut)	ON_WM_KEYDOWN()	ON_COMMAND(ID_ZOOM_TO, OnZoomTo)	ON_WM_SIZE()	ON_WM_ERASEBKGND()	ON_COMMAND(ID_TOGGLE_ARROWS, OnToggleArrows)	ON_WM_LBUTTONDOWN()	ON_COMMAND(ID_VIEW_UNIFORM, OnViewUniform)	ON_COMMAND(ID_VIEW_ZOOM, OnViewZoom)	ON_COMMAND(ID_VIEW_SLIDERANKOFFSET, OnSlideRankOffset)	//}}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()/////////////////////////////////////////////////////////////////////////////// CRimshotView construction/destructionCRimshotView::CRimshotView(){    m_Draw.pCanvas = NULL;    m_Draw.pBitmap = NULL;    m_Draw.pCopyCanvas = NULL;    m_Draw.pCopyBitmap = NULL;    m_hDrawThread = NULL;    m_Draw.max_rect_size.cx = 0;    m_Draw.max_rect_size.cy = 0;    m_Draw.max_copy_size.cx = 0;    m_Draw.max_copy_size.cy = 0;    m_Draw.bDrawUniform = false;    m_Draw.nUniformWidth = 15;    m_Draw.pCursorRanks = NULL;    m_Draw.ppUniRecursionColor = NULL;    m_Draw.bSliding = false;    m_Draw.pSlidingBitmap = NULL;}CRimshotView::~CRimshotView(){    int i;    if (m_Draw.pCursorRanks)	delete [] m_Draw.pCursorRanks;    if (m_Draw.ppUniRecursionColor)    {	for (i=0; i<m_Draw.nUniNumRanks; i++)	{	    delete m_Draw.ppUniRecursionColor[i];	}	delete m_Draw.ppUniRecursionColor;	m_Draw.ppUniRecursionColor = NULL;    }}BOOL CRimshotView::PreCreateWindow(CREATESTRUCT& cs){    return CView::PreCreateWindow(cs);}/////////////////////////////////////////////////////////////////////////////// CRimshotView drawingvoid CRimshotView::OnDraw(CDC* pDC){    CRect rect;    GetClientRect(&rect);    if (rect.Width() == m_Draw.copy_size.cx && rect.Height() == m_Draw.copy_size.cy)    {	pDC->BitBlt(0, 0, rect.Width(), rect.Height(), m_Draw.pCopyCanvas, 0, 0, SRCCOPY);    }    else    {	pDC->StretchBlt(	    0, 0, rect.Width(), rect.Height(), 	    m_Draw.pCopyCanvas, 0, 0, m_Draw.copy_size.cx, m_Draw.copy_size.cy, SRCCOPY);    }}void CRimshotView::DrawToCanvas(CDC *pDC){    CRect rect, big_rect, client_rect;    RLOG_EVENT event;    RLOG_ARROW arrow;    double dx;    int height, lip;    CBrush *pBrush;    int i, j, k, x, y;    HCURSOR hOldCursor;    double dwPixel, *pdNextPixel;    int nMaxRecursions = 0;    CBrush white_brush;    CPen line_pen, cursor_pen;    CString str;    CSize size;    double duration;    CRimshotDoc* pDoc = GetDocument();    ASSERT_VALID(pDoc);    GetClientRect(&client_rect);    GetClientRect(&big_rect);    big_rect.DeflateRect(25, 25);    line_pen.CreatePen(PS_SOLID, 1, RGB(100,100,100));    cursor_pen.CreatePen(PS_SOLID, 1, RGB(255,255,255));    pDC->FillSolidRect(client_rect, RGB(255,255,255));    pDC->FillSolidRect(big_rect, RGB(0,0,0));    if (pDoc->m_pInput)    {	hOldCursor = SetCursor( LoadCursor(NULL, IDC_WAIT) );	dx = ((double)big_rect.right - (double)big_rect.left) / (pDoc->m_dRight - pDoc->m_dLeft);	height = (big_rect.bottom - big_rect.top) / pDoc->m_pInput->nNumRanks;	for (i=0; i<pDoc->m_pInput->nNumRanks; i++)	    nMaxRecursions = max(pDoc->m_pInput->pNumEventRecursions[i], nMaxRecursions);	lip = (height / 2) / (nMaxRecursions + 1);	dwPixel = 1.0 / dx;	pdNextPixel = new double[pDoc->m_pInput->nNumRanks];	// draw the horizontal rank lines	pDC->SelectObject(&line_pen);	for (i=0; i<pDoc->m_pInput->nNumRanks; i++)	{	    y = big_rect.top + (height * i) + (height / 2);	    pDC->MoveTo(big_rect.left, y);	    pDC->LineTo(big_rect.right, y);	}	// draw the event boxes	for (j=0; j<pDoc->m_pInput->nNumRanks; j++)	{	    for (i=0; i<pDoc->m_pInput->pNumEventRecursions[j]; i++)	    {		if (RLOG_FindEventBeforeTimestamp(pDoc->m_pInput, 		    pDoc->m_pInput->header.nMinRank + j, i, pDoc->m_dLeft, &event, NULL) == 0)		{		    if (event.end_time < pDoc->m_dLeft)			RLOG_GetNextEvent(pDoc->m_pInput, pDoc->m_pInput->header.nMinRank + j, i, &event);		    else		    {			if (event.start_time < pDoc->m_dLeft)			    event.start_time = pDoc->m_dLeft;		    }		    for (k=0; k<pDoc->m_pInput->nNumRanks; k++)			pdNextPixel[k] = event.start_time;		    while (event.start_time < pDoc->m_dRight)		    {			if (event.end_time > pdNextPixel[event.rank])			{			    pdNextPixel[event.rank] = event.end_time + dwPixel;			    rect.top = big_rect.top + (event.rank * height) + (lip * (i+1));			    rect.bottom = rect.top + height - (lip * (i+1) * 2);			    rect.left = big_rect.left + (long)(dx * (event.start_time - pDoc->m_dLeft));			    rect.right = rect.left + (long)(dx * (event.end_time - event.start_time));			    if (rect.left == rect.right) rect.right++;			    if (rect.right > big_rect.right)				rect.right = big_rect.right;			    			    pDC->FillSolidRect(rect, pDoc->GetEventColor(event.event));			}						if (RLOG_GetNextEvent(pDoc->m_pInput, 			    pDoc->m_pInput->header.nMinRank + j, i, &event) != 0)			    event.start_time = pDoc->m_dRight + 1;		    }		}	    }	}	// draw the arrows	// This isn't exactly right because I don't think the arrows are stored in end time order.	if (RLOG_FindArrowBeforeTimestamp(pDoc->m_pInput, pDoc->m_dLeft, &arrow, NULL) == 0)	{	    if (arrow.end_time < pDoc->m_dLeft)		RLOG_GetNextArrow(pDoc->m_pInput, &arrow);	    //pDC->SelectObject(&line_pen);	    pDC->SelectObject(GetStockObject(WHITE_PEN));	    while (arrow.end_time < pDoc->m_dRight)	    {		x = big_rect.left + (long)(dx * (arrow.start_time - pDoc->m_dLeft));		y = big_rect.top + (height * arrow.src) + (height / 2);		pDC->MoveTo(x, y);		pDC->Ellipse(x-5, y-5, x+5, y+5);		x = x + (long)(dx * (arrow.end_time - arrow.start_time));		y = big_rect.top + (height * arrow.dest) + (height / 2);		pDC->LineTo(x, y);		if (RLOG_GetNextArrow(pDoc->m_pInput, &arrow) != 0)		    arrow.end_time = pDoc->m_dRight + 1;	    }	}	// draw the vertical cursor line	pDC->SelectObject(&cursor_pen);	pDC->MoveTo((big_rect.right + big_rect.left) / 2, big_rect.top);	pDC->LineTo((big_rect.right + big_rect.left) / 2, big_rect.bottom);	pDC->SetBkMode(OPAQUE);	pDC->SetBkColor(RGB(255,255,255));	pDC->SetTextColor(RGB(0,0,0));	// draw the ranks	for (i=0; i<pDoc->m_pInput->nNumRanks; i++)	{	    y = big_rect.top + (height * i) + (height / 2);	    str.Format("%d", i);	    size = pDC->GetTextExtent(str);	    pDC->TextOut((big_rect.left - size.cx - 7) >= 0 ? (big_rect.left - size.cx - 7) : 0, y - (size.cy / 2), str);	}	// draw the box, event description and duration	if (RLOG_GetCurrentGlobalEvent(pDoc->m_pInput, &event) == 0)	{	    pBrush = pDoc->GetEventBrush(event.event);	    rect.left = (big_rect.left + big_rect.right) / 2;	    rect.right = rect.left + 13;	    rect.top = 7;	    rect.bottom = 20;	    pDC->FillRect(&rect, pBrush);	    //str.Format("%3d: %s    duration: %.6f", event.rank, pDoc->GetEventDescription(event.event), event.end_time - event.start_time);	    //pDC->TextOut(rect.left + 20, 7, str);	    str.Format("%3d: %s ", event.rank, pDoc->GetEventDescription(event.event));	    size = pDC->GetTextExtent(str);	    pDC->TextOut(rect.left + 13, 7, str);	    //pDC->TextOut(rect.left - size.cx, 7, str);	    duration = event.end_time - event.start_time;	    str.Format("%.9f", duration);	    size = pDC->GetTextExtent(str);	    x = rect.left - 7 - size.cx;	    // write the milliseconds	    str.Format("%.3f", duration);	    size = pDC->GetTextExtent(str);	    CRgn rgn;	    rgn.CreateRectRgn(x, 7, x + size.cx, 7 + size.cy);	    pDC->SelectClipRgn(&rgn, RGN_COPY);	    str.Format("%.6f", duration);	    pDC->SetTextColor(RGB(0,0,0));	    pDC->TextOut(x, 7, str);	    // write the microseconds	    str.Format("%.6f", duration);	    size = pDC->GetTextExtent(str);	    rgn.CreateRectRgnIndirect(&client_rect);	    pDC->SelectClipRgn(&rgn, RGN_XOR);	    rgn.CreateRectRgn(x, 7, x + size.cx, 7 + size.cy);	    str.Format("%.9f", duration);	    pDC->SetTextColor(RGB(255,0,0));	    pDC->TextOut(x, 7, str);	    // write the nanoseconds	    pDC->SelectClipRgn(&rgn, RGN_COPY);	    rgn.CreateRectRgnIndirect(&client_rect);	    pDC->SelectClipRgn(&rgn, RGN_XOR);	    str.Format("%.9f", duration);	    pDC->SetTextColor(RGB(0,0,255));	    pDC->TextOut(x, 7, str);	    pDC->SetTextColor(RGB(0,0,0));	    rect.top = big_rect.top + (event.rank * height) + (lip * (event.recursion+1));	    rect.bottom = rect.top + height - (lip * (event.recursion+1) * 2);	    rect.left = big_rect.left + (long)(dx * (event.start_time - pDoc->m_dLeft));	    rect.right = rect.left + (long)(dx * (event.end_time - event.start_time));	    if (rect.left == rect.right) rect.right++;	    if (rect.right > big_rect.right)		rect.right = big_rect.right;	    white_brush.CreateStockObject(WHITE_BRUSH);	    pDC->FrameRect(&rect, &white_brush);	    // draw the current start time	    str.Format("%.0f", event.start_time);	    size = pDC->GetTextExtent(str);	    x = ((big_rect.left + big_rect.right) / 2) - size.cx;	    y = big_rect.bottom + 7;	    str.Format("%.3f", event.start_time);	    size = pDC->GetTextExtent(str);	    rgn.CreateRectRgn(x, y, x + size.cx, y + size.cy);	    pDC->SelectClipRgn(&rgn, RGN_COPY);	    str.Format("%.6f", event.start_time);	    pDC->SetTextColor(RGB(0,0,0));	    pDC->TextOut(x, y, str);	    rgn.CreateRectRgnIndirect(&client_rect);	    pDC->SelectClipRgn(&rgn, RGN_XOR);	    pDC->SetTextColor(RGB(255,0,0));	    pDC->TextOut(x, y, str);	    pDC->SetTextColor(RGB(0,0,0));	}	else	{	    str.Format("%.6f", (pDoc->m_dLeft + pDoc->m_dRight) / 2.0);	    size = pDC->GetTextExtent(str);	    pDC->TextOut(((big_rect.left + big_rect.right) / 2) - (size.cx / 2), big_rect.bottom + 7, str);	}	// draw the left and right timestamps	str.Format("%.6f", pDoc->m_dLeft);	pDC->TextOut(big_rect.left, big_rect.bottom + 7, str);	str.Format("%.6f", pDoc->m_dRight);	size = pDC->GetTextExtent(str);	pDC->TextOut(big_rect.right - size.cx, big_rect.bottom + 7, str);	delete pdNextPixel;	SetCursor(hOldCursor);    }}/////////////////////////////////////////////////////////////////////////////// CRimshotView printingBOOL CRimshotView::OnPreparePrinting(CPrintInfo* pInfo){    return DoPreparePrinting(pInfo);}void CRimshotView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/){}void CRimshotView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/){}void CRimshotView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) {    CView::OnPrepareDC(pDC, pInfo);        if (pDC->IsPrinting())    {	/*	CRect rect;	GetClientRect (&rect);		int oldMapMode = pDC->SetMapMode(MM_ISOTROPIC);	CSize ptOldWinExt = pDC->SetWindowExt(1000, 1000);	CSize ptOldViewportExt = pDC->SetViewportExt(rect.Width(), -rect.Height());	CPoint ptOldOrigin = pDC->SetViewportOrg(rect.Width()/2, rect.Height()/2);	*/    }}/////////////////////////////////////////////////////////////////////////////// CRimshotView diagnostics#ifdef _DEBUGvoid CRimshotView::AssertValid() const{	CView::AssertValid();}void CRimshotView::Dump(CDumpContext& dc) const{	CView::Dump(dc);}CRimshotDoc* CRimshotView::GetDocument() // non-debug version is inline{	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRimshotDoc)));	return (CRimshotDoc*)m_pDocument;}#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////// CRimshotView message handlersvoid CRimshotView::OnNext() {    double d;    RLOG_EVENT event1, event2;    CRimshotDoc* pDoc = GetDocument();    StopDrawing();    d = (pDoc->m_dRight - pDoc->m_dLeft) / 6.0;    RLOG_GetCurrentGlobalEvent(pDoc->m_pInput, &event1);    RLOG_FindGlobalEventBeforeTimestamp(pDoc->m_pInput, (pDoc->m_dLeft + pDoc->m_dRight) / 2.0 + d, &event2);    if (event1.start_time == event2.start_time)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -