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 GroupWidget* getGroupWindow() { return window; }
55 inline int getId() { return id; }
56 inline EditMode getEditionMode() { return editMode; }
57 InterfaceItem* getSelectedInterface(int id);
60 inline void setWindow(GroupWidget* _window) { window = _window; }
61 void setGroupItem(GroupItem* group);
62 inline void setId(int id) { this->id = id; }
63 inline void setEditionMode(EditMode mode) { editMode = mode; }
64 void setSelectedInterface(int id, InterfaceItem* iface);
67 inline bool isTopScene() { return topScene; }
71 BoxItem* createBlockItem(AbstractBlock* block);
72 void addBlockItem(BoxItem* item);
73 void removeBlockItem(BoxItem* item);
74 void createConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2);
75 ConnectionItem* searchConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2);
76 void addConnectionItem(ConnectionItem* item);
77 void removeConnectionItem(ConnectionItem* item);
78 void removeGroupItem();
79 inline void addChildScene(GroupScene* child) { childrenScene.append(child); }
80 void unselecteInterfaces();
82 QList<AbstractBoxItem*> getGroupAndBlocks();
83 QList<BoxItem *> getSelectedBlocks();
85 QList<ConnectionItem *> getInterfaceConnections(InterfaceItem *item);
87 int setItemsId(int countInit=1);
88 int setInterfacesId(int countInit=1);
90 void updateConnectionItemsShape();
92 void save(QXmlStreamWriter& writer);
95 Dispatcher *dispatcher;
97 GroupScene* parentScene; // the parnet scene, =NULL for top scene
98 GroupWidget* window; // the GroupWindow that contains that scene
100 GroupItem *groupItem; // mandatory to be an instance of GroupItem.
101 QList<ConnectionItem*> connectionItems;
102 QList<BoxItem*> blockItems;
103 QList<GroupScene*> childrenScene;
106 InterfaceItem* selectedInterfaces[2]; // selected iface 1 in AddConnection mode
110 #endif // __GROUPSCENE_H__