Re: [Planner Dev] Task Predecessors



Richard,

The attached patch has all of the style breeches fixed(I hope). Let me know if 
there is something else that I need to do to get this patch through.

Thanks

Corey

On Monday 05 April 2004 01:53, Richard Hult wrote:
> On mån, 2004-04-05 at 08:07 +1000, Corey Schuhen wrote:
> > Hi again all,
> > 
> > Thanks again Lincoln for the testing and "mentoring" I read the comments 
in 
> > the doco about giving cvs diff the "-u", unfortunately "cvs diff" is one 
of 
> > those lines that I type subconsciously. Sorry about that Richard.
> 
> No problem. I keep a few such cvs options in ~/.cvsrc, so I don't need
> to type them manually, which helps:
> 
> # more ~/.cvsrc
> cvs -z3
> diff -uBbp
> update -dP
> checkout -P
> 
> > The alternative is to implement a bunch functions calls, signals, slots in 
> > parallel to the ones that get called when a relation is added or removed. 
> > This would add functionality to "change" a relation type. While this seems 
> > slightly architecturally "cleaner" to me, it is a bunch more work and 
would 
> > just increase complexity to about 5 interfaces. i.e. the KISS principle 
> > opposes this. 
> 
> We usually try to do the "right thing" right away, but sometimes when it
> is too much work, it might be a good idea to just get the code working
> with the appropriate "FIXME: " comments added. Possibly also adding a
> bug with more comments. In this case it's not clear which would be best,
> so I think we should just go with your way.
> 
> I have a few small comments about the patch that would be good to get
> fixed before committing, only style related.
> 
> We put spaces before "(" and "{" etc, like:
> 
> foo (bar);
> 
> and 
> 
> } else {
> 
> We also prefer to do this with "else if" statements:
> 
> if (foo) {
>   bar;
> }
> else if (baz) { /* else if on a new line */
>   ...
> }
> 
> 
> It would be great if you could address this and then we could get this
> committed, will be a very nice addition :)
> 
> Thanks a lot!
> Richard
> 

-- 

--
Corey Schuhen
corey_m schuhen net
http://schuhen.net
? .pred_types_update2.diff.swp
? .pred_types_update3.diff.swp
? cppcomplete.tags
? gantt_chart.jpg
? pred_types_update.diff
? pred_types_update2.diff
? pred_types_update3.diff
? dotnet/Makefile
? dotnet/Makefile.in
? dotnet/libplanner/Makefile
? dotnet/libplanner/Makefile.in
? dotnet/samples/Makefile
? dotnet/samples/Makefile.in
? libplanner/cppcomplete.tags
? libplanner/make_other_dep_types_work.patch
? src/cppcomplete.tags
Index: libplanner/mrp-task-manager.c
===================================================================
RCS file: /cvs/gnome/planner/libplanner/mrp-task-manager.c,v
retrieving revision 1.1.1.1
diff -u -B -b -p -r1.1.1.1 mrp-task-manager.c
--- libplanner/mrp-task-manager.c	1 Dec 2003 17:36:21 -0000	1.1.1.1
+++ libplanner/mrp-task-manager.c	5 Apr 2004 20:23:49 -0000
@@ -854,6 +854,45 @@ task_manager_sort_tree (MrpTaskManager *
 	/*dump_task_tree (root);*/
 }
 
