Commit 18cda29f authored by Arturo Espinosa's avatar Arturo Espinosa

Initial framework, does not even work, do not even try -miguel

parent dcf2a876
1999-09-30 Miguel de Icaza <miguel@gnu.org>
* New ChangeLog file.
/*
* Graphic module CORBA interface
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*
* (C) 1999 International GNOME Support (http://www.gnome-support.com)
*/
#include <Gnumeric-value.idl>
#include <gnome-unknown.idl>
module GNOME {
module Graph {
enum ScaleType {
SCALE_TYPE_LINEAR,
SCALE_TYPE_LOGARITMIC,
SCALE_TYPE_PERCENT
};
interface AxisScale {
/*
* Whether the Axis is hidden
*/
attribute boolean hidden;
ScaleType type ();
/*
* The logaritmic base
*/
attribute short log_base;
};
enum AngleUnit {
ANGLE_DEGREES,
ANGLE_RADIANS,
ANGLE_GRADS
};
interface Plot {
//
// Units of measure used for chart angles
//
attribute AngleUnit angle_unit;
//
// Direction in which pie charts are drawn
//
attribute boolean clockwise;
//
// Whether the slices of a pie are sorted
//
attribute boolean sorted;
//
//
//
// Backdrop backdrop ();
//
// Starting angle for drawing pie charts.
//
attribute short starting_angle;
};
enum ChartType {
//
// Columns or bars where groups of ith-elements
// are plotted next to each other.
CHART_TYPE_CLUSTERED,
//
// ith-values of each series are stacked
// on top of each other.
//
CHART_TYPE_STACKED,
//
// Values fill entire plot
//
CHART_TYPE_STACKED_FULL,
//
// Extra axis displays i-th
//
CHART_TYPE_3D,
//
// Pie
//
CHART_TYPE_PIE,
//
// Scatter
//
CHART_TYPE_SCATTER,
//
// Surface
//
CHART_TYPE_SURFACE_2D,
CHART_TYPE_SURFACE_3D,
//
// Bubbles
//
CHART_TYPE_BUBBLES,
//
// Stock
//
CHART_TYPE_STOCK_HIGH_LOW_CLOSE,
CHART_TYPE_STOCK_OPEN_HIGH_LOW_CLOSE,
CHART_TYPE_STOCK_VOL_HIGH_LOW_CLOSE,
CHART_TYPE_STOCK_VOL_OPEN_HIGH_LOW_CLOSE
};
enum PlotMode {
PLOT_COLBAR, // Columns or bars.
PLOT_LINES, // Lines
PLOT_AREA // Areas
};
enum ColBarMode {
COLBAR_FLAT,
COLBAR_CUBE,
COLBAR_PIRAMID,
COLBAR_CONE,
COLBAR_CYLINDER
};
enum DirMode {
DIR_BAR,
DIR_COL
};
enum LineMode {
LINE_PLAIN,
LINE_MARKERS
};
enum PieMode {
PIE_SIMPLE,
PIE_EXPLODED
};
enum PieDimension {
PIE_2D,
PIE_3D
};
enum ScatterPoints {
SCATTER_NONE,
SCATTER_POINTS
};
enum ScatterConn {
SCATTER_CONN_NONE,
SCATTER_CONN_SMOOTH,
SCATTER_CONN_LINES
};
enum SurfaceMode {
SURFACE_WIREFRAME,
SURFACE_COLORED
};
interface Chart : GNOME::Unknown {
attribute ChartType chart_type;
attribute PlotMode plot_mode;
attribute ColBarMode col_bar_mode;
attribute DirMode direction;
attribute LineMode line_mode;
attribute PieMode pie_mode;
attribute PieDimension pie_dim;
attribute ScatterPoints scatter_mode;
attribute ScatterConn scatter_conn;
attribute SurfaceMode surface_mode;
//
// Methods for avoiding un-needed repaints.
//
void freeze ();
void thaw ();
};
};
};
bin_PROGRAMS = graph
graph_SOURCES = \
data-source.c \
data-source.h \
series.c \
series.h
/*
* Data Source abstract class
*
* Author:
* Miguel de Icaza (miguel@kernel.org)
*
* (C) 1999 International GNOME Support, http://www.gnome-support.com
*/
#include <config.h>
#include "data-source.h"
#include "util.h"
static DataSourceClass *dsc;
static void
data_source_init (GtkObject *object)
{
}
static void
data_source_class_init (GtkObjectClass *object_class)
{
dsc = gtk_type_class (data_source_get_type ());
}
DEFINE_TYPE(DataSource,"DataSource",gtk_object,data_source);
Value *
data_source_get_value (DataSource *data_source, const char *spec, int pos)
{
return (*dsc->get_value)(data_source, spec, pos);
}
gboolean
data_source_set_value (DataSource *data_source, const char *spec, int pos, Value *value)
{
return (*dsc->set_value)(data_source, spec, pos, value);
}
#ifndef DATA_SOURCE_H
#define DATA_SOURCE_H
typedef struct {
GtkObject parent;
} DataSource;
typedef struct {
GtkObjectClass parent_class;
Value (*get_value)(DataSource *source, const char *spec, int pos);
gboolean (*set_value)(DataSource *source, const char *spec, int pos, Value *value);
} DataSourceClass;
GtkType data_source_get_type (void);
Value *data_source_get_value (DataSource *source, const char *spec, int pos);
DataResult data_source_set_value (DataSource *source, const char *spec, int pos, Value *value);
#endif /* DATA_SOURCE_H */
/*
* graph.c: Implements the core of the graphics engine
*
* Author:
* Miguel de Icaza (miguel@kernel.org)
*
* (C) 1999 International GNOME Support
*/
#include <config.h>
#include "graph.h"
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef GRAPH_GRAPH_H_
#define GRAPH_GRAPH_H_
#include <libgnome/gnome-defs.h>
#include <bonobo/gnome-object.h>
BEGIN_GNOME_DECLS
#define GRAPH_TYPE (graph_get_type ())
#define GRAPH(o) (GTK_CHECK_CAST ((o), GRAPH_TYPE, Graph))
#define GRAPH_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GRAPH_TYPE, GraphClass))
#define IS_GRAPH(o) (GTK_CHECK_TYPE ((o), GRAPH_TYPE))
#define IS_GRAPH_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GRAPH_TYPE))
struct Graph {
GnomeObject base;
GNOME_Graph_ChartType chart_type;
GNOME_Graph_ScaleType scale_type;
GNOME_Graph_PlotMode plot_mode;
GNOME_Graph_ColBarMode col_bar_mode;
GNOME_Graph_DirMode direction;
GNOME_Graph_LineMode line_mode;
GNOME_Graph_PieMode pie_mode;
GNOME_Graph_PieDimension pie_dim;
GNOME_Graph_ScatterPoints scatter_mode;
GNOME_Graph_ScatterConn scatter_conn;
GNOME_Graph_SurfaceMode surface_mode;
};
struct GraphClass {
GnomeObjectClass parent_class;
};
GtkType graph_get_type (void);
END_GNOME_DECLS
#endif /* GRAH_GRAPH_H_ */
/*
* Plot item
*
* Author:
* Miguel de Icaza (miguel@kernel.org)
*
* (C) 1999 International GNOME Support (http://www.gnome-support.com).
*/
#include <config.h>
#include
#ifndef GRAPH_PLOT_H
#define GRAPH_PLOT_H
#include "reference.h"
#include "series.h"
typedef struct {
DataSeries *series;
} PlotState;
PlotState *plot_state_new (void);
#endif /* GRAPH_PLOT_H */
/*
* reference.c: references to an external source
*
* Author:
* Miguel de Icaza (miguel@kernel.org)
*
* (C) 1999 International GNOME Support
*/
#include <config.h>
#include "reference.h"
struct _Reference {
DataSource *data_source;
char *spec;
};
Reference *
reference_new (DataSource *data_source, const char *spec)
{
Reference *ref;
g_return_val_if_fail (data_source != NULL, NULL);
g_return_val_if_fail (spec != NULL, NULL);
ref = g_new (Reference, 1);
ref->data_source = data_source;
gtk_object_ref (GTK_OBJECT (ref->data_source));
ref->spec = g_strdup (spec);
return ref;
}
Reference *
reference_duplicate (Reference *reference)
{
g_return_val_if_fail (reference != NULL, NULL);
return reference_new (reference->data_source, reference->spec);
}
void
reference_destroy (Reference *reference)
{
g_return_if_fail (reference != NULL);
gtk_object_unref (GTK_OBJECT (reference->data_source));
g_free (reference->spec);
g_free (reference);
}
Value *
reference_value (Reference *reference)
{
g_return_val_if_fail (reference != NULL, NULL);
return data_source_get_value (reference->data_source, reference->spec, 0);
}
#ifndef GRAPH_REFERENCE_H
#define GRAPH_REFERENCE_H
typedef struct _Reference Reference;
Reference *reference_new (DataSource *data_source, const char *spec);
Reference *reference_duplicate (Reference *reference);
void reference_destroy (Reference *reference);
Value *referece_value (Reference *reference);
#endif /* GRAPH_REFERENCE_H */
/*
* Series handling.
*
* Author:
* Miguel de Icaza (miguel@kernel.org)
*/
#include <config.h>
#include "series.h"
struct _SeriesName {
Reference *ref;
char *str;
};
SeriesName *
series_name_new (void)
{
return g_new0 (SeriesName, 1);
}
static void inline
free_sn (SeriesName *sn)
{
if (sn->ref){
reference_destroy (sn->ref);
sn->ref = NULL;
}
if (sn->str){
g_free (sn->str);
sn->str = NULL;
}
}
void
series_name_set_from_ref (SeriesName *sn, Reference *ref)
{
g_return_if_fail (sn != NULL);
g_return_if_fail (ref != NULL);
free_sn (sn);
sn->ref = reference_duplicate (ref);
}
void
series_name_set_from_string (SeriesName *sn, const char *str)
{
g_return_if_fail (sn != NULL);
g_return_if_fail (str != NULL);
free_sn (sn);
sn->str = g_strdup (str);
}
void
series_name_destroy (SeriesName *sn)
{
g_return_if_fail (sn != NULL);
free_sn (sn);
g_free (sn);
}
char *
series_name_get_string (SeriesName *sn)
{
Value *val;
char *ret;
g_return_val_if_fail (sn != NULL, NULL);
if (sn->str)
return g_strdup (sn->str);
val = reference_value (sn->ref);
ret = value_get_as_string (val);
value_release (val);
return ret;
}
struct _Series {
DataSource *source;
SeriesName *series_name;
char *value_spec;
};
Series *
series_new (DataSource *source, const char *value_spec)
{
Series *series;
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (name_spec != NULL, NULL);
series = g_new (Series, 1);
series->source = source;
gtk_object_ref (GTK_OBJECT (series->source));
series->name_spec = NULL
series->value_spec = g_strdup (value_spec);
return series
}
void
series_set_name (Series *series, SeriesName *series_name)
{
g_return_if_fail (series != NULL);
g_return_if_fail (series_name != NULL);
if (series->name_spec)
series_name_destroy (series->name_spec);
series->name_spec = series_name;
}
void
series_set_source (Series *series, DataSource *source, const char *value_spec)
{
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (value_spec != NULL, NULL);
g_return_val_if_fail (series != NULL, NULL);
gtk_object_unref (GTK_OBJECT (series->source));
series->source = source;
gtk_object_ref (GTK_OBJECT (series->source));
g_free (series->value_spec);
series->value_spec = g_strdup (value_spec);
}
void
series_destroy (Series *series)
{
if (series->name_spec)
series_name_destroy (series->name_spec);
gtk_object_unref (GTK_OBJECT (series->source));
g_free (series->value_spec);
g_free (series);
}
SeriesName *
series_get_series_name (Series *series)
{
g_return_val_if_fail (series != NULL, NULL);
return series->name_spec;
}
char *
series_get_name (Series *series)
{
g_return_val_if_fail (series != NULL, NULL);
return series_name_get_string (series->name_spec);
}
Value *
series_get_value (Series *series, int n)
{
g_return_val_if_fail (series != NULL);
return data_source_fetch_value (series->data_source, series->value_spec, n);
}
void
data_set_set_value (Series *series, int n, Value *value)
{
g_return_val_if_fail (series != NULL);p
return data_source_set_value (series->data_source, series->value_spec, n, value);
}
#ifndef GRAPH_SERIES_H
#define GRAPH_SERIES_H
#include "reference.h"
typedef struct _SeriesName SeriesName;
SeriesName *series_name_new (void);
void series_name_set_from_ref (SeriesName *sn, Reference *ref);
void series_name_set_from_string (SeriesName *sn, const char *str);
char *series_get_string (SeriesName *sn);
void series_name_destory (SeriesName *sn);
typedef struct _Series Series;
Series *series_new (DataSource *source, const char *name_spec);
void series_set_name (Series *series, SeriesName *series_name);
void series_set_source (Series *series, DataSource *source, const char *name_spec);
void series_destroy (Series *series);
SeriesName *series_get_series_name (Series *series);
char *series_get_name (Series *series);
#endif
#ifndef GRAPH_UTIL_H
#define GRAPH_UTIL_H
#define DEFINE_TYPE(name,strname,parent,prefix) \
GtkType prefix##_get_type (void) \
{ \
static GtkType type = 0; \
\
if (!type){ \
GtkTypeInfo info = { \
strname, \
sizeof (name), \
sizeof (name##Class), \
(GtkClassInitFunc) prefix##_class_init, \
(GtkObjectInitFunc) prefix##_init, \
NULL, NULL, NULL \
}; \
\
type = gtk_type_unique (parent##_get_type (), &info);\
} \
\
return type;\
}
#endif /* GRAPH_UTIL_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment