1 #ifndef __GROUPSCENE_H__
2 #define __GROUPSCENE_H__
14 class AbstractBoxItem;
23 - A GroupScene is composed of a single GroupItem that contains BlockItem and ConnectionItem
24 The GroupItem is stored in the mainGroup attribute
26 - A GroupScene is instanciated whenever there is a GroupItem that must be created, i.e.
27 for the top scene or for subgroups.
29 - This class is a subclass of QGraphicsScene by convenience but it's goal is more to list
30 the different inner items. Thus, all operations that add/remove items to the scene will also
34 class GroupScene : public QGraphicsScene {
38 /* edition mode of the window:
39 - AddBlock: can only add blocks to the scene
40 - AddConnection: can only add connections to the scene
41 - AddGroup: while a new group (empty or from selected blocks) is created
42 - ItemEdtion: can move/resize blocks/interfaces, remove blocks/interface/group, ...
44 enum EditMode { InitState, AddBlock, AddConnection, AddGroup, ItemEdition };
46 GroupScene(GroupScene* _parentScene, GroupWidget* _window, Dispatcher* _dispatcher, Parameters* _params, bool topScene = false, QObject *parent = 0);
50 inline GroupItem* getGroupItem() {return groupItem;}
51 inline QList<BoxItem*> getBlockItems() { return blockItems; }
52 inline QList<ConnectionItem*> getConnectionItems() { return connectionItems; }
53 inline QList<GroupScene*> getChildrenScene() { return childrenScene; }
54 inline GroupScene* getParentScene() { return parentScene; }
55 inline GroupWidget* getGroupWidget() { return window; }
56 inline int getId() { return id; }
57 inline EditMode getEditionMode() { return editMode; }
58 InterfaceItem* getSelectedInterface(int id);
61 inline void setWindow(GroupWidget* _window) { window = _window; }
62 void setGroupItem(GroupItem* group);
63 inline void setId(int id) { this->id = id; }
64 inline void setEditionMode(EditMode mode) { editMode = mode; }
65 void setSelectedInterface(int id, InterfaceItem* iface);
68 inline bool isTopScene() { return topScene; }
72 BoxItem* createBlockItem(AbstractBlock* block);
73 void addBlockItem(BoxItem* item);
74 void removeBlockItem(BoxItem* item);
75 void createConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2);
76 ConnectionItem* searchConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2);
77 void addConnectionItem(ConnectionItem* item);
78 void removeConnectionItem(ConnectionItem* item);
79 void removeGroupItem();
80 inline void addChildScene(GroupScene* child) { childrenScene.append(child); }
81 inline void removeChildScene(GroupScene* child) { childrenScene.removeAll(child); }
82 inline int getNbChildScene() { return childrenScene.size(); }
83 void unselecteInterfaces();
85 QList<AbstractBoxItem*> getGroupAndBlocks();
86 QList<BoxItem *> getSelectedBlocks();
88 QList<ConnectionItem *> getInterfaceConnections(InterfaceItem *item);
90 int setItemsId(int countInit=1);
91 int setInterfacesId(int countInit=1);
93 void updateConnectionItemsShape();
95 void save(QXmlStreamWriter& writer);
98 Dispatcher *dispatcher;
100 GroupScene* parentScene; // the parent scene, =NULL for top scene
101 GroupWidget* window; // the GroupWindow that contains that scene
103 GroupItem *groupItem; // mandatory to be an instance of GroupItem.
104 QList<ConnectionItem*> connectionItems;
105 QList<BoxItem*> blockItems;
106 QList<GroupScene*> childrenScene;
109 InterfaceItem* selectedInterfaces[2]; // selected iface 1 in AddConnection mode
113 #endif // __GROUPSCENE_H__