kplato

kptcanvasitem.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 - 2004 Dag Andersen <danders@get2net.dk>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation;
7 version 2 of the License.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KPTCANVASITEM_H
21#define KPTCANVASITEM_H
22
23#include "kptnode.h"
24#include "KDGanttView.h"
25#include "KDGanttViewItem.h"
26#include "KDGanttViewSummaryItem.h"
27#include "KDGanttViewTaskItem.h"
28#include "KDGanttViewEventItem.h"
29
30#include <tqcanvas.h>
31#include <tqrect.h>
32
33class TQPainter;
34
35namespace KPlato
36{
37
38class Task;
39class Relation;
40class PertCanvas;
41class PertRelationItem;
42class PertNodeItem;
43class GanttView;
44
45class PertNodeItem : public TQCanvasPolygon
46{
47private:
48 class PertNodeRelation
49 {
50 public:
51 PertNodeRelation(Relation *r, PertNodeItem *n) { relation = r; childItem = n; }
52 ~PertNodeRelation() {}
53 Relation *relation;
54 PertNodeItem * childItem;
55 };
56
57public:
58 PertNodeItem( PertCanvas *view, Node &node, int row, int col );
59 virtual ~PertNodeItem();
60
61 virtual int rtti() const;
62 static int RTTI;
63
64 void setVisible(bool yes);
65 void move(PertCanvas *view, int row, int col);
66
67 TQPoint exitPoint(Relation::Type type) const;
68 TQPoint entryPoint(Relation::Type type) const;
69
70 Node &node() const { return m_node; }
71
72 TQRect rect() const { return TQRect(m_left, m_right); }
73 void setRow(int row) { m_row = row; }
74 int row() const { return m_row; }
75 void setColumn(int col) { m_col = col; }
76 int column() const { return m_col; }
77 int x() const { return m_x; }
78 int x(int col) const { return m_wgap + col*(m_width+m_wgap); }
79 int y() const { return m_y; }
80 int y(int row) const { return m_hgap + row*(m_height+m_hgap); }
81 int width() const { return m_width; }
82 int height() const { return m_height; }
83
84 void addChildRelation(Relation *relation, PertNodeItem *node)
85 { m_childRelations.append(new PertNodeRelation(relation, node)); }
86
87 bool hasParent() { return m_node.numDependParentNodes(); }
88 bool hasChild() { return m_node.numDependChildNodes(); }
89
90protected:
91 void drawShape(TQPainter & p);
92
93 int m_wgap;
94 int m_hgap;
95 int m_width;
96 int m_height;
97 int m_x;
98 int m_y;
99
100 TQPtrList<PertNodeRelation> m_childRelations;
101
102private:
103 Node &m_node;
104 int m_row, m_col;
105 TQPoint m_right; // Entry/exit point
106 TQPoint m_left; // Entry/exit point
107 TQCanvasText *m_name;
108 TQCanvasText *m_leader;
109
110#ifndef NDEBUG
111 void printDebug( int );
112#endif
113
114};
115
116class PertProjectItem : public PertNodeItem
117{
118public:
119 PertProjectItem( PertCanvas *view, Node &node, int row=-1, int col=-1 );
120 virtual ~PertProjectItem();
121
122 virtual int rtti() const;
123 static int RTTI;
124
125#ifndef NDEBUG
126 void printDebug( int );
127#endif
128
129};
130
131class PertTaskItem : public PertNodeItem
132{
133public:
134 PertTaskItem( PertCanvas *view, Node &node, int row=-1, int col=-1 );
135 virtual ~PertTaskItem();
136
137 virtual int rtti() const;
138 static int RTTI;
139
140#ifndef NDEBUG
141 void printDebug( int );
142#endif
143
144};
145
146class PertMilestoneItem : public PertNodeItem
147{
148public:
149 PertMilestoneItem( PertCanvas *view, Node &node, int row=-1, int col=-1 );
150 virtual ~PertMilestoneItem();
151
152 virtual int rtti() const;
153 static int RTTI;
154
155 void draw();
156
157#ifndef NDEBUG
158 void printDebug( int );
159#endif
160
161};
162
164
165class PertRelationItem : public TQCanvasPolygon
166{
167public:
168 PertRelationItem(PertCanvas *view, PertNodeItem *parent, PertNodeItem *child, Relation *rel);
169 virtual ~PertRelationItem();
170
171 virtual int rtti() const;
172 static int RTTI;
173
174 Relation::Type type() { return m_rel->type(); }
175 void draw();
176
177 void setFinishStartPoints();
178 void setFinishFinishPoints();
179 void setStartStartPoints();
180 TQPointArray areaPoints() const;
181
182 bool rowFree(int row, int startCol, int endCol);
183
184protected:
185 void drawShape(TQPainter &p);
186
187private:
188 PertCanvas *m_view;
189 Relation *m_rel;
190 PertNodeItem *m_parentItem;
191 PertNodeItem *m_childItem;
192 int left, top, right, bottom;
193
194 int parentTop;
195 int parentBottom;
196 int childTop;
197
198 int childRow;
199 int childCol;
200 int parentRow;
201 int parentCol;
202
203 int wgap;
204 int hgap;
205
206
207#ifndef NDEBUG
208 void printDebug( int );
209#endif
210
211};
212
213class ItemBase
214{
215protected:
216 KDGanttViewTaskLink::LinkType kdLinkType(int relationType);
217};
218
219
221
222class GanttViewSummaryItem : public KDGanttViewSummaryItem, public ItemBase
223{
224public:
225 GanttViewSummaryItem(KDGanttView *parent, Node *node);
226 GanttViewSummaryItem(KDGanttViewItem *parent, Node *node);
227
228 Node *getNode() { return m_node; }
229 void insertRelations(GanttView *view);
230 KDGanttViewItem *find(Node *node);
231 KDGanttViewItem *find(KDGanttViewItem *item, Node *node);
232 KDGanttView *ganttView() const { return m_view; }
233 bool isDrawn() const { return m_drawn; }
234 void setDrawn(bool drawn) { m_drawn = drawn; }
235
236protected:
237 Node *m_node; // can be Project or Task
238 KDGanttView *m_view;
239 bool m_drawn;
240};
241
243
244class GanttViewTaskItem : public KDGanttViewTaskItem, public ItemBase
245{
246public:
247 GanttViewTaskItem(KDGanttView *parent, KPlato::Task *task);
248 GanttViewTaskItem(KDGanttViewItem *parent, KPlato::Task *task);
249
250 KPlato::Task *getTask() const { return m_task; }
251 void insertRelations(GanttView *view);
252 KDGanttViewItem *find(Node *node);
253 KDGanttViewItem *find(KDGanttViewItem *item, Node *node);
254 KDGanttView *ganttView() const { return m_view; }
255 bool isDrawn() const { return m_drawn; }
256 void setDrawn(bool drawn) { m_drawn = drawn; }
257
258protected:
259 KPlato::Task *m_task;
260 KDGanttView *m_view;
261 bool m_drawn;
262};
263
265
266class GanttViewEventItem : public KDGanttViewEventItem, public ItemBase
267{
268public:
269 GanttViewEventItem(KDGanttView *parent, KPlato::Task *task);
270 GanttViewEventItem(KDGanttViewItem *parent, KPlato::Task *task);
271
272 KPlato::Task *getTask() { return m_task; }
273 void insertRelations(GanttView *view);
274 KDGanttViewItem *find(Node *node);
275 KDGanttViewItem *find(KDGanttViewItem *item, Node *node);
276 KDGanttView *ganttView() const { return m_view; }
277 bool isDrawn() const { return m_drawn; }
278 void setDrawn(bool drawn) { m_drawn = drawn; }
279
280protected:
281 KPlato::Task *m_task;
282 KDGanttView *m_view;
283 bool m_drawn;
284};
285
286} //KPlato namespace
287
288#endif
A task in the scheduling software is represented by this class.
Definition kpttask.h:40