[goffice] 2009-06-25 Jean Brefort <jean brefort normalesup org>



commit 9278f9c1bff8ee320fa03745314340cd1279bb87
Author: Jean Brefort <jean acer fbx proxad net>
Date:   Thu Jun 25 13:05:19 2009 +0200

    2009-06-25  Jean Brefort  <jean brefort normalesup org>
    
    	* goffice/graph/gog-axis-line.c (axis_line_render), (x_process),
    	(xy_process), (radar_process), (xyz_process): set 3d ticks at the
    	correct position. [#585298]
    	* goffice/graph/gog-chart.c: reversed fix to #152675.
    	* goffice/graph/gog-graph.c (gog_graph_class_init): ditto.

 ChangeLog                     |    8 ++++
 NEWS                          |    3 ++
 goffice/graph/gog-axis-line.c |   75 +++++++++++++++++++++++++++++++++--------
 goffice/graph/gog-chart.c     |   26 +++++++-------
 goffice/graph/gog-graph.c     |    4 +-
 5 files changed, 87 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 773e1c9..f6b2cff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-06-25  Jean Brefort  <jean brefort normalesup org>
+
+	* goffice/graph/gog-axis-line.c (axis_line_render), (x_process),
+	(xy_process), (radar_process), (xyz_process): set 3d ticks at the
+	correct position. [#585298]
+	* goffice/graph/gog-chart.c: reversed fix to #152675.
+	* goffice/graph/gog-graph.c (gog_graph_class_init): ditto.
+
 2009-06-24  Andreas J. Guelzow  <aguelzow pyrshep ca>
 
 	* goffice/utils/go-format.c 
diff --git a/NEWS b/NEWS
index 2ac4620..6f1a361 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ Andreas:
 	* Improve number style output to ODF. [#586564]
 	* Improve currency output to ODF.
 
+Jean:
+	* Align surface ticks with grid. [#585298]
+
 Morten:
 	* Fix format localization problem. [#586567]
 
diff --git a/goffice/graph/gog-axis-line.c b/goffice/graph/gog-axis-line.c
index 2987dc8..3f72cae 100644
--- a/goffice/graph/gog-axis-line.c
+++ b/goffice/graph/gog-axis-line.c
@@ -1091,7 +1091,8 @@ axis_line_render (GogAxisBase *axis_base,
 		  GOGeometrySide side,
 		  double start_at,
 		  gboolean draw_labels,
-		  gboolean sharp)
+		  gboolean sharp,
+		  double *ticks_pos)
 {
 	GogAxisMap *map = NULL;
 	GogAxisTick *ticks;
@@ -1179,9 +1180,14 @@ axis_line_render (GogAxisBase *axis_base,
 		if (gog_axis_map (map, ticks[i].position) < start_at)
 			continue;
 
-		pos = gog_axis_map_to_view (map, ticks[i].position);
-		pos_x = x + pos * cos (axis_angle);
-		pos_y = y + pos * sin (axis_angle);
+		if (ticks_pos) {
+			pos_x = ticks_pos[2 * i];
+			pos_y = ticks_pos[2 * i + 1];
+		} else {
+			pos = gog_axis_map_to_view (map, ticks[i].position);
+			pos_x = x + pos * cos (axis_angle);
+			pos_y = y + pos * sin (axis_angle);
+		}
 
 		if (is_line_visible) {
 			switch (ticks[i].type) {
@@ -1210,12 +1216,17 @@ axis_line_render (GogAxisBase *axis_base,
 
 		if (ticks[i].label != NULL && draw_labels) {
 			GOGeometryOBR *obr = obrs + i;
-			pos = gog_axis_map_to_view (map, ticks[i].position);
 			obr->w += label_padding;
 			go_geometry_calc_label_position (obr, axis_angle, tick_len,
 							 side, label_anchor);
-			obr->x += x + pos * cos (axis_angle);
-			obr->y += y + pos * sin (axis_angle);
+			if (ticks_pos) {
+				obr->x += ticks_pos[2 * i];
+				obr->y += ticks_pos[2 * i + 1];
+			} else {
+				pos = gog_axis_map_to_view (map, ticks[i].position);
+				obr->x += x + pos * cos (axis_angle);
+				obr->y += y + pos * sin (axis_angle);
+			}
 
 			indexmap[nobr] = i;
 			nobr++;
@@ -1505,7 +1516,7 @@ x_process (GogAxisBaseAction action, GogView *view, GogViewPadding *padding,
 			axis_line_render (axis_base, axis_base_view,
 					  view->renderer, ax, ay, bx - ax , by - ay, 
 					  GO_SIDE_RIGHT, -1.,
-					  axis_base->major_tick_labeled, TRUE);
+					  axis_base->major_tick_labeled, TRUE, NULL);
 			break;
 
 		case GOG_AXIS_BASE_PADDING_REQUEST:
@@ -1601,7 +1612,7 @@ xy_process (GogAxisBaseAction action, GogView *view, GogViewPadding *padding,
 			axis_line_render (axis_base, axis_base_view,
 					  view->renderer, 
 					  ax, ay, bx - ax , by - ay, side, -1.,
-					  axis_base->major_tick_labeled, TRUE);
+					  axis_base->major_tick_labeled, TRUE, NULL);
 			break;
 
 		case GOG_AXIS_BASE_PADDING_REQUEST:
@@ -1681,7 +1692,7 @@ radar_process (GogAxisBaseAction action, GogView *view, GogViewPadding *padding,
 								  parms->cx, parms->cy,
 								  bx - parms->cx, by - parms->cy,
 								  side, 0.1, i == parms->th0 && axis_base->major_tick_labeled,
-								  FALSE);
+								  FALSE, NULL);
 					} else {
 					       	gog_chart_map_2D_to_view (c_map, position, stop, &bx, &by);
 						axis_line_render (axis_base, axis_base_view,
@@ -1689,7 +1700,7 @@ radar_process (GogAxisBaseAction action, GogView *view, GogViewPadding *padding,
 								  parms->cx, parms->cy,
 								  bx - parms->cx, by - parms->cy,
 								  side, 0., axis_base->major_tick_labeled,
-								  FALSE);
+								  FALSE, NULL);
 					}
 				break;
 			case GOG_AXIS_BASE_PADDING_REQUEST:
@@ -1782,6 +1793,7 @@ xyz_process (GogAxisBaseAction action, GogView *view, GogViewPadding *padding,
 	double rx[8], ry[8], rz[8];
 	double major_tick_len, minor_tick_len, tick_len;
 	double label_w, label_h;
+	double *ticks_pos = NULL;
 
 	/* Note: Anti-clockwise order in each face,
 	 * important for calculating normals */
@@ -1907,6 +1919,17 @@ xyz_process (GogAxisBaseAction action, GogView *view, GogViewPadding *padding,
 		                          &ax, &ay, NULL);
 		gog_chart_map_3d_to_view (c_map, xposition, yposition, stop,
 		                          &bx, &by, NULL);
+		if (action == GOG_AXIS_BASE_RENDER) {
+			tick_nbr = gog_axis_get_ticks (axis_base->axis, &ticks);
+			ticks_pos = g_new (double, 2 * tick_nbr);
+			for (i = 0; i < tick_nbr; i++)
+				gog_chart_map_3d_to_view (c_map, xposition,
+							  yposition,
+							  ticks[i].position,
+							  ticks_pos + 2 * i, 
+							  ticks_pos + 2 * i + 1,
+							  NULL);
+		}
 	} else if (axis_type == GOG_AXIS_X) {
 		yposition = *py[faces[base + vertex]];
 		zposition = *pz[faces[base + vertex]];
@@ -1917,6 +1940,18 @@ xyz_process (GogAxisBaseAction action, GogView *view, GogViewPadding *padding,
 		                          &ax, &ay, NULL);
 		gog_chart_map_3d_to_view (c_map, stop, yposition, zposition,
 		                          &bx, &by, NULL);
+		if (action == GOG_AXIS_BASE_RENDER) {
+			tick_nbr = gog_axis_get_ticks (axis_base->axis, &ticks);
+			ticks_pos = g_new (double, 2 * tick_nbr);
+			for (i = 0; i < tick_nbr; i++) {
+				gog_chart_map_3d_to_view (c_map,
+							  ticks[i].position,
+							  yposition, zposition,
+							  ticks_pos + 2 * i, 
+							  ticks_pos + 2 * i + 1,
+							  NULL);
+			}
+		}
 	} else {
 		zposition = *pz[faces[base + vertex]];
 		xposition = *px[faces[base + vertex]];
@@ -1927,6 +1962,17 @@ xyz_process (GogAxisBaseAction action, GogView *view, GogViewPadding *padding,
 		                          &ax, &ay, NULL);
 		gog_chart_map_3d_to_view (c_map, xposition, stop, zposition,
 		                          &bx, &by, NULL);
+		if (action == GOG_AXIS_BASE_RENDER) {
+			tick_nbr = gog_axis_get_ticks (axis_base->axis, &ticks);
+			ticks_pos = g_new (double, 2 * tick_nbr);
+			for (i = 0; i < tick_nbr; i++)
+				gog_chart_map_3d_to_view (c_map, xposition,
+							  ticks[i].position,
+							  zposition,
+							  ticks_pos + 2 * i, 
+							  ticks_pos + 2 * i + 1,
+							  NULL);
+		}
 	}
 
 	if (axis_type == perp_axis) {
@@ -1945,14 +1991,13 @@ xyz_process (GogAxisBaseAction action, GogView *view, GogViewPadding *padding,
 	}
 	side = (tmp > 0)? GO_SIDE_LEFT : GO_SIDE_RIGHT;
 
-	gog_chart_map_3d_free (c_map);
-
 	switch (action) {
 		case GOG_AXIS_BASE_RENDER:
 			axis_line_render (axis_base, axis_base_view,
 					  view->renderer, 
 					  ax, ay, bx - ax , by - ay, side, -1.,
-					  axis_base->major_tick_labeled, TRUE);
+					  axis_base->major_tick_labeled, TRUE,
+					  ticks_pos);
 			break;
 		case GOG_AXIS_BASE_PADDING_REQUEST:
 			axis_line_bbox = axis_line_get_bbox (axis_base,
@@ -2026,6 +2071,8 @@ xyz_process (GogAxisBaseAction action, GogView *view, GogViewPadding *padding,
 			break;
 	}
 
+	gog_chart_map_3d_free (c_map);
+
 	return FALSE;
 }
 
diff --git a/goffice/graph/gog-chart.c b/goffice/graph/gog-chart.c
index d3a55fb..0a54a44 100644
--- a/goffice/graph/gog-chart.c
+++ b/goffice/graph/gog-chart.c
@@ -394,42 +394,42 @@ static gboolean role_3d_box_can_add	(GogObject const *parent) {return FALSE;}
 static gboolean role_3d_box_can_remove	(GogObject const *parent) {return FALSE;}
 
 static GogObjectRole const roles[] = {
-	{ N_("Backplane"), "GogGrid",	1,
+	{ N_("Backplane"), "GogGrid",	0,
 	  GOG_POSITION_SPECIAL, GOG_POSITION_SPECIAL, GOG_OBJECT_NAME_BY_ROLE,
 	  role_grid_can_add, NULL, NULL, role_grid_post_add, role_grid_pre_remove, NULL, { -1 } },
-	{ N_("XY-Backplane"), "GogGrid",	1,
+	{ N_("XY-Backplane"), "GogGrid",	0,
 	  GOG_POSITION_SPECIAL, GOG_POSITION_SPECIAL, GOG_OBJECT_NAME_BY_ROLE,
 	  xy_grid_3d_can_add, NULL, NULL, xy_grid_3d_post_add, NULL, NULL,
 	  { GOG_GRID_XY } },
-	{ N_("YZ-Backplane"), "GogGrid",	1,
+	{ N_("YZ-Backplane"), "GogGrid",	0,
 	  GOG_POSITION_SPECIAL, GOG_POSITION_SPECIAL, GOG_OBJECT_NAME_BY_ROLE,
 	  yz_grid_3d_can_add, NULL, NULL, yz_grid_3d_post_add, NULL, NULL,
 	  { GOG_GRID_YZ } },
-	{ N_("ZX-Backplane"), "GogGrid",	1,
+	{ N_("ZX-Backplane"), "GogGrid",	0,
 	  GOG_POSITION_SPECIAL, GOG_POSITION_SPECIAL, GOG_OBJECT_NAME_BY_ROLE,
 	  zx_grid_3d_can_add, NULL, NULL, zx_grid_3d_post_add, NULL, NULL,
 	  { GOG_GRID_ZX } },
-	{ N_("X-Axis"), "GogAxis",	2,
+	{ N_("X-Axis"), "GogAxis",	1,
 	  GOG_POSITION_PADDING, GOG_POSITION_PADDING, GOG_OBJECT_NAME_BY_ROLE,
 	  x_axis_can_add, axis_can_remove, NULL, x_axis_post_add, axis_pre_remove, NULL,
 	  { GOG_AXIS_X } },
-	{ N_("Y-Axis"), "GogAxis",	3,
+	{ N_("Y-Axis"), "GogAxis",	2,
 	  GOG_POSITION_PADDING, GOG_POSITION_PADDING, GOG_OBJECT_NAME_BY_ROLE,
 	  y_axis_can_add, axis_can_remove, NULL, y_axis_post_add, axis_pre_remove, NULL,
 	  { GOG_AXIS_Y } },
-	{ N_("Z-Axis"), "GogAxis",	4,
+	{ N_("Z-Axis"), "GogAxis",	3,
 	  GOG_POSITION_PADDING, GOG_POSITION_PADDING, GOG_OBJECT_NAME_BY_ROLE,
 	  z_axis_can_add, axis_can_remove, NULL, z_axis_post_add, axis_pre_remove, NULL,
 	  { GOG_AXIS_Z } },
-	{ N_("Circular-Axis"), "GogAxis", 2,
+	{ N_("Circular-Axis"), "GogAxis", 1,
 	  GOG_POSITION_PADDING, GOG_POSITION_PADDING, GOG_OBJECT_NAME_BY_ROLE,
 	  circular_axis_can_add, axis_can_remove, NULL, circular_axis_post_add, axis_pre_remove, NULL,
 	  { GOG_AXIS_CIRCULAR } },
-	{ N_("Radial-Axis"), "GogAxis",	3,
+	{ N_("Radial-Axis"), "GogAxis",	2,
 	  GOG_POSITION_PADDING, GOG_POSITION_PADDING, GOG_OBJECT_NAME_BY_ROLE,
 	  radial_axis_can_add, axis_can_remove, NULL, radial_axis_post_add, axis_pre_remove, NULL,
 	  { GOG_AXIS_RADIAL } },
-	{ N_("Pseudo-3D-Axis"), "GogAxis", 4,
+	{ N_("Pseudo-3D-Axis"), "GogAxis", 3,
 	  GOG_POSITION_SPECIAL, GOG_POSITION_SPECIAL, GOG_OBJECT_NAME_BY_ROLE,
 	  pseudo_3d_axis_can_add, axis_can_remove, NULL, pseudo_3d_axis_post_add, axis_pre_remove, NULL,
 	  { GOG_AXIS_PSEUDO_3D } },
@@ -437,14 +437,14 @@ static GogObjectRole const roles[] = {
 	  GOG_POSITION_SPECIAL, GOG_POSITION_SPECIAL, GOG_OBJECT_NAME_BY_ROLE,
 	  bubble_axis_can_add, axis_can_remove, NULL, bubble_axis_post_add, axis_pre_remove, NULL,
 	  { GOG_AXIS_BUBBLE } },
-	{ N_("Color-Axis"), "GogAxis", 4,
+	{ N_("Color-Axis"), "GogAxis", 5,
 	  GOG_POSITION_SPECIAL, GOG_POSITION_SPECIAL, GOG_OBJECT_NAME_BY_ROLE,
 	  color_axis_can_add, axis_can_remove, NULL, color_axis_post_add, axis_pre_remove, NULL,
 	  { GOG_AXIS_COLOR } },
 	{ N_("Plot"), "GogPlot",	6,	/* keep the axis before the plots */
 	  GOG_POSITION_SPECIAL, GOG_POSITION_SPECIAL, GOG_OBJECT_NAME_BY_TYPE,
 	  NULL, NULL, NULL, role_plot_post_add, role_plot_pre_remove, NULL, { -1 } },
-	{ N_("Title"), "GogLabel",	0,
+	{ N_("Title"), "GogLabel",	10,
 	  GOG_POSITION_COMPASS|GOG_POSITION_ANY_MANUAL, 
 	  GOG_POSITION_N|GOG_POSITION_ALIGN_CENTER, 
 	  GOG_OBJECT_NAME_BY_ROLE,
@@ -461,7 +461,7 @@ static GogObjectRole const roles[] = {
 	  GOG_OBJECT_NAME_BY_ROLE,
 	  NULL, NULL, NULL, NULL, NULL, NULL, { -1 } },
 #endif
-	{ N_("3D-Box"), "Gog3DBox",	1,
+	{ N_("3D-Box"), "Gog3DBox",	0,
 	  GOG_POSITION_SPECIAL, GOG_POSITION_SPECIAL, GOG_OBJECT_NAME_BY_ROLE,
 	  role_3d_box_can_add, role_3d_box_can_remove, NULL, NULL, NULL, NULL, { -1 } }
 };
diff --git a/goffice/graph/gog-graph.c b/goffice/graph/gog-graph.c
index 4d1dcae..bd789e2 100644
--- a/goffice/graph/gog-graph.c
+++ b/goffice/graph/gog-graph.c
@@ -279,12 +279,12 @@ gog_graph_class_init (GogGraphClass *klass)
 	GogObjectClass *gog_klass = (GogObjectClass *) klass;
 
 	static GogObjectRole const roles[] = {
-		{ N_("Chart"), "GogChart",	1,
+		{ N_("Chart"), "GogChart",	0,
 		  GOG_POSITION_SPECIAL|GOG_POSITION_ANY_MANUAL, 
 		  GOG_POSITION_SPECIAL, 
 		  GOG_OBJECT_NAME_BY_ROLE,
 		  NULL, NULL, NULL, role_chart_post_add, role_chart_pre_remove, NULL },
-		{ N_("Title"), "GogLabel",	0,
+		{ N_("Title"), "GogLabel",	1,
 		  GOG_POSITION_COMPASS|GOG_POSITION_ANY_MANUAL, 
 		  GOG_POSITION_N|GOG_POSITION_ALIGN_CENTER, 
 		  GOG_OBJECT_NAME_BY_ROLE,



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