示例#1
0
void C3DPlotCanvas::TimeSyncVariableToggle(int var_index)
{
	LOG_MSG("In C3DPlotCanvas::TimeSyncVariableToggle");
	var_info[var_index].sync_with_global_time =
		!var_info[var_index].sync_with_global_time;
	VarInfoAttributeChange();
	Refresh();
}
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");
}
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");
}
示例#5
0
C3DPlotCanvas::C3DPlotCanvas(Project* project_s, C3DPlotFrame* t_frame,
							 HighlightState* highlight_state_s,
							 const std::vector<GeoDaVarInfo>& v_info,
							 const std::vector<int>& col_ids,
							 wxWindow *parent,
							 wxWindowID id, const wxPoint& pos,
							 const wxSize& size, long style)
: wxGLCanvas(parent, id, pos, size, style), ball(0),
project(project_s), table_int(project_s->GetTableInt()),
num_obs(project_s->GetTableInt()->GetNumberRows()), num_vars(v_info.size()),
num_time_vals(1), highlight_state(highlight_state_s), var_info(v_info),
data(v_info.size()), scaled_d(v_info.size()),
c3d_plot_frame(t_frame)
{
	selectable_fill_color = GdaConst::three_d_plot_default_point_colour;
	highlight_color = GdaConst::three_d_plot_default_highlight_colour;
	canvas_background_color=GdaConst::three_d_plot_default_background_colour;
	
	data_stats.resize(var_info.size());
	var_min.resize(var_info.size());
	var_max.resize(var_info.size());
	
	std::vector<double> temp_vec(num_obs);
	for (int v=0; v<num_vars; v++) {
		table_int->GetColData(col_ids[v], data[v]);
		table_int->GetColData(col_ids[v], scaled_d[v]);
		int data_times = data[v].shape()[0];
		data_stats[v].resize(data_times);
		for (int t=0; t<data_times; t++) {
			for (int i=0; i<num_obs; i++) {
				temp_vec[i] = data[v][t][i];
			}
			data_stats[v][t].CalculateFromSample(temp_vec);
		}
	}
	
	c3d_plot_frame->ClearAllGroupDependencies();
	for (int i=0, sz=var_info.size(); i<sz; ++i) {
		c3d_plot_frame->AddGroupDependancy(var_info[i].name);
	}
	
	VarInfoAttributeChange();
	UpdateScaledData();
	
	xs = 0.1;
	xp = 0.0;
    ys = 0.1;
	yp = 0.0;
	zs = 0.1;
	zp = 0.0;
	
	m_bLButton = false;
	m_bRButton = false;
	m_brush = false;

	bb_min[0] = -1;
	bb_min[1] = -1;
	bb_min[2] = -1;
	bb_max[0] = 1;
	bb_max[1] = 1;
	bb_max[2] = 1;
	Vec3f b_min(bb_min);
	Vec3f b_max(bb_max);
	Vec3f ctr((bb_max[0]+bb_min[0])/2.0f, (bb_max[1]+bb_min[1])/2.0f,
			  (bb_max[2]+bb_min[2])/2.0f);
	
	float radius = norm(b_max - ctr);
	ball = new Arcball();
	ball->bounding_sphere(ctr, radius);

	m_x = false;
	m_y = false;
	m_z = false;
	m_d = true;
	b_select = false;
	isInit = false;
	
	highlight_state->registerObserver(this);
}