Esempio n. 1
0
void LineChartCanvas::UpdateAll()
{
	invalidateBms();
	UpdateMargins();
	PopulateCanvas();
	Refresh();
}
Esempio n. 2
0
LineChartCanvas::LineChartCanvas(wxWindow *parent, TemplateFrame* t_frame,
                                 Project* project, const LineChartStats& lcs_,
                                 LineChartCanvasCallbackInt* lc_canv_cb_,
                                 const wxPoint& pos, const wxSize& size)
: TemplateCanvas(parent, t_frame, project, project->GetHighlightState(), pos,
                 size, false, true),
lcs(lcs_), lc_canv_cb(lc_canv_cb_), summ_avg_circs(4, (GdaCircle*) 0),
y_axis_precision(1)
{
	LOG_MSG("Entering LineChartCanvas::LineChartCanvas");
	shps_orig_xmin = 0;
	shps_orig_ymin = 0;
	shps_orig_xmax = 100;
	shps_orig_ymax = 100;
	UpdateMargins();
	
	use_category_brushes = false;
	
	PopulateCanvas();
	ResizeSelectableShps();
	
	SetBackgroundStyle(wxBG_STYLE_CUSTOM);  // default style
    
    Bind(wxEVT_LEFT_DCLICK, &LineChartCanvas::OnDblClick, this);
    
	LOG_MSG("Exiting LineChartCanvas::LineChartCanvas");
}
void ConditionalHistogramCanvas::TimeSyncVariableToggle(int var_index)
{
	LOG_MSG("In ConditionalHistogramCanvas::TimeSyncVariableToggle");
	var_info[var_index].sync_with_global_time =
		!var_info[var_index].sync_with_global_time;
	VarInfoAttributeChange();
	InitIntervals();
	PopulateCanvas();
}
ConditionalHistogramCanvas::ConditionalHistogramCanvas(wxWindow *parent,
									TemplateFrame* t_frame,
									Project* project_s,
									const std::vector<GdaVarTools::VarInfo>& v_info,
									const std::vector<int>& col_ids,
									const wxPoint& pos, const wxSize& size)
: ConditionalNewCanvas(parent, t_frame, project_s, v_info, col_ids,
					   false, true, pos, size),
full_map_redraw_needed(true),
X(project_s->GetNumRecords()), Y(project_s->GetNumRecords()),
show_axes(true), scale_x_over_time(true), scale_y_over_time(true)
{
	LOG_MSG("Entering ConditionalHistogramCanvas::ConditionalHistogramCanvas");
	
	int hist_var_tms = data[HIST_VAR].shape()[0];
	data_stats.resize(hist_var_tms);
	data_sorted.resize(hist_var_tms);
	data_min_over_time = data[HIST_VAR][0][0];
	data_max_over_time = data[HIST_VAR][0][0];
	for (int t=0; t<hist_var_tms; t++) {
		data_sorted[t].resize(num_obs);
		for (int i=0; i<num_obs; i++) {
			data_sorted[t][i].first = data[HIST_VAR][t][i];
			data_sorted[t][i].second = i;
		}
		std::sort(data_sorted[t].begin(), data_sorted[t].end(),
				  Gda::dbl_int_pair_cmp_less);
		data_stats[t].CalculateFromSample(data_sorted[t]);
		if (data_stats[t].min < data_min_over_time) {
			data_min_over_time = data_stats[t].min;
		}
		if (data_stats[t].max > data_max_over_time) {
			data_max_over_time = data_stats[t].max;
		}
	}
	
	max_intervals = GenUtils::min<int>(MAX_INTERVALS, num_obs);
	cur_intervals = GenUtils::min<int>(max_intervals, default_intervals);
	if (num_obs > 49) {
		int c = sqrt((double) num_obs);
		cur_intervals = GenUtils::min<int>(max_intervals, c);
		cur_intervals = GenUtils::min<int>(cur_intervals, 7);
	}
	
	highlight_color = GdaConst::highlight_color;
	fixed_aspect_ratio_mode = false;
	use_category_brushes = false;
	selectable_shps_type = rectangles;
	
	VarInfoAttributeChange();
	InitIntervals();
	PopulateCanvas();
	
	all_init = true;
	SetBackgroundStyle(wxBG_STYLE_CUSTOM);  // default style
	LOG_MSG("Exiting ConditionalHistogramCanvas::ConditionalHistogramCanvas");
}
void ConditionalHistogramCanvas::ShowAxes(bool show_axes_s)
{
	if (show_axes_s == show_axes) return;
	show_axes = show_axes_s;
	
	invalidateBms();
	PopulateCanvas();
	Refresh();
}
void ConditionalHistogramCanvas::HistogramIntervals()
{
	HistIntervalDlg dlg(1, cur_intervals, max_intervals, this);
	if (dlg.ShowModal () != wxID_OK) return;
	if (cur_intervals == dlg.num_intervals) return;
	cur_intervals = dlg.num_intervals;
	InitIntervals();
	invalidateBms();
	PopulateCanvas();
	Refresh();
}
ConditionalScatterPlotCanvas::ConditionalScatterPlotCanvas(wxWindow *parent,
									TemplateFrame* t_frame,
									Project* project_s,
									const std::vector<GeoDaVarInfo>& v_info,
									const std::vector<int>& col_ids,
									const wxPoint& pos, const wxSize& size)
