1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
/***************************************************************************
* Copyright (C) 2003-2005 by David Saxton *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef CANVASITEMGROUP_H
#define CANVASITEMGROUP_H
#include "itemgroup.h"
class CNItem;
class Item;
class ICNDocument;
class Component;
class Connector;
class FlowPart;
class Node;
class ECNode;
class FPNode;
class ICNDocument;
class TQCanvasItem;
class TQCanvasItemList;
typedef TQValueList<TQGuardedPtr<Item> > ItemList;
typedef TQValueList<TQGuardedPtr<Node> > NodeList;
typedef TQValueList<TQGuardedPtr<Connector> > ConnectorList;
/**
@author David Saxton
*/
class CNItemGroup : public ItemGroup
{
TQ_OBJECT
public:
CNItemGroup( ICNDocument *icnDocument, const char *name = 0 );
~CNItemGroup();
/**
* Adds a CNItem to the group, if it is not already in it, or other items at
* a lower levels are already in the group. If there are items are a high level,
* those items are removed first. Returns false on failure to add.
*/
bool addItem( Item *item );
/**
* Adds a Node to the group, if it is not already in it. Note: This node
* will *NOT* be added if it is a child node, and the function will return false.
* If the node is not already present, and is added, then this will return true.
*/
bool addNode( Node *node );
/**
* Adds a Connector to the group, if it is not already in it (if it is, returns false)
*/
bool addConnector( Connector *con );
/**
* If the item is a a CNItem, Node or Connector, returns the status
* for that particular add function, else returns false
*/
virtual bool addTQCanvasItem( TQCanvasItem *qcanvasItem );
/**
* Sets the contained items to those in this list
*/
virtual void setItems( TQCanvasItemList list );
/**
* Removes the CNItem from the group
*/
void removeItem( Item *item );
/**
* Removes the Node from the group
*/
void removeNode( Node *node );
/**
* Removes the Connector from the group
*/
void removeConnector( Connector *con );
/**
* If the item is a a CNItem, Node or Connector, then attempts to remove it
*/
virtual void removeTQCanvasItem( TQCanvasItem *qcanvasItem );
/**
* Returns true if the TQCanvasItem passed is contained in the group
*/
virtual bool contains( TQCanvasItem *qcanvasItem ) const;
/**
* Returns the number of Nodes in the CanvasGroup
*/
uint nodeCount() const { return m_nodeCount; }
/**
* Returns the number of Connectors in the CanvasGroup
*/
uint connectorCount() const { return m_connectorCount; }
/**
* Returns the total number of items in the group
* (CNItems, Nodes, Connectors)
*/
uint count() const { return itemCount()+m_nodeCount+m_connectorCount; }
/**
* Sets the selected state of all items in the group
*/
virtual void setSelected( bool sel );
/**
* Sets the orientation (degrees component) of all items in the group
*/
void setOrientationAngle( int angleDegrees );
/**
* Sets the orientation (flipped component) of all items in the group
*/
void setOrientationFlipped( bool flipped );
/**
* Sets the orientation of all flowparts in the group
*/
void setFlowPartOrientation( unsigned orientation );
/**
* Sets the orientation (degrees and flipped) of all components in the group
*/
void setComponentOrientation( int angleDegrees, bool flipped );
/**
* Merges all items in the given group with this group
*/
virtual void mergeGroup( ItemGroup *group );
/**
* Removes all items from this group (doesn't delete them)
* @param unselect whether to unselect the items or not. This will be done after removal from group
*/
virtual void removeAllItems();
/**
* Attempts to delete everything in the group.
* Note: You *must* call ICNDocument::flushDeleteList() after calling this function,
* as this function only tells the items to remove themselves
*/
virtual void deleteAllItems();
/**
* Returns a list of all the Nodes in the group.
* @param excludeParented if false, then nodes that are fully contained
* within item children will also be returned.
*/
NodeList nodes( bool excludeParented = true ) const;
/**
* Returns a list of all the Connectors in the group.
* @param excludeParented if false, then connectors that are fully contained
* within item children will also be returned.
*/
ConnectorList connectors( bool excludeParented = true ) const;
/**
* Returns a list of the ids of all the CNItems in the group.
*/
TQStringList itemIDs();
/**
* Returns true if at least some of the CNItems in this group can be
* rotated. Returns false if no items present.
*/
bool canRotate() const;
/**
* Returns true if at least some of the CNItems in this group can be
* flipped. Returns false if no items present.
*/
bool canFlip() const;
public slots:
/**
* Sets the orientation of all selected items to 0 degrees.
*/
void slotSetOrientation0() { setOrientationAngle(0); }
/**
* Sets the orientation of all selected items to 90 degrees.
*/
void slotSetOrientation90() { setOrientationAngle(90); }
/**
* Sets the orientation of all selected items to 180 degrees.
*/
void slotSetOrientation180() { setOrientationAngle(180); }
/**
* Sets the orientation of all selected items to 270 (actually -90) degrees.
*/
void slotSetOrientation270() { setOrientationAngle(-90); }
/**
* Rotates all CNItems in the group clockwise
*/
void slotRotateCW();
/**
* Rotates all CNItems in the group counter-clockwise
*/
void slotRotateCCW();
/**
* Flips all CNItems in the group
*/
void slotFlip();
signals:
void connectorAdded( Connector *con );
void connectorRemoved( Connector *con );
void nodeAdded( Node *node );
void nodeRemoved( Node *node );
protected:
void updateInfo();
void getActiveItem();
void setActiveItem( Item *item );
private:
ICNDocument *p_icnDocument;
ConnectorList m_connectorList;
NodeList m_nodeList;
uint m_connectorCount;
uint m_nodeCount;
int m_currentLevel; // We can only accept CNItems of one level
};
#endif
|