+/* Calcluate the earliest start time that a particular predesessor relation 
+ * allows given:
+ * 
+ */
+mrptime
+task_manager_calc_relation (MrpTask	*task,
+			    MrpRelation	*relation,
+			    MrpTask	*predecessor)
+{
+	/* Compute the earliest start time that this particular dependancy 
+	 * would allow */
+	switch (mrp_relation_get_relation_type (relation)) {
+	            
+		case MRP_RELATION_FF:   /* finish-to-finish */
+			return mrp_task_get_finish (predecessor) +
+				mrp_relation_get_lag (relation) -
+				(mrp_task_get_finish (task) -
+				mrp_task_get_start (task));
+                  
+		case MRP_RELATION_SS:   /* start-to-start */
+			return mrp_task_get_start (predecessor) +
+				mrp_relation_get_lag (relation);
+           
+		case MRP_RELATION_SF:   /* start-to-finish */
+			return mrp_task_get_start (predecessor) +
+				mrp_relation_get_lag (relation) -
+				(mrp_task_get_finish (task) -
+				mrp_task_get_start (task) );
+                    
+		case MRP_RELATION_NONE: /* unset */
+		case MRP_RELATION_FS:   /* finish-to-start */
+		default:
+			return mrp_task_get_finish (predecessor) +
+				mrp_relation_get_lag (relation);
+	}
+
+
+}
+
 /* Calculate the start time of the task by finding the latest finish of it's
  * predecessors (plus any lag). Also take constraints into consideration.
  */
@@ -868,7 +907,7 @@ task_manager_calculate_task_start (MrpTa
 	MrpTask            *predecessor;
 	mrptime             project_start;
 	mrptime             start;
-	mrptime             finish;
+	mrptime             dep_start_time;
 	MrpConstraint       constraint;
 
 	priv = manager->priv;
@@ -883,10 +922,12 @@ task_manager_calculate_task_start (MrpTa
 			relation = l->data;
 			predecessor = mrp_relation_get_predecessor (relation);
 
-			finish = mrp_task_get_finish (predecessor) +
-				mrp_relation_get_lag (relation);
+			dep_start_time 
+				= task_manager_calc_relation (task,
+							      relation,
+							      predecessor);
 			
-			start = MAX (start, finish);
+			start = MAX (start, dep_start_time);
 		}
 		tmp_task = mrp_task_get_parent (tmp_task);
 	}
