/* bar.c generated by valac 0.56.0, the Vala compiler
 * generated from bar.vala, do not modify */

#include "livechart.h"
#include <cairo-gobject.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <string.h>

enum  {
	LIVE_CHART_BAR_0_PROPERTY,
	LIVE_CHART_BAR_NUM_PROPERTIES
};
static GParamSpec* live_chart_bar_properties[LIVE_CHART_BAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer live_chart_bar_parent_class = NULL;

static void live_chart_bar_real_draw (LiveChartSerieRenderer* base,
                               cairo_t* ctx,
                               LiveChartConfig* config);
static void live_chart_bar_update_bounding_box (LiveChartBar* self,
                                         LiveChartPoints* points,
                                         LiveChartConfig* config);
static GType live_chart_bar_get_type_once (void);

static gpointer
_g_object_ref0 (gpointer self)
{
#line 7 "../src/bar.vala"
	return self ? g_object_ref (self) : NULL;
#line 34 "bar.c"
}

LiveChartBar*
live_chart_bar_construct (GType object_type,
                          LiveChartValues* values)
{
	LiveChartBar * self = NULL;
	LiveChartValues* _tmp0_;
#line 5 "../src/bar.vala"
	g_return_val_if_fail (values != NULL, NULL);
#line 6 "../src/bar.vala"
	self = (LiveChartBar*) live_chart_serie_renderer_construct (object_type);
#line 7 "../src/bar.vala"
	_tmp0_ = _g_object_ref0 (values);
#line 7 "../src/bar.vala"
	_g_object_unref0 (((LiveChartSerieRenderer*) self)->values);
#line 7 "../src/bar.vala"
	((LiveChartSerieRenderer*) self)->values = _tmp0_;
#line 5 "../src/bar.vala"
	return self;
#line 55 "bar.c"
}

LiveChartBar*
live_chart_bar_new (LiveChartValues* values)
{
#line 5 "../src/bar.vala"
	return live_chart_bar_construct (LIVE_CHART_TYPE_BAR, values);
#line 63 "bar.c"
}

static void
live_chart_bar_real_draw (LiveChartSerieRenderer* base,
                          cairo_t* ctx,
                          LiveChartConfig* config)
{
	LiveChartBar * self;
	gboolean _tmp0_;
	gboolean _tmp1_;
#line 10 "../src/bar.vala"
	self = (LiveChartBar*) base;
#line 10 "../src/bar.vala"
	g_return_if_fail (ctx != NULL);
#line 10 "../src/bar.vala"
	g_return_if_fail (config != NULL);
#line 11 "../src/bar.vala"
	_tmp0_ = live_chart_drawable_get_visible ((LiveChartDrawable*) self);
#line 11 "../src/bar.vala"
	_tmp1_ = _tmp0_;
#line 11 "../src/bar.vala"
	if (_tmp1_) {
#line 86 "bar.c"
		LiveChartPoints* points = NULL;
		LiveChartValues* _tmp2_;
		LiveChartPoints* _tmp3_;
		LiveChartPoints* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
#line 12 "../src/bar.vala"
		_tmp2_ = ((LiveChartSerieRenderer*) self)->values;
#line 12 "../src/bar.vala"
		_tmp3_ = live_chart_points_create (_tmp2_, config);
#line 12 "../src/bar.vala"
		points = _tmp3_;
#line 13 "../src/bar.vala"
		_tmp4_ = points;
#line 13 "../src/bar.vala"
		_tmp5_ = live_chart_points_get_size (_tmp4_);
#line 13 "../src/bar.vala"
		_tmp6_ = _tmp5_;
#line 13 "../src/bar.vala"
		if (_tmp6_ > 0) {
#line 107 "bar.c"
			LiveChartPath* _tmp7_;
			LiveChartPath* _tmp8_;
			LiveChartPoints* _tmp9_;
#line 14 "../src/bar.vala"
			_tmp7_ = live_chart_serie_renderer_get_line ((LiveChartSerieRenderer*) self);
#line 14 "../src/bar.vala"
			_tmp8_ = _tmp7_;
#line 14 "../src/bar.vala"
			live_chart_path_configure (_tmp8_, ctx);
#line 16 "../src/bar.vala"
			_tmp9_ = points;
#line 16 "../src/bar.vala"
			live_chart_bar_update_bounding_box (self, _tmp9_, config);
#line 17 "../src/bar.vala"
			live_chart_serie_renderer_debug ((LiveChartSerieRenderer*) self, ctx);
#line 123 "bar.c"
			{
				gint pos = 0;
#line 19 "../src/bar.vala"
				pos = 0;
#line 128 "bar.c"
				{
					gboolean _tmp10_ = FALSE;
#line 19 "../src/bar.vala"
					_tmp10_ = TRUE;
#line 19 "../src/bar.vala"
					while (TRUE) {
#line 135 "bar.c"
						LiveChartPoints* _tmp12_;
						gint _tmp13_;
						gint _tmp14_;
						LiveChartPoint current_point = {0};
						LiveChartPoints* _tmp15_;
						LiveChartPoint _tmp16_ = {0};
						LiveChartPoint next_point = {0};
						LiveChartPoints* _tmp17_;
						LiveChartPoint _tmp18_ = {0};
						LiveChartPoint _tmp19_;
						LiveChartPadding _tmp20_;
						gdouble bar_width = 0.0;
						LiveChartPoint _tmp21_;
						LiveChartPoint _tmp22_;
						LiveChartPoint _tmp23_;
						LiveChartPoint _tmp24_;
						LiveChartPoint _tmp25_;
#line 19 "../src/bar.vala"
						if (!_tmp10_) {
#line 155 "bar.c"
							gint _tmp11_;
#line 19 "../src/bar.vala"
							_tmp11_ = pos;
#line 19 "../src/bar.vala"
							pos = _tmp11_ + 1;
#line 161 "bar.c"
						}
#line 19 "../src/bar.vala"
						_tmp10_ = FALSE;
#line 19 "../src/bar.vala"
						_tmp12_ = points;
#line 19 "../src/bar.vala"
						_tmp13_ = live_chart_points_get_size (_tmp12_);
#line 19 "../src/bar.vala"
						_tmp14_ = _tmp13_;
#line 19 "../src/bar.vala"
						if (!(pos <= (_tmp14_ - 1))) {
#line 19 "../src/bar.vala"
							break;
#line 175 "bar.c"
						}
#line 20 "../src/bar.vala"
						_tmp15_ = points;
#line 20 "../src/bar.vala"
						live_chart_points_get (_tmp15_, pos, &_tmp16_);
#line 20 "../src/bar.vala"
						current_point = _tmp16_;
#line 21 "../src/bar.vala"
						_tmp17_ = points;
#line 21 "../src/bar.vala"
						live_chart_points_after (_tmp17_, pos, &_tmp18_);
#line 21 "../src/bar.vala"
						next_point = _tmp18_;
#line 23 "../src/bar.vala"
						_tmp19_ = current_point;
#line 23 "../src/bar.vala"
						_tmp20_ = config->padding;
#line 23 "../src/bar.vala"
						if (_tmp19_.x < ((gdouble) _tmp20_.left)) {
#line 24 "../src/bar.vala"
							continue;
#line 197 "bar.c"
						}
#line 26 "../src/bar.vala"
						_tmp21_ = current_point;
#line 26 "../src/bar.vala"
						_tmp22_ = next_point;
#line 26 "../src/bar.vala"
						bar_width = (_tmp21_.x - _tmp22_.x) / 1.2;
#line 27 "../src/bar.vala"
						_tmp23_ = next_point;
#line 27 "../src/bar.vala"
						_tmp24_ = next_point;
#line 27 "../src/bar.vala"
						_tmp25_ = next_point;
#line 27 "../src/bar.vala"
						cairo_rectangle (ctx, _tmp23_.x, _tmp24_.y, bar_width, _tmp25_.height);
#line 213 "bar.c"
					}
				}
			}
#line 30 "../src/bar.vala"
			cairo_fill (ctx);
#line 219 "bar.c"
		}
#line 11 "../src/bar.vala"
		_g_object_unref0 (points);
#line 223 "bar.c"
	}
}

static void
live_chart_bar_update_bounding_box (LiveChartBar* self,
                                    LiveChartPoints* points,
                                    LiveChartConfig* config)
{
	LiveChartPoint _tmp0_ = {0};
	LiveChartBounds* _tmp1_;
	LiveChartBounds* _tmp2_;
	gdouble _tmp3_;
	gdouble _tmp4_;
	LiveChartPoint _tmp5_ = {0};
	LiveChartPoint _tmp6_ = {0};
	LiveChartBoundaries _tmp7_ = {0};
	LiveChartBoundary _tmp8_;
	LiveChartBounds* _tmp9_;
	LiveChartBounds* _tmp10_;
	gdouble _tmp11_;
	gdouble _tmp12_;
	LiveChartBoundingBox _tmp13_ = {0};
#line 35 "../src/bar.vala"
	g_return_if_fail (self != NULL);
#line 35 "../src/bar.vala"
	g_return_if_fail (points != NULL);
#line 35 "../src/bar.vala"
	g_return_if_fail (config != NULL);
#line 36 "../src/bar.vala"
	live_chart_points_first (points, &_tmp0_);
#line 36 "../src/bar.vala"
	_tmp1_ = live_chart_points_get_bounds (points);
#line 36 "../src/bar.vala"
	_tmp2_ = _tmp1_;
#line 36 "../src/bar.vala"
	_tmp3_ = live_chart_bounds_get_lower (_tmp2_);
#line 36 "../src/bar.vala"
	_tmp4_ = _tmp3_;
#line 36 "../src/bar.vala"
	live_chart_points_last (points, &_tmp5_);
#line 36 "../src/bar.vala"
	live_chart_points_first (points, &_tmp6_);
#line 36 "../src/bar.vala"
	live_chart_config_boundaries (config, &_tmp7_);
#line 36 "../src/bar.vala"
	_tmp8_ = _tmp7_.y;
#line 36 "../src/bar.vala"
	_tmp9_ = live_chart_points_get_bounds (points);
#line 36 "../src/bar.vala"
	_tmp10_ = _tmp9_;
#line 36 "../src/bar.vala"
	_tmp11_ = live_chart_bounds_get_lower (_tmp10_);
#line 36 "../src/bar.vala"
	_tmp12_ = _tmp11_;
#line 36 "../src/bar.vala"
	memset (&_tmp13_, 0, sizeof (LiveChartBoundingBox));
#line 36 "../src/bar.vala"
	_tmp13_.x = _tmp0_.x;
#line 36 "../src/bar.vala"
	_tmp13_.y = _tmp4_;
#line 36 "../src/bar.vala"
	_tmp13_.width = _tmp5_.x - _tmp6_.x;
#line 36 "../src/bar.vala"
	_tmp13_.height = _tmp8_.max - _tmp12_;
#line 36 "../src/bar.vala"
	((LiveChartSerieRenderer*) self)->bounding_box = _tmp13_;
#line 290 "bar.c"
}

static void
live_chart_bar_class_init (LiveChartBarClass * klass,
                           gpointer klass_data)
{
#line 4 "../src/bar.vala"
	live_chart_bar_parent_class = g_type_class_peek_parent (klass);
#line 4 "../src/bar.vala"
	((LiveChartSerieRendererClass *) klass)->draw = (void (*) (LiveChartSerieRenderer*, cairo_t*, LiveChartConfig*)) live_chart_bar_real_draw;
#line 301 "bar.c"
}

static void
live_chart_bar_instance_init (LiveChartBar * self,
                              gpointer klass)
{
}

static GType
live_chart_bar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (LiveChartBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) live_chart_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LiveChartBar), 0, (GInstanceInitFunc) live_chart_bar_instance_init, NULL };
	GType live_chart_bar_type_id;
	live_chart_bar_type_id = g_type_register_static (LIVE_CHART_TYPE_SERIE_RENDERER, "LiveChartBar", &g_define_type_info, 0);
	return live_chart_bar_type_id;
}

GType
live_chart_bar_get_type (void)
{
	static volatile gsize live_chart_bar_type_id__once = 0;
	if (g_once_init_enter (&live_chart_bar_type_id__once)) {
		GType live_chart_bar_type_id;
		live_chart_bar_type_id = live_chart_bar_get_type_once ();
		g_once_init_leave (&live_chart_bar_type_id__once, live_chart_bar_type_id);
	}
	return live_chart_bar_type_id__once;
}