1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "StandAloneDlg.h"
23 #include "XPImageButton.h"
25 #include "UnicodeUtils.h"
31 * \ingroup TortoiseProc
32 * Helper class for drawing and then saving the drawing to a meta file (wmf)
34 class CMyMetaFileDC
: public CMetaFileDC
37 HGDIOBJ
CMyMetaFileDC::SelectObject(HGDIOBJ hObject
)
39 return (hObject
!= NULL
) ? ::SelectObject(m_hDC
, hObject
) : NULL
;
44 * \ingroup TortoiseProc
45 * Helper dialog showing statistics gathered from the log messages shown in the
48 * The function GatherData() collects statistical information and stores it
49 * in the corresponding member variables. You can access the data as shown in
50 * the following examples:
52 * commits = m_commitsPerWeekAndAuthor[week_nr][author_name];
53 * filechanges = m_filechangesPerWeekAndAuthor[week_nr][author_name];
54 * commits = m_commitsPerAuthor[author_name];
58 class CStatGraphDlg
: public CResizableStandAloneDialog
//CResizableStandAloneDialog
60 DECLARE_DYNAMIC(CStatGraphDlg
)
63 CStatGraphDlg(CWnd
* pParent
= NULL
);
64 virtual ~CStatGraphDlg();
66 enum { IDD
= IDD_STATGRAPH
};
68 // Data passed from the caller of the dialog.
69 CDWordArray
* m_parDates
;
70 CDWordArray
* m_parFileChanges
;
71 CStringArray
* m_parAuthors
;
78 /// The types of units used in the various graphs.
87 /// The mapping type used to store data per interval/week and author.
88 typedef std::map
<int, std::map
<stdstring
, LONG
> > IntervalDataMap
;
89 /// The mapping type used to store data per author.
90 typedef std::map
<stdstring
, LONG
> AuthorDataMap
;
92 // *** Re-implemented member functions from CDialog
94 virtual void OnCancel();
96 virtual void DoDataExchange(CDataExchange
* pDX
);
97 virtual BOOL
OnInitDialog();
98 void ShowLabels(BOOL bShow
);
99 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
100 afx_msg
void OnCbnSelchangeGraphcombo();
101 afx_msg
void OnHScroll(UINT nSBCode
, UINT nPos
, CScrollBar
* pScrollBar
);
102 afx_msg
void OnBnClickedStacked();
103 afx_msg
void OnNeedText(NMHDR
*pnmh
, LRESULT
*pResult
);
104 afx_msg
void OnBnClickedGraphbarbutton();
105 afx_msg
void OnBnClickedGraphbarstackedbutton();
106 afx_msg
void OnBnClickedGraphlinebutton();
107 afx_msg
void OnBnClickedGraphlinestackedbutton();
108 afx_msg
void OnBnClickedGraphpiebutton();
109 afx_msg
void OnFileSavestatgraphas();
110 DECLARE_MESSAGE_MAP()
112 // ** Member functions **
114 /// Updates the variables m_weekCount and m_minDate and returns the number
115 /// of weeks in the revision interval.
116 void UpdateWeekCount();
117 /// Returns the week-of-the-year for the given time.
118 int GetCalendarWeek(const CTime
& time
);
119 /// Parses the data given to the dialog and generates mappings with statistical data.
121 /// Populates the lists passed as arguments based on the commit threshold set with the skipper.
122 void FilterSkippedAuthors(std::list
<stdstring
>& included_authors
, std::list
<stdstring
>& skipped_authors
);
123 /// Shows the graph with commit counts per author.
124 void ShowCommitsByAuthor();
125 /// Shows the graph with commit counts per author and date.
126 void ShowCommitsByDate();
127 /// Shows the initial statistics page.
131 /// Called when user checks/unchecks the "Authors case sensitive" checkbox.
132 /// Recalculates statistical data because the number and names of authors
133 /// can have changed. Also calls RedrawGraph().
134 void AuthorsCaseSensitiveChanged();
135 /// Called when user checks/unchecks the "Sort by commit count" checkbox.
136 /// Calls RedrawGraph().
137 void SortModeChanged();
138 /// Clears the current graph and frees all data series.
140 /// Updates the currently shown statistics page.
144 int GetUnit(const CTime
& time
);
145 CStatGraphDlg::UnitType
GetUnitType();
146 CString
GetUnitString();
147 CString
GetUnitLabel(int unit
, CTime
&lasttime
);
149 void EnableDisableMenu();
151 void SaveGraph(CString sFilename
);
152 int GetEncoderClsid(const WCHAR
* format
, CLSID
* pClsid
);
154 void StoreCurrentGraphType();
156 CPtrArray m_graphDataArray
;
158 CComboBox m_cGraphType
;
159 CSliderCtrl m_Skipper
;
160 BOOL m_bAuthorsCaseSensitive
;
161 BOOL m_bSortByCommitCount
;
163 CXPImageButton m_btnGraphBar
;
164 CXPImageButton m_btnGraphBarStacked
;
165 CXPImageButton m_btnGraphLine
;
166 CXPImageButton m_btnGraphLineStacked
;
167 CXPImageButton m_btnGraphPie
;
169 HICON m_hGraphBarIcon
;
170 HICON m_hGraphBarStackedIcon
;
171 HICON m_hGraphLineIcon
;
172 HICON m_hGraphLineStackedIcon
;
173 HICON m_hGraphPieIcon
;
175 MyGraph::GraphType m_GraphType
;
178 CToolTipCtrl
* m_pToolTip
;
182 // ** Member variables holding the statistical data **
184 /// Number of weeks in the revision interval.
186 /// The starting date/time for the revision interval.
187 __time64_t m_minDate
;
188 /// The ending date/time for the revision interval.
189 __time64_t m_maxDate
;
190 /// The total number of commits (equals size of the m_parXXX arrays).
191 INT_PTR m_nTotalCommits
;
192 /// The total number of file changes.
193 LONG m_nTotalFileChanges
;
194 /// Holds the number of commits per unit and author.
195 IntervalDataMap m_commitsPerUnitAndAuthor
;
196 /// Holds the number of file changes per unit and author.
197 IntervalDataMap m_filechangesPerUnitAndAuthor
;
198 /// First interval number (key) in the mappings.
200 /// Last interval number (key) in the mappings.
202 /// Mapping of total commits per author, access data via
203 AuthorDataMap m_commitsPerAuthor
;
204 /// The list of author names sorted based on commit count
205 /// (author with most commits is first in list).
206 std::list
<stdstring
> m_authorNames
;
207 /// unit names by week/month/quarter
208 std::map
<LONG
, stdstring
> m_unitNames
;