예제 #1
0
bool FloatSliderMenuItem::OnKey(int key, int mod)
{
	float amt = kInc * m_scale;
	if(mod & KMOD_SHIFT) amt = kLargeInc * m_scale;
	else if(mod & KMOD_CTRL) amt = kSmallInc * m_scale;

	switch(key)
	{
		case SDLK_UP:
			m_set(m_limits(m_get() + amt));
			UpdateData();
			break;
		case SDLK_DOWN:
			m_set(m_limits(m_get() - amt));
			UpdateData();
			break;
		case SDLK_BACKSPACE:
		case SDLK_LEFT:
			menu_DeactivateMenuItem();
			break;
		default:
			break;
	}
	return true;
}
// Reconstruct - make the _pair_bins_summaries_ structure
void pair_bins_summary::_reconstruct() const
{
	// Set up the construction function
	auto func = [=] (const ssize_t & R_i, const ssize_t & m_i, const ssize_t & z_i, const ssize_t & mag_i)
	{
		return pair_bin(R_limits().lower_limit(R_i),R_limits().upper_limit(R_i),
						m_limits().lower_limit(m_i),m_limits().upper_limit(m_i),
						z_limits().lower_limit(z_i),z_limits().upper_limit(z_i),
						mag_limits().lower_limit(mag_i),mag_limits().upper_limit(mag_i));
	};
	make_vector_function(_pair_bin_summaries_,func,R_limits().num_bins(),m_limits().num_bins(),z_limits().num_bins(),mag_limits().num_bins());
}
예제 #3
0
bool pair_binner::binnable( const galaxy & lens ) const
{
	if(!valid_limits()) return false;
	if(m_limits().outside_limits(lens.m())) return false;
	if(z_limits().outside_limits(lens.z())) return false;
	if(mag_limits().outside_limits(lens.mag())) return false;
	return true;
}
예제 #4
0
surface_density_type pair_binner::delta_Sigma_x_stderr_for_bin(const distance_type & R, const mass_type & m,
													const flt_type & z, const flt_type & mag)
{
	_sort();
	ssize_t R_i = R_limits().get_bin_index(R);
	ssize_t m_i = m_limits().get_bin_index(m);
	ssize_t z_i = z_limits().get_bin_index(z);
	ssize_t mag_i = mag_limits().get_bin_index(mag);
	return _pair_bin_summaries_.at(R_i).at(m_i).at(z_i).at(mag_i).delta_Sigma_x_stderr();
}
예제 #5
0
bool IntSliderMenuItem::OnKey(int key, int mod) 
{
	switch(key)
	{
		case SDLK_UP:
			m_set(m_limits(m_get() + m_scale));
			UpdateData();
			break;
		case SDLK_DOWN:
			m_set(m_limits(m_get() - m_scale));
			UpdateData();
			break;
		case SDLK_BACKSPACE:
		case SDLK_LEFT:
			menu_DeactivateMenuItem();
			break;
		default:
			break;
	}
	return true;
}
예제 #6
0
void pair_binner::_sort() const
{
	if(_sorted_) return;

	if(!valid_limits()) throw std::logic_error("Pairs can't be sorted without valid bin limits.");

	// Check if we have a lens to sort
	if(!_buffering_lens_id_)
	{
		_empty_buffer(); // Anything in the buffer must be junk
		return;
	}

	// Check if the lens is within bounds first
	const mass_type & m = _buffering_lens_id_->m;
	const flt_type & z = _buffering_lens_id_->z;
	const flt_type & mag = _buffering_lens_id_->mag;
	if(m_limits().outside_limits(m) || z_limits().outside_limits(z) || mag_limits().outside_limits(mag))
	{
		// This lens can't be binned, and therefore no pairs currently buffered can be binned, so empty
		// the buffer and return
		_empty_buffer();
		return;
	}

	// Get the bin indices for this lens
	const ssize_t m_i = m_limits().get_bin_index(m);
	const ssize_t z_i = z_limits().get_bin_index(z);
	const ssize_t mag_i = mag_limits().get_bin_index(mag);

	_pair_bins_buffer_.resize(R_limits().num_bins());

	ssize_t R_i = 0;
	for( auto & bin : _pair_bins_buffer_ )
	{
		bin.clear();
		bin.set_limits(R_limits().lower_limit(R_i),R_limits().upper_limit(R_i),
				m_limits().lower_limit(m_i),m_limits().upper_limit(m_i),
				z_limits().lower_limit(z_i),z_limits().upper_limit(z_i),
				mag_limits().lower_limit(mag_i),mag_limits().upper_limit(mag_i));
		bin.set_z_buffer(_z_buffer_);
		bin.add_lens(*_buffering_lens_id_);
		++R_i;
	}

	// Now loop through and sort each pair into the proper bin
	// Note that we don't zero the sorting index here. This is intentional, so
	// we don't have to resort previously sorted pairs when new ones are added.

	for(const auto & pair : _pairs_)
	{

		// Check bounds first
		distance_type R_proj = pair.R_proj();
		if(R_limits().outside_limits(R_proj)) continue;

		// Check lens-source z separation against buffer
		if(pair.z_diff()<_z_buffer_-std::numeric_limits<flt_type>::epsilon()) continue;

		// Add the pair to the proper bin
		_pair_bins_buffer_[R_limits().get_bin_index(R_proj)].add_pair(pair);
	}

	// Add the buffer to the summaries
	_construct();
	for(ssize_t R_i = 0; R_i<R_limits().num_bins(); ++R_i)
	{
		_pair_bin_summaries_[R_i][m_i][z_i][mag_i] += _pair_bins_buffer_[R_i];
	}

	_past_lens_ids_.insert(*_buffering_lens_id_);
	_empty_buffer();
}
예제 #7
0
bool VecSliderMenuItem::OnKey(int key, int mod) 
{

	float inc = m_scale * kInc;
	if(mod & KMOD_SHIFT) inc = m_scale * kLargeInc;
	else if(mod & KMOD_CTRL) inc = m_scale * kSmallInc;

	float incAmt = 0.f;
	switch(key)
	{
		case SDLK_UP:
			m_pos = Max(0, m_pos - 1);
			break;
		case SDLK_DOWN:
			m_pos = Min(VECSLIDE_NUM-1, m_pos + 1);
			break;
		case SDLK_LEFT:
			incAmt = -inc;
			break;
		case SDLK_RIGHT:
			incAmt = inc;
			break;
		case SDLK_BACKSPACE:
			menu_DeactivateMenuItem();
			break;
		default:
			break;
	}

	vec3 val = m_get();
	vec3 old = val;
	float radAmt = (M_PI / 180.f) * incAmt;
	mat4 rotmat;
	static const vec3 kXAxis = {1,0,0};
	static const vec3 kYAxis = {0,1,0};
	static const vec3 kZAxis = {0,0,1};
	switch(m_pos)
	{
		case VECSLIDE_RotateX:
			rotmat = RotateAround(kXAxis, radAmt);
			val = TransformVec(rotmat, val);
			break;
		case VECSLIDE_RotateY:
			rotmat = RotateAround(kYAxis, radAmt);
			val = TransformVec(rotmat, val);
			break;
		case VECSLIDE_RotateZ:
			rotmat = RotateAround(kZAxis, radAmt);
			val = TransformVec(rotmat, val);
			break;
		case VECSLIDE_X:
			val.x += incAmt;
			break;
		case VECSLIDE_Y:
			val.y += incAmt;
			break;
		case VECSLIDE_Z:
			val.z += incAmt;
			break;
		case VECSLIDE_Length:
			{
				float len = Length(val);
				val = val * (len+incAmt) / len;
			}
			break;
		default:break;
	}
	vec3 newVal = m_limits(val);
	if(newVal != old)
	{
		m_set(newVal);
		UpdateData();
	}
	return true;
}