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