Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Comparer/FrmsInfoView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ BEGIN_MESSAGE_MAP(CFrmsInfoView, CView)
ON_WM_ERASEBKGND()
ON_WM_MOUSEWHEEL()
ON_WM_LBUTTONDBLCLK()
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()


Expand Down Expand Up @@ -211,3 +212,42 @@ void CFrmsInfoView::OnLButtonDblClk(UINT /*nFlags*/, CPoint point)
Invalidate(FALSE);
}
}

void CFrmsInfoView::OnLButtonDown(UINT nFlags, CPoint point)
{
if (!mGraphRect.PtInRect(point)) {
CView::OnLButtonDown(nFlags, point);
return;
}

CComparerDoc *pDoc = GetDocument();
if (pDoc->mMinFrames <= 0) {
CView::OnLButtonDown(nFlags, point);
return;
}

int graphX = point.x - mGraphRect.left - GRAPH_IN_MARGIN_L;
long frameID = mPsnrCal->FrameAtX(graphX);
if (frameID < 0) {
CView::OnLButtonDown(nFlags, point);
return;
}

pDoc->KillPlayTimer();
pDoc->SetScenes(frameID);

// Refresh the per-frame metric label shown in FrmInfoView for the new
// pair of frames.
IFrmCmpStrategy *compareStrategy = pDoc->mFrmCmpStrategy;
if (compareStrategy) {
CMainFrame *pMainFrm = static_cast<CMainFrame *>(AfxGetMainWnd());
ComparerPane *paneL = &pDoc->mPane[CComparerDoc::IMG_VIEW_1];
ComparerPane *paneR = &pDoc->mPane[CComparerDoc::IMG_VIEW_2];
compareStrategy->CalMetrics(paneL, paneR,
pMainFrm->mMetricIdx, pDoc->mFrmState);
}

pDoc->UpdateAllViews(NULL);

CView::OnLButtonDown(nFlags, point);
}
1 change: 1 addition & 0 deletions Comparer/FrmsInfoView.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class CFrmsInfoView : public CView
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};


23 changes: 23 additions & 0 deletions Comparer/MetricCal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,29 @@ void MetricCal::ZoomAtX(short zDelta, int graphX)
mViewEndFrame = mViewStartFrame + 1;
}

long MetricCal::FrameAtX(int graphX) const
{
if (mStepCount == 0 || mFrameIdx == 0)
return -1;
int graphW = getGraphW();
if (graphW <= 0)
return -1;

if (graphX < 0) graphX = 0;
if (graphX > graphW) graphX = graphW;

size_t viewSpan = mViewEndFrame > mViewStartFrame
? mViewEndFrame - mViewStartFrame : 1;
long frameID = long(mViewStartFrame)
+ long((size_t(graphX) * viewSpan) / size_t(graphW));

// Clamp to frames that actually have parsed metrics so far.
long maxFrame = long(mFrameIdx) - 1;
if (frameID > maxFrame) frameID = maxFrame;
if (frameID < 0) frameID = 0;
return frameID;
}

void MetricCal::CalMinMaxAccum()
{
size_t i;
Expand Down
3 changes: 3 additions & 0 deletions Comparer/MetricCal.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class MetricCal
void ZoomAtX(short zDelta, int graphX);
// Restore the X axis to cover the full parsed range.
void ResetView();
// Frame index at the given graph-area X pixel under the current view
// range. Returns -1 if no data is available.
long FrameAtX(int graphX) const;

void DrawCmpResult(CDC* pDC, CFont *font) const;
void DrawYLabel(CDC* pDC, CRect *yLabelRect, CFont *font) const;
Expand Down
20 changes: 13 additions & 7 deletions Comparer/PosInfoView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ void CPosInfoView::DrawEachRect(CDC* pDC,
{
CComparerDoc* pDoc = GetDocument();

bool isCurFrame = pane->isAvail() && (i == pane->curFrameID);
bool isLeftPane = (pane == &pDoc->mPane[CComparerDoc::IMG_VIEW_1]);

COLORREF frameColor;
if (!pane->isAvail()) {
if (isCurFrame) {
// Pane-specific highlight so left vs right is obvious at a glance.
frameColor = isLeftPane ? Q1UI_COLOR_ACCENT : Q1UI_COLOR_WARNING;
} else if (!pane->isAvail()) {
frameColor = Q1UI_COLOR_SURFACE;
} else if (parseDone) {
frameColor = Q1UI_COLOR_ACCENT_SOFT;
Expand All @@ -112,12 +118,12 @@ void CPosInfoView::DrawEachRect(CDC* pDC,
pDC->SelectObject(prev);
}

const COLORREF curIdColor = Q1UI_COLOR_ACCENT;
COLORREF preColor;
bool isCurFrame = i == pane->curFrameID;

if (isCurFrame)
preColor = pDC->SetTextColor(curIdColor);
COLORREF preColor = 0;
if (isCurFrame) {
// Use surface (near-white) on the saturated highlight fill for
// maximum contrast.
preColor = pDC->SetTextColor(Q1UI_COLOR_SURFACE);
}

CString numStr;
numStr.Format(_T("%d"), i);
Expand Down