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, AddConnection, ItemEdition };
47 GroupScene(GroupScene* _parentScene, GroupWidget* _window, Dispatcher* _dispatcher, Parameters* _params, bool topScene = false, QObject *parent = 0);
50 //void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
53 inline GroupItem* getGroupItem() {return groupItem;}
54 inline QList<BoxItem*> getBoxItems() { return boxItems; }
55 inline QList<SourceItem*> getSourceItems() { return sourceItems; }
56 inline QList<ConnectionItem*> getConnectionItems() { return connectionItems; }
57 inline QList<GroupScene*> getChildrenScene() { return childrenScene; }
58 inline GroupScene* getParentScene() { return parentScene; }
59 inline GroupWidget* getGroupWidget() { return window; }
60 inline int getId() { return id; }
61 inline EditMode getEditionMode() { return editMode; }
62 InterfaceItem* getSelectedInterface(int id);
65 inline void setWindow(GroupWidget* _window) { window = _window; }
66 void setGroupItem(GroupItem* group);
67 inline void setId(int id) { this->id = id; }
68 inline void setEditionMode(EditMode mode) { editMode = mode; }
69 void setSelectedInterface(int id, InterfaceItem* iface);
72 inline bool isTopScene() { return topScene; }
77 BoxItem* createBoxItem(AbstractBlock* block); //! create a new BoxItem and place it at the center of the scene
78 void addBoxItem(BoxItem* item); //! add an already configured BoxItem in the scene.
79 void removeBoxItem(BoxItem* item);
81 // ConnectionItem related
82 void createConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2);
83 ConnectionItem* searchConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2);
84 void addConnectionItem(ConnectionItem* item);
85 void removeConnectionItem(ConnectionItem* item);
88 void removeGroupItem();
91 SourceItem* createSourceItem(AbstractBlock* block); //! create a new SourceItem and place it around the group item
92 void addSourceItem(SourceItem* item); //! add an already configured SourceItem in the scene.
93 void removeSourceItem(SourceItem* item);
95 // child scenes related
96 inline void addChildScene(GroupScene* child) { childrenScene.append(child); }
97 inline void removeChildScene(GroupScene* child) { childrenScene.removeAll(child); }
98 inline int getNbChildScene() { return childrenScene.size(); }
99 void unselecteInterfaces();
101 QList<BoxItem *> getSelectedBlocks();
103 int setItemsId(int countInit=1);
104 int setInterfacesId(int countInit=1);
106 void updateConnectionItemsShape();
108 void save(QXmlStreamWriter& writer);
111 Dispatcher *dispatcher;
113 GroupScene* parentScene; // the parent scene, =NULL for top scene
114 GroupWidget* window; // the GroupWindow that contains that scene
116 GroupItem *groupItem; //! for convenience, the group item is directly accessible via this attribute
117 QList<ConnectionItem*> connectionItems; //! for convenience, connections are directly accessible via this attribute
118 QList<BoxItem*> boxItems; //! for convenience, box items are directly accessible via this attribute
119 QList<SourceItem*> sourceItems; //! for convenience, box items are directly accessible via this attribute. Only usefull for top scene
120 QList<GroupScene*> childrenScene;//! for convenience, children scenes are directly accessible via this attribute
123 InterfaceItem* selectedInterfaces[2]; // selected iface 1 in AddConnection mode
127 #endif // __GROUPSCENE_H__