X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/abbc64cf04a35ab3549d5c516f44c7c5921baa63..3bcfe4df6fdde086eb1b59f7a0173358170174a1:/Dispatcher.h diff --git a/Dispatcher.h b/Dispatcher.h index 4475518..0fa74bd 100644 --- a/Dispatcher.h +++ b/Dispatcher.h @@ -15,62 +15,145 @@ class GroupScene; class AbstractBoxItem; class GroupItem; class BoxItem; +class SourceItem; class ConnectionItem; class InterfaceItem; +class GroupBlock; +class FunctionalBlock; +#include "Exception.h" +class Exception; using namespace std; using namespace Qt; +/*! + * \brief The Dispatcher class + * The Dispatcher class represents the control part (in MVC) of the application. It relays + * user's interactions with the GUI into model's modifications and feeds back them onto the view. + */ class Dispatcher { public: + /*! + * \brief The Context enum + * Some methods are called while creating a design from scratch or when loading + * a desgin from a project file previously saved. Thus, their behavior may change + * according to the situation. Context is used to specifiy the situation. + * Must be always specified. + */ + enum Context {AnyContext = 0, Design = 1, Load = 2 }; + Dispatcher(Parameters* _params, MainWindow* _window); GroupWidget* loadProject(const QString& filename); - inline int getNumberOfScenes() { return groupList.length(); } - bool connect(InterfaceItem *iface1, InterfaceItem *iface2); - void checkSelection(); - void unselectAllItems(int direction=0); - void setCurrentGroupWidget(GroupWidget *win); - void changeConnectionMode(int mode = -1); - void rename(AbstractBoxItem* item); - void rename(InterfaceItem* item); - GroupWidget* createTopScene(); - GroupWidget* createChildScene(GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL); - void showRaiseWindow(AbstractBoxItem *item); - void showRstClkInter(AbstractBoxItem *item); - void addNewFullGroup(); - - inline GroupWidget* getCurrentGroup() { return currentGroup; } + bool isCurrentProject; -public slots: - - GroupScene* searchSceneById(int id); - BoxItem* searchBlockItemById(int id); - GroupItem* searchGroupItemById(int id); - InterfaceItem* searchInterfaceItemById(int id); - - void removeBlock(AbstractBoxItem* item); - void duplicateBlock(BoxItem* item); - void duplicateInterface(InterfaceItem* item); - void addBlock(int idCategory, int idBlock); - ConnectionItem *addConnection(InterfaceItem *input, InterfaceItem *output); - void removeAllBlockConnections(AbstractBoxItem *block); - void removeConnection(ConnectionItem *conn); - void removeUselessGroupInterfaces(); + /************************** + * scene ops + *************************/ + // getters + GroupScene* getSceneById(int id); + GroupScene* getSceneByName(QString name); + BoxItem* getBoxItemById(int id); + GroupItem* getGroupItemById(int id); + InterfaceItem* getInterfaceItemById(int id); + inline GroupWidget* getCurrentGroup() { return currentGroupWidget; } + inline int getNumberOfScenes() { return groupList.length(); } + // setters + void showRaiseWindow(Context context, BoxItem *item); + void showRstClkIface(Context context, AbstractBoxItem *item); + void showWishboneIface(Context context, AbstractBoxItem *item); + void unselectAllItems(Context context, int direction=0); + void setCurrentGroupWidget(Context context, GroupWidget *win); + void changeConnectionMode(Context context, int mode = -1); + void setSceneCounter(Context context, int value); + // testers + // others + GroupWidget* createTopScene(Context context); + GroupWidget* createChildScene(Context context, GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL); + void destroyScene(Context context, GroupScene* scene); + GroupWidget *addNewEmptyGroup(Context context, GroupScene *scene, bool show = true); + void addNewFullGroup(Context context); + + /************************** + * graph ops + *************************/ + // getters + QMap getAllGroupNames(); + // setters + // testers + // others + void generateVHDL(Context context) throw(Exception); + + /************************** + * block ops + *************************/ + BoxItem* addBlock(Context context, int idCategory, int idBlock, int idScene, QHash clkRstToGen ); + void addClkRstGenBlock(Context context, double frequency); + void removeBoxItem(Context context, BoxItem* item); + void duplicateBoxItem(Context context, BoxItem* item); + void renameFunctionalBlock(Context context, BoxItem* item); + void generateBlockVHDL(Context context, BoxItem* item); + void renameGroupBlock(Context context, GroupItem* item); + void renameSourceBlock(Context context, SourceItem* item); + void removeSourceItem(Context context, SourceItem* item); + void duplicateSourceItem(Context context, SourceItem* item); + + + // interface ops + /*! + * \brief connectInterToGroup + * \param item item is always owned by a BoxItem + * + * This method is called only when the user right clicks on an InterfaceItem (that belongs + * to a BoxItem and if it is NOT connected to an InterfaceItem of the GroupItem) and chooses + * connect to group in the contextual menu. + * Thus, parameter item is always owned by a BoxItem + */ + void connectInterToGroup(Context context, InterfaceItem* item); + /*! + * \brief removeFunctionalInterface + * \param item item is always owned by a BoxItem + * + * This method is called only when the user right clicks on an InterfaceItem (that belongs + * to a BoxItem that represents a functional block and has a multiplicity > 1) and chooses remove in the contextual menu. + * Thus, parameter item is always owned by a BoxItem + */ + void removeFunctionalInterface(Context context, InterfaceItem* item); + /*! + * \brief removeGroupInterface + * \param item item is always owned by a GroupItem + * + * This method is called only when the user right clicks on an InterfaceItem (that belongs + * to a GroupItem and if it is connected only to an inner interface) and chooses remove in the contextual menu. + * Thus, parameter item is always owned by a GroupItem + */ + void removeGroupInterface(Context context, InterfaceItem* item); + void duplicateInterfaceItem(Context context, InterfaceItem* item); + void showProperties(Context context, InterfaceItem *inter); + void renameInterface(Context context, InterfaceItem* item); + void showPatterns(Context context, InterfaceItem* item); + void showModifier(Context context, InterfaceItem* item); + void removeModifier(Context context, InterfaceItem* item); + + // connection ops + bool createConnection(Context context, InterfaceItem *iface1, InterfaceItem *iface2, bool visible = true); + void removeAllBlockConnections(Context context, AbstractBoxItem *item); + void removeConnection(Context context, ConnectionItem *conn); + + + // analysis ops + void findGraphModifications(Context context, FunctionalBlock* block); // find modif so that block has compatible inputs + + // others void showBlocksLibrary(); - void showProperties(InterfaceItem *inter); - void connectInterToGroup(InterfaceItem* item); - void disconnectInterFromGroup(InterfaceItem* item); - void removeGroupInterface(InterfaceItem* item); - void addConnection(); void closeCurrentProject(); @@ -82,8 +165,10 @@ private: // attributes that corresponds to the views MainWindow* mainWindow; QList groupList; - GroupWidget* currentGroup; - GroupWidget *topGroup; + GroupWidget* currentGroupWidget; + GroupWidget *topGroupWidget; + + static int sceneCounter; }; #endif // __DISPATCHER_H__