2 * TaskScenario.h - TaskJuggler
4 * Copyright (c) 2002 by Chris Schlaeger <cs@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
13 #include "TaskScenario.h"
15 #include "ResourceTreeIterator.h"
19 TaskScenario::TaskScenario() :
40 pathCriticalness(0.0),
41 isOnCriticalPath(false),
42 reportedCompletion(-1.0),
43 containerCompletion(-1.0),
44 completionDegree(0.0),
47 specifiedScheduled(false),
49 startCanBeDetermined(false),
50 endCanBeDetermined(false),
51 specifiedBookedResources(),
54 svgGanttReportIndex(-1)
59 TaskScenario::calcCompletionDegree(time_t now)
63 completionDegree = 100.0;
64 status = reportedCompletion >= 0 && reportedCompletion < 100 ?
67 else if (now <= start)
69 completionDegree = 0.0;
70 status = reportedCompletion > 0 ? InProgressEarly : NotStarted;
77 completionDegree = (100.0 / effort) *
78 task->getLoad(index, Interval(start, now));
80 else if (length > 0.0)
82 completionDegree = (100.0 /
83 task->getProject()->calcWorkingDays(Interval(start, end))) *
84 task->getProject()->calcWorkingDays(Interval(start, now));
87 completionDegree = (100.0 / (end - start + 1)) * (now - start);
89 if (reportedCompletion >= 0.0)
91 if (reportedCompletion < completionDegree)
92 status = InProgressLate;
93 else if (reportedCompletion > completionDegree)
94 status = InProgressEarly;
99 bool TaskScenario::isDutyOf(const Resource* r) const
101 for (ConstResourceTreeIterator rti(r); *rti; ++rti)
102 if (bookedResources.containsRef(*rti) > 0)