Index: src/planner-gantt-chart.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-gantt-chart.c,v
retrieving revision 1.4
diff -u -B -b -p -r1.4 planner-gantt-chart.c
--- src/planner-gantt-chart.c	14 Mar 2004 23:28:00 -0000	1.4
+++ src/planner-gantt-chart.c	5 Apr 2004 20:23:54 -0000
@@ -172,7 +172,8 @@ static TreeNode *  gantt_chart_insert_ta
 static PlannerRelationArrow *
 gantt_chart_add_relation                                (PlannerGanttChart       *chart,
 							 TreeNode           *task,
-							 TreeNode           *predecessor);
+							 TreeNode           *predecessor,
+							 MrpRelationType    type);
 static void        gantt_chart_set_scroll_region        (PlannerGanttChart       *chart,
 							 gdouble             x1,
 							 gdouble             y1,
@@ -786,6 +787,7 @@ gantt_chart_build_relations (PlannerGant
 	TreeNode         *predecessor_node;
 	GList            *relations, *l;
 	PlannerRelationArrow  *arrow;
+	MrpRelationType	      rel_type;
 
 	priv = chart->priv;
 	
@@ -802,7 +804,12 @@ gantt_chart_build_relations (PlannerGant
 			task_node = g_hash_table_lookup (hash, task);
 			predecessor_node = g_hash_table_lookup (hash, predecessor);
 
-			arrow = gantt_chart_add_relation (chart, task_node, predecessor_node);
+			rel_type = mrp_relation_get_relation_type(relation);
+
+			arrow = gantt_chart_add_relation (chart, 
+							  task_node, 
+							  predecessor_node, 
+							  rel_type);
 
 			g_hash_table_insert (priv->relation_hash, relation, arrow);
 		}
@@ -1034,10 +1041,12 @@ gantt_chart_insert_task (PlannerGanttCha
 static PlannerRelationArrow *
 gantt_chart_add_relation (PlannerGanttChart *chart,
 			  TreeNode     *task,
-			  TreeNode     *predecessor)
+			  TreeNode     		*predecessor,
+			  MrpRelationType 	type)
 {
 	return planner_relation_arrow_new (PLANNER_GANTT_ROW (task->item),
-				      PLANNER_GANTT_ROW (predecessor->item));
+				      PLANNER_GANTT_ROW (predecessor->item),
+				      type);
 }
 
 static void
@@ -1161,6 +1170,7 @@ gantt_chart_relation_added (MrpTask     
 	TreeNode        *predecessor_node;
 	PlannerRelationArrow *arrow;
 	MrpTask         *predecessor;
+	MrpRelationType	 rel_type;
 
 	predecessor = mrp_relation_get_predecessor (relation);
 	
@@ -1180,9 +1190,12 @@ gantt_chart_relation_added (MrpTask     
 	predecessor_node = gantt_chart_tree_node_at_path (chart->priv->tree,
 							  predecessor_path);
 	
+	rel_type = mrp_relation_get_relation_type(relation);
+	
 	arrow = gantt_chart_add_relation (chart,
 					  task_node,
-					  predecessor_node);
+					  predecessor_node,
+					  rel_type);
 
 	g_hash_table_insert (chart->priv->relation_hash, relation, arrow);
 }
Index: src/planner-relation-arrow.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-relation-arrow.c,v
retrieving revision 1.2
diff -u -B -b -p -r1.2 planner-relation-arrow.c
--- src/planner-relation-arrow.c	11 Dec 2003 10:52:46 -0000	1.2
+++ src/planner-relation-arrow.c	5 Apr 2004 20:23:56 -0000
@@ -36,6 +36,38 @@
 
 /*
 
+SS:
+
+  1:      A 
+  	 +--XXXXXX
+       B | 
+	 +---XXXXX
+          C
+	  
+FF:
+
+  1:               A 
+  	   XXXXXX----+
+	             | B
+	     XXXXX---+
+		   C
+		   
+SF:
+
+  1:                       A (we have a maximum value for A)
+  	   		 +------XXXXXX
+	               B |
+		     XXXXX
+
+
+  2:	          A (max value)  
+     	         +-XXXXXX
+	       B |        C
+	 	 +---------------+
+	  		         |D
+	 		   XXXXX-+
+          		        E (max value)
+
 FS:
 
   1:               A (we have a minimum value for A)
@@ -53,8 +85,6 @@ FS:
           E (min value)
 
 
-TODO: Implement other types, remove the arguments from the geometry-changed signal.
-	 
 */
 
 
@@ -251,8 +281,10 @@ relation_arrow_update_line_segments (Pla
 	gdouble              px1, py1, px2, py2;
 	gdouble              sx1, sy1, sx2, sy2;
 	gdouble              y;
+	MrpRelationType type;
 
 	priv = arrow->priv;
+	type = priv->type;
 
 	planner_gantt_row_get_geometry (priv->predecessor,
 				   &px1,
@@ -265,7 +297,108 @@ relation_arrow_update_line_segments (Pla
 				   &sy1,
 				   &sx2,
 				   &sy2);
+	if (type == MRP_RELATION_SS) {
+		priv->num_points = 4;
+		priv->arrow_dir = PLANNER_ARROW_RIGHT;
+
+		/* LHS of pred */
+		priv->points[0].x = px1;
+		priv->points[0].y = py1 + (py2 - py1) / 2;
+
+		/* Next two, a bit left of the most left */
+		if (sx1 < px1) {
+			priv->points[1].x = sx1 - MIN_SPACING - ARROW_SIZE;
+			priv->points[1].y = py1 + (py2 - py1) / 2;
+			priv->points[2].x = sx1 - MIN_SPACING - ARROW_SIZE;
+			priv->points[2].y = sy1 + (sy2 - sy1) / 2;
+		} else {
+			priv->points[1].x = px1 - MIN_SPACING - ARROW_SIZE;
+			priv->points[1].y = py1 + (py2 - py1) / 2;
+			priv->points[2].x = px1 - MIN_SPACING - ARROW_SIZE;
+			priv->points[2].y = sy1 + (sy2 - sy1) / 2;
+		}
+		
+		priv->points[3].x = sx1;
+		priv->points[3].y = sy1 + (sy2 - sy1) / 2;
+		
+	}
+	else if (type == MRP_RELATION_FF) {
+		
+		priv->num_points = 4;
+		priv->arrow_dir = PLANNER_ARROW_LEFT;
+
+		/* LHS of pred */
+		priv->points[0].x = px2;
+		priv->points[0].y = py1 + (py2 - py1) / 2;
+
+		/* Next two, a bit left of the most left */
+		if (sx2 > px2) {
+			priv->points[1].x = sx2 + MIN_SPACING + ARROW_SIZE;
+			priv->points[1].y = py1 + (py2 - py1) / 2;
+			priv->points[2].x = sx2 + MIN_SPACING + ARROW_SIZE;
+			priv->points[2].y = sy1 + (sy2 - sy1) / 2;
+		} else {
+			priv->points[1].x = px2 + MIN_SPACING + ARROW_SIZE;
+			priv->points[1].y = py1 + (py2 - py1) / 2;
+			priv->points[2].x = px2 + MIN_SPACING + ARROW_SIZE;
+			priv->points[2].y = sy1 + (sy2 - sy1) / 2;
+		}
+		
+		priv->points[3].x = sx2;
+		priv->points[3].y = sy1 + (sy2 - sy1) / 2;
+	}
+	else if (type == MRP_RELATION_SF) {
+		/* Two cases for SF, as shown at the top of this file. */
+		if (px1 >= sx2) {
+			priv->num_points = 3;
+	
+			priv->points[0].x = px1;
+			priv->points[0].y = py1 + (py2 - py1) / 2;
 
+			priv->points[1].x = MIN (px1 - MIN_SPACING, sx2);
+			priv->points[1].y = py1 + (py2 - py1) / 2;
+	
+			priv->points[2].x = MIN (px1 - MIN_SPACING, sx2);
+			if (sy1 > py1) {
+				priv->points[2].y = sy1;
+				priv->arrow_dir = PLANNER_ARROW_DOWN;
+			} else {
+				priv->points[2].y = sy2;
+				priv->arrow_dir = PLANNER_ARROW_UP;
+			}
+	
+			
+		} else {
+			priv->num_points = 6;
+			priv->arrow_dir = PLANNER_ARROW_LEFT;
+	
+			priv->points[0].x = px1;
+			priv->points[0].y = py1 + (py2 - py1) / 2;
+	
+			priv->points[1].x = px1 - MIN_SPACING;
+			priv->points[1].y = py1 + (py2 - py1) / 2;
+	
+	 		if (sy1 > py1) {
+				y = py2 + (py2 - py1) / 2 - 1;
+			} else {
+				y = py1 - (py2 - py1) / 2 + 2;
+			}
+			
+			priv->points[2].x = px1 - MIN_SPACING;
+			priv->points[2].y = y;
+	
+			priv->points[3].x = sx2 + ARROW_SIZE + MIN_SPACING;
+			priv->points[3].y = y;
+			
+			priv->points[4].x = sx2 + ARROW_SIZE + MIN_SPACING;
+			priv->points[4].y = sy1 + (sy2 - sy1) / 2;
+	
+			priv->points[5].x = sx2;
+			priv->points[5].y = sy1 + (sy2 - sy1) / 2;
+		}
+	
+	
+	} else {
 	/* Two cases for FS, as shown at the top of this file. */
 	if (px2 <= sx1) {
 		priv->num_points = 3;
@@ -284,6 +417,8 @@ relation_arrow_update_line_segments (Pla
 			priv->points[2].y = sy2;
 			priv->arrow_dir = PLANNER_ARROW_UP;
 		}
+	
+			
 	} else {
 		priv->num_points = 6;
 		priv->arrow_dir = PLANNER_ARROW_RIGHT;
@@ -312,6 +447,7 @@ relation_arrow_update_line_segments (Pla
 		priv->points[5].x = sx1;
 		priv->points[5].y = sy1 + (sy2 - sy1) / 2;
 	}
+	}
 
 	gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (arrow));
 }
@@ -431,7 +567,7 @@ planner_relation_arrow_set_successor (Pl
 }
 
 PlannerRelationArrow *
-planner_relation_arrow_new (PlannerGanttRow *successor, PlannerGanttRow *predecessor)
+planner_relation_arrow_new (PlannerGanttRow *successor, PlannerGanttRow *predecessor, MrpRelationType type)
 {
 	PlannerRelationArrow   *arrow;
 	GnomeCanvasGroup  *root;
@@ -445,7 +581,7 @@ planner_relation_arrow_new (PlannerGantt
 	
 	planner_relation_arrow_set_successor (arrow, successor);
 	planner_relation_arrow_set_predecessor (arrow, predecessor);
-	
+	arrow->priv->type = type;
 	return arrow;
 }
 
Index: src/planner-relation-arrow.h
===================================================================
RCS file: /cvs/gnome/planner/src/planner-relation-arrow.h,v
retrieving revision 1.2
diff -u -B -b -p -r1.2 planner-relation-arrow.h
--- src/planner-relation-arrow.h	11 Dec 2003 10:52:46 -0000	1.2
+++ src/planner-relation-arrow.h	5 Apr 2004 20:23:56 -0000
@@ -52,7 +52,8 @@ struct _PlannerRelationArrowClass {
 GType            planner_relation_arrow_get_type (void) G_GNUC_CONST;
 
 PlannerRelationArrow *planner_relation_arrow_new      (PlannerGanttRow *successor,
-					     PlannerGanttRow *predecessor);
+					     PlannerGanttRow *predecessor,
+					     MrpRelationType type);
 void
 planner_relation_arrow_set_successor             (PlannerRelationArrow *arrow,
 					     PlannerGanttRow      *successor);
Index: src/planner-task-dialog.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-task-dialog.c,v
retrieving revision 1.4
diff -u -B -b -p -r1.4 planner-task-dialog.c
--- src/planner-task-dialog.c	27 Mar 2004 08:18:23 -0000	1.4
+++ src/planner-task-dialog.c	5 Apr 2004 20:24:00 -0000
@@ -988,13 +988,48 @@ task_dialog_pred_cell_edited (GtkCellRen
 	case PREDECESSOR_COL_TYPE:
 		planner_cell = PLANNER_CELL_RENDERER_LIST (cell);
 
+		{	
+			GError *error = NULL;
+			mrp_task_remove_predecessor (task_main, task_pred);
+
+			if (!mrp_task_add_predecessor (task_main,
+						       task_pred,
+						       planner_cell->selected_index + 1,
+						       lag,
+						       &error)) {
+				GtkWidget *dialog;
+				
+				dialog = gtk_message_dialog_new (
+					NULL,
+					GTK_DIALOG_DESTROY_WITH_PARENT,
+					GTK_MESSAGE_ERROR,
+					GTK_BUTTONS_OK,
+					"%s", error->message);
+
+				gtk_dialog_run (GTK_DIALOG (dialog));
+				gtk_widget_destroy (dialog);
+				
+				g_error_free (error);
+
+				/* Restore the previous state. */
+				mrp_task_add_predecessor (task_main,
+							  task_pred, 
+							  type,
+							  lag,
+							  NULL);
+			}
+		}
 		/* The index + 1 happens to be the same as the enum,
 		 * we should probably do this some other way.
 		 */
+		
+		relation = mrp_task_get_relation (task_main, task_pred);
 		mrp_object_set (relation,
 				"type",
 				planner_cell->selected_index + 1,
 				NULL);
+				
+
 		break;
 
 	case PREDECESSOR_COL_LAG:


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