Esempio n. 1
0
void 
gosFX::Curve::LocalScale(Stuff::Scalar sfactor,int curvenum)
{
	Check_Object(this);
	AxisScale(sfactor,Mid(curvenum),curvenum);
}
Esempio n. 2
0
void LineChartCanvas::PopulateCanvas()
{
	LOG_MSG("Entering LineChartCanvas::PopulateCanvas");
	BOOST_FOREACH( GdaShape* shp, background_shps ) { delete shp; }
	background_shps.clear();
	BOOST_FOREACH( GdaShape* shp, selectable_shps ) { delete shp; }
	selectable_shps.clear();
	BOOST_FOREACH( GdaShape* shp, foreground_shps ) { delete shp; }
	foreground_shps.clear();
	tm_rects.clear(); // NOTE: tm_rects are owned by background_shps
	summ_avg_circs[0] = 0; // NOTE: summ_avg_circs contents are owned
	summ_avg_circs[1] = 0; //       by background_shps.
	summ_avg_circs[2] = 0;
	summ_avg_circs[3] = 0;
	comb_circs.clear();
	sel_circs.clear();
	excl_circs.clear();
	
	wxSize size(GetVirtualSize());
	int win_width = size.GetWidth();
	int win_height = size.GetHeight();
	double scale_x, scale_y, trans_x, trans_y;
	GdaScaleTrans::calcAffineParams(shps_orig_xmin, shps_orig_ymin,
                                    shps_orig_xmax, shps_orig_ymax,
                                    virtual_screen_marg_top,
                                    virtual_screen_marg_bottom,
                                    virtual_screen_marg_left,
                                    virtual_screen_marg_right,
                                    win_width, win_height,
                                    fixed_aspect_ratio_mode,
                                    fit_to_window_mode,
                                    &scale_x, &scale_y, &trans_x, &trans_y,
                                    0, 0,
                                    &current_shps_width, &current_shps_height);
																	
	fixed_aspect_ratio_val = current_shps_width / current_shps_height;
	
	
	double y_min = 0;
	double y_max = 100;
	if (lcs.Y_avg_valid) {
		y_min = lcs.Y_avg_min;
		y_max = lcs.Y_avg_max;
	}
	if ((lcs.compare_regimes || lcs.compare_r_and_t) && lcs.Y_sel_avg_valid) {
		if (lcs.Y_sel_avg_min < y_min) y_min = lcs.Y_sel_avg_min;
		if (lcs.Y_sel_avg_max > y_max) y_max = lcs.Y_sel_avg_max;
	}
	if ((lcs.compare_regimes || lcs.compare_r_and_t) && lcs.Y_excl_avg_valid) {
		if (lcs.Y_excl_avg_min < y_min) y_min = lcs.Y_excl_avg_min;
		if (lcs.Y_excl_avg_max > y_max) y_max = lcs.Y_excl_avg_max;
	}
	double y_pad = 0.1 * (y_max - y_min);
	double axis_min = y_min - y_pad;
	double axis_max = y_max + y_pad;
    
	if (y_min >= 0 && axis_min < 0)
        axis_min = 0;
    
    if (!def_y_min.IsEmpty())
          def_y_min.ToDouble(&axis_min);
    
    if (!def_y_max.IsEmpty())
          def_y_max.ToDouble(&axis_max);

	axis_scale_y = AxisScale(axis_min, axis_max, 4, y_axis_precision);
	
	//LOG_MSG(wxString(axis_scale_y.ToString().c_str(), wxConvUTF8));
	scaleY = 100.0 / (axis_scale_y.scale_range);
	
	TableInterface* table_int = project->GetTableInt();
	// create axes
	std::vector<wxString> tm_strs;
	table_int->GetTimeStrings(tm_strs);
	bool time_variant = lcs.Y.size() > 1;
	
	wxRealPoint* y_pts = 0;
	size_t num_points = lcs.Y_avg.size();
	
	if (time_variant && num_points > 0) {
		// draw summary average circs
		// Will define avg point 1 and avg point 2 depending on
		// state of lcs.  Will ultimately need these points to
		// be detectable objects so that we can report summaries.
		// NULL indicates avg is not currently defined.
		
		
		if (lcs.compare_regimes) {
			if (lcs.Y_sel_tm0_avg_valid) {
				summ_avg_circs[0] = 
					MakeSummAvgHelper(lcs.Y_sel_tm0_avg,GdaConst::ln_cht_clr_sel_dark);
			}
			if (lcs.Y_excl_tm0_avg_valid) {
				summ_avg_circs[1] =
					MakeSummAvgHelper(lcs.Y_excl_tm0_avg,GdaConst::ln_cht_clr_exl_dark);
			}
		} else if (lcs.compare_time_periods) {
			if (lcs.Y_avg_tm0_valid) {
				summ_avg_circs[0] =
					MakeSummAvgHelper(lcs.Y_avg_tm0,GdaConst::ln_cht_clr_tm1_dark);
			}
			if (lcs.Y_avg_tm1_valid) {
				summ_avg_circs[1] =
					MakeSummAvgHelper(lcs.Y_avg_tm1,GdaConst::ln_cht_clr_tm2_dark);
			}
		} else if (lcs.compare_r_and_t) {
			if (lcs.Y_sel_tm0_avg_valid) {
				summ_avg_circs[0] = 
				MakeSummAvgHelper(lcs.Y_sel_tm0_avg,GdaConst::ln_cht_clr_sel_dark,GdaConst::ln_cht_clr_tm1_light);
			}
			if (lcs.Y_excl_tm0_avg_valid) {
				summ_avg_circs[1] =
				MakeSummAvgHelper(lcs.Y_excl_tm0_avg,GdaConst::ln_cht_clr_exl_dark,GdaConst::ln_cht_clr_tm1_light);
			}
			if (lcs.Y_sel_tm1_avg_valid) {
				summ_avg_circs[2] = 
				MakeSummAvgHelper(lcs.Y_sel_tm1_avg,GdaConst::ln_cht_clr_sel_dark,GdaConst::ln_cht_clr_tm2_light);
			}
			if (lcs.Y_excl_tm1_avg_valid) {
				summ_avg_circs[3] =
				MakeSummAvgHelper(lcs.Y_excl_tm1_avg,GdaConst::ln_cht_clr_exl_dark,GdaConst::ln_cht_clr_tm2_light);
			}
		}
	}
	
	if (time_variant && num_points > 0) {
		size_t tms = lcs.Y_avg.size();
		y_pts = new wxRealPoint[num_points];
		
		
		// Draw subset highlight line and invisible selection
		// rectangles first
		if (lcs.Y_avg_valid) {
			for (size_t t=0; t<tms; ++t) {
				double fracX = ((double) t)/((double) (tms-1));
				double x = fracX * 100.0;
				double y = (lcs.Y_avg[t] - axis_scale_y.scale_min) * scaleY;
				
				// draw a rectangle behind x-axis line to indicate
				// time period 0 or 1.
				double x0 = 0.0;
				double x1 = 100.0;
				double x_p1 = ((double) (t+1))/((double) (tms-1)) * 100.0;
				double x_m1 = ((double) (t-1))/((double) (tms-1)) * 100.0;
				if (t == 0) {
					x1 = (x+x_p1)/2.0;
				} else if (t+1 == tms) {
					x0 = (x_m1+x)/2.0;
				} else { // not an end-point
					x0 = (x_m1+x)/2.0;
					x1 = (x+x_p1)/2.0;
				}
				if (lcs.tms_subset0[t]) {
					GdaPolyLine* p = new GdaPolyLine(x0, 0, x1, 0);
					if (lcs.compare_time_periods || lcs.compare_r_and_t) {
						p->setPen(wxPen(GdaConst::ln_cht_clr_tm1_light, 9));
					} else {
						p->setPen(wxPen(GdaConst::ln_cht_clr_regimes_hl, 9));
					}
					p->setNudge(0, 5);
					background_shps.push_back(p);
				}
				if ((lcs.compare_time_periods || lcs.compare_r_and_t)
						&& lcs.tms_subset1[t]) {
					GdaPolyLine* p = new GdaPolyLine(x0, 0, x1, 0);
					p->setPen(wxPen(GdaConst::ln_cht_clr_tm2_light, 9));
					p->setNudge(0, 5);
					background_shps.push_back(p);
				}
      
				// Create invisible selection rectangles
				{
					double x0_nudge = 0;
					double x1_nudge = 0;
					if (t == 0) {
						x0_nudge = -5;
					} else if (t+1 == tms) {
						x1_nudge = 5;
					}
					GdaRectangle* r = new GdaRectangle(wxRealPoint(x0, 0), wxRealPoint(x1, 100));
					tm_rects.push_back(r);
					r->setPen(*wxTRANSPARENT_PEN);
					r->setBrush(*wxTRANSPARENT_BRUSH);
					background_shps.push_back(r);
				}
			}
		}
		
		
		// Push subset circle highlights to the background first
		if ((lcs.compare_regimes || lcs.compare_r_and_t) && lcs.Y_excl_avg_valid) {
			for (size_t t=0; t<tms; ++t) {
				double fracX = ((double) t)/((double) (tms-1));
				double x = fracX * 100.0;
				double y = (lcs.Y_excl_avg[t] - axis_scale_y.scale_min) * scaleY;
				if (lcs.tms_subset0[t]) {
					GdaCircle* c = new GdaCircle(wxRealPoint(x, y), ss_circ_rad);
					if (lcs.compare_r_and_t) {
						c->setPen(GdaConst::ln_cht_clr_tm1_light);
						c->setBrush(GdaConst::ln_cht_clr_tm1_light);
					} else {
						c->setPen(GdaConst::ln_cht_clr_regimes_hl);
						c->setBrush(GdaConst::ln_cht_clr_regimes_hl);
					}
					background_shps.push_back(c);
				}
				if (lcs.compare_r_and_t && lcs.tms_subset1[t]) {
					GdaCircle* c = new GdaCircle(wxRealPoint(x, y), ss_circ_rad);
					c->setPen(GdaConst::ln_cht_clr_tm2_light);
					c->setBrush(GdaConst::ln_cht_clr_tm2_light);
					background_shps.push_back(c);
				}
			}
		}
		if ((lcs.compare_regimes || lcs.compare_r_and_t) && lcs.Y_sel_avg_valid) {
			for (size_t t=0; t<tms; ++t) {
				double fracX = ((double) t)/((double) (tms-1));
				double x = fracX * 100.0;	
				double y = (lcs.Y_sel_avg[t] - axis_scale_y.scale_min) * scaleY;
				if (lcs.tms_subset0[t]) {
					GdaCircle* c = new GdaCircle(wxRealPoint(x, y), ss_circ_rad);
					if (lcs.compare_r_and_t) {
						c->setPen(GdaConst::ln_cht_clr_tm1_light);
						c->setBrush(GdaConst::ln_cht_clr_tm1_light);
					} else {
						c->setPen(GdaConst::ln_cht_clr_regimes_hl);
						c->setBrush(GdaConst::ln_cht_clr_regimes_hl);
					}
					background_shps.push_back(c);
				}
				if (lcs.compare_r_and_t && lcs.tms_subset1[t]) {
					GdaCircle* c = new GdaCircle(wxRealPoint(x, y), ss_circ_rad);
					c->setPen(GdaConst::ln_cht_clr_tm2_light);
					c->setBrush(GdaConst::ln_cht_clr_tm2_light);
					background_shps.push_back(c);
				}
			}
		}
		if (lcs.Y_avg_valid && lcs.Y_excl_avg_valid == lcs.Y_sel_avg_valid) {
			for (size_t t=0; t<tms; ++t) {
				double fracX = ((double) t)/((double) (tms-1));
				double x = fracX * 100.0;
				double y = (lcs.Y_avg[t] - axis_scale_y.scale_min) * scaleY;
				if (lcs.tms_subset0[t]) {
					GdaCircle* c = new GdaCircle(wxRealPoint(x, y), ss_circ_rad);
					if (lcs.compare_time_periods || lcs.compare_r_and_t) {
						c->setPen(GdaConst::ln_cht_clr_tm1_light);
						c->setBrush(GdaConst::ln_cht_clr_tm1_light);
					} else {
						c->setPen(GdaConst::ln_cht_clr_regimes_hl);
						c->setBrush(GdaConst::ln_cht_clr_regimes_hl);
					}
					background_shps.push_back(c);
				}
				if ((lcs.compare_time_periods || lcs.compare_r_and_t)
						&& lcs.tms_subset1[t]) {
					GdaCircle* c = new GdaCircle(wxRealPoint(x, y), ss_circ_rad);
					c->setPen(GdaConst::ln_cht_clr_tm2_light);
					c->setBrush(GdaConst::ln_cht_clr_tm2_light);
					background_shps.push_back(c);
				}
			}
		}
		
		// Draw everything else
        if (lcs.Y_avg_valid) {
			for (size_t t=0; t<tms; ++t) {
				double fracX = ((double) t)/((double) (tms-1));
				double x = fracX * 100.0;
				double y = (lcs.Y_avg[t] - axis_scale_y.scale_min) * scaleY;
				y_pts[t].x = x;
				y_pts[t].y = y;
			}
			GdaPolyLine* p = new GdaPolyLine(num_points, y_pts);
            p->setPen(wxPen(*wxBLACK, 1, wxSHORT_DASH));
			background_shps.push_back(p);
			for (size_t t=0; t<tms; ++t) {
				GdaCircle* c = new GdaCircle(wxRealPoint(y_pts[t].x, y_pts[t].y), circ_rad);
				wxColour lc = *wxBLACK;
				wxColour dc = GdaColorUtils::ChangeBrightness(lc);
				c->setPen(lc);
				c->setBrush(dc);
				background_shps.push_back(c);
				comb_circs.push_back(c);
			}
		}
		if ((lcs.compare_regimes || lcs.compare_r_and_t) && lcs.Y_excl_avg_valid) {
			for (size_t t=0; t<tms; ++t) {
				double fracX = ((double) t)/((double) (tms-1));
				double x = fracX * 100.0;
				double y = (lcs.Y_excl_avg[t] - axis_scale_y.scale_min) * scaleY;
				y_pts[t].x = x;
				y_pts[t].y = y;
			}
			GdaPolyLine* p = new GdaPolyLine(num_points, y_pts);
			p->setPen(GdaConst::ln_cht_clr_exl_dark);
			background_shps.push_back(p);
			for (size_t t=0; t<tms; ++t) {
				GdaCircle* c = new GdaCircle(wxRealPoint(y_pts[t].x, y_pts[t].y),
																		 circ_rad);
				wxColour lc = GdaConst::ln_cht_clr_exl_dark;
				wxColour dc = GdaColorUtils::ChangeBrightness(lc);
				c->setPen(lc);
				c->setBrush(dc);
				background_shps.push_back(c);
				excl_circs.push_back(c);
			}
		}
		
		if ((lcs.compare_regimes || lcs.compare_r_and_t) && lcs.Y_sel_avg_valid) {
			for (size_t t=0; t<tms; ++t) {
				double fracX = ((double) t)/((double) (tms-1));
				double x = fracX * 100.0;	
				double y = (lcs.Y_sel_avg[t] - axis_scale_y.scale_min) * scaleY;
				y_pts[t].x = x;
				y_pts[t].y = y;
			}
			GdaPolyLine* p = new GdaPolyLine(num_points, y_pts);
			p->setPen(GdaConst::ln_cht_clr_sel_dark);
			background_shps.push_back(p);
			for (size_t t=0; t<tms; ++t) {
				GdaCircle* c = new GdaCircle(wxRealPoint(y_pts[t].x, y_pts[t].y), circ_rad);
				wxColour lc = GdaConst::ln_cht_clr_sel_dark;
				wxColour dc = GdaColorUtils::ChangeBrightness(lc);
				c->setPen(lc);
				c->setBrush(dc);
				background_shps.push_back(c);
				sel_circs.push_back(c);
			}
		}
	}
	
	if (!time_variant) {
		size_t t = 0;
		const double d=5.0;
		const double x = 50.0;
        
		if (lcs.Y_avg_valid && lcs.Y_excl_avg_valid == lcs.Y_sel_avg_valid) {
			double y = (lcs.Y_avg[t] - axis_scale_y.scale_min) * scaleY;
			GdaPolyLine* p = new GdaPolyLine(x-d, y, x+d, y);
			p->setPen(*wxBLACK_PEN);
			background_shps.push_back(p);
			GdaCircle* c = new GdaCircle(wxRealPoint(x,y), circ_rad);
			wxColour lc = *wxBLACK;
			wxColour dc = GdaColorUtils::ChangeBrightness(lc);
			c->setPen(lc);
			c->setBrush(dc);
			background_shps.push_back(c);
			comb_circs.push_back(c);
		}
		if ((lcs.compare_regimes || lcs.compare_r_and_t) && lcs.Y_excl_avg_valid) {
			double y = (lcs.Y_excl_avg[t] - axis_scale_y.scale_min) * scaleY;
			GdaPolyLine* p = new GdaPolyLine(x-d, y, x+d, y);
			p->setPen(GdaConst::ln_cht_clr_exl_dark);
			background_shps.push_back(p);
			GdaCircle* c = new GdaCircle(wxRealPoint(x,y), circ_rad);
			wxColour lc = GdaConst::ln_cht_clr_exl_dark;
			wxColour dc = GdaColorUtils::ChangeBrightness(lc);
			c->setPen(lc);
			c->setBrush(dc);
			background_shps.push_back(c);
			excl_circs.push_back(c);
		}
		if ((lcs.compare_regimes || lcs.compare_r_and_t) && lcs.Y_sel_avg_valid) {
			double y = (lcs.Y_sel_avg[t] - axis_scale_y.scale_min) * scaleY;
			GdaPolyLine* p = new GdaPolyLine(x-d, y, x+d, y);
			p->setPen(GdaConst::ln_cht_clr_sel_dark);
			background_shps.push_back(p);
			GdaCircle* c = new GdaCircle(wxRealPoint(x,y), circ_rad);
			wxColour lc = GdaConst::ln_cht_clr_sel_dark;
			wxColour dc = GdaColorUtils::ChangeBrightness(lc);
			c->setPen(lc);
			c->setBrush(dc);
			background_shps.push_back(c);
			sel_circs.push_back(c);
		}
	}

	GdaAxis* x_baseline = 0;
	if (time_variant) {
		x_baseline = new GdaAxis("", tm_strs, wxRealPoint(0,0), wxRealPoint(100, 0), 0, 5);
		x_baseline->hideCaption(true);
		x_baseline->setPen(*GdaConst::scatterplot_scale_pen);
		x_baseline->autoDropScaleValues(true);
		x_baseline->moveOuterValTextInwards(false);
		background_shps.push_back(x_baseline);
	}
	GdaAxis* y_baseline = new GdaAxis(lcs.Yname, axis_scale_y, wxRealPoint(0,0), wxRealPoint(0, 100), -5, 0);
	y_baseline->autoDropScaleValues(true);
	y_baseline->moveOuterValTextInwards(true);
	y_baseline->setPen(*GdaConst::scatterplot_scale_pen);
	background_shps.push_back(y_baseline);	
	
	if (y_pts) delete [] y_pts;
	
	ResizeSelectableShps();
    Refresh(false);
	LOG_MSG("Exiting LineChartCanvas::PopulateCanvas");
}
Esempio n. 3
0
void
gosFX::Curve::LocalScale(float sfactor, int32_t curvenum)
{
	Check_Object(this);
	AxisScale(sfactor, Mid(curvenum), curvenum);
}
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");
}
Esempio n. 5
0
/*
================
CG_AddMissile
================
*/
static void CG_AddMissile( localEntity_t *le ) {
	refEntity_t			*re;
	const weaponInfo_t	*weapon;
	trace_t				trace;
	centity_t			*other;
	qboolean			inWater;

	// just existing for server entity deletion
	if ( le->leFlags & LEF_FINISHED ) {
		return;
	}

	// get weapon info
	if ( le->ti.weapon > WP_NUM_WEAPONS ) {
		le->ti.weapon = 0;
	}
	weapon = &cg_weapons[le->ti.weapon];

	re = &le->refEntity;

	// calculate position
	BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );

	// special case for flames
	if ( re->reType == RT_SPRITE ) {
		int deltaTime;

		// check for water
		if ( trap_CM_PointContents( re->origin, 0 ) & CONTENTS_WATER ) {
			// do a trace to get water surface normals
			CG_Trace( &trace, re->oldorigin, NULL, NULL, re->origin, le->owner, MASK_WATER );
			CG_FreeLocalEntity( le );

			CG_MakeExplosion( trace.endpos, trace.plane.normal, 
				cgs.media.ringFlashModel, cgs.media.vaporShader,
				500, qfalse, qtrue );
			return;
		}

		// change radius over time
		deltaTime = cg.time - le->startTime;
		re->radius = deltaTime * deltaTime * ( random()*0.4f + 0.8f ) / 2000.0f + 9;

		// do a trace sometimes
		if ( le->ti.trailTime++ > 5 ) {
			le->ti.trailTime = 0;

			CG_Trace( &trace, re->oldorigin, NULL, NULL, re->origin, le->owner, MASK_SHOT );
			VectorCopy( re->origin, re->oldorigin );

			// hit something
			if ( trace.fraction < 1.0 ) {
				CG_MissileHitWall( le->ti.weapon, 0, trace.endpos, trace.plane.normal, IMPACTSOUND_DEFAULT );
				CG_FreeLocalEntity( le );
				return;
			}
		}

		// add to refresh list
		trap_R_AddRefEntityToScene( re );
		return;
	}

	// add trails
	if ( weapon->missileTrailFunc ) weapon->missileTrailFunc( &le->ti, cg.time );

	// add dynamic light
	if ( weapon->missileDlight ) {
		trap_R_AddLightToScene( re->origin, weapon->missileDlight, 
			weapon->missileDlightColor[0], weapon->missileDlightColor[1], weapon->missileDlightColor[2] );
	}

	// flicker between two skins
	re->skinNum = cg.clientFrame & 1;

	// convert direction of travel into axis
	if ( VectorNormalize2( le->pos.trDelta, re->axis[0] ) == 0 ) {
		re->axis[0][2] = 1;
	}

	// spin as it moves
	if ( le->pos.trType != TR_STATIONARY ) {
		if ( le->pos.trType == TR_GRAVITY ) {
			RotateAroundDirection( re->axis, cg.time / 4 );
		} else if ( le->pos.trType == TR_WATER_GRAVITY ) {
			RotateAroundDirection( re->axis, cg.time / 8 );
		} else {
			RotateAroundDirection( re->axis, cg.time );
		}
	} else {
		RotateAroundDirection( re->axis, 0 );
	}

	// trace a line from previous position to new position
	CG_Trace( &trace, re->oldorigin, NULL, NULL, re->origin, le->owner, MASK_SHOT );
	VectorCopy( re->origin, re->oldorigin );

	// draw BIG grenades
	if ( weLi[le->ti.weapon].category == CT_EXPLOSIVE ) {
		AxisScale( re->axis, GRENADE_SCALE, re->axis );
	}

	if ( trace.fraction != 1.0 ) {
		// hit the sky or something like that
		if ( trace.surfaceFlags & SURF_NOIMPACT ) {
			le->leFlags |= LEF_FINISHED;
			le->endTime = cg.time + 500;
			return;
		}

		// impact
		other = &cg_entities[trace.entityNum];

		if ( le->bounceFactor > 0 && ( le->bounceFactor == BOUNCE_FACTOR_HALF || other->currentState.eType != ET_PLAYER ) ) {
			// reflect the velocity on the trace plane
			CG_ReflectVelocity( le, &trace );
			if ( cg.predictedImpacts < MAX_PREDICTED_IMPACTS ) {
				cg.predictedImpacts++;
				cg.predictedImpactsDecTime = cg.time;
			}

			// do bounce sound
			if ( rand() & 1 ) {
				trap_S_StartSound( le->pos.trBase, 0, CHAN_AUTO, cgs.media.hgrenb1aSound );
			} else {
				trap_S_StartSound( le->pos.trBase, 0, CHAN_AUTO, cgs.media.hgrenb2aSound );
			}
		} else {
			// explode missile
			if ( cg.predictedImpacts < MAX_PREDICTED_IMPACTS ) {
				cg.predictedImpacts++;
				cg.predictedImpactsDecTime = cg.time;
			}

			if ( other->currentState.eType == ET_PLAYER ) {
				CG_MissileHitPlayer( le->ti.weapon, 0, trace.endpos, trace.plane.normal, trace.entityNum );
			} else if ( !(trace.surfaceFlags & SURF_NOIMPACT) ) {
				CG_MissileHitWall( le->ti.weapon, 0, trace.endpos, trace.plane.normal, 
					(trace.surfaceFlags & SURF_METALSTEPS) ? IMPACTSOUND_METAL : IMPACTSOUND_DEFAULT );
			}
			// store the entity for deleting the server entity
			le->leFlags |= LEF_FINISHED;
			le->endTime = cg.time + 500;
			return;
		}
	}

	// check for medium change
	if ( trap_CM_PointContents( re->origin, 0 ) & CONTENTS_WATER ) inWater = qtrue;
	else inWater = qfalse;

	if (  ( !inWater && le->pos.trType == TR_WATER_GRAVITY )
		|| ( inWater && le->pos.trType == TR_GRAVITY ) ) {
		// setup new tr
		vec3_t	newDelta;

		BG_EvaluateTrajectoryDelta( &le->pos, cg.time, newDelta );
		VectorCopy( re->origin, le->pos.trBase );
		VectorCopy( newDelta, le->pos.trDelta );
		le->pos.trTime = cg.time;
		if ( inWater ) le->pos.trType = TR_WATER_GRAVITY;
		else le->pos.trType = TR_GRAVITY;
	}	

	// add to refresh list
	trap_R_AddRefEntityToScene( re );
}
Esempio n. 6
0
/*
==================
CG_AddMoveScale
==================
*/
static void CG_AddMoveScale( localEntity_t *le ) {
	refEntity_t	*re;
	vec3_t		delta;
	float		len;

	re = &le->refEntity;

	if ( !( le->leFlags & (LEF_DONT_SCALE | LEF_ALT_SCALE) ) ) {
		re->radius = le->radius * ( cg.time - le->startTime ) * le->lifeRate + 8;
	}
	if ( le->leFlags & LEF_ALT_SCALE ) {
		if ( re->hModel ) {
			if ( (le->leFlags & LEF_AXIS_ALIGNED) && le->radius ) {
				// it has a variing scale
				AxisClear( re->axis );
				AxisScale( re->axis, re->radius + le->radius * (cg.time - le->startTime) / (le->endTime - le->startTime), re->axis );
			}
			if ( !(le->leFlags & LEF_AXIS_ALIGNED) ) {
				// model looks in flight direction
				vec3_t	delta, angles;
				
				BG_EvaluateTrajectoryDelta( &le->pos, cg.time, delta );
				vectoangles( delta, angles );
				AnglesToAxis( angles, re->axis );
				if ( re->radius || le->radius ) AxisScale( re->axis, re->radius + le->radius * (cg.time - le->startTime) / (le->endTime - le->startTime), re->axis );
			}
		} else {
			// sprites scale like this
			re->radius += le->radius * cg.frametime / (le->endTime - le->startTime);
		}
	}

	BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );

	// check for collisions
	if ( le->leFlags & LEF_COLLISIONS ) {
		// do a trace sometimes
		if ( le->ti.trailTime++ > 5 ) {
			trace_t		trace;

			le->ti.trailTime = 0;

			CG_Trace( &trace, re->oldorigin, NULL, NULL, re->origin, le->owner, MASK_SHOT );
			VectorCopy( re->origin, re->oldorigin );

			// hit something
			if ( trace.fraction < 1.0 ) {
				entityState_t	*s1;
				int		life;

				// do impact effect
				s1 = &cg_entities[le->owner].currentState;
				life = s1->groundEntityNum;

				if ( !( trace.surfaceFlags & SURF_NOIMPACT ) ) {
					if ( s1->generic1 & PF_IMPACT_MODEL ) {
						CG_MakeExplosion( trace.endpos, trace.plane.normal, 
								   cgs.gameModels[s1->modelindex2],	cgs.gameShaders[s1->otherEntityNum2],
								   life, qfalse, qfalse );
					} else if ( s1->modelindex2 ) {
						CG_MakeExplosion( trace.endpos, trace.plane.normal, 
								   cgs.media.dishFlashModel, cgs.gameShaders[s1->modelindex2],
								   life, qtrue, qtrue );
					}
				}

				CG_FreeLocalEntity( le );
				return;
			}
		}
	}

	// if the view would be "inside" the sprite, kill the sprite
	// so it doesn't add too much overdraw
	VectorSubtract( re->origin, cg.refdef.vieworg, delta );
	len = VectorLength( delta );
	if ( len < le->radius ) {
		CG_FreeLocalEntity( le );
		return;
	}

	trap_R_AddRefEntityToScene( re );
}
void ConditionalHistogramCanvas::PopulateCanvas()
{
	LOG_MSG("Entering ConditionalHistogramCanvas::PopulateCanvas");
	BOOST_FOREACH( GdaShape* shp, selectable_shps ) { delete shp; }
	selectable_shps.clear();

	int t = var_info[HIST_VAR].time;
	
	double x_min = 0;
	double x_max = left_pad_const + right_pad_const
		+ interval_width_const * cur_intervals + 
		+ interval_gap_const * (cur_intervals-1);
	
	// orig_x_pos is the center of each histogram bar
	std::vector<double> orig_x_pos(cur_intervals);
	for (int i=0; i<cur_intervals; i++) {
		orig_x_pos[i] = left_pad_const + interval_width_const/2.0
			+ i * (interval_width_const + interval_gap_const);
	}
	
	shps_orig_xmin = x_min;
	shps_orig_xmax = x_max;
	shps_orig_ymin = 0;
	shps_orig_ymax = (scale_y_over_time ? overall_max_num_obs_in_ival :
					  max_num_obs_in_ival[t]);
	if (show_axes) {
		axis_scale_y = AxisScale(0, shps_orig_ymax, 3);
		shps_orig_ymax = axis_scale_y.scale_max;
		y_axis = new GdaAxis("Frequency", axis_scale_y,
							wxRealPoint(0,0), wxRealPoint(0, shps_orig_ymax),
							-9, 0);
		
		axis_scale_x = AxisScale(0, max_ival_val[t]);
		//shps_orig_xmax = axis_scale_x.scale_max;
		axis_scale_x.data_min = min_ival_val[t];
		axis_scale_x.data_max = max_ival_val[t];
		axis_scale_x.scale_min = axis_scale_x.data_min;
		axis_scale_x.scale_max = axis_scale_x.data_max;
		double range = axis_scale_x.scale_max - axis_scale_x.scale_min;
		LOG(axis_scale_x.data_max);
		axis_scale_x.scale_range = range;
		axis_scale_x.p = floor(log10(range));
		axis_scale_x.ticks = cur_intervals+1;
		axis_scale_x.tics.resize(axis_scale_x.ticks);
		axis_scale_x.tics_str.resize(axis_scale_x.ticks);
		axis_scale_x.tics_str_show.resize(axis_scale_x.tics_str.size());
		for (int i=0; i<axis_scale_x.ticks; i++) {
			axis_scale_x.tics[i] =
			axis_scale_x.data_min +
			range*((double) i)/((double) axis_scale_x.ticks-1);
			wxString flt = wxString::Format("%.2g", axis_scale_x.tics[i]);
			axis_scale_x.tics_str[i] = flt.ToStdString();
			axis_scale_x.tics_str_show[i] = false;
		}
		int tick_freq = ceil(((double) cur_intervals)/5.0);
		for (int i=0; i<axis_scale_x.ticks; i++) {
			if (i % tick_freq == 0) {
				axis_scale_x.tics_str_show[i] = true;
			}
		}
		axis_scale_x.tic_inc = axis_scale_x.tics[1]-axis_scale_x.tics[0];
		x_axis = new GdaAxis(GetNameWithTime(2), axis_scale_x, wxRealPoint(0,0),
							wxRealPoint(shps_orig_xmax, 0), 0, 9);
	}
	
	selectable_shps.resize(vert_num_cats * horiz_num_cats * cur_intervals);
	int i=0;
	for (int r=0; r<vert_num_cats; r++) {
		for (int c=0; c<horiz_num_cats; c++) {
			for (int ival=0; ival<cur_intervals; ival++) {
				double x0 = orig_x_pos[ival] - interval_width_const/2.0;
				double x1 = orig_x_pos[ival] + interval_width_const/2.0;
				double y0 = 0;
				double y1 = cell_data[t][r][c].ival_obs_cnt[ival];
				selectable_shps[i] = new GdaRectangle(wxRealPoint(x0, 0),
													 wxRealPoint(x1, y1));
				int sz = GdaConst::qualitative_colors.size();
				selectable_shps[i]->
					setPen(GdaConst::qualitative_colors[ival%sz]);
				selectable_shps[i]->
					setBrush(GdaConst::qualitative_colors[ival%sz]);
				i++;
			}
		}
	}
	
	virtual_screen_marg_top = 25;
	virtual_screen_marg_bottom = 70;
	virtual_screen_marg_left = 70;
	virtual_screen_marg_right = 25;
	
	if (show_axes) {
		virtual_screen_marg_bottom += 25;
		virtual_screen_marg_left += 25;
	}
	
	ResizeSelectableShps();
	LOG_MSG("Exiting ConditionalHistogramCanvas::PopulateCanvas");
}