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, QHash<QString,int> clkRstToGen );
98 void addClkRstGenBlock(Context context, double frequency);
99 void removeBoxItem(Context context, BoxItem* item);
100 void duplicateBoxItem(Context context, BoxItem* item);
101 void renameFunctionalBlock(Context context, BoxItem* item);
102 void generateBlockVHDL(Context context, BoxItem* item);
103 void renameGroupBlock(Context context, GroupItem* item);
104 void renameSourceBlock(Context context, SourceItem* item);
105 void removeSourceItem(Context context, SourceItem* item);
106 void duplicateSourceItem(Context context, SourceItem* item);
111 * \brief connectInterToGroup
112 * \param item item is always owned by a BoxItem
114 * This method is called only when the user right clicks on an InterfaceItem (that belongs
115 * to a BoxItem and if it is NOT connected to an InterfaceItem of the GroupItem) and chooses
116 * connect to group in the contextual menu.
117 * Thus, parameter item is always owned by a BoxItem
119 void connectInterToGroup(Context context, InterfaceItem* item);
121 * \brief removeFunctionalInterface
122 * \param item item is always owned by a BoxItem
124 * This method is called only when the user right clicks on an InterfaceItem (that belongs
125 * to a BoxItem that represents a functional block and has a multiplicity > 1) and chooses remove in the contextual menu.
126 * Thus, parameter item is always owned by a BoxItem
128 void removeFunctionalInterface(Context context, InterfaceItem* item);
130 * \brief removeGroupInterface
131 * \param item item is always owned by a GroupItem
133 * This method is called only when the user right clicks on an InterfaceItem (that belongs
134 * to a GroupItem and if it is connected only to an inner interface) and chooses remove in the contextual menu.
135 * Thus, parameter item is always owned by a GroupItem
137 void removeGroupInterface(Context context, InterfaceItem* item);
138 void duplicateInterfaceItem(Context context, InterfaceItem* item);
139 void showProperties(Context context, InterfaceItem *inter);
140 void renameInterface(Context context, InterfaceItem* item);
141 void showPatterns(Context context, InterfaceItem* item);
142 void showModifier(Context context, InterfaceItem* item);
143 void removeModifier(Context context, InterfaceItem* item);
146 bool createConnection(Context context, InterfaceItem *iface1, InterfaceItem *iface2, bool visible = true);
147 void removeAllBlockConnections(Context context, AbstractBoxItem *item);
148 void removeConnection(Context context, ConnectionItem *conn);
152 void findGraphModifications(Context context, FunctionalBlock* block); // find modif so that block has compatible inputs
155 void showBlocksLibrary();
158 void closeCurrentProject();
165 // attributes that corresponds to the views
166 MainWindow* mainWindow;
167 QList<GroupWidget*> groupList;
168 GroupWidget* currentGroupWidget;
169 GroupWidget *topGroupWidget;
171 static int sceneCounter;
174 #endif // __DISPATCHER_H__