static void gtk_plot_candle_draw_symbol(GtkPlotData *dataset, gdouble x, gdouble y, gdouble z, gdouble a, gdouble dx, gdouble dy, gdouble dz, gdouble da) { GtkPlot *plot; GtkPlotCandle *box = NULL; gdouble px, py, pz, ex, ey, ez; gdouble x1 = 0.0, y1 = 0.0, width = 0.0, height = 0.0; gdouble m; gboolean filled; gdouble a_scale; g_return_if_fail(GTK_IS_PLOT_CANDLE(dataset)); box = GTK_PLOT_CANDLE(dataset); g_return_if_fail(dataset->plot != NULL); plot = dataset->plot; a_scale = gtk_plot_data_get_a_scale(dataset); m = plot->magnification * a_scale; gtk_plot_pc_set_lineattr (plot->pc, dataset->symbol.border.line_width, 0, 0, 0); gtk_plot_pc_set_dash (plot->pc, 0, 0, 0); if(x >= plot->xmin && x <= plot->xmax){ if(GTK_IS_PLOT3D(plot)){ }else if(dataset->show_zerrbars){ gtk_plot_pc_set_color(plot->pc, &dataset->symbol.border.color); gtk_plot_get_pixel(plot, x, y, &px, &py); gtk_plot_get_pixel(plot, x, z, &px, &pz); width = m * dataset->symbol.size / 2; x1 = px - width; y1 = MIN(py, pz); filled = z < y; height = abs(py - pz); gtk_plot_get_pixel(plot, x, dy, &ex, &ey); gtk_plot_get_pixel(plot, x, dz, &ex, &ez); gtk_plot_pc_draw_line(plot->pc, px, py, px, ey); gtk_plot_pc_draw_line(plot->pc, px, pz, px, ez); if(!filled && dataset->symbol.symbol_style != GTK_PLOT_SYMBOL_EMPTY){ gtk_plot_pc_set_color(plot->pc, &plot->background); gtk_plot_pc_draw_rectangle (plot->pc, TRUE, x1, y1, width * 2, height); } if(dataset->symbol.symbol_style == GTK_PLOT_SYMBOL_EMPTY){ GtkPlotPoint lines[4]; gtk_plot_pc_set_color(plot->pc, &dataset->symbol.color); lines[0].x = px - width; lines[0].y = py; lines[1].x = px; lines[1].y = py; lines[2].x = px; lines[2].y = pz; lines[3].x = px + width; lines[3].y = pz; gtk_plot_pc_draw_lines(plot->pc, lines, 4); } else { if(filled){ gtk_plot_pc_set_color(plot->pc, &dataset->symbol.color); gtk_plot_pc_draw_rectangle (plot->pc, TRUE, x1, y1, width * 2, height); } gtk_plot_pc_set_color(plot->pc, &dataset->symbol.border.color); gtk_plot_pc_draw_rectangle (plot->pc, FALSE, x1, y1, width * 2, height); } } } }
static void gtk_plot_flux_draw_arrow(GtkPlotFlux *flux, gdouble x1, gdouble y1, gdouble x2, gdouble y2) { GtkPlot *plot; GtkPlotData *data; GtkPlotPoint arrow[3]; gdouble xm, ym; gdouble width, height; gdouble arrow_width; gdouble line_width; gdouble angle; gdouble length; gdouble m; data = GTK_PLOT_DATA(flux); plot = data->plot; m = plot->magnification; width = fabs(x2 - x1); height = fabs(y2 - y1); /* This is a nan */ if (width != width || height != height) return; if(width == 0 && height == 0) return; if(width != 0) angle = atan2((y2 - y1), (x2 - x1)); else angle = asin((y2 - y1)/height); length = (y2 - y1)*(y2 - y1) + (x2 - x1)*(x2 - x1); if (length > 0.0) length = sqrt(length); arrow_width = flux->arrow_width; line_width = data->symbol.border.line_width; gtk_plot_pc_set_color(plot->pc, &data->symbol.color); gtk_plot_pc_set_lineattr (plot->pc, line_width, 0, 0, 0); gtk_plot_pc_set_dash (plot->pc, 0, 0, 0); if(flux->centered && width != 0){ x1 -= cos(angle) * length / 2.0; x2 -= cos(angle) * length / 2.0; } if(flux->centered && height != 0){ y1 -= sin(angle) * length / 2.0; y2 -= sin(angle) * length / 2.0; } if(flux->arrow_style == GTK_PLOT_SYMBOL_EMPTY) gtk_plot_pc_draw_line(plot->pc, x1, y1, x2, y2); else gtk_plot_pc_draw_line(plot->pc, x1, y1, x2 - flux->arrow_length * m * cos(angle) / 2., y2 - flux->arrow_length * m * sin(angle) / 2.); arrow[1].x = x2; arrow[1].y = y2; xm = x2 - cos(angle) * flux->arrow_length * m; ym = y2 - sin(angle) * flux->arrow_length * m; arrow[0].x = xm - sin(angle)* arrow_width * m / 2.0; arrow[0].y = ym + cos(angle)* arrow_width * m / 2.0; arrow[2].x = xm + sin(angle)* arrow_width * m / 2.0; arrow[2].y = ym - cos(angle)* arrow_width * m / 2.0; switch(flux->arrow_style){ case GTK_PLOT_SYMBOL_EMPTY: gtk_plot_pc_draw_lines (plot->pc, arrow, 3); break; case GTK_PLOT_SYMBOL_OPAQUE: gtk_plot_pc_set_color(plot->pc, &plot->background); gtk_plot_pc_draw_polygon (plot->pc, TRUE, arrow, 3); gtk_plot_pc_set_color(plot->pc, &data->symbol.color); gtk_plot_pc_draw_polygon (plot->pc, FALSE, arrow, 3); break; case GTK_PLOT_SYMBOL_FILLED: gtk_plot_pc_draw_polygon (plot->pc, TRUE, arrow, 3); } }