Re: adding gtkdatabox_region



I had a bug in the attached header file.
Please replace with this one ...

On 24/02/12 10:22, Brian Phelps wrote:
I am checking it out tonight.  Please add an example program also and I will incorporate the patch after I test it.

Sent from my 4G etch-a-sketch.



On Thu, Feb 23, 2012 at 5:51 PM, Matt Flax <flatmax mimosaacoustics com> wrote:
here is my git diff.

I have added the new feature to the basics2.c example. Run it to see it in action !

I decided the best way to approach the new feature is :
a] To call the new plotting feature offset_bars : Bars which start at Y1 and end at Y2
b] To create a new XYYC graph type ... called gtkdatabox_xyyc_graph which handles X, Y1 and Y2. This approach leaves all of the other XYC graphs and plotting methods intact. It is also logical because for each X ordinate we have two Y co-ordinates to draw a line from and to.
c] I found a redundant variable in  _GtkDataboxXYCGraphPrivate. The GdkPoint * is never used ... does anyone know where it is used ? I have removed it and the 'free' call.


What do you think ?
Is there a better name for the new feature ?


Matt

On 24/02/12 05:55, Brian Phelps wrote:
Looks interesting.  DO you have a patch?  t

Sent from my 4G etch-a-sketch.



On Thu, Feb 23, 2012 at 1:05 AM, Matt Flax <flatmax mimosaacoustics com> wrote:
Hi there,

I would like to add a new type of graph to gtkdatabox.

What do you think of a gtkdatabox_region type of graph ? See the attachment.

It would let you plot a region of colour on the graph - similar to the gtkdatabox_bars graph, however allowing two Y points for each X.
In this way, a region of colour may be plotted.
Currently gtkdatabox_bars sets the bar region like so :
      data->x1 = data->x2 = gtk_databox_value_to_pixel_x (box, *X);

      data->y1 = zero;

      data->y2 = gtk_databox_value_to_pixel_y (box, *Y);

I would think that the gtkdatabox_region graph would do something like this instead :
      data->x1 = data->x2 = gtk_databox_value_to_pixel_x (box, *X);

      data->y1 = gtk_databox_value_to_pixel_y (box, *Y2);

      data->y2 = gtk_databox_value_to_pixel_y (box, *Y);


What do you think ?

I have already tested this method and it is attached.

Matt
p.s. I previously posted this message, but the attachment was too large, so I am resending with a smaller attachment.

_______________________________________________
gtkdatabox-list mailing list
gtkdatabox-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkdatabox-list





/* $Id: gtkdatabox_xyyc_graph.h 4 2008-06-22 09:19:11Z rbock $ */
/* GtkDatabox - An extension to the gtk+ library
 * Copyright (C) 1998 - 2008  Dr. Roland Bock
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

/**
 * SECTION:gtkdatabox_xyyc_graph
 * @short_description: An abstract anchestor for all graphs which display xyy-values (x, y1 and y2 values) in one color.
 * @include: gtkdatabox_xyyc_graph.h
 * @see_also: #GtkDatabox, #GtkDataboxOffsetBars
 *
 * GtkDataboxXYYCGraphs are an abstract class for displaying XYY-data (x, y1 and y2 values) in one color. The values for the data are represented
 * as an array of X values, an array of Y1 values and an array of Y2 values. In order to actually display data, you should
 * use one of the derived classes.
 *
 */

#ifndef __GTK_DATABOX_XYYC_GRAPH_H__
#define __GTK_DATABOX_XYYC_GRAPH_H__

#include <gtkdatabox_graph.h>

G_BEGIN_DECLS
#define GTK_DATABOX_TYPE_XYYC_GRAPH		  (gtk_databox_xyyc_graph_get_type ())
#define GTK_DATABOX_XYYC_GRAPH(obj)		  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
                                           GTK_DATABOX_TYPE_XYYC_GRAPH, \
                                           GtkDataboxXYYCGraph))
#define GTK_DATABOX_XYYC_GRAPH_CLASS(klass)	  (G_TYPE_CHECK_CLASS_CAST ((klass), \
                                           GTK_DATABOX_TYPE_XYYC_GRAPH, \
                                           GtkDataboxXYYCGraphClass))
#define GTK_DATABOX_IS_XYYC_GRAPH(obj)	  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
                                           GTK_DATABOX_TYPE_XYYC_GRAPH))
#define GTK_DATABOX_IS_XYYC_GRAPH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
                                           GTK_DATABOX_TYPE_XYYC_GRAPH))
#define GTK_DATABOX_XYYC_GRAPH_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
                                           GTK_DATABOX_TYPE_XYYC_GRAPH, \
                                           GtkDataboxXYYCGraphClass))

/**
 * GtkDataboxXYYCGraph:
 *
 * GtkDataboxXYYCGraphs are an abstract class for displaying XY-data in one color. The values for the data are represented
 * as an array of X values and a second array of Y values. In order to actually display data, you should
 * use one of the derived classes.
 *
 */
   typedef struct _GtkDataboxXYYCGraph GtkDataboxXYYCGraph;

   typedef struct _GtkDataboxXYYCGraphClass GtkDataboxXYYCGraphClass;

   /**
    * GtkDataboxXYYCGraphPrivate
    *
    * A private data structure used by the #GtkDataboxXYYCGraph. It shields all internal things
    * from developers who are just using the object.
    *
    **/
   typedef struct _GtkDataboxXYYCGraphPrivate GtkDataboxXYYCGraphPrivate;

   struct _GtkDataboxXYYCGraph
   {
      /*< private >*/
      GtkDataboxGraph parent;

      GtkDataboxXYYCGraphPrivate *priv;
   };

   struct _GtkDataboxXYYCGraphClass
   {
      GtkDataboxGraphClass parent_class;
   };

   GType gtk_databox_xyyc_graph_get_type (void);

   guint gtk_databox_xyyc_graph_get_length (GtkDataboxXYYCGraph * xyyc_graph);
   gfloat *gtk_databox_xyyc_graph_get_X (GtkDataboxXYYCGraph * xyyc_graph);
   gfloat *gtk_databox_xyyc_graph_get_Y1 (GtkDataboxXYYCGraph * xyyc_graph);
   gfloat *gtk_databox_xyyc_graph_get_Y2 (GtkDataboxXYYCGraph * xyyc_graph);

G_END_DECLS
#endif				/* __GTK_DATABOX_XYYC_GRAPH_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]