genius r734 - in trunk: . gtkextra src
- From: jirka svn gnome org
- To: svn-commits-list gnome org
- Subject: genius r734 - in trunk: . gtkextra src
- Date: Tue, 24 Feb 2009 07:39:51 +0000 (UTC)
Author: jirka
Date: Tue Feb 24 07:39:51 2009
New Revision: 734
URL: http://svn.gnome.org/viewvc/genius?rev=734&view=rev
Log:
Tue Feb 24 01:35:34 2009 Jiri (George) Lebl <jirka 5z com>
* src/graphing.c: use gtkextra clipping of lines
* gtkextra/*.c: apply patches from cvs gtkextra
* gtkextra/gtkplotgdk.c: fix drawing of lines which have parts which
are very far offscreen. Need to push this logic higher up the stack
since such lines also kill the postscript output.
* src/graphing.c: remove some pointless allocation of point
arrays.
* src/gnome-genius.c, src/graphing.c: fix menu accelerators
Modified:
trunk/ChangeLog
trunk/gtkextra/gtkplot.c
trunk/gtkextra/gtkplotdata.c
trunk/gtkextra/gtkplotgdk.c
trunk/src/gnome-genius.c
trunk/src/graphing.c
Modified: trunk/gtkextra/gtkplot.c
==============================================================================
--- trunk/gtkextra/gtkplot.c (original)
+++ trunk/gtkextra/gtkplot.c Tue Feb 24 07:39:51 2009
@@ -49,6 +49,7 @@
UPDATE,
MOVED,
RESIZED,
+ PLOT_AXIS_CHANGED,
LAST_SIGNAL
};
@@ -308,6 +309,14 @@
gtkextra_BOOL__POINTER_POINTER,
GTK_TYPE_BOOL, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER);
+ plot_signals[PLOT_AXIS_CHANGED] =
+ gtk_signal_new("axis_changed",
+ GTK_RUN_LAST,
+ GTK_CLASS_TYPE(object_class),
+ GTK_SIGNAL_OFFSET (GtkPlotClass, moved),
+ gtkextra_BOOL__POINTER,
+ GTK_TYPE_BOOL, 1, GTK_TYPE_PLOT_AXIS);
+
object_class->destroy = gtk_plot_destroy;
gobject_class->set_property = gtk_plot_set_property;
gobject_class->get_property = gtk_plot_get_property;
@@ -2951,7 +2960,8 @@
point = ticks.break_max + (x - ticks.break_position)*(ticks.max-ticks.break_max)/(1-ticks.break_position);
}
} else {
- point = ticks.min + x*(ticks.max-ticks.min);
+ point = log(ticks.min) + x*(log(ticks.max/ticks.min));
+ point = exp(point);
}
break;
}
@@ -4978,7 +4988,7 @@
tick = min;
n = 0;
while(tick <= max + 2*fabs(major_step)){
- if(tick >= min-major_step*1.E-10 && tick <= max+major_step*1.E-10){
+ if(tick >= min-major_step*1.E-2 && tick <= max+major_step*1.E-2){
nmajor ++;
major = g_realloc(major, nmajor*sizeof(GtkPlotTick));
major[nmajor-1].value = tick;
@@ -5006,7 +5016,7 @@
gint i;
n = 0;
for(nmajor = 0; nmajor <= ticks->nmajorticks; nmajor++){
- if(nmajor < ticks->nmajorticks && major[nmajor].value >= absmin-major_step*1.E-10 && major[nmajor].value <= absmax+major_step*1.E-10){
+ if(nmajor < ticks->nmajorticks && major[nmajor].value >= absmin-major_step*1.E-2 && major[nmajor].value <= absmax+major_step*1.E-2){
n++;
ticks->values = g_realloc(ticks->values, n*sizeof(GtkPlotTick));
ticks->values[n-1] = major[nmajor];
@@ -5036,7 +5046,7 @@
tick += tick_step;
break;
}
- if(tick >= absmin-major_step*1.E-10 && tick <= absmax+major_step*1.E-10){
+ if(tick >= absmin-major_step*1.E-2 && tick <= absmax+major_step*1.E-2){
n++;
ticks->values = g_realloc(ticks->values, n*sizeof(GtkPlotTick));
ticks->values[n-1].value = tick;
@@ -5052,7 +5062,6 @@
if(major) g_free(major);
/* sorting ticks */
-
while(changed){
gint i;
changed = FALSE;
Modified: trunk/gtkextra/gtkplotdata.c
==============================================================================
--- trunk/gtkextra/gtkplotdata.c (original)
+++ trunk/gtkextra/gtkplotdata.c Tue Feb 24 07:39:51 2009
@@ -249,6 +249,7 @@
ARG_GRADIENT_BREAK_NMINOR,
ARG_GRADIENT_BREAK_SCALE,
ARG_GRADIENT_BREAK_POSITION,
+ ARG_GRADIENT,
};
static GtkWidgetClass *parent_class = NULL;
@@ -883,6 +884,13 @@
P_(""),
0.,1.,0.0,
G_PARAM_READABLE|G_PARAM_WRITABLE));
+ g_object_class_install_property(gobject_class,
+ ARG_GRADIENT,
+ g_param_spec_object ("bottom_axis",
+ P_(""),
+ P_(""),
+ GTK_TYPE_PLOT_AXIS,
+ G_PARAM_READABLE));
data_class->clone = gtk_plot_data_real_clone;
data_class->add_to_plot = NULL;
@@ -1714,6 +1722,9 @@
if(!data->gradient) return;
g_value_set_double(value, data->gradient->ticks.break_position);
break;
+ case ARG_GRADIENT:
+ g_value_set_object(value, GTK_OBJECT(data->gradient));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -2295,6 +2306,8 @@
gint gradient_width = 0;
gint gradient_height = 0;
gint width = 0, height = 0;
+ gint nmajor = 0;
+ gint y_max = 0;
g_return_if_fail(data->plot != NULL);
g_return_if_fail(GTK_IS_PLOT(data->plot));
@@ -2439,9 +2452,12 @@
}
}
+ for(level = nlevels-1; level >= 0; level--){
+ if(!data->gradient->ticks.values[level].minor) nmajor++;
+ }
if(!data->gradient_custom){
- gint ncolors = line_height * (data->gradient->ticks.nticks - 1);
+ gint ncolors = (nmajor-1)*line_height;
gint cy;
gdouble h;
gint l;
@@ -2466,6 +2482,7 @@
x, y,
roundint(data->gradient_line_width * m),
ncolors);
+ y_max = y + ncolors;
} else {
@@ -2473,6 +2490,7 @@
legend.x = (gdouble)(area.x + x) / (gdouble)area.width;
ry = y;
+ gint ncolors = 0;
for(level = nlevels-1; level >= 0; level--){
gdouble val, h;
gboolean sublevel = FALSE;
@@ -2480,6 +2498,10 @@
val = data->gradient->ticks.values[level].value;
sublevel = data->gradient->ticks.values[level].minor;
+/*
+ if(val <= data->gradient->ticks.min || val > data->gradient->ticks.max) continue;
+*/
+
if(level != 0){
h = val;
color = data->gradient_colors[level-1];
@@ -2489,16 +2511,18 @@
gtk_plot_pc_draw_rectangle(plot->pc, TRUE,
x, ry,
roundint(data->gradient_line_width * m),
- line_height/(gdouble)(data->gradient->ticks.nminor+1)+1);
+ line_height/(gdouble)(data->gradient->ticks.nminor+1));
+ ncolors++;
+ ry += line_height/(gdouble)(data->gradient->ticks.nminor+1);
}
- ry += line_height/(gdouble)(data->gradient->ticks.nminor+1);
}
gtk_plot_pc_set_color(plot->pc, &plot->legends_attr.fg);
gtk_plot_pc_set_lineattr(plot->pc, plot->legends_border_width, 0, 0, 0);
gtk_plot_pc_draw_rectangle(plot->pc, FALSE,
x, y,
roundint(data->gradient_line_width * m),
- (data->gradient->ticks.nmajorticks)*line_height);
+ ry-y);
+ y_max = ry;
}
@@ -2510,7 +2534,11 @@
val = data->gradient->ticks.values[level].value;
if(data->gradient->ticks.values[level].minor) sublevel = TRUE;
+ if(val < data->gradient->ticks.min || val > data->gradient->ticks.max) continue;
+
+
if(!sublevel){
+ ry = y_max-gtk_plot_axis_ticks_transform(data->gradient, val)*(y_max-y);
legend.y = (gdouble)(area.y + ry + lascent - (lascent + ldescent)/2.) / (gdouble)area.height;
gtk_plot_axis_parse_label(data->gradient, val, data->gradient->label_precision, data->gradient->label_style, text);
@@ -2547,9 +2575,9 @@
x + roundint(data->gradient_line_width * m),
ry);
}
-
ry += line_height/(gdouble)(data->gradient->ticks.nminor+1);
+
}
if(data->gradient->title_visible){
switch(data->gradient_title_pos){
@@ -2563,7 +2591,7 @@
break;
case GTK_PLOT_AXIS_RIGHT:
legend = data->gradient->title;
- legend.angle = 270;
+ legend.angle = 270;
legend.x = (gdouble)(area.x + x + lwidth + roundint((data->gradient_line_width + 2*data->gradient_border_offset) * m)) / (gdouble)area.width;
legend.y = (gdouble)(area.y + y_orig + height / 2.)/(gdouble)area.height;
legend.justification = GTK_JUSTIFY_CENTER;
@@ -2612,6 +2640,9 @@
gint nlevels = data->gradient->ticks.nticks;
gint gradient_width = 0;
gint gradient_height = 0;
+ gint nmajor = 0;
+ gint ncolors = 0;
+ gint x_max = 0;
g_return_if_fail(data->plot != NULL);
g_return_if_fail(GTK_IS_PLOT(data->plot));
@@ -2760,17 +2791,20 @@
}
}
+ for(level = nlevels-1; level >= 0; level--){
+ if(!data->gradient->ticks.values[level].minor) nmajor++;
+ }
if(!data->gradient_custom){
- gint ncolors = line_width * (data->gradient->ticks.nticks - 1);
+ gint ncolors = (nmajor-1)*line_width;
gint cx;
gdouble h;
gint l;
cx = x;
gtk_plot_pc_set_lineattr(plot->pc, 0, 0, 0, 0);
- for(l = ncolors; l >= 0; l -= 1){
- h = gtk_plot_axis_ticks_inverse(data->gradient, (gdouble)l/(gdouble)ncolors);
+ for(l = ncolors; l >= 0; l--){
+ h = gtk_plot_axis_ticks_inverse(data->gradient, (gdouble)(ncolors-l)/(gdouble)ncolors);
gtk_plot_data_get_gradient_level(data, h, &color);
gtk_plot_pc_set_color(plot->pc, &color);
@@ -2788,19 +2822,26 @@
ncolors,
roundint(data->gradient_line_height * m));
+ x_max = x + ncolors;
+
} else {
legend.x = (gdouble)(area.x + x) / (gdouble)area.width;
rx = x;
- for(level = nlevels-1; level >= 0; level--){
+ ncolors = 0;
+ for(level = 0; level < nlevels; level++){
gdouble val, h;
gboolean sublevel = FALSE;
val = data->gradient->ticks.values[level].value;
sublevel = data->gradient->ticks.values[level].minor;
+/*
+ if(val <= data->gradient->ticks.min || val > data->gradient->ticks.max) continue;
+*/
+
if(level != 0){
h = val;
color = data->gradient_colors[level-1];
@@ -2809,17 +2850,19 @@
gtk_plot_pc_draw_rectangle(plot->pc, TRUE,
rx, y,
- line_width/(gdouble)(data->gradient->ticks.nminor+1)+1,
+ line_width/(gdouble)(data->gradient->ticks.nminor+1),
roundint(data->gradient_line_height * m));
+ ncolors++;
+ rx += line_width/(gdouble)(data->gradient->ticks.nminor+1);
}
- rx += line_width/(gdouble)(data->gradient->ticks.nminor+1);
}
gtk_plot_pc_set_color(plot->pc, &plot->legends_attr.fg);
gtk_plot_pc_set_lineattr(plot->pc, plot->legends_border_width, 0, 0, 0);
gtk_plot_pc_draw_rectangle(plot->pc, FALSE,
x, y,
- (data->gradient->ticks.nmajorticks)*line_width,
+ rx - x,
roundint(data->gradient_line_height * m));
+ x_max = rx;
}
@@ -2831,7 +2874,10 @@
val = data->gradient->ticks.values[level].value;
if(data->gradient->ticks.values[level].minor) sublevel = TRUE;
+ if(val < data->gradient->ticks.min || val > data->gradient->ticks.max) continue;
+
if(!sublevel){
+ rx = x+gtk_plot_axis_ticks_transform(data->gradient, val)*(x_max-x);
legend.x = (gdouble)(area.x + rx) / (gdouble)area.width;
gtk_plot_axis_parse_label(data->gradient, val, data->gradient->label_precision, data->gradient->label_style, text);
@@ -3115,6 +3161,8 @@
gint gradient_height = 0;
gint line_height = 0;
gint nlevels = data->gradient->ticks.nticks;
+ gint nmajor;
+ gint n;
g_return_if_fail(data->plot != NULL);
g_return_if_fail(GTK_IS_PLOT(data->plot));
@@ -3178,9 +3226,14 @@
&twidth, &theight,
&tascent, &tdescent);
+ nmajor = 0;
+ for(n = nlevels-1; n >= 0; n--){
+ if(!data->gradient->ticks.values[n].minor) nmajor++;
+ }
+
if(data->gradient->orientation == GTK_ORIENTATION_VERTICAL){
line_height = MAX(lheight, roundint(data->gradient_line_height * m));
- gradient_height = (nlevels - 1) * line_height;
+ gradient_height = (nmajor - 1) * line_height;
gradient_height += 2*roundint(data->gradient_border_offset * m);
gradient_height += lheight;
@@ -3188,14 +3241,14 @@
gradient_width += roundint(data->gradient_line_width * m);
if(data->gradient->label_mask & GTK_PLOT_LABEL_IN){
- gradient_width += lwidth + roundint(data->gradient->labels_offset * m);
+ gradient_width += lwidth + roundint(data->gradient->labels_offset * 2* m);
}
if(data->gradient->label_mask & GTK_PLOT_LABEL_OUT){
- gradient_width += lwidth + roundint(data->gradient->labels_offset * m);
+ gradient_width += lwidth + roundint(data->gradient->labels_offset * 2 * m);
}
} else {
line_height = MAX(lwidth + roundint(data->gradient->labels_offset * m), roundint(data->gradient_line_width * m));
- gradient_width = (nlevels - 1) * line_height;
+ gradient_width = (nmajor - 1) * line_height;
gradient_width += 2*roundint(data->gradient_border_offset * m);
gradient_width += lwidth + roundint(data->gradient_border_offset * m);
@@ -3203,10 +3256,10 @@
gradient_height += roundint(data->gradient_line_height * m);
if(data->gradient->label_mask & GTK_PLOT_LABEL_IN){
- gradient_height += lheight + roundint(data->gradient->labels_offset * m);
+ gradient_height += lheight + roundint(data->gradient->labels_offset * 2 * m);
}
if(data->gradient->label_mask & GTK_PLOT_LABEL_OUT){
- gradient_height += lheight + roundint(data->gradient->labels_offset * m);
+ gradient_height += lheight + roundint(data->gradient->labels_offset * 2 * m);
}
}
@@ -3214,12 +3267,12 @@
switch(data->gradient_title_pos){
case GTK_PLOT_AXIS_LEFT:
case GTK_PLOT_AXIS_RIGHT:
- gradient_height = MAX(gradient_height, theight + roundint(data->gradient->labels_offset * 2 * m) + lheight);
+ gradient_height = MAX(gradient_height, theight + roundint(data->gradient->labels_offset * 3 * m) + lheight);
gradient_width += twidth + roundint(data->gradient->labels_offset * m);
break;
case GTK_PLOT_AXIS_TOP:
case GTK_PLOT_AXIS_BOTTOM:
- gradient_width = MAX(gradient_width, twidth + roundint(data->gradient->labels_offset * 2 * m));
+ gradient_width = MAX(gradient_width, twidth + roundint(data->gradient->labels_offset * 3 * m));
gradient_height += theight + roundint(data->gradient->labels_offset * m);
break;
}
@@ -4970,16 +5023,19 @@
gdouble h2, s2, v2;
gdouble value;
GtkPlotTicks *ticks = &data->gradient->ticks;
+ gint i;
+ gint start;
+ gint end = ticks->nticks;
min = data->color_min;
max = data->color_max;
if(level > ticks->max) { *color = data->color_gt_max; return; }
if(level < ticks->min) { *color = data->color_lt_min; return; }
+
+ start = ticks->scale == GTK_PLOT_SCALE_LINEAR ? (level - ticks->min) / (ticks->max - ticks->min) * ticks->nticks : 0;
+
if(data->gradient_custom){
- gint i;
- gint start = ticks->scale == GTK_PLOT_SCALE_LINEAR ? (level - ticks->min) / (ticks->max - ticks->min) * ticks->nticks : 0;
- gint end = ticks->nticks;
for(i = MAX(start-2,0); i < end; i++){
if(level > ticks->values[i].value && level <= ticks->values[i+1].value)
{
@@ -4991,8 +5047,21 @@
return;
}
+/*
+ value = -1;
+ for(i = MAX(start-2,0); i < end; i++){
+ if(level > ticks->values[i].value && level <= ticks->values[i+1].value)
+ {
+ value = (gdouble)i/(gdouble)end;
+ break;
+ }
+ }
+ if(value == -1) value = 1.;
+*/
+
value = gtk_plot_axis_ticks_transform(data->gradient, level);
+
red = min.red;
green = min.green;
blue = min.blue;
@@ -5002,9 +5071,9 @@
blue = max.blue;
rgb_to_hsv(red, green, blue, &h2, &s2, &v2);
- s = 1.;
- v = 1.;
- h = 1.;
+ s = MAX(s2,s1);
+ v = MAX(v2,v1);
+ h = MAX(h2,h1);
if(data->gradient_mask & GTK_PLOT_GRADIENT_S)
s = s1 + (s2 - s1) * value;
if(data->gradient_mask & GTK_PLOT_GRADIENT_V)
@@ -5013,7 +5082,6 @@
h = h1 + (h2 - h1) * value;
hsv_to_rgb(h, MIN(s, 1.0), MIN(v, 1.0), &red, &green, &blue);
-
color->red = red;
color->green = green;
color->blue = blue;
@@ -5219,6 +5287,7 @@
data->gradient->ticks.step = (data->gradient->ticks.max - data->gradient->ticks.min)/data->gradient->ticks.nmajorticks;
gtk_plot_axis_ticks_recalc(data->gradient);
+/*
max = data->gradient->ticks.max;
min = data->gradient->ticks.min;
if(data->gradient->ticks.set_limits){
@@ -5226,9 +5295,11 @@
min = MAX(min, data->gradient->ticks.begin);
}
data->gradient->ticks.nmajorticks = nmajorticks;
+*/
+/*
data->gradient->ticks.values[0].value = min;
data->gradient->ticks.values[data->gradient->ticks.nticks-1].value = max;
-
+*/
gtk_signal_emit(GTK_OBJECT(data), data_signals[GRADIENT_CHANGED]);
gtk_plot_data_reset_gradient_colors(data);
}
@@ -5253,8 +5324,10 @@
max = data->gradient->ticks.max;
min = data->gradient->ticks.min;
- if(data->gradient_colors)
+ if(data->gradient_colors){
g_free(data->gradient_colors);
+ data->gradient_colors = NULL;
+ }
data->gradient_custom = FALSE;
data->gradient_colors = g_new0(GdkColor, ticks->nticks + 1);
Modified: trunk/gtkextra/gtkplotgdk.c
==============================================================================
--- trunk/gtkextra/gtkplotgdk.c (original)
+++ trunk/gtkextra/gtkplotgdk.c Tue Feb 24 07:39:51 2009
@@ -429,24 +429,144 @@
roundint(x1), roundint(y1), roundint(x2), roundint(y2));
}
+static gboolean
+line_on_screen (int x1, int y1, int x2, int y2, int width, int height)
+{
+ if ( (x1 >= 0 && y1 >= 0 && x1 <= width && y1 <= height) ||
+ (x2 >= 0 && y2 >= 0 && x2 <= width && y2 <= height))
+ return TRUE;
+
+ if ( (x1 < 0 && x2 < 0) ||
+ (x1 > width && x2 > width) ||
+ (y1 < 0 && y2 < 0) ||
+ (y1 > height && y2 > height) )
+ return FALSE; /* obvious */
+
+ if (x1 == x2) {
+ /* in this case it must be true that y is in range, */
+ return TRUE;
+ } else if (x1 > x2) {
+ int t = x1;
+ x1 = x2;
+ x2 = t;
+
+ t = y1;
+ y1 = y2;
+ y2 = t;
+ }
+
+ if (x1 < 0) {
+ /* Move line so that x1 = 0 */
+ double t = -x2 / (double)(x1-x2);
+ x1 = t*x1 + (1-t)*x2;
+ y1 = t*y1 + (1-t)*y2;
+
+ /* note that x2 > 0, so t < 1 !*/
+
+ if (y1 >= 0 || y1 <= height)
+ return TRUE;
+
+ if (y1 < 0) {
+ if (y2 < 0)
+ return FALSE;
+
+ /* Move line so that y1 = 0 */
+ t = -y2 / (double)(y1-y2);
+ x1 = t*x1 + (1-t)*x2;
+ y1 = t*y1 + (1-t)*y2;
+
+ /* note that y2 > 0, so 0 < t < 1 !*/
+
+ if (x1 <= width)
+ return TRUE;
+ else
+ return FALSE;
+ } else {
+ if (y2 > height)
+ return FALSE;
+
+ /* Move line so that y1 = height */
+ t = (height-y2) / (double)(y1-y2);
+ x1 = t*x1 + (1-t)*x2;
+ y1 = t*y1 + (1-t)*y2;
+
+ /* note that y2 < height, so 0 < t < 1 !*/
+
+ if (x1 <= width)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ }
+
+ /* must be that x1 <= width and y1 < 0 or y1 > height */
+
+ if (y1 < 0) {
+ /* Move line so that y1 = 0 */
+ double t = -y2 / (double)(y1-y2);
+ x1 = t*x1 + (1-t)*x2;
+ y1 = t*y1 + (1-t)*y2;
+
+ /* y2 >= 0 so 0 < t < 1 */
+
+ if (x1 <= width)
+ return TRUE;
+ else
+ return FALSE;
+ } else {
+ /* Move line so that y1 = height */
+ double t = (height-y2) / (double)(y1-y2);
+ x1 = t*x1 + (1-t)*x2;
+ y1 = t*y1 + (1-t)*y2;
+
+ /* y2 < height so 0 < t < 1 */
+
+ if (x1 <= width)
+ return TRUE;
+ else
+ return FALSE;
+ }
+}
+
static void
gtk_plot_gdk_draw_lines (GtkPlotPC *pc,
GtkPlotPoint *points,
gint numpoints)
{
GdkPoint *p = NULL;
- gint i;
+ gint width, height;
+ gboolean last_off = FALSE;
+ gint i, j;
if(!GTK_PLOT_GDK(pc)->gc) return;
if(!GTK_PLOT_GDK(pc)->drawable) return;
+ gdk_drawable_get_size (GTK_PLOT_GDK(pc)->drawable, &width, &height);
+
p = (GdkPoint *)g_malloc(numpoints * sizeof(GdkPoint));
+ j = 0;
for(i = 0; i < numpoints; i++){
- p[i].x = roundint(points[i].x);
- p[i].y = roundint(points[i].y);
+ p[j].x = roundint(points[i].x);
+ p[j].y = roundint(points[i].y);
+ if (j > 0 && ! line_on_screen (p[j-1].x, p[j-1].y, p[j].x, p[j].y, width, height)) {
+ if (j > 1) {
+ gdk_draw_lines(GTK_PLOT_GDK(pc)->drawable, GTK_PLOT_GDK(pc)->gc, p, j);
+ }
+ last_off = TRUE;
+ p[0].x = p[j].x;
+ p[0].y = p[j].y;
+ j = 1;
+ continue;
+ } else {
+ last_off = FALSE;
+ }
+
+ j++;
}
- gdk_draw_lines(GTK_PLOT_GDK(pc)->drawable, GTK_PLOT_GDK(pc)->gc, p, numpoints);
+ if ( ! last_off)
+ gdk_draw_lines(GTK_PLOT_GDK(pc)->drawable, GTK_PLOT_GDK(pc)->gc, p, j);
g_free(p);
}
@@ -621,6 +741,7 @@
PangoContext *context = GTK_PLOT_GDK(pc)->context;
GdkDrawable *drawable = GTK_PLOT_GDK(pc)->drawable;
gint sign_x = 1, sign_y = 0;
+ gint old_tx = tx, old_ty = ty;
if(!GTK_PLOT_GDK(pc)->drawable) return;
if(!GTK_PLOT_GDK(pc)->gc) return;
@@ -680,23 +801,31 @@
tx -= descent;
break;
}
+ old_tx = tx;
+ old_ty = ty;
break;
case GTK_JUSTIFY_RIGHT:
switch(angle){
case 0:
tx -= width;
ty -= ascent;
+ old_tx -= width;
+ old_ty -= ascent;
break;
case 90:
tx -= ascent;
ty += height;
+ old_tx -= ascent;
break;
case 180:
tx += width;
ty -= descent;
+ old_ty -= descent;
break;
case 270:
tx -= descent;
+ old_tx -= descent;
+ old_ty -= height;
break;
}
break;
@@ -706,18 +835,26 @@
case 0:
tx -= width / 2.;
ty -= ascent;
+ old_tx -= width / 2.;
+ old_ty -= ascent;
break;
case 90:
tx -= ascent;
ty += height / 2.;
+ old_tx -= ascent;
+ old_ty -= height / 2.;
break;
case 180:
tx += width / 2.;
ty -= descent;
+ old_tx -= width / 2.;
+ old_ty -= descent;
break;
case 270:
tx -= descent;
ty -= height / 2.;
+ old_tx -= descent;
+ old_ty -= height / 2.;
break;
}
}
@@ -733,7 +870,7 @@
if(!transparent){
gdk_gc_set_foreground(gc, &real_bg);
- gdk_draw_rectangle(drawable, gc, TRUE, tx, ty, old_width, old_height);
+ gdk_draw_rectangle(drawable, gc, TRUE, old_tx, old_ty, old_width, old_height);
}
/* TEST */
@@ -950,6 +1087,8 @@
}
}
+ pango_matrix_rotate (&matrix, 0);
+ pango_context_set_matrix (context, &matrix);
pango_font_description_free(font);
if(latin_font) pango_font_description_free(latin_font);
if(metrics) pango_font_metrics_unref(metrics);
@@ -963,18 +1102,18 @@
case GTK_PLOT_BORDER_SHADOW:
gtk_plot_pc_draw_rectangle(pc,
TRUE,
- tx - border_space + shadow_width,
- ty + height + border_space,
+ old_tx - border_space + shadow_width,
+ old_ty + height + border_space,
width + 2 * border_space, shadow_width);
gtk_plot_pc_draw_rectangle(pc,
TRUE,
- tx + width + border_space,
- ty - border_space + shadow_width,
+ old_tx + width + border_space,
+ old_ty - border_space + shadow_width,
shadow_width, height + 2 * border_space);
case GTK_PLOT_BORDER_LINE:
gtk_plot_pc_draw_rectangle(pc,
FALSE,
- tx - border_space, ty - border_space,
+ old_tx - border_space, old_ty - border_space,
width + 2*border_space, height + 2*border_space);
case GTK_PLOT_BORDER_NONE:
default:
Modified: trunk/src/gnome-genius.c
==============================================================================
--- trunk/src/gnome-genius.c (original)
+++ trunk/src/gnome-genius.c Tue Feb 24 07:39:51 2009
@@ -320,7 +320,7 @@
N_("Paste the clipboard"),
G_CALLBACK (paste_callback) },
{ "CopyPlain", GTK_STOCK_COPY,
- N_("Copy Answer As Plain _Text"), "",
+ N_("Copy Answer As Plain Te_xt"), "",
N_("Copy last answer into the clipboard in plain text"),
G_CALLBACK (copy_as_plain) },
{ "CopyLaTeX", GTK_STOCK_COPY,
@@ -376,7 +376,7 @@
N_("Go to the console tab"),
G_CALLBACK (prog_menu_activated) },
{ "Preferences", GTK_STOCK_PREFERENCES,
- N_("Prefere_nces"), "",
+ N_("_Preferences"), "",
N_("Configure Genius"),
G_CALLBACK (setup_calc) },
{ "Contents", GTK_STOCK_HELP,
Modified: trunk/src/graphing.c
==============================================================================
--- trunk/src/graphing.c (original)
+++ trunk/src/graphing.c Tue Feb 24 07:39:51 2009
@@ -1412,6 +1412,8 @@
gtk_plot_set_legends_border (GTK_PLOT (line_plot),
GTK_PLOT_BORDER_LINE, 3);
+ gtk_plot_clip_data (GTK_PLOT (line_plot), TRUE);
+
line_plot_move_about ();
}
@@ -1729,7 +1731,7 @@
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
plot_exporteps_item = item;
- item = gtk_menu_item_new_with_mnemonic (_("_Export PNG..."));
+ item = gtk_menu_item_new_with_mnemonic (_("Export P_NG..."));
g_signal_connect (G_OBJECT (item), "activate",
G_CALLBACK (plot_exportpng_cb), NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
@@ -2962,21 +2964,14 @@
static GtkPlotData *
draw_line (double *x, double *y, int len, int thickness, GdkColor *color)
{
- double *dx, *dy;
GtkPlotData *data;
data = GTK_PLOT_DATA (gtk_plot_data_new ());
- dx = g_new0 (double, len);
- dy = g_new0 (double, len);
- gtk_plot_data_set_points (data, x, y, dx, dy, len);
+ gtk_plot_data_set_points (data, x, y, NULL, NULL, len);
g_object_set_data_full (G_OBJECT (data),
"x", x, (GDestroyNotify)g_free);
g_object_set_data_full (G_OBJECT (data),
"y", y, (GDestroyNotify)g_free);
- g_object_set_data_full (G_OBJECT (data),
- "dx", dx, (GDestroyNotify)g_free);
- g_object_set_data_full (G_OBJECT (data),
- "dy", dy, (GDestroyNotify)g_free);
gtk_plot_add_data (GTK_PLOT (line_plot), data);
gtk_plot_data_hide_legend (data);
@@ -2994,6 +2989,7 @@
return data;
}
+#if 0
static void
clip_line_ends (double xx[], double yy[], int len)
{
@@ -3041,6 +3037,7 @@
}
}
}
+#endif
static void
solution_destroyed (GtkWidget *plotdata, gpointer data)
@@ -3178,7 +3175,7 @@
g_slist_free (points2);
/* Adjust ends */
- clip_line_ends (xx, yy, len);
+ /*clip_line_ends (xx, yy, len);*/
data = draw_line (xx, yy, len, 2 /* thickness */, &color);
solutions_list = g_slist_prepend (solutions_list,
@@ -3492,7 +3489,7 @@
GdkColor color;
char *label;
int len;
- double *x, *y, *dx, *dy;
+ double *x, *y;
double t;
parametric_data = GTK_PLOT_DATA (gtk_plot_data_new ());
@@ -3501,8 +3498,6 @@
len = MAX(ceil (((plott2 - plott1) / plottinc)) + 2,1);
x = g_new0 (double, len);
y = g_new0 (double, len);
- dx = g_new0 (double, len);
- dy = g_new0 (double, len);
t = plott1;
for (i = 0; i < len; i++) {
@@ -3523,15 +3518,11 @@
/* how many actually went */
len = MAX(1,i);
- gtk_plot_data_set_points (parametric_data, x, y, dx, dy, len);
+ gtk_plot_data_set_points (parametric_data, x, y, NULL, NULL, len);
g_object_set_data_full (G_OBJECT (parametric_data),
"x", x, (GDestroyNotify)g_free);
g_object_set_data_full (G_OBJECT (parametric_data),
"y", y, (GDestroyNotify)g_free);
- g_object_set_data_full (G_OBJECT (parametric_data),
- "dx", dx, (GDestroyNotify)g_free);
- g_object_set_data_full (G_OBJECT (parametric_data),
- "dy", dy, (GDestroyNotify)g_free);
gtk_plot_add_data (GTK_PLOT (line_plot), parametric_data);
gtk_widget_show (GTK_WIDGET (parametric_data));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]