: ConditionalNewCanvas(parent, t_frame, project_s, v_info, col_ids,
					   false, true, pos, size),
full_map_redraw_needed(true),
X(project_s->GetNumRecords()), Y(project_s->GetNumRecords()),
display_axes_scale_values(true), display_slope_values(true)
{
	LOG_MSG("Entering ConditionalScatterPlotCanvas::ConditionalScatterPlotCanvas");
	
	double x_max = var_info[IND_VAR].max_over_time;
	double x_min = var_info[IND_VAR].min_over_time;
	double y_max = var_info[DEP_VAR].max_over_time;
	double y_min = var_info[DEP_VAR].min_over_time;
	double x_pad = 0.1 * (x_max - x_min);
	double y_pad = 0.1 * (y_max - y_min);
	axis_scale_x = AxisScale(x_min - x_pad, x_max + x_pad, 4);
	axis_scale_x.SkipEvenTics();
	axis_scale_y = AxisScale(y_min - y_pad, y_max + y_pad, 4);
	axis_scale_y.SkipEvenTics();
	
	highlight_color = GdaConst::scatterplot_regression_selected_color;
	selectable_fill_color =
		GdaConst::scatterplot_regression_excluded_color;
	selectable_outline_color = GdaConst::scatterplot_regression_color;
	
	shps_orig_xmin = 0;
	shps_orig_ymin = 0;
	shps_orig_xmax = 100;
	shps_orig_ymax = 100;
	virtual_screen_marg_top = 25;
	virtual_screen_marg_bottom = 75;
	virtual_screen_marg_left = 75;
	virtual_screen_marg_right = 25;
	
	selectable_shps_type = points;
	use_category_brushes = true;
	
	ref_var_index = -1;
	num_time_vals = 1;
	for (int i=0; i<var_info.size() && ref_var_index == -1; i++) {
		if (var_info[i].is_ref_variable) ref_var_index = i;
	}
	if (ref_var_index != -1) {
		num_time_vals = (var_info[ref_var_index].time_max -
						 var_info[ref_var_index].time_min) + 1;
	}
	
	// 1 = #cats
	cat_data.CreateCategoriesAllCanvasTms(1, num_time_vals, num_obs);
	for (int t=0; t<num_time_vals; t++) {
		cat_data.SetCategoryColor(t, 0, selectable_fill_color);
		for (int i=0; i<num_obs; i++) {
			cat_data.AppendIdToCategory(t, 0, i);
		}
	}
	if (ref_var_index != -1) {
		cat_data.SetCurrentCanvasTmStep(var_info[ref_var_index].time
										- var_info[ref_var_index].time_min);
	}
	VarInfoAttributeChange();
	PopulateCanvas();
	
	all_init = true;
	SetBackgroundStyle(wxBG_STYLE_CUSTOM);  // default style
	LOG_MSG("Exiting ConditionalScatterPlotCanvas::ConditionalScatterPlotCanvas");
}