1 #ifndef __GROUPSCENE_H__
2 #define __GROUPSCENE_H__
15 class AbstractBoxItem;
24 - A GroupScene is composed of a single GroupItem that contains BlockItem and ConnectionItem
25 The GroupItem is stored in the mainGroup attribute
27 - A GroupScene is instanciated whenever there is a GroupItem that must be created, i.e.
28 for the top scene or for subgroups.
30 - This class is a subclass of QGraphicsScene by convenience but it's goal is more to list
31 the different inner items. Thus, all operations that add/remove items to the scene will also
35 class GroupScene : public QGraphicsScene {
39 /* edition mode of the window:
40 - AddBlock: can only add blocks to the scene
41 - AddConnection: can only add connections to the scene
42 - AddGroup: while a new group (empty or from selected blocks) is created
43 - ItemEdtion: can move/resize blocks/interfaces, remove blocks/interface/group, ...
45 enum EditMode { InitState, AddBlock, AddConnection, AddGroup, ItemEdition };
47 GroupScene(GroupScene* _parentScene, GroupWidget* _window, Dispatcher* _dispatcher, Parameters* _params, bool topScene = false, QObject *parent = 0);
51 inline GroupItem* getGroupItem() {return groupItem;}
52 inline QList<BoxItem*> getBoxItems() { return boxItems; }
53 inline QList<ConnectionItem*> getConnectionItems() { return connectionItems; }
54 inline QList<GroupScene*> getChildrenScene() { return childrenScene; }
55 inline GroupScene* getParentScene() { return parentScene; }
56 inline GroupWidget* getGroupWidget() { return window; }
57 inline int getId() { return id; }
58 inline EditMode getEditionMode() { return editMode; }
59 InterfaceItem* getSelectedInterface(int id);
62 inline void setWindow(GroupWidget* _window) { window = _window; }
63 void setGroupItem(GroupItem* group);
64 inline void setId(int id) { this->id = id; }
65 inline void setEditionMode(EditMode mode) { editMode = mode; }
66 void setSelectedInterface(int id, InterfaceItem* iface);
69 inline bool isTopScene() { return topScene; }
74 BoxItem* createBoxItem(AbstractBlock* block); //! create a new BoxItem and place it at the center of the scene
75 void addBoxItem(BoxItem* item); //! add an already configured BoxItem in the scene.
76 void removeBoxItem(BoxItem* item);
78 // ConnectionItem related
79 void createConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2, bool withinGroup = true);
80 ConnectionItem* searchConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2);
81 void addConnectionItem(ConnectionItem* item);
82 void removeConnectionItem(ConnectionItem* item);
85 void removeGroupItem();
88 SourceItem* createSourceItem(AbstractBlock* block); //! create a new SourceItem and place it around the group item
89 void addSourceItem(SourceItem* item); //! add an already configured SourceItem in the scene.
90 void removeSourceItem(SourceItem* item);
92 // child scenes related
93 inline void addChildScene(GroupScene* child) { childrenScene.append(child); }
94 inline void removeChildScene(GroupScene* child) { childrenScene.removeAll(child); }
95 inline int getNbChildScene() { return childrenScene.size(); }
96 void unselecteInterfaces();
98 QList<BoxItem *> getSelectedBlocks();
100 int setItemsId(int countInit=1);
101 int setInterfacesId(int countInit=1);
103 void updateConnectionItemsShape();
105 void save(QXmlStreamWriter& writer);
108 Dispatcher *dispatcher;
110 GroupScene* parentScene; // the parent scene, =NULL for top scene
111 GroupWidget* window; // the GroupWindow that contains that scene
113 GroupItem *groupItem; //! for convenience, the group item is directly accessible via this attribute
114 QList<ConnectionItem*> connectionItems; //! for convenience, connections are directly accessible via this attribute
115 QList<BoxItem*> boxItems; //! for convenience, box items are directly accessible via this attribute
116 QList<SourceItem*> sourceItems; //! for convenience, box items are directly accessible via this attribute. Only usefull for top scene
117 QList<GroupScene*> childrenScene;//! for convenience, children scenes are directly accessible via this attribute
120 InterfaceItem* selectedInterfaces[2]; // selected iface 1 in AddConnection mode
124 #endif // __GROUPSCENE_H__