2014-03-17 19:44:11 +00:00
|
|
|
// This file is part of BOINC.
|
2005-04-04 06:02:36 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2005-04-04 06:02:36 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2005-04-04 06:02:36 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-04-04 06:02:36 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2005-04-04 06:02:36 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
2005-04-04 06:50:42 +00:00
|
|
|
#pragma implementation "ViewStatistics.h"
|
2005-04-04 06:02:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "BOINCGUIApp.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "BOINCBaseFrame.h"
|
2005-04-04 06:02:36 +00:00
|
|
|
#include "MainDocument.h"
|
2006-06-24 05:00:57 +00:00
|
|
|
#include "AdvancedFrame.h"
|
2005-04-04 06:02:36 +00:00
|
|
|
#include "BOINCTaskCtrl.h"
|
|
|
|
#include "BOINCListCtrl.h"
|
|
|
|
#include "ViewStatistics.h"
|
|
|
|
#include "Events.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
2006-02-16 18:01:46 +00:00
|
|
|
#include "res/stats.xpm"
|
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
enum { // Command buttons (m_SelectedStatistic)
|
|
|
|
show_user_total = 0,
|
|
|
|
show_user_average,
|
|
|
|
show_host_total,
|
2014-08-10 22:33:07 +00:00
|
|
|
show_host_average,
|
|
|
|
n_command_buttons
|
2010-09-14 14:04:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum { // Mode buttons (m_ModeViewStatistic)
|
|
|
|
mode_one_project = 0,
|
|
|
|
mode_all_separate,
|
|
|
|
mode_all_together,
|
|
|
|
mode_sum
|
|
|
|
};
|
|
|
|
|
|
|
|
enum { // Project buttons
|
|
|
|
previous_project = 0,
|
|
|
|
next_project,
|
|
|
|
show_hide_project_list
|
|
|
|
};
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
BEGIN_EVENT_TABLE (CPaintStatistics, wxWindow)
|
|
|
|
EVT_PAINT(CPaintStatistics::OnPaint)
|
|
|
|
EVT_SIZE(CPaintStatistics::OnSize)
|
|
|
|
EVT_LEFT_DOWN(CPaintStatistics::OnLeftMouseDown)
|
2007-04-20 03:26:12 +00:00
|
|
|
EVT_LEFT_UP(CPaintStatistics::OnLeftMouseUp)
|
2006-12-01 20:51:37 +00:00
|
|
|
EVT_RIGHT_DOWN(CPaintStatistics::OnRightMouseDown)
|
2007-04-20 03:26:12 +00:00
|
|
|
EVT_RIGHT_UP(CPaintStatistics::OnRightMouseUp)
|
2006-12-01 20:51:37 +00:00
|
|
|
EVT_MOTION(CPaintStatistics::OnMouseMotion)
|
|
|
|
EVT_LEAVE_WINDOW(CPaintStatistics::OnMouseLeaveWindows)
|
|
|
|
EVT_ERASE_BACKGROUND(CPaintStatistics::OnEraseBackground)
|
2010-09-10 11:14:10 +00:00
|
|
|
EVT_SCROLL(CPaintStatistics::OnLegendScroll)
|
2005-04-04 06:02:36 +00:00
|
|
|
END_EVENT_TABLE ()
|
|
|
|
|
2010-09-10 11:29:44 +00:00
|
|
|
// Set USE_MEMORYDC FALSE to aid debugging
|
|
|
|
#define USE_MEMORYDC TRUE
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
CPaintStatistics::CPaintStatistics(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name
|
|
|
|
): wxWindow(parent, id, pos, size, style, name)
|
|
|
|
{ m_font_standart = *wxSWISS_FONT;
|
|
|
|
m_font_bold = *wxSWISS_FONT;
|
|
|
|
m_font_standart_italic = *wxSWISS_FONT;
|
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
m_SelectedStatistic = show_user_total;
|
2006-12-01 20:51:37 +00:00
|
|
|
heading = wxT("");
|
2010-09-14 14:04:59 +00:00
|
|
|
m_ModeViewStatistic = mode_one_project;
|
2006-12-01 20:51:37 +00:00
|
|
|
m_NextProjectStatistic = 0;
|
2007-01-09 20:43:21 +00:00
|
|
|
m_ViewHideProjectStatistic = -1;
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
m_GraphLineWidth = 2;
|
|
|
|
m_GraphPointWidth = 4;
|
|
|
|
|
2010-09-10 11:14:10 +00:00
|
|
|
m_Space_for_scrollbar = 0;
|
|
|
|
m_Num_projects = 0;
|
|
|
|
m_previous_SelProj = -1;
|
|
|
|
m_scrollBar = new wxScrollBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL);
|
|
|
|
int h;
|
|
|
|
m_scrollBar->GetSize(&m_Scrollbar_width, &h);
|
|
|
|
m_scrollBar->SetScrollbar(0, 1, 1, 1);
|
|
|
|
m_scrollBar->Hide();
|
2006-12-01 20:51:37 +00:00
|
|
|
m_Legend_Shift_Mode1 = 0;
|
|
|
|
m_Legend_Shift_Mode2 = 0;
|
|
|
|
|
|
|
|
m_GraphMarker_X1 = 0;
|
|
|
|
m_GraphMarker_Y1 = 0;
|
|
|
|
m_GraphMarker1 = false;
|
|
|
|
|
|
|
|
m_GraphZoom_X1 = 0;
|
|
|
|
m_GraphZoom_Y1 = 0;
|
|
|
|
m_GraphZoom_X2 = 0;
|
|
|
|
m_GraphZoom_Y2 = 0;
|
|
|
|
m_GraphZoom_X2_old = 0;
|
|
|
|
m_GraphZoom_Y2_old = 0;
|
|
|
|
|
|
|
|
m_GraphZoomStart = false;
|
|
|
|
|
2007-04-20 03:26:12 +00:00
|
|
|
m_GraphMove_X1 = 0;
|
|
|
|
m_GraphMove_Y1 = 0;
|
|
|
|
m_GraphMove_X2 = 0;
|
|
|
|
m_GraphMove_Y2 = 0;
|
|
|
|
m_GraphMoveStart = false;
|
|
|
|
m_GraphMoveGo = false;
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
m_Zoom_max_val_X = 0;
|
|
|
|
m_Zoom_min_val_X = 0;
|
|
|
|
m_Zoom_max_val_Y = 0;
|
|
|
|
m_Zoom_min_val_Y = 0;
|
|
|
|
m_Zoom_Auto = true;
|
|
|
|
|
|
|
|
// XY
|
|
|
|
m_main_X_start = 0;
|
|
|
|
m_main_X_end = 0;
|
|
|
|
m_main_Y_start = 0;
|
|
|
|
m_main_Y_end = 0;
|
|
|
|
|
|
|
|
m_WorkSpace_X_start = 0;
|
|
|
|
m_WorkSpace_X_end = 0;
|
|
|
|
m_WorkSpace_Y_start = 0;
|
|
|
|
m_WorkSpace_Y_end = 0;
|
|
|
|
|
|
|
|
m_Legend_X_start = 0;
|
|
|
|
m_Legend_X_end = 0;
|
|
|
|
m_Legend_Y_start = 0;
|
|
|
|
m_Legend_Y_end = 0;
|
|
|
|
|
|
|
|
m_Legend_select_X_start = 0;
|
|
|
|
m_Legend_select_X_end = 0;
|
|
|
|
m_Legend_select_Y_start = 0;
|
|
|
|
m_Legend_select_Y_end = 0;
|
|
|
|
|
|
|
|
m_Graph_X_start = 0;
|
|
|
|
m_Graph_X_end = 0;
|
|
|
|
m_Graph_Y_start = 0;
|
|
|
|
m_Graph_Y_end = 0;
|
|
|
|
|
|
|
|
m_Graph_draw_X_start = 0;
|
|
|
|
m_Graph_draw_X_end = 0;
|
|
|
|
m_Graph_draw_Y_start = 0;
|
|
|
|
m_Graph_draw_Y_end = 0;
|
|
|
|
|
|
|
|
m_Legend_dY = 0;
|
2007-04-20 03:26:12 +00:00
|
|
|
m_LegendDraw = true;
|
2006-12-01 20:51:37 +00:00
|
|
|
|
|
|
|
// Default colours
|
|
|
|
m_pen_MarkerLineColour = wxColour(0, 0, 0);
|
|
|
|
m_pen_ZoomRectColour = wxColour (128, 64, 95);
|
|
|
|
m_brush_ZoomRectColour = wxColour(24, 31, 0);
|
|
|
|
m_brush_AxisColour = wxColour(192, 224, 255);
|
|
|
|
m_pen_AxisColour = wxColour(64, 128, 192);
|
2007-04-20 03:26:12 +00:00
|
|
|
m_pen_AxisColourZoom = wxColour(255, 64, 0);
|
|
|
|
m_pen_AxisColourAutoZoom = wxColour(64, 128, 192);
|
2006-12-01 20:51:37 +00:00
|
|
|
m_pen_AxisXColour = wxColour(64, 128, 192);
|
|
|
|
m_pen_AxisYColour = wxColour(64, 128, 192);
|
|
|
|
m_pen_AxisXTextColour = wxColour(0, 0, 0);
|
|
|
|
m_pen_AxisYTextColour = wxColour(0, 0, 0);
|
2006-11-03 19:33:53 +00:00
|
|
|
|
2007-01-09 20:43:21 +00:00
|
|
|
m_brush_LegendColour = wxColour(235, 255, 255);//wxColour(220, 240, 255);
|
2006-12-01 20:51:37 +00:00
|
|
|
m_brush_LegendSelectColour = wxColour(192, 224, 255);
|
|
|
|
m_pen_LegendSelectColour = wxColour(64, 128, 192);
|
|
|
|
m_pen_LegendSelectTextColour = wxColour(0, 0, 0);
|
|
|
|
m_pen_LegendColour = wxColour(64, 128, 192);
|
|
|
|
m_pen_LegendTextColour = wxColour(0, 0, 0);
|
2006-11-03 19:33:53 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
m_brush_MainColour = wxColour(255, 255, 255);
|
|
|
|
m_pen_MainColour = wxColour(64, 128, 192);
|
2006-11-03 19:33:53 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
m_pen_HeadTextColour = wxColour(0, 0, 0);
|
|
|
|
m_pen_ProjectHeadTextColour = wxColour(0, 0, 0);
|
2006-11-03 19:33:53 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
m_pen_GraphTotalColour = wxColour(255, 0, 0);
|
|
|
|
m_pen_GraphRACColour = wxColour(0, 160, 0);
|
|
|
|
m_pen_GraphTotalHostColour = wxColour(0, 0, 255);
|
|
|
|
m_pen_GraphRACHostColour = wxColour(0, 0, 0);
|
|
|
|
|
|
|
|
m_dc_bmp.Create(1, 1);
|
|
|
|
m_full_repaint = true;
|
|
|
|
m_bmp_OK = false;
|
2013-10-24 12:49:59 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
m_fauxStatisticsView = NULL;
|
|
|
|
SetupMacAccessibilitySupport();
|
|
|
|
#endif
|
2005-04-04 06:02:36 +00:00
|
|
|
}
|
2010-09-10 11:14:10 +00:00
|
|
|
|
|
|
|
CPaintStatistics::~CPaintStatistics() {
|
|
|
|
if (m_scrollBar) {
|
|
|
|
delete m_scrollBar;
|
|
|
|
}
|
2013-10-24 12:49:59 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
RemoveMacAccessibilitySupport();
|
|
|
|
#endif
|
2010-09-10 11:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
static void getTypePoint(int &typePoint, int number) {typePoint = number / 10;}
|
|
|
|
|
|
|
|
static bool CrossTwoLine(const double X1_1, const double Y1_1, const double X1_2, const double Y1_2,
|
|
|
|
const double X2_1, const double Y2_1, const double X2_2, const double Y2_2,
|
|
|
|
double &Xcross, double &Ycross) {
|
|
|
|
double A1 = Y1_1 - Y1_2;
|
|
|
|
double B1 = X1_2 - X1_1;
|
|
|
|
double C1 = - X1_1 * A1 - Y1_1 * B1;
|
|
|
|
double A2 = Y2_1 - Y2_2;
|
|
|
|
double B2 = X2_2 - X2_1;
|
|
|
|
double C2 = - X2_1 * A2 - Y2_1 * B2;
|
|
|
|
double tmp1 = (A1 * B2 - A2 * B1);
|
|
|
|
if (0 == tmp1){
|
|
|
|
Xcross = 0;
|
|
|
|
Ycross = 0;
|
|
|
|
return false;
|
|
|
|
}else{
|
|
|
|
Xcross = (B1 * C2 - B2 * C1) / tmp1;
|
|
|
|
Ycross = (C1 * A2 - C2 * A1) / tmp1;
|
|
|
|
return true;
|
|
|
|
}
|
2006-01-20 22:57:32 +00:00
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
|
2006-01-20 22:57:32 +00:00
|
|
|
//----Draw "Point"
|
2006-12-01 20:51:37 +00:00
|
|
|
static void myDrawPoint(wxDC &dc,int X, int Y, wxColour graphColour,int numberTypePoint, int PointWidth) {
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetPen(wxPen(graphColour , 1 , wxSOLID));
|
2006-12-01 20:51:37 +00:00
|
|
|
switch (numberTypePoint % 5){
|
2006-01-20 22:57:32 +00:00
|
|
|
case 1: {wxPoint* points = new wxPoint[3];
|
2006-12-01 20:51:37 +00:00
|
|
|
points[0] = wxPoint(X, Y - 1 - (PointWidth / 2));
|
|
|
|
points[1] = wxPoint(X + (PointWidth / 2), Y + (PointWidth / 2));
|
|
|
|
points[2] = wxPoint(X - (PointWidth / 2), Y + (PointWidth / 2));
|
2006-01-20 22:57:32 +00:00
|
|
|
dc.DrawPolygon(3, points);
|
|
|
|
delete[] points;
|
|
|
|
break;}
|
|
|
|
case 2: {wxPoint* points = new wxPoint[3];
|
2006-12-01 20:51:37 +00:00
|
|
|
points[0] = wxPoint(X, Y + 1 + (PointWidth / 2));
|
|
|
|
points[1] = wxPoint(X + (PointWidth / 2), Y - (PointWidth / 2));
|
|
|
|
points[2] = wxPoint(X - (PointWidth / 2), Y - (PointWidth / 2));
|
2006-01-20 22:57:32 +00:00
|
|
|
dc.DrawPolygon(3, points);
|
|
|
|
delete[] points;
|
|
|
|
break;}
|
2006-12-01 20:51:37 +00:00
|
|
|
case 3: dc.DrawRectangle(wxCoord(X - (PointWidth / 2)),wxCoord(Y - (PointWidth / 2)),wxCoord(PointWidth + 1),wxCoord(PointWidth + 1));
|
2006-01-20 22:57:32 +00:00
|
|
|
break;
|
2006-12-01 20:51:37 +00:00
|
|
|
case 4: {wxPoint* points = new wxPoint[4];
|
|
|
|
points[0] = wxPoint(X, Y - 1 - (PointWidth / 2));
|
|
|
|
points[1] = wxPoint(X + 1 + (PointWidth / 2), Y);
|
|
|
|
points[2] = wxPoint(X, Y + 1 + (PointWidth / 2));
|
|
|
|
points[3] = wxPoint(X - 1 - (PointWidth / 2), Y);
|
|
|
|
dc.DrawPolygon(4, points);
|
|
|
|
delete[] points;
|
|
|
|
break;}
|
|
|
|
default:dc.DrawCircle(wxCoord(X), wxCoord(Y), wxCoord(PointWidth / 2));
|
2006-01-20 22:57:32 +00:00
|
|
|
}
|
|
|
|
}
|
2005-12-08 19:21:56 +00:00
|
|
|
//----Find minimum/maximum value----
|
2006-12-01 20:51:37 +00:00
|
|
|
static void MinMaxDayCredit(std::vector<PROJECT*>::const_iterator &i, double &min_credit, double &max_credit, double &min_day, double &max_day, const int m_SelectedStatistic, bool first = true) {
|
|
|
|
for (std::vector<DAILY_STATS>::const_iterator j = (*i)->statistics.begin(); j != (*i)->statistics.end(); ++j) {
|
|
|
|
if (first){
|
|
|
|
max_day = j->day;
|
|
|
|
switch (m_SelectedStatistic){
|
2010-09-14 14:04:59 +00:00
|
|
|
case show_user_total: max_credit = j->user_total_credit; break;
|
|
|
|
case show_user_average: max_credit = j->user_expavg_credit; break;
|
|
|
|
case show_host_total: max_credit = j->host_total_credit; break;
|
|
|
|
case show_host_average: max_credit = j->host_expavg_credit; break;
|
2006-12-01 20:51:37 +00:00
|
|
|
default: max_credit = 0.0;
|
|
|
|
}
|
|
|
|
min_day = max_day;
|
|
|
|
min_credit = max_credit;
|
|
|
|
first = false;
|
|
|
|
} else {
|
|
|
|
if (j->day < min_day) min_day = j->day;
|
|
|
|
if (j->day > max_day) max_day = j->day;
|
|
|
|
|
|
|
|
switch (m_SelectedStatistic){
|
2010-09-14 14:04:59 +00:00
|
|
|
case show_user_total:
|
2006-12-01 20:51:37 +00:00
|
|
|
if (j->user_total_credit > max_credit) max_credit = j->user_total_credit;
|
|
|
|
if (j->user_total_credit < min_credit) min_credit = j->user_total_credit;
|
|
|
|
break;
|
2010-09-14 14:04:59 +00:00
|
|
|
case show_user_average:
|
2006-12-01 20:51:37 +00:00
|
|
|
if (j->user_expavg_credit > max_credit) max_credit = j->user_expavg_credit;
|
|
|
|
if (j->user_expavg_credit < min_credit) min_credit = j->user_expavg_credit;
|
|
|
|
break;
|
2010-09-14 14:04:59 +00:00
|
|
|
case show_host_total:
|
2006-12-01 20:51:37 +00:00
|
|
|
if (j->host_total_credit > max_credit) max_credit = j->host_total_credit;
|
|
|
|
if (j->host_total_credit < min_credit) min_credit = j->host_total_credit;
|
|
|
|
break;
|
2010-09-14 14:04:59 +00:00
|
|
|
case show_host_average:
|
2006-12-01 20:51:37 +00:00
|
|
|
if (j->host_expavg_credit > max_credit) max_credit = j->host_expavg_credit;
|
|
|
|
if (j->host_expavg_credit < min_credit) min_credit = j->host_expavg_credit;
|
|
|
|
break;
|
|
|
|
}
|
2005-12-08 19:21:56 +00:00
|
|
|
}
|
|
|
|
}
|
2006-01-20 22:57:32 +00:00
|
|
|
}
|
|
|
|
static void CheckMinMaxD(double &min_val, double &max_val) {
|
2006-12-01 20:51:37 +00:00
|
|
|
if (min_val > max_val) min_val = max_val;
|
2007-04-20 03:26:12 +00:00
|
|
|
if (max_val == min_val){
|
|
|
|
max_val += 0.5;
|
|
|
|
min_val -= 0.5;
|
|
|
|
}
|
2006-01-20 22:57:32 +00:00
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
void CPaintStatistics::ClearXY(){
|
|
|
|
m_main_X_start = 0;
|
|
|
|
m_main_X_end = 0;
|
|
|
|
m_main_Y_start = 0;
|
|
|
|
m_main_Y_end = 0;
|
|
|
|
|
|
|
|
m_WorkSpace_X_start = 0;
|
|
|
|
m_WorkSpace_X_end = 0;
|
|
|
|
m_WorkSpace_Y_start = 0;
|
|
|
|
m_WorkSpace_Y_end = 0;
|
|
|
|
|
|
|
|
m_Graph_X_start = 0;
|
|
|
|
m_Graph_X_end = 0;
|
|
|
|
m_Graph_Y_start = 0;
|
|
|
|
m_Graph_Y_end = 0;
|
|
|
|
|
|
|
|
m_Graph_draw_X_start = 0;
|
|
|
|
m_Graph_draw_X_end = 0;
|
|
|
|
m_Graph_draw_Y_start = 0;
|
|
|
|
m_Graph_draw_Y_end = 0;
|
2007-04-20 03:26:12 +00:00
|
|
|
}
|
|
|
|
void CPaintStatistics::ClearLegendXY(){
|
|
|
|
|
|
|
|
m_Legend_X_start = 0;
|
|
|
|
m_Legend_X_end = 0;
|
|
|
|
m_Legend_Y_start = 0;
|
|
|
|
m_Legend_Y_end = 0;
|
|
|
|
|
|
|
|
m_Legend_select_X_start = 0;
|
|
|
|
m_Legend_select_X_end = 0;
|
|
|
|
m_Legend_select_Y_start = 0;
|
|
|
|
m_Legend_select_Y_end = 0;
|
2006-12-01 20:51:37 +00:00
|
|
|
|
|
|
|
m_Legend_dY = 0;
|
|
|
|
}
|
|
|
|
void CPaintStatistics::AB(const double x_coord1, const double y_coord1, const double x_coord2, const double y_coord2, const double x_val1, const double y_val1, const double x_val2, const double y_val2){
|
|
|
|
// Val -> Coord
|
|
|
|
if (0.0 == (x_val2 - x_val1)){
|
|
|
|
m_Ax_ValToCoord = 0.0;
|
|
|
|
m_Bx_ValToCoord = 0.0;
|
|
|
|
}else{
|
|
|
|
m_Ax_ValToCoord = (x_coord2 - x_coord1) / (x_val2 - x_val1);
|
|
|
|
m_Bx_ValToCoord = x_coord1 - (m_Ax_ValToCoord * x_val1);
|
|
|
|
}
|
|
|
|
if (0.0 == (y_val2 - y_val1)){
|
|
|
|
m_Ay_ValToCoord = 0.0;
|
|
|
|
m_By_ValToCoord = 0.0;
|
|
|
|
}else{
|
|
|
|
m_Ay_ValToCoord = (y_coord2 - y_coord1) / (y_val2 - y_val1);
|
|
|
|
m_By_ValToCoord = y_coord1 - (m_Ay_ValToCoord * y_val1);
|
|
|
|
}
|
|
|
|
// Coord -> Val
|
|
|
|
if (0.0 == (x_coord2 - x_coord1)){
|
|
|
|
m_Ax_CoordToVal = 0.0;
|
|
|
|
m_Bx_CoordToVal = 0.0;
|
|
|
|
}else{
|
|
|
|
m_Ax_CoordToVal = (x_val2 - x_val1) / (x_coord2 - x_coord1);
|
|
|
|
m_Bx_CoordToVal = x_val1 - (m_Ax_CoordToVal * x_coord1);
|
|
|
|
}
|
|
|
|
if (0.0 == (y_coord2 - y_coord1)){
|
|
|
|
m_Ay_CoordToVal = 0.0;
|
|
|
|
m_By_CoordToVal = 0.0;
|
|
|
|
}else{
|
|
|
|
m_Ay_CoordToVal = (y_val2 - y_val1) / (y_coord2 - y_coord1);
|
|
|
|
m_By_CoordToVal = y_val1 - (m_Ay_CoordToVal * y_coord1);
|
|
|
|
}
|
2005-12-08 19:21:56 +00:00
|
|
|
}
|
2010-09-15 08:57:11 +00:00
|
|
|
|
|
|
|
void CPaintStatistics::AddToStats(const DAILY_STATS &src, DAILY_STATS &dst) {
|
|
|
|
dst.user_total_credit += src.user_total_credit;
|
|
|
|
dst.user_expavg_credit += src.user_expavg_credit;
|
|
|
|
dst.host_total_credit += src.host_total_credit;
|
|
|
|
dst.host_expavg_credit += src.host_expavg_credit;
|
|
|
|
}
|
|
|
|
|
2006-01-20 22:57:32 +00:00
|
|
|
//----Draw Main Head----
|
2006-12-01 20:51:37 +00:00
|
|
|
void CPaintStatistics::DrawMainHead(wxDC &dc, const wxString head_name){
|
|
|
|
wxCoord w_temp = 0, h_temp = 0, des_temp = 0, lead_temp = 0;
|
2006-01-20 22:57:32 +00:00
|
|
|
dc.GetTextExtent(head_name, &w_temp, &h_temp, &des_temp, &lead_temp);
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetTextForeground (m_pen_HeadTextColour);
|
2006-12-01 20:51:37 +00:00
|
|
|
wxCoord x0 = wxCoord(m_WorkSpace_X_start + ((m_WorkSpace_X_end - m_WorkSpace_X_start - double(w_temp)) / 2.0));
|
|
|
|
wxCoord y0 = wxCoord(m_WorkSpace_Y_start + 1.0);
|
|
|
|
if (x0 > wxCoord(m_WorkSpace_X_end)) x0 = wxCoord(m_WorkSpace_X_end);
|
|
|
|
if (x0 < wxCoord(m_WorkSpace_X_start)) x0 = wxCoord(m_WorkSpace_X_start);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 > wxCoord(m_WorkSpace_Y_end)) y0 = wxCoord(m_WorkSpace_Y_end);
|
|
|
|
if (y0 < wxCoord(m_WorkSpace_Y_start)) y0 = wxCoord(m_WorkSpace_Y_start);
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
dc.DrawText (head_name, x0, y0);
|
|
|
|
m_WorkSpace_Y_start += double(h_temp) + 2.0;
|
|
|
|
if (m_WorkSpace_Y_start > m_WorkSpace_Y_end) m_WorkSpace_Y_start = m_WorkSpace_Y_end;
|
|
|
|
if (m_WorkSpace_Y_start < 0.0) m_WorkSpace_Y_start = 0.0;
|
|
|
|
}
|
2006-11-03 19:33:53 +00:00
|
|
|
//----Draw Project Head----
|
2007-04-20 03:26:12 +00:00
|
|
|
void CPaintStatistics::DrawProjectHead(wxDC &dc, PROJECT* project1, const wxString head_name_last){
|
2006-12-01 20:51:37 +00:00
|
|
|
wxCoord w_temp = 0, h_temp = 0, des_temp = 0, lead_temp = 0;
|
|
|
|
wxString head_name = wxT("");
|
|
|
|
wxCoord x0 = 0;
|
|
|
|
wxCoord y0 = 0;
|
2006-11-03 19:33:53 +00:00
|
|
|
|
|
|
|
if (project1) {
|
2006-12-01 20:51:37 +00:00
|
|
|
head_name = wxString(_("Project")) + wxT(": ") + wxString(project1->project_name.c_str(), wxConvUTF8);
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.GetTextExtent(head_name, &w_temp, &h_temp, &des_temp, &lead_temp);
|
2006-12-01 20:51:37 +00:00
|
|
|
x0 = wxCoord(m_WorkSpace_X_start + ((m_WorkSpace_X_end - m_WorkSpace_X_start - double(w_temp)) / 2.0));
|
|
|
|
y0 = wxCoord(m_WorkSpace_Y_start + 1.0);
|
|
|
|
if (x0 > wxCoord(m_WorkSpace_X_end)) x0 = wxCoord(m_WorkSpace_X_end);
|
|
|
|
if (x0 < wxCoord(m_WorkSpace_X_start)) x0 = wxCoord(m_WorkSpace_X_start);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 > wxCoord(m_WorkSpace_Y_end)) y0 = wxCoord(m_WorkSpace_Y_end);
|
|
|
|
if (y0 < wxCoord(m_WorkSpace_Y_start)) y0 = wxCoord(m_WorkSpace_Y_start);
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
dc.DrawText (head_name, x0, y0);
|
|
|
|
m_WorkSpace_Y_start += double(h_temp) + 2.0;
|
|
|
|
if (m_WorkSpace_Y_start > m_WorkSpace_Y_end) m_WorkSpace_Y_start = m_WorkSpace_Y_end;
|
|
|
|
if (m_WorkSpace_Y_start < 0.0) m_WorkSpace_Y_start = 0.0;
|
|
|
|
|
|
|
|
head_name = wxString(_("Account")) + wxT(": ") + wxString(project1->user_name.c_str(), wxConvUTF8);
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.GetTextExtent(head_name, &w_temp, &h_temp, &des_temp, &lead_temp);
|
2006-12-01 20:51:37 +00:00
|
|
|
x0 = wxCoord(m_WorkSpace_X_start + ((m_WorkSpace_X_end - m_WorkSpace_X_start - double(w_temp)) / 2.0));
|
|
|
|
y0 = wxCoord(m_WorkSpace_Y_start + 1.0);
|
|
|
|
if (x0 > wxCoord(m_WorkSpace_X_end)) x0 = wxCoord(m_WorkSpace_X_end);
|
|
|
|
if (x0 < wxCoord(m_WorkSpace_X_start)) x0 = wxCoord(m_WorkSpace_X_start);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 > wxCoord(m_WorkSpace_Y_end)) y0 = wxCoord(m_WorkSpace_Y_end);
|
|
|
|
if (y0 < wxCoord(m_WorkSpace_Y_start)) y0 = wxCoord(m_WorkSpace_Y_start);
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
dc.DrawText (head_name, x0, y0);
|
|
|
|
m_WorkSpace_Y_start += double(h_temp) + 2.0;
|
|
|
|
if (m_WorkSpace_Y_start > m_WorkSpace_Y_end) m_WorkSpace_Y_start = m_WorkSpace_Y_end;
|
|
|
|
if (m_WorkSpace_Y_start < 0.0) m_WorkSpace_Y_start = 0.0;
|
|
|
|
|
|
|
|
head_name = wxString(_("Team")) + wxT(": ") + wxString(project1->team_name.c_str(), wxConvUTF8);
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.GetTextExtent(head_name, &w_temp, &h_temp, &des_temp, &lead_temp);
|
2006-12-01 20:51:37 +00:00
|
|
|
x0 = wxCoord(m_WorkSpace_X_start + ((m_WorkSpace_X_end - m_WorkSpace_X_start - double(w_temp)) / 2.0));
|
|
|
|
y0 = wxCoord(m_WorkSpace_Y_start + 1.0);
|
|
|
|
if (x0 > wxCoord(m_WorkSpace_X_end)) x0 = wxCoord(m_WorkSpace_X_end);
|
|
|
|
if (x0 < wxCoord(m_WorkSpace_X_start)) x0 = wxCoord(m_WorkSpace_X_start);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 > wxCoord(m_WorkSpace_Y_end)) y0 = wxCoord(m_WorkSpace_Y_end);
|
|
|
|
if (y0 < wxCoord(m_WorkSpace_Y_start)) y0 = wxCoord(m_WorkSpace_Y_start);
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
dc.DrawText (head_name, x0, y0);
|
|
|
|
m_WorkSpace_Y_start += double(h_temp) + 2.0;
|
|
|
|
if (m_WorkSpace_Y_start > m_WorkSpace_Y_end) m_WorkSpace_Y_start = m_WorkSpace_Y_end;
|
|
|
|
if (m_WorkSpace_Y_start < 0.0) m_WorkSpace_Y_start = 0.0;
|
2006-11-03 19:33:53 +00:00
|
|
|
|
|
|
|
dc.GetTextExtent(head_name_last, &w_temp, &h_temp, &des_temp, &lead_temp);
|
2006-12-01 20:51:37 +00:00
|
|
|
x0 = wxCoord(m_WorkSpace_X_start + ((m_WorkSpace_X_end - m_WorkSpace_X_start - double(w_temp)) / 2.0));
|
|
|
|
y0 = wxCoord(m_WorkSpace_Y_start + 1.0);
|
|
|
|
if (x0 > wxCoord(m_WorkSpace_X_end)) x0 = wxCoord(m_WorkSpace_X_end);
|
|
|
|
if (x0 < wxCoord(m_WorkSpace_X_start)) x0 = wxCoord(m_WorkSpace_X_start);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 > wxCoord(m_WorkSpace_Y_end)) y0 = wxCoord(m_WorkSpace_Y_end);
|
|
|
|
if (y0 < wxCoord(m_WorkSpace_Y_start)) y0 = wxCoord(m_WorkSpace_Y_start);
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
dc.DrawText (head_name_last, x0, y0);
|
|
|
|
m_WorkSpace_Y_start += double(h_temp) + 2.0;
|
|
|
|
if (m_WorkSpace_Y_start > m_WorkSpace_Y_end) m_WorkSpace_Y_start = m_WorkSpace_Y_end;
|
|
|
|
if (m_WorkSpace_Y_start < 0.0) m_WorkSpace_Y_start = 0.0;
|
2006-11-03 19:33:53 +00:00
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
}
|
2006-01-20 22:57:32 +00:00
|
|
|
//----Draw Legend----
|
2007-04-20 03:26:12 +00:00
|
|
|
void CPaintStatistics::DrawLegend(wxDC &dc, PROJECTS* proj, CMainDocument* pDoc, int SelProj, bool bColour, int &m_Legend_Shift){
|
2006-12-01 20:51:37 +00:00
|
|
|
wxString head_name = wxT("0");
|
|
|
|
wxCoord project_name_max_width = 0;
|
|
|
|
const double radius1 = 5;
|
|
|
|
const wxCoord buffer_y1 = 3;
|
|
|
|
const wxCoord buffer_x1 = 3;
|
|
|
|
int count = -1;
|
2014-06-05 11:15:19 +00:00
|
|
|
// int project_count = -1;
|
2006-12-01 20:51:37 +00:00
|
|
|
wxCoord w_temp = 0, h_temp = 0, des_temp = 0, lead_temp = 0;
|
|
|
|
wxCoord x0 = 0;
|
|
|
|
wxCoord y0 = 0;
|
|
|
|
wxCoord h0 = 0;
|
|
|
|
wxCoord w0 = 0;
|
2010-09-10 11:14:10 +00:00
|
|
|
wxCoord totalTextAreaHeight = 0;
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
dc.SetFont(m_font_bold);
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.GetTextExtent(head_name, &w_temp, &h_temp, &des_temp, &lead_temp);
|
2006-12-01 20:51:37 +00:00
|
|
|
m_Legend_dY = (double)(h_temp) + 4.0;
|
|
|
|
if (m_Legend_dY < 0) m_Legend_dY = 0;
|
2006-11-03 19:33:53 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
2006-01-20 22:57:32 +00:00
|
|
|
++count;
|
2006-11-03 19:33:53 +00:00
|
|
|
PROJECT* state_project = pDoc->state.lookup_project((*i)->master_url);
|
2006-12-01 20:51:37 +00:00
|
|
|
if (state_project) head_name = wxString(state_project->project_name.c_str(), wxConvUTF8);
|
2006-01-20 22:57:32 +00:00
|
|
|
dc.GetTextExtent(head_name, &w_temp, &h_temp, &des_temp, &lead_temp);
|
2006-12-01 20:51:37 +00:00
|
|
|
if (project_name_max_width < w_temp) project_name_max_width = w_temp;
|
2006-01-20 22:57:32 +00:00
|
|
|
}
|
2010-09-10 11:14:10 +00:00
|
|
|
m_Num_projects = count + 1;
|
2007-01-09 20:43:21 +00:00
|
|
|
project_name_max_width += wxCoord(8) + buffer_x1 + buffer_x1 + wxCoord(m_GraphPointWidth) + wxCoord(2);
|
2006-12-01 20:51:37 +00:00
|
|
|
if (project_name_max_width < 0) project_name_max_width = 0;
|
2010-09-10 11:14:10 +00:00
|
|
|
totalTextAreaHeight = (m_Num_projects * m_Legend_dY);
|
2006-12-01 20:51:37 +00:00
|
|
|
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetBrush(wxBrush(m_brush_LegendColour , wxSOLID));
|
|
|
|
dc.SetPen(wxPen(m_pen_LegendColour , 1 , wxSOLID));
|
2006-12-01 20:51:37 +00:00
|
|
|
y0 = wxCoord(m_WorkSpace_Y_start) + buffer_y1;
|
|
|
|
if (y0 > wxCoord(m_WorkSpace_Y_end)) y0 = wxCoord(m_WorkSpace_Y_end);
|
|
|
|
if (y0 < wxCoord(m_WorkSpace_Y_start)) y0 = wxCoord(m_WorkSpace_Y_start);
|
|
|
|
if (y0 < 0) y0 = 0;
|
2010-09-10 11:14:10 +00:00
|
|
|
w0 = project_name_max_width - buffer_x1 - buffer_x1;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (w0 < 0) w0 = 0;
|
2010-09-10 11:14:10 +00:00
|
|
|
h0 = wxCoord(m_WorkSpace_Y_end - m_WorkSpace_Y_start) - buffer_y1 - buffer_y1;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (h0 < 0) h0 = 0;
|
2010-09-10 11:14:10 +00:00
|
|
|
|
|
|
|
m_Space_for_scrollbar = 0;
|
|
|
|
if (h0 < (totalTextAreaHeight + (2 * radius1))) m_Space_for_scrollbar = m_Scrollbar_width;
|
|
|
|
int numVisible = (h0 - (2 * radius1)) / m_Legend_dY;
|
|
|
|
int numSteps = m_Num_projects - numVisible + 1;
|
|
|
|
if (numSteps < 2) {
|
|
|
|
m_scrollBar->Hide();
|
|
|
|
} else {
|
|
|
|
m_scrollBar->SetSize(m_WorkSpace_X_end - m_Scrollbar_width, m_WorkSpace_Y_start, m_Scrollbar_width, m_WorkSpace_Y_end - m_WorkSpace_Y_start, 0);
|
|
|
|
m_scrollBar->SetScrollbar(m_scrollBar->GetThumbPosition(), 1, numSteps, 1);
|
|
|
|
m_scrollBar->Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
x0 = wxCoord(m_WorkSpace_X_end) - project_name_max_width + buffer_x1 - m_Space_for_scrollbar;
|
|
|
|
if (x0 > wxCoord(m_WorkSpace_X_end)) x0 = wxCoord(m_WorkSpace_X_end);
|
|
|
|
if (x0 < wxCoord(m_WorkSpace_X_start)) x0 = wxCoord(m_WorkSpace_X_start);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
dc.DrawRoundedRectangle(x0, y0, w0, h0, radius1);
|
|
|
|
|
|
|
|
m_Legend_X_start = double(x0);
|
|
|
|
m_Legend_X_end = double(x0 + w0);
|
|
|
|
m_Legend_Y_start = double(y0);
|
|
|
|
m_Legend_Y_end = double(y0 + h0);
|
|
|
|
if (m_Legend_X_end > m_WorkSpace_X_end) m_Legend_X_end = m_WorkSpace_X_end;
|
|
|
|
if (m_Legend_Y_end > m_WorkSpace_Y_end) m_Legend_Y_end = m_WorkSpace_Y_end;
|
|
|
|
if (m_Legend_X_start > m_Legend_X_end) m_Legend_X_start = m_Legend_X_end;
|
|
|
|
if (m_Legend_Y_start > m_Legend_Y_end) m_Legend_Y_start = m_Legend_Y_end;
|
|
|
|
|
|
|
|
m_Legend_select_X_start = m_Legend_X_start;
|
|
|
|
m_Legend_select_X_end = m_Legend_X_end;
|
|
|
|
m_Legend_select_Y_start = m_Legend_Y_start + radius1;
|
|
|
|
m_Legend_select_Y_end = m_Legend_Y_end - radius1;
|
|
|
|
if (m_Legend_select_Y_start < 0.0) m_Legend_select_Y_start = 0.0;
|
|
|
|
if (m_Legend_select_Y_end < 0.0) m_Legend_select_Y_end = 0.0;
|
|
|
|
if (m_Legend_select_Y_start > m_Legend_select_Y_end) m_Legend_select_Y_start = m_Legend_select_Y_end;
|
|
|
|
|
|
|
|
// Legend Shift (start)
|
|
|
|
int Legend_count_temp = 0;
|
|
|
|
if (m_Legend_dY > 0) Legend_count_temp = int(floor((m_Legend_select_Y_end - m_Legend_select_Y_start) / m_Legend_dY));
|
|
|
|
|
2010-09-10 11:14:10 +00:00
|
|
|
if (numSteps > 1) {
|
|
|
|
m_Legend_Shift = m_scrollBar->GetThumbPosition();
|
|
|
|
} else {
|
|
|
|
m_Legend_Shift = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((SelProj >= 0) && (m_previous_SelProj != SelProj)) {
|
|
|
|
m_previous_SelProj = SelProj;
|
2007-01-09 20:43:21 +00:00
|
|
|
if (Legend_count_temp <= 0){
|
|
|
|
m_Legend_Shift = SelProj;
|
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
else {
|
|
|
|
if (SelProj < m_Legend_Shift) m_Legend_Shift = SelProj;
|
|
|
|
if (SelProj >= (m_Legend_Shift + Legend_count_temp)) m_Legend_Shift = SelProj - Legend_count_temp + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((m_Legend_Shift + Legend_count_temp) > count) m_Legend_Shift = count - Legend_count_temp + 1;
|
|
|
|
|
|
|
|
if (m_Legend_Shift > count) m_Legend_Shift = count; //???
|
|
|
|
if (m_Legend_Shift < 0) m_Legend_Shift = 0;
|
2010-09-10 11:14:10 +00:00
|
|
|
m_scrollBar->SetThumbPosition(m_Legend_Shift);
|
2006-12-01 20:51:37 +00:00
|
|
|
// Legend Shift (end)
|
|
|
|
//---------------
|
2014-06-05 11:15:19 +00:00
|
|
|
// project_count = count;
|
2006-12-01 20:51:37 +00:00
|
|
|
count = -1;
|
2006-01-20 22:57:32 +00:00
|
|
|
|
2010-09-10 11:14:10 +00:00
|
|
|
m_WorkSpace_X_end -= double(project_name_max_width) + m_Space_for_scrollbar;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (m_WorkSpace_X_end < m_WorkSpace_X_start) m_WorkSpace_X_end = m_WorkSpace_X_start;
|
|
|
|
if (m_WorkSpace_X_end < 0.0) m_WorkSpace_X_end = 0.0;
|
2006-11-03 19:33:53 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
2006-01-20 22:57:32 +00:00
|
|
|
++count;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (count < m_Legend_Shift) continue;
|
2006-01-20 22:57:32 +00:00
|
|
|
///Draw project name
|
2006-11-03 19:33:53 +00:00
|
|
|
head_name = wxT("?");
|
2006-08-22 17:59:18 +00:00
|
|
|
PROJECT* state_project = pDoc->state.lookup_project((*i)->master_url);
|
2006-12-01 20:51:37 +00:00
|
|
|
if (state_project) head_name = wxString(state_project->project_name.c_str(), wxConvUTF8);
|
2006-08-22 17:59:18 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
if (SelProj == count){
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetBrush(wxBrush(m_brush_LegendSelectColour , wxSOLID));
|
|
|
|
dc.SetPen(wxPen(m_pen_LegendSelectColour , 1 , wxSOLID));
|
2006-12-01 20:51:37 +00:00
|
|
|
x0 = wxCoord(m_WorkSpace_X_end) + buffer_x1 - wxCoord(1);
|
|
|
|
y0 = wxCoord(m_WorkSpace_Y_start + (double)(count - m_Legend_Shift) * m_Legend_dY + double(buffer_y1) + radius1);
|
|
|
|
w0 = project_name_max_width - buffer_x1 - buffer_x1 + 2;
|
|
|
|
h0 = wxCoord(m_Legend_dY);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
if (w0 < 0) w0 = 0;
|
|
|
|
if (h0 < 0) h0 = 0;
|
|
|
|
dc.DrawRoundedRectangle(x0 ,y0 , w0, h0, 1);
|
2006-01-20 22:57:32 +00:00
|
|
|
}
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
wxColour graphColour = wxColour(0, 0, 0);
|
|
|
|
int typePoint = 0;
|
2006-01-20 22:57:32 +00:00
|
|
|
if (bColour){
|
2006-12-01 20:51:37 +00:00
|
|
|
getTypePoint(typePoint, count);
|
2014-08-10 22:33:07 +00:00
|
|
|
color_cycle(count, proj->projects.size(), graphColour);
|
2006-12-01 20:51:37 +00:00
|
|
|
} else if (SelProj == count) {
|
|
|
|
graphColour = m_pen_LegendSelectTextColour;
|
2006-11-03 19:33:53 +00:00
|
|
|
} else {
|
2006-12-01 20:51:37 +00:00
|
|
|
graphColour = m_pen_LegendTextColour;
|
2006-11-03 19:33:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dc.SetBrush(wxBrush(m_brush_LegendColour , wxSOLID));
|
2006-12-01 20:51:37 +00:00
|
|
|
x0 = wxCoord(m_WorkSpace_X_end) + buffer_x1 + wxCoord(4) + wxCoord(m_GraphPointWidth / 2);
|
|
|
|
y0 = wxCoord(m_WorkSpace_Y_start + ((double)(count - m_Legend_Shift) + 0.5) * m_Legend_dY + double(buffer_y1) + radius1);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
2010-03-12 17:47:17 +00:00
|
|
|
if ((SelProj >= 0) || (!(m_HideProjectStatistic.count( wxString( (*i)->master_url, wxConvUTF8 ) )))){
|
2007-01-09 20:43:21 +00:00
|
|
|
myDrawPoint(dc, int(x0), int(y0), graphColour, typePoint ,m_GraphPointWidth);
|
|
|
|
dc.SetFont(m_font_bold);
|
|
|
|
}else {
|
|
|
|
dc.SetFont(m_font_standart_italic);
|
|
|
|
graphColour = wxColour(0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
x0 = wxCoord(m_WorkSpace_X_end) + buffer_x1 + wxCoord(7) + wxCoord(m_GraphPointWidth);
|
|
|
|
y0 = wxCoord(m_WorkSpace_Y_start + 1.0 + (double)(count - m_Legend_Shift) * m_Legend_dY + double(buffer_y1) + radius1);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
2007-01-09 20:43:21 +00:00
|
|
|
dc.SetTextForeground(graphColour);
|
|
|
|
dc.DrawText(head_name, x0, y0);
|
2006-12-01 20:51:37 +00:00
|
|
|
m_Legend_select_Y_end = m_WorkSpace_Y_start + (double)(count - m_Legend_Shift + 1) * m_Legend_dY + double(buffer_y1) + radius1;
|
|
|
|
if ((m_Legend_select_Y_end + m_Legend_dY) > (m_WorkSpace_Y_end - double(buffer_y1) - radius1)){
|
2005-12-08 19:21:56 +00:00
|
|
|
break;
|
2005-11-28 06:28:55 +00:00
|
|
|
}
|
2005-12-08 19:21:56 +00:00
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
dc.SetFont(m_font_standart);
|
2005-12-08 19:21:56 +00:00
|
|
|
}
|
|
|
|
//----Draw background, axis(lines), text(01-Jan-1980)----
|
2007-04-20 03:26:12 +00:00
|
|
|
void CPaintStatistics::DrawAxis(wxDC &dc, const double max_val_y, const double min_val_y, const double max_val_x, const double min_val_x,
|
|
|
|
wxColour pen_AxisColour, const double max_val_y_all, const double min_val_y_all) {
|
2006-12-01 20:51:37 +00:00
|
|
|
wxCoord x0 = wxCoord(m_WorkSpace_X_start);
|
|
|
|
wxCoord y0 = wxCoord(m_WorkSpace_Y_start);
|
|
|
|
wxCoord w0 = wxCoord(m_WorkSpace_X_end - m_WorkSpace_X_start);
|
|
|
|
wxCoord h0 = wxCoord(m_WorkSpace_Y_end - m_WorkSpace_Y_start);
|
|
|
|
wxCoord x1 = 0;
|
|
|
|
wxCoord y1 = 0;
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
if (w0 < 0) w0 = 0;
|
|
|
|
if (h0 < 0) h0 = 0;
|
|
|
|
dc.SetClippingRegion(x0, y0, w0, h0);
|
2006-08-21 16:38:16 +00:00
|
|
|
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetBrush(wxBrush(m_brush_AxisColour , wxSOLID));
|
2007-04-20 03:26:12 +00:00
|
|
|
dc.SetPen(wxPen(pen_AxisColour , 1 , wxSOLID));
|
2005-12-08 19:21:56 +00:00
|
|
|
|
|
|
|
wxCoord w_temp, h_temp, des_temp, lead_temp;
|
2007-04-20 03:26:12 +00:00
|
|
|
wxCoord w_temp2;
|
2005-12-08 19:21:56 +00:00
|
|
|
|
2015-09-22 18:22:07 +00:00
|
|
|
dc.GetTextExtent(wxString::Format(wxT(" %s"), format_number(max_val_y_all, 2)), &w_temp, &h_temp, &des_temp, &lead_temp);
|
|
|
|
dc.GetTextExtent(wxString::Format(wxT(" %s"), format_number(min_val_y_all, 2)), &w_temp2, &h_temp, &des_temp, &lead_temp);
|
2007-04-20 03:26:12 +00:00
|
|
|
|
|
|
|
if (w_temp < w_temp2) w_temp = w_temp2;
|
2005-12-08 19:21:56 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
m_WorkSpace_X_start += double(w_temp) + 3.0;
|
|
|
|
m_WorkSpace_Y_end -= double(h_temp) + 3.0;
|
2005-12-08 19:21:56 +00:00
|
|
|
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.GetTextExtent(wxT("0"), &w_temp, &h_temp, &des_temp, &lead_temp);
|
2005-12-08 19:21:56 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
m_WorkSpace_X_end -= 3.0;//w_temp;
|
|
|
|
const double radius1 = 5.0;//(double)(h_temp/2.0);
|
|
|
|
double d_y = (double)(h_temp) / 2.0;
|
|
|
|
if (d_y < 5.0) d_y = 5.0;
|
2005-12-08 19:21:56 +00:00
|
|
|
|
|
|
|
wxDateTime dtTemp1;
|
|
|
|
wxString strBuffer1;
|
|
|
|
dtTemp1.Set((time_t)max_val_x);
|
2007-04-20 03:26:12 +00:00
|
|
|
strBuffer1 = dtTemp1.Format(wxT("%d.%b.%y"), wxDateTime::GMT0);
|
2005-12-08 19:21:56 +00:00
|
|
|
dc.GetTextExtent(strBuffer1, &w_temp, &h_temp, &des_temp, &lead_temp);
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
double d_x = (double)(w_temp) / 2.0;
|
2005-12-08 19:21:56 +00:00
|
|
|
|
|
|
|
// Draw background graph
|
2006-12-01 20:51:37 +00:00
|
|
|
x0 = wxCoord(m_WorkSpace_X_start);
|
|
|
|
y0 = wxCoord(m_WorkSpace_Y_start);
|
|
|
|
w0 = wxCoord(m_WorkSpace_X_end - m_WorkSpace_X_start);
|
|
|
|
h0 = wxCoord(m_WorkSpace_Y_end - m_WorkSpace_Y_start);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
if (w0 < 0) w0 = 0;
|
|
|
|
if (h0 < 0) h0 = 0;
|
|
|
|
dc.DrawRoundedRectangle(x0, y0, w0, h0, radius1);
|
|
|
|
|
|
|
|
m_Graph_X_start = m_WorkSpace_X_start; //x0;
|
|
|
|
m_Graph_X_end = m_WorkSpace_X_end; //x0 + w0;
|
|
|
|
m_Graph_Y_start = m_WorkSpace_Y_start; //y0;
|
|
|
|
m_Graph_Y_end = m_WorkSpace_Y_end; //y0 + h0;
|
|
|
|
|
|
|
|
m_WorkSpace_X_start += d_x;
|
|
|
|
m_WorkSpace_X_end -= d_x;
|
|
|
|
m_WorkSpace_Y_start += d_y;
|
|
|
|
m_WorkSpace_Y_end -= d_y;
|
|
|
|
|
|
|
|
if (m_WorkSpace_X_end < m_WorkSpace_X_start) m_WorkSpace_X_start = m_WorkSpace_X_end = (m_WorkSpace_X_end + m_WorkSpace_X_start) / 2.0;
|
|
|
|
if (m_WorkSpace_Y_end < m_WorkSpace_Y_start) m_WorkSpace_Y_start = m_WorkSpace_Y_end = (m_WorkSpace_Y_end + m_WorkSpace_Y_start) / 2.0;
|
|
|
|
|
|
|
|
m_Graph_draw_X_start = m_WorkSpace_X_start;
|
|
|
|
m_Graph_draw_X_end = m_WorkSpace_X_end;
|
|
|
|
m_Graph_draw_Y_start = m_WorkSpace_Y_start;
|
|
|
|
m_Graph_draw_Y_end = m_WorkSpace_Y_end;
|
|
|
|
// A B
|
|
|
|
AB(m_WorkSpace_X_start, m_WorkSpace_Y_end, m_WorkSpace_X_end, m_WorkSpace_Y_start,
|
|
|
|
min_val_x, min_val_y, max_val_x, max_val_y);
|
2005-12-08 19:21:56 +00:00
|
|
|
//Draw val and lines
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetPen(wxPen(m_pen_AxisYColour , 1 , wxDOT));
|
|
|
|
dc.SetTextForeground (m_pen_AxisYTextColour);
|
2006-08-21 16:38:16 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
int d_oy_count = 1;
|
|
|
|
if (h_temp > 0) d_oy_count = (int)ceil((m_WorkSpace_Y_end - m_WorkSpace_Y_start) / ( 2.0 * double(h_temp)));
|
|
|
|
if (d_oy_count <= 0) d_oy_count = 1;
|
|
|
|
double d_oy_val = fabs((max_val_y - min_val_y) / double(d_oy_count));
|
|
|
|
double d2 = pow(double(10.0) , floor(log10(d_oy_val)));
|
|
|
|
|
|
|
|
if (d2 >= d_oy_val){
|
|
|
|
d_oy_val = 1.0 * d2;
|
|
|
|
} else if (2.0 * d2 >= d_oy_val){
|
|
|
|
d_oy_val = 2.0 * d2;
|
|
|
|
} else if (5.0 * d2 >= d_oy_val){
|
|
|
|
d_oy_val = 5.0 * d2;
|
2006-08-21 16:38:16 +00:00
|
|
|
} else {
|
2006-12-01 20:51:37 +00:00
|
|
|
d_oy_val = 10.0 * d2;
|
2006-08-21 16:38:16 +00:00
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
if (0 == d_oy_val) d_oy_val = 0.01;
|
|
|
|
double y_start_val = ceil(min_val_y / d_oy_val) * d_oy_val;
|
|
|
|
d_oy_count = (int)floor((max_val_y - y_start_val) / d_oy_val);
|
|
|
|
|
2017-08-30 04:09:22 +00:00
|
|
|
double temp_int_part;
|
2017-08-30 21:47:54 +00:00
|
|
|
int prec = modf(d_oy_val, &temp_int_part) < 0.01 ? 0 : 2;
|
2017-08-30 04:09:22 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
for (double ny = 0; ny <= double(d_oy_count); ++ny){
|
2017-08-30 04:09:22 +00:00
|
|
|
dc.GetTextExtent(wxString::Format(wxT("%s"), format_number(y_start_val + ny * d_oy_val, prec)), &w_temp, &h_temp, &des_temp, &lead_temp);
|
2006-12-01 20:51:37 +00:00
|
|
|
x0 = wxCoord(m_Graph_X_start + 1.0);
|
|
|
|
y0 = wxCoord(m_Ay_ValToCoord * (y_start_val + ny * d_oy_val) + m_By_ValToCoord);
|
|
|
|
x1 = wxCoord(m_Graph_X_end - 1.0);
|
|
|
|
if ((y0 >= wxCoord(m_WorkSpace_Y_start)) && (y0 <= wxCoord(m_WorkSpace_Y_end))){
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
if (x1 < 0) x1 = 0;
|
|
|
|
dc.DrawLine(x0, y0, x1, y0);
|
|
|
|
x0 = wxCoord(m_Graph_X_start - 2.0) - w_temp;
|
|
|
|
y0 = wxCoord(m_Ay_ValToCoord * (y_start_val + ny * d_oy_val) + m_By_ValToCoord - double(h_temp) / 2.0);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
2017-08-30 04:09:22 +00:00
|
|
|
dc.DrawText(wxString::Format(wxT("%s"), format_number(y_start_val + ny * d_oy_val, prec)), x0, y0);
|
2006-08-21 16:38:16 +00:00
|
|
|
}
|
2005-12-08 19:21:56 +00:00
|
|
|
}
|
2005-11-28 06:28:55 +00:00
|
|
|
|
2005-12-08 19:21:56 +00:00
|
|
|
//Draw day numbers and lines marking the days
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetPen(wxPen(m_pen_AxisXColour , 1 , wxDOT));
|
|
|
|
dc.SetTextForeground (m_pen_AxisXTextColour);
|
|
|
|
|
2005-12-08 19:21:56 +00:00
|
|
|
dtTemp1.Set((time_t)max_val_x);
|
2007-04-20 03:26:12 +00:00
|
|
|
strBuffer1 = dtTemp1.Format(wxT("%d.%b.%y"), wxDateTime::GMT0);
|
2005-12-08 19:21:56 +00:00
|
|
|
dc.GetTextExtent(strBuffer1, &w_temp, &h_temp, &des_temp, &lead_temp);
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
int d_ox_count = 1;
|
|
|
|
if (w_temp > 0) d_ox_count = (int)((m_WorkSpace_X_end - m_WorkSpace_X_start) / (1.2 * double(w_temp)));
|
|
|
|
if (d_ox_count <= 0) d_ox_count = 1;
|
2005-12-08 19:21:56 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
double d_ox_val = ceil(((double)(max_val_x - min_val_x) / double(d_ox_count)) / 86400.0) * 86400.0;
|
|
|
|
if (0 == d_ox_val) d_ox_val = 1;
|
2005-12-08 19:21:56 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
double x_start_val = ceil(min_val_x / 86400.0) * 86400.0;
|
|
|
|
d_ox_count = (int)floor((max_val_x - x_start_val) / d_ox_val);
|
|
|
|
|
|
|
|
for (double nx = 0; nx <= double(d_ox_count); ++nx){
|
|
|
|
dtTemp1.Set((time_t)(x_start_val + nx * d_ox_val));
|
2007-04-20 03:26:12 +00:00
|
|
|
strBuffer1 = dtTemp1.Format(wxT("%d.%b.%y"), wxDateTime::GMT0);
|
2005-12-08 19:21:56 +00:00
|
|
|
dc.GetTextExtent(strBuffer1, &w_temp, &h_temp, &des_temp, &lead_temp);
|
2006-12-01 20:51:37 +00:00
|
|
|
x0 = wxCoord(m_Ax_ValToCoord * (x_start_val + nx * d_ox_val) + m_Bx_ValToCoord);
|
|
|
|
y0 = wxCoord(m_Graph_Y_start + 1.0);
|
|
|
|
y1 = wxCoord(m_Graph_Y_end - 1.0);
|
|
|
|
if ((x0 <= wxCoord(m_WorkSpace_X_end)) && (x0 >= wxCoord(m_WorkSpace_X_start))){
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
if (y1 < 0) y1 = 0;
|
|
|
|
dc.DrawLine(x0, y0, x0, y1);
|
|
|
|
x0 = wxCoord(m_Ax_ValToCoord * (x_start_val + nx * d_ox_val) + m_Bx_ValToCoord - (double(w_temp) / 2.0));
|
2006-12-13 08:03:48 +00:00
|
|
|
y0 = (wxCoord)m_Graph_Y_end;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
dc.DrawText(strBuffer1, x0, y0);
|
2006-08-21 16:38:16 +00:00
|
|
|
}
|
2005-11-28 06:28:55 +00:00
|
|
|
}
|
2006-08-21 16:38:16 +00:00
|
|
|
dc.DestroyClippingRegion();
|
2005-12-08 19:21:56 +00:00
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
//----Draw graph----
|
2013-07-29 08:31:09 +00:00
|
|
|
void CPaintStatistics::DrawGraph(wxDC &dc, std::vector<PROJECT*>::const_iterator &i, const wxColour graphColour, const int typePoint, const int selectedStatistic) {
|
2010-09-14 14:04:59 +00:00
|
|
|
std::vector<DAILY_STATS> stats = (*i)->statistics;
|
2013-07-29 08:31:09 +00:00
|
|
|
DrawGraph2(dc, stats, graphColour, typePoint, selectedStatistic);
|
2010-09-14 14:04:59 +00:00
|
|
|
}
|
|
|
|
|
2013-07-29 08:31:09 +00:00
|
|
|
void CPaintStatistics::DrawGraph2(wxDC &dc, std::vector<DAILY_STATS> stats, const wxColour graphColour, const int typePoint, const int selectedStatistic) {
|
2006-12-01 20:51:37 +00:00
|
|
|
wxCoord x0 = wxCoord(m_Graph_X_start);
|
|
|
|
wxCoord y0 = wxCoord(m_Graph_Y_start);
|
|
|
|
wxCoord w0 = wxCoord(m_Graph_X_end - m_Graph_X_start);
|
|
|
|
wxCoord h0 = wxCoord(m_Graph_Y_end - m_Graph_Y_start);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
if (w0 < 0) w0 = 0;
|
|
|
|
if (h0 < 0) h0 = 0;
|
|
|
|
dc.SetClippingRegion(x0, y0, w0, h0);
|
2005-11-28 06:28:55 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
dc.SetPen(wxPen(graphColour , m_GraphLineWidth , wxSOLID));
|
|
|
|
|
|
|
|
wxCoord last_x = 0;
|
|
|
|
wxCoord last_y = 0;
|
|
|
|
wxCoord xpos = 0;
|
|
|
|
wxCoord ypos = 0;
|
|
|
|
|
|
|
|
double d_last_x = 0;
|
|
|
|
double d_last_y = 0;
|
|
|
|
bool last_point_in = false;
|
|
|
|
|
|
|
|
double d_xpos = 0;
|
|
|
|
double d_ypos = 0;
|
|
|
|
bool point_in = false;
|
|
|
|
|
|
|
|
bool b_point1 = false;
|
|
|
|
bool b_point2 = false;
|
|
|
|
// cross
|
|
|
|
double d_cross_x1 = 0;
|
|
|
|
double d_cross_y1 = 0;
|
|
|
|
// first point (no line)
|
|
|
|
bool first_point = true;
|
|
|
|
// end point
|
|
|
|
double d_end_point_x = 0;
|
|
|
|
double d_end_point_y = 0;
|
|
|
|
bool end_point = false;
|
|
|
|
//
|
2010-09-14 14:04:59 +00:00
|
|
|
for (std::vector<DAILY_STATS>::const_iterator j = stats.begin(); j != stats.end(); ++j) {
|
2006-12-01 20:51:37 +00:00
|
|
|
double d_x1 = 0;
|
|
|
|
double d_y1 = 0;
|
|
|
|
double d_x2 = 0;
|
|
|
|
double d_y2 = 0;
|
|
|
|
double d_min1 = 0;
|
|
|
|
double d_max1 = 0;
|
|
|
|
double d_min2 = 0;
|
|
|
|
double d_max2 = 0;
|
|
|
|
|
|
|
|
b_point1 = false;
|
|
|
|
b_point2 = false;
|
|
|
|
|
2014-01-28 20:29:59 +00:00
|
|
|
d_xpos = (m_Ax_ValToCoord * j->day + m_Bx_ValToCoord);// äîáàâèòü îêðóãëåíèå
|
|
|
|
switch (selectedStatistic){ // äîáàâèòü îêðóãëåíèå
|
2010-09-14 14:04:59 +00:00
|
|
|
case show_user_total: d_ypos = (m_Ay_ValToCoord * j->user_total_credit + m_By_ValToCoord); break;
|
|
|
|
case show_user_average: d_ypos = (m_Ay_ValToCoord * j->user_expavg_credit + m_By_ValToCoord); break;
|
|
|
|
case show_host_total: d_ypos = (m_Ay_ValToCoord * j->host_total_credit + m_By_ValToCoord); break;
|
|
|
|
case show_host_average: d_ypos = (m_Ay_ValToCoord * j->host_expavg_credit + m_By_ValToCoord); break;
|
2006-12-01 20:51:37 +00:00
|
|
|
default:d_ypos = (m_Ay_ValToCoord * j->user_total_credit + m_By_ValToCoord); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (first_point) {
|
|
|
|
if ((d_xpos < m_Graph_X_start) || (d_xpos > m_Graph_X_end) ||
|
|
|
|
(d_ypos < m_Graph_Y_start) || (d_ypos > m_Graph_Y_end)){
|
|
|
|
point_in = false;
|
|
|
|
b_point2 = false;
|
|
|
|
end_point = false;
|
|
|
|
}else {
|
|
|
|
point_in = true;
|
|
|
|
d_x2 = d_xpos;
|
|
|
|
d_y2 = d_ypos;
|
|
|
|
b_point2 = true;
|
|
|
|
d_end_point_x = d_xpos;
|
|
|
|
d_end_point_y = d_ypos;
|
|
|
|
end_point = true;
|
|
|
|
}
|
|
|
|
first_point = false;
|
|
|
|
}else {
|
|
|
|
dc.SetPen(wxPen(graphColour , m_GraphLineWidth , wxSOLID));
|
2014-01-28 20:29:59 +00:00
|
|
|
// ïðîâåðêà ïîïàäàíèÿ ïåðâîé òî÷êè ëèíèè â îáëàñòü ðèñîâàíèÿ
|
2006-12-01 20:51:37 +00:00
|
|
|
if (last_point_in){
|
|
|
|
d_x1 = d_last_x;
|
|
|
|
d_y1 = d_last_y;
|
|
|
|
b_point1 = true;
|
|
|
|
}else b_point1 = false;
|
2014-01-28 20:29:59 +00:00
|
|
|
// ïðîâåðêà ïîïàäàíèÿ âòîðîé òî÷êè ëèíèè â îáëàñòü ðèñîâàíèÿ
|
2006-12-01 20:51:37 +00:00
|
|
|
if ((d_xpos < m_Graph_X_start) || (d_xpos > m_Graph_X_end) ||
|
|
|
|
(d_ypos < m_Graph_Y_start) || (d_ypos > m_Graph_Y_end)){
|
|
|
|
point_in = false;
|
|
|
|
b_point2 = false;
|
|
|
|
}else {
|
|
|
|
point_in = true;
|
|
|
|
d_x2 = d_xpos;
|
|
|
|
d_y2 = d_ypos;
|
|
|
|
b_point2 = true;
|
|
|
|
}
|
2014-01-28 20:29:59 +00:00
|
|
|
// Èùåì òî÷êó âõîäà ëèíèè â îáëàñòü ðèñîâàíèÿ (1) x=const
|
2006-12-01 20:51:37 +00:00
|
|
|
if (!b_point1 || !b_point2){
|
|
|
|
if (CrossTwoLine(d_last_x, d_last_y, d_xpos, d_ypos,
|
|
|
|
m_Graph_X_start, m_Graph_Y_end, m_Graph_X_start, m_Graph_Y_start,
|
|
|
|
d_cross_x1, d_cross_y1)){
|
|
|
|
if (d_last_x > d_xpos){
|
|
|
|
d_min1 = d_xpos;
|
|
|
|
d_max1 = d_last_x;
|
|
|
|
}else{
|
|
|
|
d_max1 = d_xpos;
|
|
|
|
d_min1 = d_last_x;
|
|
|
|
}
|
|
|
|
if (m_Graph_Y_end > m_Graph_Y_start){
|
|
|
|
d_min2 = m_Graph_Y_start;
|
|
|
|
d_max2 = m_Graph_Y_end;
|
|
|
|
}else{
|
|
|
|
d_max2 = m_Graph_Y_end;
|
|
|
|
d_min2 = m_Graph_Y_start;
|
|
|
|
}
|
|
|
|
if ((d_cross_x1 <= d_max1) && (d_cross_x1 >= d_min1) &&
|
|
|
|
(d_cross_y1 <= d_max2) && (d_cross_y1 >= d_min2)){
|
|
|
|
if (!b_point1){
|
|
|
|
d_x1 = d_cross_x1;
|
|
|
|
d_y1 = d_cross_y1;
|
|
|
|
b_point1 = true;
|
|
|
|
} else if (!b_point2){
|
|
|
|
d_x2 = d_cross_x1;
|
|
|
|
d_y2 = d_cross_y1;
|
|
|
|
b_point2 = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-28 20:29:59 +00:00
|
|
|
// Èùåì òî÷êó âõîäà ëèíèè â îáëàñòü ðèñîâàíèÿ (2) x=const
|
2006-12-01 20:51:37 +00:00
|
|
|
if (!b_point1 || !b_point2){
|
|
|
|
if (CrossTwoLine(d_last_x, d_last_y, d_xpos, d_ypos,
|
|
|
|
m_Graph_X_end, m_Graph_Y_end, m_Graph_X_end, m_Graph_Y_start,
|
|
|
|
d_cross_x1, d_cross_y1)){
|
|
|
|
if (d_last_x > d_xpos){
|
|
|
|
d_min1 = d_xpos;
|
|
|
|
d_max1 = d_last_x;
|
|
|
|
}else{
|
|
|
|
d_max1 = d_xpos;
|
|
|
|
d_min1 = d_last_x;
|
|
|
|
}
|
|
|
|
if (m_Graph_Y_end > m_Graph_Y_start){
|
|
|
|
d_min2 = m_Graph_Y_start;
|
|
|
|
d_max2 = m_Graph_Y_end;
|
|
|
|
}else{
|
|
|
|
d_max2 = m_Graph_Y_end;
|
|
|
|
d_min2 = m_Graph_Y_start;
|
|
|
|
}
|
|
|
|
if ((d_cross_x1 <= d_max1) && (d_cross_x1 >= d_min1) &&
|
|
|
|
(d_cross_y1 <= d_max2) && (d_cross_y1 >= d_min2)){
|
|
|
|
if (!b_point1){
|
|
|
|
d_x1 = d_cross_x1;
|
|
|
|
d_y1 = d_cross_y1;
|
|
|
|
b_point1 = true;
|
|
|
|
} else if (!b_point2){
|
|
|
|
d_x2 = d_cross_x1;
|
|
|
|
d_y2 = d_cross_y1;
|
|
|
|
b_point2 = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-28 20:29:59 +00:00
|
|
|
// Èùåì òî÷êó âõîäà ëèíèè â îáëàñòü ðèñîâàíèÿ (3) y=const
|
2006-12-01 20:51:37 +00:00
|
|
|
if (!b_point1 || !b_point2){
|
|
|
|
if (CrossTwoLine(d_last_x, d_last_y, d_xpos, d_ypos,
|
|
|
|
m_Graph_X_start, m_Graph_Y_start, m_Graph_X_end, m_Graph_Y_start,
|
|
|
|
d_cross_x1, d_cross_y1)){
|
|
|
|
if (d_last_y > d_ypos){
|
|
|
|
d_min1 = d_ypos;
|
|
|
|
d_max1 = d_last_y;
|
|
|
|
}else{
|
|
|
|
d_max1 = d_ypos;
|
|
|
|
d_min1 = d_last_y;
|
|
|
|
}
|
|
|
|
if (m_Graph_X_end > m_Graph_X_start){
|
|
|
|
d_min2 = m_Graph_X_start;
|
|
|
|
d_max2 = m_Graph_X_end;
|
|
|
|
}else{
|
|
|
|
d_max2 = m_Graph_X_end;
|
|
|
|
d_min2 = m_Graph_X_start;
|
|
|
|
}
|
|
|
|
if ((d_cross_y1 <= d_max1) && (d_cross_y1 >= d_min1) &&
|
|
|
|
(d_cross_x1 <= d_max2) && (d_cross_x1 >= d_min2)){
|
|
|
|
if (!b_point1){
|
|
|
|
d_x1 = d_cross_x1;
|
|
|
|
d_y1 = d_cross_y1;
|
|
|
|
b_point1 = true;
|
|
|
|
} else if (!b_point2){
|
|
|
|
d_x2 = d_cross_x1;
|
|
|
|
d_y2 = d_cross_y1;
|
|
|
|
b_point2 = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-28 20:29:59 +00:00
|
|
|
// Èùåì òî÷êó âõîäà ëèíèè â îáëàñòü ðèñîâàíèÿ (4) y=const
|
2006-12-01 20:51:37 +00:00
|
|
|
if (!b_point1 || !b_point2){
|
|
|
|
if (CrossTwoLine(d_last_x, d_last_y, d_xpos, d_ypos,
|
|
|
|
m_Graph_X_start, m_Graph_Y_end, m_Graph_X_end, m_Graph_Y_end,
|
|
|
|
d_cross_x1, d_cross_y1)){
|
|
|
|
if (d_last_y > d_ypos){
|
|
|
|
d_min1 = d_ypos;
|
|
|
|
d_max1 = d_last_y;
|
|
|
|
}else{
|
|
|
|
d_max1 = d_ypos;
|
|
|
|
d_min1 = d_last_y;
|
|
|
|
}
|
|
|
|
if (m_Graph_X_end > m_Graph_X_start){
|
|
|
|
d_min2 = m_Graph_X_start;
|
|
|
|
d_max2 = m_Graph_X_end;
|
|
|
|
}else{
|
|
|
|
d_max2 = m_Graph_X_end;
|
|
|
|
d_min2 = m_Graph_X_start;
|
|
|
|
}
|
|
|
|
if ((d_cross_y1 <= d_max1) && (d_cross_y1 >= d_min1) &&
|
|
|
|
(d_cross_x1 <= d_max2) && (d_cross_x1 >= d_min2)){
|
|
|
|
if (!b_point1){
|
|
|
|
d_x1 = d_cross_x1;
|
|
|
|
d_y1 = d_cross_y1;
|
|
|
|
b_point1 = true;
|
|
|
|
} else if (!b_point2){
|
|
|
|
d_x2 = d_cross_x1;
|
|
|
|
d_y2 = d_cross_y1;
|
|
|
|
b_point2 = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (b_point1 && b_point2){
|
|
|
|
last_x = wxCoord(d_x1);
|
|
|
|
last_y = wxCoord(d_y1);
|
|
|
|
xpos = wxCoord(d_x2);
|
|
|
|
ypos = wxCoord(d_y2);
|
2007-01-09 20:43:21 +00:00
|
|
|
if (last_x > (wxCoord)m_Graph_X_end) last_x = (wxCoord)m_Graph_X_end;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (last_x < 0) last_x = 0;
|
2007-01-09 20:43:21 +00:00
|
|
|
if (last_y > (wxCoord)m_Graph_Y_end) last_y = (wxCoord)m_Graph_Y_end;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (last_y < 0) last_y = 0;
|
2007-01-09 20:43:21 +00:00
|
|
|
if (xpos > (wxCoord)m_Graph_X_end) xpos = (wxCoord)m_Graph_X_end;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (xpos < 0) xpos = 0;
|
2007-01-09 20:43:21 +00:00
|
|
|
if (ypos > (wxCoord)m_Graph_Y_end) ypos = (wxCoord)m_Graph_Y_end;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (ypos < 0) ypos = 0;
|
|
|
|
|
|
|
|
dc.DrawLine(last_x, last_y, xpos, ypos);
|
|
|
|
if (last_point_in) myDrawPoint(dc, last_x, last_y, graphColour, typePoint ,m_GraphPointWidth);
|
|
|
|
if (point_in){
|
|
|
|
d_end_point_x = d_xpos;
|
|
|
|
d_end_point_y = d_ypos;
|
|
|
|
end_point = true;
|
|
|
|
}else end_point = false;
|
|
|
|
}else end_point = false;
|
|
|
|
}
|
|
|
|
d_last_x = d_xpos;
|
|
|
|
d_last_y = d_ypos;
|
|
|
|
last_point_in = point_in;
|
|
|
|
}
|
|
|
|
// draw last point
|
|
|
|
if (end_point){
|
|
|
|
xpos = wxCoord(d_end_point_x);
|
|
|
|
ypos = wxCoord(d_end_point_y);
|
2007-01-09 20:43:21 +00:00
|
|
|
if (xpos > (wxCoord)m_Graph_X_end) xpos = (wxCoord)m_Graph_X_end;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (xpos < 0) xpos = 0;
|
2007-01-09 20:43:21 +00:00
|
|
|
if (ypos > (wxCoord)m_Graph_Y_end) ypos = (wxCoord)m_Graph_Y_end;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (ypos < 0) ypos = 0;
|
|
|
|
myDrawPoint(dc, xpos, ypos, graphColour, typePoint ,m_GraphPointWidth);
|
|
|
|
}
|
|
|
|
dc.DestroyClippingRegion();
|
|
|
|
}
|
|
|
|
//----Draw marker----
|
|
|
|
void CPaintStatistics::DrawMarker(wxDC &dc) {
|
|
|
|
if (m_GraphMarker1){
|
|
|
|
wxCoord x0 = wxCoord(m_Graph_X_start);
|
|
|
|
wxCoord y0 = wxCoord(m_Graph_Y_start);
|
|
|
|
wxCoord w0 = wxCoord(m_Graph_X_end - m_Graph_X_start);
|
|
|
|
wxCoord h0 = wxCoord(m_Graph_Y_end - m_Graph_Y_start);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
if (w0 < 0) w0 = 0;
|
|
|
|
if (h0 < 0) h0 = 0;
|
|
|
|
dc.SetClippingRegion(x0, y0, w0, h0);
|
|
|
|
|
|
|
|
dc.SetPen(wxPen(m_pen_MarkerLineColour , 1 , wxSOLID));
|
|
|
|
wxCoord x00 = wxCoord(m_Ax_ValToCoord * m_GraphMarker_X1 + m_Bx_ValToCoord);
|
|
|
|
wxCoord y00 = wxCoord(m_Ay_ValToCoord * m_GraphMarker_Y1 + m_By_ValToCoord);
|
|
|
|
if (x00 < 0) x00 = 0;
|
|
|
|
if (y00 < 0) y00 = 0;
|
|
|
|
if ((x00 < wxCoord(m_Graph_X_start)) || (x00 > wxCoord(m_Graph_X_end)) ||
|
|
|
|
(y00 < wxCoord(m_Graph_Y_start)) || (y00 > wxCoord(m_Graph_Y_end))){
|
|
|
|
}else{
|
|
|
|
dc.CrossHair(x00, y00);
|
|
|
|
wxDateTime dtTemp1;
|
|
|
|
wxString strBuffer1;
|
|
|
|
dtTemp1.Set((time_t)m_GraphMarker_X1);
|
2007-04-20 03:26:12 +00:00
|
|
|
strBuffer1=dtTemp1.Format(wxT("%d.%b.%y"), wxDateTime::GMT0);
|
2006-12-01 20:51:37 +00:00
|
|
|
|
|
|
|
dc.SetFont(m_font_bold);
|
|
|
|
dc.SetTextBackground (m_brush_AxisColour);
|
|
|
|
dc.SetBackgroundMode(wxSOLID);
|
|
|
|
x0 += 2;
|
|
|
|
y0 += 2;
|
|
|
|
x00 += 2;
|
|
|
|
y00 += 2;
|
|
|
|
if (x00 < 0) x00 = 0;
|
|
|
|
if (y00 < 0) y00 = 0;
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
|
|
|
|
dc.SetTextForeground (m_pen_AxisYTextColour);
|
2015-09-22 18:22:07 +00:00
|
|
|
dc.DrawText(wxString::Format(wxT("%s"), format_number(m_GraphMarker_Y1, 2)) , x0, y00);
|
2006-12-01 20:51:37 +00:00
|
|
|
dc.SetTextForeground (m_pen_AxisXTextColour);
|
|
|
|
dc.DrawText(strBuffer1 ,x00, y0);
|
|
|
|
dc.SetBackgroundMode(wxTRANSPARENT);
|
|
|
|
}
|
|
|
|
dc.DestroyClippingRegion();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//-------- Draw All ---------
|
|
|
|
void CPaintStatistics::DrawAll(wxDC &dc) {
|
2005-12-08 19:21:56 +00:00
|
|
|
//Init global
|
2006-12-01 20:51:37 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-12-08 19:21:56 +00:00
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
PROJECTS *proj = &(pDoc->statistics_status);
|
2005-11-28 06:28:55 +00:00
|
|
|
wxASSERT(proj);
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
m_WorkSpace_X_start = m_main_X_start;
|
|
|
|
m_WorkSpace_X_end = m_main_X_end;
|
|
|
|
m_WorkSpace_Y_start = m_main_Y_start;
|
|
|
|
m_WorkSpace_Y_end = m_main_Y_end;
|
2006-11-03 19:33:53 +00:00
|
|
|
|
|
|
|
dc.SetBackground(m_brush_MainColour);
|
2006-08-21 16:38:16 +00:00
|
|
|
|
|
|
|
// dc.SetTextForeground (GetForegroundColour ());
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetTextForeground (m_pen_HeadTextColour);
|
2005-11-28 06:28:55 +00:00
|
|
|
dc.SetTextBackground (GetBackgroundColour ());
|
|
|
|
|
2014-01-11 10:32:22 +00:00
|
|
|
// The next 3 lines seem unnecessary and cause problems
|
|
|
|
// when monitor dpi is set to 125% of normal on MS Windows.
|
|
|
|
// m_font_standart = dc.GetFont();
|
|
|
|
// m_font_bold = dc.GetFont();
|
|
|
|
// m_font_standart_italic = dc.GetFont();
|
2005-11-28 06:28:55 +00:00
|
|
|
|
2006-11-03 19:33:53 +00:00
|
|
|
m_font_standart.SetWeight(wxNORMAL);
|
2006-01-20 22:57:32 +00:00
|
|
|
m_font_bold.SetWeight(wxBOLD);
|
2007-01-09 20:43:21 +00:00
|
|
|
// m_font_standart_italic.SetFaceName(_T("Verdana"));
|
2006-11-03 19:33:53 +00:00
|
|
|
m_font_standart_italic.SetStyle(wxFONTSTYLE_ITALIC);
|
2006-01-20 22:57:32 +00:00
|
|
|
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetFont(m_font_standart);
|
2005-12-08 19:21:56 +00:00
|
|
|
//Start drawing
|
2006-01-20 22:57:32 +00:00
|
|
|
dc.Clear();
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetBrush(wxBrush(m_brush_MainColour , wxSOLID));
|
|
|
|
dc.SetPen(wxPen(m_pen_MainColour , 1 , wxSOLID));
|
2006-12-01 20:51:37 +00:00
|
|
|
|
|
|
|
wxCoord x0 = wxCoord(m_main_X_start);
|
|
|
|
wxCoord y0 = wxCoord(m_main_Y_start);
|
|
|
|
wxCoord w0 = wxCoord(m_main_X_end - m_main_X_start);
|
|
|
|
wxCoord h0 = wxCoord(m_main_Y_end - m_main_Y_start);
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
if (w0 < 0) w0 = 0;
|
|
|
|
if (h0 < 0) h0 = 0;
|
2010-09-10 11:14:10 +00:00
|
|
|
dc.SetBrush(wxBrush(m_brush_MainColour , wxSOLID));
|
|
|
|
dc.SetPen(wxPen(m_pen_MainColour , 1 , wxSOLID));
|
2006-12-01 20:51:37 +00:00
|
|
|
dc.DrawRectangle(x0, y0, w0, h0);
|
2005-12-08 19:21:56 +00:00
|
|
|
//Number of Projects
|
2006-12-01 20:51:37 +00:00
|
|
|
int nb_proj = 0;
|
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) { ++nb_proj; }
|
|
|
|
if (0 == nb_proj) {
|
2010-09-10 11:14:10 +00:00
|
|
|
dc.DrawRectangle(x0, y0, w0, h0);
|
2005-12-08 19:21:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-01-20 22:57:32 +00:00
|
|
|
// Check m_NextProjectStatistic
|
2006-12-01 20:51:37 +00:00
|
|
|
if (m_NextProjectStatistic < 0) m_NextProjectStatistic = nb_proj - 1;
|
|
|
|
if ((m_NextProjectStatistic < 0) || (m_NextProjectStatistic >= nb_proj)) m_NextProjectStatistic = 0;
|
2006-01-20 22:57:32 +00:00
|
|
|
// Initial coord
|
2006-11-03 19:33:53 +00:00
|
|
|
switch (m_SelectedStatistic){
|
2010-09-14 14:04:59 +00:00
|
|
|
case show_user_total: heading = _("User Total"); break;
|
|
|
|
case show_user_average: heading = _("User Average"); break;
|
|
|
|
case show_host_total: heading = _("Host Total"); break;
|
|
|
|
case show_host_average: heading = _("Host Average"); break;
|
2006-12-01 20:51:37 +00:00
|
|
|
default:heading = wxT("");
|
2006-11-03 19:33:53 +00:00
|
|
|
}
|
|
|
|
|
2010-09-10 11:14:10 +00:00
|
|
|
if (!m_LegendDraw) {
|
|
|
|
m_scrollBar->Hide();
|
|
|
|
m_Space_for_scrollbar = 0;
|
|
|
|
}
|
|
|
|
|
2005-11-28 06:28:55 +00:00
|
|
|
switch (m_ModeViewStatistic){
|
2010-09-14 14:04:59 +00:00
|
|
|
case mode_all_separate:
|
|
|
|
{
|
2007-04-20 03:26:12 +00:00
|
|
|
//Draw Legend
|
|
|
|
if (m_ViewHideProjectStatistic >= 0){
|
|
|
|
int count = -1;
|
|
|
|
std::set<wxString>::iterator s;
|
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
|
|
|
++count;
|
|
|
|
if (m_ViewHideProjectStatistic == count){
|
2010-03-12 17:47:17 +00:00
|
|
|
s = m_HideProjectStatistic.find( wxString((*i)->master_url, wxConvUTF8) );
|
2007-04-20 03:26:12 +00:00
|
|
|
if (s != m_HideProjectStatistic.end()){
|
|
|
|
m_HideProjectStatistic.erase(s);
|
2010-04-01 20:29:36 +00:00
|
|
|
} else {
|
|
|
|
m_HideProjectStatistic.insert(wxString((*i)->master_url, wxConvUTF8));
|
|
|
|
}
|
2007-04-20 03:26:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_ViewHideProjectStatistic = -1;
|
|
|
|
|
|
|
|
if (m_LegendDraw) DrawLegend(dc, proj, pDoc, -1, false, m_Legend_Shift_Mode2);
|
2006-01-20 22:57:32 +00:00
|
|
|
///Draw heading
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetFont(m_font_bold);
|
2006-12-01 20:51:37 +00:00
|
|
|
DrawMainHead(dc, heading);
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetFont(m_font_standart);
|
2021-10-01 06:32:40 +00:00
|
|
|
//How many rows/columns?
|
2007-04-20 03:26:12 +00:00
|
|
|
int nb_proj_show = 0;
|
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
2010-03-12 17:47:17 +00:00
|
|
|
if (!(m_HideProjectStatistic.count( wxString((*i)->master_url, wxConvUTF8) ))){
|
2007-04-20 03:26:12 +00:00
|
|
|
++nb_proj_show;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
2006-12-01 20:51:37 +00:00
|
|
|
int nb_proj_row = 0, nb_proj_col = 0;
|
2007-04-20 03:26:12 +00:00
|
|
|
if (nb_proj_show < 4) {
|
2006-12-01 20:51:37 +00:00
|
|
|
nb_proj_col = 1;
|
2007-04-20 03:26:12 +00:00
|
|
|
nb_proj_row = nb_proj_show;
|
2005-11-28 06:28:55 +00:00
|
|
|
} else {
|
2006-12-01 20:51:37 +00:00
|
|
|
nb_proj_col = 2;
|
2007-04-20 03:26:12 +00:00
|
|
|
nb_proj_row = (int)ceil(double(nb_proj_show) / double(nb_proj_col));
|
2005-11-28 06:28:55 +00:00
|
|
|
}
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
int col = 1, row = 1; //Used to identify the actual row/col
|
2005-11-28 06:28:55 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
double rectangle_x_start = m_WorkSpace_X_start;
|
|
|
|
double rectangle_x_end = m_WorkSpace_X_end;
|
|
|
|
double rectangle_y_start = m_WorkSpace_Y_start;
|
|
|
|
double rectangle_y_end = m_WorkSpace_Y_end;
|
|
|
|
|
|
|
|
if (0 == nb_proj_col) nb_proj_col = 1;
|
|
|
|
if (0 == nb_proj_row) nb_proj_row = 1;
|
|
|
|
const double x_fac = (rectangle_x_end - rectangle_x_start) / double(nb_proj_col);
|
|
|
|
const double y_fac = (rectangle_y_end - rectangle_y_start) / double(nb_proj_row);
|
2005-11-28 06:28:55 +00:00
|
|
|
|
2007-04-20 03:26:12 +00:00
|
|
|
double min_val_y_all = 10e32, max_val_y_all = 0;
|
|
|
|
double min_val_x_all = 10e32, max_val_x_all = 0;
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
2010-03-12 17:47:17 +00:00
|
|
|
if (!(m_HideProjectStatistic.count( wxString((*i)->master_url, wxConvUTF8) ))){
|
2007-04-20 03:26:12 +00:00
|
|
|
MinMaxDayCredit(i, min_val_y_all, max_val_y_all, min_val_x_all, max_val_x_all, m_SelectedStatistic, false);
|
2005-11-28 06:28:55 +00:00
|
|
|
}
|
2007-04-20 03:26:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
2010-03-12 17:47:17 +00:00
|
|
|
if (!(m_HideProjectStatistic.count( wxString((*i)->master_url, wxConvUTF8) ))){
|
2007-04-20 03:26:12 +00:00
|
|
|
//Find minimum/maximum value
|
|
|
|
double min_val_y = 10e32, max_val_y = 0;
|
|
|
|
double min_val_x = 10e32, max_val_x = 0;
|
|
|
|
MinMaxDayCredit(i, min_val_y, max_val_y, min_val_x, max_val_x, m_SelectedStatistic);
|
|
|
|
CheckMinMaxD(min_val_x, max_val_x);
|
|
|
|
CheckMinMaxD(min_val_y, max_val_y);
|
|
|
|
min_val_x = floor(min_val_x / 86400.0) * 86400.0;
|
|
|
|
max_val_x = ceil(max_val_x / 86400.0) * 86400.0;
|
|
|
|
//Where do we draw in?
|
|
|
|
ClearXY();
|
|
|
|
m_main_X_start = (wxCoord)(rectangle_x_start + x_fac * (double)(col - 1));
|
|
|
|
m_main_X_end = (wxCoord)(rectangle_x_start + x_fac * ((double)col));
|
|
|
|
m_main_Y_start = (wxCoord)(rectangle_y_start + y_fac * (double)(row - 1));
|
|
|
|
m_main_Y_end = (wxCoord)(rectangle_y_start + y_fac * (double)row);
|
|
|
|
if (m_main_X_start < 0) m_main_X_start = 0;
|
|
|
|
if (m_main_X_start > m_main_X_end) m_main_X_end = m_main_X_start;
|
|
|
|
if (m_main_Y_start < 0) m_main_Y_start = 0;
|
|
|
|
if (m_main_Y_start > m_main_Y_end) m_main_Y_end = m_main_Y_start;
|
|
|
|
|
|
|
|
m_WorkSpace_X_start = m_main_X_start;
|
|
|
|
m_WorkSpace_X_end = m_main_X_end;
|
|
|
|
m_WorkSpace_Y_start = m_main_Y_start;
|
|
|
|
m_WorkSpace_Y_end = m_main_Y_end;
|
|
|
|
|
|
|
|
//Draw scale Draw Project name
|
|
|
|
wxString head_name = wxT("?");
|
|
|
|
PROJECT* state_project = pDoc->state.lookup_project((*i)->master_url);
|
|
|
|
if (state_project) {
|
|
|
|
head_name = wxString(state_project->project_name.c_str(), wxConvUTF8);
|
|
|
|
}
|
|
|
|
//Draw heading
|
|
|
|
DrawMainHead(dc, head_name);
|
|
|
|
//Draw axis
|
|
|
|
DrawAxis(dc, max_val_y, min_val_y,max_val_x, min_val_x, m_pen_AxisColour, max_val_y_all, min_val_y_all);
|
|
|
|
//Draw graph
|
|
|
|
wxColour graphColour=wxColour(0,0,0);
|
2014-08-10 22:33:07 +00:00
|
|
|
color_cycle(m_SelectedStatistic, n_command_buttons, graphColour);
|
2007-04-20 03:26:12 +00:00
|
|
|
DrawGraph(dc, i, graphColour, 0, m_SelectedStatistic);
|
|
|
|
//Change row/col
|
|
|
|
if (col == nb_proj_col) {
|
|
|
|
col = 1;
|
|
|
|
++row;
|
|
|
|
} else {
|
|
|
|
++col;
|
|
|
|
}
|
2005-11-28 06:28:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2010-09-14 14:04:59 +00:00
|
|
|
case mode_one_project:
|
|
|
|
{
|
2006-12-01 20:51:37 +00:00
|
|
|
//Draw Legend
|
2007-04-20 03:26:12 +00:00
|
|
|
if (m_LegendDraw) DrawLegend(dc, proj, pDoc, m_NextProjectStatistic, false, m_Legend_Shift_Mode1);
|
2006-12-01 20:51:37 +00:00
|
|
|
//Draw heading
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetFont(m_font_bold);
|
2006-12-01 20:51:37 +00:00
|
|
|
DrawMainHead(dc, heading);
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetFont(m_font_standart);
|
2006-01-20 22:57:32 +00:00
|
|
|
//Draw project
|
2006-12-01 20:51:37 +00:00
|
|
|
int count = -1;
|
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
2005-11-28 06:28:55 +00:00
|
|
|
++count;
|
2006-12-01 20:51:37 +00:00
|
|
|
if (count != m_NextProjectStatistic) continue;
|
|
|
|
//Find minimum/maximum value
|
|
|
|
double min_val_y = 10e32, max_val_y = 0;
|
|
|
|
double min_val_x = 10e32, max_val_x = 0;
|
2005-12-08 19:21:56 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
MinMaxDayCredit(i, min_val_y, max_val_y, min_val_x, max_val_x, m_SelectedStatistic);
|
2005-12-08 19:21:56 +00:00
|
|
|
|
2006-11-03 19:33:53 +00:00
|
|
|
double t_n1 = dtime();
|
2006-12-01 20:51:37 +00:00
|
|
|
double t_d1 = floor((t_n1 - max_val_x) / 86400.0);
|
|
|
|
|
|
|
|
wxString head_name=wxString::Format(_("Last update: %.0f days ago"), t_d1);
|
2007-04-20 03:26:12 +00:00
|
|
|
|
|
|
|
wxColour pen_AxisColour1 = m_pen_AxisColourAutoZoom;
|
2006-12-01 20:51:37 +00:00
|
|
|
|
|
|
|
if (m_Zoom_Auto){
|
|
|
|
min_val_x = floor(min_val_x / 86400.0) * 86400.0;
|
|
|
|
max_val_x = ceil(max_val_x / 86400.0) * 86400.0;
|
|
|
|
}else{
|
2007-04-20 03:26:12 +00:00
|
|
|
pen_AxisColour1 = m_pen_AxisColourZoom;
|
2006-12-01 20:51:37 +00:00
|
|
|
min_val_x = m_Zoom_min_val_X;
|
|
|
|
max_val_x = m_Zoom_max_val_X;
|
|
|
|
min_val_y = m_Zoom_min_val_Y;
|
|
|
|
max_val_y = m_Zoom_max_val_Y;
|
|
|
|
}
|
2006-01-20 22:57:32 +00:00
|
|
|
CheckMinMaxD(min_val_x, max_val_x);
|
|
|
|
CheckMinMaxD(min_val_y, max_val_y);
|
2007-04-20 03:26:12 +00:00
|
|
|
|
2010-04-01 20:29:36 +00:00
|
|
|
// Draw heading
|
2006-11-03 19:33:53 +00:00
|
|
|
PROJECT* state_project = pDoc->state.lookup_project((*i)->master_url);
|
|
|
|
if (state_project) {
|
|
|
|
dc.SetFont(m_font_standart_italic);
|
2006-12-01 20:51:37 +00:00
|
|
|
DrawProjectHead(dc, state_project, head_name);
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetFont(m_font_standart);
|
|
|
|
}
|
2007-04-20 03:26:12 +00:00
|
|
|
m_Zoom_min_val_X = min_val_x;
|
|
|
|
m_Zoom_max_val_X = max_val_x;
|
|
|
|
m_Zoom_min_val_Y = min_val_y;
|
|
|
|
m_Zoom_max_val_Y = max_val_y;
|
2010-04-01 20:29:36 +00:00
|
|
|
// Draw axis
|
2007-04-20 03:26:12 +00:00
|
|
|
DrawAxis(dc, max_val_y, min_val_y, max_val_x, min_val_x, pen_AxisColour1, max_val_y, min_val_y);
|
2010-04-01 20:29:36 +00:00
|
|
|
// Draw graph
|
2006-11-03 19:33:53 +00:00
|
|
|
wxColour graphColour=wxColour(0,0,0);
|
2014-08-10 22:33:07 +00:00
|
|
|
color_cycle(m_SelectedStatistic, n_command_buttons, graphColour);
|
2006-12-01 20:51:37 +00:00
|
|
|
DrawGraph(dc, i, graphColour, 0, m_SelectedStatistic);
|
2010-04-01 20:29:36 +00:00
|
|
|
// Draw marker
|
2006-12-01 20:51:37 +00:00
|
|
|
DrawMarker(dc);
|
2005-11-28 06:28:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2010-09-14 14:04:59 +00:00
|
|
|
case mode_all_together:
|
|
|
|
{
|
2006-12-01 20:51:37 +00:00
|
|
|
//Draw Legend
|
2007-01-09 20:43:21 +00:00
|
|
|
if (m_ViewHideProjectStatistic >= 0){
|
|
|
|
int count = -1;
|
|
|
|
std::set<wxString>::iterator s;
|
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
|
|
|
++count;
|
|
|
|
if (m_ViewHideProjectStatistic == count){
|
2010-03-12 17:47:17 +00:00
|
|
|
s = m_HideProjectStatistic.find( wxString((*i)->master_url, wxConvUTF8) );
|
2007-01-09 20:43:21 +00:00
|
|
|
if (s != m_HideProjectStatistic.end()){
|
|
|
|
m_HideProjectStatistic.erase(s);
|
2010-03-12 17:47:17 +00:00
|
|
|
}else m_HideProjectStatistic.insert( wxString((*i)->master_url, wxConvUTF8) );
|
2007-01-09 20:43:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_ViewHideProjectStatistic = -1;
|
|
|
|
|
2007-04-20 03:26:12 +00:00
|
|
|
if (m_LegendDraw) DrawLegend(dc, proj, pDoc, -1, true, m_Legend_Shift_Mode2);
|
2006-12-01 20:51:37 +00:00
|
|
|
//Draw heading
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetFont(m_font_bold);
|
2006-12-01 20:51:37 +00:00
|
|
|
DrawMainHead(dc, heading);
|
2006-11-03 19:33:53 +00:00
|
|
|
dc.SetFont(m_font_standart);
|
2005-12-08 19:21:56 +00:00
|
|
|
//Find minimum/maximum value
|
2006-12-01 20:51:37 +00:00
|
|
|
double min_val_y = 10e32, max_val_y = 0;
|
|
|
|
double min_val_x = 10e32, max_val_x = 0;
|
2005-12-08 19:21:56 +00:00
|
|
|
|
2007-04-20 03:26:12 +00:00
|
|
|
wxColour pen_AxisColour1 = m_pen_AxisColourAutoZoom;
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
if (m_Zoom_Auto){
|
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
2010-03-12 17:47:17 +00:00
|
|
|
if (!(m_HideProjectStatistic.count( wxString((*i)->master_url, wxConvUTF8) ))){
|
2007-01-09 20:43:21 +00:00
|
|
|
MinMaxDayCredit(i, min_val_y, max_val_y, min_val_x, max_val_x, m_SelectedStatistic, false);
|
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
}
|
|
|
|
min_val_x = floor(min_val_x / 86400.0) * 86400.0;
|
|
|
|
max_val_x = ceil(max_val_x / 86400.0) * 86400.0;
|
|
|
|
}else{
|
2007-04-20 03:26:12 +00:00
|
|
|
pen_AxisColour1 = m_pen_AxisColourZoom;
|
2006-12-01 20:51:37 +00:00
|
|
|
min_val_x = m_Zoom_min_val_X;
|
|
|
|
max_val_x = m_Zoom_max_val_X;
|
|
|
|
min_val_y = m_Zoom_min_val_Y;
|
|
|
|
max_val_y = m_Zoom_max_val_Y;
|
2005-12-08 19:21:56 +00:00
|
|
|
}
|
2006-01-20 22:57:32 +00:00
|
|
|
CheckMinMaxD(min_val_x, max_val_x);
|
|
|
|
CheckMinMaxD(min_val_y, max_val_y);
|
2007-04-20 03:26:12 +00:00
|
|
|
|
|
|
|
m_Zoom_min_val_X = min_val_x;
|
|
|
|
m_Zoom_max_val_X = max_val_x;
|
|
|
|
m_Zoom_min_val_Y = min_val_y;
|
|
|
|
m_Zoom_max_val_Y = max_val_y;
|
2006-12-01 20:51:37 +00:00
|
|
|
//Draw axis
|
2007-04-20 03:26:12 +00:00
|
|
|
DrawAxis(dc, max_val_y, min_val_y, max_val_x, min_val_x, pen_AxisColour1, max_val_y, min_val_y);
|
2006-12-01 20:51:37 +00:00
|
|
|
//Draw graph
|
|
|
|
int count = -1;
|
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
2005-12-08 19:21:56 +00:00
|
|
|
++count;
|
2010-03-12 17:47:17 +00:00
|
|
|
if (!(m_HideProjectStatistic.count( wxString((*i)->master_url, wxConvUTF8) ))){
|
2007-01-09 20:43:21 +00:00
|
|
|
wxColour graphColour = wxColour(0,0,0);
|
|
|
|
int typePoint = 0;
|
|
|
|
getTypePoint(typePoint,count);
|
2014-08-10 22:33:07 +00:00
|
|
|
color_cycle(count, proj->projects.size(), graphColour);
|
2007-01-09 20:43:21 +00:00
|
|
|
DrawGraph(dc, i, graphColour, typePoint, m_SelectedStatistic);
|
|
|
|
}
|
2005-12-08 19:21:56 +00:00
|
|
|
}
|
2010-09-14 14:04:59 +00:00
|
|
|
//Draw marker
|
|
|
|
DrawMarker(dc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mode_sum:
|
|
|
|
{
|
|
|
|
//Draw Legend
|
|
|
|
if (m_ViewHideProjectStatistic >= 0){
|
|
|
|
int count = -1;
|
|
|
|
std::set<wxString>::iterator s;
|
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
|
|
|
++count;
|
|
|
|
if (m_ViewHideProjectStatistic == count){
|
|
|
|
s = m_HideProjectStatistic.find( wxString((*i)->master_url, wxConvUTF8) );
|
|
|
|
if (s != m_HideProjectStatistic.end()){
|
|
|
|
m_HideProjectStatistic.erase(s);
|
|
|
|
}else m_HideProjectStatistic.insert( wxString((*i)->master_url, wxConvUTF8) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_ViewHideProjectStatistic = -1;
|
|
|
|
|
|
|
|
if (m_LegendDraw) DrawLegend(dc, proj, pDoc, -1, true, m_Legend_Shift_Mode2);
|
|
|
|
//Draw heading
|
|
|
|
dc.SetFont(m_font_bold);
|
|
|
|
DrawMainHead(dc, heading);
|
|
|
|
dc.SetFont(m_font_standart);
|
|
|
|
//Find minimum/maximum value
|
|
|
|
double min_val_y = 10e32, max_val_y = 0;
|
|
|
|
double min_val_x = 10e32, max_val_x = 0;
|
|
|
|
double min_total_y = 0;
|
|
|
|
double max_total_y = 0;
|
|
|
|
|
|
|
|
wxColour pen_AxisColour1 = m_pen_AxisColourAutoZoom;
|
|
|
|
|
|
|
|
if (m_Zoom_Auto){
|
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
|
|
|
if (!(m_HideProjectStatistic.count( wxString((*i)->master_url, wxConvUTF8) ))){
|
|
|
|
MinMaxDayCredit(i, min_val_y, max_val_y, min_val_x, max_val_x, m_SelectedStatistic, false);
|
|
|
|
min_total_y += min_val_y;
|
|
|
|
max_total_y += max_val_y;
|
|
|
|
min_val_y = 10e32;
|
|
|
|
max_val_y = 0;
|
|
|
|
}
|
|
|
|
}
|
2010-11-23 11:07:30 +00:00
|
|
|
// Start graph 30 days before today
|
|
|
|
min_val_x = dday() - (30*86400);
|
2010-09-14 14:04:59 +00:00
|
|
|
max_val_x = ceil(max_val_x / 86400.0) * 86400.0;
|
|
|
|
min_val_y = min_total_y;
|
|
|
|
max_val_y = max_total_y;
|
|
|
|
}else{
|
|
|
|
pen_AxisColour1 = m_pen_AxisColourZoom;
|
|
|
|
min_val_x = m_Zoom_min_val_X;
|
|
|
|
max_val_x = m_Zoom_max_val_X;
|
|
|
|
min_val_y = m_Zoom_min_val_Y;
|
|
|
|
max_val_y = m_Zoom_max_val_Y;
|
|
|
|
}
|
|
|
|
CheckMinMaxD(min_val_x, max_val_x);
|
|
|
|
CheckMinMaxD(min_val_y, max_val_y);
|
|
|
|
|
|
|
|
m_Zoom_min_val_X = min_val_x;
|
|
|
|
m_Zoom_max_val_X = max_val_x;
|
|
|
|
m_Zoom_min_val_Y = min_val_y;
|
|
|
|
m_Zoom_max_val_Y = max_val_y;
|
|
|
|
//Draw axis
|
|
|
|
DrawAxis(dc, max_val_y, min_val_y, max_val_x, min_val_x, pen_AxisColour1, max_val_y, min_val_y);
|
|
|
|
// Generate summed data
|
2010-09-15 08:57:11 +00:00
|
|
|
DAILY_STATS stat, saved_sum_stat, prev_proj_stat;
|
2010-09-14 14:04:59 +00:00
|
|
|
std::vector<DAILY_STATS> sumstats;
|
|
|
|
stat.user_total_credit = 0.0;
|
|
|
|
stat.user_expavg_credit = 0.0;
|
|
|
|
stat.host_total_credit = 0.0;
|
|
|
|
stat.host_expavg_credit = 0.0;
|
2010-09-15 08:57:11 +00:00
|
|
|
stat.day = min_val_x;
|
2010-09-14 14:04:59 +00:00
|
|
|
sumstats.push_back(stat);
|
|
|
|
stat.day = max_val_x;
|
|
|
|
sumstats.push_back(stat);
|
|
|
|
|
|
|
|
int count = -1;
|
|
|
|
for (std::vector<PROJECT*>::const_iterator i = proj->projects.begin(); i != proj->projects.end(); ++i) {
|
|
|
|
++count;
|
|
|
|
if (m_HideProjectStatistic.count( wxString((*i)->master_url, wxConvUTF8) )) continue;
|
2010-09-15 08:57:11 +00:00
|
|
|
saved_sum_stat.user_total_credit = 0.0;
|
|
|
|
saved_sum_stat.user_expavg_credit = 0.0;
|
|
|
|
saved_sum_stat.host_total_credit = 0.0;
|
|
|
|
saved_sum_stat.host_expavg_credit = 0.0;
|
|
|
|
saved_sum_stat.day = 0.0;
|
|
|
|
prev_proj_stat = saved_sum_stat;
|
2013-04-09 16:26:25 +00:00
|
|
|
|
|
|
|
if (sumstats.size() && (*i)->statistics.size()) {
|
|
|
|
std::vector<DAILY_STATS>::iterator sum_iter = sumstats.begin();
|
|
|
|
std::vector<DAILY_STATS>::const_iterator proj_iter = (*i)->statistics.begin();
|
|
|
|
for (;;) {
|
|
|
|
if ((*proj_iter).day >= min_val_x) {
|
|
|
|
if ((*proj_iter).day < (*sum_iter).day) {
|
|
|
|
sum_iter = sumstats.insert(sum_iter, stat);
|
|
|
|
*sum_iter = saved_sum_stat;
|
|
|
|
(*sum_iter).day = (*proj_iter).day;
|
|
|
|
} else {
|
|
|
|
saved_sum_stat = *sum_iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*proj_iter).day > (*sum_iter).day) {
|
|
|
|
AddToStats(prev_proj_stat, *sum_iter);
|
|
|
|
} else {
|
|
|
|
AddToStats(*proj_iter, *sum_iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
++sum_iter;
|
|
|
|
if (sum_iter == sumstats.end()) {
|
|
|
|
break;
|
|
|
|
}
|
2010-09-15 08:57:11 +00:00
|
|
|
}
|
|
|
|
|
2013-04-09 16:26:25 +00:00
|
|
|
if ((*proj_iter).day <= (*sum_iter).day) {
|
|
|
|
prev_proj_stat = *proj_iter;
|
|
|
|
++proj_iter;
|
|
|
|
if (proj_iter == (*i)->statistics.end()) {
|
|
|
|
for (; sum_iter != sumstats.end(); ++sum_iter) {
|
|
|
|
AddToStats(prev_proj_stat, *sum_iter);
|
|
|
|
}
|
|
|
|
break;
|
2010-09-14 14:04:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Draw graph
|
|
|
|
wxColour graphColour = wxColour(0,0,0);
|
|
|
|
int typePoint = 0;
|
|
|
|
getTypePoint(typePoint,count);
|
2014-08-10 22:33:07 +00:00
|
|
|
color_cycle(m_SelectedStatistic, n_command_buttons, graphColour);
|
2010-09-14 14:04:59 +00:00
|
|
|
DrawGraph2(dc, sumstats, graphColour, typePoint, m_SelectedStatistic);
|
|
|
|
// sumstats.clear();
|
2006-12-01 20:51:37 +00:00
|
|
|
//Draw marker
|
|
|
|
DrawMarker(dc);
|
2005-12-08 19:21:56 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-11-28 06:28:55 +00:00
|
|
|
default:{
|
2010-09-14 14:04:59 +00:00
|
|
|
m_ModeViewStatistic = mode_all_separate;
|
2005-11-28 06:28:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-09-10 11:14:10 +00:00
|
|
|
if (m_Space_for_scrollbar) {
|
|
|
|
dc.SetPen(wxPen(m_pen_MainColour , 1 , wxSOLID));
|
|
|
|
dc.DrawLine(w0 - m_Space_for_scrollbar - x0 - 1, y0, w0 - m_Space_for_scrollbar - x0 - 1, y0 + h0);
|
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
//=================================================================
|
|
|
|
void CPaintStatistics::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
2010-09-10 11:14:10 +00:00
|
|
|
#if USE_MEMORYDC
|
2006-12-01 20:51:37 +00:00
|
|
|
wxPaintDC pdc(this);
|
|
|
|
wxMemoryDC mdc;
|
2010-09-10 11:14:10 +00:00
|
|
|
#else
|
|
|
|
wxPaintDC mdc(this);
|
|
|
|
m_full_repaint=true;
|
|
|
|
#endif
|
2006-12-01 20:51:37 +00:00
|
|
|
wxCoord width = 0, height = 0;
|
|
|
|
GetClientSize(&width, &height);
|
|
|
|
if (m_full_repaint){
|
|
|
|
if (!m_GraphZoomStart){
|
|
|
|
ClearXY();
|
2007-04-20 03:26:12 +00:00
|
|
|
ClearLegendXY();
|
2006-12-01 20:51:37 +00:00
|
|
|
|
|
|
|
m_main_X_start = 0.0;
|
|
|
|
if (width > 0) m_main_X_end = double(width); else m_main_X_end = 0.0;
|
|
|
|
m_main_Y_start = 0.0;
|
|
|
|
if (height > 0) m_main_Y_end = double(height); else m_main_Y_end = 0.0;
|
|
|
|
|
|
|
|
if (width < 1) width = 1;
|
|
|
|
if (height < 1) height = 1;
|
2010-09-10 11:14:10 +00:00
|
|
|
#if USE_MEMORYDC
|
2006-12-01 20:51:37 +00:00
|
|
|
m_dc_bmp.Create(width, height);
|
|
|
|
mdc.SelectObject(m_dc_bmp);
|
2010-09-10 11:14:10 +00:00
|
|
|
#endif
|
2006-12-01 20:51:37 +00:00
|
|
|
DrawAll(mdc);
|
|
|
|
m_bmp_OK = true;
|
|
|
|
m_full_repaint = false;
|
|
|
|
}else if(m_bmp_OK){
|
2010-09-10 11:14:10 +00:00
|
|
|
#if USE_MEMORYDC
|
2006-12-01 20:51:37 +00:00
|
|
|
mdc.SelectObject(m_dc_bmp);
|
2010-09-10 11:14:10 +00:00
|
|
|
#endif
|
2006-12-01 20:51:37 +00:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if (m_bmp_OK){
|
2010-09-10 11:14:10 +00:00
|
|
|
#if USE_MEMORYDC
|
2006-12-01 20:51:37 +00:00
|
|
|
mdc.SelectObject(m_dc_bmp);
|
2010-09-10 11:14:10 +00:00
|
|
|
#endif
|
2006-12-01 20:51:37 +00:00
|
|
|
if (m_GraphZoomStart && (width == m_dc_bmp.GetWidth()) &&(height == m_dc_bmp.GetHeight())){
|
|
|
|
|
|
|
|
mdc.SetPen(wxPen(m_pen_ZoomRectColour , 1 , wxSOLID));
|
|
|
|
mdc.SetBrush(wxBrush(m_brush_ZoomRectColour , wxSOLID));
|
|
|
|
mdc.SetLogicalFunction(wxXOR);
|
|
|
|
|
|
|
|
wxCoord x0 = 0;
|
|
|
|
wxCoord y0 = 0;
|
|
|
|
wxCoord w0 = 0;
|
|
|
|
wxCoord h0 = 0;
|
|
|
|
|
|
|
|
if (m_GraphZoom_X1 < m_GraphZoom_X2_old) x0 = m_GraphZoom_X1;
|
|
|
|
else x0 = m_GraphZoom_X2_old;
|
|
|
|
if (m_GraphZoom_Y1 < m_GraphZoom_Y2_old) y0 = m_GraphZoom_Y1;
|
|
|
|
else y0 = m_GraphZoom_Y2_old;
|
|
|
|
w0 = m_GraphZoom_X2_old - m_GraphZoom_X1;
|
|
|
|
h0 = m_GraphZoom_Y2_old - m_GraphZoom_Y1;
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
if (w0 < 0) w0 = -w0;
|
|
|
|
if (h0 < 0) h0 = -h0;
|
|
|
|
mdc.DrawRectangle(x0, y0, w0, h0);
|
|
|
|
|
|
|
|
if (m_GraphZoom_X1 < m_GraphZoom_X2) x0 = m_GraphZoom_X1;
|
|
|
|
else x0 = m_GraphZoom_X2;
|
|
|
|
if (m_GraphZoom_Y1 < m_GraphZoom_Y2) y0 = m_GraphZoom_Y1;
|
|
|
|
else y0 = m_GraphZoom_Y2;
|
|
|
|
w0 = m_GraphZoom_X2 - m_GraphZoom_X1;
|
|
|
|
h0 = m_GraphZoom_Y2 - m_GraphZoom_Y1;
|
|
|
|
if (x0 < 0) x0 = 0;
|
|
|
|
if (y0 < 0) y0 = 0;
|
|
|
|
if (w0 < 0) w0 = -w0;
|
|
|
|
if (h0 < 0) h0 = -h0;
|
|
|
|
mdc.DrawRectangle(x0, y0, w0, h0);
|
|
|
|
|
|
|
|
m_GraphZoom_X2_old = m_GraphZoom_X2;
|
|
|
|
m_GraphZoom_Y2_old = m_GraphZoom_Y2;
|
|
|
|
|
|
|
|
mdc.SetLogicalFunction(wxCOPY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-10 11:14:10 +00:00
|
|
|
#if USE_MEMORYDC
|
2006-12-01 20:51:37 +00:00
|
|
|
if (m_bmp_OK && (width == m_dc_bmp.GetWidth()) &&(height == m_dc_bmp.GetHeight())){
|
2010-09-10 11:14:10 +00:00
|
|
|
pdc.Blit(0, 0, width - m_Space_for_scrollbar, height,& mdc, 0, 0);
|
2006-12-01 20:51:37 +00:00
|
|
|
}
|
|
|
|
mdc.SelectObject(wxNullBitmap);
|
2010-09-10 11:14:10 +00:00
|
|
|
#endif
|
2006-12-01 20:51:37 +00:00
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2006-11-03 19:33:53 +00:00
|
|
|
void CPaintStatistics::OnLeftMouseDown(wxMouseEvent& event) {
|
2007-04-20 03:26:12 +00:00
|
|
|
// Legend
|
|
|
|
if (m_Legend_dY > 0){
|
|
|
|
wxClientDC dc (this);
|
|
|
|
wxPoint pt(event.GetLogicalPosition(dc));
|
|
|
|
if((double(pt.y) > m_Legend_select_Y_start) && (double(pt.y) < m_Legend_select_Y_end) && (double(pt.x) > m_Legend_select_X_start) && (double(pt.x) < m_Legend_select_X_end)){
|
|
|
|
int i1 = (int)floor((double(pt.y) - m_Legend_select_Y_start) / m_Legend_dY);
|
|
|
|
switch (m_ModeViewStatistic){
|
2010-09-14 14:04:59 +00:00
|
|
|
case mode_one_project:
|
2007-04-20 03:26:12 +00:00
|
|
|
m_NextProjectStatistic = i1 + m_Legend_Shift_Mode1;
|
|
|
|
m_Zoom_Auto = true;
|
|
|
|
m_GraphMarker1 = false;
|
|
|
|
break;
|
2010-09-14 14:04:59 +00:00
|
|
|
case mode_all_separate:
|
|
|
|
case mode_all_together:
|
|
|
|
case mode_sum:
|
2007-04-20 03:26:12 +00:00
|
|
|
m_ViewHideProjectStatistic = i1 + m_Legend_Shift_Mode2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
m_full_repaint = true;
|
|
|
|
Refresh(false);
|
|
|
|
event.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Graph
|
2006-11-03 19:33:53 +00:00
|
|
|
switch (m_ModeViewStatistic){
|
2010-09-14 14:04:59 +00:00
|
|
|
case mode_one_project:
|
|
|
|
case mode_all_together:
|
|
|
|
case mode_sum:
|
|
|
|
{
|
2006-12-01 20:51:37 +00:00
|
|
|
wxClientDC dc (this);
|
|
|
|
wxPoint pt(event.GetLogicalPosition(dc));
|
2007-01-09 20:43:21 +00:00
|
|
|
if((double(pt.y) > m_Graph_Y_start) && (double(pt.y) < m_Graph_Y_end) && (double(pt.x) > m_Graph_X_start) && (double(pt.x) < m_Graph_X_end)){
|
2006-12-01 20:51:37 +00:00
|
|
|
m_GraphMarker_X1 = m_Ax_CoordToVal * double(pt.x) + m_Bx_CoordToVal;
|
|
|
|
m_GraphMarker_Y1 = m_Ay_CoordToVal * double(pt.y) + m_By_CoordToVal;
|
|
|
|
m_GraphMarker1 = true;
|
|
|
|
|
2007-01-09 20:43:21 +00:00
|
|
|
m_GraphZoom_X1 = wxCoord(pt.x);
|
|
|
|
m_GraphZoom_Y1 = wxCoord(pt.y);
|
|
|
|
m_GraphZoom_X2 = wxCoord(pt.x);
|
|
|
|
m_GraphZoom_Y2 = wxCoord(pt.y);
|
|
|
|
m_GraphZoom_X2_old = wxCoord(pt.x);
|
|
|
|
m_GraphZoom_Y2_old = wxCoord(pt.y);
|
2006-12-01 20:51:37 +00:00
|
|
|
|
|
|
|
m_GraphZoomStart = true;
|
2006-11-03 19:33:53 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
event.Skip();
|
2006-11-03 19:33:53 +00:00
|
|
|
}
|
2007-04-20 03:26:12 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
void CPaintStatistics::OnMouseMotion(wxMouseEvent& event) {
|
|
|
|
switch (m_ModeViewStatistic){
|
2010-09-14 14:04:59 +00:00
|
|
|
case mode_one_project:
|
|
|
|
case mode_all_together:
|
|
|
|
case mode_sum:
|
|
|
|
{
|
2006-12-01 20:51:37 +00:00
|
|
|
if (m_GraphZoomStart){
|
|
|
|
if (event.LeftIsDown()){
|
|
|
|
wxClientDC cdc (this);
|
|
|
|
wxPoint pt(event.GetLogicalPosition(cdc));
|
2007-01-09 20:43:21 +00:00
|
|
|
if((double(pt.y) > m_Graph_Y_start) && (double(pt.y) < m_Graph_Y_end) && (double(pt.x) > m_Graph_X_start) && (double(pt.x) < m_Graph_X_end)){
|
2006-11-03 19:33:53 +00:00
|
|
|
|
2007-01-09 20:43:21 +00:00
|
|
|
m_GraphZoom_X2 = wxCoord(pt.x);
|
|
|
|
m_GraphZoom_Y2 = wxCoord(pt.y);
|
2006-12-01 20:51:37 +00:00
|
|
|
|
|
|
|
m_full_repaint = false;
|
|
|
|
Refresh(false);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
m_GraphZoomStart = false;
|
2007-04-20 03:26:12 +00:00
|
|
|
|
|
|
|
m_full_repaint = true;
|
|
|
|
Refresh(false);
|
|
|
|
}
|
|
|
|
}else if (m_GraphMoveStart){
|
|
|
|
if (event.RightIsDown()){
|
|
|
|
wxClientDC cdc (this);
|
|
|
|
wxPoint pt(event.GetLogicalPosition(cdc));
|
|
|
|
if((double(pt.y) > m_Graph_Y_start) && (double(pt.y) < m_Graph_Y_end) && (double(pt.x) > m_Graph_X_start) && (double(pt.x) < m_Graph_X_end)){
|
|
|
|
|
|
|
|
m_GraphMove_X2 = wxCoord(pt.x);
|
|
|
|
m_GraphMove_Y2 = wxCoord(pt.y);
|
|
|
|
|
|
|
|
double X1 = m_Ax_CoordToVal * double(m_GraphMove_X1 - m_GraphMove_X2);
|
|
|
|
double Y1 = m_Ay_CoordToVal * double(m_GraphMove_Y1 - m_GraphMove_Y2);
|
|
|
|
|
|
|
|
if ( (X1 != 0) || (Y1 != 0)){
|
|
|
|
m_GraphMove_X1 = m_GraphMove_X2;
|
|
|
|
m_GraphMove_Y1 = m_GraphMove_Y2;
|
|
|
|
|
|
|
|
m_Zoom_min_val_X = m_Zoom_min_val_X + X1;
|
|
|
|
m_Zoom_max_val_X = m_Zoom_max_val_X + X1;
|
|
|
|
m_Zoom_min_val_Y = m_Zoom_min_val_Y + Y1;
|
|
|
|
m_Zoom_max_val_Y = m_Zoom_max_val_Y + Y1;
|
|
|
|
|
|
|
|
m_GraphMoveGo = true;
|
|
|
|
m_Zoom_Auto = false;
|
|
|
|
m_full_repaint = true;
|
|
|
|
Refresh(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
m_GraphMoveStart = false;
|
|
|
|
m_GraphMoveGo = false;
|
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
m_full_repaint = true;
|
|
|
|
Refresh(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
void CPaintStatistics::OnLeftMouseUp(wxMouseEvent& event) {
|
|
|
|
switch (m_ModeViewStatistic){
|
2010-09-14 14:04:59 +00:00
|
|
|
case mode_one_project:
|
|
|
|
case mode_all_together:
|
|
|
|
case mode_sum:
|
|
|
|
{
|
2006-12-01 20:51:37 +00:00
|
|
|
if (m_GraphZoomStart){
|
|
|
|
if ((abs(int(m_GraphZoom_X1 - m_GraphZoom_X2)) > 2) && (abs(int(m_GraphZoom_Y1 - m_GraphZoom_Y2)) > 2)){
|
|
|
|
double X1 = m_Ax_CoordToVal * double(m_GraphZoom_X1) + m_Bx_CoordToVal;
|
|
|
|
double Y1 = m_Ay_CoordToVal * double(m_GraphZoom_Y1) + m_By_CoordToVal;
|
|
|
|
double X2 = m_Ax_CoordToVal * double(m_GraphZoom_X2) + m_Bx_CoordToVal;
|
|
|
|
double Y2 = m_Ay_CoordToVal * double(m_GraphZoom_Y2) + m_By_CoordToVal;
|
|
|
|
|
|
|
|
if (X1 > X2){
|
|
|
|
m_Zoom_max_val_X = X1;
|
|
|
|
m_Zoom_min_val_X = X2;
|
|
|
|
}else{
|
|
|
|
m_Zoom_min_val_X = X1;
|
|
|
|
m_Zoom_max_val_X = X2;
|
|
|
|
}
|
|
|
|
if (Y1 > Y2){
|
|
|
|
m_Zoom_max_val_Y = Y1;
|
|
|
|
m_Zoom_min_val_Y = Y2;
|
|
|
|
}else{
|
|
|
|
m_Zoom_min_val_Y = Y1;
|
|
|
|
m_Zoom_max_val_Y = Y2;
|
|
|
|
}
|
|
|
|
m_GraphMarker1 = false;
|
|
|
|
m_Zoom_Auto = false;
|
|
|
|
}
|
|
|
|
m_GraphZoomStart = false;
|
|
|
|
m_full_repaint = true;
|
|
|
|
Refresh(false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
void CPaintStatistics::OnRightMouseDown(wxMouseEvent& event) {
|
2007-04-20 03:26:12 +00:00
|
|
|
switch (m_ModeViewStatistic){
|
2010-09-14 14:04:59 +00:00
|
|
|
case mode_one_project:
|
|
|
|
case mode_all_together:
|
|
|
|
case mode_sum:
|
|
|
|
{
|
2007-04-20 03:26:12 +00:00
|
|
|
if (m_GraphZoomStart){ //???
|
|
|
|
m_GraphZoomStart = false;
|
2006-12-01 20:51:37 +00:00
|
|
|
m_GraphMarker1 = false;
|
|
|
|
m_full_repaint = true;
|
|
|
|
Refresh(false);
|
2007-04-20 03:26:12 +00:00
|
|
|
}else{
|
|
|
|
wxClientDC dc (this);
|
|
|
|
wxPoint pt(event.GetLogicalPosition(dc));
|
|
|
|
if((double(pt.y) > m_Graph_Y_start) && (double(pt.y) < m_Graph_Y_end) && (double(pt.x) > m_Graph_X_start) && (double(pt.x) < m_Graph_X_end)){
|
|
|
|
m_GraphMove_X1 = wxCoord(pt.x);
|
|
|
|
m_GraphMove_Y1 = wxCoord(pt.y);
|
|
|
|
|
|
|
|
m_GraphMoveStart = true;
|
|
|
|
m_GraphMoveGo = false;
|
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
}
|
2007-04-20 03:26:12 +00:00
|
|
|
break;
|
2006-12-01 20:51:37 +00:00
|
|
|
}
|
|
|
|
}
|
2007-04-20 03:26:12 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
void CPaintStatistics::OnRightMouseUp(wxMouseEvent& event) {
|
|
|
|
if (m_GraphMoveGo){
|
|
|
|
m_GraphMoveStart = false;
|
|
|
|
m_GraphMoveGo = false;
|
|
|
|
}else if (m_GraphMarker1){
|
|
|
|
m_GraphMarker1 = false;
|
|
|
|
m_full_repaint = true;
|
|
|
|
Refresh(false);
|
|
|
|
}else if (!m_Zoom_Auto){
|
|
|
|
m_Zoom_Auto = true;
|
|
|
|
m_full_repaint = true;
|
|
|
|
Refresh(false);
|
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
void CPaintStatistics::OnMouseLeaveWindows(wxMouseEvent& event) {
|
|
|
|
if (m_GraphZoomStart){
|
|
|
|
m_GraphMarker1 = false;
|
|
|
|
m_GraphZoomStart = false;
|
|
|
|
m_full_repaint = true;
|
|
|
|
Refresh(false);
|
|
|
|
}
|
2007-04-20 03:26:12 +00:00
|
|
|
if (m_GraphMoveStart || m_GraphMoveGo){
|
|
|
|
m_GraphMoveStart = false;
|
|
|
|
m_GraphMoveGo = false;
|
|
|
|
}
|
2006-12-01 20:51:37 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|
2010-09-10 11:14:10 +00:00
|
|
|
|
|
|
|
void CPaintStatistics::OnLegendScroll(wxScrollEvent& event) {
|
|
|
|
m_full_repaint = true;
|
|
|
|
Refresh(false);
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
2005-11-14 22:06:17 +00:00
|
|
|
void CPaintStatistics::OnSize(wxSizeEvent& event) {
|
2006-12-01 20:51:37 +00:00
|
|
|
m_full_repaint = true;
|
2006-11-03 19:33:53 +00:00
|
|
|
Refresh(false);
|
2013-10-24 12:49:59 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
ResizeMacAccessibilitySupport();
|
|
|
|
#endif
|
2005-11-14 22:06:17 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
2005-04-04 06:02:36 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CViewStatistics, CBOINCBaseView)
|
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
BEGIN_EVENT_TABLE (CViewStatistics, CBOINCBaseView)
|
|
|
|
EVT_BUTTON(ID_TASK_STATISTICS_USERTOTAL, CViewStatistics::OnStatisticsUserTotal)
|
|
|
|
EVT_BUTTON(ID_TASK_STATISTICS_USERAVERAGE, CViewStatistics::OnStatisticsUserAverage)
|
|
|
|
EVT_BUTTON(ID_TASK_STATISTICS_HOSTTOTAL, CViewStatistics::OnStatisticsHostTotal)
|
|
|
|
EVT_BUTTON(ID_TASK_STATISTICS_HOSTAVERAGE, CViewStatistics::OnStatisticsHostAverage)
|
2010-09-14 14:04:59 +00:00
|
|
|
EVT_BUTTON(ID_TASK_STATISTICS_MODEVIEWALLSEPARATE, CViewStatistics::OnStatisticsModeViewAllSeparate)
|
|
|
|
EVT_BUTTON(ID_TASK_STATISTICS_MODEVIEWONEPROJECT, CViewStatistics::OnStatisticsModeViewOneProject)
|
|
|
|
EVT_BUTTON(ID_TASK_STATISTICS_MODEVIEWALLTOGETHER, CViewStatistics::OnStatisticsModeViewAllTogether)
|
|
|
|
EVT_BUTTON(ID_TASK_STATISTICS_MODEVIEWSUM, CViewStatistics::OnStatisticsModeViewSum)
|
2005-11-28 06:28:55 +00:00
|
|
|
EVT_BUTTON(ID_TASK_STATISTICS_NEXTPROJECT, CViewStatistics::OnStatisticsNextProject)
|
2006-01-20 22:57:32 +00:00
|
|
|
EVT_BUTTON(ID_TASK_STATISTICS_PREVPROJECT, CViewStatistics::OnStatisticsPrevProject)
|
2010-09-10 11:14:10 +00:00
|
|
|
EVT_BUTTON(ID_TASK_STATISTICS_HIDEPROJLIST, CViewStatistics::OnShowHideProjectList)
|
2005-04-21 06:04:26 +00:00
|
|
|
END_EVENT_TABLE ()
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-09-02 18:40:06 +00:00
|
|
|
CViewStatistics::CViewStatistics()
|
|
|
|
{}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
CViewStatistics::CViewStatistics(wxNotebook* pNotebook) :
|
2005-09-06 06:18:36 +00:00
|
|
|
CBOINCBaseView(pNotebook)
|
2005-04-21 06:04:26 +00:00
|
|
|
{
|
2005-11-28 06:28:55 +00:00
|
|
|
CTaskItemGroup* pGroup = NULL;
|
|
|
|
CTaskItem* pItem = NULL;
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2021-02-21 03:34:51 +00:00
|
|
|
//
|
|
|
|
// Setup View
|
|
|
|
//
|
|
|
|
wxFlexGridSizer* itemFlexGridSizer = new wxFlexGridSizer(2, 0, 0);
|
|
|
|
wxASSERT(itemFlexGridSizer);
|
|
|
|
|
|
|
|
itemFlexGridSizer->AddGrowableRow(0);
|
|
|
|
itemFlexGridSizer->AddGrowableCol(1);
|
2012-01-06 17:12:19 +00:00
|
|
|
|
2021-02-21 03:34:51 +00:00
|
|
|
m_pTaskPane = new CBOINCTaskCtrl(this, ID_TASK_STATISTICSVIEW, DEFAULT_TASK_FLAGS);
|
|
|
|
wxASSERT(m_pTaskPane);
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-11-28 06:28:55 +00:00
|
|
|
m_PaintStatistics = new CPaintStatistics(this, ID_LIST_STATISTICSVIEW, wxDefaultPosition, wxSize(-1, -1), 0);
|
|
|
|
wxASSERT(m_PaintStatistics);
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2021-02-20 20:31:18 +00:00
|
|
|
m_pTaskPane->SetLayoutDirection(wxLayout_LeftToRight);
|
|
|
|
m_PaintStatistics->SetLayoutDirection(wxLayout_LeftToRight);
|
2021-02-21 03:34:51 +00:00
|
|
|
itemFlexGridSizer->Add(m_pTaskPane, 1, wxGROW|wxALL, 1);
|
|
|
|
itemFlexGridSizer->Add(m_PaintStatistics, 1, wxGROW|wxALL, 1);
|
2012-01-06 17:12:19 +00:00
|
|
|
|
2021-02-21 03:34:51 +00:00
|
|
|
SetSizer(itemFlexGridSizer);
|
2012-01-06 17:12:19 +00:00
|
|
|
|
2021-02-21 03:34:51 +00:00
|
|
|
Layout();
|
2005-07-22 22:57:38 +00:00
|
|
|
|
2006-02-08 06:56:34 +00:00
|
|
|
pGroup = new CTaskItemGroup( _("Commands") );
|
2005-11-28 06:28:55 +00:00
|
|
|
m_TaskGroups.push_back( pGroup );
|
2005-04-21 06:04:26 +00:00
|
|
|
|
2005-11-28 06:28:55 +00:00
|
|
|
pItem = new CTaskItem(
|
2021-02-21 03:34:51 +00:00
|
|
|
_("Show user total"),
|
|
|
|
_("Show total credit for user"),
|
|
|
|
ID_TASK_STATISTICS_USERTOTAL
|
|
|
|
);
|
|
|
|
pGroup->m_Tasks.push_back( pItem );
|
2005-04-21 06:04:26 +00:00
|
|
|
|
2005-11-28 06:28:55 +00:00
|
|
|
pItem = new CTaskItem(
|
2021-02-21 03:34:51 +00:00
|
|
|
_("Show user average"),
|
|
|
|
_("Show average credit for user"),
|
|
|
|
ID_TASK_STATISTICS_USERAVERAGE
|
|
|
|
);
|
|
|
|
pGroup->m_Tasks.push_back( pItem );
|
2005-04-21 06:04:26 +00:00
|
|
|
|
2005-11-28 06:28:55 +00:00
|
|
|
pItem = new CTaskItem(
|
2021-02-21 03:34:51 +00:00
|
|
|
_("Show host total"),
|
|
|
|
_("Show total credit for host"),
|
|
|
|
ID_TASK_STATISTICS_HOSTTOTAL
|
|
|
|
);
|
|
|
|
pGroup->m_Tasks.push_back( pItem );
|
2005-04-21 06:04:26 +00:00
|
|
|
|
2005-11-28 06:28:55 +00:00
|
|
|
pItem = new CTaskItem(
|
2021-02-21 03:34:51 +00:00
|
|
|
_("Show host average"),
|
|
|
|
_("Show average credit for host"),
|
|
|
|
ID_TASK_STATISTICS_HOSTAVERAGE
|
|
|
|
);
|
|
|
|
pGroup->m_Tasks.push_back( pItem );
|
2006-01-20 22:57:32 +00:00
|
|
|
|
|
|
|
pGroup = new CTaskItemGroup( _("Project") );
|
|
|
|
m_TaskGroups.push_back( pGroup );
|
|
|
|
|
|
|
|
pItem = new CTaskItem(
|
2021-02-21 03:34:51 +00:00
|
|
|
_("< &Previous project"),
|
|
|
|
_("Show chart for previous project"),
|
|
|
|
ID_TASK_STATISTICS_PREVPROJECT
|
|
|
|
);
|
|
|
|
pGroup->m_Tasks.push_back( pItem );
|
2006-01-20 22:57:32 +00:00
|
|
|
pItem = new CTaskItem(
|
2021-02-21 03:34:51 +00:00
|
|
|
_("&Next project >"),
|
|
|
|
_("Show chart for next project"),
|
|
|
|
ID_TASK_STATISTICS_NEXTPROJECT
|
|
|
|
);
|
|
|
|
pGroup->m_Tasks.push_back( pItem );
|
2010-09-10 11:14:10 +00:00
|
|
|
|
|
|
|
pItem = new CTaskItem(
|
2021-02-21 03:34:51 +00:00
|
|
|
_("Hide project list"),
|
|
|
|
_("Use entire area for graphs"),
|
|
|
|
ID_TASK_STATISTICS_HIDEPROJLIST
|
|
|
|
);
|
|
|
|
pGroup->m_Tasks.push_back( pItem );
|
2005-04-21 06:04:26 +00:00
|
|
|
|
2005-12-08 19:21:56 +00:00
|
|
|
pGroup = new CTaskItemGroup( _("Mode view") );
|
|
|
|
m_TaskGroups.push_back( pGroup );
|
2005-11-28 06:28:55 +00:00
|
|
|
|
|
|
|
pItem = new CTaskItem(
|
2021-02-21 03:34:51 +00:00
|
|
|
_("One project"),
|
|
|
|
_("Show one chart with selected project"),
|
|
|
|
ID_TASK_STATISTICS_MODEVIEWONEPROJECT
|
|
|
|
);
|
|
|
|
pGroup->m_Tasks.push_back( pItem );
|
2006-01-20 22:57:32 +00:00
|
|
|
|
|
|
|
pItem = new CTaskItem(
|
2021-02-21 03:34:51 +00:00
|
|
|
_("All projects (separate)"),
|
|
|
|
_("Show all projects, one chart per project"),
|
|
|
|
ID_TASK_STATISTICS_MODEVIEWALLSEPARATE
|
|
|
|
);
|
|
|
|
pGroup->m_Tasks.push_back( pItem );
|
2010-09-14 14:04:59 +00:00
|
|
|
|
|
|
|
pItem = new CTaskItem(
|
2021-02-21 03:34:51 +00:00
|
|
|
_("All projects (together)"),
|
|
|
|
_("Show one chart with all projects"),
|
|
|
|
ID_TASK_STATISTICS_MODEVIEWALLTOGETHER
|
|
|
|
);
|
|
|
|
pGroup->m_Tasks.push_back( pItem );
|
2010-09-14 14:04:59 +00:00
|
|
|
|
|
|
|
pItem = new CTaskItem(
|
2021-02-21 03:34:51 +00:00
|
|
|
_("All projects (sum)"),
|
|
|
|
_("Show one chart with sum of projects"),
|
|
|
|
ID_TASK_STATISTICS_MODEVIEWSUM
|
|
|
|
);
|
|
|
|
pGroup->m_Tasks.push_back( pItem );
|
2010-09-14 14:04:59 +00:00
|
|
|
|
2021-02-21 03:34:51 +00:00
|
|
|
// Create Task Pane Items
|
|
|
|
m_pTaskPane->UpdateControls();
|
2005-04-22 01:46:32 +00:00
|
|
|
|
2021-02-21 03:34:51 +00:00
|
|
|
UpdateSelection();
|
2005-04-21 06:04:26 +00:00
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
CViewStatistics::~CViewStatistics() {
|
|
|
|
EmptyTasks();
|
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-09-02 21:03:36 +00:00
|
|
|
wxString& CViewStatistics::GetViewName() {
|
2009-05-01 01:32:26 +00:00
|
|
|
static wxString strViewName(wxT("Statistics"));
|
2005-09-02 20:56:08 +00:00
|
|
|
return strViewName;
|
2005-04-21 06:04:26 +00:00
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
- fixes #207 - HTML entities in BOINC Manager have to be decoded
BOINC Manager can now properly decode HTML entites for the
following elements:
Projects Tab:
Project Name
User Name
Team Name
Work Tab:
Project Name
Application Name
Transfers Tab:
Project Name
Messages Tab:
Project Name
Disk Tab:
Project Name
- fixes #212 - Info in columns misaligned on switching views
- Properly restore which tab view the user left from when going
to the advanced view from the simple view
- Fix the problem that caused the manager to wait for 7 seconds
to display anything on initial startup.
- Store the various Grid/List persisted data seperately so that
the different header sizes don't cause problems.
clientgui/
AdvancedFrame.cpp
BOINCBaseView.cpp, .h
BOINCGridCtrl.cpp
ViewMessages.cpp, .h
ViewMessagesGrid.cpp, .h
ViewProjects.cpp, .h
ViewProjectsGrid.cpp, .h
ViewResources.cpp, .h
ViewStatistics.cpp, .h
ViewTransfers.cpp, .h
ViewTransfersGrid.cpp, .h
ViewWork.cpp, .h
ViewWorkGrid.cpp, .h
lib/
gui_rpc_client_ops.C
svn path=/trunk/boinc/; revision=12761
2007-05-29 05:07:35 +00:00
|
|
|
wxString& CViewStatistics::GetViewDisplayName() {
|
|
|
|
static wxString strViewName(_("Statistics"));
|
|
|
|
return strViewName;
|
|
|
|
}
|
|
|
|
|
2006-02-16 18:01:46 +00:00
|
|
|
const char** CViewStatistics::GetViewIcon() {
|
|
|
|
return stats_xpm;
|
|
|
|
}
|
|
|
|
|
2013-02-07 18:26:02 +00:00
|
|
|
int CViewStatistics::GetViewRefreshRate() {
|
2006-12-29 16:35:33 +00:00
|
|
|
return 60;
|
|
|
|
}
|
|
|
|
|
2013-02-07 18:26:02 +00:00
|
|
|
int CViewStatistics::GetViewCurrentViewPage() {
|
2009-12-22 01:22:11 +00:00
|
|
|
return VW_STAT;
|
|
|
|
}
|
|
|
|
|
2005-07-07 22:26:49 +00:00
|
|
|
void CViewStatistics::OnStatisticsUserTotal( wxCommandEvent& WXUNUSED(event) ) {
|
2005-04-21 06:04:26 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsUserTotal - Function Begin"));
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2007-04-20 03:26:12 +00:00
|
|
|
CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pFrame);
|
2006-06-24 05:00:57 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
m_PaintStatistics->m_SelectedStatistic = show_user_total;
|
2006-12-01 20:51:37 +00:00
|
|
|
m_PaintStatistics->m_Zoom_Auto = true;
|
|
|
|
m_PaintStatistics->m_GraphMarker1 = false;
|
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-21 23:14:10 +00:00
|
|
|
UpdateSelection();
|
2005-05-05 06:07:14 +00:00
|
|
|
pFrame->FireRefreshView();
|
2005-04-21 23:14:10 +00:00
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsUserTotal - Function End"));
|
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-07-07 22:26:49 +00:00
|
|
|
void CViewStatistics::OnStatisticsUserAverage( wxCommandEvent& WXUNUSED(event) ) {
|
2005-04-21 06:04:26 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsUserAverage - Function Begin"));
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2006-06-24 05:00:57 +00:00
|
|
|
CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pFrame);
|
2006-06-24 05:00:57 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
m_PaintStatistics->m_SelectedStatistic = show_user_average;
|
2006-12-01 20:51:37 +00:00
|
|
|
m_PaintStatistics->m_Zoom_Auto = true;
|
|
|
|
m_PaintStatistics->m_GraphMarker1 = false;
|
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-21 23:14:10 +00:00
|
|
|
UpdateSelection();
|
2005-05-05 06:07:14 +00:00
|
|
|
pFrame->FireRefreshView();
|
2005-04-21 23:14:10 +00:00
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsUserAverage - Function End"));
|
2005-04-04 06:02:36 +00:00
|
|
|
}
|
|
|
|
|
2005-07-07 22:26:49 +00:00
|
|
|
void CViewStatistics::OnStatisticsHostTotal( wxCommandEvent& WXUNUSED(event) ) {
|
2005-04-21 06:04:26 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsHostTotal - Function Begin"));
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2006-06-24 05:00:57 +00:00
|
|
|
CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
|
2005-04-21 06:04:26 +00:00
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pFrame);
|
2006-06-24 05:00:57 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
m_PaintStatistics->m_SelectedStatistic = show_host_total;
|
2006-12-01 20:51:37 +00:00
|
|
|
m_PaintStatistics->m_Zoom_Auto = true;
|
|
|
|
m_PaintStatistics->m_GraphMarker1 = false;
|
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-21 23:14:10 +00:00
|
|
|
UpdateSelection();
|
2005-05-05 06:07:14 +00:00
|
|
|
pFrame->FireRefreshView();
|
2005-04-21 23:14:10 +00:00
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsHostTotal - Function End"));
|
2005-04-07 07:04:50 +00:00
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
|
|
|
|
2005-07-07 22:26:49 +00:00
|
|
|
void CViewStatistics::OnStatisticsHostAverage( wxCommandEvent& WXUNUSED(event) ) {
|
2005-04-21 06:04:26 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsHostAverage - Function Begin"));
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2006-06-24 05:00:57 +00:00
|
|
|
CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pFrame);
|
2006-06-24 05:00:57 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
m_PaintStatistics->m_SelectedStatistic = show_host_average;
|
2006-12-01 20:51:37 +00:00
|
|
|
m_PaintStatistics->m_Zoom_Auto = true;
|
|
|
|
m_PaintStatistics->m_GraphMarker1 = false;
|
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
2005-04-21 06:04:26 +00:00
|
|
|
|
2005-04-21 23:14:10 +00:00
|
|
|
UpdateSelection();
|
2005-05-05 06:07:14 +00:00
|
|
|
pFrame->FireRefreshView();
|
2005-04-21 23:14:10 +00:00
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsHostAverage - Function End"));
|
2005-04-04 06:02:36 +00:00
|
|
|
}
|
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
void CViewStatistics::OnStatisticsModeViewAllSeparate( wxCommandEvent& WXUNUSED(event) ) {
|
2005-11-28 06:28:55 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsModeView - Function Begin"));
|
|
|
|
|
2006-06-24 05:00:57 +00:00
|
|
|
CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
|
2005-11-28 06:28:55 +00:00
|
|
|
|
|
|
|
wxASSERT(pFrame);
|
2006-06-24 05:00:57 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
|
2005-11-28 06:28:55 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
m_PaintStatistics->m_ModeViewStatistic = mode_all_separate;
|
2006-12-01 20:51:37 +00:00
|
|
|
m_PaintStatistics->m_Zoom_Auto = true;
|
|
|
|
m_PaintStatistics->m_GraphMarker1 = false;
|
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
2006-01-20 22:57:32 +00:00
|
|
|
|
|
|
|
UpdateSelection();
|
|
|
|
pFrame->FireRefreshView();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsModeView - Function End"));
|
|
|
|
}
|
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
void CViewStatistics::OnStatisticsModeViewOneProject( wxCommandEvent& WXUNUSED(event) ) {
|
2006-01-20 22:57:32 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsModeView - Function Begin"));
|
|
|
|
|
2006-06-24 05:00:57 +00:00
|
|
|
CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
|
2006-01-20 22:57:32 +00:00
|
|
|
|
|
|
|
wxASSERT(pFrame);
|
2006-06-24 05:00:57 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
|
2006-01-20 22:57:32 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
m_PaintStatistics->m_ModeViewStatistic = mode_one_project;
|
2006-12-01 20:51:37 +00:00
|
|
|
m_PaintStatistics->m_Zoom_Auto = true;
|
|
|
|
m_PaintStatistics->m_GraphMarker1 = false;
|
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
2006-01-20 22:57:32 +00:00
|
|
|
|
|
|
|
UpdateSelection();
|
|
|
|
pFrame->FireRefreshView();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsModeView - Function End"));
|
|
|
|
}
|
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
void CViewStatistics::OnStatisticsModeViewAllTogether( wxCommandEvent& WXUNUSED(event) ) {
|
2006-01-20 22:57:32 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsModeView - Function Begin"));
|
|
|
|
|
2006-06-24 05:00:57 +00:00
|
|
|
CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
|
2006-01-20 22:57:32 +00:00
|
|
|
|
|
|
|
wxASSERT(pFrame);
|
2006-06-24 05:00:57 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
|
2006-01-20 22:57:32 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
m_PaintStatistics->m_ModeViewStatistic = mode_all_together;
|
|
|
|
m_PaintStatistics->m_Zoom_Auto = true;
|
|
|
|
m_PaintStatistics->m_GraphMarker1 = false;
|
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
|
|
|
|
|
|
|
UpdateSelection();
|
|
|
|
pFrame->FireRefreshView();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsModeView - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CViewStatistics::OnStatisticsModeViewSum( wxCommandEvent& WXUNUSED(event) ) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsModeView - Function Begin"));
|
|
|
|
|
|
|
|
CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
|
|
|
|
|
|
|
|
wxASSERT(pFrame);
|
|
|
|
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
|
|
|
|
|
|
|
|
m_PaintStatistics->m_ModeViewStatistic = mode_sum;
|
2006-12-01 20:51:37 +00:00
|
|
|
m_PaintStatistics->m_Zoom_Auto = true;
|
|
|
|
m_PaintStatistics->m_GraphMarker1 = false;
|
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
2005-11-28 06:28:55 +00:00
|
|
|
|
|
|
|
UpdateSelection();
|
|
|
|
pFrame->FireRefreshView();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsModeView - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CViewStatistics::OnStatisticsNextProject( wxCommandEvent& WXUNUSED(event) ) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsNextProject - Function Begin"));
|
|
|
|
|
2006-06-24 05:00:57 +00:00
|
|
|
CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
|
2005-11-28 06:28:55 +00:00
|
|
|
|
|
|
|
wxASSERT(pFrame);
|
2006-06-24 05:00:57 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
|
2005-11-28 06:28:55 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
if (m_PaintStatistics->m_ModeViewStatistic == mode_one_project) m_PaintStatistics->m_NextProjectStatistic++;
|
2006-12-01 20:51:37 +00:00
|
|
|
m_PaintStatistics->m_Zoom_Auto = true;
|
|
|
|
m_PaintStatistics->m_GraphMarker1 = false;
|
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
2010-09-14 14:04:59 +00:00
|
|
|
if (m_PaintStatistics->m_ModeViewStatistic == mode_all_separate) m_PaintStatistics->m_Legend_Shift_Mode2++;
|
|
|
|
if (m_PaintStatistics->m_ModeViewStatistic == mode_all_together) m_PaintStatistics->m_Legend_Shift_Mode2++;
|
2010-09-15 09:09:29 +00:00
|
|
|
if (m_PaintStatistics->m_ModeViewStatistic == mode_sum) m_PaintStatistics->m_Legend_Shift_Mode2++;
|
2005-11-28 06:28:55 +00:00
|
|
|
|
|
|
|
UpdateSelection();
|
|
|
|
pFrame->FireRefreshView();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsNextProject - Function End"));
|
|
|
|
}
|
|
|
|
|
2006-01-20 22:57:32 +00:00
|
|
|
void CViewStatistics::OnStatisticsPrevProject( wxCommandEvent& WXUNUSED(event) ) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsPrevProject - Function Begin"));
|
|
|
|
|
2006-06-24 05:00:57 +00:00
|
|
|
CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
|
2006-01-20 22:57:32 +00:00
|
|
|
|
|
|
|
wxASSERT(pFrame);
|
2006-06-24 05:00:57 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
|
2006-01-20 22:57:32 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
if (m_PaintStatistics->m_ModeViewStatistic == mode_one_project) m_PaintStatistics->m_NextProjectStatistic--;
|
2006-12-01 20:51:37 +00:00
|
|
|
m_PaintStatistics->m_Zoom_Auto = true;
|
|
|
|
m_PaintStatistics->m_GraphMarker1 = false;
|
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
2010-09-14 14:04:59 +00:00
|
|
|
if (m_PaintStatistics->m_ModeViewStatistic == mode_all_separate) m_PaintStatistics->m_Legend_Shift_Mode2--;
|
|
|
|
if (m_PaintStatistics->m_ModeViewStatistic == mode_all_together) m_PaintStatistics->m_Legend_Shift_Mode2--;
|
2010-09-15 09:09:29 +00:00
|
|
|
if (m_PaintStatistics->m_ModeViewStatistic == mode_sum) m_PaintStatistics->m_Legend_Shift_Mode2--;
|
2006-01-20 22:57:32 +00:00
|
|
|
|
|
|
|
UpdateSelection();
|
|
|
|
pFrame->FireRefreshView();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsPrevProject - Function End"));
|
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2010-09-10 11:14:10 +00:00
|
|
|
void CViewStatistics::OnShowHideProjectList( wxCommandEvent& WXUNUSED(event) ) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnShowHideProjectList - Function Begin"));
|
|
|
|
|
|
|
|
m_PaintStatistics->m_LegendDraw = !m_PaintStatistics->m_LegendDraw;
|
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
|
|
|
m_PaintStatistics->Refresh(false);
|
|
|
|
UpdateSelection();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnShowHideProjectList - Function End"));
|
|
|
|
}
|
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
bool CViewStatistics::OnSaveState(wxConfigBase* pConfig) {
|
|
|
|
bool bReturnValue = true;
|
2005-04-08 06:24:58 +00:00
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pConfig);
|
|
|
|
wxASSERT(m_pTaskPane);
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
if (!m_pTaskPane->OnSaveState(pConfig)) {
|
|
|
|
bReturnValue = false;
|
|
|
|
}
|
2006-11-03 19:33:53 +00:00
|
|
|
//--
|
|
|
|
wxString strBaseConfigLocation = wxEmptyString;
|
2009-03-09 18:02:37 +00:00
|
|
|
strBaseConfigLocation = wxT("/Statistics");
|
2006-11-03 19:33:53 +00:00
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
2006-12-01 20:51:37 +00:00
|
|
|
pConfig->Write(wxT("ModeViewStatistic"), m_PaintStatistics->m_ModeViewStatistic);
|
|
|
|
pConfig->Write(wxT("SelectedStatistic"), m_PaintStatistics->m_SelectedStatistic);
|
|
|
|
pConfig->Write(wxT("NextProjectStatistic"), m_PaintStatistics->m_NextProjectStatistic);
|
2009-03-09 18:02:37 +00:00
|
|
|
strBaseConfigLocation = wxT("/Statistics/ViewAll");
|
2007-01-09 20:43:21 +00:00
|
|
|
pConfig->DeleteGroup(strBaseConfigLocation);
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
int count = -1;
|
|
|
|
for (std::set<wxString>::const_iterator i_s = m_PaintStatistics->m_HideProjectStatistic.begin(); i_s != m_PaintStatistics->m_HideProjectStatistic.end(); ++i_s) {
|
|
|
|
++count;
|
|
|
|
pConfig->Write(wxString::Format(wxT("%d"), count), (*i_s));
|
|
|
|
}
|
2006-11-03 19:33:53 +00:00
|
|
|
//--
|
2005-04-21 06:04:26 +00:00
|
|
|
return bReturnValue;
|
|
|
|
}
|
2005-04-08 06:24:58 +00:00
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
bool CViewStatistics::OnRestoreState(wxConfigBase* pConfig) {
|
2006-11-03 19:33:53 +00:00
|
|
|
wxASSERT(pConfig);
|
2005-04-21 06:04:26 +00:00
|
|
|
wxASSERT(m_pTaskPane);
|
2005-04-08 06:24:58 +00:00
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
if (!m_pTaskPane->OnRestoreState(pConfig)) {
|
|
|
|
return false;
|
|
|
|
}
|
2006-11-03 19:33:53 +00:00
|
|
|
//--
|
2006-12-01 20:51:37 +00:00
|
|
|
int iTempValue = 0;
|
2006-11-03 19:33:53 +00:00
|
|
|
wxString strBaseConfigLocation = wxEmptyString;
|
2009-03-09 18:02:37 +00:00
|
|
|
strBaseConfigLocation = wxT("/Statistics");
|
2006-11-03 19:33:53 +00:00
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
2005-04-08 06:24:58 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
m_PaintStatistics->m_ModeViewStatistic = mode_all_separate;
|
2006-11-03 19:33:53 +00:00
|
|
|
pConfig->Read(wxT("ModeViewStatistic"), &iTempValue, -1);
|
2010-09-15 09:09:29 +00:00
|
|
|
if ((iTempValue >= mode_one_project) && (iTempValue <= mode_sum))m_PaintStatistics->m_ModeViewStatistic = iTempValue;
|
2006-11-03 19:33:53 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
m_PaintStatistics->m_SelectedStatistic = show_user_total;
|
2006-11-03 19:33:53 +00:00
|
|
|
pConfig->Read(wxT("SelectedStatistic"), &iTempValue, -1);
|
2010-09-15 09:09:29 +00:00
|
|
|
if ((iTempValue >= show_user_total) && (iTempValue <= show_host_average))m_PaintStatistics->m_SelectedStatistic = iTempValue;
|
2006-11-03 19:33:53 +00:00
|
|
|
|
2006-12-01 20:51:37 +00:00
|
|
|
m_PaintStatistics->m_NextProjectStatistic = 0;
|
2006-11-03 19:33:53 +00:00
|
|
|
pConfig->Read(wxT("NextProjectStatistic"), &iTempValue, -1);
|
2006-12-01 20:51:37 +00:00
|
|
|
if (iTempValue >= 0)m_PaintStatistics->m_NextProjectStatistic = iTempValue;
|
2007-01-09 20:43:21 +00:00
|
|
|
// -- Hide View All projects
|
2009-10-07 19:00:02 +00:00
|
|
|
strBaseConfigLocation = wxT("/Statistics/ViewAll");
|
2007-01-09 20:43:21 +00:00
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
wxString tmpstr1;
|
|
|
|
if (!(m_PaintStatistics->m_HideProjectStatistic.empty())) m_PaintStatistics->m_HideProjectStatistic.clear();
|
|
|
|
for (int count = 0; count < 1000; ++count) {
|
2007-01-10 22:19:29 +00:00
|
|
|
pConfig->Read(wxString::Format(wxT("%d"), count), &tmpstr1, wxT(""));
|
|
|
|
if (tmpstr1 == wxEmptyString){
|
2007-01-09 20:43:21 +00:00
|
|
|
break;
|
|
|
|
}else{
|
|
|
|
m_PaintStatistics->m_HideProjectStatistic.insert(tmpstr1);
|
|
|
|
}
|
|
|
|
}
|
2010-09-14 14:04:59 +00:00
|
|
|
|
|
|
|
UpdateSelection();
|
2005-04-21 06:04:26 +00:00
|
|
|
return true;
|
2005-04-04 06:02:36 +00:00
|
|
|
}
|
|
|
|
|
2005-07-07 22:26:49 +00:00
|
|
|
void CViewStatistics::OnListRender( wxTimerEvent& WXUNUSED(event) ) {
|
2006-04-17 20:26:59 +00:00
|
|
|
if (wxGetApp().GetDocument()->GetStatisticsCount()) {
|
2006-12-01 20:51:37 +00:00
|
|
|
m_PaintStatistics->m_full_repaint = true;
|
2006-11-03 19:33:53 +00:00
|
|
|
m_PaintStatistics->Refresh(false);
|
2005-11-28 06:28:55 +00:00
|
|
|
}
|
2005-04-21 06:04:26 +00:00
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
void CViewStatistics::UpdateSelection() {
|
2010-09-10 11:14:10 +00:00
|
|
|
CTaskItemGroup* pGroup = m_TaskGroups[0];
|
|
|
|
|
2006-01-09 14:03:13 +00:00
|
|
|
CBOINCBaseView::PreUpdateSelection();
|
2010-09-10 11:14:10 +00:00
|
|
|
|
2010-09-14 14:04:59 +00:00
|
|
|
pGroup->m_Tasks[show_user_total]->m_pButton->Enable(m_PaintStatistics->m_SelectedStatistic != show_user_total);
|
|
|
|
pGroup->m_Tasks[show_user_average]->m_pButton->Enable(m_PaintStatistics->m_SelectedStatistic != show_user_average);
|
|
|
|
pGroup->m_Tasks[show_host_total]->m_pButton->Enable(m_PaintStatistics->m_SelectedStatistic != show_host_total);
|
|
|
|
pGroup->m_Tasks[show_host_average]->m_pButton->Enable(m_PaintStatistics->m_SelectedStatistic != show_host_average);
|
2010-09-10 11:14:10 +00:00
|
|
|
|
|
|
|
pGroup = m_TaskGroups[1];
|
2010-09-14 14:04:59 +00:00
|
|
|
pGroup->m_Tasks[previous_project]->m_pButton->Enable(m_PaintStatistics->m_ModeViewStatistic == mode_one_project);
|
|
|
|
pGroup->m_Tasks[next_project]->m_pButton->Enable(m_PaintStatistics->m_ModeViewStatistic == mode_one_project);
|
2010-09-10 11:14:10 +00:00
|
|
|
|
|
|
|
if (m_PaintStatistics->m_LegendDraw) {
|
|
|
|
m_pTaskPane->UpdateTask(
|
2010-09-14 14:04:59 +00:00
|
|
|
pGroup->m_Tasks[show_hide_project_list], _("Hide project list"), _("Use entire area for graphs")
|
2010-09-10 11:14:10 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
m_pTaskPane->UpdateTask(
|
2010-09-14 14:04:59 +00:00
|
|
|
pGroup->m_Tasks[show_hide_project_list], _("Show project list"), _("Uses smaller area for graphs")
|
2010-09-10 11:14:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
pGroup = m_TaskGroups[2];
|
2010-09-14 14:04:59 +00:00
|
|
|
pGroup->m_Tasks[mode_one_project]->m_pButton->Enable(m_PaintStatistics->m_ModeViewStatistic != mode_one_project);
|
|
|
|
pGroup->m_Tasks[mode_all_separate]->m_pButton->Enable(m_PaintStatistics->m_ModeViewStatistic != mode_all_separate);
|
|
|
|
pGroup->m_Tasks[mode_all_together]->m_pButton->Enable(m_PaintStatistics->m_ModeViewStatistic != mode_all_together);
|
|
|
|
pGroup->m_Tasks[mode_sum]->m_pButton->Enable(m_PaintStatistics->m_ModeViewStatistic != mode_sum);
|
2010-09-10 11:14:10 +00:00
|
|
|
|
2006-01-09 14:03:13 +00:00
|
|
|
CBOINCBaseView::PostUpdateSelection();
|
2005-04-21 06:04:26 +00:00
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|