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);
82 BoxItem* searchBoxItemByName(QString name);
84 // ConnectionItem related
85 void createConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2, bool visible = true);
86 ConnectionItem* searchConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2);
87 void addConnectionItem(ConnectionItem* item);
88 void removeConnectionItem(ConnectionItem* item);
91 void removeGroupItem();
93 // StimuliItem related
94 StimuliItem* createStimuliItem(AbstractBlock* block); //! create a new SourceItem and place it around the group item
95 void addStimuliItem(StimuliItem* item); //! add an already configured SourceItem in the scene.
96 void removeStimuliItem(StimuliItem* item);
98 // child scenes related
99 inline void addChildScene(GroupScene* child) { childrenScene.append(child); }
100 inline void removeChildScene(GroupScene* child) { childrenScene.removeAll(child); }
101 inline int getNbChildScene() { return childrenScene.size(); }
102 void unselecteInterfaces();
104 QList<BoxItem *> getSelectedBlocks();
106 int setItemsId(int countInit=1);
107 int setInterfacesId(int countInit=1);
109 void updateConnectionItemsShape();
111 void save(QXmlStreamWriter& writer);
114 Dispatcher *dispatcher;
116 GroupScene* parentScene; // the parent scene, =NULL for top scene
117 GroupWidget* window; // the GroupWindow that contains that scene
119 GroupItem *groupItem; //! for convenience, the group item is directly accessible via this attribute
120 QList<ConnectionItem*> connectionItems; //! for convenience, connections are directly accessible via this attribute
121 QList<BoxItem*> boxItems; //! for convenience, box items are directly accessible via this attribute
122 QList<StimuliItem*> stimuliItems; //! for convenience, box items are directly accessible via this attribute. Only usefull for top scene
123 QList<GroupScene*> childrenScene;//! for convenience, children scenes are directly accessible via this attribute
126 InterfaceItem* selectedInterfaces[2]; // selected iface 1 in AddConnection mode
130 #endif // __GROUPSCENE_H__