Skip to content
Browse files

gplot directory fixes

  • Loading branch information...
1 parent 2fcd6f1 commit 7a1b1a642f65c5b7d7b1e900b709ec0c7d540623 @marc-lorber committed
Showing with 84 additions and 72 deletions.
  1. +6 −7 src/gplot/gplot-internal.h
  2. +24 −11 src/gplot/gplot.c
  3. +6 −5 src/gplot/gplot.h
  4. +2 −0 src/gplot/gplotfunction.c
  5. +4 −2 src/gplot/gplotfunction.h
  6. +37 −42 src/gplot/gplotlines.c
  7. +5 −5 src/gplot/gplotlines.h
View
13 src/gplot/gplot-internal.h
@@ -2,10 +2,9 @@
* gplot-internal.h
*
* Authors:
- * Ricardo Markiewicz <rmarkie@fi.uba.ar>
+ * Marc Lorber <lorber.marc@wanadoo.fr>
*
- * Copyright (C) 1999-2001 Richard Hult
- * Copyright (C) 2003,2004 Ricardo Markiewicz
+ * Copyright (C) 2009,2010 Marc Lorber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -51,8 +50,8 @@ struct _GPlotClass {
// Internal definitions associated to gplotfunction.h
-#define TYPE_GPLOT_FUNCTION (g_plot_function_get_type())
-#define GPLOT_FUNCTION_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, TYPE_GPLOT_FUNCTION, GPlotFunctionClass)
+#define TYPE_GPLOT_FUNCTION (g_plot_function_get_type ())
+#define GPLOT_FUNCTION_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, TYPE_GPLOT_FUNCTION, GPlotFunctionClass)
#define GPLOT_FUNCTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), TYPE_GPLOT_FUNCTION, GPlotFunctionClass))
typedef struct _GPlotFunctionClass GPlotFunctionClass;
@@ -60,8 +59,8 @@ typedef struct _GPlotFunctionClass GPlotFunctionClass;
struct _GPlotFunctionClass {
GTypeInterface parent;
- void (*draw)(GPlotFunction *, cairo_t *, GPlotFunctionBBox *);
- void (*get_bbox)(GPlotFunction *, GPlotFunctionBBox *);
+ void (*draw) (GPlotFunction *, cairo_t *, GPlotFunctionBBox *);
+ void (*get_bbox) (GPlotFunction *, GPlotFunctionBBox *);
};
#endif
View
35 src/gplot/gplot.c
@@ -3,9 +3,11 @@
*
* Authors:
* Ricardo Markiewicz <rmarkie@fi.uba.ar>
+ * Marc Lorber <lorber.marc@wanadoo.fr>
*
* Copyright (C) 1999-2001 Richard Hult
* Copyright (C) 2003,2004 Ricardo Markiewicz
+ * Copyright (C) 2009,2010 Marc Lorber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -233,7 +235,8 @@ draw_axis (cairo_t *cr, GPlotFunctionBBox *bbox, gdouble min, gdouble max, gbool
y2 = i;
x3 = bbox->xmin - extents.width * 1.5;
y3 = i + extents.height / 2.0;
- } else {
+ }
+ else {
x1 = i;
y1 = bbox->ymax - 4;
x2 = i;
@@ -511,9 +514,12 @@ g_plot_new ()
GDK_BUTTON1_MOTION_MASK|GDK_BUTTON2_MOTION_MASK|
GDK_BUTTON3_MOTION_MASK);
- g_signal_connect (G_OBJECT (plot), "motion-notify-event", G_CALLBACK(g_plot_motion_cb), plot);
- g_signal_connect (G_OBJECT (plot), "button-press-event", G_CALLBACK(g_plot_button_press_cb), plot);
- g_signal_connect (G_OBJECT (plot), "button-release-event", G_CALLBACK(g_plot_button_release_cb), plot);
+ g_signal_connect (G_OBJECT (plot), "motion-notify-event",
+ G_CALLBACK (g_plot_motion_cb), plot);
+ g_signal_connect (G_OBJECT (plot), "button-press-event",
+ G_CALLBACK (g_plot_button_press_cb), plot);
+ g_signal_connect (G_OBJECT (plot), "button-release-event",
+ G_CALLBACK (g_plot_button_release_cb), plot);
return GTK_WIDGET (plot);
}
@@ -572,12 +578,14 @@ g_plot_motion_cb (GtkWidget *w, GdkEventMotion *e, GPlot *p)
if (dx < 0) {
p->priv->rubberband.xmin = e->x;
- } else {
+ }
+ else {
p->priv->rubberband.xmax = e->x;
}
if (dy < 0) {
p->priv->rubberband.ymin = e->y;
- } else {
+ }
+ else {
p->priv->rubberband.ymax = e->y;
}
@@ -596,7 +604,8 @@ g_plot_button_press_cb (GtkWidget *w, GdkEventButton *e, GPlot *p)
if (e->type == GDK_2BUTTON_PRESS) {
/* TODO : Check function below cursor and open a property dialog :) */
- } else {
+ }
+ else {
switch (p->priv->zoom_mode) {
case GPLOT_ZOOM_INOUT:
if (e->button == 1) {
@@ -645,7 +654,8 @@ g_plot_button_release_cb (GtkWidget *w, GdkEventButton *e, GPlot *p)
p->priv->window_bbox.ymin /= zoom;
p->priv->window_bbox.ymax /= zoom;
gtk_widget_queue_draw (w);
- } else {
+ }
+ else {
gdk_window_set_cursor (w->window, NULL);
gdk_flush ();
}
@@ -672,7 +682,8 @@ g_plot_button_release_cb (GtkWidget *w, GdkEventButton *e, GPlot *p)
p->priv->window_bbox.ymin = y2;
p->priv->window_bbox.ymax = y1;
}
- } else if (e->button == 3) {
+ }
+ else if (e->button == 3) {
gdk_window_set_cursor (w->window, NULL);
gdk_flush ();
}
@@ -763,7 +774,8 @@ g_plot_set_axis_labels (GPlot *p, gchar *x, gchar *y)
p->priv->xlabel = g_strdup (x);
p->priv->bottom_border = BORDER_SIZE + extents.height;
- } else {
+ }
+ else {
p->priv->bottom_border = BORDER_SIZE;
if (p->priv->xlabel) {
g_free (p->priv->xlabel);
@@ -782,7 +794,8 @@ g_plot_set_axis_labels (GPlot *p, gchar *x, gchar *y)
p->priv->left_border = BORDER_SIZE + extents.height;
p->priv->ylabel = g_strdup (y);
- } else {
+ }
+ else {
p->priv->left_border = BORDER_SIZE;
if (p->priv->ylabel) {
g_free (p->priv->ylabel);
View
11 src/gplot/gplot.h
@@ -3,9 +3,11 @@
*
* Authors:
* Ricardo Markiewicz <rmarkie@fi.uba.ar>
+ * Marc Lorber <lorber.marc@wanadoo.fr>
*
* Copyright (C) 1999-2001 Richard Hult
* Copyright (C) 2003,2004 Ricardo Markiewicz
+ * Copyright (C) 2009-2010 Marc Lorber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -30,9 +32,9 @@
#include <gtk/gtk.h>
#include <glib.h>
-#define GPLOT(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_GPLOT, GPlot)
-#define IS_GPLOT(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_GPLOT)
-#define TYPE_GPLOT (g_plot_get_type())
+#define GPLOT(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_GPLOT, GPlot)
+#define IS_GPLOT(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, TYPE_GPLOT)
+#define TYPE_GPLOT (g_plot_get_type())
typedef struct _GPlot GPlot;
typedef struct _GPlotFunction {} GPlotFunction;
@@ -52,5 +54,4 @@ void g_plot_reset_zoom (GPlot *);
void g_plot_set_axis_labels (GPlot *, gchar *, gchar *);
void g_plot_window_to_device (GPlot *, double *x, double *y);
-#endif
-
+#endif
View
2 src/gplot/gplotfunction.c
@@ -3,9 +3,11 @@
*
* Authors:
* Ricardo Markiewicz <rmarkie@fi.uba.ar>
+ * Marc Lorber <lorber.marc@wanadoo.fr>
*
* Copyright (C) 1999-2001 Richard Hult
* Copyright (C) 2003,2004 Ricardo Markiewicz
+ * Copyright (C) 2009-2010 Marc Lorber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
View
6 src/gplot/gplotfunction.h
@@ -3,9 +3,11 @@
*
* Authors:
* Ricardo Markiewicz <rmarkie@fi.uba.ar>
+ * Marc Lorber <lorber.marc@wanadoo.fr>
*
* Copyright (C) 1999-2001 Richard Hult
* Copyright (C) 2003,2004 Ricardo Markiewicz
+ * Copyright (C) 2009-2010 Marc Lorber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -28,8 +30,8 @@
#include <gtk/gtk.h>
-#define GPLOT_FUNCTION(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_GPLOT_FUNCTION, GPlotFunction)
-#define IS_GPLOT_FUNCTION (obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_GPLOT_FUNCTION)
+#define GPLOT_FUNCTION(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_GPLOT_FUNCTION, GPlotFunction)
+#define IS_GPLOT_FUNCTION(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, TYPE_GPLOT_FUNCTION)
typedef struct _GPlotFunctionBBox {
gdouble xmin;
View
79 src/gplot/gplotlines.c
@@ -3,9 +3,11 @@
*
* Authors:
* Ricardo Markiewicz <rmarkie@fi.uba.ar>
+ * Marc Lorber <lorber.marc@wanadoo.fr>
*
* Copyright (C) 1999-2001 Richard Hult
* Copyright (C) 2003,2004 Ricardo Markiewicz
+ * Copyright (C) 2009-2010 Marc Lorber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -24,6 +26,7 @@
*/
#include <string.h>
+
#include "gplot-internal.h"
#include "gplotlines.h"
@@ -48,8 +51,8 @@ static void g_plot_lines_init (GPlotLines* plot);
static void g_plot_lines_draw (GPlotFunction *, cairo_t *, GPlotFunctionBBox *);
static void g_plot_lines_get_bbox (GPlotFunction *, GPlotFunctionBBox *);
static void g_plot_lines_function_init (GPlotFunctionClass *iface);
-static void g_plot_lines_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *spec);
-static void g_plot_lines_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *spec);
+static void g_plot_lines_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *spec);
+static void g_plot_lines_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *spec);
static GObjectClass* parent_class = NULL;
@@ -85,8 +88,8 @@ struct _GPlotLinesPriv {
gdouble shift;
};
-#define TYPE_GPLOT_LINES (g_plot_lines_get_type())
-#define TYPE_GPLOT_GRAPHIC_TYPE (g_plot_lines_graphic_get_type())
+#define TYPE_GPLOT_LINES (g_plot_lines_get_type ())
+#define TYPE_GPLOT_GRAPHIC_TYPE (g_plot_lines_graphic_get_type ())
#define NG_DEBUG(s) if (0) g_print ("%s\n", s)
G_DEFINE_TYPE_WITH_CODE (GPlotLines, g_plot_lines, G_TYPE_OBJECT,
@@ -94,18 +97,18 @@ G_DEFINE_TYPE_WITH_CODE (GPlotLines, g_plot_lines, G_TYPE_OBJECT,
g_plot_lines_function_init));
GType
-g_plot_lines_graphic_get_type(void)
+g_plot_lines_graphic_get_type (void)
{
- static GType etype = 0;
- if (etype == 0) {
- static const GEnumValue values[] = {
- { FUNCTIONAL_CURVE, "FUNCTIONAL_CURVE", "funct-curve" },
- { FREQUENCY_PULSE, "FREQUENCY_PULSE", "freq-pulse" },
- { 0, NULL, NULL }
- };
- etype = g_enum_register_static ("GraphicType", values);
- }
- return etype;
+ static GType etype = 0;
+ if (etype == 0) {
+ static const GEnumValue values[] = {
+ { FUNCTIONAL_CURVE, "FUNCTIONAL_CURVE", "funct-curve" },
+ { FREQUENCY_PULSE, "FREQUENCY_PULSE", "freq-pulse" },
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GraphicType", values);
+ }
+ return etype;
}
static void
@@ -116,13 +119,13 @@ g_plot_lines_function_init (GPlotFunctionClass *iface)
}
static void
-g_plot_lines_dispose(GObject *object)
+g_plot_lines_dispose (GObject *object)
{
- G_OBJECT_CLASS(parent_class)->dispose(object);
+ G_OBJECT_CLASS (parent_class)->dispose(object);
}
static void
-g_plot_lines_finalize(GObject *object)
+g_plot_lines_finalize (GObject *object)
{
GPlotLines *lines;
@@ -135,7 +138,7 @@ g_plot_lines_finalize(GObject *object)
g_free (lines->priv);
}
- G_OBJECT_CLASS(parent_class)->finalize(object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
@@ -153,34 +156,24 @@ g_plot_lines_class_init (GPlotLinesClass* class)
g_object_class_override_property (object_class, ARG_VISIBLE, "visible");
- g_object_class_install_property(
- object_class,
- ARG_WIDTH,
+ g_object_class_install_property (object_class, ARG_WIDTH,
g_param_spec_double ("width", "GPlotLines::width",
"the line width", 0.1, 5.0, 1.0, G_PARAM_READWRITE));
- g_object_class_install_property(
- object_class,
- ARG_COLOR,
+ g_object_class_install_property (object_class, ARG_COLOR,
g_param_spec_string ("color", "GPlotLines::color",
"the string color line", "white", G_PARAM_READWRITE));
- g_object_class_install_property(
- object_class,
- ARG_COLOR_GDKCOLOR,
+ g_object_class_install_property (object_class, ARG_COLOR_GDKCOLOR,
g_param_spec_pointer ("color-rgb", "GPlotLines::color-rgb",
"the GdkColor of the line", G_PARAM_READWRITE));
- g_object_class_install_property(
- object_class,
- ARG_GRAPH_TYPE,
+ g_object_class_install_property (object_class, ARG_GRAPH_TYPE,
g_param_spec_enum ("graph-type", "GPlotLines::graph-type",
"the type of graphic", TYPE_GPLOT_GRAPHIC_TYPE,
FUNCTIONAL_CURVE, G_PARAM_READWRITE));
- g_object_class_install_property(
- object_class,
- ARG_SHIFT,
+ g_object_class_install_property (object_class, ARG_SHIFT,
g_param_spec_double ("shift", "GPlotLines::shift",
"the shift for multiple pulses", 0.0, 500.0, 50.0, G_PARAM_READWRITE));
}
@@ -201,7 +194,7 @@ g_plot_lines_init (GPlotLines* plot)
}
static void
-g_plot_lines_set_property(GObject *object, guint prop_id, const GValue *value,
+g_plot_lines_set_property (GObject *object, guint prop_id, const GValue *value,
GParamSpec *spec)
{
GPlotLines *plot = GPLOT_LINES (object);
@@ -231,7 +224,7 @@ g_plot_lines_set_property(GObject *object, guint prop_id, const GValue *value,
static void
-g_plot_lines_get_property(GObject *object, guint prop_id, GValue *value,
+g_plot_lines_get_property (GObject *object, guint prop_id, GValue *value,
GParamSpec *spec)
{
GPlotLines *plot = GPLOT_LINES (object);
@@ -293,10 +286,10 @@ g_plot_lines_get_bbox (GPlotFunction *f, GPlotFunctionBBox *bbox)
plot->priv->bbox.ymin = 99999999;
plot->priv->bbox.ymax = -99999999;
for (point = 0; point < points; point++) {
- plot->priv->bbox.xmin = MIN(plot->priv->bbox.xmin, x[point]);
- plot->priv->bbox.ymin = MIN(plot->priv->bbox.ymin, y[point]);
- plot->priv->bbox.xmax = MAX(plot->priv->bbox.xmax, x[point]);
- plot->priv->bbox.ymax = MAX(plot->priv->bbox.ymax, y[point]);
+ plot->priv->bbox.xmin = MIN (plot->priv->bbox.xmin, x[point]);
+ plot->priv->bbox.ymin = MIN (plot->priv->bbox.ymin, y[point]);
+ plot->priv->bbox.xmax = MAX (plot->priv->bbox.xmax, x[point]);
+ plot->priv->bbox.ymax = MAX (plot->priv->bbox.ymax, y[point]);
}
plot->priv->bbox_valid = TRUE;
}
@@ -338,14 +331,16 @@ g_plot_lines_draw (GPlotFunction *f, cairo_t *cr, GPlotFunctionBBox *bbox)
}
cairo_line_to (cr, x[point], y[point]);
- } else {
+ }
+ else {
if (!first_point) {
cairo_line_to (cr, x[point], y[point]);
first_point = TRUE;
}
}
}
- } else {
+ }
+ else {
for (point = 1; point < points; point++) {
x1 = x[point-1]+plot->priv->shift;
y1 = 0;
View
10 src/gplot/gplotlines.h
@@ -3,9 +3,11 @@
*
* Authors:
* Ricardo Markiewicz <rmarkie@fi.uba.ar>
+ * Marc Lorber <lorber.marc@wanadoo.fr>
*
* Copyright (C) 1999-2001 Richard Hult
* Copyright (C) 2003,2004 Ricardo Markiewicz
+ * Copyright (C) 2009,2010 Marc Lorber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -34,11 +36,9 @@ typedef enum {
FREQUENCY_PULSE
} GraphicType;
-#define GPLOT_LINES(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_GPLOT_LINES, GPlotLines)
-#define IS_GPLOT_LINES(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_GPLOT_LINES)
+#define GPLOT_LINES(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_GPLOT_LINES, GPlotLines)
+#define IS_GPLOT_LINES(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, TYPE_GPLOT_LINES)
GPlotFunction* g_plot_lines_new (gdouble *x, gdouble *y, guint points);
-#endif
-
-
+#endif

0 comments on commit 7a1b1a6

Please sign in to comment.
Something went wrong with that request. Please try again.