Пример #1
0
Rect
PathGeometry::ComputePathBounds ()
{
	if (!IsBuilt ())
		Build ();

	Value *v = GetValueNoAutoCreate (FiguresProperty);

	PathFigureCollection *figures = v ? v->AsPathFigureCollection() : NULL;

	if (!figures && (!path || (path->cairo.num_data == 0)))
		return Rect ();

	cairo_t *cr = measuring_context_create ();

	cairo_append_path (cr, &path->cairo);
	
	double x1, y1, x2, y2;

	cairo_path_extents (cr, &x1, &y1, &x2, &y2);

	Rect bounds = Rect (MIN (x1, x2), MIN (y1, y2), fabs (x2 - x1), fabs (y2 - y1));

	measuring_context_destroy (cr);

	return bounds;
}
Пример #2
0
public func IsProducerOf (object clonk, id def) {
  if (def != WOOD) return (0);
  if (!IsBuilt ()) return (0);
  if (NeedsEnergy ())
    if (FindSuppliedObjectCloseTo (clonk)) return (0);
//  if (!FindWorkTree (clonk)) return (0);
  return(1);
}
Пример #3
0
Point
Geometry::GetOriginPoint ()
{
	double x = 0.0;
	double y = 0.0;

	if (!IsBuilt ())
		Build ();

	moon_get_origin (path, &x, &y);
	return Point (x, y);
}
Пример #4
0
//-----------------------------------------------------------------------------------------
void KDTree::AddShape( const shared_ptr<Shape>& shape )
{
	assert(!IsBuilt());

	const Mesh* mesh = shape->GetTriangleMesh();

	if (mesh)
	{
		// Triangle meshes are expanded into individual primitives,
		// which are visible to the tree construction code. Generic
		// primitives are only handled by their AABBs
		mShapeMap.push_back(mShapeMap.back() + mesh->GetTriangleCount());
		mTriangleFlag.push_back(true);
	} 
	else
	{
		mShapeMap.push_back(1);
		mTriangleFlag.push_back(false);
	}
	
	mShapes.push_back(shape);
}
Пример #5
0
Rect
Geometry::ComputePathBounds()
{
	if (!IsBuilt ())
		Build ();

	if (!path || (path->cairo.num_data == 0))
		return Rect ();

	cairo_t *cr = measuring_context_create ();

	cairo_append_path (cr, &path->cairo);
	
	double x1, y1, x2, y2;

	cairo_path_extents (cr, &x1, &y1, &x2, &y2);

	Rect bounds = Rect (MIN (x1, x2), MIN (y1, y2), fabs (x2 - x1), fabs (y2 - y1));

	measuring_context_destroy (cr);

	return bounds;
}
Пример #6
0
Rect
Geometry::GetBounds ()
{
	bool compute = local_bounds.IsEmpty (true);

	if (!IsBuilt ()) {
		Build ();
		compute = true;
	}

	if (compute)
		local_bounds = ComputePathBounds ();

	Rect bounds = local_bounds;

	Transform *transform = GetTransform ();
	if (transform) {
		cairo_matrix_t matrix;
		transform->GetTransform (&matrix);
		bounds = bounds.Transform (&matrix);
	}

	return bounds;
}
Пример #7
0
void
Geometry::Draw (cairo_t *cr)
{
	Transform *transform = GetTransform ();
	cairo_matrix_t saved;
	cairo_get_matrix (cr, &saved);

	if (transform) {
		cairo_matrix_t matrix;
		transform->GetTransform (&matrix);
		cairo_transform (cr, &matrix);
	}

	if (!IsBuilt ())
		Build ();

	// Geometry is used for Clip so Fill (normally setting the fill rule) is never called
	cairo_set_fill_rule (cr, convert_fill_rule (GetFillRule ()));

	if (path)
		cairo_append_path (cr, &path->cairo);

	cairo_set_matrix (cr, &saved);
}
Пример #8
0
void _AmControlMenu::AttachedToWindow()
{
	if (!IsBuilt()) Build();
	inherited::AttachedToWindow();
}