1 #ifndef __GROUPSCENE_H__
2 #define __GROUPSCENE_H__
16 class AbstractBoxItem;
25 - A GroupScene is composed of a single GroupItem that contains BlockItem and ConnectionItem
26 The GroupItem is stored in the mainGroup attribute
28 - A GroupScene is instanciated whenever there is a GroupItem that must be created, i.e.
29 for the top scene or for subgroups.
31 - This class is a subclass of QGraphicsScene by convenience but it's goal is more to list
32 the different inner items. Thus, all operations that add/remove items to the scene will also
36 class GroupScene : public QGraphicsScene {
40 /* edition mode of the window:
41 - AddBlock: can only add blocks to the scene
42 - AddConnection: can only add connections to the scene
43 - AddGroup: while a new group (empty or from selected blocks) is created
44 - ItemEdtion: can move/resize blocks/interfaces, remove blocks/interface/group, ...
46 enum EditMode { InitState, AddConnection, ItemEdition };
49 GroupScene(GroupScene* _parentScene, GroupWidget* _window, Dispatcher* _dispatcher, Parameters* _params, bool topScene = false, QObject *parent = 0);
52 //void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
55 inline GroupItem* getGroupItem() {return groupItem;}
56 inline QList<BoxItem*> getBoxItems() { return boxItems; }
57 inline QList<StimuliItem*> getSourceItems() { return stimuliItems; }
58 inline QList<ConnectionItem*> getConnectionItems() { return connectionItems; }
59 inline QList<GroupScene*> getChildrenScene() { return childrenScene; }
60 inline GroupScene* getParentScene() { return parentScene; }
61 inline GroupWidget* getGroupWidget() { return window; }
62 inline int getId() { return id; }
63 inline EditMode getEditionMode() { return editMode; }
64 InterfaceItem* getSelectedInterface(int id);
67 inline void setWindow(GroupWidget* _window) { window = _window; }
68 void setGroupItem(GroupItem* group);
69 inline void setId(int id) { this->id = id; }
70 inline void setEditionMode(EditMode mode) { editMode = mode; }
71 void setSelectedInterface(int id, InterfaceItem* iface);
74 inline bool isTopScene() { return topScene; }
79 BoxItem* createBoxItem(AbstractBlock* block, BoxItem::Position position = BoxItem::Free, int lock = AbstractBoxItem::NoLock, BoxItem::SpanType span = BoxItem::NoSpan); //! create a new BoxItem and place it at the center of the scene
80 void addBoxItem(BoxItem* item); //! add an already configured BoxItem in the scene.
81 void removeBoxItem(BoxItem* item);
83 // ConnectionItem related
84 void createConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2, bool visible = true);
85 ConnectionItem* searchConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2);
86 void addConnectionItem(ConnectionItem* item);
87 void removeConnectionItem(ConnectionItem* item);
90 void removeGroupItem();
92 // StimuliItem related
93 StimuliItem* createStimuliItem(AbstractBlock* block); //! create a new SourceItem and place it around the group item
94 void addStimuliItem(StimuliItem* item); //! add an already configured SourceItem in the scene.
95 void removeStimuliItem(StimuliItem* item);
97 // child scenes related
98 inline void addChildScene(GroupScene* child) { childrenScene.append(child); }
99 inline void removeChildScene(GroupScene* child) { childrenScene.removeAll(child); }
100 inline int getNbChildScene() { return childrenScene.size(); }
101 void unselecteInterfaces();
103 QList<BoxItem *> getSelectedBlocks();
105 int setItemsId(int countInit=1);
106 int setInterfacesId(int countInit=1);
108 void updateConnectionItemsShape();
110 void save(QXmlStreamWriter& writer);
113 Dispatcher *dispatcher;
115 GroupScene* parentScene; // the parent scene, =NULL for top scene
116 GroupWidget* window; // the GroupWindow that contains that scene
118 GroupItem *groupItem; //! for convenience, the group item is directly accessible via this attribute
119 QList<ConnectionItem*> connectionItems; //! for convenience, connections are directly accessible via this attribute
120 QList<BoxItem*> boxItems; //! for convenience, box items are directly accessible via this attribute
121 QList<StimuliItem*> stimuliItems; //! for convenience, box items are directly accessible via this attribute. Only usefull for top scene
122 QList<GroupScene*> childrenScene;//! for convenience, children scenes are directly accessible via this attribute
125 InterfaceItem* selectedInterfaces[2]; // selected iface 1 in AddConnection mode
129 #endif // __GROUPSCENE_H__