1 #ifndef __DISPATCHER_H__
2 #define __DISPATCHER_H__
15 class AbstractBoxItem;
22 class FunctionalBlock;
23 #include "Exception.h"
32 * \brief The Dispatcher class
33 * The Dispatcher class represents the control part (in MVC) of the application. It relays
34 * user's interactions with the GUI into model's modifications and feeds back them onto the view.
40 * \brief The Context enum
41 * Some methods are called while creating a design from scratch or when loading
42 * a desgin from a project file previously saved. Thus, their behavior may change
43 * according to the situation. Context is used to specifiy the situation.
44 * Must be always specified.
46 enum Context {AnyContext = 0, Design = 1, Load = 2 };
48 Dispatcher(Parameters* _params,
51 GroupWidget* loadProject(const QString& filename);
55 bool isCurrentProject;
57 /**************************
59 *************************/
61 GroupScene* getSceneById(int id);
62 GroupScene* getSceneByName(QString name);
63 BoxItem* getBoxItemById(int id);
64 GroupItem* getGroupItemById(int id);
65 InterfaceItem* getInterfaceItemById(int id);
66 inline GroupWidget* getCurrentGroup() { return currentGroupWidget; }
67 inline int getNumberOfScenes() { return groupList.length(); }
69 void showRaiseWindow(Context context, BoxItem *item);
70 void showRstClkIface(Context context, AbstractBoxItem *item);
71 void showWishboneIface(Context context, AbstractBoxItem *item);
72 void unselectAllItems(Context context, int direction=0);
73 void setCurrentGroupWidget(Context context, GroupWidget *win);
74 void changeConnectionMode(Context context, int mode = -1);
75 void setSceneCounter(Context context, int value);
78 GroupWidget* createTopScene(Context context);
79 GroupWidget* createChildScene(Context context, GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL);
80 void destroyScene(Context context, GroupScene* scene);
81 GroupWidget *addNewEmptyGroup(Context context, GroupScene *scene, bool show = true);
82 void addNewFullGroup(Context context);
84 /**************************
86 *************************/
88 QMap<int, QString> getAllGroupNames();
92 void generateVHDL(Context context) throw(Exception);
94 /**************************
96 *************************/
97 BoxItem* addBlock(Context context, int idCategory, int idBlock, int idScene);
98 void removeBoxItem(Context context, BoxItem* item);
99 void duplicateBoxItem(Context context, BoxItem* item);
100 void renameFunctionalBlock(Context context, BoxItem* item);
101 void generateBlockVHDL(Context context, BoxItem* item);
102 void renameGroupBlock(Context context, GroupItem* item);
103 void renameSourceBlock(Context context, SourceItem* item);
104 void removeSourceItem(Context context, SourceItem* item);
105 void duplicateSourceItem(Context context, SourceItem* item);
110 * \brief connectInterToGroup
111 * \param item item is always owned by a BoxItem
113 * This method is called only when the user right clicks on an InterfaceItem (that belongs
114 * to a BoxItem and if it is NOT connected to an InterfaceItem of the GroupItem) and chooses
115 * connect to group in the contextual menu.
116 * Thus, parameter item is always owned by a BoxItem
118 void connectInterToGroup(Context context, InterfaceItem* item);
120 * \brief removeFunctionalInterface
121 * \param item item is always owned by a BoxItem
123 * This method is called only when the user right clicks on an InterfaceItem (that belongs
124 * to a BoxItem that represents a functional block and has a multiplicity > 1) and chooses remove in the contextual menu.
125 * Thus, parameter item is always owned by a BoxItem
127 void removeFunctionalInterface(Context context, InterfaceItem* item);
129 * \brief removeGroupInterface
130 * \param item item is always owned by a GroupItem
132 * This method is called only when the user right clicks on an InterfaceItem (that belongs
133 * to a GroupItem and if it is connected only to an inner interface) and chooses remove in the contextual menu.
134 * Thus, parameter item is always owned by a GroupItem
136 void removeGroupInterface(Context context, InterfaceItem* item);
137 void duplicateInterfaceItem(Context context, InterfaceItem* item);
138 void showProperties(Context context, InterfaceItem *inter);
139 void renameInterface(Context context, InterfaceItem* item);
140 void showPatterns(Context context, InterfaceItem* item);
141 void showModifier(Context context, InterfaceItem* item);
142 void removeModifier(Context context, InterfaceItem* item);
145 bool createConnection(Context context, InterfaceItem *iface1, InterfaceItem *iface2, bool visible = true);
146 void removeAllBlockConnections(Context context, AbstractBoxItem *item);
147 void removeConnection(Context context, ConnectionItem *conn);
151 void findGraphModifications(Context context, FunctionalBlock* block); // find modif so that block has compatible inputs
154 void showBlocksLibrary();
157 void closeCurrentProject();
164 // attributes that corresponds to the views
165 MainWindow* mainWindow;
166 QList<GroupWidget*> groupList;
167 GroupWidget* currentGroupWidget;
168 GroupWidget *topGroupWidget;
170 static int sceneCounter;
173 #endif // __DISPATCHER_H__